/* Modern right-facing race cars and animated winner podium. */
.game-grid[hidden] { display: none !important; }
.race-live { position: relative; }

.race-fullscreen {
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 8px;
  padding: 6px 10px;
  color: #fff;
  background: rgba(255,255,255,.12);
  font: 800 .75rem Inter,sans-serif;
  cursor: pointer;
}
.race-fullscreen[hidden] { display: none; }

.race-live.teacher-view > .race-passage,
.race-live.teacher-view > .race-key-instruction,
.race-live.teacher-view > .race-prompt,
.race-live.teacher-view > .race-keyboard { display: none; }

.race-live.teacher-view .race-track { min-height: 420px; }
.race-live.teacher-view .race-lane { height: max(72px,calc(420px / var(--lane-count,6))); }
.race-live.teacher-view .race-track.density-medium .race-lane { height: 52px; }
.race-live.teacher-view .race-track.density-compact {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 0 14px;
}
.race-live.teacher-view .race-track.density-compact .race-lane { height: 44px; margin: 0; }
.race-live.teacher-view .race-track.density-medium .race-car,
.race-live.teacher-view .race-track.density-compact .race-car { width: 70px; height: 34px; bottom: 2px; }
.race-live.teacher-view .race-track.density-compact .race-lane-name { font-size: .65rem; top: 3px; }

.race-stage:fullscreen,
.race-stage.is-fullscreen {
  width: 100vw;
  height: 100vh;
  border: 0;
  border-radius: 0;
  background: #0b1730;
}
.race-stage:fullscreen .race-top,
.race-stage.is-fullscreen .race-top { color: #fff; background: #071a38; }
.race-stage:fullscreen .race-live.teacher-view,
.race-stage.is-fullscreen .race-live.teacher-view { height: calc(100vh - 50px); display: flex; flex-direction: column; }
.race-stage:fullscreen .race-live.teacher-view .race-track,
.race-stage.is-fullscreen .race-live.teacher-view .race-track { flex: 1; min-height: 0; }
.race-stage:fullscreen .race-live.teacher-view .race-track:not(.density-compact) .race-lane,
.race-stage.is-fullscreen .race-live.teacher-view .race-track:not(.density-compact) .race-lane { height: auto; min-height: 54px; flex: 1; }
.race-stage:fullscreen .race-live.teacher-view .race-track:not(.density-compact),
.race-stage.is-fullscreen .race-live.teacher-view .race-track:not(.density-compact) { display: flex; flex-direction: column; }

.race-track {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), transparent 45%),
    #303947;
}

.race-countdown[hidden] { display: none; }
.race-countdown {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(4,18,45,.72);
  backdrop-filter: blur(4px);
}
.race-countdown strong {
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border: 8px solid #fff;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(145deg,#ef3340,#c5162e);
  box-shadow: 0 0 0 12px rgba(255,255,255,.15),0 25px 60px rgba(0,0,0,.4);
  font: 900 4rem Inter,sans-serif;
  animation: countdownPop .55s ease infinite alternate;
}

.race-track::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: .18;
  background: repeating-linear-gradient(105deg, transparent 0 70px, rgba(255,255,255,.18) 72px 74px);
  animation: roadMove 2.2s linear infinite;
}

.race-lane {
  height: 72px;
  border-bottom: 2px dashed rgba(255,255,255,.58);
}

.race-lane-name {
  z-index: 3;
  top: 7px;
  padding: 4px 9px;
  border-radius: 7px;
  color: #fff;
  background: rgba(10,26,52,.84);
}

.race-car {
  z-index: 2;
  bottom: 4px;
  width: 92px;
  height: 42px;
  font-size: 0;
  transition: left .72s cubic-bezier(.2,.8,.2,1);
  filter: drop-shadow(0 5px 5px rgba(0,0,0,.32));
}

