/* Pit Wall. The phone is the pit board: a black board with big white figures, in both themes.
   One type family (Archivo, width axis 62 to 125): its narrow heavy cut is the board, its normal width is reading text.
   Colour comes only from the followed driver's team, F1's flags and the tyre compounds. No gradients, no glass.
   Corners: square on data surfaces (board, tables, tiles), 4 px on controls, 12 px on the top of sheets. */

/* ---------- tokens ---------- */
:root {
  /* Light is the primary theme: warm-neutral paper, near-black ink, rules dark enough to see (3:1 for edges). */
  --bg: #f4f4f2; --raise: #ffffff; --ink: #0c0d0f; --ink-2: #2f3237; --muted: #5a5e65;
  --rule: #c9cac5; --rule-2: #8a8e94;
  --slab: #0b0b0c; --slab-ink: #ffffff; --slab-mute: #a9adb3; --slab-line: #2a2c30; --groove: #2a2c30;
  --me-row: var(--slab);
  /* His row in every list: tinted with his team colour on paper, a dark row in dark mode. */
  --hl: color-mix(in srgb, var(--team) 16%, #ffffff); --hl-ink: var(--ink); --hl-mute: var(--ink-2); --hl-purple: var(--purple); --hl-green: var(--green);
  --bar-bg: var(--bg); --bar-ink: var(--ink);
  --green: #0b7a3e; --green-slab: #44e08a; --yellow: #ffd400; --red: #c80400; --red-slab: #ff6257; --purple: #7a2fd1; --purple-slab: #c28dff;
  --soft: #e10600; --medium: #f2c200; --hard: #9a9ea4; --inter: #2f9e44; --wet: #0067ad;
  --team: #3a3f47; --on-team: #ffffff;
  --r: 4px; --inst: 10px; /* instruments (map, gauges, trace, mini sectors, board) read as fitted panels */
  --fig: clamp(72px, 23vw, 124px); --fig-m: clamp(60px, 19vw, 104px); --fig-s: clamp(46px, 14.5vw, 80px);
  --dock-h: 64px;
  --font: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0e; --raise: #141619; --ink: #f1f1ee; --ink-2: #d0d3d7; --muted: #9a9fa7; --rule: #2a2d33; --rule-2: #5b6068;
    --slab: #000000; --slab-line: #3d4148; --me-row: #24272d; --hl: #24272d; --hl-ink: #fff; --hl-mute: var(--slab-mute); --hl-purple: var(--purple-slab); --hl-green: var(--green-slab); --bar-bg: var(--slab); --bar-ink: #fff;
    --green: #43d17f; --red: #ff5a4f; --purple: #b57bff; --hard: #eceef0;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0e; --raise: #141619; --ink: #f1f1ee; --ink-2: #d0d3d7; --muted: #9a9fa7; --rule: #2a2d33; --rule-2: #5b6068;
  --slab: #000000; --slab-line: #3d4148; --me-row: #24272d; --hl: #24272d; --hl-ink: #fff; --hl-mute: var(--slab-mute); --hl-purple: var(--purple-slab); --hl-green: var(--green-slab); --bar-bg: var(--slab); --bar-ink: #fff;
  --green: #43d17f; --red: #ff5a4f; --purple: #b57bff; --hard: #eceef0;
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; font-size: 100%; }
/* iPhone text size setting (Dynamic Type) scales the whole app. */
@supports (font: -apple-system-body) { html { font: -apple-system-body; } }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 1rem; line-height: 1.4; font-stretch: 100%;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; min-height: 44px; display: inline-flex; align-items: center; background: var(--ink); color: var(--bg); padding: 0 14px; }
.skip:focus { left: 8px; }
.pad { padding: 16px 0; }
.iconbtn svg, .tab svg, .chip svg, .playbtn svg, .nowrow svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; stroke-linejoin: miter; }
svg .fill { fill: currentColor; stroke: none; }

/* ---------- header ---------- */
.sticky { position: sticky; top: 0; z-index: 30; }
.top {
  display: flex; align-items: center; gap: 8px; background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 8px) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--rule);
}
/* The driver chip: a black number cell (white stencil digits) and the team-colour name cell. Large text, so any
   team colour passes contrast with black or white. */
.chip { display: inline-flex; align-items: stretch; height: 44px; padding: 0; border: 0; border-radius: var(--r); overflow: hidden; background: var(--team); color: var(--on-team); }
.chip-num { display: grid; place-items: center; min-width: 44px; padding: 0 8px; background: var(--slab); color: #fff; font-weight: 900; font-stretch: 62%; font-size: 1.45rem; }
.chip-tla { display: grid; place-items: center; padding: 0 4px 0 11px; font-weight: 850; font-stretch: 87%; font-size: 1.2rem; letter-spacing: .01em; }
.chip svg { width: 18px; height: 18px; align-self: center; margin-right: 9px; }
.conn { margin-left: auto; min-height: 44px; display: inline-flex; align-items: center; gap: 7px; padding: 0 2px; border: 0; background: transparent; color: var(--ink); font-family: inherit; font-weight: 750; font-stretch: 87%; font-size: .88rem; white-space: nowrap; }
.conn:disabled { cursor: default; }
.conn.live { color: var(--ink); }
.conn.live::before { content: ""; width: 9px; height: 9px; background: var(--red); }
.conn.wait { color: var(--muted); }
/* When the status is a retry button, it looks like one: underlined, like the other text links. */
.conn[data-act="retry"]:not(:disabled) { text-decoration: underline; text-underline-offset: 3px; }
.conn.bad { color: var(--red); }
/* In replay the pill is a button back to live: same height and corners as the chip, a 2 px outline. */
.conn.replay { border: 2px solid var(--ink); border-radius: var(--r); padding: 0 12px; }
.iconbtn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; background: transparent; color: var(--ink); border-radius: var(--r); flex: none; }
.iconbtn svg { width: 24px; height: 24px; }
.conn[hidden] + .iconbtn { margin-left: auto; }

