/* LIGHTS OUT — pit wall / broadcast telemetry aesthetic */
:root {
  --bg: #07090c;
  --panel: #0d1015;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9edf2;
  --dim: #85909e;
  --red: #e10600;
  --amber: #ffb400;
  --display: "Unbounded", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; }
html { color-scheme: dark; }
[hidden] { display: none !important; }

body {
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(225, 6, 0, 0.05), transparent 55%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.014) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.014) 0 2px, transparent 2px 7px),
    var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.noise {
  position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.04 0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: screen;
}

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── top bar ─────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 1.2rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem; letter-spacing: 0.22em;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 0.55em; }
.brand .sq { width: 0.6em; height: 0.6em; background: var(--red); }
.season { color: var(--dim); margin-right: auto; }

.gantry {
  display: flex; gap: 0.45rem; align-items: center;
  padding: 0.4rem 0.7rem;
  background: #04050a;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.gantry i {
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  background: #1a1d22;
  transition: background 0.25s, box-shadow 0.25s;
}
.gantry.lit i { background: var(--red); box-shadow: 0 0 10px 2px rgba(225, 6, 0, 0.55); }
.gantry.lit i:nth-child(1) { transition-delay: 0.0s; }
.gantry.lit i:nth-child(2) { transition-delay: 0.35s; }
.gantry.lit i:nth-child(3) { transition-delay: 0.7s; }
.gantry.lit i:nth-child(4) { transition-delay: 1.05s; }
.gantry.lit i:nth-child(5) { transition-delay: 1.4s; }
body.racing .gantry i { background: #1a1d22; box-shadow: none; transition-delay: 0s; }

/* ── hero ────────────────────────────────────────── */
main { flex: 1; display: flex; flex-direction: column; position: relative; z-index: 2; }
.hero {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(1rem, 4vw, 3rem);
  align-items: center;
  padding: clamp(1.2rem, 4vh, 3rem) clamp(1rem, 4vw, 3rem);
}

.eyebrow {
  color: var(--red);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.3em;
  margin-bottom: 1rem;
}
.race-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 5.2vw, 4.4rem);
  line-height: 1.02;
  text-transform: uppercase;
  letter-spacing: -0.01em;
}
.race-name { text-wrap: balance; }
.race-name em { font-style: normal; color: var(--red); display: block; }
.circuit-line {
  margin-top: 0.9rem;
  color: var(--dim);
  font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase;
}
.circuit-line b { color: var(--text); font-weight: 500; }

/* countdown — LED timing board */
.countdown {
  display: flex; gap: clamp(0.4rem, 1vw, 0.8rem);
  margin-top: clamp(1.4rem, 4vh, 2.6rem);
}
.cell {
  flex: 1;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.008));
  border: 1px solid var(--line);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  padding: clamp(0.7rem, 1.8vw, 1.2rem) 0.4rem clamp(0.55rem, 1.4vw, 0.9rem);
  text-align: center;
  position: relative;
}
.cell::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: var(--red); opacity: 0.85;
}
.cell b {
  display: block;
  font-size: clamp(1.9rem, 5.5vw, 4.6rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 180, 0, 0.28);
  line-height: 1;
}
.cell::after { /* LED matrix scanlines */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg,
    transparent 0 2px, rgba(0, 0, 0, 0.16) 2px 3px);
}
.cell i {
  display: block; margin-top: 0.5rem;
  font-style: normal;
  font-size: 0.62rem; letter-spacing: 0.3em;
  color: var(--dim);
}
.cell.ms { flex: 0.85; }
.cell.ms b { font-size: clamp(1.3rem, 3.6vw, 3rem); line-height: 1.52; }
body.racing .cell b { color: var(--red); text-shadow: 0 0 18px rgba(225, 6, 0, 0.35); }