.race-car::before {
  content: "";
  position: absolute;
  right: 78%;
  top: 18px;
  width: 42px;
  height: 8px;
  opacity: .55;
  border-radius: 100%;
  background: linear-gradient(90deg, transparent, #8bd8ff);
  filter: blur(2px);
}

.race-car-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.car-shadow {
  stroke: rgba(0,0,0,.32);
  stroke-width: 5;
  stroke-linecap: round;
}

.race-finish {
  z-index: 2;
  width: 18px;
  background: repeating-conic-gradient(#111827 0 25%, white 0 50%) 0/18px 18px;
  box-shadow: -4px 0 14px rgba(0,0,0,.18);
}

.race-live.show-results > :not(.race-status):not(.race-results) {
  display: none;
}

.race-results[hidden] {
  display: none;
}

.race-results {
  position: relative;
  overflow: hidden;
  min-height: 620px;
  padding: 30px 24px 28px;
  text-align: center;
  color: #fff;
  background:
    radial-gradient(circle at 50% 20%, rgba(65,166,255,.7), transparent 32%),
    linear-gradient(145deg, #081b3e, #0d4e98 58%, #112d62);
}

.race-results::before,
.race-results::after {
  content: "🏁";
  position: absolute;
  top: 58px;
  font-size: clamp(3rem, 7vw, 6rem);
  opacity: .75;
  transform: rotate(-12deg);
}

.race-results::before { left: 5%; }
.race-results::after { right: 5%; transform: rotate(12deg); }

.confetti,
.confetti::before,
.confetti::after {
  position: absolute;
  inset: -50px 0 0;
  pointer-events: none;
  content: "";
  background-image:
    radial-gradient(circle, #ffd43b 0 4px, transparent 5px),
    radial-gradient(circle, #ef3340 0 4px, transparent 5px),
    radial-gradient(circle, #54d6ff 0 4px, transparent 5px),
    radial-gradient(circle, #8b5cf6 0 4px, transparent 5px);
  background-size: 93px 117px, 127px 109px, 151px 139px, 181px 133px;
  background-position: 12px 0, 45px 19px, 78px 7px, 21px 31px;
  animation: confettiFall 6s linear infinite;
}

.confetti::before { animation-delay: -2s; transform: translateX(35px); }
.confetti::after { animation-delay: -4s; transform: translateX(-42px); }

.results-eyebrow {
  position: relative;
  z-index: 2;
  margin: 0;
  color: #9ee8ff;
  font: 900 .75rem Inter, sans-serif;
  letter-spacing: .18em;
}

.race-results h2 {
  position: relative;
  z-index: 2;
  margin: 4px 0 24px;
  font: 900 clamp(2.2rem, 6vw, 4rem) Inter, sans-serif;
  letter-spacing: -.04em;
  text-transform: uppercase;
  text-shadow: 0 5px 0 rgba(0,0,0,.18);
}

.race-podium {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: end;
  justify-content: center;
  max-width: 850px;
  margin: 0 auto;
}

.podium-place {
  width: 31%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: podiumRise .75s both cubic-bezier(.2,.85,.25,1.2);
}

.podium-place.place-1 { order: 2; animation-delay: .12s; }
.podium-place.place-2 { order: 1; animation-delay: .3s; }
.podium-place.place-3 { order: 3; animation-delay: .45s; }

.podium-medal {
  font-size: 2rem;
  filter: drop-shadow(0 4px 5px rgba(0,0,0,.25));
}

.podium-car {
  width: min(150px, 85%);
  height: 66px;
  animation: carBounce 1.8s ease-in-out infinite;
}

.podium-block {
  width: 100%;
  min-height: 145px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px 8px;
  border-radius: 14px 14px 0 0;
  box-shadow: inset 0 2px rgba(255,255,255,.5), 0 16px 35px rgba(0,0,0,.25);
}

.place-1 .podium-block { min-height: 210px; background: linear-gradient(135deg,#f7c632,#a86b08); }
.place-2 .podium-block { min-height: 165px; background: linear-gradient(135deg,#dce5ef,#6f8095); }
.place-3 .podium-block { min-height: 135px; background: linear-gradient(135deg,#dd8d50,#84401e); }

.podium-block::before {
  content: attr(data-place);
  display: block;
  font: 900 3.2rem/1 Inter, sans-serif;
  text-shadow: 0 4px 0 rgba(0,0,0,.18);
}

.podium-block strong { font: 900 1.35rem Inter, sans-serif; }
.podium-block span { margin-top: 5px; font: 800 .8rem Inter, sans-serif; }

.other-racers {
  position: relative;
  z-index: 2;
  max-width: 720px;
  margin: 18px auto 0;
  padding: 13px 18px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 14px;
  background: rgba(4,22,55,.58);
}

.other-racers h3 { margin: 0 0 8px; }
.other-racers #raceOtherList > div { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; padding: 7px; text-align: left; }

.results-actions {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}

.results-actions[hidden] { display: none; }
.results-actions .button { min-width: 155px; }

@keyframes roadMove { to { background-position: -150px 0; } }
@keyframes confettiFall { to { background-position: 12px 700px,45px 719px,78px 707px,21px 731px; } }
@keyframes podiumRise { from { opacity: 0; transform: translateY(130px); } }
@keyframes carBounce { 50% { transform: translateY(-5px); } }
@keyframes countdownPop { to { transform: scale(1.08); } }

@media (max-width: 720px) {
  .race-car { width: 70px; height: 34px; }
  .race-lane { height: 62px; }
  .race-results { min-height: 520px; padding: 24px 8px; }
  .race-results::before,.race-results::after { display: none; }
  .podium-place { width: 33.333%; }
  .podium-car { height: 47px; }
  .podium-block { padding: 12px 3px; }
  .place-1 .podium-block { min-height: 175px; }
  .place-2 .podium-block { min-height: 140px; }
  .place-3 .podium-block { min-height: 115px; }
  .podium-block::before { font-size: 2.35rem; }
  .podium-block strong { font-size: 1rem; }
  .podium-block span { font-size: .65rem; }
  .results-actions { flex-direction: column; padding: 0 18px; }
  .results-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .race-track::before,.confetti,.confetti::before,.confetti::after,.podium-place,.podium-car { animation: none !important; }
}
