/* Kart Strat — race-timing instrument skin. Light is the default (sunlight, race day); dark is the
   night-garage mode. Interactive chrome is monochrome on purpose: colour belongs to DATA only
   (the kart heat ramp, driver deltas, warnings), so nothing competes with the answer. */

/* Russo One: the display voice — the owner picked it from six live variants (2026-07-30).
   Wide, muscular, full Ukrainian Cyrillic (і ї є ґ in the cyrillic subset). Single weight 400:
   hierarchy comes from size, never synthetic bold. Self-hosted so the tool works from a paddock
   hotspot with no CDN. Digits, clock, tabs, headings only; body text stays on the system stack. */
@font-face {
  font-family: 'Russo One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/russo-one-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Russo One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/russo-one-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #0a0a0b;
  --panel: #141416;
  --panel-2: #1b1b1f;
  --fg: #edf1f4;
  --muted: #9aa5ad;
  --line: #2d2d33;
  --accent: #edf1f4;          /* interactive = monochrome; colour is reserved for data */
  --good: #177a3e;            /* tile-ramp target: full-green kart under light text, 4.8:1 */
  --danger: #c02636;          /* tile-ramp target: full-red kart under light text, 5.2:1 */
  --warn: #f0a929;
  --good-ink: #4cd97f;        /* text-on-panel twins of the ramp colours */
  --bad-ink: #ff6b74;
  --warn-ink: #f0a929;
  --tile-line: rgba(255, 255, 255, .07);
  --checker: rgba(255, 255, 255, .10);
  --radius: 6px;
  --disp: 'Russo One', system-ui, sans-serif;
}
[data-theme="light"] {
  --bg: #eef0f2;
  --panel: #ffffff;
  --panel-2: #e2e6eb;
  --fg: #12161a;
  --muted: #4d5760;
  --line: #cfd6dc;
  --accent: #12161a;
  --good: #47b975;            /* full-green under dark ink, 7.3:1 — sun-proof */
  --danger: #e4525f;          /* full-red under dark ink, 4.9:1 */
  --warn: #8a5f10;
  --good-ink: #0d7a3c;
  --bad-ink: #c21f2e;
  --warn-ink: #8a5f10;
  --tile-line: rgba(18, 22, 26, .13);
  --checker: rgba(18, 22, 26, .14);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
h1 { font: 400 1.5rem/1.2 var(--disp); letter-spacing: .01em; margin: 0 0 .25rem; }
h2 {
  font: 400 .85rem/1.3 var(--disp);
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
  margin: 1.4rem 0 .45rem;
}
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: 1; } /* browser default fails 4.5:1 in both themes */

/* ---- Shared surfaces: panel box + alerts strip ---- */
#app { min-height: 100vh; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  min-width: 0;
}
.alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 2.5rem;
  padding: 4px 12px 12px;
}
.alert {
  padding: 6px 12px;
  border: 1px solid var(--warn);
  color: var(--warn-ink);
  border-radius: 6px;
  font-weight: 600;
  font-size: .9rem;
}

/* ---- Screen headers ---- */
.setup-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.theme-toggle { white-space: nowrap; }

input, select, textarea, button { font: inherit; }
input, select, textarea {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  width: 100%;
  min-height: 44px;
}
input[type="radio"] { width: auto; min-height: 0; }
input[type="range"] { min-height: 0; padding: 0; border: none; background: none; accent-color: var(--fg); height: 28px; }
button {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 14px;
  min-height: 44px;
  cursor: pointer;
}
button.ghost { padding: 6px 10px; min-height: 44px; color: var(--muted); background: none; }
button:hover { border-color: var(--fg); }
.danger[data-armed="true"] { color: var(--bad-ink); border-color: var(--danger); }
/* «Старт» / «Готово»: the solid monochrome block — number-plate, not app button */
.start {
  margin-top: 20px;
  background: var(--fg);
  color: var(--bg);
  border: none;
  font: 400 1.1rem/1.2 var(--disp);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 14px;
}
.start:hover { border: none; opacity: .92; }

