:root {
  --bg-deep: #0b0f1a;
  --bg-panel: #121a2b;
  --grid-line: #1c2740;
  --cyan: #00ffc8;
  --pink: #ff2e88;
  --yellow: #ffd21f;
  --purple: #8a5cff;
  --red: #ff3b3b;
  --text-dim: #6f7fa8;
  --text-bright: #eaf6ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
}

body {
  font-family: 'Press Start 2P', monospace;
  color: var(--text-bright);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: center;
  image-rendering: pixelated;
}

/* CRT effects */
.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.18) 0px,
    rgba(0, 0, 0, 0.18) 1px,
    transparent 2px,
    transparent 3px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}

.crt-vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 49;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.65) 100%);
}

.cabinet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  background: var(--bg-panel);
  border: 4px solid var(--cyan);
  box-shadow:
    0 0 0 4px var(--bg-deep),
    0 0 0 8px var(--purple),
    0 0 24px rgba(0, 255, 200, 0.35);
  padding: 28px 20px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

/* ---------- screens ---------- */
.screen {
  display: none;
  width: 100%;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.screen.active { display: flex; }

/* ---------- title screen ---------- */
.logo {
  margin: 8px 0 0;
  line-height: 1.6;
}
.logo-line {
  font-size: clamp(20px, 6vw, 32px);
  color: var(--cyan);
  text-shadow:
    3px 3px 0 var(--pink),
    6px 6px 0 var(--purple);
  letter-spacing: 2px;
}

.tagline {
  font-size: 9px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin: 0;
}

.panel {
  width: 100%;
  background: var(--bg-deep);
  border: 3px solid var(--grid-line);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-label {
  display: block;
  font-size: 9px;
  color: var(--yellow);
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 8px;
}

.stepper-value {
  min-width: 40px;
  font-size: 18px;
  color: var(--text-bright);
}

.hint {
  font-size: 8px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}

.blink { animation: blink 1.4s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- pixel buttons ---------- */
.pixel-btn {
  font-family: inherit;
  font-size: 11px;
  color: var(--bg-deep);
  background: var(--cyan);
  border: none;
  padding: 12px 18px;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow:
    inset -4px -4px 0 rgba(0,0,0,0.35),
    inset 4px 4px 0 rgba(255,255,255,0.35),
    4px 4px 0 var(--bg-deep),
    4px 4px 0 4px var(--purple);
  transition: transform 0.05s ease;
}
.pixel-btn:active {
  transform: translate(2px, 2px);
  box-shadow:
    inset -2px -2px 0 rgba(0,0,0,0.35),
    inset 2px 2px 0 rgba(255,255,255,0.35),
    2px 2px 0 var(--bg-deep),
    2px 2px 0 4px var(--purple);
}
.pixel-btn.small {
  padding: 8px 12px;
  font-size: 12px;
  line-height: 1;
}
.pixel-btn.big {
  font-size: 14px;
  padding: 16px 28px;
  background: var(--yellow);
}
.pixel-btn.primary { background: var(--cyan); }

/* ---------- game screen ---------- */
.hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.hud-item {
  flex: 1;
  background: var(--bg-deep);
  border: 3px solid var(--grid-line);
  padding: 8px;
}
.hud-label {
  display: block;
  font-size: 8px;
  color: var(--text-dim);
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.hud-value {
  font-size: 13px;
  color: var(--pink);
}

.target-box {
  width: 100%;
  background: var(--bg-deep);
  border: 3px dashed var(--yellow);
  padding: 10px;
}
.target-value {
  display: block;
  font-size: 26px;
  color: var(--yellow);
  margin-top: 6px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
}

.timer-display {
  position: relative;
  width: 100%;
  font-size: clamp(40px, 13vw, 64px);
  color: var(--cyan);
  background: var(--bg-deep);
  border: 4px solid var(--cyan);
  padding: 18px 10px;
  text-shadow: 0 0 12px var(--cyan);
  letter-spacing: 2px;
}

.ready-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
}
.ready-overlay.show {
  display: flex;
}

/* game screen needs relative positioning for overlay layering via JS toggle on timer area */
#screen-game { position: relative; }

.ready-overlay {
  position: static;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-deep);
  border: 3px solid var(--pink);
  padding: 14px;
  width: 100%;
}
.ready-overlay.show { display: flex; }
.ready-text {
  font-size: 10px;
  color: var(--pink);
  margin: 0;
  letter-spacing: 1px;
}
.countdown-text {
  font-size: 34px;
  color: var(--pink);
  margin: 4px 0 0;
}

.buzz-btn {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--red);
  border: 6px solid #7a0000;
  color: var(--text-bright);
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow:
    inset 0 -10px 0 rgba(0,0,0,0.35),
    inset 0 10px 0 rgba(255,255,255,0.15),
    0 8px 0 #4a0000,
    0 10px 14px rgba(0,0,0,0.5);
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}
.buzz-btn:active:not(:disabled) {
  transform: translateY(6px);
  box-shadow:
    inset 0 -6px 0 rgba(0,0,0,0.35),
    inset 0 6px 0 rgba(255,255,255,0.15),
    0 2px 0 #4a0000;
}
.buzz-btn:disabled {
  filter: grayscale(0.6) brightness(0.6);
  cursor: not-allowed;
}

.result-popup {
  width: 100%;
  background: var(--bg-deep);
  border: 4px solid var(--purple);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.result-popup.hidden { display: none; }
.result-diff {
  font-size: 20px;
  color: var(--pink);
  margin: 0;
}
.result-score {
  font-size: 14px;
  color: var(--yellow);
  margin: 0;
}

/* ---------- scoreboard / game over ---------- */
.section-title {
  font-size: 18px;
  color: var(--cyan);
  margin: 0;
}
.section-title.glow {
  color: var(--pink);
  text-shadow: 0 0 14px var(--pink);
}
.winner-text {
  font-size: 13px;
  color: var(--yellow);
  margin: 0;
}

.scores-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scores-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-deep);
  border: 3px solid var(--grid-line);
  padding: 10px 12px;
  font-size: 11px;
}
.scores-list li.leader {
  border-color: var(--yellow);
  color: var(--yellow);
}

.footer {
  position: fixed;
  bottom: 8px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--text-dim);
  z-index: 2;
}

/* ---------- responsive ---------- */
@media (max-width: 420px) {
  .cabinet { padding: 20px 14px 26px; }
  .buzz-btn { width: 130px; height: 130px; font-size: 15px; }
}
