/* === NIKC R2 · Pit-lane timing tower ===================================
   Aesthetic: matte black surfaces, NIKC racing red as signal,
   hi-vis yellow reserved for LIVE moments only, class-livery spine
   on every session card.
   Type: Antonio (display) / Manrope (body) / JetBrains Mono (numerics).
   ====================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  /* Surfaces — pit-paddock paper */
  --bg-0:        #f3f2ec;  /* warm off-white page */
  --bg-1:        #fbfaf4;  /* card */
  --bg-2:        #e8e5d6;  /* active / elevated */
  --bg-3:        #d8d4c2;  /* deeper elevated */
  --border:      #c8c3ae;  /* warm beige border */
  --border-soft: rgba(20, 18, 8, 0.10);
  --hairline:    rgba(20, 18, 8, 0.06);

  /* Text */
  --text:        #14140e;  /* near-black, warm tint */
  --text-dim:    #4d4d44;
  --text-faint:  #7a7a6e;
  --text-mute:   #a8a698;

  /* Signal palette */
  --signal:      #e30021;  /* deep racing red */
  --signal-deep: #a8001a;
  --signal-soft: rgba(227, 0, 33, 0.10);
  --signal-fg:   #ffffff;

  --hi-vis:      #fbe122;
  --hi-vis-deep: #b89e00;
  --hi-vis-fg:   #0b0c11;

  --ok:          #0c7a44;
  --warn:        #a8580c;
  --err:         #b3001a;

  /* Podium medals — readable on the warm light bg (silver/bronze match the
     leader-row podium colours; gold is a deep goldenrod for contrast) */
  --medal-gold:   #a07300;
  --medal-silver: #6b7280;
  --medal-bronze: #92520d;

  /* Class livery — kart-class color spines (deeper for light bg) */
  --c-bambino:   #0e7490;
  --c-cadet:     #4d7c0f;
  --c-int-jr:    #c2410c;
  --c-int-sr:    #6d28d9;
  --c-girls:     #be185d;

  /* Type */
  --display: "Antonio", "Bebas Neue", "Oswald", Impact, sans-serif;
  --body:    "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Spacing & radii */
  --gutter:    16px;
  --radius-sm: 4px;
  --radius:    6px;
  --radius-lg: 10px;
}

/* Class livery cascade — any element with data-class gets a --livery */
[data-class="bambino"] { --livery: var(--c-bambino); }
[data-class="cadet"]   { --livery: var(--c-cadet); }
[data-class="int-jr"]  { --livery: var(--c-int-jr); }
[data-class="int-sr"]  { --livery: var(--c-int-sr); }
[data-class="girls"]   { --livery: var(--c-girls); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  /* Bottom space reserved for the fixed "Powered by CBFoundry" band */
  padding-bottom: calc(44px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 60% at 90% -10%, rgba(227, 0, 33, 0.05), transparent 55%),
    radial-gradient(80% 50% at -10% 80%, rgba(14, 116, 144, 0.03), transparent 50%),
    linear-gradient(180deg, #f3f2ec 0%, #edebde 100%);
  background-attachment: fixed;
  position: relative;
}

/* Paper-grain overlay (very subtle on light bg) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0   0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.5;
  mix-blend-mode: multiply;
  z-index: 0;
}
body > * { position: relative; z-index: 1; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}

/* === Feed strip (very top hairline) ====================================== */
.feed-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
  white-space: nowrap;
}
.feed-strip .strip-tick {
  color: var(--signal);
  font-size: 8px;
  animation: pulse-soft 1.6s ease-in-out infinite;
}
.feed-strip .strip-text {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.22em;
}
.feed-strip .strip-meta {
  color: var(--text-mute);
  overflow: hidden;
  text-overflow: ellipsis;
}
@keyframes pulse-soft {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 1; }
}

/* === Masthead ============================================================ */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px 13px;
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: calc(14px + env(safe-area-inset-top));
  background:
    linear-gradient(115deg, transparent 64%, rgba(227, 0, 33, 0.08) 64.4%, rgba(227, 0, 33, 0.08) 67%, transparent 67.4%),
    linear-gradient(180deg, rgba(243, 242, 236, 0.96), rgba(243, 242, 236, 0.88));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.mast-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.mast-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.08));
}
.mast-titles {
  min-width: 0;
  flex: 1;
}
.mast-wordmark {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
  line-height: 1;
}
.mast-line {
  margin: 5px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
}
.mast-line .mast-tag {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.22em;
}
.mast-line .mast-rule {
  flex: none;
  width: 2px;
  height: 9px;
  background: var(--signal);
  transform: skewX(-18deg);
}
.mast-line .mast-meta {
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
}

