/* ═══════════════════════════════════════════════════════════════
   ac.9cs.rs — Assetto Corsa servers and time-attack leaderboard.

   The palette, type scale and geometry are the 9CS design system,
   copied rather than imported: this site is static HTML on nginx and
   shares no build with the Astro app on 9cs.rs. The token names are
   identical, so a value changed there can be changed here by name.

   Everything below the token block is layout, plus the timing-screen
   vocabulary (sectors, gaps, purple bests) the main site has no use for.
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens — mirrors 9cs/web/src/styles/tokens.css ───────────── */

:root,
:root[data-theme='dark'] {
  --bg-primary: #0f0f14;
  --bg-secondary: #1a1a22;

  --accent: #573dd3;
  --accent-hover: #6b4de6;

  --text-primary: #e8eaed;
  --text-secondary: #9ca3af;

  --glass-bg: rgba(26, 26, 34, 0.6);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

  --accent-glow: rgba(87, 61, 211, 0.25);
  --accent-subtle: rgba(87, 61, 211, 0.1);

  --radius: 12px;
  --radius-lg: 20px;

  --input-bg: rgba(15, 15, 20, 0.5);
  --input-bg-focus: rgba(15, 15, 20, 0.8);
  --hover-bg: rgba(255, 255, 255, 0.05);
  --scrollbar-thumb: rgba(255, 255, 255, 0.1);
  --table-row-border: rgba(255, 255, 255, 0.04);

  /* Site-only: the timing-screen signal colours. Purple is the fastest
     time of the session in every real timing screen ever built, and it
     happens to be the brand accent — so a purple sector here is both. */
  --live: #3ecf8e;
  --live-glow: rgba(62, 207, 142, 0.18);
  --down: #ef476f;
  --idle: #f0a02c;
  --gold: #d8b34a;
  --silver: #a8adb8;
  --bronze: #b9793f;
}

:root[data-theme='light'] {
  --bg-primary: #f0f0f3;
  --bg-secondary: #ffffff;

  --text-primary: #1a1a22;
  --text-secondary: #6b7280;

  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(0, 0, 0, 0.1);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);

  --accent-glow: rgba(87, 61, 211, 0.2);
  --accent-subtle: rgba(87, 61, 211, 0.06);

  --input-bg: rgba(0, 0, 0, 0.04);
  --input-bg-focus: rgba(0, 0, 0, 0.07);
  --hover-bg: rgba(0, 0, 0, 0.04);
  --scrollbar-thumb: rgba(0, 0, 0, 0.15);
  --table-row-border: rgba(0, 0, 0, 0.06);

  --live: #16a06a;
  --live-glow: rgba(22, 160, 106, 0.14);
  --down: #d62d55;
  --idle: #c37a12;
  --gold: #9c7d18;
  --silver: #6f757f;
  --bronze: #8f5a29;
}

/* ── Type and scaffolding ─────────────────────────────────────── */

:root {
  --font-display: Archivo, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body: Archivo, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --gutter: clamp(1.15rem, 5vw, 3.5rem);
  --section-y: clamp(3rem, 7vw, 5.5rem);

  --step--1: 0.82rem;
  --step-0: 1.02rem;
  --step-1: clamp(1.1rem, 1.6vw, 1.3rem);
  --step-2: clamp(1.5rem, 3vw, 2.1rem);
  --step-3: clamp(2rem, 5vw, 3.2rem);
  --step-4: clamp(2.6rem, 8vw, 5rem);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 4rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.028em;
  line-height: 1.04;
  text-wrap: balance;
  margin: 0;
}

p { text-wrap: pretty; margin: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  max-width: 82rem;
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--section-y); }
.section-alt { background: var(--bg-secondary); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0 0 1.1rem;
}
.eyebrow::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--glass-border);
}

.section-title { font-size: var(--step-3); }

.lede {
  margin: 0.9rem 0 0;
  max-width: 60ch;
  color: var(--text-secondary);
  font-size: var(--step-1);
}

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

/* ── Cross-property strip ─────────────────────────────────────────
   A static copy of <nine-cs-header>. The Astro app builds this from a
   web component because three tools share one document there; here one
   page needs one strip, and a custom element would only cost a script. */

.chrome {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  font-size: 12px;
  line-height: 1;
}

.chrome-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 40px;
  padding-inline: clamp(0.6rem, 3vw, 1.5rem);
  max-width: 90rem;
  margin: 0 auto;
}

