/* Stint Control — pit wall.
   Same family as maianiwat.com: Titillium Web, carbon ink, F1 red, slanted tags.
   Light by default (sunlit pit lane); dark is the night-stint option. */

:root {
  --ground: #f3f3f6;
  --surface: #ffffff;
  --surface-2: #ececf1;
  --surface-3: #e1e1e8;
  --ink: #15151e;
  --ink-2: #4a4a5c;
  --muted: #7c7c90;
  --rule: #dcdce4;
  --rule-2: #c3c3cf;
  --carbon: #15151e;
  --carbon-2: #23232f;
  --on-carbon: #ffffff;
  --on-carbon-2: #a3a3b6;
  --f1: #e10600;
  --f1-ink: #ffffff;
  --f1-tint: #fff1f0;
  --live: #00a651;
  --live-tint: #eaf7f0;
  --amber: #c27a00;
  --amber-bar: #f5a300;
  --amber-tint: #fff6e0;
  --pit: #15151e;
  --info-tint: #eef0f6;

  --f-display: 'Titillium Web', 'IBM Plex Sans Thai', 'Arial Narrow', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans Thai', 'Titillium Web', 'Thonburi', system-ui, sans-serif;
  --r: 6px;
  --r-sm: 4px;
  --slant: -14deg;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --ground: #101017;
  --surface: #1b1b25;
  --surface-2: #252532;
  --surface-3: #30303f;
  --ink: #ffffff;
  --ink-2: #c2c2d1;
  --muted: #8a8aa0;
  --rule: #2e2e3e;
  --rule-2: #3d3d50;
  --carbon: #0a0a10;
  --carbon-2: #181822;
  --f1-tint: #3a1414;
  --live: #2bd67b;
  --live-tint: #12301f;
  --amber: #ffc53d;
  --amber-bar: #ffc53d;
  --amber-tint: #3a2e10;
  --pit: #ffffff;
  --info-tint: #23232f;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body {
  min-height: 100dvh;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
a {
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--f1);
  outline-offset: 2px;
}
.num,
.mono {
  font-family: var(--f-display);
  font-variant-numeric: tabular-nums;
}
.muted {
  color: var(--muted);
}
.dim {
  color: var(--ink-2);
}
.nowrap {
  white-space: nowrap;
}
.grow {
  flex: 1;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row.wrap {
  flex-wrap: wrap;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.label {
  font: 700 11px/1.2 var(--f-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.ok-t {
  color: var(--live);
}
.warn-t {
  color: var(--amber);
}
.bad-t {
  color: var(--f1);
}
.pit-t {
  color: var(--ink);
}

/* Slanted shapes live on ::before so text and focus rings stay square. */
.slant {
  position: relative;
  isolation: isolate;
}
.slant::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--b);
  transform: skewX(var(--slant));
  border-radius: 3px;
}

/* ---------- header (carbon timing bar) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--carbon);
  color: var(--on-carbon);
}
.topbar-in {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}
.mark {
  --b: var(--f1);
  color: var(--f1-ink);
  font: 900 italic 14px/1 var(--f-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
  white-space: nowrap;
}
.event-id {
  min-width: 0;
  border-left: 1px solid var(--carbon-2);
  padding-left: 18px;
  line-height: 1.25;
}
.event-id .name {
  font: 700 15px var(--f-display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 36ch;
}
.event-id .sub {
  font: 600 12px var(--f-display);
  color: var(--on-carbon-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 44ch;
}
.raceclock {
  margin-left: auto;
  display: flex;
  align-items: stretch;
  height: 100%;
}
.rc-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  padding: 0 18px;
  border-left: 1px solid var(--carbon-2);
}
.rc-big {
  font: 700 30px/1 var(--f-display);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.rc-big.warn-t {
  color: #ffc53d;
}
.rc-small {
  font: 700 18px/1 var(--f-display);
  font-variant-numeric: tabular-nums;
  color: var(--on-carbon-2);
}
.rc-cap {
  margin-top: 4px;
  color: var(--on-carbon-2);
  font-size: 10px;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 16px;
  border-left: 1px solid var(--carbon-2);
}
.topbar .btn {
  background: transparent;
  border-color: transparent;
  color: var(--on-carbon);
}
.topbar .btn:hover,
.topbar .btn.icon:hover {
  background: var(--carbon-2);
  color: var(--on-carbon);
}
.topbar .btn.icon {
  color: var(--on-carbon);
}

.conn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 700 11px/1 var(--f-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--on-carbon-2);
  padding: 0 8px;
  white-space: nowrap;
}
.conn i {
  width: 8px;
  height: 8px;
  background: var(--on-carbon-2);
  transform: skewX(var(--slant));
}
.conn.live i {
  background: #2bd67b;
}
.conn.live {
  color: var(--on-carbon);
}
.conn.offline {
  color: #ffc53d;
}
.conn.offline i {
  background: #ffc53d;
  animation: blink 1s steps(2) infinite;
}

.tabs-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  position: sticky;
  top: 64px;
  z-index: 29;
}
.tabs {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 12px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tab {
  appearance: none;
  border: 0;
  background: none;
  padding: 13px 10px 11px;
  color: var(--ink-2);
  font: 700 14px/1 var(--f-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.tab .ic {
  display: none;
}
.tab:hover {
  color: var(--ink);
}
.tab[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--f1);
}
.tab .badge {
  font: 700 11px/1 var(--f-display);
  letter-spacing: 0;
  min-width: 18px;
  padding: 3px 5px;
  background: var(--f1);
  color: #fff;
  text-align: center;
}

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 22px 20px 96px;
}

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--rule-2);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  padding: 8px 14px;
  font: 700 13px/1.1 var(--f-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover {
  border-color: var(--ink);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn.sm {
  padding: 6px 10px;
  font-size: 12px;
}
.btn.icon {
  padding: 6px;
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
}
.btn.icon:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover {
  background: var(--surface-2);
}
.btn.link {
  border: 0;
  background: none;
  padding: 6px 0;
  color: var(--ink-2);
}
.btn.link:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn.danger {
  color: var(--f1);
  border-color: color-mix(in srgb, var(--f1) 45%, var(--rule));
  background: transparent;
}
.btn.danger:hover {
  background: var(--f1-tint);
}
/* Slanted solid buttons */
.btn.primary,
.btn.pit,
.btn.go,
.btn.lights {
  border: 0;
  background: transparent;
  color: #fff;
  position: relative;
  isolation: isolate;
  padding: 10px 20px;
}
.btn.primary::before,
.btn.pit::before,
.btn.go::before,
.btn.lights::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: skewX(var(--slant));
  border-radius: 3px;
  background: var(--f1);
}
.btn.go::before {
  background: var(--live);
}
.btn.primary:hover::before,
.btn.pit:hover::before,
.btn.lights:hover::before {
  background: #c40500;
}
.btn.go:hover::before {
  filter: brightness(0.92);
}
.btn.primary .ic,
.btn.big .ic,
.btn.lights .ic {
  display: none;
}
.btn.big {
  width: calc(100% - 16px);
  margin-left: 8px;
  padding: 20px 16px;
  font: 900 italic 24px/1 var(--f-display);
  letter-spacing: 0.1em;
}

.tap-hint {
  margin-top: 6px;
  text-align: center;
  font: 600 12px/1.3 var(--f-display);
  letter-spacing: 0.04em;
  color: var(--muted);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field > span {
  font: 700 11px/1.2 var(--f-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.field small {
  color: var(--muted);
  font-size: 12px;
}
.inp,
select.inp,
textarea.inp {
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  min-width: 0;
  width: 100%;
  outline: none;
  font: 600 15px/1.3 var(--f-body);
}
.inp:hover {
  border-color: var(--muted);
}
.inp:focus {
  border-color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--f1);
}
.inp.sm {
  padding: 5px 8px;
  font-size: 14px;
}
.inp.num {
  font-family: var(--f-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
input[type='color'].inp {
  padding: 2px;
  height: 36px;
  width: 52px;
}
fieldset:disabled .inp {
  background: var(--surface-2);
  color: var(--ink-2);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-sm);
  overflow: hidden;
  flex-wrap: wrap;
  background: var(--surface);
}
.seg button {
  appearance: none;
  border: 0;
  border-right: 1px solid var(--rule);
  background: none;
  padding: 8px 12px;
  font: 700 12px/1 var(--f-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  cursor: pointer;
}
.seg button:last-child {
  border-right: 0;
}
.seg button:hover {
  background: var(--surface-2);
}
.seg button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--surface);
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
}
.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}

/* ---------- panels ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
}
.panel-h {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--rule);
}
.panel-h h2,
.panel-h h3 {
  margin: 0;
  font: 900 italic 18px/1.1 var(--f-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.panel-h > .ic {
  display: none;
}
.panel-b {
  padding: 18px;
}
.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 14px 16px;
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.section-title {
  margin: 0;
  font: 900 italic 32px/1 var(--f-display);
  text-transform: uppercase;
  letter-spacing: -0.005em;
}
.page-head {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin: 4px 0 18px;
  flex-wrap: wrap;
}
.page-head .muted {
  font: 600 14px var(--f-display);
  padding-bottom: 3px;
}

/* Status tags (timing-tower style) */
.tag,
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 700 11px/1 var(--f-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 2px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip .dot {
  display: none;
}
.chip.ok,
.tag.track {
  background: var(--live);
  color: #fff;
}
.chip.pit,
.tag.pit {
  background: var(--pit);
  color: var(--surface);
}
.chip.garage,
.tag.garage {
  background: var(--ink-2);
  color: var(--surface);
}
.chip.bad,
.tag.out {
  background: var(--f1);
  color: #fff;
}
.chip.warn {
  background: var(--amber-bar);
  color: #15151e;
}
.chip.flagged {
  background: var(--ink);
  color: var(--surface);
}
.chip.live {
  position: relative;
}

/* Car number: slanted tag in the team colour */
.carno {
  --b: var(--car, var(--ink));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  height: 36px;
  padding: 0 12px;
  font: 900 italic 22px/1 var(--f-display);
  color: #fff;
  position: relative;
  isolation: isolate;
  font-variant-numeric: tabular-nums;
}
.carno::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--b);
  transform: skewX(var(--slant));
  border-radius: 3px;
}
.carno.sm {
  min-width: 38px;
  height: 24px;
  font-size: 15px;
  padding: 0 8px;
}
.dot-d {
  width: 4px;
  height: 16px;
  background: var(--d, var(--muted));
  transform: skewX(var(--slant));
  flex-shrink: 0;
  display: inline-block;
}

/* Chequered flag swatch */
.chq {
  display: inline-block;
  width: 14px;
  height: 10px;
  background: conic-gradient(var(--ink) 25%, var(--surface) 0 50%, var(--ink) 0 75%, var(--surface) 0) 0 0 / 5px 5px;
  border: 1px solid var(--ink);
  vertical-align: -1px;
}

/* ---------- live timing ---------- */
.tm-flag {
  display: inline-block;
  font: 900 italic 13px/1 var(--f-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 10px;
  border-radius: 2px;
  background: #3d3d50;
  color: #fff;
  white-space: nowrap;
}
.tm-flag.green {
  background: #00a651;
}
.tm-flag.sc,
.tm-flag.fcy,
.tm-flag.code60 {
  background: #ffd100;
  color: #15151e;
}
.tm-flag.red {
  background: var(--f1);
}
.tm-flag.finish {
  color: #15151e;
  background: conic-gradient(#15151e 25%, #fff 0 50%, #15151e 0 75%, #fff 0) 0 0 / 8px 8px;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
}
.topbar .tm-flag {
  font-size: 12px;
}
.tm-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  padding: 8px 18px 8px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--rule);
  gap: 6px;
}
.tm-strip > div {
  min-width: 0;
}
.tm-strip span {
  display: block;
  font: 700 9.5px/1.2 var(--f-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-strip b {
  display: block;
  font: 700 14px/1.2 var(--f-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tm-strip .tm-warn {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  font: 600 12px var(--f-display);
  color: var(--amber);
}
.tm-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  border-top: 2px solid var(--ink);
  padding-top: 10px;
}
.tm-status b {
  display: block;
  overflow-wrap: anywhere;
  font: 700 15px/1.3 var(--f-display);
  margin-top: 4px;
}
.tm-cols {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  margin-top: 10px;
}
.tm-cols > div {
  border: 1px solid var(--rule);
  padding: 6px 8px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tm-cols > div.on {
  border-color: var(--ink);
}
.tm-cols b {
  font: 700 12px var(--f-display);
}
.tm-cols span {
  color: var(--muted);
  font: 600 11px var(--f-display);
}
.tm-cols code {
  font-size: 11px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- LIVE ---------- */
.live-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.prerace {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.prerace .cd {
  font: 700 34px/1.05 var(--f-display);
  font-variant-numeric: tabular-nums;
}

.car {
  position: relative;
  overflow: hidden;
  --lvl: var(--live);
  border-left: 0;
}
.car::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--car);
}
.car-h {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 14px 22px;
  border-bottom: 1px solid var(--rule);
}
.car-h .nm {
  min-width: 0;
}
.car-h .nm b {
  display: block;
  padding-right: 0.2em;
  font: 900 italic 18px/1.1 var(--f-display);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.car-h .nm small {
  font: 600 12px var(--f-display);
  letter-spacing: 0.04em;
  color: var(--muted);
}
.car-h .chip {
  margin-left: auto;
}
.car-sec {
  padding: 14px 18px 14px 22px;
}
.car-sec + .car-sec {
  border-top: 1px solid var(--rule);
}
.driver-now {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.driver-now .who {
  padding-right: 0.18em; /* room for the italic overhang */
  font: 900 italic 34px/1 var(--f-display);
  text-transform: uppercase;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.driver-now .dot-d {
  height: 26px;
  width: 6px;
}
.driver-now .of {
  margin-left: auto;
  font: 700 13px var(--f-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.timer {
  font: 700 clamp(64px, 6.2vw, 92px)/0.95 var(--f-display);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  margin: 14px 0 12px;
}
.car[data-lvl='warn'] {
  --lvl: var(--amber-bar);
}
.car[data-lvl='crit'],
.car[data-lvl='over'] {
  --lvl: var(--f1);
}
.car[data-lvl='warn'] .timer {
  color: var(--amber);
}
.car[data-lvl='crit'] .timer,
.car[data-lvl='over'] .timer {
  color: var(--f1);
}
.car[data-lvl='crit'],
.car[data-lvl='over'] {
  border-color: var(--f1);
  box-shadow: 0 0 0 1px var(--f1);
}
.car[data-lvl='over'] .timer {
  animation: blink 1s steps(2) infinite;
}
@keyframes blink {
  50% {
    opacity: 0.35;
  }
}
/* Segmented bar: 18 blocks (= 5 min each on a 90 min limit) */
.bar {
  position: relative;
  height: 12px;
  background: var(--surface-2);
  --segs: 18;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 calc(100% / var(--segs) - 2px), transparent 0 calc(100% / var(--segs)));
  mask: repeating-linear-gradient(90deg, #000 0 calc(100% / var(--segs) - 2px), transparent 0 calc(100% / var(--segs)));
}
.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--lvl);
  transition: width 0.4s linear;
}
.bar-wrap {
  position: relative;
}
.bar-wrap > em,
.bar > em {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--ink);
}
.bar.fuel {
  height: 8px;
  --segs: 12;
}
.bar.fuel > i {
  background: var(--fuel, var(--live));
}
.kv {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
  border-top: 1px solid var(--rule);
}
.kv > div {
  min-width: 0;
  padding: 10px 0 0 12px;
  border-left: 1px solid var(--rule);
}
.kv > div:first-child {
  padding-left: 0;
  border-left: 0;
}
.kv b {
  display: block;
  font: 700 22px/1.15 var(--f-display);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.kv span {
  font: 700 10.5px/1.2 var(--f-display);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.next-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font: 600 15px var(--f-display);
  flex-wrap: wrap;
}
.next-line b {
  font: 900 italic 18px/1 var(--f-display);
  text-transform: uppercase;
}
.next-line .label {
  --b: var(--ink);
  color: var(--surface);
  padding: 4px 8px;
  letter-spacing: 0.12em;
}
.car-actions {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 12px;
  align-items: center;
}
.car-actions .btn {
  border: 0;
  background: none;
  padding: 6px 0;
  color: var(--ink-2);
}
.car-actions .btn:hover {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}
.car-actions .btn .ic {
  display: none;
}
.pitbox {
  background: var(--surface-2);
}
.pit-timer {
  font: 700 56px/1 var(--f-display);
  font-variant-numeric: tabular-nums;
}
.car[data-st='pit'] .car-h,
.car[data-st='garage'] .car-h {
  background: var(--surface-2);
}
.pit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 12px;
  font-size: 13.5px;
  line-height: 1.4;
  background: var(--info-tint);
  border-left: 3px solid var(--ink-2);
}
.alert.warn {
  background: var(--amber-tint);
  border-left-color: var(--amber-bar);
}
.alert.bad {
  background: var(--f1-tint);
  border-left-color: var(--f1);
  color: var(--ink);
}
.alert.ok {
  background: var(--live-tint);
  border-left-color: var(--live);
}
.alert.info {
  border-left-color: var(--ink);
}
.alert .ic {
  flex-shrink: 0;
  margin-top: 1px;
}
.alert.warn .ic {
  color: var(--amber);
}
.alert.bad .ic {
  color: var(--f1);
}
.alert.ok .ic {
  color: var(--live);
}
.mini-stops {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.mini-stops div {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--rule);
  color: var(--ink-2);
}
.mini-stops div:first-child {
  border-top: 0;
}
.mini-stops .mono {
  font-weight: 700;
  color: var(--ink);
}

/* ---------- PLAN (timeline + table) ---------- */
.gantt {
  position: relative;
  padding: 6px 18px 16px;
  overflow-x: auto;
}
.g-inner {
  position: relative;
  min-width: 780px;
}
.g-axis {
  position: relative;
  height: 34px;
  margin-left: 92px;
  border-bottom: 2px solid var(--ink);
}
.g-tick {
  position: absolute;
  bottom: 4px;
  transform: translateX(-50%);
  text-align: center;
  font: 700 11px/1.15 var(--f-display);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.g-tick span {
  color: var(--muted);
}
.g-row {
  display: flex;
  align-items: center;
  height: 38px;
  border-bottom: 1px solid var(--rule);
}
.g-lab {
  width: 92px;
  flex-shrink: 0;
  font: 700 10.5px/1 var(--f-display);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.g-track {
  position: relative;
  flex: 1;
  height: 24px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% / var(--hours, 12) - 1px), var(--rule) 0 calc(100% / var(--hours, 12)));
}
.g-blk {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--d);
  color: #fff;
  font: 700 11px/1 var(--f-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0 6px;
  display: flex;
  align-items: center;
  overflow: hidden;
  white-space: nowrap;
  min-width: 2px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
  border-right: 2px solid var(--surface);
}
.g-blk.plan {
  background: var(--surface);
  color: var(--ink);
  text-shadow: none;
  box-shadow: inset 0 0 0 1.5px var(--d), inset 4px 0 0 var(--d);
  padding-left: 9px;
  border-right: 0;
}
.g-blk.over {
  box-shadow: inset 0 0 0 2px var(--f1);
}
.g-blk.cur {
  background-image: repeating-linear-gradient(-45deg, transparent 0 5px, rgba(255, 255, 255, 0.22) 5px 10px);
}
.g-pit {
  position: absolute;
  top: -3px;
  bottom: -3px;
  background: var(--ink);
  min-width: 2px;
}
.g-now {
  position: absolute;
  top: -6px;
  bottom: 0;
  width: 2px;
  background: var(--f1);
  z-index: 2;
  pointer-events: none;
}
.g-now::before {
  content: 'NOW';
  position: absolute;
  top: -12px;
  left: -14px;
  font: 700 9.5px/1 var(--f-display);
  letter-spacing: 0.1em;
  color: #fff;
  background: var(--f1);
  padding: 3px 5px;
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl th {
  text-align: left;
  font: 700 10.5px/1.2 var(--f-display);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 10px;
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}
.tbl td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
}
.tbl tr:last-child td {
  border-bottom: 0;
}
.tbl tr.done td {
  color: var(--ink-2);
}
.tbl tr.cur td {
  background: var(--live-tint);
}
.tbl tr.err td:first-child {
  box-shadow: inset 4px 0 0 var(--f1);
}
.tbl tr.wrn td:first-child {
  box-shadow: inset 4px 0 0 var(--amber-bar);
}
.tbl .num {
  text-align: right;
  font-family: var(--f-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tbl b {
  font-family: var(--f-display);
  font-weight: 700;
}
.tbl-wrap {
  overflow-x: auto;
}
.idx {
  --b: var(--ink);
  display: inline-flex;
  justify-content: center;
  min-width: 26px;
  padding: 3px 6px;
  font: 900 italic 13px/1 var(--f-display);
  color: var(--surface);
  position: relative;
  isolation: isolate;
}
.idx::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--b);
  transform: skewX(var(--slant));
  border-radius: 2px;
}
tr.done .idx {
  --b: var(--rule-2);
}
.issues {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.summary > div {
  padding: 12px 16px 12px 0;
}
.summary > div + div {
  padding-left: 16px;
  border-left: 1px solid var(--rule);
}
.summary b {
  display: block;
  font: 700 28px/1.1 var(--f-display);
  font-variant-numeric: tabular-nums;
}
.summary span {
  font: 700 10.5px/1.2 var(--f-display);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ---------- drivers ---------- */
.me-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  padding: 18px 20px;
  margin-bottom: 16px;
  border-left: 5px solid var(--me, var(--ink));
}
.me-card > .ic {
  color: var(--muted);
}
.me-cd {
  font: 700 46px/1 var(--f-display);
  font-variant-numeric: tabular-nums;
}
.hbar {
  height: 10px;
  background: var(--surface-2);
  position: relative;
  min-width: 80px;
}
.hbar i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--d);
}
.hbar i.pr {
  opacity: 0.3;
}

/* ---------- log ---------- */
.log-list {
  display: flex;
  flex-direction: column;
}
.log-item {
  display: grid;
  grid-template-columns: 80px 150px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 11px 18px;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}
.log-item:last-child {
  border-bottom: 0;
}
.log-item time {
  font: 700 14px var(--f-display);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

/* ---------- home ---------- */
.home-top {
  background: var(--carbon);
}
.home {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 72px;
}
.hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--rule);
}
.hero h1 {
  margin: 0;
  font: 900 italic clamp(44px, 8vw, 80px)/0.95 var(--f-display);
  letter-spacing: -0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}
.hero h1 em {
  color: var(--f1);
  font-style: italic;
}
.hero p {
  margin: 18px 0 0;
  max-width: 58ch;
  font-size: 18px;
  color: var(--ink-2);
  text-wrap: pretty;
}
.home-label {
  font: 700 12px var(--f-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 32px 0 12px;
}
.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.rowcard {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 4px 18px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r);
  padding: 16px 20px;
  text-decoration: none;
}
.rowcard .pos {
  --b: var(--ink);
  color: var(--ground);
  font: 900 italic 20px/1 var(--f-display);
  padding: 8px 12px;
  min-width: 48px;
  text-align: center;
}
.rowcard.featured .pos {
  --b: var(--f1);
  color: #fff;
}
.rowcard h3 {
  margin: 0;
  font: 900 italic 21px/1.15 var(--f-display);
}
.rowcard p {
  margin: 2px 0 0;
  color: var(--ink-2);
  font-size: 14px;
}
.rowcard .go-cta {
  --b: var(--f1);
  color: #fff;
  font: 700 14px/1 var(--f-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 11px 20px;
  white-space: nowrap;
  border: 0;
  background: none;
  cursor: pointer;
}
.rowcard .go-cta.quiet {
  --b: var(--surface-3);
  color: var(--ink);
}
.rowcard .x {
  margin-left: 6px;
}

/* ---------- modal / toast ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 16, 0.55);
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal {
  width: min(560px, 100%);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  background: var(--surface);
  border-radius: var(--r);
  border-top: 4px solid var(--f1);
}
.modal-h {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
}
.modal-h h3 {
  margin: 0;
  font: 900 italic 20px/1.1 var(--f-display);
  text-transform: uppercase;
}
.modal-h .btn {
  margin-left: auto;
}
.modal-b {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-f {
  padding: 14px 20px;
  border-top: 1px solid var(--rule);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}
/* Toasts read like race-control messages */
.toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  width: min(580px, calc(100% - 24px));
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--carbon);
  color: #fff;
  padding: 0 10px 0 0;
  font-size: 14px;
  min-height: 46px;
  animation: rise 0.16s ease-out;
  border-radius: 3px;
  overflow: hidden;
}
.toast::before {
  content: 'RACE CONTROL';
  align-self: stretch;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--carbon-2);
  border-left: 4px solid var(--on-carbon-2);
  font: 700 10px/1 var(--f-display);
  letter-spacing: 0.12em;
  color: var(--on-carbon-2);
  white-space: nowrap;
}
.toast.bad::before {
  border-left-color: var(--f1);
}
.toast.warn::before {
  border-left-color: #ffc53d;
}
.toast.ok::before {
  border-left-color: #2bd67b;
}
.toast > .ic {
  display: none;
}
.toast .btn {
  margin-left: auto;
  background: transparent;
  color: #fff;
  border-color: #4a4a5c;
}
@keyframes rise {
  from {
    transform: translateY(6px);
    opacity: 0;
  }
}
.linkbox {
  display: flex;
  gap: 8px;
}
.linkbox input {
  font: 600 13px var(--f-display);
}
.menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 250px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--f1);
  border-radius: var(--r-sm);
  padding: 6px;
  box-shadow: 0 18px 40px rgba(10, 10, 16, 0.18);
  z-index: 40;
}
.topbar .menu .btn {
  width: 100%;
  justify-content: flex-start;
  border: 0;
  background: none;
  color: var(--ink);
  font-weight: 600;
  padding: 10px 10px;
}
.topbar .menu .btn:hover {
  background: var(--surface-2);
}
.menu hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 6px 0;
}
.rel {
  position: relative;
}
.empty {
  text-align: center;
  padding: 52px 20px;
  color: var(--muted);
}
.empty > .ic {
  display: none;
}
.empty h3 {
  color: var(--ink);
  margin: 0 0 6px;
  font: 900 italic 24px/1.1 var(--f-display);
  text-transform: uppercase;
}
.empty p {
  margin: 0 0 16px;
}
.ro-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink-2);
  padding: 10px 14px;
  background: var(--surface);
  border-left: 3px solid var(--ink);
  margin-bottom: 16px;
}
.foot {
  color: var(--muted);
  font: 600 12px var(--f-display);
  letter-spacing: 0.04em;
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}
details > summary {
  list-style: none;
}
details > summary::before {
  content: '+ ';
}
details[open] > summary::before {
  content: '− ';
}

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .live-grid {
    grid-template-columns: repeat(min(var(--cols, 3), 2), minmax(0, 1fr));
  }
  .event-id .sub {
    display: none;
  }
}
@media (max-width: 900px) {
  .live-grid {
    grid-template-columns: 1fr;
  }
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .summary > div:nth-child(3) {
    border-left: 0;
    padding-left: 0;
  }
  .event-id {
    display: none;
  }
}
@media (max-width: 640px) {
  html,
  body {
    font-size: 14px;
  }
  .topbar-in {
    padding: 0 12px;
    height: 56px;
    gap: 10px;
  }
  .mark {
    font-size: 12px;
    padding: 7px 10px;
  }
  .rc-block {
    padding: 0 10px;
  }
  .rc-big {
    font-size: 24px;
  }
  .rc-elapsed {
    display: none;
  }
  .conn span {
    display: none;
  }
  .top-actions {
    padding-left: 6px;
  }
  main {
    padding: 14px 12px 104px;
  }
  .tabs-bar {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 35;
    border-top: 1px solid var(--rule);
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabs {
    justify-content: space-around;
    padding: 0;
  }
  .tab {
    flex-direction: column;
    gap: 4px;
    font-size: 10.5px;
    padding: 9px 4px 10px;
    border-bottom: 0;
    border-top: 3px solid transparent;
  }
  .tab .ic {
    display: block;
  }
  .tab[aria-current='page'] {
    border-top-color: var(--f1);
  }
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  .me-card {
    grid-template-columns: 1fr;
  }
  .log-item {
    grid-template-columns: 64px 1fr auto;
    padding: 10px 12px;
  }
  .log-item .chip-c {
    display: none;
  }
  .pit-grid {
    grid-template-columns: 1fr;
  }
  .tm-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tm-status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .timer {
    font-size: 72px;
  }
  .section-title {
    font-size: 26px;
  }
  .rowcard {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 14px;
  }
  .rowcard .cta {
    grid-column: 1 / -1;
    margin-top: 8px;
  }
  .hide-sm {
    display: none !important;
  }
}
@media (min-width: 641px) {
  .show-sm {
    display: none !important;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
