:root {
  --p1: #FF5C8A;
  --p1-soft: #FFD1DF;
  --p1-dark: #C73061;
  --p2: #3BC5BE;
  --p2-soft: #C7F0EE;
  --p2-dark: #1A8782;

  --sky-1: #B7E7FB;
  --sky-2: #87CEEB;
  --grass-1: #9EE066;
  --grass-2: #6FB942;

  --road: #46464F;
  --road-light: #5A5A65;
  --road-edge: #2E2E36;
  --lane-line: #FFE16B;

  --sun: #FFD93D;
  --cream: #FFF7E1;
  --paper: #FFFDF6;
  --text: #2A2535;
  --text-soft: #5A536A;

  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-num: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

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

html, body, #root {
  height: 100%;
  width: 100%;
}
@supports (height: 100svh) {
  html, body, #root { height: 100svh; }
}

body {
  font-family: var(--font-display);
  color: var(--text);
  background: linear-gradient(180deg, #B7E7FB 0%, #87CEEB 55%, #9EE066 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

button { font-family: inherit; cursor: default; }

/* ─────────── App shell ─────────── */
.app {
  height: 100vh;
  width: 100vw;
  position: relative;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
@supports (height: 100svh) {
  .app { height: 100svh; }
}

/* ─────────── Decor: clouds, sun, hills ─────────── */
.sky-decor {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}
.sun {
  position: absolute;
  top: 30px; right: 60px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FFF2A8, var(--sun) 60%, #FFAA2B);
  box-shadow: 0 0 60px rgba(255, 217, 61, 0.5);
}
.cloud {
  position: absolute;
  background: white;
  border-radius: 100px;
  opacity: 0.92;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.05));
}
.cloud::before, .cloud::after {
  content: ''; position: absolute; background: white; border-radius: 100px;
}
.cloud-a {
  top: 80px; left: 10%; width: 110px; height: 30px;
  animation: drift 60s linear infinite;
}
.cloud-a::before { width: 50px; height: 50px; top: -22px; left: 20px; }
.cloud-a::after  { width: 36px; height: 36px; top: -14px; left: 60px; }
.cloud-b {
  top: 140px; right: 20%; width: 80px; height: 22px;
  animation: drift 80s linear infinite reverse;
}
.cloud-b::before { width: 38px; height: 38px; top: -18px; left: 12px; }
.cloud-b::after  { width: 28px; height: 28px; top: -10px; left: 44px; }
.cloud-c {
  top: 50px; left: 50%; width: 90px; height: 26px;
  animation: drift 100s linear infinite;
}
.cloud-c::before { width: 42px; height: 42px; top: -20px; left: 15px; }
.cloud-c::after  { width: 30px; height: 30px; top: -12px; left: 52px; }

@keyframes drift {
  0%   { transform: translateX(-100px); }
  100% { transform: translateX(calc(100vw + 200px)); }
}

/* ─────────── Setup screen ─────────── */
.setup {
  position: relative; z-index: 2;
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center;
  padding: 24px 32px 32px;
  gap: 18px;
  overflow-y: auto;
}
.setup-title {
  font-size: clamp(40px, 6vw, 72px);
  letter-spacing: 0.02em;
  text-shadow:
    0 4px 0 #fff,
    0 6px 0 var(--p1-dark),
    0 10px 30px rgba(0,0,0,0.15);
  color: var(--p1);
  margin-top: 8px;
  display: flex; align-items: center; gap: 16px;
}
.setup-title .flag { font-size: 0.8em; animation: wave 2s ease-in-out infinite; transform-origin: bottom left; }
@keyframes wave { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

.setup-sub {
  font-size: 20px; color: var(--text-soft);
  background: rgba(255,255,255,0.7);
  border-radius: 999px;
  padding: 6px 18px;
}

.player-cards {
  display: flex; gap: 24px;
  width: 100%; max-width: 1100px;
  justify-content: center;
  flex-wrap: wrap;
}
.pcard {
  flex: 1 1 360px;
  max-width: 480px;
  background: var(--paper);
  border-radius: 28px;
  padding: 20px 22px 22px;
  box-shadow:
    0 0 0 4px #fff,
    0 14px 0 -4px var(--card-shadow, rgba(0,0,0,0.1)),
    0 22px 40px rgba(0,0,0,0.18);
  border: 4px solid var(--card-stroke, transparent);
}
.pcard.p1 { --card-stroke: var(--p1); --card-shadow: var(--p1-dark); }
.pcard.p2 { --card-stroke: var(--p2); --card-shadow: var(--p2-dark); }
.pcard h3 {
  font-size: 26px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px;
}
.pcard.p1 h3 { color: var(--p1-dark); }
.pcard.p2 h3 { color: var(--p2-dark); }
.pcard h3 .badge {
  background: var(--card-stroke);
  color: white;
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 18px;
}

.name-input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 22px;
  padding: 12px 16px;
  border: 3px solid #EEE6F0;
  border-radius: 16px;
  background: white;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.name-input:focus { border-color: var(--card-stroke); }

.avatar-label {
  font-size: 16px; color: var(--text-soft);
  margin: 12px 0 8px;
}
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.avatar-btn {
  appearance: none; border: 3px solid transparent;
  background: #F4EFF7;
  border-radius: 14px;
  font-size: 28px;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, border-color .12s, background .12s;
}
.avatar-btn:hover { background: #EBE3F0; transform: translateY(-2px); }
.avatar-btn.selected {
  border-color: var(--card-stroke);
  background: white;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 0 -2px var(--card-shadow);
}
.avatar-btn.disabled { opacity: 0.3; pointer-events: none; }

.setup-actions {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  margin-top: 4px;
}
.btn-start {
  appearance: none; border: 0;
  background: linear-gradient(180deg, #FFD93D 0%, #FFB347 100%);
  color: #6B3F00;
  font-family: var(--font-display);
  font-size: 36px;
  padding: 14px 56px;
  border-radius: 999px;
  box-shadow:
    0 0 0 4px white,
    0 10px 0 -2px #C77A00,
    0 18px 30px rgba(0,0,0,0.2);
  transition: transform .12s, box-shadow .12s;
  letter-spacing: 0.04em;
}
.btn-start:hover { transform: translateY(-2px); }
.btn-start:active { transform: translateY(4px); box-shadow: 0 0 0 4px white, 0 4px 0 -2px #C77A00, 0 8px 16px rgba(0,0,0,0.15); }
.btn-start:disabled { opacity: 0.5; }

.race-len-control {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.7);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 18px;
  color: var(--text-soft);
}
.race-len-control input[type=range] { accent-color: var(--p1); }

.records-section {
  width: 100%; max-width: 720px;
  background: rgba(255,255,255,0.75);
  border-radius: 20px;
  padding: 14px 20px;
}
.records-section h4 {
  font-size: 20px; color: var(--text-soft);
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.records-list {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 16px;
}
.record-row {
  display: flex; justify-content: space-between;
  padding: 4px 8px;
  border-radius: 8px;
}
.record-row:nth-child(odd) { background: rgba(0,0,0,0.04); }
.record-row .who { display: flex; align-items: center; gap: 6px; }
.records-empty { color: var(--text-soft); font-size: 15px; padding: 8px 0; }

/* ─────────── Countdown ─────────── */
.countdown-overlay {
  position: absolute; inset: 0;
  z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.15);
  pointer-events: none;
}
.countdown-num {
  font-family: var(--font-num);
  font-size: 320px;
  font-weight: 700;
  color: white;
  text-shadow:
    0 0 0 var(--p1-dark),
    0 8px 0 var(--p1-dark),
    0 12px 30px rgba(0,0,0,0.4);
  animation: cd-pop .9s ease-out forwards;
}
.countdown-num.go {
  color: var(--sun);
  font-size: 240px;
  text-shadow:
    0 8px 0 #C77A00,
    0 14px 40px rgba(0,0,0,0.5);
  animation: cd-go 1s ease-out forwards;
}
@keyframes cd-pop {
  0%   { transform: scale(2.2); opacity: 0; }
  20%  { transform: scale(1);   opacity: 1; }
  80%  { transform: scale(1);   opacity: 1; }
  100% { transform: scale(0.5); opacity: 0; }
}
@keyframes cd-go {
  0%   { transform: scale(0.3) rotate(-15deg); opacity: 0; }
  30%  { transform: scale(1.2) rotate(5deg);   opacity: 1; }
  60%  { transform: scale(1)   rotate(0deg);   opacity: 1; }
  100% { transform: scale(1.6) rotate(0deg);   opacity: 0; }
}

/* ─────────── Game screen ─────────── */
.game {
  position: relative; z-index: 2;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(140px, 1fr) auto;
  padding: 14px 12px 16px;
  gap: 8px;
  min-height: 0;
}
.game > * { min-height: 0; min-width: 0; }

/* Top bar */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
}
.scorecard {
  background: var(--paper);
  border-radius: 16px;
  padding: 6px 12px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 0 0 2px white, 0 4px 0 -2px var(--card-shadow), 0 8px 18px rgba(0,0,0,0.12);
  border: 2px solid var(--card-stroke);
  max-width: 100%;
  min-width: 0;
}
.scorecard.p1 { --card-stroke: var(--p1); --card-shadow: var(--p1-dark); }
.scorecard.p2 { --card-stroke: var(--p2); --card-shadow: var(--p2-dark); justify-self: end; flex-direction: row-reverse; }
.scorecard .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--card-stroke);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.15);
}
.scorecard .info { flex: 1; min-width: 0; }
.scorecard.p2 .info { text-align: right; }
.scorecard .name {
  font-size: 18px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scorecard .progress {
  height: 10px; background: #EEE6F0;
  border-radius: 999px; overflow: hidden;
  margin-top: 4px;
}
.scorecard .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--card-stroke) 0%, var(--card-shadow) 100%);
  border-radius: 999px;
  transition: width .4s cubic-bezier(.34,1.6,.64,1);
}
.scorecard.p2 .progress-fill {
  background: linear-gradient(90deg, var(--card-shadow) 0%, var(--card-stroke) 100%);
}

