/* Last Lap Lunge (Formula 1) */
:root { --page-tint: #3a0a0a; --f1-red: #e10600; }
#app { max-width: 980px; margin: 0 auto; padding: 14px 14px 40px; }

/* ---------- Menu ---------- */
.hero { text-align: center; padding: 18px 8px 8px; }
.hero h1 {
  font-family: var(--display); font-size: clamp(2.6rem, 9vw, 4.6rem); font-style: italic;
  text-transform: uppercase; letter-spacing: 2px; margin: 6px 0; text-shadow: 0 4px 0 rgba(0, 0, 0, .35);
}
.hero h1 span { color: var(--f1-red); }
.hero-sub { color: var(--muted); max-width: 520px; margin: 0 auto 6px; line-height: 1.45; }
.hero-date { font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: .85rem; color: var(--gold); }
.lap-board {
  display: inline-flex; flex-direction: column; align-items: center;
  background: #111; border: 3px solid #333; border-radius: 8px; padding: 4px 14px 2px;
  box-shadow: 0 0 0 2px #000, var(--shadow);
}
.lap-board-label { font-size: .6rem; letter-spacing: 2px; text-transform: uppercase; color: #aaa; }
.lap-board-num { font-family: var(--led); font-weight: 700; font-size: 1.7rem; color: var(--led-amber); text-shadow: 0 0 10px rgba(255, 176, 0, .9); animation: blink-lap 1.2s steps(2, start) infinite; }
@keyframes blink-lap { 50% { opacity: .35; } }

.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.mode-card {
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; padding: 18px;
  border-radius: var(--radius); border: 2px solid rgba(255, 255, 255, .1);
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, .04) 0 18px, transparent 18px 36px),
    linear-gradient(160deg, #b30500, #5c0300);
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s;
  position: relative; overflow: hidden;
}
.mode-card::after { /* chequered corner */
  content: ''; position: absolute; right: 0; top: 0; width: 48px; height: 48px; opacity: .22;
  background: conic-gradient(#fff 25%, transparent 0 50%, #fff 0 75%, transparent 0) 0 0 / 16px 16px;
  -webkit-mask: linear-gradient(225deg, #000 40%, transparent 70%); mask: linear-gradient(225deg, #000 40%, transparent 70%);
}
@media (hover: hover) and (pointer: fine) { .mode-card:hover { transform: translateY(-3px); border-color: var(--gold); } }
.mode-card.sprint { background: repeating-linear-gradient(115deg, rgba(255, 255, 255, .04) 0 18px, transparent 18px 36px), linear-gradient(160deg, #3b3f4a, #1b1d23); }
.mode-card.practice { background: repeating-linear-gradient(115deg, rgba(255, 255, 255, .04) 0 18px, transparent 18px 36px), linear-gradient(160deg, #24496f, #142c47); }
.mode-card.played { opacity: .85; }
.mode-tag { font-size: .7rem; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.mode-title { font-family: var(--display); font-size: 1.6rem; letter-spacing: 1px; text-transform: uppercase; }
.mode-teaser { color: #f1e3e3; font-size: .92rem; line-height: 1.4; min-height: 2.8em; }
.mode-status { margin-top: auto; font-weight: 700; color: var(--gold); }

.season-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin-top: 14px; padding: 14px 18px; border-radius: var(--radius);
  background: var(--panel); border: 2px solid rgba(255, 255, 255, .1);
}
.season-strip span:first-child { font-weight: 700; }
.season-strip span:last-child { color: var(--muted); }
.season-strip strong { color: var(--gold); }

/* ---------- Race header ---------- */
.race-head {
  display: grid; grid-template-columns: 1fr auto auto; align-items: stretch;
  background: linear-gradient(180deg, #1d1d2b, #0e0e18); border-radius: 10px; overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid rgba(255, 255, 255, .12); font-weight: 800;
}
.rh-circuit { padding: 10px 14px; display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rh-lap { background: var(--f1-red); color: #fff; padding: 10px 12px; letter-spacing: 2px; display: flex; align-items: center; font-style: italic; animation: pulse 1.2s infinite; }
.rh-pos { background: var(--chalk); color: #111; padding: 6px 16px; font-size: 1.6rem; display: flex; align-items: center; font-variant-numeric: tabular-nums; min-width: 66px; justify-content: center; }
@keyframes pulse { 50% { filter: brightness(1.25); } }

/* ---------- Tower + track ---------- */
.race-layout { display: grid; grid-template-columns: 150px 1fr; gap: 10px; margin-top: 10px; align-items: stretch; }
.tower {
  list-style: none; margin: 0; padding: 6px; border-radius: 10px; background: rgba(5, 8, 14, .85);
  border: 1px solid rgba(255, 255, 255, .1); display: flex; flex-direction: column; justify-content: center; gap: 4px;
  font-family: var(--led); font-weight: 700; font-size: .95rem;
}
.tower li { display: grid; grid-template-columns: 18px 5px 1fr auto; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 5px; animation: pop .35s ease-out; }
.tower li.you { background: rgba(255, 210, 63, .2); color: var(--gold); }
.t-pos { text-align: right; color: var(--muted); }
.tower li.you .t-pos { color: var(--gold); }
.t-bar { height: 16px; border-radius: 2px; }
.t-gap { color: var(--muted); font-size: .8rem; }

.track-wrap {
  position: relative; border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); border: 4px solid #1f1f25; background: #2f7d2a;
}
#track { display: block; width: 100%; height: auto; }
.scroll { animation: scroll-by .32s linear infinite; }
@keyframes scroll-by { to { transform: translateX(-80px); } }
.car, .finish-line { transition: transform .55s cubic-bezier(.4, .1, .3, 1); }
.finish-line.moving { transition-duration: .9s; transition-timing-function: ease-out; }
svg.instant .car, svg.instant .finish-line { transition: none !important; }
.car-inner { animation: hum .18s ease-in-out infinite alternate; }
@keyframes hum { to { transform: translateY(.8px); } }
.car.you .car-tag rect { filter: drop-shadow(0 0 4px rgba(255, 210, 63, .9)); }
.car .smoke { opacity: 0; }
.car.lockup .smoke { animation: smoke .9s ease-out; }
@keyframes smoke { 0% { opacity: .9; } 100% { opacity: 0; transform: translateX(-40px) scale(1.6); } }
.car.boost .car-inner { filter: drop-shadow(-14px 0 6px rgba(255, 210, 63, .55)); }

.track-banner {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(5, 10, 20, .55); text-align: center; padding: 10px; pointer-events: none;
}
.track-banner.pop > * { animation: pop .35s ease-out both; }
.track-banner.pop > *:nth-child(2) { animation-delay: .1s; }
.track-banner.pop > *:nth-child(3) { animation-delay: .2s; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bn-big {
  font-family: var(--display); font-style: italic; font-size: clamp(2.6rem, 10vw, 5.4rem); color: var(--f1-red); letter-spacing: 3px;
  text-shadow: 0 0 18px rgba(225, 6, 0, .6), 0 3px 0 #000; line-height: 1;
}
.bn-big.sm { font-size: clamp(1.7rem, 6vw, 3rem); color: var(--chalk); text-shadow: 0 3px 0 rgba(0, 0, 0, .5); }
.bn-big.good { color: var(--gold); }
.bn-small { font-weight: 700; font-size: clamp(.85rem, 2.6vw, 1.1rem); margin: 6px 0; }

/* ---------- Zones strip ---------- */
.zones { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.zone {
  padding: 5px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; letter-spacing: .3px;
  background: rgba(255, 255, 255, .08); color: var(--muted); border: 1px solid rgba(255, 255, 255, .12);
  transition: background .3s, color .3s;
}
.zone.done { background: rgba(34, 197, 94, .25); color: #bbf7d0; border-color: var(--good); }
.zone.lost { background: rgba(239, 68, 68, .25); color: #fecaca; border-color: var(--bad); }
.zone.now { background: var(--chalk); color: #111; animation: pulse 1s infinite; }
.zone.skip { opacity: .45; }
.zone.flag.done { background: var(--gold); border-color: var(--gold); }
.zone-arrow { color: var(--muted); font-weight: 800; }

/* ---------- Questions ---------- */
.question-panel {
  margin-top: 12px; background: var(--panel); border-radius: var(--radius); padding: 16px;
  border: 1px solid rgba(255, 255, 255, .1); box-shadow: var(--shadow); transition: opacity .3s, filter .3s;
}
.question-panel.dim { opacity: .35; filter: grayscale(.6); pointer-events: none; }
.q-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; font-weight: 700; }
.q-stage { color: var(--gold); }
.q-diff { color: var(--muted); }
.pips { letter-spacing: 1px; }
.pips.d1 { color: var(--good); } .pips.d2 { color: #facc15; } .pips.d3 { color: #fb923c; } .pips.d4 { color: #f43f5e; }
.timer { height: 6px; background: rgba(255, 255, 255, .12); border-radius: 3px; overflow: hidden; margin: 10px 0 4px; }
.timer-fill { height: 100%; width: 100%; background: var(--good); }
.timer-fill.warn { background: var(--bad); }
.q-text { font-size: clamp(1.05rem, 2.8vw, 1.3rem); font-weight: 700; line-height: 1.35; margin: 10px 0 14px; min-height: 2.7em; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.answer {
  font: inherit; color: inherit; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px;
  background: var(--panel-2); border: 2px solid rgba(255, 255, 255, .12);
  transition: transform .1s, border-color .15s, background .2s;
}
@media (hover: hover) and (pointer: fine) { .answers:not(.fresh) .answer:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-1px); } }
.answer:disabled { cursor: default; }
.answer-key {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .12); font-size: .8rem; font-weight: 800;
}
.answer.correct { background: #166534; border-color: var(--good); animation: pop .3s; }
.answer.wrong { background: #7f1d1d; border-color: var(--bad); animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; padding: 12px; }
#overlay-pass { background: radial-gradient(circle, rgba(255, 210, 63, .3), rgba(5, 10, 20, .7) 70%); }
.pass-text {
  font-family: var(--display); font-style: italic; font-size: clamp(2.4rem, 12vw, 8rem); color: var(--gold); letter-spacing: 2px; max-width: 100%;
  text-shadow: 0 6px 0 #a07800, 0 0 40px rgba(255, 210, 63, .8);
  animation: zoom-in .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.pass-sub { font-size: clamp(1.1rem, 4vw, 1.7rem); font-weight: 800; animation: pop .4s .3s both; }
@keyframes zoom-in { from { transform: translateX(-60vw) skewX(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }

#overlay-fail { background: rgba(60, 5, 5, .5); }
.fail-card {
  background: var(--panel); border-radius: var(--radius); padding: 20px 28px; text-align: center;
  box-shadow: var(--shadow); border: 2px solid var(--bad); animation: pop .35s both; max-width: 90vw;
}
.fail-title { font-family: var(--display); font-size: 2rem; letter-spacing: 1px; text-transform: uppercase; color: #ff7a7a; }
.fail-sub { color: #dce6f2; margin-top: 6px; line-height: 1.4; }
.fail-ans { color: var(--gold); font-weight: 700; }

#overlay-flag { background: rgba(5, 10, 20, .7); }
.flag-wave {
  width: min(260px, 60vw); height: min(170px, 40vw); border: 3px solid #fff; border-radius: 4px;
  background: conic-gradient(#111 25%, #fff 0 50%, #111 0 75%, #fff 0) 0 0 / 40px 40px;
  animation: wave .5s ease-in-out infinite alternate; transform-origin: left center;
}
@keyframes wave { from { transform: perspective(400px) rotateY(-14deg) skewY(-3deg); } to { transform: perspective(400px) rotateY(14deg) skewY(3deg); } }
.flag-text { font-family: var(--display); font-size: clamp(2rem, 8vw, 3.6rem); letter-spacing: 2px; margin-top: 16px; animation: pop .4s both; }
.flag-sub { font-size: clamp(1.1rem, 4vw, 1.6rem); font-weight: 800; color: var(--gold); animation: pop .4s .2s both; }

/* ---------- Result ---------- */
.result-card {
  margin: 20px auto; max-width: 560px; text-align: center; padding: 28px 22px;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); border: 2px solid rgba(255, 255, 255, .12);
}
.result-card.res-p1 { border-color: var(--gold); background: linear-gradient(180deg, #4a3a10, var(--panel) 60%); }
.result-card.res-p2, .result-card.res-p3 { border-color: #cbd5e1; }
.result-pos {
  font-family: var(--display); font-style: italic; font-size: clamp(4rem, 18vw, 7rem); line-height: 1; color: var(--chalk);
  animation: zoom-in .6s cubic-bezier(.2, 1.4, .4, 1) both;
}
.res-p1 .result-pos { color: var(--gold); text-shadow: 0 0 30px rgba(255, 210, 63, .6); }
.res-p2 .result-pos { color: #e2e8f0; } .res-p3 .result-pos { color: #e6a15c; }
.result-title { font-family: var(--display); font-size: clamp(1.8rem, 6vw, 2.6rem); text-transform: uppercase; letter-spacing: 1px; margin: 8px 0; }
.res-p1 .result-title { color: var(--gold); }
.result-sub { color: #dce6f2; }
.result-grid { font-size: 1.5rem; line-height: 1.3; margin: 14px 0 6px; font-family: inherit; white-space: pre-wrap; }
.result-points { color: var(--gold); font-weight: 800; margin: 0 0 14px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.result-next { color: var(--muted); font-size: .9rem; margin-top: 16px; }

/* ---------- Phone ---------- */
@media (max-width: 560px) {
  .answers { grid-template-columns: 1fr; }
  .race-layout { grid-template-columns: 1fr; }
  .tower { flex-direction: row; justify-content: space-between; padding: 4px; gap: 2px; font-size: .78rem; order: 2; }
  .tower li { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px; flex: 1; }
  .tower .t-bar { width: 100%; height: 4px; order: -1; }
  .tower .t-gap { display: none; }
  .rh-circuit { font-size: .85rem; padding: 8px 10px; }
  .rh-lap { font-size: .8rem; padding: 8px; letter-spacing: 1px; }
  .rh-pos { font-size: 1.3rem; min-width: 54px; padding: 6px 10px; }
  .zone { padding: 4px 7px; font-size: .66rem; }
}