.flagband { padding: 8px 16px; text-align: center; font-weight: 900; font-stretch: 75%; font-size: 1.3rem; letter-spacing: .02em; text-transform: uppercase; }
.flagband.yellow { background: var(--yellow); color: #0b0b0c; }
.flagband.red { background: #e10600; color: #fff; }

.alert { display: flex; align-items: center; gap: 8px; padding: 10px 6px 10px 16px; background: var(--slab); color: var(--slab-ink); font-weight: 800; font-stretch: 80%; font-size: 1.3rem; line-height: 1.15; border-bottom: 1px solid var(--slab-line); }
.alert-text { flex: 1; }
.alert .iconbtn { color: inherit; }
.alert.tone-sc, .alert.tone-yellow { background: var(--yellow); color: #0b0b0c; }
.alert.tone-red { background: #e10600; color: #fff; }
.alert.tone-green { background: #0b7a3e; color: #fff; }
.alert.tone-purple { background: #6a24c0; color: #fff; }
.alert.tone-win { background: var(--team); color: var(--on-team); }
.alert.tone-up .alert-text::before { content: "▲ "; color: var(--green-slab); }
.alert.tone-down .alert-text::before { content: "▼ "; color: var(--red-slab); }
.alert.tone-pit .alert-text::before { content: "PIT "; color: var(--yellow); }
.toast { background: var(--slab); }
.toastbtn { display: block; width: 100%; min-height: 48px; border: 0; padding: 0 16px; text-align: left; background: var(--team); color: var(--on-team); font-weight: 800; font-stretch: 87%; font-size: 1.05rem; }

/* ---------- layout ---------- */
main { padding-bottom: calc(var(--dock-h) + 24px); }
.view { max-width: 760px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); outline: none; }
main:not([data-tab="live"]) #board, main:not([data-tab="live"]) #aside, .aside:empty { display: none; }

/* ---------- the pit board ---------- */
/* One black board, a livery post down its left edge, plates separated by dark grooves (pressed metal). */
.board {
  position: relative; margin: 12px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  background: var(--groove); color: var(--slab-ink); padding-left: 10px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--slab-line); border-radius: var(--inst);
}
.board::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 10px; background: var(--team); }
.board:empty { display: none; }
.board-head, .slat { background: var(--slab); box-shadow: inset 0 1px 0 rgb(255 255 255 / .06); }
.board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 14px 7px; }
.board-title { color: var(--slab-mute); font-weight: 650; font-stretch: 87%; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-stamp { flex: none; font-weight: 750; font-stretch: 87%; font-size: .85rem; color: var(--slab-ink); }
.board[data-mode="race"] .board-stamp::before, .board[data-mode="quali"] .board-stamp::before, .board[data-mode="practice"] .board-stamp::before {
  content: ""; display: inline-block; width: 7px; height: 7px; background: #e10600; margin-right: 7px; vertical-align: 1px;
}
.board[data-replay="1"] .board-stamp::before { background: var(--slab-mute) !important; }
.board.quiet .board-stamp { color: var(--yellow); }
.board.quiet .board-stamp::before { background: var(--yellow) !important; }
.slat { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; margin-top: 2px; padding: 4px 14px 9px; }
.slat-tag { grid-column: 1 / -1; padding-top: 7px; font-weight: 650; font-stretch: 87%; font-size: .78rem; color: var(--slab-mute); letter-spacing: .01em; }
.slat-main { display: flex; align-items: baseline; gap: 6px; min-width: 0; overflow: hidden; }
.fig { display: inline-block; font-weight: 850; font-stretch: 62%; font-size: var(--fig); line-height: .9; letter-spacing: -.01em; white-space: nowrap; transform-origin: 50% 0; }
.slat[data-len="6"] .fig, .slat[data-len="7"] .fig { font-size: var(--fig-m); }
.slat[data-len="8"] .fig, .slat[data-len="9"] .fig { font-size: var(--fig-s); }
.unit { font-weight: 700; font-stretch: 75%; font-size: 1.1rem; color: var(--slab-mute); }
.slat-side { display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 2px; max-width: 46vw; }
.side { font-weight: 850; font-stretch: 70%; font-size: 2.1rem; line-height: 1; white-space: nowrap; }
.side-label { font-weight: 600; font-stretch: 87%; font-size: .9rem; color: var(--slab-mute); line-height: 1.2; }
.slat-note { grid-column: 1 / -1; font-weight: 750; font-stretch: 87%; color: var(--yellow); padding-top: 2px; }
.slat[data-tone="good"] .side-label { color: var(--green-slab); }
.slat[data-tone="bad"] .side-label, .slat[data-tone="bad"] .slat-note { color: var(--red-slab); }
.slat[data-tone="warn"] .fig { color: var(--yellow); }
.slat[data-tone="purple"] .fig { color: var(--purple-slab); }
.slat[data-tone^="tyre-"] .side { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; border: 6px solid var(--t, #fff); font-size: 1.5rem; font-stretch: 75%; }
.slat[data-tone="tyre-S"] { --t: var(--soft); } .slat[data-tone="tyre-M"] { --t: var(--medium); } .slat[data-tone="tyre-H"] { --t: #f0f0f0; }
.slat[data-tone="tyre-I"] { --t: var(--inter); } .slat[data-tone="tyre-W"] { --t: var(--wet); }
.board-foot { display: flex; gap: 2px; margin-top: 2px; }
.bf { flex: 1; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; background: var(--slab); padding: 8px 14px 9px; min-width: 0; }
.bf-l { font-weight: 650; font-stretch: 87%; font-size: .78rem; color: var(--slab-mute); }
.bf b { font-weight: 850; font-stretch: 75%; font-size: 1.2rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bf[data-tone="warn"] b { color: var(--yellow); } .bf[data-tone="good"] b { color: var(--green-slab); } .bf[data-tone="purple"] b { color: var(--purple-slab); }
/* Short phones (an SE, a landscape-ish window): a tighter board, so the cards below start on the first screen. */
@media (max-height: 720px) and (max-width: 899px) {
  :root { --fig: clamp(52px, 16vw, 92px); --fig-m: clamp(46px, 14vw, 80px); --fig-s: clamp(38px, 12vw, 64px); }
  .slat { padding-bottom: 5px; } .slat-tag { padding-top: 4px; } .board-head { padding-top: 8px; padding-bottom: 5px; }
  .side { font-size: 1.7rem; } .slat[data-tone^="tyre-"] .side { width: 42px; height: 42px; border-width: 5px; font-size: 1.2rem; }
}
.flip { animation: flip .34s cubic-bezier(.2, .8, .3, 1); }
@keyframes flip { from { transform: perspective(500px) rotateX(-75deg); opacity: .25; } to { transform: none; opacity: 1; } }
.board.chequered .board-head { padding-top: 26px; }
.board.chequered::after { content: ""; position: absolute; left: 10px; right: 0; top: 0; height: 14px; background: repeating-conic-gradient(#fff 0 25%, #000 0 50%) 0 0 / 14px 14px; }
@media (prefers-reduced-motion: reduce) { .flip { animation: none; } .switch i, details.roughnote summary::after { transition: none; } }

/* ---------- headings, panels ---------- */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 24px 0 4px; }
.view-head h1 { margin: 0; font-weight: 850; font-stretch: 72%; font-size: 2.3rem; line-height: .95; letter-spacing: -.005em; }
.sub { margin: 6px 0 0; color: var(--muted); }
.panel { margin-top: 24px; padding-top: 10px; border-top: 2px solid var(--ink); }
.panel h2 { margin: 0 0 10px; font-weight: 780; font-stretch: 85%; font-size: 1.2rem; line-height: 1.2; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h2 { margin: 0; }
.h-sub { margin-left: 8px; font-weight: 550; color: var(--muted); font-size: .9rem; font-stretch: 100%; }
.more { font-weight: 650; text-underline-offset: 3px; min-height: 44px; display: inline-flex; align-items: center; }
.fine { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }
.source { color: var(--muted); font-size: .8rem; margin: 24px 0 0; }
.conditions { display: flex; gap: 18px; color: var(--muted); margin: 20px 0 0; }
.conditions b { color: var(--ink); }
.conditions .rain b { color: var(--wet); }
.note-bar { margin: 16px 0 0; padding: 10px 12px; background: var(--slab); color: var(--slab-ink); font-weight: 600; font-size: .92rem; }

/* ---------- controls ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border: 2px solid var(--ink); border-radius: var(--r); background: transparent; color: var(--ink);
  font-weight: 750; font-stretch: 87%; font-size: 1rem; text-decoration: none; white-space: nowrap;
}
.btn.primary { background: var(--team); border-color: var(--team); color: var(--on-team); }
.btn.on { background: var(--ink); color: var(--bg); }
.btn.wide { width: 100%; }
.btn.ghost { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn.small { padding: 0 12px; font-size: .92rem; }
.btn:active { transform: translateY(1px); }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; max-width: 100%; }
.seg button { appearance: none; border: 0; border-left: 2px solid var(--ink); background: transparent; min-height: 40px; padding: 0 14px; font-weight: 700; font-stretch: 87%; white-space: nowrap; }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg.scroll { display: flex; overflow-x: auto; scrollbar-width: none; margin-bottom: 10px; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg.scroll button { flex: 1 0 auto; }
/* Many sessions: separate pills on as many rows as they need, none hidden off the edge. */
.seg.wrap { display: flex; flex-wrap: wrap; gap: 6px; border: 0; border-radius: 0; overflow: visible; margin-bottom: 10px; }
.seg.wrap button, .seg.wrap button:first-child { border: 2px solid var(--ink); border-radius: var(--r); flex: 0 1 auto; }
.select { min-height: 44px; width: 100%; padding: 0 10px; border: 2px solid var(--ink); border-radius: var(--r); background: var(--raise); color: var(--ink); }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { font-size: .78rem; font-weight: 650; color: var(--muted); text-align: left; padding: 4px 6px; border-bottom: 2px solid var(--ink); }
td { padding: 9px 6px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
td.p, th.p { width: 2.4em; padding-left: 4px; }
td.p { font-weight: 850; font-stretch: 75%; font-size: 1.1rem; }
td.b, th.b { width: 10px; padding: 0 2px 0 4px; }
.teambar { display: block; width: 5px; height: 22px; background: var(--c, var(--muted)); }
/* The name column gives way first, so tables never push the page sideways (150% text on a 360 px phone). */
td.t { width: 100%; max-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
td.g, th.g, td.n, th.n, td.s, th.s, td.pts, th.pts, td.behind, th.behind { text-align: right; white-space: nowrap; }
td.g { color: var(--ink-2); }
td.s { width: 3em; color: var(--muted); }
td.pts { font-weight: 800; width: 3.5em; }
td.behind { color: var(--muted); width: 3.5em; }
td.ty { white-space: nowrap; width: 4.2em; }
tr.me td { background: var(--hl); color: var(--hl-ink); border-bottom-color: var(--hl); }
tr.me td.behind, tr.me td.s, tr.me .nm, tr.me small, tr.me .ko, tr.me.out td { color: var(--hl-mute); }
tr.me .tyre { color: var(--hl-ink); }
tr.out td { color: var(--muted); }
tr.skip td { border-top: 3px double var(--rule-2); }
.tla { font-weight: 800; }
.t .tla ~ .nm { margin-left: 8px; }
.nm { color: var(--muted); font-weight: 500; }
.classif small, .tower small { font-size: .78rem; color: var(--muted); font-weight: 600; }
.classif small.note { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.inpit { display: inline-block; background: var(--yellow); color: #0b0b0c; font-weight: 850; font-stretch: 75%; font-size: .8rem; padding: 1px 5px; }
.ko { color: var(--muted); font-weight: 650; }
.zero { color: var(--muted); font-weight: 500; }
tr.me .zero, .tw-row.me .zero { color: var(--hl-mute); }
/* Narrow phones: surnames only in tables ("Verstappen", not "Max Verstap…"). */
@media (max-width: 420px) { .fn { display: none; } }

/* tyres: a ring in the compound colour with its letter, so it never relies on colour alone */
.tyre { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; border: .23em solid var(--t, var(--muted)); font-weight: 850; font-stretch: 75%; font-size: .8rem; line-height: 1; vertical-align: middle; }
.t-S { --t: var(--soft); } .t-M { --t: var(--medium); } .t-H { --t: var(--hard); } .t-I { --t: var(--inter); } .t-W { --t: var(--wet); }
.tyre-age { margin-left: 6px; font-weight: 650; }

/* ---------- live ---------- */
.flags { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 2px; }
.flag { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-weight: 750; font-size: 1.05rem; }
.flag::before { content: ""; flex: none; width: 12px; height: 12px; background: var(--ink); }
.flag.good::before { background: var(--green); }
.flag.warn::before { background: var(--yellow); outline: 1px solid #0b0b0c; }
.flag.plain { font-weight: 550; color: var(--ink-2); padding-left: 22px; }
.flag.plain::before { display: none; }
.panel.sync { background: var(--slab); color: var(--slab-ink); border-top: 0; padding: 16px; }
.panel.sync p { margin: 0 0 12px; }
.panel.sync .btn.primary { width: 100%; min-height: 56px; font-size: 1.15rem; }
.rj-row { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; }
.rj-p { display: block; font-weight: 900; font-stretch: 62%; font-size: 4rem; line-height: .88; }
.rj-change { display: block; color: var(--muted); font-size: .9rem; }
.rj-around { display: grid; gap: 4px; font-size: 1.05rem; }
.rj-around b { font-weight: 850; }
.rejoin.cheap { border-top-color: var(--green); }
.rejoin.cheap .fine b { color: var(--green); }
.rc, .moments { list-style: none; padding: 0; margin: 0; }
.rc li, .moments li { display: grid; grid-template-columns: 3.4em 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.rc time, .m-when { color: var(--muted); font-weight: 650; }
.rc li.mine span { font-weight: 750; }
.moments .m-text { font-weight: 650; }
.moments .tone-up .m-text::before { content: "▲ "; color: var(--green); }
.moments .tone-down .m-text::before { content: "▼ "; color: var(--red); }
.moments .tone-sc .m-text::before, .moments .tone-yellow .m-text::before { content: "■ "; color: #c9a300; }
.moments .tone-red .m-text::before { content: "■ "; color: var(--red); }
.moments .tone-pit .m-text::before { content: "PIT "; font-weight: 900; font-stretch: 75%; }
.moments .tone-purple .m-text::before { content: "■ "; color: var(--purple); }
.moments .tone-win .m-text, .moments .tone-green .m-text { font-weight: 800; }

/* ---------- weekend ---------- */
.weekend-head { justify-content: flex-start; align-items: center; flex-wrap: nowrap; }
.round { display: grid; place-items: center; flex: none; min-width: 3.3rem; height: 3.3rem; padding: 0 6px; background: var(--slab); color: var(--slab-ink); font-weight: 900; font-stretch: 62%; font-size: 1.6rem; }
.round.small { min-width: 2.5rem; height: 2rem; font-size: 1.05rem; }
.track-card svg.track { display: block; width: 100%; max-height: 360px; margin: 4px auto 0; }
.track-under { fill: none; stroke: var(--ink); stroke-width: 26; stroke-linejoin: round; stroke-linecap: round; }
.track-line { fill: none; stroke: var(--team); stroke-width: 7; stroke-linejoin: round; stroke-linecap: round; }
.track-start { fill: var(--bg); stroke: var(--ink); stroke-width: 7; }
.corner { fill: var(--muted); font-family: var(--font); font-weight: 750; font-size: 32px; text-anchor: middle; dominant-baseline: central; paint-order: stroke; stroke: var(--bg); stroke-width: 10px; stroke-linejoin: round; }
.facts { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--muted); }
.facts b { color: var(--ink); }
.tz-note { margin: -4px 0 6px; }
.sessions { list-style: none; padding: 0; margin: 0; }
.sessions li { display: grid; grid-template-columns: 2.8em 3.2em minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--rule); }
.s-day { color: var(--muted); font-weight: 600; }
.s-time { font-weight: 850; }
.s-name { font-weight: 650; }
.s-state { color: var(--ink-2); font-size: .9rem; text-align: right; white-space: nowrap; }
.sessions li.done { color: var(--muted); }
.sessions li.done .s-time, .sessions li.done .s-name { font-weight: 550; }
.sessions li.done .s-state { color: var(--muted); }
.sessions li.live { background: var(--me-row); color: var(--slab-ink); margin: 0 -10px; padding: 11px 10px; border-bottom-color: var(--slab); }
.sessions li.live .s-state, .sessions li.live .s-day { color: var(--slab-ink); }
.sessions li.live .s-state b::before { content: ""; display: inline-block; width: 7px; height: 7px; background: #e10600; margin-right: 6px; vertical-align: 1px; }
.sessions.compact li { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0; }
.sessions.compact .s-when { grid-column: 1; color: var(--muted); font-size: .9rem; }
.sessions.compact .s-state { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.ahead { list-style: none; padding: 0; margin: 0; }
.ahead li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.a-name { font-weight: 700; }
.a-when { color: var(--ink-2); }

/* ---------- radio ---------- */
.clips { list-style: none; padding: 0; margin: 12px 0 0; }
.clips li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.clips li:not(:has(.said)) { padding: 6px 0; }
.playbtn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 2px solid var(--ink); border-radius: 50%; background: transparent; color: var(--ink); }
.playbtn svg { width: 20px; height: 20px; }
.clips li.playing .playbtn { background: var(--ink); color: var(--bg); }
.clip-head { display: flex; align-items: center; gap: 8px; min-height: 44px; min-width: 0; }
.clip-head .tla { flex: none; }
.clip-head time { font-weight: 650; }
.lap-tag { min-width: 2em; font-weight: 800; font-stretch: 75%; font-size: .9rem; color: var(--muted); }
.lap-head { display: block !important; position: sticky; top: var(--top-h, 60px); z-index: 2; background: var(--bg); padding: 16px 0 6px !important; margin-bottom: 8px; font-weight: 780; font-stretch: 85%; font-size: .85rem; color: var(--ink-2); border-bottom: 2px solid var(--ink) !important; box-shadow: 0 8px 0 var(--bg); }
.clips li { scroll-margin-top: calc(var(--top-h, 60px) + 48px); }
.pre-toggle { appearance: none; border: 0; background: none; padding: 0; min-height: 32px; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.pre-toggle::after { content: "▾"; display: inline-block; margin-left: 6px; text-decoration: none; }
.pre-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }
.clips.fold-pre li.pre { display: none; }
.clip-len { min-width: 2.4em; font-variant-numeric: tabular-nums; font-weight: 700; font-size: .85rem; color: var(--ink-2); }
.clip-len:empty { visibility: hidden; }
.late { color: var(--muted); font-size: .85rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.star { margin-left: auto; min-width: 44px; min-height: 44px; border: 0; background: none; font-size: 1.35rem; color: var(--ink); }
.bb-btn { appearance: none; border: 0; background: none; padding: 13px 2px; margin: -13px 0; min-height: 44px; font: inherit; color: var(--ink-2); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.tx-src { margin: 3px 0 0; font-size: .74rem; color: var(--muted); letter-spacing: .01em; }
q.said { display: block; margin: 2px 0 0; font-size: 1.1rem; line-height: 1.35; quotes: "“" "”"; }
p.said.rough { margin: 2px 0 0; font-size: .98rem; color: var(--muted); }
p.said.probable { color: var(--ink-2); font-size: 1.02rem; }
.rough-tag { display: inline-block; margin-right: 4px; padding: 0 5px; border: 1.5px solid var(--rule-2); border-radius: 2px; font-weight: 750; font-stretch: 87%; font-size: .72rem; line-height: 1.5; color: var(--ink-2); vertical-align: 1px; }
.said.rough:not(.probable) .rough-tag { border-style: dashed; color: var(--red); border-color: var(--red); }
.roughnote { margin: 0; font-size: .82rem; color: var(--muted); }
details.roughnote summary { cursor: pointer; display: inline-flex; align-items: center; min-height: 44px; color: var(--ink-2); font-size: .82rem; text-decoration: underline; text-underline-offset: 3px; list-style: none; }
details.roughnote summary::-webkit-details-marker { display: none; }
details.roughnote summary::after { content: "▾" / ""; display: inline-block; margin-left: 6px; text-decoration: none; transition: transform .15s; }
details.roughnote[open] summary::after { transform: rotate(180deg); }
.commentary .btn { min-width: 6em; }

/* ---------- season ---------- */
.year-line { margin: 2px 0 16px; font-size: 1.15rem; line-height: 1.5; font-weight: 500; }
.year-line b { font-weight: 900; font-stretch: 62%; font-size: 1.45rem; line-height: 1; }
.rounds { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(2.7rem, 1fr)); gap: 4px; }
.rd { display: grid; justify-items: center; padding: 5px 0 4px; border: 1px solid var(--rule); }
.rd-n, .rd-name { font-size: .7rem; color: var(--muted); font-weight: 600; line-height: 1.2; }
.rd-p { font-weight: 900; font-stretch: 62%; font-size: 1.4rem; line-height: 1.05; }
.rd.win { background: var(--team); border-color: var(--team); color: var(--on-team); }
.rd.win .rd-n, .rd.win .rd-name { color: inherit; }
.rd.podium { border: 2.5px solid var(--ink); }
.rd.points { border: 1px solid var(--rule-2); }
.rd.none .rd-p { color: var(--muted); }
.rd.dnf .rd-p { color: var(--red); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 0; }
.legend .k { display: inline-block; width: 12px; height: 12px; margin: 0 5px 0 12px; }
.legend .k:first-child { margin-left: 0; }
.k.win { background: var(--team); } .k.podium { border: 2.5px solid var(--ink); } .k.points { border: 1px solid var(--rule-2); }
.k.dnf { width: auto; height: auto; color: var(--red); font-weight: 900; line-height: 1; }
.statement { margin: 0 0 12px; font-weight: 750; font-stretch: 87%; font-size: 1.3rem; line-height: 1.25; }
.tf-row { display: grid; grid-template-columns: 3em minmax(0, 1fr) 3em; gap: 10px; align-items: center; margin: 8px 0; }
.tf-row span { font-weight: 800; }
.tf-row b { text-align: right; }
.tf-track { position: relative; height: 16px; background: var(--rule); }
.tf-fill { position: absolute; top: 0; bottom: 0; left: 0; }
.tf-fill.lead { background: var(--ink); }
.tf-fill.me { background: var(--team); }
.tf-fill.max { background: repeating-linear-gradient(135deg, var(--team) 0 3px, transparent 3px 7px); }
.title-fight.out .statement { color: var(--ink-2); }

/* ---------- dock: radio bar, replay bar, tabs ---------- */
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--bg); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); }
/* In light the bars sit on the paper (the board stays the one black object); in dark they are slabs. */
.nowbar, .replaybar { background: var(--bar-bg); color: var(--bar-ink); border-bottom: 1px solid var(--rule); }
.nowbar .btn, .replaybar .btn { border-color: var(--bar-ink); color: var(--bar-ink); }
.nowbar .btn.primary, .replaybar .btn.primary { background: var(--bar-ink); border-color: var(--bar-ink); color: var(--bar-bg); }
.nowrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px; }
.nowrow span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrow svg { width: 18px; height: 18px; vertical-align: -3px; margin-right: 8px; }
.replaybar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); }
.replaybar .btn { flex: none; padding: 0 12px; }
.replaybar .btn.step { width: 44px; padding: 0; font-size: 1.6rem; line-height: 1; }
.replaybar #rp-speed { min-width: 52px; }
.rp-where { margin-left: auto; font-weight: 850; font-stretch: 75%; font-size: 1.15rem; white-space: nowrap; }
.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; max-width: 640px; margin: 0 auto; }
.tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; padding: 6px 0 4px; color: var(--muted); text-decoration: none; font-weight: 650; font-size: .76rem; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--ink); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 4px; left: 32%; right: 32%; height: 3px; background: var(--ink); }

/* ---------- sheets ---------- */
dialog.sheet {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; padding: 0; border: 0; width: 100%; max-width: 640px; max-height: 92dvh;
  background: var(--bg); color: var(--ink); border-radius: 12px 12px 0 0; overflow: auto; overscroll-behavior: contain;
}
dialog.sheet.full { inset: 0; max-height: none; height: 100dvh; max-width: none; border-radius: 0; }
dialog::backdrop { background: rgb(0 0 0 / .55); }
/* First run: nothing is chosen yet, so the screen behind does not show a driver as if he were. */
#onboard::backdrop { background: var(--bg); }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: 12px 8px 10px 16px; background: var(--bg); border-bottom: 2px solid var(--ink); }
.sheet-head h2 { margin: 0; font-weight: 850; font-stretch: 72%; font-size: 1.8rem; }
.sheet-body { padding: 0 16px calc(32px + env(safe-area-inset-bottom)); }
/* Settings on an 8-point rhythm: 24 above a section, 16 under its heading. */
.set { padding: 24px 0; border-bottom: 1px solid var(--rule); }
.set:last-child { border-bottom: 0; }
.set h3 { margin: 0 0 16px; font-weight: 780; font-stretch: 85%; font-size: 1.15rem; }
.set > .seg { display: flex; width: 100%; margin-top: 16px; }
.set > .seg button { flex: 1 1 0; padding: 0 4px; }
.row-switch { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; }
.rs-label { display: block; font-weight: 650; }
.rs-hint { display: block; color: var(--muted); font-size: .85rem; }
.row-seg { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 0; }
/* A switch: a round knob that travels, filled with the team colour when on. */
.switch { position: relative; flex: none; width: 54px; height: 32px; padding: 0; border: 2px solid var(--ink); border-radius: 16px; background: transparent; }
.switch i { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border: 2px solid var(--ink); border-radius: 50%; background: transparent; transition: transform .15s ease-out; }
.switch[aria-checked="true"] { background: var(--team); border-color: var(--team); }
.switch[aria-checked="true"] i { transform: translateX(22px); background: var(--on-team); border-color: var(--on-team); }
/* Pit loss: one three-cell control across the width. */
.stepper { display: grid; grid-template-columns: 56px 1fr 56px; border: 2px solid var(--ink); border-radius: var(--r); overflow: hidden; }
.stepper .btn { border: 0; border-radius: 0; min-height: 56px; padding: 0; font-size: 1.5rem; }
.stepper output { display: grid; place-content: center; text-align: center; border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); padding: 4px 0; }
.stepper output b { font-weight: 900; font-stretch: 62%; font-size: 2rem; line-height: 1; }
.stepper output span { color: var(--muted); font-size: .8rem; }
.stepper-auto { margin-top: 8px; }

/* Driver picker: timing-tower rows (face on the team colour, stencil number, name, team), divider rules. */
.drivers { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr; border-top: 1px solid var(--rule); }
.drivers li { border-bottom: 1px solid var(--rule); }
.driver { display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) auto; align-items: center; column-gap: 12px; width: 100%; min-height: 3.75rem; padding: 0 12px 0 0; border: 0; background: transparent; color: var(--ink); text-align: left; position: relative; }
.d-pic { position: relative; display: block; align-self: stretch; min-height: 3.75rem; grid-row: 1 / span 2; background: var(--c, var(--muted)); overflow: hidden; }
.d-pic .d-face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 10%; }
.d-pic .d-num { position: absolute; left: 0; bottom: 0; display: grid; place-items: center; min-width: 1.65rem; height: 1.4rem; padding: 0 .25rem; background: var(--slab); color: #fff; font-weight: 900; font-stretch: 62%; font-size: 1rem; }
.d-pic:not(:has(img)) .d-num { inset: 0; width: 100%; height: 100%; background: transparent; color: var(--on, #fff); font-size: 1.6rem; }
.d-text { display: grid; align-content: center; min-width: 0; padding: 8px 0; }
.d-tla { font-weight: 850; font-stretch: 87%; font-size: 1.05rem; line-height: 1.15; }
.d-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-team { color: var(--muted); font-size: .82rem; text-align: right; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.driver[aria-pressed="true"] { background: var(--slab); color: var(--slab-ink); box-shadow: inset 0 0 0 2px var(--c, var(--team)); }
.driver[aria-pressed="true"] .d-team { color: var(--slab-mute); }
/* The selected driver: a black row with the team post on the left, like the board. */
.driver[aria-pressed="true"]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; z-index: 1; background: var(--c, var(--team)); box-shadow: 1px 0 0 var(--slab); }
@media (min-width: 700px) {
  .drivers { grid-template-columns: 1fr 1fr; column-gap: 24px; border-top: 0; }
  .drivers li:nth-child(-n+2) { border-top: 1px solid var(--rule); }
}

.onboard { max-width: 720px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 32px) 16px calc(env(safe-area-inset-bottom) + 128px); }
.ob-kicker { display: inline-block; margin: 0; padding: 4px 9px; background: var(--slab); color: var(--slab-ink); font-weight: 900; font-stretch: 62%; font-size: 1.25rem; }
.ob-title { margin: 16px 0 12px; font-weight: 900; font-stretch: 66%; font-size: 3rem; line-height: .92; letter-spacing: -.01em; }
.ob-lede { margin: 0 0 24px; color: var(--ink-2); font-size: 1.05rem; max-width: 34em; }
.ob-foot { position: fixed; left: 0; right: 0; bottom: 0; z-index: 2; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--bg); border-top: 2px solid var(--ink); }
.ob-foot .btn[disabled] { background: transparent; color: var(--muted); border: 2px dashed var(--muted); box-shadow: none; cursor: default; }
.ob-loading { padding: 24px 0; min-height: 50vh; font-size: 1rem; color: var(--ink-2); }
.boot { max-width: 760px; margin: 24px auto; padding: 0 16px; color: var(--muted); }
.boot .btn { margin-left: 6px; }
/* Tabbing never leaves the focused control under the sticky header or the dock. */
html { scroll-padding-top: calc(var(--top-h, 60px) + 8px); scroll-padding-bottom: calc(var(--dock-h, 64px) + 12px); }
/* The list scrolls clear of the sticky footer when tabbing through it. */
#onboard { scroll-padding-bottom: 150px; }
/* Landscape phones: a smaller title, so the list has room. */
@media (max-height: 480px) { .onboard { padding-top: 12px; } .ob-title { font-size: 2rem; margin: 6px 0; } .ob-lede { margin-bottom: 10px; font-size: .95rem; } .ob-foot { padding-top: 8px; padding-bottom: 8px; } .ob-foot .fine { display: none; } .ob-foot .btn { min-height: 44px; } #onboard { scroll-padding-bottom: 80px; } }
.ob-foot .btn { min-height: 54px; font-size: 1.1rem; max-width: 688px; margin: 0 auto; display: flex; }
.ob-foot .fine { text-align: center; }

/* ---------- narrow phones ---------- */
@media (max-width: 380px) {
  :root { --fig: clamp(60px, 19vw, 124px); --fig-m: clamp(52px, 16vw, 104px); --fig-s: clamp(42px, 13vw, 80px); }
  .slat { padding-bottom: 7px; }
  .slat-tag { padding-top: 5px; }
  .side { font-size: 1.8rem; }
}
/* Narrow or large text: the team moves under the name instead of disappearing. */
@media (max-width: 420px) {
  .d-text { padding-bottom: 0; }
  .d-team { grid-column: 2; grid-row: 2; text-align: left; max-width: none; padding-bottom: 8px; }
}

/* ---------- wider screens ---------- */
@media (min-width: 900px) {
  :root { --fig: 112px; --fig-m: 96px; --fig-s: 76px; }
  body { padding-left: 92px; }
  .dock { top: 0; right: auto; width: 92px; border-top: 0; border-right: 1px solid var(--rule); padding-top: 84px; }
  .tabs { grid-template-columns: 1fr; grid-auto-flow: row; }
  .tab { min-height: 72px; }
  .tab[aria-current="page"]::before { top: 18%; bottom: 18%; left: auto; right: -1px; width: 3px; height: auto; }
  .nowbar, .replaybar { position: fixed; left: 92px; right: 0; bottom: 0; border-bottom: 0; border-top: 1px solid var(--rule); }
  main { padding-bottom: 80px; }
  /* Live: the board and the cars around him on the left, everything else on the right, top edges aligned. */
  main[data-tab="live"] { display: grid; grid-template-columns: minmax(380px, 470px) minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 32px; max-width: 1280px; margin: 0 auto; padding: 0 28px 80px; align-items: start; }
  main[data-tab="live"] #board { grid-column: 1; margin: 24px 0 0; }
  main[data-tab="live"] #aside { grid-column: 1; }
  main[data-tab="live"] #aside > :first-child { margin-top: 24px; }
  main[data-tab="live"] .view { grid-column: 2; grid-row: 1 / span 2; max-width: none; margin: 0; padding: 0; }
  main[data-tab="live"] .view > :first-child:not(.sr), main[data-tab="live"] .view > .sr + * { margin-top: 24px; }
  .view { max-width: 820px; }
  dialog.sheet:not(.full) { inset: 0; margin: auto; max-height: 86dvh; border-radius: 12px; }
  .slat-side { max-width: 220px; }
  /* Reading lines stay readable in the wide right column. */
  .view .fine, .view .said, .view .rj-around, .rc li span, .roughnote { max-width: 68ch; }
}
@media (min-width: 1000px) {
  main[data-tab="weekend"] .view, main[data-tab="season"] .view { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 36px; max-width: 1180px; align-items: start; }
  main[data-tab="weekend"] .view > *, main[data-tab="season"] .view > * { grid-column: 1 / -1; }
  main[data-tab="weekend"] .view > .track-card { grid-column: 1; grid-row: span 2; }
  main[data-tab="weekend"] .view > section[aria-labelledby="ss-h"], main[data-tab="weekend"] .view > section[aria-labelledby="ah-h"] { grid-column: 2; }
  main[data-tab="season"] .view > .year, main[data-tab="season"] .view > section[aria-labelledby="dr-h"] { grid-column: 1; }
  main[data-tab="season"] .view > .title-fight, main[data-tab="season"] .view > section[aria-labelledby="co-h"] { grid-column: 2; }
}
@media (forced-colors: active) {
  .board, .slat, .teambar, .tyre, .switch { forced-color-adjust: none; }
}

/* ---------- v2: depth ---------- */
:root { --gain: rgb(11 122 62 / .16); --loss: rgb(200 4 0 / .14); --ms-purple: #a64dff; --ms-green: #19c26b; --ms-yellow: #ffd400; --ms-none: #2a2c30; --ms-pit: #6f747b; }
.count { font-weight: 650; color: var(--muted); font-stretch: 100%; font-size: .95rem; margin-left: 6px; }
.note-bar.yellow { background: var(--yellow); color: #0b0b0c; }
.chips { gap: 0; }

/* Mini sectors: a timing-screen strip on the slab, three groups, each cell fills as it's crossed. */
.ministrip { border-radius: var(--inst); display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--slab); padding: 8px; margin-top: 8px; }
.ms-sector { display: flex; gap: 2px; }
.ms { display: inline-block; flex: 1; height: 12px; background: var(--ms-none); transition: background-color .35s ease; }
.ms-other { background: #6f747b; }
.ms-purple { background: var(--ms-purple); } .ms-green { background: var(--ms-green); } .ms-yellow { background: var(--ms-yellow); } .ms-pit { background: var(--ms-pit); }
.ms-key > span, .ms-key .k { white-space: nowrap; }
.seg.scroll { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.ms-key { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 6px 0 0; font-size: .8rem; color: var(--muted); align-items: center; }
.ms-key .ms { flex: none; width: 14px; height: 8px; margin-right: 5px; }
.sectors { margin-top: 10px; }
.sectors th[scope="row"] { font-weight: 850; font-stretch: 75%; font-size: 1rem; color: var(--ink); border-bottom: 1px solid var(--rule); width: 2.6em; }
.sectors td { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sectors .sv { font-weight: 800; font-size: 1.05rem; }
.sectors .sd, .sectors .sb, .sectors .st { text-align: right; color: var(--ink-2); }
.sectors th:nth-child(n+3) { text-align: right; }
.sectors small { color: var(--muted); font-weight: 600; }
.sec-purple .sv { color: var(--purple); } .sec-green .sv { color: var(--green); }
.sec-purple th[scope="row"], .sec-green th[scope="row"], .sec-yellow th[scope="row"] { box-shadow: inset 4px 0 0 var(--ms-yellow); padding-left: 10px; }
.sec-purple th[scope="row"] { box-shadow: inset 4px 0 0 var(--ms-purple); } .sec-green th[scope="row"] { box-shadow: inset 4px 0 0 var(--ms-green); }
.last { font-weight: 800; font-variant-numeric: tabular-nums; }
.last.purple { color: var(--purple); } .last.green { color: var(--green); }
.lapfacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 20px; margin: 14px 0 0; }
.lapfacts div { border-top: 1px solid var(--rule); padding: 9px 0 10px; }
.lapfacts div.bench dd { color: var(--ink-2); }
.lapfacts dt { font-size: .8rem; color: var(--muted); font-weight: 650; }
.lapfacts dd { margin: 2px 0 0; font-weight: 850; font-stretch: 80%; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.lapfacts small { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); font-stretch: 100%; }

/* The battle: three rows, the followed car between its rivals. */
.battle-list { list-style: none; margin: 8px 0 0; padding: 0; }
.bt { display: grid; grid-template-columns: 3em 1fr auto 100px 4.4em; align-items: center; gap: 8px; padding: 10px 8px 10px 12px; border-bottom: 1px solid var(--rule); box-shadow: inset 4px 0 0 var(--c); }
.om.off { background: transparent; color: var(--muted); border: 1.5px solid var(--rule-2); }
.bt.me { background: var(--hl); color: var(--hl-ink); border-bottom-color: var(--hl); }
.bt-pos { font-weight: 850; font-stretch: 75%; font-size: 1.1rem; }
.bt-tla { font-weight: 850; font-size: 1.05rem; }
.bt-gap { font-weight: 850; font-stretch: 80%; font-size: 1.35rem; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bt-gap small { font-size: .8rem; color: var(--muted); }
.bt-tyre { text-align: right; white-space: nowrap; }
.bt .age { margin-left: 5px; font-weight: 700; }
.om { background: var(--purple); color: #fff; font-weight: 800; font-stretch: 85%; padding: 3px 8px; font-size: .85rem; }
.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--ink); }
.spark.good path { stroke: var(--green); } .spark.good circle { fill: var(--green); }
.spark.bad path { stroke: var(--red); } .spark.bad circle { fill: var(--red); }
@media (max-width: 380px) { .bt { grid-template-columns: 2.6em 1fr auto 72px 4em; gap: 6px; } .spark { width: 72px; } }

/* Stewards: each incident with its state, his own name marked, track-limit strikes. */
.incidents { list-style: none; margin: 6px 0 0; padding: 0; }
.inc { display: grid; grid-template-columns: 8.4rem minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.inc-state { white-space: nowrap; font-weight: 800; font-stretch: 85%; font-size: .82rem; padding: 2px 6px; justify-self: start; border: 2px solid currentColor; line-height: 1.2; }
.inc.open .inc-state { color: var(--ink); background: var(--yellow); border-color: var(--yellow); color: #0b0b0c; }
.inc.noted .inc-state { background: var(--rule); border-color: var(--rule); color: var(--ink); }
.inc.after .inc-state { background: transparent; border-color: var(--yellow); color: var(--ink); }
.inc.pen .inc-state { background: var(--red); border-color: var(--red); color: #fff; }
.inc.served .inc-state { color: var(--ink-2); }
.inc.clear .inc-state { color: var(--muted); border-color: var(--rule-2); }
.inc-body { line-height: 1.35; }
.inc-body b .me { background: var(--team); color: var(--on-team); padding: 0 3px; }
.inc-dec { display: block; font-weight: 800; color: var(--red); }
.inc.served .inc-dec { color: var(--ink-2); }
.inc-time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.owe { margin: 8px 0 0; padding: 10px 12px; background: var(--red); color: #fff; font-weight: 650; }
.strikes { display: flex; align-items: center; gap: 4px; margin-top: 12px; font-weight: 650; }
.strikes i { width: 22px; height: 10px; background: var(--rule); }
.strikes i.on { background: var(--ink); }
.strikes i.last { background: transparent; border: 2px dashed var(--rule-2); height: 10px; }
.strikes i.last.on { background: var(--red); border-color: var(--red); }
.strikes span { margin-left: 8px; color: var(--ink-2); font-size: .92rem; }

/* Race control log: a coloured mark per kind (F1's flag colours), his own lines in his team colour. */
.rclog { list-style: none; margin: 4px 0 0; padding: 0; }
.rclog li { display: grid; grid-template-columns: 10px 3.1em 2.3em minmax(0, 1fr); gap: 0 8px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.rclog li.mine { box-shadow: inset 3px 0 0 var(--team); padding-left: 6px; }
.rc-mark { width: 10px; height: 10px; align-self: start; margin-top: .42em; background: var(--rule-2); }
.rclog li.cleared .rc-mark { background: transparent !important; box-shadow: inset 0 0 0 2px var(--yellow) !important; outline: none; }
.more-btn { margin-top: 10px; }
tr.gaprow td { padding: 0; height: 8px; border-bottom: 2px dotted var(--rule-2); }
.rclog li.rc-pre { display: block; padding: 0; border-bottom: 0; }
.rc-pre summary { padding: 12px 0; font-weight: 750; cursor: pointer; border-bottom: 1px solid var(--rule); min-height: 44px; box-sizing: border-box; }
.rc-pre .rclog { margin: 0; }
.g-yellow .rc-mark { background: var(--yellow); outline: 1px solid #0b0b0c; } .g-dyellow .rc-mark { background: var(--yellow); box-shadow: 0 0 0 2px var(--bg), 0 0 0 3px var(--yellow); }
.g-red .rc-mark { background: var(--red); } .g-green .rc-mark { background: var(--green); } .g-blue .rc-mark { background: #1f6fd6; }
.g-cheq .rc-mark { background: repeating-conic-gradient(var(--ink) 0 25%, var(--bg) 0 50%) 0 0 / 5px 5px; outline: 1px solid var(--ink); }
.g-bw .rc-mark { background: linear-gradient(135deg, var(--ink) 50%, var(--bg) 50%); outline: 1px solid var(--ink); }
.g-stewards .rc-mark, [class*="g-st-"] .rc-mark { border-radius: 50%; }
.g-st-noted .rc-mark { background: var(--muted); } .g-st-inv .rc-mark { background: var(--yellow); box-shadow: 0 0 0 1px #0b0b0c66; }
.g-st-after .rc-mark { background: transparent; box-shadow: inset 0 0 0 2px var(--yellow); }
.g-st-pen .rc-mark { background: var(--red); } .g-st-served .rc-mark { background: var(--ink); }
.g-st-nfa .rc-mark { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.rc-key { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 6px 0 0; font-size: .82rem; color: var(--ink-2); }
.rc-key span { display: inline-flex; align-items: center; gap: 6px; } .rc-key .rc-mark { display: inline-block; margin-top: 0; } .g-limits .rc-mark { background: var(--ink); transform: rotate(45deg) scale(.8); }
.rclog time { color: var(--muted); font-size: .85rem; }
.rc-lap { font-weight: 800; font-stretch: 80%; font-size: .85rem; color: var(--ink-2); }
.rc-text { grid-column: 4; min-width: 0; overflow-wrap: break-word; text-wrap: pretty; }

/* Strategy chart: compound blocks to scale. */
.strategy { list-style: none; margin: 8px 0 0; padding: 0; }
.strategy li { display: grid; grid-template-columns: 2em 3.2em 1fr; gap: 8px; align-items: center; padding: 5px 0; }
.strategy li.me { background: var(--hl); color: var(--hl-ink); }
.st-pos { font-weight: 850; font-stretch: 75%; text-align: right; }
.st-tla { font-weight: 800; box-shadow: inset 3px 0 0 var(--c); padding-left: 7px; }
.st-bar { display: block; height: 20px; }
.st-bar i { position: absolute; top: 0; bottom: 0; box-shadow: inset -2px 0 0 var(--bg); display: flex; align-items: center; padding-left: 4px; font-style: normal; font-weight: 800; font-stretch: 75%; font-size: .72rem; color: #0b0b0c; overflow: hidden; white-space: nowrap; transform-origin: left; animation: grow-x .6s cubic-bezier(.2,.7,.2,1) both; }
.st-S { background: var(--soft); color: #fff !important; } .st-M { background: var(--medium); } .st-H { background: #e9ebee; outline: 1px solid var(--rule-2); outline-offset: -1px; } .st-I { background: var(--inter); color: #fff !important; } .st-W { background: var(--wet); color: #fff !important; }
.st-bar i.used { background-image: repeating-linear-gradient(135deg, rgb(0 0 0 / .18) 0 3px, transparent 3px 7px); }
.st-bar i.same { opacity: .6; }
.st-bar { position: relative; }
.strategy.has-now .st-bar::after { content: ''; position: absolute; top: -5px; bottom: -5px; left: var(--now); width: 2px; background: var(--ink); opacity: .55; }
.strategy li.me .st-bar::after { background: var(--hl-ink); }
.strategy li.st-axis { padding-top: 2px; }
.st-axis-name { font-size: .72rem; color: var(--muted); font-weight: 650; }
.st-ticks { position: relative; height: 1.1em; border-top: 1px solid var(--rule-2); }
.st-ticks b { position: absolute; top: 2px; transform: translateX(-50%); font-size: .72rem; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-ticks b:first-child { transform: none; } .st-ticks b:last-child { transform: translateX(-100%); }
.st-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 0; font-size: .8rem; color: var(--ink-2); }
.st-legend span { display: inline-flex; align-items: center; gap: 6px; }
.st-legend i { display: inline-block; width: 16px; height: 10px; }
.st-legend i.same { opacity: .6; }
.st-legend i.used { background-image: repeating-linear-gradient(135deg, rgb(0 0 0 / .18) 0 3px, transparent 3px 7px); }
.st-nowkey { width: 2px !important; height: 14px !important; background: var(--ink); opacity: .55; }
.pc-out { stroke: var(--muted); stroke-width: 1.6; fill: none; } .pc-out.main { stroke: var(--c, var(--ink)); stroke-width: 2.4; }

/* Speed-trap and other bar lists. */
.bars { list-style: none; margin: 8px 0 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 2em 3.2em 1fr 4.6em; gap: 8px; align-items: center; padding: 4px 0; }
.bars li.me { font-weight: 800; background: var(--hl); color: var(--hl-ink); box-shadow: 0 0 0 4px var(--hl); }
.bars li.me small { color: var(--hl-mute); }
.bars li.gap { border-top: 3px double var(--rule-2); }
.b-pos { text-align: right; font-weight: 800; font-stretch: 75%; color: var(--muted); }
.b-tla { font-weight: 800; }
.b-track { height: 14px; background: var(--rule); }
.b-track i { display: block; height: 100%; background: var(--c); transform-origin: left; animation: grow-x .7s cubic-bezier(.2,.7,.2,1) both; }
.bars li.me .b-track i { background: var(--team); }
.b-val { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.b-val small { color: var(--muted); font-weight: 600; }

/* Position chart */
.poschart { width: 100%; height: auto; display: block; margin-top: 6px; }
.poschart path { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.pc-rest { stroke: var(--ink); stroke-opacity: .3; stroke-width: 1.5; }
.pc-main { stroke: var(--c, var(--ink-2)); stroke-width: 2.2; }
.pc-focus { stroke: var(--c, var(--team)); stroke-width: 3.4; }
.pc-tag { font-weight: 800; font-size: 11px; fill: var(--c, var(--ink)); font-family: var(--font); }
.pc-axis { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.pc-grid { stroke: var(--rule); stroke-width: .6; stroke-dasharray: 2 3; }

/* Motion: things draw once, and only if motion is allowed. */
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
.draw { stroke-dasharray: 1; animation: draw .8s ease-out both; }
.draw-all path { stroke-dasharray: 2000; stroke-dashoffset: 0; animation: drawlong 1.4s ease-out both; }
@keyframes drawlong { from { stroke-dashoffset: 2000; } }
@media (prefers-reduced-motion: reduce) {
  .draw, .draw-all path, .st-bar i, .b-track i { animation: none !important; }
  .ms { transition: none; }
}

/* ---------- v2: Timing tab ---------- */
.views { margin: 12px 0 0; }
.views button { padding: 0 11px; font-size: .92rem; }
.badge { display: inline-grid; place-items: center; min-width: 1.4em; height: 1.4em; padding: 0 4px; background: var(--red); color: #fff; font-size: .75rem; font-weight: 800; margin-left: 4px; }
.seg.small button { min-height: 34px; padding: 0 10px; font-size: .9rem; }
.top-seg { display: flex; margin: 14px 0 0; }
.top-seg button { flex: 1; }
.tower-panel { padding-top: 12px; }
.tw-head, .tw-row { display: grid; grid-template-columns: 1.7rem minmax(0, 1fr) 4.7rem 3.2rem 2.1rem; gap: 0 6px; align-items: center; }
.tw-head abbr { text-decoration: none; }
.tw-h-sec { display: none; }
/* Phones and tablets: one line a car (place, driver, this lap's mini sectors, gap, tyre, stops); tap for the
   sector times and last lap. Wide screens show everything on the line. */
.tw-head span:nth-child(5), .tw-row > .tw-last { display: none; }
.tw-row { min-height: 42px; padding-top: 5px !important; padding-bottom: 5px !important; }
.tw-sectors { display: none !important; }
.tw-row.open .tw-sectors { display: grid !important; grid-template-columns: repeat(3, 1fr); padding-bottom: 2px; }
.tw-sectors .tw-last2 { grid-column: 1 / -1; display: block; }
.tw-strip { grid-column: 2 / -1; grid-row: 2; display: flex; gap: 3px; min-width: 0; margin-top: 5px; }
.tw-strip .tw-ms { flex: 1; min-width: 0; padding: 1px; }
.tw-strip .ms { height: 3px; min-width: 0; }
.tw-row.out .ms, .tw-row.ko .ms { background: var(--ms-none) !important; }
.tw-sn { font-weight: 650; color: var(--muted); font-size: .7rem; margin-right: 5px; }
.tw-row.me .tw-sn { color: var(--hl-mute); }
.tw-strip:empty, .tw-h-strip { display: none; }
.tw-row.open .tw-sectors { grid-row: 3; }
.tw-sectors .tw-ms { display: none; }
.tw-hit { position: absolute; inset: 0; width: 100%; appearance: none; border: 0; background: transparent; cursor: pointer; }
.tw-hit:focus-visible { outline: 3px solid var(--focus, #1f6fd6); outline-offset: -3px; }
.tw-row.open { box-shadow: inset 4px 0 0 var(--c), inset 0 -2px 0 var(--ink); }
.tw-last2 small { color: var(--muted); font-size: .7rem; }
.tw-tip { margin-top: 8px; }
.tw-head { margin-top: 10px; padding: 0 6px 4px 10px; border-bottom: 2px solid var(--ink); font-size: .74rem; font-weight: 650; color: var(--muted); }
.tw-head span:nth-child(n+3) { text-align: right; }
.tw-head .tw-h-strip { text-align: left; }
.seg.views { display: flex; }
.seg.views button { flex: 1 1 auto; padding: 0 6px; }
@media (max-width: 380px) { .seg.views button { font-size: .9rem; padding: 0 4px; } }
.tw { list-style: none; margin: 0; padding: 0; }
.tw-row { padding: 7px 6px 7px 10px; border-bottom: 1px solid var(--rule); box-shadow: inset 4px 0 0 var(--c); position: relative; background: var(--bg); }
.tw-row.me { background: var(--hl); color: var(--hl-ink); border-bottom-color: var(--hl); }
.tw-row.out, .tw-row.ko { color: var(--muted); }
.tw-row.cutline { border-bottom: 3px solid var(--red); }
.tw-pos { font-weight: 850; font-stretch: 75%; font-size: 1.1rem; }
.tw-tla { font-weight: 850; display: flex; gap: 5px; align-items: center; min-width: 0; overflow: hidden; }
.tw-gap, .tw-last, .tw-stops { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .88rem; letter-spacing: -.01em; }
.tw-gap { font-weight: 750; }
.tw-last { color: var(--ink-2); }
.tw-row.me .tw-last { color: var(--hl-mute); }
.tw-last.purple { color: var(--purple); font-weight: 800; } .tw-last.green { color: var(--green); font-weight: 800; }
.tw-row.me .tw-last.purple { color: var(--hl-purple); } .tw-row.me .tw-last.green { color: var(--hl-green); }
.tw-tyre { text-align: right; white-space: nowrap; }
.tw-row.me .tyre { color: var(--hl-ink); }
.tw-sectors { grid-column: 2 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 5px; }
.tw-sectors:empty { display: none; }
.tw-s { display: grid; gap: 2px; font-size: .78rem; }
.tw-s b { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.tw-row.me .tw-s b { color: var(--hl-mute); }
.tw-s.purple b { color: var(--purple); } .tw-s.green b { color: var(--green); }
.tw-row.me .tw-s.purple b { color: var(--hl-purple); } .tw-row.me .tw-s.green b { color: var(--hl-green); }
.tw-ms { display: flex; gap: 1px; background: var(--slab); padding: 2px; }
.tw-ms .ms { height: 5px; }
.pen, .inv, .bw { font-size: .68rem; font-weight: 850; font-stretch: 85%; padding: 1px 4px; line-height: 1.2; flex: none; }
.pen { background: var(--red); color: #fff; }
.inv { background: var(--yellow); color: #0b0b0c; }
.bw { background: linear-gradient(135deg, #0b0b0c 50%, #fff 50%); color: transparent; width: 14px; outline: 1px solid var(--ink); }
.ms-key .pen, .ms-key .inv { margin-left: 8px; margin-right: 3px; }
@media (min-width: 900px) {
  .tw-head, .tw-row { grid-template-columns: 2.4rem 6rem 6.4rem 6.4rem 4rem 2.6rem minmax(0, 1fr); }
  .tw-sectors { padding-left: 12px; }
  .tw-strip, .tw-h-strip, .tw-hit, .tw-tip { display: none !important; }
  .tw-head span:nth-child(5), .tw-row > .tw-last { display: block; }
  .tw-sectors, .tw-row.open .tw-sectors { display: grid !important; grid-template-columns: repeat(3, 1fr); grid-column: auto; grid-row: auto; margin-top: 0; }
  .tw-sectors .tw-last2 { display: none; }
  .tw-sectors .tw-ms { display: flex; }
}

.dlist { list-style: none; margin: 6px 0 0; padding: 0; }
.dlist li { display: grid; grid-template-columns: 3.2em auto 2.4em minmax(0, 1fr); gap: 10px; align-items: center; padding: 8px 6px; border-bottom: 1px solid var(--rule); }
.dlist li.me { background: var(--hl); color: var(--hl-ink); }
.dl-n { font-weight: 800; text-align: right; }
.dl-last { color: var(--muted); font-size: .88rem; min-width: 0; }
.dlist li.me .dl-last { color: var(--hl-mute); }
.strikes.small { margin: 0; gap: 2px; } .strikes.small i { width: 12px; height: 8px; }
.dlist li.me .strikes i { background: #3a3d42; } .dlist li.me .strikes i.on { background: #fff; }

/* ---------- v2: radio ---------- */
.clips li { box-shadow: inset 3px 0 0 var(--c, transparent); padding-left: 10px; }
.clips li.key { background: none; }
.clips li.key .lap-tag { color: var(--ink); box-shadow: inset 0 -3px 0 var(--yellow); }
.clip-ctx { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; margin: 4px 0 0; font-size: .86rem; font-weight: 650; color: var(--ink-2); }
.clip-ctx .tyre { font-size: .7rem; }
.clip-ctx .dot { color: var(--muted); }
.moment { padding: 0 5px; font-weight: 800; font-stretch: 85%; font-size: .8rem; border: 1.5px solid var(--ink); }
.m-pit { background: var(--ink); color: var(--bg); }
.m-penalty, .m-red { background: var(--red); border-color: var(--red); color: #fff; }
.m-incident, .m-sc, .m-limits { background: var(--yellow); border-color: var(--yellow); color: #0b0b0c; }
.m-blue { background: #1f6fd6; border-color: #1f6fd6; color: #fff; }
.m-finish { border-color: var(--ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.tags span { font-size: .78rem; font-weight: 750; padding: 2px 7px; border: 1.5px solid var(--rule-2); color: var(--ink-2); }
.badge.plain { background: var(--ink); color: var(--bg); }
.said.alt { color: var(--muted); }

/* ---------- v2: track map ---------- */
.mapbox { position: relative; margin-top: 8px; background: var(--slab); border-radius: var(--inst); aspect-ratio: 4 / 3; overflow: hidden; touch-action: pan-y; }
.mapbox.big { aspect-ratio: 1 / 1; margin-top: 12px; max-height: 72vh; width: 100%; }
/* Pinned to the box, so a box capped by screen height still holds the whole circuit (the SVG fits inside it). */
.trackmap { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.trackmap[data-size="big"] { cursor: grab; }
.tm-under { fill: none; stroke: #2e3136; stroke-width: calc(var(--u) * 13); stroke-linejoin: round; }
.tm-track { fill: none; stroke: #e9eaec; stroke-width: calc(var(--u) * 4); stroke-linejoin: round; }
.tm-ground { fill: none; stroke: #2a2c30; stroke-width: calc(var(--u) * 3); stroke-dasharray: calc(var(--u) * 6) calc(var(--u) * 6); }
.tm-wall { stroke: #3a3d43; stroke-width: calc(var(--u) * 1.4); }
.tm-pit { fill: none; stroke: #6f747b; stroke-width: calc(var(--u) * 2.2); stroke-dasharray: calc(var(--u) * 5) calc(var(--u) * 4); }
.tm-start { stroke: #fff; stroke-width: calc(var(--u) * 4); }
.tm-start-chq { stroke: #0b0b0c; stroke-width: calc(var(--u) * 4); stroke-dasharray: calc(var(--u) * 2.5) calc(var(--u) * 2.5); }
.tm-yellow { fill: none; stroke: var(--yellow); stroke-width: calc(var(--u) * 9); stroke-linecap: round; opacity: .9; animation: flagin .5s ease-out both; }
.tm-yellow.double { stroke-dasharray: calc(var(--u) * 14) calc(var(--u) * 5); }
@keyframes flagin { from { opacity: 0; } }
.tm-car circle { fill: var(--c); stroke: #0b0b0c; stroke-width: calc(var(--u) * 1.4); }
.tm-car.near circle { stroke: #fff; stroke-width: calc(var(--u) * 1.6); }
.tm-car.me circle { stroke: #fff; stroke-width: calc(var(--u) * 2.6); }
.tm-car.pit circle { opacity: .7; }
.tm-car text { fill: #fff; font-family: var(--font); font-weight: 800; paint-order: stroke; stroke: #0b0b0c; stroke-width: calc(var(--u) * 3); }
.tm-car:not(.me):not(.near) text { fill: #c9ccd1; font-weight: 700; }

@media (prefers-reduced-motion: reduce) { .tm-yellow { animation: none; } }
.tm-curtain { fill: #1d1f23; stroke: #2a2c30; stroke-width: calc(var(--u) * .6); }
.tm-ribbon { fill: #33363c; }
.trackmap { overflow: visible; }
.trackmap[data-view="3d"] .tm-under { display: none; }
.trackmap[data-view="3d"] .tm-track { stroke: #f4f4f2; stroke-width: calc(var(--u) * 1.6); }
.trackmap[data-view="3d"] .tm-ribbon { fill: #44484f; stroke: #8b9097; stroke-width: calc(var(--u) * .8); }

/* ---------- v2: telemetry ---------- */
.gauge-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 10px; }
.g-trace-box { margin: 12px 0 0; background: var(--slab); border-radius: var(--inst); color: var(--slab-ink); padding: 10px; }
.g-trace-box figcaption { font-size: .8rem; font-weight: 650; color: #a9adb3; margin-bottom: 6px; }
.g-trace-box figcaption span { color: var(--c); font-weight: 850; }
.g-trace { display: block; width: 100%; height: 110px; }
.g-grid { stroke: #2c2f34; stroke-width: 1; vector-effect: non-scaling-stroke; }
.g-trace-wrap { display: grid; grid-template-columns: 30px minmax(0, 1fr); }
.g-axis { position: relative; }
.g-axis span { position: absolute; right: 6px; transform: translateY(-50%); color: #8b9097; font-size: .68rem; font-variant-numeric: tabular-nums; }
.g-xaxis { display: flex; justify-content: space-between; margin: 4px 0 0 30px; color: #8b9097; font-size: .68rem; }
.g-brk { font-size: .75rem; font-weight: 850; padding: 1px 6px; border: 1.5px solid #5b6068; color: #8b9097; }
.g-brk.on { background: var(--red-slab); border-color: var(--red-slab); color: #0b0b0c; }
.g-line { fill: none; stroke: var(--c); stroke-width: 2.4; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.gauge { margin: 0; border-radius: var(--inst); overflow: hidden; background: var(--slab); color: var(--slab-ink); padding: 10px 10px 12px; box-shadow: inset 0 4px 0 var(--c); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; min-width: 0; }
.gauge svg { width: 100%; max-width: 250px; justify-self: center; height: auto; grid-column: 1; }
.gauge-row { max-width: 760px; }
@media (min-width: 900px) {
  .gauges { display: grid; grid-template-columns: minmax(0, 600px) minmax(0, 1fr); gap: 12px; align-items: stretch; }
  .gauge-row { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 0; }
  .g-trace-box { margin: 0; display: flex; flex-direction: column; }
  .g-trace-box .g-trace-wrap { flex: 1; } .g-trace-box .g-trace { height: 100%; min-height: 160px; }
}
/* Light theme: the dark instruments get a hairline edge, so they read as fitted panels. */
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .mapbox, :root:not([data-theme="dark"]) .g-trace-box { box-shadow: 0 0 0 1px #2f3238; } }
:root[data-theme="light"] .mapbox, :root[data-theme="light"] .g-trace-box { box-shadow: 0 0 0 1px #2f3238; }
.g-speed, .g-rpm { transition: stroke-dasharray .25s linear; }
.g-track, .g-rpm-track { fill: none; stroke: #26292e; stroke-width: 10; stroke-linecap: butt; }
.g-rpm-track { stroke-width: 5; }
.g-speed { fill: none; stroke: var(--c); stroke-width: 10; stroke-dasharray: 0 1; transition: stroke-dasharray .12s linear; }
.g-rpm { fill: none; stroke: #e9eaec; stroke-width: 5; stroke-dasharray: 0 1; transition: stroke-dasharray .12s linear; }
.g-v { fill: #fff; font-family: var(--font); font-weight: 850; font-stretch: 70%; font-size: 46px; }
.g-u { fill: #a9adb3; font-family: var(--font); font-size: 15px; font-weight: 650; }
.g-gear { fill: #fff; font-family: var(--font); font-weight: 850; font-stretch: 70%; font-size: 34px; }
.g-bars { grid-column: 2; display: flex; gap: 6px; align-items: stretch; }
.g-bar { position: relative; width: 16px; background: #26292e; display: block; }
.g-bar i { position: absolute; inset: 0; transform-origin: bottom; transform: scaleY(0); transition: transform .1s linear; }
.g-bar.thr i { background: var(--ms-green); } .g-bar.brk i { background: var(--red-slab); }
.g-bar { width: 24px; }
.g-bar b { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%) rotate(180deg); writing-mode: vertical-rl; font-size: .74rem; letter-spacing: .04em; color: #fff; font-weight: 750; text-shadow: 0 0 3px #000; z-index: 1; }
.gauge figcaption { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; font-weight: 750; }
.g-tla { font-weight: 850; }
.g-drs { font-size: .75rem; font-weight: 850; padding: 1px 6px; border: 1.5px solid #5b6068; color: #5b6068; }
.g-drs.on { background: var(--ms-green); border-color: var(--ms-green); color: #0b0b0c; }
.g-rpmv { margin-left: auto; color: #a9adb3; font-size: .78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gauge.nodata { opacity: .5; }
.traps { list-style: none; margin: 8px 0 0; padding: 0; }
.traps li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.tp-name { font-weight: 700; } .tp-now { font-weight: 850; font-size: 1.15rem; text-align: right; }
.tp-now small { font-size: .75rem; color: var(--muted); font-weight: 600; }
.tp-best { color: var(--muted); font-size: .85rem; }
.tp-bar { grid-column: 1 / -1; height: 6px; background: var(--rule); } .tp-bar i { display: block; height: 100%; background: var(--ink-2); }
.traps li.purple .tp-bar i { background: var(--purple); } .traps li.green .tp-bar i { background: var(--green); }
@media (prefers-reduced-motion: reduce) { .g-speed, .g-rpm, .g-bar i { transition: none; } }

/* The flag band arrives with a sweep, like a marshal's flag being waved in. */
.flagband:not([hidden]) { animation: sweep .45s cubic-bezier(.2,.7,.2,1) both; transform-origin: left; }
@keyframes sweep { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@media (prefers-reduced-motion: reduce) { .flagband:not([hidden]) { animation: none; } }

@media (min-width: 900px) {
  main[data-tab="timing"] .view, main[data-tab="track"] .view { max-width: 1180px; }
  .tw-h-sec { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding-left: 12px; text-align: left !important; }
  .tw-h-sec i { font-style: normal; }
  .tw-row { padding-top: 9px !important; padding-bottom: 9px !important; }
  .tw-sn { display: none; }
  .tw-s { grid-template-columns: 4.2em 1fr; align-items: center; gap: 8px; }
  .tw-ms .ms { height: 8px; }
  main[data-tab="track"] .mapbox.big { max-height: 78vh; }
}

/* ---------- launch QA fixes (20 Oct) ---------- */
/* Reduce Motion: no switch slide either (this comes after the switch rule, so it wins). */
@media (prefers-reduced-motion: reduce) { .switch i { transition: none !important; } }
/* Dark mode: white on the bright dark-mode red is too faint for small text; dark text instead. Black boxes get an edge. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge:not(.plain), :root:not([data-theme="light"]) .pen { color: #0b0b0c; } :root:not([data-theme="light"]) .chip-num, :root:not([data-theme="light"]) .round { box-shadow: inset 0 0 0 1px #4a4e56; } }
:root[data-theme="dark"] .badge:not(.plain), :root[data-theme="dark"] .pen { color: #0b0b0c; }
:root[data-theme="dark"] .chip-num, :root[data-theme="dark"] .round { box-shadow: inset 0 0 0 1px #4a4e56; }
/* Tap targets: segmented controls and switches at least 44 px. */
.seg button { min-height: 44px; }
.seg.small button { min-height: 44px; }
.switch::after { content: ''; position: absolute; inset: -7px -4px; } /* a 44 px tap area round the 32 px switch */
/* Very narrow layouts (200% zoom on a phone): controls wrap instead of pushing the page sideways. */
@media (max-width: 300px) {
  .seg, .seg.views { flex-wrap: wrap; } .seg button { flex: 1 1 auto; border-left: 0; border-top: 2px solid var(--ink); }
  .clip-head { flex-wrap: wrap; } .ob-title { font-size: 2rem; overflow-wrap: anywhere; } .ob-foot .btn { font-size: .95rem; }
  .classif, .tower { display: block; overflow-x: auto; } .tabs .tab span { font-size: .6rem; } .ob-foot { position: static; }
  .tw-head, .tw-row { grid-template-columns: 1.5rem minmax(0, 1fr) 4rem 2.6rem 1.8rem; }
  .btn { white-space: normal; max-width: 100%; } .row-switch > div, .row-seg > * { min-width: 0; overflow-wrap: anywhere; }
}