/* track panel */
.hero-track { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
#track-svg { width: 100%; max-width: 30rem; height: auto; aspect-ratio: 1; }
#track-ghost {
  stroke: rgba(255, 255, 255, 0.07);
  stroke-width: 2.6;
}
#track-path {
  stroke: var(--text);
  stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.25));
}
#track-path.draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw 1.5s cubic-bezier(0.6, 0, 0.3, 1) 0.2s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
#sf { fill: #fff; }
#comets circle { fill: var(--red); }
#comets circle:first-child { fill: #fff; }
body.racing #comets { display: none; } /* real cars take over the path */
.track-caption {
  font-size: 0.68rem; letter-spacing: 0.24em; color: var(--dim);
  text-transform: uppercase; text-align: center;
}

/* kerb divider — red/white start-line stripes */
.kerb {
  height: 7px;
  margin: 0 clamp(1rem, 4vw, 3rem);
  background: repeating-linear-gradient(
    -45deg,
    var(--red) 0 14px,
    #d8dbe0 14px 28px
  );
  opacity: 0.75;
  border-radius: 2px;
}

/* ── weekend sessions ────────────────────────────── */
.weekend { padding: clamp(1.2rem, 3vh, 2rem) clamp(1rem, 4vw, 3rem); }
.weekend h2 {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.3em;
  color: var(--dim); margin-bottom: 1.1rem;
}
#local-note { color: var(--dim); font-weight: 400; }
.sessions {
  list-style: none; padding: 0;
  display: flex; gap: 0.6rem; flex-wrap: wrap;
}
.sessions li {
  flex: 1 1 8rem;
  border: 1px solid var(--line);
  border-top: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  padding: 0.7rem 0.8rem;
  display: grid; gap: 0.2rem;
  font-size: 0.72rem;
  transition: opacity 0.3s;
}
.sessions .s-name { font-weight: 700; letter-spacing: 0.14em; }
.sessions .s-when { color: var(--dim); font-size: 0.66rem; letter-spacing: 0.08em; }
.sessions li.done { opacity: 0.35; }
.sessions li.done .s-name { text-decoration: line-through; }
.sessions li.next { border-top-color: var(--red); background: rgba(225, 6, 0, 0.06); }
.sessions li.next .s-name { color: var(--red); }
.sessions li.next .s-name::after {
  content: " · NEXT"; font-weight: 400;
}
.sessions li.live { border-top-color: var(--amber); }
.sessions li.live .s-name { color: var(--amber); }
.sessions li.live .s-name::after {
  content: " · LIVE";
  animation: blink 1.1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.25; } }

/* ── context strip ───────────────────────────────── */
.context {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem;
  padding: 0.9rem clamp(1rem, 4vw, 3rem) 1.2rem;
  border-top: 1px solid var(--line);
  font-size: 0.68rem; letter-spacing: 0.14em; color: var(--dim);
  text-transform: uppercase;
}
.context span { display: inline-flex; align-items: center; gap: 0.5em; }
#wx b, #track-clock b { color: var(--text); font-weight: 500; }
.wind-arrow { display: inline-block; transform: rotate(var(--wd, 0deg));
  color: var(--text); }
.src { margin-left: auto; opacity: 0.5; }

/* ── responsive ──────────────────────────────────── */
@media (max-width: 56rem) {
  .hero { grid-template-columns: 1fr; }
  .hero-track { order: -1; }
  #track-svg { max-width: 15rem; }
  .track-caption { display: none; }
  .season { display: none; }
  .cell.ms { display: none; }
}

/* ── reduced motion ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #track-path.draw { animation: none; stroke-dashoffset: 0; }
  .gantry i { transition: none; }
  .sessions li.live .s-name::after { animation: none; }
}

/* ── fx canvas (warp particles) ──────────────────── */
#fx { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.topbar { position: relative; z-index: 2; }

/* ── live mode layout ────────────────────────────── */
body.racing .countdown { display: none; }
body.racing .race-name { font-size: clamp(1.4rem, 3.2vw, 2.6rem); }
body.racing .cell b { color: var(--amber); }