/* ---- v3 kart grid (phone-first) ---- */
.kart-grid { display: grid; grid-template-columns: repeat(var(--grid-cols, 4), 1fr); gap: 7px; padding: 10px 12px; width: 100%; max-width: 920px; margin: 0 auto; }
.kt {
  /* var(--fg), not #fff: the two-segment deltaMix sits mid-pack tiles on the neutral --panel-2,
     where white text would vanish in the light theme */
  border-radius: 3px; padding: 9px 2px 8px; text-align: center; color: var(--fg);
  box-shadow: inset 0 0 0 1px var(--tile-line);
  transition: transform .28s cubic-bezier(.2,.7,.3,1);
  display: flex; flex-direction: column; gap: 1px; align-items: center;
}
.grid-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 48px 12px; font: 400 .95rem/1.4 var(--disp); text-transform: uppercase; letter-spacing: .08em; }
.kt-top { display: flex; align-items: baseline; gap: 2px; justify-content: center; }
.kt-num { font: 400 2.1rem/1 var(--disp); font-variant-numeric: tabular-nums; }
.kt-dots { font-size: .72rem; }
.kt-gap { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; opacity: .95; }

/* ---- v3 live shell ---- */
.live { display: flex; flex-direction: column; min-height: 100vh; }
.live-bar { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px 16px; }
/* waiting for the race: «Приєднати зараз» takes its own full-width row under the clock */
.live-bar > .attach-now { order: 5; flex-basis: 100%; min-height: 48px; color: var(--fg); border: 1px solid var(--line); }
.live-bar > .attach-now[hidden] { display: none; }
/* the one identity mark: a quiet checkered hairline under the timing bar */
.live-bar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  background: repeating-conic-gradient(var(--checker) 0% 25%, transparent 0% 50%) 0 0 / 12px 12px;
}
/* clock + race state: the biggest thing in the bar, readable at arm's length */
.clock-box { margin-right: auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.live-bar .clock {
  font: 400 2rem/1 var(--disp);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}
.bar-status { display: flex; flex-wrap: wrap; gap: 0 8px; font-size: .8rem; line-height: 1.2; }
.bar-status:empty, .bar-status > :empty { display: none; }
.icon-btn { min-width: 48px; min-height: 48px; font-size: 1.35rem; line-height: 1; padding: 0; color: var(--fg); }
.live-menu { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.live-menu[hidden] { display: none; }
.live-menu > button { flex: 1 1 auto; min-height: 48px; color: var(--fg); border: 1px solid var(--line); }
.live-menu > button[hidden] { display: none; }
.start-mini {
  min-height: 48px; padding: 10px 16px;
  background: var(--fg); color: var(--bg); border: none;
  font: 400 1rem/1.2 var(--disp); text-transform: uppercase; letter-spacing: .05em;
}
.start-mini:hover { border: none; opacity: .92; }
.tabs { display: flex; padding: 10px 12px 4px; width: 100%; max-width: 920px; margin: 0 auto; }
.tabs button {
  flex: 1;
  font: 400 .95rem/1.2 var(--disp);
  text-transform: uppercase;
  letter-spacing: .07em;
  background: var(--panel);
  border-radius: 0;
}
.tabs button:first-child { border-radius: 3px 0 0 3px; }
.tabs button:last-child { border-radius: 0 3px 3px 0; border-left: none; }
.tabs button[data-on="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.live-body { flex: 1; min-width: 0; }
/* conditions hint: the one sentence that changes what the operator does next */
.hint-line { margin: 8px 12px 0; padding: 10px 12px; border-radius: var(--radius); font-weight: 600; font-size: .95rem;
  color: var(--warn-ink); border: 1px solid var(--warn-ink); background: color-mix(in oklab, var(--panel), var(--warn) 10%); }
.hint-line[data-kind="settled"] { color: var(--fg); border-color: var(--fg); background: color-mix(in oklab, var(--panel), var(--good) 22%); }
.hint-line[hidden] { display: none; }
/* «Наш карт 17  −0.54  1-й з 17» — our answer, above the board */
.mine-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; max-width: 920px; margin: 6px auto 0;
  padding: 0 12px; font: 400 1.1rem/1.3 var(--disp); }
.mine-line[hidden] { display: none; }
.mine-line .muted { font: 600 .95rem/1.3 system-ui, sans-serif; }
.mine-delta { padding: 3px 8px; border-radius: 4px; font: 400 1.1rem/1.2 var(--disp); font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px var(--tile-line); }
/* our kart's tile: a thick ink frame — readable in sun, independent of the tile's heat colour */
.kt { border: none; cursor: pointer; font: inherit; min-height: 0; }
.kt[data-mine="true"] { box-shadow: inset 0 0 0 3px var(--fg), 0 0 0 2px var(--bg), 0 0 0 4px var(--fg); }
.team-pick { display: flex; flex-direction: column; gap: 4px; flex-basis: 100%; font-size: .85rem; }
.team-select { min-height: 48px; }
/* kart details bottom sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet-wrap[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); }
.sheet { position: relative; background: var(--panel); color: var(--fg); border-radius: 12px 12px 0 0; padding: 16px 14px 20px;
  max-height: 80vh; overflow-y: auto; width: 100%; max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.sheet-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sheet-kart { font: 400 1.6rem/1 var(--disp); }
.sheet-note { font-size: .9rem; color: var(--warn-ink); }
.sheet-stints { display: flex; flex-direction: column; }
.sheet-stint { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.st-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.st-who { min-width: 0; overflow-wrap: anywhere; }
.st-laps { grid-column: 2; font-size: .85rem; }
.sheet-close { margin-top: 6px; }
.sheet-stint.before-reset { opacity: .55; }
.sheet-stint[data-excluded="true"] .st-who { text-decoration: line-through; }
.st-toggle { grid-column: 2; justify-self: start; min-height: 40px; padding: 4px 10px; border: 1px solid var(--line); }
.sheet-kart-toggle { min-height: 48px; }
.sheet-kart-toggle.danger { color: var(--bad-ink); border-color: var(--danger); }
.kt[data-excluded="true"] { background: var(--panel-2); opacity: .55; }
.test-feed { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 12px;
  background: #f0a929; color: #12161a; font-weight: 700; font-size: .9rem; }
.test-feed button { color: #12161a; min-height: 40px; border: 1px solid rgba(0,0,0,.35); }
/* feed-lost / load-failed banner: a stale board mid-race must shout, not whisper */
.live > .muted { color: var(--warn-ink); font-weight: 600; font-size: .9rem; padding: 6px 12px; }
/* the driver table is the only wide thing on the phone: it scrolls inside its panel, never the page */
.driver-panel { overflow-x: auto; margin: 4px auto; width: calc(100% - 24px); max-width: 896px; }

/* ---- driver table (presentation lives here; dom.js th/td carry no inline style) ---- */
.driver-table { width: 100%; border-collapse: collapse; }
.driver-table th {
  text-align: left;
  font: 400 .72rem/1.3 var(--disp);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--line);
}
.driver-table th:nth-child(n+3), .driver-table td:nth-child(n+3) { text-align: right; }
.driver-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.driver-table tr:last-child td { border-bottom: none; }
.driver-table td:nth-child(4) { font-weight: 600; }

.cat {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  font: 400 .78rem/1.3 var(--disp);
  letter-spacing: .05em;
}
.cat[data-cat="PRO"] { background: var(--fg); color: var(--bg); }
.cat[data-cat="GOLD"] { background: #d9a521; color: #12161a; }
.cat[data-cat="LITE"] { background: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--muted); }

/* ---- v3 settings ---- */
.settings { max-width: 640px; margin: 0 auto; padding: 16px 12px 64px; display: flex; flex-direction: column; gap: 8px; }
.import-box { width: 100%; }
.code-row { display: flex; gap: 8px; }
.code-row[hidden] { display: none; }
.code-box { flex: 1; min-width: 0; min-height: 44px; letter-spacing: .12em; text-transform: uppercase; }
.tag-list { display: flex; flex-direction: column; gap: 6px; }
.known-search { margin: 8px 0; }
.tag-row { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; background: var(--panel); }
.tag-row[data-skipped="true"] { opacity: .35; }
.tag-row[data-merged="true"] { border-color: var(--fg); background: color-mix(in oklab, var(--panel), var(--fg) 7%); }
.tag-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tag-name { font-weight: 600; }
.tag-ctl { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tag-cands { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.cat-toggle { display: flex; gap: 4px; flex-wrap: wrap; }
.cat-btn { font: 400 .85rem/1.2 var(--disp); letter-spacing: .04em; min-height: 44px; }
.cat-btn[data-on="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.mark-lbl { display: flex; align-items: center; gap: 6px; }
.mark-lbl .cat-btn { min-width: 34px; min-height: 36px; padding: 2px 6px; }
.muted { color: var(--muted); font-size: .85rem; }
summary.muted:empty { display: none; } /* pre-import: no stray disclosure marker for a nameless fold */
.settings h2:has(+ .tag-list:empty) { display: none; }
@media (prefers-reduced-motion: reduce) { .kt { transition: none; } }
.cond-note { font-size: .8rem; white-space: nowrap; }