/* Question banner */
.qbanner {
  background: var(--paper);
  border-radius: 18px;
  padding: 6px 22px;
  display: flex; align-items: center; gap: 6px;
  box-shadow: 0 0 0 3px white, 0 5px 0 -2px #FFAA2B, 0 10px 22px rgba(0,0,0,0.18);
  border: 3px solid var(--sun);
  font-family: var(--font-num);
  font-size: clamp(28px, 4.2vh, 44px);
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
  animation: q-pop .35s ease-out;
  justify-self: center;
}
.qbanner .q-mark {
  color: var(--p1);
  display: inline-block;
  animation: q-bounce 1s ease-in-out infinite;
}
@keyframes q-pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
@keyframes q-bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* ─────────── Race track ─────────── */
.track {
  position: relative;
  border-radius: 22px;
  overflow: hidden;
  background:
    linear-gradient(180deg, var(--grass-1) 0%, var(--grass-2) 100%);
  box-shadow: inset 0 0 0 4px white, inset 0 0 0 6px rgba(0,0,0,0.1);
  min-height: 280px;
}

.track-road {
  position: absolute;
  left: 0; right: 0;
  top: 18%; bottom: 18%;
  background: var(--road);
  border-top: 6px solid var(--road-edge);
  border-bottom: 6px solid var(--road-edge);
}
.lane-divider {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 6px;
  transform: translateY(-50%);
  background-image: linear-gradient(90deg, var(--lane-line) 50%, transparent 50%);
  background-size: 60px 6px;
  background-repeat: repeat-x;
  animation: dash 1.5s linear infinite;
  opacity: 0.95;
}
@keyframes dash {
  from { background-position: 0 0; }
  to   { background-position: -60px 0; }
}