.panel-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: .8rem; flex-wrap: wrap;
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.3em;
  color: var(--dim); margin-bottom: 0.6rem;
}
.panel-head b { color: var(--amber); letter-spacing: 0.1em; }

/* position tower — broadcast timing wall */
#tower-wrap { max-width: 62rem; }
.tower {
  list-style: none; padding: 0; margin-top: 1rem;
  display: grid; gap: 2px; max-height: 46vh; overflow-y: auto;
  scrollbar-width: thin;
}
.tower li {
  display: grid;
  grid-template-columns: 2.1rem 0.35rem 2.9rem 1fr auto;
  align-items: center; gap: 0.55rem;
  padding: 0.34rem 0.6rem 0.34rem 0;
  background: rgba(255, 255, 255, 0.025);
  border-left: 1px solid var(--line);
  font-size: 0.78rem; cursor: pointer;
  touch-action: manipulation;
}
.tower li.sel { background: rgba(225, 6, 0, 0.1); }
.tower li.ret .tla, .tower li.ret .pos { opacity: .38; }
#lap-age, #drs-state, #grip, #pit-loss { font-style: normal;
  font-size: .62rem; letter-spacing: .18em; color: var(--dim); }
#drs-state.on { color: #35e06c; }
#grip:not(:empty) { color: var(--amber); }
#pit-loss { margin-left: .4rem; }
#comms {
  margin-left: auto; font-family: var(--mono); font-size: .6rem;
  letter-spacing: .22em; color: var(--dim); background: none;
  border: 1px solid var(--line); border-radius: 3px;
  padding: .25em .7em; cursor: pointer;
}
#comms:hover { border-color: var(--amber); color: var(--amber); }
#comms.on { color: var(--red); border-color: var(--red);
  box-shadow: 0 0 10px rgba(225,6,0,.35); }
.sec em { font-style: normal; font-size: .6rem; color: #b45cff;
  margin-left: .3em; font-weight: 700; }
.tower li:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }
.tower .pos { text-align: center; color: var(--dim); font-weight: 700; }
.tower .bar-c { height: 100%; min-height: 1.3rem; }
.tower .tla { font-weight: 700; letter-spacing: 0.1em; }
.tower .gap { color: var(--dim); font-size: 0.68rem;
  font-variant-numeric: tabular-nums; }
.tower .delta {
  font-size: 0.62rem; font-weight: 700; text-align: right;
  min-width: 1.9rem;
}
.tower .delta.up { color: #35e06c; }
.tower .delta.down { color: #ff5a4d; }
.tower .delta.fade { animation: delta-out 4.5s ease forwards; }
@keyframes delta-out { 0%, 55% { opacity: 1; } 100% { opacity: 0; } }
.tower .aux { display: flex; gap: 0.5rem; align-items: center; }
.tower .tyre {
  width: 1.15rem; height: 1.15rem; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 0.6rem; font-weight: 700; color: #000;
}
.tower .fl { /* F1 fastest-lap purple */
  background: #b45cff; color: #0a0614;
  font-size: 0.55rem; font-weight: 700; letter-spacing: 0.08em;
  padding: 0.1em 0.38em; border-radius: 2px;
}
.tower .pits { color: var(--dim); font-size: 0.64rem; }
.tower li.battle .gap { color: var(--amber); font-weight: 700; }
.tower li.battle { border-left-color: var(--amber); }

/* holo track */
.holo { position: relative; width: 100%; max-width: 30rem; }
#track-svg { transition: transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1); position: relative; }
body.racing #track-panel { perspective: 1100px; }
body.racing .holo {
  transform: rotateX(47deg) rotateZ(-3deg);
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: drop-shadow(0 22px 26px rgba(0, 0, 0, 0.65));
  -webkit-box-reflect: below -4px linear-gradient(transparent 62%, rgba(0, 0, 0, 0.5));
}
.holo-grid { /* floor grid, sits just below the track plane */
  display: none;
}
body.racing .holo-grid {
  display: block; position: absolute; inset: -7% -9%; z-index: -1;
  transform: translateZ(-7px);
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 11px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 11px);
  -webkit-mask-image: radial-gradient(52% 52% at 50% 50%, #000 25%, transparent 78%);
  mask-image: radial-gradient(52% 52% at 50% 50%, #000 25%, transparent 78%);
}
.scan { display: none; }
body.racing .scan {
  display: block; position: absolute; left: -4%; right: -4%; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(225, 6, 0, 0.9), transparent);
  box-shadow: 0 0 14px 3px rgba(225, 6, 0, 0.45);
  animation: scan 3.4s linear infinite;
}
@keyframes scan { from { top: -2%; } to { top: 102%; } }
body.racing #track-path {
  stroke: #ff2a1e;
  filter: drop-shadow(0 0 8px rgba(255, 42, 30, 0.5));
}
/* flag-state track tint — whole circuit follows race control */
body[data-flag="yellow"] #track-path {
  stroke: #ffd12f; filter: drop-shadow(0 0 8px rgba(255, 209, 47, 0.55));
}
body[data-flag="red"] #track-path {
  stroke: #ff1a10; filter: drop-shadow(0 0 12px rgba(255, 26, 16, 0.8));
}
body[data-flag="sc"] #track-path {
  stroke: var(--amber); filter: drop-shadow(0 0 8px rgba(255, 180, 0, 0.5));
}
body[data-flag="cheq"] #track-path {
  stroke: #fff; filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.7));
}

