:root {
  --bg: #050403;
  --panel: #0d0b07;
  --amber: #ffb000;
  --amber-dim: rgba(255, 176, 0, 0.55);
  --amber-faint: rgba(255, 176, 0, 0.22);
  --red: #ff4b2e;
  --font-display: 'VT323', monospace;
  --font-mono: 'Share Tech Mono', monospace;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--amber);
  font-family: var(--font-mono);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* CRT atmosphere: vignette + faint moving scanlines */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 176, 0, 0.02) 0px,
    rgba(255, 176, 0, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  animation: flicker 4s infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  97% { opacity: 1; }
  98% { opacity: 0.86; }
  99% { opacity: 0.95; }
}

.shell {
  height: 100vh;
  width: min(100vw - 24px, 1480px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--amber-faint);
  padding: 0 4px 8px;
}

.hud-left { display: flex; align-items: baseline; gap: 14px; }

.logo {
  font-family: var(--font-display);
  font-size: 34px;
  letter-spacing: 2px;
  text-shadow: 0 0 12px rgba(255, 176, 0, 0.45);
}

.cursor { animation: blink 1.1s steps(1) infinite; color: var(--red); }

@keyframes blink { 50% { opacity: 0; } }

.sub {
  font-size: 12px;
  color: var(--amber-dim);
  letter-spacing: 1.5px;
}

.hud-stats { display: flex; gap: 26px; }

.stat { display: flex; flex-direction: column; align-items: flex-end; }

.stat-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--amber-dim);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  line-height: 1;
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.35);
}

.stat-value.bump { animation: bump 0.28s ease-out; }

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); color: #ffe9b3; }
  100% { transform: scale(1); }
}

/* ---------- Stage ---------- */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--amber-faint);
  background: var(--panel);
  box-shadow:
    inset 0 0 60px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(255, 176, 0, 0.05);
}

#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- Overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 4, 3, 0.72);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.18s ease;
  cursor: pointer;
}

.overlay.show { opacity: 1; }
.overlay[hidden] { display: none; }

.card {
  text-align: center;
  border: 1px solid var(--amber-faint);
  background: rgba(13, 11, 7, 0.92);
  padding: 34px 52px;
  box-shadow: 0 0 40px rgba(255, 176, 0, 0.08);
  animation: rise 0.28s ease-out;
  max-width: 90%;
}

@keyframes rise {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.card.danger { border-color: rgba(255, 75, 46, 0.4); }
.card.danger h2 { color: var(--red); text-shadow: 0 0 14px rgba(255, 75, 46, 0.4); }
.card.gold { border-color: rgba(255, 217, 119, 0.5); }

.eyebrow {
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--amber-dim);
  margin-bottom: 10px;
}

.card h2 {
  font-family: var(--font-display);
  font-size: 54px;
  letter-spacing: 3px;
  text-shadow: 0 0 16px rgba(255, 176, 0, 0.4);
}

.underscore { animation: blink 1s steps(1) infinite; }

.hint { margin-top: 18px; font-size: 14px; color: var(--amber); }

.dim { margin-top: 8px; font-size: 13px; color: var(--amber-dim); }

kbd {
  border: 1px solid var(--amber-faint);
  padding: 1px 6px;
  font-family: inherit;
  font-size: 12px;
  margin: 0 2px;
  background: rgba(255, 176, 0, 0.06);
}

.tally {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-top: 20px;
}

.tally > div { display: flex; flex-direction: column; gap: 2px; }

.t-label { font-size: 10px; letter-spacing: 2px; color: var(--amber-dim); }
.t-value { font-family: var(--font-display); font-size: 36px; }

.badge {
  display: inline-block;
  margin-top: 16px;
  border: 1px solid var(--amber);
  padding: 4px 14px;
  font-size: 13px;
  letter-spacing: 3px;
  animation: blink 1.2s steps(1) infinite;
}

.stat-value.small { font-size: 16px; }

/* Speed meter — fills amber → red as the game accelerates */
.stat-speed { min-width: 90px; align-items: flex-end; }

.speed-track {
  width: 90px;
  height: 8px;
  margin-top: 7px;
  border: 1px solid var(--amber-faint);
  background: rgba(255, 176, 0, 0.05);
}

.speed-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #b87800, var(--amber));
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(255, 176, 0, 0.4);
}

.speed-fill.maxed {
  background: linear-gradient(90deg, var(--amber), var(--red));
  animation: blink 0.7s steps(1) infinite;
}

#snd-state.muted { color: var(--red); }

/* ---------- Footer ---------- */
.foot {
  display: flex;
  gap: 22px;
  font-size: 12px;
  color: var(--amber-dim);
  border-top: 1px solid var(--amber-faint);
  padding: 8px 4px 0;
}

.foot-right { margin-left: auto; }

.ok { color: var(--amber); animation: blink 2.4s steps(1) infinite; }

.touch-hint { display: none; }

@media (pointer: coarse) {
  .touch-hint { display: inline; color: var(--amber); }
  .foot span:nth-child(2), .foot span:nth-child(3) { display: none; }
}

@media (max-width: 720px) {
  .sub, .foot span:nth-child(2) { display: none; }
  .hud-stats { gap: 14px; }
  .card { padding: 24px 26px; }
  .card h2 { font-size: 38px; }
  .stat-speed, .speed-track { min-width: 0; width: 54px; }
}
