* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: 'Courier New', Courier, monospace;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #000;
}

#game-canvas {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  background: #000;
  max-width: 100vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  aspect-ratio: 640 / 480;
  border: 2px solid #fff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

#controls-hint {
  color: #888;
  font-size: 11px;
  margin-top: 8px;
  letter-spacing: 1px;
  text-align: center;
  font-family: 'Courier New', Courier, monospace;
}

/* ---- Touch controls (mobile only) ---- */

#touch-controls {
  display: none;
}

body.touch {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body.touch #touch-controls {
  display: block;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  pointer-events: none;
  z-index: 100;
}

body.touch #controls-hint {
  display: none;
}

/* D-pad */
#dpad {
  position: absolute;
  bottom: 24px;
  left: 20px;
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px 56px;
  gap: 4px;
  pointer-events: auto;
}

.dpad-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}

.dpad-btn.pressed {
  background: rgba(255, 204, 0, 0.45);
  border-color: #ffcc00;
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

/* Action buttons */
#action-buttons {
  position: absolute;
  bottom: 30px;
  right: 24px;
  display: flex;
  gap: 14px;
  pointer-events: auto;
}

.action-btn {
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  font-family: 'Courier New', Courier, monospace;
  color: #fff;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
}

.btn-confirm {
  background: rgba(255, 204, 0, 0.25);
  border: 2px solid rgba(255, 204, 0, 0.6);
}

.btn-cancel {
  background: rgba(255, 100, 100, 0.25);
  border: 2px solid rgba(255, 100, 100, 0.6);
}

.action-btn.pressed {
  background: rgba(255, 204, 0, 0.6);
  border-color: #ffcc00;
}

.btn-cancel.pressed {
  background: rgba(255, 100, 100, 0.6);
  border-color: #ff6464;
}

/* On very small screens, shrink the controls a bit */
@media (max-height: 420px) {
  #dpad {
    grid-template-columns: 46px 46px 46px;
    grid-template-rows: 46px 46px 46px;
    bottom: 14px;
    left: 12px;
  }
  .dpad-btn { font-size: 18px; }
  .action-btn { width: 56px; height: 56px; font-size: 20px; }
  #action-buttons { bottom: 18px; right: 14px; gap: 10px; }
}