/* car trails — fading motion ribbons */
#trails polyline {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
}

/* car pods */
#cars .car { transition: transform 0.9s linear, opacity 0.3s; }
#cars.live .car { transition: opacity 0.3s; } /* raf-driven positions */
#cars circle { filter: drop-shadow(0 0 1.1px); }
#cars .p1 circle { stroke: #fff; stroke-width: 0.5;
  filter: drop-shadow(0 0 1.6px rgba(255, 255, 255, 0.9)); }
#cars text {
  font-family: var(--mono); font-size: 3.1px; fill: #fff;
  paint-order: stroke; stroke: rgba(4, 5, 10, 0.9); stroke-width: 0.55;
  letter-spacing: 0.06em;
}
#cars .dim { opacity: 0.55; }
#cars circle.pit { animation: pitpulse 1.2s ease-out 2; }
@keyframes pitpulse {
  0%, 100% { stroke-width: 0; }
  45% { stroke: #8fd3ff; stroke-width: 0.9;
    filter: drop-shadow(0 0 2.5px rgba(143, 211, 255, 0.9)); }
}

/* leader sonar ping */
#ping {
  fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 0.5;
  opacity: 0; transform-box: fill-box; transform-origin: center;
}
body.racing #ping { animation: ping 1.7s ease-out infinite; }
@keyframes ping {
  0% { transform: scale(0.35); opacity: 0.85; }
  100% { transform: scale(3.4); opacity: 0; }
}

/* telemetry card */
.telem {
  width: 100%; max-width: 30rem;
  border: 1px solid var(--line);
  border-top: 2px solid var(--red);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.01));
  padding: 0.7rem 0.9rem 0.8rem;
}
.t-grid {
  display: grid; grid-template-columns: 1.3fr 0.7fr 0.8fr; gap: 0.6rem;
  align-items: stretch;
}
.t-speed b, .t-gear b {
  font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1;
  color: var(--amber); text-shadow: 0 0 16px rgba(255, 180, 0, 0.3);
}
.t-gear b { color: var(--text); text-shadow: none; }
.t-drs b {
  font-size: 0.85rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--dim); display: inline-block; padding: 0.25em 0.5em;
  border: 1px solid var(--line); border-radius: 3px;
}
.t-drs.open b { color: #35e06c; border-color: #35e06c;
  box-shadow: 0 0 12px rgba(53, 224, 108, 0.35); }