/* The mark is a mask, so the glyph takes the accent token and cannot go
   out of step with the palette. Same trick as the header component. */
.chrome-mark {
  flex: none;
  display: block;
  width: 37px;
  height: 20px;
  background: var(--accent);
  -webkit-mask: url('/logo.png') center / contain no-repeat;
  mask: url('/logo.png') center / contain no-repeat;
  text-indent: -9999px;
  overflow: hidden;
}

.chrome nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.chrome nav::-webkit-scrollbar { display: none; }

.chrome .item {
  flex: none;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.chrome .item:hover { color: var(--text-primary); background: var(--hover-bg); }
.chrome .item[aria-current='page'] {
  color: var(--text-primary);
  background: var(--accent-subtle);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.chrome .item[data-soon] { opacity: 0.4; cursor: default; }

.chrome-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: none;
}

.chrome button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  border-radius: 6px;
  cursor: pointer;
  padding: 0.35rem 0.45rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.chrome button:hover { color: var(--text-primary); background: var(--hover-bg); }
.chrome button svg { display: block; width: 15px; height: 15px; }

.lang {
  padding: 3px;
  border-radius: 4px;
  line-height: 0;
  opacity: 0.45;
  filter: saturate(0.25);
}
.lang:hover { opacity: 0.85; filter: saturate(0.8); background: transparent; }
.lang[aria-pressed='true'] { opacity: 1; filter: none; box-shadow: 0 0 0 1.5px var(--accent); }
.lang svg {
  display: block;
  width: 19px;
  height: 13px;
  border-radius: 2px;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.35);
}

.chrome .sep {
  width: 1px;
  height: 16px;
  background: var(--glass-border);
  flex: none;
}

@media (max-width: 620px) {
  .chrome-bar { gap: 0.5rem; }
  .chrome .item { padding: 0.4rem 0.34rem; }
  .chrome .item[data-id='site'] { display: none; }
  .chrome nav {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 16px), transparent);
  }
}

/* ── Hero ─────────────────────────────────────────────────────────
   No video here. The main site can afford an 18 MB onboard clip on a
   landing page; this one is a dashboard people open to check whether a
   server is up, so it starts with the numbers. */

.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border-bottom: 1px solid var(--glass-border);
  padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(2rem, 4vw, 3rem);
}
.hero::before {
  content: '';
  position: absolute;
  inset: -40% -10% auto;
  height: 130%;
  z-index: -1;
  background:
    radial-gradient(60% 55% at 20% 0%, var(--accent-glow), transparent 70%),
    radial-gradient(45% 45% at 85% 10%, var(--live-glow), transparent 70%);
  pointer-events: none;
}

.hero h1 {
  font-size: var(--step-4);
  max-width: 15ch;
}
.hero h1 .accent { color: var(--accent); }

.hero .lede { max-width: 52ch; }

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.8rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.94rem;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { border-color: var(--glass-border); color: var(--text-primary); }
.btn-ghost:hover { border-color: var(--accent); background: var(--accent-subtle); }

/* ── Stat strip ──────────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
  gap: 1px;
  margin-top: 2.4rem;
  background: var(--glass-border);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.stat {
  background: var(--bg-primary);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-value .unit { font-size: 0.5em; color: var(--text-secondary); margin-left: 0.15em; }
.stat-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.stat.is-live .stat-value { color: var(--live); }

/* ── Section headers with controls ───────────────────────────── */

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}
.section-head .meta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* A dot that says the page is still talking to the server. */
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 var(--live);
  flex: none;
}
.pulse.beat { animation: beat 1.6s ease-out; }
@keyframes beat {
  0% { box-shadow: 0 0 0 0 var(--live-glow); }
  70% { box-shadow: 0 0 0 7px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.pulse.stale { background: var(--idle); }
.pulse.dead { background: var(--down); }

/* ── Controls: search, segmented toggles ─────────────────────── */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-top: 1.6rem;
}

.search {
  position: relative;
  flex: 1 1 14rem;
  max-width: 22rem;
  display: flex;
  align-items: center;
}
.search svg {
  position: absolute;
  left: 0.7rem;
  width: 15px;
  height: 15px;
  color: var(--text-secondary);
  pointer-events: none;
}
.search input {
  width: 100%;
  padding: 0.55rem 0.8rem 0.55rem 2.1rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--input-bg);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.88rem;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
.search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--input-bg-focus);
}
.search input::placeholder { color: var(--text-secondary); opacity: 0.75; }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  background: var(--input-bg);
}
.segmented button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button[aria-pressed='true'] { background: var(--accent); color: #fff; }

/* ── Server cards ────────────────────────────────────────────── */

.servers {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr));
  gap: 0.9rem;
  margin-top: 1.6rem;
}

