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

/* ── Base ───────────────────────────────────────────────────────────────────── */
body {
  background: #0e0e18;
  background-image:
    radial-gradient(ellipse 120% 60% at 50% 0%, #1c1c38 0%, transparent 65%),
    radial-gradient(ellipse 80% 50% at 50% 100%, #0e1a30 0%, transparent 60%);
  color: #f0f0f0;
  font-family: sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Screens ────────────────────────────────────────────────────────────────── */
.screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  min-height: 100vh;
  padding: 16px;
}

.hidden {
  display: none !important;
}

/* ── Typography ─────────────────────────────────────────────────────────────── */
.title {
  font-size: clamp(1.6rem, 6vw, 2.8rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  text-align: center;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-size: clamp(1rem, 4vw, 1.3rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  min-height: 56px;
  padding: 0 32px;
  transition: filter 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active {
  filter: brightness(0.85);
  transform: scale(0.97);
}

/* Start / Restart */
.btn-start {
  background: linear-gradient(135deg, #f0c040, #e09020);
  color: #1a1a1a;
  min-width: 180px;
  box-shadow: 0 4px 20px rgba(240, 160, 32, 0.35);
}

/* Answer buttons container */
#answer-btns {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 460px;
}

.btn-left,
.btn-right {
  flex: 1;
  min-height: 68px;
  font-size: clamp(1.1rem, 5vw, 1.4rem);
  border-radius: 16px;
}

.btn-left {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  box-shadow: 0 4px 16px rgba(21, 101, 192, 0.4);
}

.btn-right {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  color: #fff;
  box-shadow: 0 4px 16px rgba(21, 101, 192, 0.4);
}

/* ── HUD (top status bar) ───────────────────────────────────────────────────── */
#hud {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  max-width: 460px;
}

.hud-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  border-top: 3px solid transparent;
  backdrop-filter: blur(8px);
}

.hud-timer-card   { border-top-color: #f0c040; }
.hud-correct-card { border-top-color: #4caf50; }
.hud-errors-card  { border-top-color: #ef5350; }

.hud-divider {
  display: none;
}

.hud-label {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  opacity: 0.5;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.hud-value {
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  font-weight: 700;
  line-height: 1.1;
}

/* ── Game container ─────────────────────────────────────────────────────────── */
#game-container {
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.07),
    0 12px 48px rgba(0, 0, 0, 0.6),
    0 0 80px rgba(80, 80, 180, 0.08);
}

/* ── Intersection SVG ───────────────────────────────────────────────────────── */
#intersection-svg {
  width: min(78vmin, 420px);
  height: min(78vmin, 420px);
  display: block;
}

/* ── In-game restart button ─────────────────────────────────────────────────── */
.btn-restart-game {
  background: transparent;
  color: rgba(240, 240, 240, 0.35);
  border: 1px solid rgba(240, 240, 240, 0.1);
  border-radius: 10px;
  font-size: 0.82rem;
  min-height: 36px;
  padding: 0 18px;
  letter-spacing: 0.06em;
  transition: color 0.15s, border-color 0.15s;
}

.btn-restart-game:active {
  color: rgba(240, 240, 240, 0.9);
  border-color: rgba(240, 240, 240, 0.35);
}

/* ── Results screen ─────────────────────────────────────────────────────────── */
#results-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 24px 40px;
  width: 100%;
  max-width: 320px;
  backdrop-filter: blur(8px);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.result-label {
  font-size: 1rem;
  opacity: 0.6;
}

.result-value {
  font-size: 2.2rem;
  font-weight: 700;
}

.result-value.correct { color: #66bb6a; }
.result-value.errors  { color: #ef5350; }

/* ── Subtitle ───────────────────────────────────────────────────────────────── */
.subtitle {
  font-size: clamp(0.9rem, 3vw, 1.05rem);
  opacity: 0.55;
  text-align: center;
  max-width: 340px;
  line-height: 1.5;
  margin-top: -8px;
}

/* ── Score bar ──────────────────────────────────────────────────────────────── */
#score-bar-wrap {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#score-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

#score-grade {
  font-size: 1.1rem;
  font-weight: 700;
}

#score-num {
  font-size: 0.9rem;
  opacity: 0.5;
}

#score-bar-track {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

#score-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(to right, #ef5350, #f0c040, #4caf50);
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

#score-bar-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  opacity: 0.35;
  letter-spacing: 0.04em;
}

/* ── How to play ────────────────────────────────────────────────────────────── */
#how-to-play {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 22px 24px;
  max-width: 380px;
  width: 100%;
  backdrop-filter: blur(8px);
}

.htp-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  opacity: 0.9;
}

.htp-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Round feedback flash ───────────────────────────────────────────────────── */
@keyframes flash-correct {
  0%   { background-color: rgba(27, 94, 32, 0.7); }
  100% { background-color: transparent; }
}

@keyframes flash-error {
  0%   { background-color: rgba(183, 28, 28, 0.7); }
  100% { background-color: transparent; }
}

.flash-correct { animation: flash-correct 0.38s ease-out forwards; }
.flash-error   { animation: flash-error   0.38s ease-out forwards; }