.t-grid i, .telem .t-foot { font-style: normal; font-size: 0.62rem;
  letter-spacing: 0.22em; color: var(--dim); display: block; margin-top: 0.35rem; }
.t-bars { grid-column: 1 / -1; display: grid; gap: 0.32rem; }
/* feed mode has no car telemetry (subscription-gated) — hide the dials */
.telem.timing .t-speed, .telem.timing .t-gear,
.telem.timing .t-drs, .telem.timing .t-bars { display: none; }
.telem.timing .t-grid { grid-template-columns: 1fr; }
.t-bar { display: grid; grid-template-columns: 2.4rem 1fr; align-items: center;
  gap: 0.5rem; font-size: 0.62rem; letter-spacing: 0.2em; color: var(--dim); }
.bar { height: 0.42rem; background: rgba(255, 255, 255, 0.06);
  overflow: hidden; }
.bar i { display: block; height: 100%; width: 0;
  background: var(--amber); transition: width 0.25s linear; }
.bar i.thr { background: #35e06c; }
.bar i.brk { background: var(--red); }
.t-foot { display: flex; gap: 1.2rem; margin-top: 0.6rem; flex-wrap: wrap;
  align-items: center; }
.t-foot b { color: var(--text); }
#t-tyre .tyre-dot { display: inline-grid; place-items: center;
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  color: #000; font-weight: 700; margin-right: 0.3em; }

/* driver headshot in telemetry header */
.t-pic { width: 1.5rem; height: 1.5rem; border-radius: 3px;
  object-fit: cover; object-position: top;
  background: rgba(255, 255, 255, 0.06); margin-left: auto;
  margin-right: 0.6rem; }
#t-driver { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* sector chips — F1 timing colors (pb green / ob purple / slower yellow) */
.t-sectors { grid-column: 1 / -1; display: grid;
  grid-template-columns: repeat(3, 1fr); gap: 0.45rem; margin-top: 0.35rem; }
.sec {
  font-size: 0.64rem; font-weight: 500; letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  padding: 0.3em 0.55em; border: 1px solid var(--line);
  border-radius: 3px; color: var(--dim); text-align: center;
}
.sec.pb { color: #35e06c; border-color: rgba(53, 224, 108, 0.5); }
.sec.ob { color: #b45cff; border-color: rgba(180, 92, 255, 0.55); }
.sec.sl { color: #ffd12f; border-color: rgba(255, 209, 47, 0.45); }

/* radio link + lap-time sparkline */
#t-radio { color: #8fd3ff; text-decoration: none; letter-spacing: 0.18em; }
#t-radio:hover { text-decoration: underline; }
#t-radio:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
#t-spark { margin-left: auto; height: 1.6rem; width: auto; max-width: 46%; }

/* interval-to-car-ahead under the leader gap */
.tower .gap { display: flex; flex-direction: column; line-height: 1.25; }
.tower .iv { font-size: 0.55rem; letter-spacing: 0.08em; color: var(--dim); }
.tower .iv::before { content: "INT "; opacity: 0.6; }

/* race-control ping on an implicated driver's row */
.tower li.rc-hit { border-left-color: #8fd3ff;
  background: rgba(143, 211, 255, 0.07); }

/* pre-race championship context line */
.standings { font-size: 0.66rem; letter-spacing: 0.16em; color: var(--dim);
  margin: 0.7rem 0 0; font-variant-numeric: tabular-nums; }
.standings b { color: var(--text); font-weight: 500; }

/* race control strip */
.rc {
  margin: 0 clamp(1rem, 4vw, 3rem) 0.6rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--line); border-left: 3px solid var(--dim);
  font-size: 0.7rem; letter-spacing: 0.06em;
  display: flex; gap: 0.9rem; align-items: center;
  background: rgba(255, 255, 255, 0.02);
}
.rc-tag { font-size: 0.62rem; letter-spacing: 0.24em; color: var(--dim);
  flex-shrink: 0; }
.rc.yellow { border-left-color: #ffd12f; }
.rc.red { border-left-color: var(--red); }
.rc.sc { border-left-color: var(--amber); }
.rc.green { border-left-color: #35e06c; }
.rc.cheq { border-left-color: #fff; }
.rc.otk { border-left-color: #8fd3ff; }

/* position-flow chart — lives inside the timing column */
.chart {
  margin-top: .8rem; max-width: 62rem;
  border: 1px solid var(--line); border-top: 2px solid var(--amber);
  background: rgba(255,255,255,.02); padding: .6rem .8rem .8rem;
}
.chart .panel-head { margin-bottom: .4rem; }
#pos-chart { width: 100%; height: auto; display: block; }

/* map overlays — marshal ticks, corner numbers, sector-activity arcs */
#corners .mtick { fill: rgba(255,255,255,.5); }
#corners .corner-txt {
  font-family: var(--mono); font-size: 2.2px; fill: rgba(255,255,255,.45);
  letter-spacing: 0;
}
#seclines .secarc {
  fill: none; stroke-width: 1.1; stroke-linecap: butt;
  transition: stroke .5s;
}

/* chequered flag overlay */
.checker {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-conic-gradient(#fff 0 25%, #000 0 50%) 0 0/64px 64px;
  animation: cheq 2.6s ease forwards;
}
@keyframes cheq {
  0% { opacity: 0; } 15% { opacity: 0.92; }
  70% { opacity: 0.55; } 100% { opacity: 0; }
}

/* pointer tilt sheen */
.tilt { transform: perspective(700px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0));
  transition: transform 0.18s ease-out; will-change: transform; }
.tilt::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%),
    rgba(255, 255, 255, 0.07), transparent 45%);
  opacity: 0; transition: opacity 0.2s;
}
.tilt:hover::after { opacity: 1; }
.cell { position: relative; }
.telem { position: relative; }

@media (max-width: 56rem) {
  .tower { max-height: 34vh; }
  body.racing .holo { transform: rotateX(42deg); }
  .t-grid { grid-template-columns: 1fr 1fr; }
  .t-drs { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  body.racing .scan { animation: none; display: none; }
  #cars .car, #cars circle { transition: none; }
  #cars circle.pit, body.racing #ping { animation: none; }
  .bar i { transition: none; }
  #finish { animation: none; }
}

/* ── chequered-flag podium overlay ── */
#finish {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 1rem;
  background: rgba(4, 5, 8, 0.82);
  backdrop-filter: blur(6px);
  animation: fin-in 0.45s cubic-bezier(.2,.8,.2,1) both;
  cursor: pointer;
}
@keyframes fin-in { from { opacity: 0; transform: scale(1.04); } }
.fin-card {
  width: min(34rem, 100%); border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14,16,22,.96), rgba(7,9,12,.96));
  box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(225,6,0,.15);
  padding: 1.6rem 1.4rem 1.1rem;
}
.fin-flag {
  display: flex; align-items: center; gap: .9rem;
  font-weight: 800; letter-spacing: .34em; font-size: .78rem;
  color: var(--text); justify-content: center;
}
.fin-flag i {
  flex: 1; height: 8px;
  background:
    conic-gradient(#fff 25%, #111 0 50%, #fff 0 75%, #111 0) 0 0/16px 8px;
  border: 1px solid var(--line);
}
.fin-race {
  text-align: center; margin: .7rem 0 1.4rem;
  font-size: .66rem; letter-spacing: .3em; color: var(--dim);
}
.fin-row {
  display: grid; grid-template-columns: 2rem 2.6rem 2.6rem 1fr auto;
  align-items: center; gap: .8rem; padding: .55rem .7rem;
  border: 1px solid var(--line); border-left-width: 3px;
  margin-bottom: .45rem; background: rgba(255,255,255,.02);
}
.fin-row.p0 { border-left-color: #ffd12f; background: rgba(255,209,47,.06);
  padding: .8rem .7rem; }
.fin-row.p1 { border-left-color: #c8ccd2; }
.fin-row.p2 { border-left-color: #a05f3c; }
.fin-pos { font-size: 1.15rem; color: var(--amber); font-weight: 800; }
.fin-row img { width: 2.6rem; height: 2.6rem; object-fit: cover;
  border-radius: 2px; background: #111; }
.fin-tla { font-weight: 800; font-size: .95rem; }
.fin-name { font-size: .7rem; letter-spacing: .12em; color: var(--text); }
.fin-team { display: none; }
.fin-gap { font-size: .8rem; color: var(--amber);
  font-variant-numeric: tabular-nums; }
.fin-fl { margin-top: 1rem; text-align: center; font-size: .64rem;
  letter-spacing: .22em; color: #b45cff; }
.fin-hint { margin-top: .9rem; text-align: center; font-size: .55rem;
  letter-spacing: .3em; color: var(--dim); opacity: .7; }

/* ── previous-race results overlay ── */
.res-btn {
  margin-top: .9rem; font-family: var(--mono); font-size: .68rem;
  letter-spacing: .26em; color: var(--amber); background: none;
  border: 1px solid var(--line); border-top-color: var(--amber);
  border-radius: 2px; padding: .6em 1.1em; cursor: pointer;
}
.res-btn:hover { background: rgba(255, 180, 0, 0.08); }
.res-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
#results {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; padding: 1rem;
  background: rgba(4, 5, 8, 0.82); backdrop-filter: blur(6px);
  animation: fin-in 0.4s cubic-bezier(.2,.8,.2,1) both;
}
.res-card {
  width: min(46rem, 100%); max-height: 86vh; overflow: auto;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14,16,22,.97), rgba(7,9,12,.97));
  box-shadow: 0 24px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(225,6,0,.15);
  padding: 1.5rem 1.3rem 1.1rem; cursor: pointer;
}
.res-list { list-style: none; padding: 0; margin: 0; }
.res-row {
  display: grid;
  grid-template-columns: 1.9rem 0.3rem 2.7rem minmax(0, 1.5fr) minmax(0, 1.2fr) auto auto auto;
  align-items: center; gap: .7rem; padding: .42rem .65rem .42rem 0;
  border: 1px solid var(--line); border-left-width: 3px;
  margin-bottom: .3rem; background: rgba(255,255,255,.02);
  font-size: .8rem;
}
.res-row.p0 { border-left-color: #ffd12f; background: rgba(255,209,47,.06); }
.res-row.p1 { border-left-color: #c8ccd2; }
.res-row.p2 { border-left-color: #a05f3c; }
.res-row:not(.p0):not(.p1):not(.p2) { border-left-color: var(--line); }
.res-row .fin-pos { font-size: .95rem; }
.res-tla { font-weight: 800; }
.res-name { font-size: .72rem; letter-spacing: .08em; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-team { font-size: .62rem; letter-spacing: .12em; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-gap { font-size: .74rem; color: var(--amber);
  font-variant-numeric: tabular-nums; text-align: right; }
.res-pts { font-size: .74rem; color: var(--text); text-align: right;
  font-variant-numeric: tabular-nums; }
.res-pts i { font-style: normal; font-size: .58rem; color: var(--dim); }
.res-row.dnf .res-tla, .res-row.dnf .res-name { opacity: .42; }
.res-row.dnf .res-gap { color: var(--red); }
.fl-mark {
  background: #b45cff; color: #0a0614; font-size: .55rem;
  font-weight: 700; letter-spacing: .08em; padding: .1em .38em;
  border-radius: 2px;
}
@media (max-width: 40rem) {
  .res-row { grid-template-columns: 1.6rem 0.3rem 2.4rem minmax(0, 1fr) auto auto; }
  .res-team { display: none; }
  .fl-mark { display: none; }
}