.refresh-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: var(--text-dim);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 18px;
  transition: transform 200ms, color 200ms, border-color 200ms, background 200ms;
}
.refresh-btn:hover { color: var(--text); border-color: var(--text-mute); background: var(--bg-2); }
.refresh-btn:active { transform: rotate(120deg) scale(0.94); }

/* === Live banner ========================================================= */
.live-banner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #0a0a0e;
  color: #ffffff;
  padding: 18px 16px;
  cursor: pointer;
  overflow: hidden;
}
.live-banner[hidden] { display: none; }
.live-banner::before,
.live-banner::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: repeating-linear-gradient(135deg,
    var(--hi-vis) 0 10px,
    transparent 10px 20px);
  pointer-events: none;
}
.live-banner::before { top: 0; }
.live-banner::after  { bottom: 0; }

.live-banner .live-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--hi-vis);
}
.live-banner .live-label::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  background: var(--signal);
  border-radius: 999px;
  animation: live-pulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(227, 0, 33, 0);
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(227, 0, 33, 0.7); opacity: 1; }
  50%      { box-shadow: 0 0 0 8px rgba(227, 0, 33, 0); opacity: 0.7; }
}
.live-banner .live-text {
  font-family: var(--body);
  font-weight: 800;
  font-size: 13.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
}
.live-banner .live-cta {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--hi-vis);
  flex: none;
}

/* === Tab bar ============================================================= */
.tab-bar {
  display: flex;
  background: var(--bg-0);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: calc(68px + env(safe-area-inset-top));
  z-index: 19;
}
.tab-bar .tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  position: relative;
  color: var(--text-faint);
  transition: color 150ms, background 150ms;
}
.tab-bar .tab + .tab {
  border-left: 1px solid var(--border-soft);
}
.tab-bar .tab .tab-label {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tab-bar .tab[aria-selected="true"]      { color: var(--text); background: var(--bg-1); }
.tab-bar .tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2.5px;
  background: var(--signal);
}

/* === Tab content shell =================================================== */
.tab-content { flex: 1; }
.tab-panel { padding: 18px 16px 24px; }
.tab-panel[hidden] { display: none; }

.empty {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-align: center;
  padding: 60px 0;
}
/* A <button class="empty"> (the archive-fetch retry control) is inline-block
   by default, so it sits left-aligned at text width instead of filling the
   panel like the sibling "Loading…"/"No sessions yet." <div>s. Force it to
   read as the same centered block; text-align above still centers its
   label, and the full-width box keeps the tap target at least as large as
   the div variant. */
button.empty {
  display: block;
  width: 100%;
}

/* === Schedule lanes ====================================================== */
.lanes {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lane {
  --livery: var(--text-mute);
  position: relative;
  display: grid;
  grid-template-columns: 6px 64px minmax(0, 1fr) auto;
  align-items: stretch;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: background 120ms, border-color 120ms, transform 120ms;
}
.lane--tappable { cursor: pointer; }
.lane--tappable:active { transform: scale(0.995); background: var(--bg-2); }

.lane-livery {
  background: var(--livery);
  align-self: stretch;
}
.lane-livery--admin {
  background: linear-gradient(180deg, var(--text-mute), var(--text-faint));
}
.lane-livery--break {
  background: repeating-linear-gradient(0deg,
    var(--text-mute) 0 4px,
    transparent 4px 8px);
}

.lane-time {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 6px 12px 10px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  border-right: 1px solid var(--hairline);
}
.lane-time .lane-start {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.lane-time .lane-end {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-faint);
  margin-top: 3px;
  letter-spacing: 0.02em;
}

.lane-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 11px 10px 11px 12px;
  min-width: 0;
}
.lane-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
}
.lane-tags .lane-cls {
  color: var(--livery);
  font-weight: 700;
}
.lane-tags .lane-dot {
  color: var(--text-mute);
  letter-spacing: 0;
}
.lane-tags .lane-kind {
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.22em;
}
.lane-label {
  margin: 0;
  font-family: var(--body);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.3;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.lane-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  min-width: 64px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
}
.lane-state--done     { color: var(--text-mute); }
.lane-state--upcoming { color: var(--text-faint); }
.lane-state--next {
  color: var(--warn);
  background: rgba(168, 88, 12, 0.07);
  border-left: 1px solid rgba(168, 88, 12, 0.22);
}
.lane-state--live {
  background: #0a0a0e;
  color: var(--hi-vis);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.18em;
}
.lane-state--live .state-pulse {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--signal);
  margin-right: 7px;
  animation: live-pulse 1.2s ease-in-out infinite;
}