.lane-edge {
  position: absolute;
  left: 0; right: 0;
  height: 4px;
  background: repeating-linear-gradient(90deg, white 0, white 20px, transparent 20px, transparent 32px);
}
.lane-edge.top { top: 0; }
.lane-edge.bottom { bottom: 0; }

/* Grass extras */
.grass-decor {
  position: absolute;
  font-size: 32px;
  filter: drop-shadow(0 4px 0 rgba(0,0,0,0.1));
}

/* Cars */
.car-track-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.car-wrap {
  position: absolute;
  width: 120px; height: 70px;
  transition: left .55s cubic-bezier(.34,1.4,.64,1);
}
.car-wrap.lane-1 { top: calc(50% - 60px); }
.car-wrap.lane-2 { top: calc(50% - 10px); }
.car {
  width: 100%; height: 100%;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.25));
  animation: car-idle 1.2s ease-in-out infinite;
}
.car.boosting { animation: car-boost .35s ease-out; }
.car.winner { animation: car-cheer 0.6s ease-in-out infinite; }
@keyframes car-idle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-2px) rotate(-0.5deg); }
}
@keyframes car-boost {
  0%   { transform: translateX(-8px) scale(0.95); }
  40%  { transform: translateX(0)    scale(1.08); }
  100% { transform: translateX(0)    scale(1); }
}
@keyframes car-cheer {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-12px) rotate(3deg); }
}
.boost-flame {
  animation: flame 0.08s steps(2) infinite;
}
@keyframes flame { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }

/* Power-ups */
.power-up {
  position: absolute;
  font-size: 36px;
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  animation: pu-float 1.6s ease-in-out infinite;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.power-up.lane-1 { top: calc(50% - 50px); }
.power-up.lane-2 { top: calc(50% + 0px); }
.power-up.collected { animation: pu-collect .5s ease-out forwards; }
@keyframes pu-float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50%      { transform: translateY(-6px) rotate(4deg); }
}
@keyframes pu-collect {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-40px) scale(2); opacity: 0; }
}
.power-up::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,217,61,0.5) 0%, transparent 65%);
  z-index: -1;
  animation: pu-glow 1s ease-in-out infinite alternate;
}
@keyframes pu-glow { from { opacity: 0.5; } to { opacity: 1; } }

/* Bonus popup over car */
.bonus-pop {
  position: absolute;
  font-family: var(--font-num);
  font-size: 32px;
  font-weight: 700;
  color: var(--sun);
  text-shadow: 0 0 0 #C77A00, 0 4px 0 #C77A00, 0 6px 12px rgba(0,0,0,0.4);
  pointer-events: none;
  animation: bonus-rise 1s ease-out forwards;
}
@keyframes bonus-rise {
  0%   { transform: translate(-50%, 0)     scale(0.6); opacity: 0; }
  20%  { transform: translate(-50%, -10px) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -60px) scale(1);   opacity: 0; }
}

/* Finish line */
.finish-line {
  position: absolute;
  right: 4%; top: 14%; bottom: 14%;
  width: 14px;
  background:
    repeating-conic-gradient(black 0deg 90deg, white 90deg 180deg);
  background-size: 14px 14px;
  border-radius: 3px;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.4);
}
.finish-flag {
  position: absolute;
  right: calc(4% + 6px);
  top: 4%;
  font-size: 40px;
  animation: wave 1s ease-in-out infinite;
  transform-origin: bottom left;
}
.start-line {
  position: absolute;
  left: 3%; top: 14%; bottom: 14%;
  width: 8px;
  background: linear-gradient(180deg, white 0%, white 50%, var(--p1) 50%, var(--p1) 100%);
  border-radius: 2px;
  opacity: 0.7;
}

/* ─────────── Answer panels ─────────── */
.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.apanel {
  background: var(--paper);
  border-radius: 22px;
  padding: 12px 14px 14px;
  border: 4px solid var(--card-stroke);
  box-shadow: 0 0 0 4px white, 0 10px 0 -3px var(--card-shadow), 0 16px 32px rgba(0,0,0,0.15);
  position: relative;
}
.apanel.p1 { --card-stroke: var(--p1); --card-shadow: var(--p1-dark); }
.apanel.p2 { --card-stroke: var(--p2); --card-shadow: var(--p2-dark); }
.apanel-title {
  font-size: 20px;
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
  color: var(--card-shadow);
}
.apanel-title .av {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--card-stroke); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.apanel.p2 .apanel-title { justify-content: flex-end; flex-direction: row-reverse; }