.server {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass-bg);
  overflow: hidden;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.server:hover { border-color: var(--accent); transform: translateY(-2px); }
.server.is-offline { opacity: 0.62; }
.server.is-offline:hover { transform: none; border-color: var(--glass-border); }

/* A left edge that carries the state, so a grid of twelve reads at a
   glance without anyone parsing twelve status words. */
.server::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--text-secondary);
  opacity: 0.4;
}
.server.is-online::before { background: var(--live); opacity: 1; }
.server.is-busy::before { background: var(--accent); opacity: 1; }
.server.is-offline::before { background: var(--down); opacity: 0.8; }

.server-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 1rem 1.1rem 0.7rem 1.3rem;
}
.server-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.server-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}
.state {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}
.state .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.server.is-online .state { color: var(--live); }
.server.is-busy .state { color: var(--accent); }
.server.is-offline .state { color: var(--down); }
.server.is-checking .state .dot { animation: blink 1.1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.server-body {
  padding: 0 1.1rem 0.9rem 1.3rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.84rem;
}
.server-body dt {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  align-self: center;
}
.server-body dd {
  margin: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-line {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.4rem;
}
.bar {
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: var(--hover-bg);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.5s ease;
}
.server.is-online .bar-fill { background: linear-gradient(90deg, var(--live), var(--accent)); }
.slots {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  min-width: 3.4rem;
  text-align: right;
}
.slots b { color: var(--text-primary); }

/* Who is actually driving. Nothing else on the page answers that. */
.drivers-now {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.5rem;
}
.driver-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-subtle);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.server-foot {
  margin-top: auto;
  display: flex;
  border-top: 1px solid var(--glass-border);
}
.server-foot a,
.server-foot button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 0.6rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.server-foot a { color: var(--accent); flex: 2; }
.server-foot a:hover { background: var(--accent-subtle); }
.server-foot button { border-left: 1px solid var(--glass-border); }
.server-foot button:hover { color: var(--text-primary); background: var(--hover-bg); }
.server-foot button.done { color: var(--live); }
.server-foot svg { width: 15px; height: 15px; }

/* ── Leaderboard ─────────────────────────────────────────────── */

.lb {
  margin-top: 1.4rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  overflow: hidden;
}

/* Track and car choosers. Two rows of pills rather than tabs: the track
   list grows past a dozen and tabs stop being clickable long before a
   wrapped pill row stops being readable. */
.picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--glass-border);
}
.picker-cars { background: var(--input-bg); }
.picker:empty { display: none; }

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}
.pill:hover { color: var(--text-primary); border-color: var(--accent); }
.pill[aria-pressed='true'] {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.pill .n {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 400;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}
.pill-sm { font-size: 0.76rem; padding: 0.3rem 0.65rem; }

/* Podium — the three rows people actually came to see, pulled out of
   the table so they survive a phone screen. */
.podium {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr));
  gap: 1px;
  background: var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
}
.podium:empty { display: none; }
.podium-slot {
  background: var(--bg-primary);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.podium-pos {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.podium-slot:nth-child(1) .podium-pos { color: var(--gold); }
.podium-slot:nth-child(2) .podium-pos { color: var(--silver); }
.podium-slot:nth-child(3) .podium-pos { color: var(--bronze); }
.podium-driver {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.podium-time {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.podium-slot:nth-child(1) .podium-time { color: var(--accent); }
.podium-meta {
  font-size: 0.74rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 0.7rem 0.9rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--glass-border);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
  white-space: nowrap;
}
th.num, td.num { text-align: right; }
tbody td {
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--table-row-border);
  font-size: 0.88rem;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--hover-bg); }
tbody tr.is-match { background: var(--accent-subtle); }

/* Sortable column headers, used by the drivers table. */
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text-primary); }
th[aria-sort] { color: var(--accent); }
th[data-sort]::after { content: ''; }
th[aria-sort='descending']::after { content: ' ↓'; }
th[aria-sort='ascending']::after { content: ' ↑'; }

