:root {
  --bg: #070a12;
  --grid: #101827;
  --ink: #e6edf7;
  --dim: #6b7a90;
  --accent: #46e0b0;
  --danger: #ff5a6a;
  --ground: #1d2942;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 50% -10%, #16203a 0%, transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- HUD ---------- */

#hud {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--grid);
  font-size: 0.95rem;
}

.hud-left { display: flex; gap: 0.6rem; align-items: baseline; }
.hud-left #clock, .hud-left #gear { color: var(--ink); margin-right: 0.9rem; }

.hud-label {
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
}

#ammo {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--accent);
  margin-left: 0.55rem;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}

#ammo.low { color: var(--danger); }

/* Every shot thumps the ammunition counter. Two beats, the second softer, so
   it reads as a heartbeat rather than a single bounce. `scale` is animated
   rather than `transform` so it composites on its own and cannot clash with
   any layout transform on the counter. */
#ammo.beat { animation: heartbeat 0.62s ease-out; }

@keyframes heartbeat {
  0%   { scale: 1; }
  12%  { scale: 1.28; }
  26%  { scale: 1; }
  40%  { scale: 1.16; }
  62%  { scale: 1; }
}

/* ---------- Field ---------- */

#field {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
}

.question {
  position: absolute;
  top: 0;
  transform: translateY(0);
  translate: -50% 0;
  padding: 0.35rem 0.7rem;
  font-size: 1.45rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--ink);
  /* Opaque, not translucent: questions can cross mid-flight, and a see-through
     box turns both expressions into unreadable mush when they do. */
  background: #121b2f;
  border: 1px solid #2a3a5c;
  border-radius: 7px;
  text-shadow: 0 0 14px rgba(70, 224, 176, 0.28);
}

/* Animate `scale`/`opacity` only. The falling position is driven by inline
   `transform: translateY(...)`, so animating `transform` here would snap the
   question back to the top of the field for the length of the animation. */
.question.hit {
  animation: pop 0.24s ease-out forwards;
}

/* The one question left standing after a ground hit — the reason the run
   ended. Marked in the danger colour and lifted above everything else. */
.question.grounded {
  z-index: 2000;
  color: var(--danger);
  border-color: var(--danger);
  box-shadow: 0 0 26px rgba(255, 90, 106, 0.35);
  text-shadow: 0 0 14px rgba(255, 90, 106, 0.4);
}

@keyframes pop {
  to { scale: 1.6; opacity: 0; }
}

/* ---------- Turret ---------- */

#turret {
  flex: 0 0 auto;
  padding: 0.7rem 1.25rem 1.1rem;
  text-align: center;
  border-top: 2px solid var(--ground);
  background: linear-gradient(180deg, rgba(29, 41, 66, 0.35), transparent);
}

#typed {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-height: 1.2em;
  transition: color 0.15s, text-shadow 0.15s;
}

#typed.hit { color: var(--accent); text-shadow: 0 0 22px var(--accent); }
#typed.miss { color: var(--danger); text-shadow: 0 0 22px var(--danger); }

.hint { margin: 0.15rem 0 0; color: var(--dim); font-size: 0.78rem; }

kbd {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--grid);
  border-radius: 4px;
  background: #0d1424;
  font-family: inherit;
  font-size: 0.9em;
}

/* ---------- Game over ---------- */

#overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1.5rem;
  background: rgba(7, 10, 18, 0.9);
  backdrop-filter: blur(4px);
}

#overlay.visible { display: grid; }

.panel {
  width: min(30rem, 100%);
  padding: 1.75rem 2rem 2rem;
  border: 1px solid var(--grid);
  border-radius: 14px;
  background: #0b1120;
  text-align: center;
}

.panel h1 {
  margin: 0;
  font-size: 1.9rem;
  letter-spacing: 0.04em;
  color: var(--danger);
}

#over-reason { margin: 0.4rem 0 1.1rem; color: var(--dim); font-size: 0.9rem; }

.final { margin: 0 0 1.3rem; font-size: 1rem; color: var(--dim); }
.final strong {
  display: block;
  font-size: 2.6rem;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

#board {
  margin: 0 0 1.3rem;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 0.92rem;
}

#board li {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.32rem 0.5rem;
  border-radius: 6px;
}

#board li.mine { background: rgba(70, 224, 176, 0.11); }
#board li.loading { color: var(--dim); justify-content: center; }

.rank { width: 1.6rem; color: var(--dim); text-align: right; }
.who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pts { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 700; }

.restart { margin: 0; color: var(--dim); font-size: 0.82rem; }