.answer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.ans-btn {
  appearance: none; border: 0;
  font-family: var(--font-num);
  font-weight: 700;
  font-size: clamp(32px, 4vw, 52px);
  padding: 8px 0;
  background: linear-gradient(180deg, var(--btn-c1, #FFF2A8) 0%, var(--btn-c2, #FFD93D) 100%);
  color: var(--btn-num, var(--text));
  border: 4px solid white;
  border-radius: 22px;
  height: clamp(64px, 11vh, 110px);
  display: flex; align-items: center; justify-content: center;
  box-shadow:
    0 0 0 3px var(--card-stroke),
    0 6px 0 -1px var(--card-shadow),
    0 10px 20px rgba(0,0,0,0.12);
  text-shadow: 0 2px 0 rgba(255,255,255,0.7);
  transition: transform .08s, box-shadow .08s, background .15s;
}

/* rainbow color rotation for each answer button */
.apanel .ans-btn:nth-child(1) { --btn-c1: #FFF2A8; --btn-c2: #FFD93D; }   /* yellow */
.apanel .ans-btn:nth-child(2) { --btn-c1: #FFD0B5; --btn-c2: #FF8C42; }   /* orange */
.apanel .ans-btn:nth-child(3) { --btn-c1: #D5F5C8; --btn-c2: #7CDB58; }   /* green */
.apanel .ans-btn:nth-child(4) { --btn-c1: #D9C6FF; --btn-c2: #A66BFF; }   /* purple */

/* P1 numbers in pink, P2 numbers in black */
.apanel.p1 .ans-btn { --btn-num: #C73061; }
.apanel.p2 .ans-btn { --btn-num: #1a1a25; }
.ans-btn:hover { transform: translateY(-2px); box-shadow: 0 0 0 3px var(--card-stroke), 0 8px 0 -1px var(--card-shadow), 0 14px 24px rgba(0,0,0,0.14); }
.ans-btn:active { transform: translateY(4px); box-shadow: 0 0 0 3px var(--card-stroke), 0 2px 0 -1px var(--card-shadow), 0 4px 10px rgba(0,0,0,0.1); }
.ans-btn.wrong {
  animation: shake .4s;
  background: linear-gradient(180deg, #FFE0E6 0%, #FFC8D4 100%);
  pointer-events: none;
  opacity: 0.7;
}
.ans-btn.correct {
  animation: pop .5s ease-out;
  background: linear-gradient(180deg, #DFFFE3 0%, #B6F5C0 100%);
  border-color: #2DAA45;
  box-shadow: 0 6px 0 -1px #1E7830, 0 10px 24px rgba(45,170,69,0.4);
}
.ans-btn:disabled { pointer-events: none; opacity: 0.6; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.panel-flash {
  position: absolute; inset: -4px;
  border-radius: 26px;
  pointer-events: none;
  border: 6px solid var(--card-stroke);
  animation: flash-in 0.6s ease-out;
}
@keyframes flash-in {
  0% { opacity: 0; transform: scale(1.05); }
  30% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

/* ─────────── Game over ─────────── */
.gameover {
  position: absolute; inset: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
.go-card {
  background: var(--paper);
  border-radius: 32px;
  padding: 36px 48px;
  max-width: 640px;
  width: 92%;
  text-align: center;
  box-shadow:
    0 0 0 6px white,
    0 18px 0 -4px var(--winner-shadow, var(--p1-dark)),
    0 30px 80px rgba(0,0,0,0.4);
  border: 6px solid var(--winner-stroke, var(--p1));
  position: relative;
  animation: go-pop .7s cubic-bezier(.34,1.5,.64,1);
}
@keyframes go-pop {
  0%   { transform: scale(0.5) rotate(-10deg); opacity: 0; }
  60%  { transform: scale(1.05) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
.go-trophy {
  font-size: 100px;
  animation: trophy 1.4s ease-in-out infinite;
}
@keyframes trophy {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-10px) rotate(5deg); }
}
.go-winner {
  font-size: 48px;
  color: var(--winner-shadow, var(--p1-dark));
  margin: 8px 0 12px;
}
.go-stat {
  font-size: 20px;
  color: var(--text-soft);
  margin-bottom: 18px;
}
.go-stats-row {
  display: flex; justify-content: space-around;
  gap: 16px;
  background: #FAF6F0;
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 18px;
}
.go-stats-row .col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.go-stats-row .num { font-family: var(--font-num); font-size: 32px; font-weight: 700; }
.go-stats-row .lbl { font-size: 14px; color: var(--text-soft); }
.go-actions {
  display: flex; gap: 12px; justify-content: center;
  flex-wrap: wrap;
}
.btn-again {
  appearance: none; border: 0;
  background: linear-gradient(180deg, var(--p1) 0%, var(--p1-dark) 100%);
  color: white;
  font-family: var(--font-display);
  font-size: 26px;
  padding: 12px 32px;
  border-radius: 999px;
  box-shadow: 0 6px 0 -1px var(--p1-dark), 0 12px 24px rgba(0,0,0,0.2);
}
.btn-again.secondary {
  background: white; color: var(--text);
  box-shadow: inset 0 0 0 3px var(--text-soft), 0 6px 0 -1px #B8B0C2, 0 12px 24px rgba(0,0,0,0.15);
}
.btn-again:active { transform: translateY(3px); box-shadow: 0 2px 0 -1px var(--p1-dark), 0 4px 10px rgba(0,0,0,0.15); }

/* ─────────── Confetti ─────────── */
.confetti {
  position: absolute; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 55;
}
.conf-piece {
  position: absolute;
  width: 12px; height: 16px;
  top: -20px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

/* ─────────── Sound toggle ─────────── */
.sound-toggle {
  position: absolute;
  bottom: 12px; right: 12px;
  z-index: 10;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid white;
  background: rgba(255,255,255,0.85);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 -1px rgba(0,0,0,0.1), 0 6px 12px rgba(0,0,0,0.1);
}
.sound-toggle:active { transform: translateY(2px); }

/* ─────────── Helper utilities ─────────── */
.row { display: flex; align-items: center; gap: 8px; }

/* small screens */
@media (max-width: 900px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; }
  .scorecard { padding: 5px 10px; gap: 8px; }
  .scorecard .avatar { width: 30px; height: 30px; font-size: 18px; }
  .scorecard .name { font-size: 14px; }
  .scorecard .progress { height: 7px; }
  .qbanner { font-size: clamp(22px, 4vw, 32px); padding: 4px 14px; }
  .answer-grid { gap: 6px; }
  .ans-btn { font-size: clamp(26px, 6vw, 38px); border-radius: 14px; height: clamp(54px, 9vh, 86px); }
  .car-wrap { width: 90px; height: 54px; }
  .car-wrap.lane-1 { top: calc(50% - 46px); }
  .car-wrap.lane-2 { top: calc(50% - 8px); }
  .apanel-title { font-size: 14px; margin-bottom: 4px; }
  .apanel-title .av { width: 24px; height: 24px; font-size: 16px; }
  .apanel { padding: 8px 10px 10px; }
}
@media (max-height: 700px) {
  .qbanner { font-size: clamp(24px, 5vh, 36px); padding: 4px 18px; }
  .scorecard { padding: 4px 10px; }
  .scorecard .avatar { width: 32px; height: 32px; font-size: 20px; }
  .scorecard .name { font-size: 15px; }
  .ans-btn { height: clamp(54px, 13vh, 90px); font-size: clamp(28px, 5.5vh, 44px); }
  .apanel { padding: 6px 10px 8px; }
  .apanel-title { font-size: 14px; margin-bottom: 4px; }
}