.pos {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  width: 3rem;
  font-size: 0.8rem;
}
.pos.p1 { color: var(--gold); }
.pos.p2 { color: var(--silver); }
.pos.p3 { color: var(--bronze); }

.driver-cell { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.driver-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  flex: none;
}
.tag.rec { color: var(--accent); border-color: var(--accent); }

.time {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.time.lead { color: var(--accent); }

.gap { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-secondary); }

.sector {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
}
/* Purple is the fastest sector of the board, the way every timing screen
   in the sport marks it — and it is the brand accent by coincidence. */
.sector.best { color: var(--accent); font-weight: 600; }

.car-cell, .when {
  color: var(--text-secondary);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 14rem;
}

.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-secondary);
}
.empty strong { display: block; color: var(--text-primary); font-size: 1.05rem; margin-bottom: 0.3rem; }

/* Loading skeleton — three grey bars, so a slow fetch does not look
   like an empty leaderboard. */
.skeleton { padding: 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; }
.skeleton div {
  height: 2.2rem;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--hover-bg) 25%, var(--glass-border) 50%, var(--hover-bg) 75%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -300% 0; } }

/* ── Downloads ───────────────────────────────────────────────── */

.dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
  gap: 0.5rem;
  margin-top: 1.4rem;
}
.dl {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  background: var(--glass-bg);
  text-decoration: none;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}
.dl:hover { border-color: var(--accent); background: var(--accent-subtle); }
.dl svg { width: 16px; height: 16px; color: var(--accent); flex: none; }
.dl-name {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dl-size {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-secondary);
  flex: none;
}

/* ── Help ────────────────────────────────────────────────────── */

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1px;
  margin-top: 2rem;
  background: var(--glass-border);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.step {
  background: var(--bg-primary);
  padding: clamp(1.2rem, 2.5vw, 1.8rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.step-n {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.step h3 { font-size: 1.15rem; }
.step p { color: var(--text-secondary); font-size: 0.9rem; }
.step a { color: var(--accent); font-weight: 600; }
.step code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--input-bg);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 0.1rem 0.35rem;
}

/* ── Discord ─────────────────────────────────────────────────── */

.discord {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.1rem 1.3rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: linear-gradient(100deg, var(--accent-subtle), transparent 60%);
  text-decoration: none;
  transition: border-color 0.18s ease;
}
.discord:hover { border-color: var(--accent); }
.discord svg { width: 30px; height: 30px; color: #5865f2; flex: none; }
.discord .txt { flex: 1 1 14rem; min-width: 0; }
.discord .t { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; }
.discord .s { color: var(--text-secondary); font-size: 0.86rem; }
.discord .go {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ── Footer ──────────────────────────────────────────────────── */

.footer {
  border-top: 1px solid var(--glass-border);
  padding-block: 2.6rem 2rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.footer-top {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem 3rem;
  justify-content: space-between;
}
.footer-mark {
  width: 46px;
  height: 25px;
  background: var(--accent);
  -webkit-mask: url('/logo.png') center / contain no-repeat;
  mask: url('/logo.png') center / contain no-repeat;
}
.footer-links { display: flex; gap: 2.4rem; flex-wrap: wrap; }
.footer-col { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-col h4 {
  margin: 0 0 0.2rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.footer-col a { text-decoration: none; }
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  margin-top: 2.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--glass-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

/* ── Toast ───────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translate(-50%, 150%);
  z-index: 60;
  padding: 0.6rem 1.1rem;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  box-shadow: var(--glass-shadow);
  font-size: 0.86rem;
  font-weight: 600;
  transition: transform 0.25s ease;
}
.toast.show { transform: translate(-50%, 0); }

/* ── Narrow screens ──────────────────────────────────────────────
   The leaderboard table is the only thing here that cannot simply
   reflow: seven columns do not fit a phone. Sectors and the set-on
   date go first — they are reference, not the answer to "who is
   fastest" — and the table keeps its shape rather than turning into
   cards, so positions stay comparable down the column. */

@media (max-width: 860px) {
  .lb .sector-col, .lb .when-col { display: none; }
}
@media (max-width: 560px) {
  .lb .car-col { display: none; }
  tbody td, thead th { padding: 0.55rem 0.6rem; }
  .pos { width: 2.2rem; }
}

@media print {
  .chrome, .hero-cta, .controls, .server-foot, .discord { display: none; }
  body { background: #fff; color: #000; }
}