/* Lane state outlines */
.lane--live { border-color: #0a0a0e; }
.lane--next { border-color: rgba(168, 88, 12, 0.36); }
.lane--done { opacity: 0.62; }
.lane--done .lane-time .lane-start { color: var(--text-dim); }
.lane--admin .lane-time .lane-start { color: var(--text-dim); }

/* === Results — chip filter =============================================== */
.chip-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 -16px 18px;
  padding: 4px 16px 6px;
  scrollbar-width: none;
}
.chip-bar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
  transition: all 120ms;
}
.chip:hover { color: var(--text); border-color: var(--text-mute); }
.chip--active {
  color: var(--text);
  background: rgba(255, 31, 58, 0.10);
  border-color: var(--signal);
  box-shadow: inset 0 0 0 1px rgba(255, 31, 58, 0.35);
}

/* === Results — leaderboard slips ========================================= */
.sheets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rsheet {
  --livery: var(--text-mute);
  position: relative;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 160ms;
}
.rsheet::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--livery);
}

.rsheet-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 14px 18px;
  text-align: left;
  transition: background 120ms;
}
.rsheet-head:hover { background: var(--bg-2); }

.rsheet-stamp {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
}
.rsheet-time {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.rsheet-titleline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.rsheet-cls {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-transform: uppercase;
  line-height: 1;
}
.rsheet-grp,
.rsheet-sess {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.rsheet-sep {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
}

.rsheet-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
  white-space: nowrap;
  flex: none;
}
.rsheet-status--done    { color: var(--ok); }
.rsheet-status--running {
  color: var(--hi-vis);
  background: #0a0a0e;
  padding: 4px 9px;
  border-radius: 999px;
}
.rsheet-status .rsheet-tick {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}
.rsheet-status--running .rsheet-tick {
  background: var(--signal);
  animation: live-pulse 1.2s ease-in-out infinite;
}

.rsheet-body {
  display: none;
  padding: 0 16px 14px 18px;
  border-top: 1px solid var(--border-soft);
}
.rsheet--open .rsheet-body { display: block; }

.session-empty {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 16px 0 6px;
}

.rsheet--flash {
  animation: rsheet-flash 1.8s ease-out;
}
@keyframes rsheet-flash {
  0%   { box-shadow: 0 0 0 3px rgba(227, 0, 33, 0.55); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Leaderboard table */
.board {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.board thead th {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 8px 4px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.board tbody td {
  padding: 10px 4px;
  border-bottom: 1px solid var(--hairline);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text);
}
.board tbody tr:last-child td { border-bottom: none; }

.board .b-pos {
  width: 42px;
  font-family: var(--display);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  line-height: 1;
}
.board .b-no {
  width: 42px;
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.board .b-name {
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.005em;
}
.board .b-pen {
  width: 44px;
  text-align: right;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}
.board .b-pen--has { color: var(--warn); font-weight: 700; }
.board .b-laps {
  width: 40px;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.board .b-time {
  width: 84px;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.board tr.row--p1 .b-pos  { color: var(--signal); }
.board tr.row--p1 .b-name { color: var(--text); }
.board tr.row--p2 .b-pos  { color: #6b7280; }
.board tr.row--p3 .b-pos  { color: #92520d; }

/* === Drivers tab ========================================================= */
.grid-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 10px;
}
.grid-head:first-of-type { margin-top: 6px; }
.grid-eyebrow {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.grid-letter {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--signal);
}
.grid-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
}
.grid-count {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.plate-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.plate {
  --livery: var(--text-mute);
  display: grid;
  grid-template-columns: 6px 64px 1fr auto;
  align-items: stretch;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 100%;
  text-align: left;
  transition: transform 120ms, border-color 120ms, background 120ms;
}
.plate:hover { border-color: var(--text-mute); background: var(--bg-2); }
.plate:active { transform: scale(0.995); }

.plate-livery {
  background: var(--livery);
}
.plate-num {
  display: flex;
  align-items: baseline;
  justify-content: center;
  padding: 14px 0;
  border-right: 1px solid var(--hairline);
  font-family: var(--display);
  color: var(--text);
}
.plate-num .plate-prefix {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-mute);
  margin-right: 1px;
}
.plate-num .plate-no {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.plate-body {
  padding: 12px 14px;
  min-width: 0;
}
.plate-name {
  margin: 0;
  font-family: var(--body);
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: 0.005em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.plate-meta {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.plate-arrow {
  display: inline-flex;
  align-items: center;
  padding: 0 16px;
  color: var(--text-mute);
  font-family: var(--mono);
  font-size: 16px;
  transition: transform 200ms, color 200ms;
}
.plate:hover .plate-arrow { color: var(--signal); transform: translateX(2px); }

/* === Footer ============================================================== */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 16px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-0);
  margin-top: auto;
}
/* Results tab — eyebrow with official-sheet link */
.results-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.results-eyebrow .results-eyebrow-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-faint);
}
.results-eyebrow .results-eyebrow-label::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 1.5px;
  background: var(--signal);
}
.results-eyebrow .results-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--signal);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms;
}
.results-eyebrow .results-eyebrow-links {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.results-eyebrow .results-link:hover { color: var(--signal-deep); }
.results-eyebrow .results-link-arrow {
  font-size: 12px;
  font-weight: 700;
  transition: transform 200ms;
}
.results-eyebrow .results-link:hover .results-link-arrow { transform: translate(2px, -2px); }
.site-footer .foot-tick {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--signal);
  animation: live-pulse 1.6s ease-in-out infinite;
}
.site-footer .foot-feed { color: var(--text); font-weight: 700; }
.site-footer .foot-sep  { color: var(--text-mute); }
.site-footer .net-indicator {
  margin-left: 6px;
  color: var(--err);
  font-weight: 700;
  padding: 2px 8px;
  border: 1px solid var(--err);
  border-radius: 999px;
}

/* === Powered-by attribution band ========================================= */
.powered-by {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg-1);
  border-top: 1px solid var(--border-soft);
  box-shadow: 0 -6px 16px -10px rgba(20, 18, 8, 0.18);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
  text-decoration: none;
  transition: background 150ms, color 150ms;
}
.powered-by:hover,
.powered-by:focus-visible { background: var(--bg-2); color: var(--text-dim); }
.powered-by:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.powered-by-label { font-weight: 600; }
.powered-by-logo {
  height: 20px;
  width: 66px;
  max-width: 40vw;
  display: block;
  flex: 0 0 auto;
  opacity: 0.92;
}

/* === Bottom sheet ======================================================== */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
}
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 8, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: backdrop-in 220ms ease-out;
}
.sheet-body {
  position: relative;
  width: 100%;
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  border-top: 4px solid var(--signal);
  border-top-left-radius: 14px;
  border-top-right-radius: 14px;
  padding: 24px 20px calc(28px + env(safe-area-inset-bottom));
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 -16px 48px rgba(20, 18, 8, 0.18);
  animation: sheet-in 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  font-size: 20px;
  color: var(--text-dim);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 150ms, border-color 150ms;
}
.sheet-close:hover { color: var(--text); border-color: var(--text-mute); }

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes sheet-in {
  from { transform: translateY(36%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* Sheet content — driver detail */
.sheet-eyebrow {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--signal);
}
.sheet-title {
  margin: 0 0 4px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.02em;
  line-height: 1.05;
  color: var(--text);
  text-transform: uppercase;
}
.sheet-sub {
  margin: 0 0 22px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sheet-sub .sub-no {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}
.sheet-sub .sub-dot { color: var(--text-mute); }

.sheet-empty {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 18px 0;
  text-align: center;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}

/* Day-log timeline */
.runlog {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  padding-left: 20px;
}
.runlog::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: linear-gradient(180deg, var(--border) 0%, var(--text-mute) 50%, var(--border) 100%);
}
.runlog-item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--bg-2);
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.runlog-item::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--signal);
  transform: translateY(-50%);
  box-shadow: 0 0 0 3px var(--bg-1);
}
.runlog-title {
  font-family: var(--body);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.runlog-meta {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.runlog-pos {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  color: var(--signal);
  letter-spacing: 0.02em;
  line-height: 1;
}
.runlog-time {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* === Stagger-in on mount ================================================= */
.lanes > .lane,
.sheets > .rsheet,
.plate-list > .plate,
.runlog > .runlog-item {
  animation: row-in 340ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.lanes > .lane:nth-child(1)  { animation-delay: 0ms; }
.lanes > .lane:nth-child(2)  { animation-delay: 28ms; }
.lanes > .lane:nth-child(3)  { animation-delay: 56ms; }
.lanes > .lane:nth-child(4)  { animation-delay: 84ms; }
.lanes > .lane:nth-child(5)  { animation-delay: 112ms; }
.lanes > .lane:nth-child(6)  { animation-delay: 140ms; }
.lanes > .lane:nth-child(7)  { animation-delay: 168ms; }
.lanes > .lane:nth-child(n+8){ animation-delay: 180ms; }

.sheets > .rsheet:nth-child(1)  { animation-delay: 0ms; }
.sheets > .rsheet:nth-child(2)  { animation-delay: 36ms; }
.sheets > .rsheet:nth-child(3)  { animation-delay: 72ms; }
.sheets > .rsheet:nth-child(n+4){ animation-delay: 100ms; }

.plate-list > .plate:nth-child(1)  { animation-delay: 0ms; }
.plate-list > .plate:nth-child(2)  { animation-delay: 24ms; }
.plate-list > .plate:nth-child(3)  { animation-delay: 48ms; }
.plate-list > .plate:nth-child(n+4){ animation-delay: 72ms; }

@keyframes row-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* === Wider screens (centered column) ===================================== */
@media (min-width: 720px) {
  body { font-size: 16px; }
  .feed-strip,
  .masthead,
  .live-banner,
  .tab-bar,
  .tab-content,
  .site-footer { max-width: 720px; margin-left: auto; margin-right: auto; }
  .tab-panel { padding: 28px 22px 36px; }
  .mast-wordmark .mast-brand { font-size: 28px; }
  .mast-logo { width: 46px; height: 46px; }
}

/* === Standings — segmented toggle ======================================= */
.toggle-bar {
  display: inline-flex;
  max-width: 100%;
  /* results_rounds grows by one every round and is never pruned, so from
     Round 6 on this segmented control (and the 4-option Standings one)
     would overflow a 360px phone and push the whole page into horizontal
     scroll. Scroll the bar itself instead — same fix as .chip-bar below. */
  overflow-x: auto;
  scrollbar-width: none;
  align-items: center;
  gap: 2px;
  margin: 0 0 14px;
  padding: 3px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.toggle-bar::-webkit-scrollbar { display: none; }
.toggle-bar .toggle-opt {
  appearance: none;
  border: 0;
  background: transparent;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 7px 16px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-radius: 999px;
  cursor: pointer;
  transition: all 120ms;
}
.toggle-bar .toggle-opt:hover { color: var(--text); }
.toggle-bar .toggle-opt--active {
  color: var(--text);
  background: rgba(255, 31, 58, 0.10);
  box-shadow: inset 0 0 0 1px rgba(255, 31, 58, 0.35);
}

/* === Standings — numeric cell =========================================== */
.board .b-num {
  width: 48px;
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.board .b-num--total {
  width: 56px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.board .b-cell {
  width: 36px;
  text-align: right;
  vertical-align: middle;
}
.board .b-cell-pos {
  display: block;
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.board .b-cell-pts {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-mute);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
/* Invisible spacer in the Grid cell so its single position aligns with the
   top (position) line of the two-line TT/Final cells. */
.board .b-cell-pts--ghost { visibility: hidden; }
/* Final-race medal in the leftmost position column (🥇🥈🥉 / 4️⃣5️⃣).
   Slightly under the 19px display size so the glyph sits cleanly in the cell. */
.board .b-pos--medal {
  font-size: 17px;
  line-height: 1;
}
/* Podium-worthy session positions: gold / silver / bronze medals. Applies
   in every per-round session cell incl. Grid; non-podium degrades cleanly. */
.board .b-cell-pos--p1 { color: var(--medal-gold);   font-weight: 800; }
.board .b-cell-pos--p2 { color: var(--medal-silver); font-weight: 800; }
.board .b-cell-pos--p3 { color: var(--medal-bronze); font-weight: 800; }
.board .b-cell-pos--top5 { color: var(--text); }
.board .b-cell-pos--rest { color: var(--text-faint); font-weight: 600; }

/* === Standings — position delta ========================================== */
.board .b-delta {
  width: 38px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.board .b-delta--up   { color: #16a34a; }
.board .b-delta--down { color: var(--signal); }

.board .b-num--dnr {
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* === Standings — horizontal scroll ======================================= */
/* The season table grows a column every round; at phone width it used to be
   squeezed to the screen, wrapping names onto two lines. Let it take its
   natural width and scroll sideways inside this box (bleeding to the screen
   edge like .chip-bar), with names on one line. Pos, Driver and Total lead,
   so the points are visible before any scrolling. */
.board-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 0 -16px;
  padding: 0 16px;
}
.board-scroll .board {
  width: auto;
  min-width: 100%;
}
.board-scroll .board .b-name { white-space: nowrap; padding-right: 12px; }
.board-scroll .board .b-num,
.board-scroll .board .b-cell { padding-left: 10px; padding-right: 10px; }
.board-scroll .board .b-num--total { padding-right: 14px; }
@media (min-width: 720px) {
  .board-scroll { margin: 0 -22px; padding: 0 22px; }
}
