/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Root / Page ───────────────────────────────────── */
html, body {
  height: 100%;
  background: #0d120d;
  color: #c8e6c5;
  font-family: 'Courier New', Courier, monospace;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  touch-action: none;
}

/* ── Game Root ─────────────────────────────────────── */
#game-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 12px 8px 16px;
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
}

/* ── HUD ───────────────────────────────────────────── */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  width: 100%;
  max-width: 360px;
  gap: 10px;
}

.hud-box {
  flex: 1;
  background: #111a11;
  border: 1px solid #2a4a28;
  border-radius: 10px;
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #4a7a48;
  text-transform: uppercase;
}

.hud-val {
  font-size: 22px;
  font-weight: 700;
  color: #7ee87a;
  line-height: 1.1;
}

/* ── Canvas Wrapper ────────────────────────────────── */
#canvas-wrap {
  position: relative;
  width: 360px;
  height: 360px;
  border-radius: 12px;
  overflow: hidden;
  border: 1.5px solid #2a4a28;
  background: #0a0f0a;
  box-shadow: 0 0 40px rgba(80, 200, 80, 0.08);
  flex-shrink: 0;
}

canvas {
  display: block;
  image-rendering: pixelated;
}

/* ── Overlay ───────────────────────────────────────── */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 8, 0.91);
  transition: opacity 0.2s ease;
  gap: 0;
}

#overlay.hidden {
  display: none;
}

.ov-title {
  font-size: 28px;
  font-weight: 700;
  color: #7ee87a;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(126, 232, 122, 0.4);
}

.ov-sub {
  font-size: 13px;
  color: #5a8a58;
  margin-bottom: 20px;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.02em;
}

.ov-score {
  font-size: 14px;
  color: #7aaa78;
  margin-bottom: 26px;
  letter-spacing: 0.04em;
  min-height: 20px;
}

.ov-btn {
  background: #142914;
  border: 1px solid #4caf50;
  color: #7ee87a;
  font-size: 15px;
  font-family: 'Courier New', Courier, monospace;
  font-weight: 700;
  padding: 11px 32px;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 0 16px rgba(76, 175, 80, 0.2);
}

.ov-btn:hover {
  background: #1e3d1c;
  box-shadow: 0 0 24px rgba(76, 175, 80, 0.35);
}

.ov-btn:active {
  transform: scale(0.96);
  background: #254d23;
}

/* ── D-Pad ─────────────────────────────────────────── */
#dpad {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 52px);
  gap: 7px;
}

.dp-empty {
  /* intentional empty cell */
}

.dp-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111a11;
  border: 1px solid #2a4a28;
  border-radius: 10px;
  cursor: pointer;
  font-size: 22px;
  color: #5aaa58;
  transition: background 0.1s, transform 0.08s, border-color 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.dp-btn:active,
.dp-btn.pressed {
  background: #1c311a;
  border-color: #4caf50;
  transform: scale(0.91);
  color: #7ee87a;
}

.dp-center {
  background: #0e1a0e;
  border-color: #2a4a28;
  font-size: 11px;
  color: #3a6a38;
  letter-spacing: 0.1em;
  font-family: system-ui, sans-serif;
  cursor: default;
}

/* ── Speed Row ─────────────────────────────────────── */
#speed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: #4a7a48;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.04em;
}

#speed-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: #1c3a1c;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

#speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  background: #4caf50;
  border-radius: 50%;
  border: 2px solid #0d120d;
  cursor: pointer;
  transition: transform 0.1s;
}

#speed-slider::-webkit-slider-thumb:active {
  transform: scale(1.25);
}

#speed-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #4caf50;
  border-radius: 50%;
  border: 2px solid #0d120d;
  cursor: pointer;
}

#speed-val {
  min-width: 16px;
  text-align: center;
  font-weight: 700;
  color: #7ee87a;
}

/* ── Keyboard hint ─────────────────────────────────── */
#keyboard-hint {
  font-size: 11px;
  color: #2e4e2c;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.04em;
}

/* ── Responsive: very small screens ───────────────── */
@media (max-height: 680px) {
  #game-root { gap: 8px; padding: 8px 8px 10px; }
  #canvas-wrap { width: 300px; height: 300px; }
  canvas { width: 300px; height: 300px; }
  #dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 46px); gap: 5px; }
  .dp-btn { font-size: 19px; }
  .ov-title { font-size: 24px; }
}

@media (max-height: 560px) {
  #canvas-wrap { width: 260px; height: 260px; }
  canvas { width: 260px; height: 260px; }
  #dpad { display: none; }
  #keyboard-hint { color: #3a6a38; }
}
