/* =====================================================================
   PPF admin + player — self-contained styles. No CDN: Geist is served
   from assets/fonts (SIL OFL 1.1, see GEIST-LICENSE.txt).
   Palette: zinc neutrals + RACEMASTER blue (lead) and green (second),
   both muted (<= 62% sat), taken from the PPF badge.
   Theme: follows the system; html[data-theme] pins light or dark
   (set by the switch in the sidebar, remembered per browser).
   ===================================================================== */

@font-face {
  font-family: "Geist";
  src: url("fonts/Geist-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/GeistMono-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --bg:            #f5f5f6;
  --surface:       #ffffff;
  --surface-sunk:  #f4f4f5;
  --field:         #ffffff;
  --line:          #e6e6e9;
  --line-strong:   #d4d4d8;

  --text:          #18181b;
  --text-muted:    #52525b;
  --text-faint:    #8b8b94;

  /* Brand: federation blue leads (actions, links, current page); green
     follows (brand details, live). Both muted, taken from the PPF badge. */
  --accent:        hsl(212 62% 38%);
  --accent-hi:     hsl(208 60% 47%);
  --accent-soft:   hsl(212 60% 95%);
  --accent-line:   hsl(212 40% 80%);
  --on-accent:     #ffffff;
  --accent2:       hsl(152 48% 34%);
  --accent2-hi:    hsl(150 46% 42%);
  --accent2-soft:  hsl(152 40% 94%);

  --ok:            hsl(152 42% 32%);
  --ok-soft:       hsl(152 38% 95%);
  --warn:          hsl(28 62% 38%);
  --warn-soft:     hsl(38 70% 95%);
  --danger:        hsl(2 58% 44%);
  --danger-soft:   hsl(2 62% 96%);

  --radius:        10px;
  --radius-lg:     18px;
  --ease:          cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows tinted to the ground (cool zinc), never pure black. */
  --shadow:        0 1px 2px hsl(215 10% 50% / 0.08), 0 14px 34px -20px hsl(215 16% 35% / 0.22);
  --shadow-pop:    0 2px 6px hsl(215 10% 40% / 0.10), 0 22px 48px -22px hsl(215 16% 30% / 0.32);
  --highlight:     inset 0 1px 0 hsl(0 0% 100% / 0.7);
  --mesh-a:        hsl(210 70% 60% / 0.10);
  --mesh-b:        hsl(152 50% 50% / 0.07);
  --grain:         0.035;

  /* The systemic layers, and nothing else. */
  --z-nav:         30;
  --z-pop:         40;
  --z-rail:        35;   /* desktop slim menu (tooltips over the page) */
  --z-scrim:       45;   /* drawer: dimmed page behind it */
  --z-drawer:      50;   /* drawer itself */
  --rail-w:        72px;

  --font: "Geist", "Segoe UI Variable Text", "Segoe UI", "Noto Sans", sans-serif;
  --mono: "Geist Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
}

/* Dark: once for "follow the system", once for "pinned dark". */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:           #09090b;   /* zinc-950, not #000 */
    --surface:      #111113;
    --surface-sunk: #18181b;
    --field:        #0d0d0f;
    --line:         #232327;
    --line-strong:  #34343b;

    --text:         #f4f4f5;
    --text-muted:   #a1a1aa;
    --text-faint:   #71717a;

    --accent:       hsl(211 70% 66%);
    --accent-hi:    hsl(208 72% 74%);
    --accent-soft:  hsl(213 34% 14%);
    --accent-line:  hsl(213 30% 30%);
    --on-accent:    hsl(213 50% 10%);
    --accent2:      hsl(150 44% 58%);
    --accent2-hi:   hsl(150 46% 68%);
    --accent2-soft: hsl(152 26% 12%);

    --ok:           hsl(152 40% 60%);
    --ok-soft:      hsl(152 24% 12%);
    --warn:         hsl(38 62% 62%);
    --warn-soft:    hsl(38 30% 13%);
    --danger:       hsl(2 66% 66%);
    --danger-soft:  hsl(2 32% 14%);

    --shadow:       0 1px 2px hsl(240 10% 2% / 0.5), 0 14px 34px -18px hsl(240 10% 2% / 0.8);
    --shadow-pop:   0 2px 8px hsl(240 10% 2% / 0.6), 0 24px 52px -20px hsl(240 10% 2% / 0.9);
    --highlight:    inset 0 1px 0 hsl(0 0% 100% / 0.05);
    --mesh-a:       hsl(210 60% 50% / 0.10);
    --mesh-b:       hsl(152 40% 40% / 0.07);
    --grain:        0.05;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #09090b;
  --surface:      #111113;
  --surface-sunk: #18181b;
  --field:        #0d0d0f;
  --line:         #232327;
  --line-strong:  #34343b;

  --text:         #f4f4f5;
  --text-muted:   #a1a1aa;
  --text-faint:   #71717a;

  --accent:       hsl(211 70% 66%);
  --accent-hi:    hsl(208 72% 74%);
  --accent-soft:  hsl(213 34% 14%);
  --accent-line:  hsl(213 30% 30%);
  --on-accent:    hsl(213 50% 10%);
  --accent2:      hsl(150 44% 58%);
  --accent2-hi:   hsl(150 46% 68%);
  --accent2-soft: hsl(152 26% 12%);

  --ok:           hsl(152 40% 60%);
  --ok-soft:      hsl(152 24% 12%);
  --warn:         hsl(38 62% 62%);
  --warn-soft:    hsl(38 30% 13%);
  --danger:       hsl(2 66% 66%);
  --danger-soft:  hsl(2 32% 14%);

  --shadow:       0 1px 2px hsl(240 10% 2% / 0.5), 0 14px 34px -18px hsl(240 10% 2% / 0.8);
  --shadow-pop:   0 2px 8px hsl(240 10% 2% / 0.6), 0 24px 52px -20px hsl(240 10% 2% / 0.9);
  --highlight:    inset 0 1px 0 hsl(0 0% 100% / 0.05);
  --mesh-a:       hsl(210 60% 50% / 0.10);
  --mesh-b:       hsl(152 40% 40% / 0.07);
  --grain:        0.05;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ground: a soft blue/green mesh plus fine grain. Both on FIXED,
   pointer-events-none pseudo-elements -- never on anything that scrolls. */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}
body::before {
  background:
    radial-gradient(1100px 620px at -8% -12%, var(--mesh-a), transparent 62%),
    radial-gradient(900px 560px at 108% -6%, var(--mesh-b), transparent 60%);
}
body::after {
  opacity: var(--grain);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

::selection { background: var(--accent-soft); color: var(--text); }

/* Numbers in this app are read in columns — velocities, distances, ranks. */
.num, td.num, .table td, .stat-value { font-variant-numeric: tabular-nums; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.icon { flex: none; display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* ---------------------------------------------------------------- shell */

/* One column on every screen: a sticky top bar with the menu button, the
   page, and the pinned footer. The sidebar is a slide-out drawer -- on a
   phone and on a desktop alike (the user's call) -- wired in app.js. */
.shell { min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: 14px;
  padding: 11px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { padding: 0; gap: 10px; }
.topbar .brand-logo { width: 34px; height: 34px; }

/* Off-canvas by transform only; visibility drops after the slide so a
   closed drawer takes no Tab stops. */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: var(--z-drawer);
  width: 300px; height: 100dvh;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 14px 20px;
  display: flex; flex-direction: column; gap: 22px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow-pop);
  transform: translateX(-104%);
  visibility: hidden;
  transition: transform .42s var(--ease), visibility 0s linear .42s;
}
.sidebar.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform .42s var(--ease), visibility 0s;
}
.sidebar.is-dragging { transition: none; }
.drawer-scrim {
  position: fixed; inset: 0; z-index: var(--z-scrim);
  background: hsl(215 30% 8% / 0.42);
  opacity: 0; pointer-events: none;
  transition: opacity .35s var(--ease);
}
.drawer-open .drawer-scrim { opacity: 1; pointer-events: auto; }
html.drawer-open { overflow: hidden; }   /* page stays put behind the drawer */

/* Items cascade in as the drawer opens. */
.sidebar.is-open .nav a { animation: drawer-item .45s var(--ease) backwards; }
.sidebar.is-open .nav a:nth-child(2) { animation-delay: 40ms; }
.sidebar.is-open .nav a:nth-child(3) { animation-delay: 80ms; }
.sidebar.is-open .nav a:nth-child(4) { animation-delay: 120ms; }
.sidebar.is-open .nav a:nth-child(5) { animation-delay: 160ms; }
.sidebar.is-open .nav a:nth-child(6) { animation-delay: 200ms; }
.sidebar.is-open .nav a:nth-child(n+7) { animation-delay: 240ms; }

.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px;
  color: var(--text); text-decoration: none;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* The player tab bar is phone-only (shown in the mobile block below). */
.tabbar { display: none; }

/* ------------------------------------------------ desktop slim menu (rail)
   Always on screen at the left edge; the top bar, page and footer sit to
   its right. Hidden on a phone (the top bar's menu button takes over). */
.rail {
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: var(--z-rail);
  width: var(--rail-w);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 11px 0 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.rail-links { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 10px; border-top: 1px solid var(--line); width: 44px; }
.rail-link {
  position: relative;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  color: var(--text-faint); text-decoration: none;
  transition: color .3s var(--ease), background-color .3s var(--ease), transform .3s var(--ease);
}
.rail-link:hover { color: var(--text); background: var(--surface-sunk); }
.rail-link:active { transform: scale(.94); }
.rail-link[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
/* Current page: a short accent bar on the rail's edge, like the drawer's. */
.rail-link::before {
  content: ""; position: absolute; left: -14px; top: 11px; bottom: 11px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
  transform: scaleY(0); transition: transform .4s var(--ease);
}
.rail-link[aria-current="page"]::before { transform: scaleY(1); }
.rail-foot { margin-top: auto; }
/* Tooltip label, slid in with transform + opacity only. */
.rail-link::after, .rail-menu::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 12px); top: 50%;
  padding: 5px 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 560; white-space: nowrap;
  color: var(--surface); background: var(--text);
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transform: translate(-4px, -50%);
  transition: opacity .2s var(--ease), transform .3s var(--ease);
}
.rail-menu { position: relative; }
.rail-link:hover::after, .rail-link:focus-visible::after,
.rail-menu:hover::after, .rail-menu:focus-visible::after { opacity: 1; transform: translate(0, -50%); }

.topbar, .main { margin-left: var(--rail-w); }
.main { width: calc(100% - var(--rail-w)); }
.topbar .menu-btn { display: none; }        /* the rail has it on desktop */

.menu-btn, .drawer-close {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  cursor: pointer;
  transition: transform .3s var(--ease), border-color .3s var(--ease);
}
.menu-btn:hover, .drawer-close:hover { border-color: var(--accent-line); }
.menu-btn:active, .drawer-close:active { transform: scale(.94); }

/* Footer of every page's main column: pinned to the bottom of the screen,
   never scrolls away. .main carries matching bottom padding so the last
   row of a page is never hidden under it. */
.page-foot {
  position: fixed; left: var(--rail-w); right: 0; bottom: 0;
  z-index: var(--z-nav);
  padding: 10px 44px 12px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.page-foot .powered { align-items: center; text-align: center; }
/* The PPF badge (round PNG, transparent corners, own navy rim). */
.brand-logo {
  display: block; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  box-shadow: 0 6px 16px -8px hsl(212 60% 25% / 0.55);
}
.brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
/* RACEMASTER wordmark: RACE in blue, MASTER in green -- the only place the
   two brand colours sit side by side. Solid fills, no gradient text. */
.wordmark { font-weight: 720; letter-spacing: 0.05em; line-height: 1.15; color: var(--accent); white-space: nowrap; }
.wordmark b { font-weight: inherit; color: var(--accent2); }
.brand-mark { font-size: 15px; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); }
.powered {
  display: flex; flex-direction: column; gap: 1px;
  font-size: 12px; line-height: 1.45; color: var(--text-faint);
}
.powered strong { font-weight: 640; letter-spacing: 0.05em; color: var(--text-muted); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: color .3s var(--ease), background-color .3s var(--ease), transform .3s var(--ease);
}
.nav a .icon { opacity: .8; transition: transform .3s var(--ease), opacity .3s var(--ease); }
.nav a:hover { color: var(--text); background: var(--surface-sunk); }
.nav a:hover .icon { opacity: 1; transform: translateX(1px); }
.nav a:active { transform: scale(.98); }
.nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}
.nav a[aria-current="page"] .icon { opacity: 1; }
/* Active marker: a short bar on the rail, grown in with transform. */
.nav a::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
  transform: scaleY(0); transition: transform .4s var(--ease);
}
.nav a[aria-current="page"]::before { transform: scaleY(1); }

.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 8px 0;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--text-faint);
}
.sidebar-foot strong { color: var(--text-muted); font-weight: 550; display: block; }
.who { display: flex; align-items: center; gap: 10px; }
.who-avatar {
  display: grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 12.5px; font-weight: 650; color: var(--accent);
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.who-text strong { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text span { font-size: 11.5px; text-transform: capitalize; }
.foot-links { display: flex; gap: 14px; flex-wrap: wrap; }
.foot-links a {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-muted); text-decoration: none;
  transition: color .3s var(--ease);
}
.foot-links a:hover { color: var(--accent); }

/* Auto / Light / Dark segmented control. */
.theme-switch {
  display: inline-grid; grid-template-columns: repeat(3, 1fr);
  padding: 3px; gap: 2px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 100%;
}
.theme-switch button {
  display: grid; place-items: center;
  height: 26px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-faint);
  cursor: pointer;
  transition: background-color .3s var(--ease), color .3s var(--ease), transform .3s var(--ease);
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button:active { transform: scale(.94); }
.theme-switch button[aria-checked="true"] {
  background: var(--surface); color: var(--accent);
  box-shadow: 0 1px 2px hsl(240 6% 20% / 0.15), var(--highlight);
}

.main { padding: 34px 44px 140px; max-width: 1400px; }

/* Asymmetric header: title left, actions right. Never centered. */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
  flex-wrap: wrap;
}
.page-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.page-head p { margin: 6px 0 0; color: var(--text-muted); font-size: 14px; max-width: 65ch; line-height: 1.6; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Load-in: the page settles in a short cascade. `backwards` (not `both`)
   so no transform is left behind once it ends -- a lingering transform
   would trap the player-search dropdown under the next panel. */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: none; }
}
.main > * { animation: rise .7s var(--ease) backwards; }
.main > *:nth-child(2) { animation-delay: 60ms; }
.main > *:nth-child(3) { animation-delay: 120ms; }
.main > *:nth-child(4) { animation-delay: 180ms; }
.main > *:nth-child(5) { animation-delay: 240ms; }
.main > *:nth-child(n+6) { animation-delay: 300ms; }

/* ---------------------------------------------------------------- panel */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), var(--highlight);
  overflow: hidden;
}
.panel + .panel { margin-top: 22px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 14.5px; font-weight: 620; letter-spacing: -0.01em; }
.panel-head .hint { font-size: 12.5px; color: var(--text-faint); }
.panel-body { padding: 20px; }

/* ---------------------------------------------------------------- table */

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 11px 20px;
  background: color-mix(in srgb, var(--surface-sunk) 70%, transparent);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 12px 20px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr {
  transition: background-color .3s var(--ease);
  animation: fade .45s var(--ease) backwards;
}
.table tbody tr:nth-child(2) { animation-delay: 25ms; }
.table tbody tr:nth-child(3) { animation-delay: 50ms; }
.table tbody tr:nth-child(4) { animation-delay: 75ms; }
.table tbody tr:nth-child(5) { animation-delay: 100ms; }
.table tbody tr:nth-child(6) { animation-delay: 125ms; }
.table tbody tr:nth-child(7) { animation-delay: 150ms; }
.table tbody tr:nth-child(n+8) { animation-delay: 175ms; }
.table tbody tr:hover { background: var(--surface-sunk); }
.table .right { text-align: right; }
.table-scroll { overflow-x: auto; }

.mono { font-family: var(--mono); font-size: 13px; letter-spacing: -0.01em; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }

/* Rank: the one thing the eye hunts for on race day. */
.rank {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 26px; padding: 0 8px;
  border-radius: 8px;
  font-size: 12.5px; font-weight: 650;
  background: var(--surface-sunk); color: var(--text-muted);
  border: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.rank.top {
  background: linear-gradient(160deg, var(--accent-soft), var(--surface));
  color: var(--accent); border-color: var(--accent-line);
}
.rank.none { background: transparent; color: var(--text-faint); font-weight: 400; border-color: transparent; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 560; letter-spacing: 0.01em;
  background: var(--surface-sunk); color: var(--text-muted);
  border: 1px solid var(--line);
}
.pill.ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.pill.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* --------------------------------------------------------------- inputs */

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; }
.field label { font-size: 13px; font-weight: 560; color: var(--text); }
.field .helper { font-size: 12px; color: var(--text-faint); line-height: 1.45; }
.field .field-error { font-size: 12.5px; color: var(--danger); min-height: 0; }
.field .field-error:empty { display: none; }

input[type=text], input[type=password], input[type=date], input[type=url],
input[type=datetime-local], input[type=number], select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 2px hsl(240 6% 20% / 0.04);
  transition: border-color .3s var(--ease), box-shadow .3s var(--ease), background-color .3s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--text-faint)); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
input[aria-invalid="true"] { border-color: var(--danger); }
input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--danger-soft); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }

/* A grid cell holding only the form's button(s): line them up with the
   INPUT beside them, not with the bottom of its helper text. The cell sits
   at the top of the row and drops by one label line + the label gap. */
.form-grid > .field:has(> .btn, > .page-actions):not(:has(input, select, textarea)) {
  align-self: start;
  justify-content: flex-start !important;   /* beats the old inline flex-end */
  padding-top: calc(13px * 1.55 + 7px);
}
.form-grid > .field:has(> .btn, > .page-actions):not(:has(input, select, textarea)) .btn {
  min-height: 40px;                         /* same height as the inputs */
  justify-content: center;
}

/* --------------------------------------------------------------- button */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 38px;
  padding: 8px 15px;
  font: inherit; font-size: 13.5px; font-weight: 560;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px hsl(240 6% 20% / 0.06), var(--highlight);
  cursor: pointer;
  text-decoration: none;
  transition: transform .3s var(--ease), background-color .3s var(--ease),
              border-color .3s var(--ease), opacity .3s var(--ease), box-shadow .3s var(--ease);
}
.btn:hover { background: var(--surface-sunk); }
.btn:active { transform: scale(.98) translateY(1px); }          /* tactile */
.btn.primary {
  color: var(--on-accent);
  background: linear-gradient(180deg, var(--accent-hi), var(--accent));
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.22), 0 6px 16px -10px var(--accent);
}
.btn.primary:hover { filter: brightness(1.05); box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.22), 0 10px 22px -12px var(--accent); }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; filter: none; }
.btn.small { min-height: 30px; padding: 5px 11px; font-size: 12.5px; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }

/* ------------------------------------------------------------- FB Live
   Red here is meaning (on air), not a third brand colour: the dot and the
   LIVE word only. */
.live-dot.is-red, .live-dot.is-red::after { background: var(--danger); }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 6px;
  padding: 2px 8px 2px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; vertical-align: 2px;
  color: var(--danger); background: var(--danger-soft);
}
.live-now {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 18px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); border-radius: 14px;
  background: var(--danger-soft);
}
/* display:flex would beat the [hidden] attribute these two are toggled with. */
.live-now[hidden], .live-card[hidden] { display: none; }
.live-now-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.live-now-text a { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.live-now-text .faint { font-size: 12px; }

/* Member dashboard: the card on top while a live is on. */
.live-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 20px; margin-bottom: 22px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow), var(--highlight);
  animation: rise .5s var(--ease) backwards;
}
.live-card-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.live-card-text strong { font-size: 16px; font-weight: 640; letter-spacing: -0.01em; }
.live-card-text span { font-size: 13px; color: var(--text-muted); }

/* --------------------------------------------------------------- alerts */

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  font-size: 13.5px;
  margin-bottom: 18px;
  animation: fade .4s var(--ease) backwards;
}
.alert.error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger); }
.alert.ok    { background: var(--ok-soft);     border-color: color-mix(in srgb, var(--ok) 45%, transparent);     color: var(--ok); }
.alert.warn  { background: var(--warn-soft);   border-color: color-mix(in srgb, var(--warn) 45%, transparent);   color: var(--warn); }
.alert:empty { display: none; }

/* ------------------------------------------------- loading / empty state */

/* Skeletons mirror the row geometry rather than spinning in the middle. */
.skel {
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-sunk) 25%, var(--line) 37%, var(--surface-sunk) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

.empty { padding: 48px 22px; text-align: center; }
.empty h3 { margin: 0 0 6px; font-size: 15px; font-weight: 620; letter-spacing: -0.01em; }
.empty p { margin: 0 auto 16px; color: var(--text-muted); font-size: 13.5px; max-width: 46ch; }

/* ----------------------------------------------------------- stats strip */

/* Deliberately not 3 equal cards: a wide lead column, then narrow readouts. */
.stats {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}
.stat { background: var(--surface); padding: 17px 20px; }
.stat:first-child { background: linear-gradient(150deg, var(--accent-soft), var(--surface) 70%); }
.stat-label { font-size: 11px; font-weight: 560; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.stat-value { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; margin-top: 4px; line-height: 1.2; }
.stat-value.small { font-size: 15px; font-weight: 560; letter-spacing: -0.01em; }

/* Live pulse — the one perpetual animation, isolated to one dot. */
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-faint); }
.live-dot {
  position: relative;
  display: inline-block; flex: none;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
}
.live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: var(--ok);
  animation: ping 2.4s var(--ease) infinite;
}
@keyframes ping {
  0%   { opacity: .6; transform: scale(1); }
  70%  { opacity: 0;  transform: scale(2.6); }
  100% { opacity: 0;  transform: scale(2.6); }
}

/* ---------------------------------------------------------------- login */

/* Split screen, per the house ban on centred hero blocks. */
.login-shell { display: grid; grid-template-columns: 1.05fr 1fr; min-height: 100dvh; }
.login-aside {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(700px 420px at 0% 0%, hsl(210 62% 50% / 0.16), transparent 65%),
    radial-gradient(600px 400px at 100% 100%, hsl(152 48% 42% / 0.12), transparent 60%),
    var(--surface);
  border-right: 1px solid var(--line);
  padding: 44px 48px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.login-brand { display: flex; align-items: center; gap: 11px; font-size: 13px; font-weight: 560; color: var(--text-muted); }
.login-brand .brand-logo { width: 34px; height: 34px; }
/* The badge drifts a few px, forever: the page's one perpetual motion. */
.login-badge {
  display: block; width: 132px; height: 132px; margin: 0 0 26px;
  border-radius: 50%;
  box-shadow: 0 26px 50px -24px hsl(212 60% 22% / 0.6);
  animation: rise .8s var(--ease) backwards, float 6s ease-in-out .8s infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.login-hero h1 {
  font-size: 40px; margin: 0 0 8px; letter-spacing: 0.04em;
  animation: rise .8s var(--ease) backwards;
}
.login-hero .login-tagline {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 18px; font-size: 15px; font-weight: 560; color: var(--text);
  animation: rise .8s var(--ease) 40ms backwards;
}
.login-tagline::before {
  content: ""; flex: none; width: 22px; height: 3px; border-radius: 3px; background: var(--accent2);
}
.login-hero p {
  color: var(--text-muted); font-size: 15px; max-width: 44ch; margin: 0; line-height: 1.65;
  animation: rise .8s var(--ease) 80ms backwards;
}
.login-points {
  list-style: none; margin: 28px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 12px;
  font-size: 13.5px; color: var(--text-muted);
  animation: rise .8s var(--ease) 160ms backwards;
}
.login-points li { display: flex; align-items: center; gap: 12px; }
.login-points .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); flex: none; }
.login-meta { display: flex; flex-direction: column; gap: 14px; font-size: 12px; color: var(--text-faint); max-width: 52ch; }
.login-form-wrap { display: flex; align-items: center; padding: 48px; }
.login-form {
  width: 100%; max-width: 380px;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop), var(--highlight);
  animation: rise .8s var(--ease) 120ms backwards;
}
.login-form h2 { font-size: 18px; font-weight: 640; letter-spacing: -0.02em; margin: 0 0 22px; }

/* ------------------------------------------------- player identity card */

/* Sidebar block on the player side. Sunk rather than raised: it is context,
   not something to act on. */
.player-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-sunk);
  padding: 13px 14px 14px;
}
.player-card-label {
  font-size: 11px; font-weight: 560; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); margin-bottom: 9px;
}
.player-card-rows { display: flex; flex-direction: column; gap: 8px; }
.player-card-rows > div { display: flex; flex-direction: column; gap: 1px; }
.player-card-rows span   { font-size: 11px; color: var(--text-faint); }
.player-card-rows strong { font-size: 13px; font-weight: 560; word-break: break-word; }
.player-card-rows strong.mono { font-family: var(--mono); font-weight: 450; }

/* ------------------------------------------------------ race-day banner */

.banner {
  border: 1px solid var(--accent-line);
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, var(--accent-soft), var(--surface) 60%);
  box-shadow: var(--shadow), var(--highlight);
  padding: 20px 22px;
}
.banner.live { background: linear-gradient(150deg, var(--warn-soft), var(--surface) 70%); }
.banner-kicker {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 560; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint);
}
.banner.live .banner-kicker { color: var(--warn); }
.banner-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.banner.live .banner-dot { background: var(--warn); }
.banner-title { font-size: 21px; font-weight: 650; letter-spacing: -0.025em; margin-top: 6px; }
.banner-sub { color: var(--text-muted); font-size: 13.5px; margin-top: 2px; }
.banner-figures {
  display: flex; gap: 30px; flex-wrap: wrap;
  margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line);
}

/* --------------------------------------------------------- bird pickers */

/* Race-day targets: tapped one-handed, outdoors, in a hurry. */
.pickers { display: flex; flex-wrap: wrap; gap: 8px; }
.picker {
  display: flex; flex-direction: column; gap: 1px; justify-content: center;
  padding: 9px 14px; min-height: 46px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  box-shadow: var(--highlight);
  transition: transform .3s var(--ease), border-color .3s var(--ease),
              background-color .3s var(--ease);
}
.picker:hover { background: var(--surface-sunk); }
.picker:active { transform: scale(.98); }
.picker[aria-pressed="true"] {
  border-color: var(--accent-line); background: var(--accent-soft);
}
.picker[aria-pressed="true"] .picker-name { color: var(--accent); }
.picker[disabled] { opacity: .5; cursor: not-allowed; }
.picker-name { font-size: 13.5px; font-weight: 600; }
.picker-ring { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); }

.clock-row { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.clock-row:last-child { border-bottom: 0; }

/* ------------------------------------------------------------ combobox */
/* Basketing player search. The list is an overlay, so it takes the one
   stacking layer it needs above the page content. */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: var(--z-pop);
  margin: 0; padding: 5px; list-style: none;
  max-height: 300px; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  animation: fade .25s var(--ease) backwards;
}
.combo-list [role=option] {
  display: flex; flex-direction: column; gap: 2px;
  padding: 9px 11px; border-radius: 8px; cursor: pointer;
  transition: background .3s var(--ease);
}
.combo-list [role=option]:hover,
.combo-list [role=option][aria-selected="true"] { background: var(--accent-soft); }
.combo-list [role=option]:active { transform: scale(.98); }
.combo-main { font-size: 13.5px; font-weight: 600; color: var(--text); }
.combo-sub  { font-size: 12px; color: var(--text-muted); }
.combo-empty { padding: 10px; font-size: 13px; color: var(--text-muted); }

/* ---------------------------------------------------------- race ticks */
/* .field sets display:flex, which would beat the [hidden] attribute. */
.ticks { border: 0; padding: 0; min-width: 0; }
.ticks[hidden] { display: none; }
.ticks legend { padding: 0; margin-bottom: 6px; font-size: 13px; font-weight: 560; color: var(--text); }
.tick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.field label.tick {
  display: inline-flex; align-items: center; gap: 11px;
  padding: 9px 15px 9px 11px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  cursor: pointer;
  font-weight: 400;
  box-shadow: var(--highlight);
  transition: transform .3s var(--ease), border-color .3s var(--ease), background-color .3s var(--ease);
}
.field label.tick:hover { border-color: var(--accent-line); }
.field label.tick:active { transform: scale(.98); }
.tick input { width: 17px; height: 17px; margin: 0; accent-color: var(--accent); }
.tick-text { display: flex; flex-direction: column; gap: 1px; }
.tick-main { font-size: 13.5px; font-weight: 600; color: var(--text); }
.tick-sub  { font-size: 12px; color: var(--text-muted); }
.field label.tick:has(input:checked) {
  background: linear-gradient(160deg, var(--accent-soft), var(--surface));
  border-color: var(--accent-line);
}
.field label.tick:has(input:focus-visible) { box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }
.field label.tick:has(input:disabled) { opacity: .55; cursor: not-allowed; }
/* Carried from the season's first race: on, fixed, and plainly so. */
.field label.tick.locked { opacity: 1; border-style: dashed; border-color: var(--accent); }
.field label.tick.locked .tick-sub { color: var(--accent); font-weight: 550; }
.field label.tick:has(input[aria-invalid="true"]) { border-color: var(--danger); }

/* ------------------------------------------------- series & categories */

.panel-foot { border-top: 1px solid var(--line); }
.form-grid-4 { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.4fr) auto; }
.field .field-label { font-size: 13px; font-weight: 560; color: var(--text); }
.table tr.row-off td { color: var(--text-faint); }
.table tr.row-off strong { font-weight: 500; }

.order-btns { display: inline-flex; gap: 4px; }
.btn.icon { padding: 4px 9px; min-width: 30px; justify-content: center; }

/* On/off switch around a real checkbox (keyboard + screen reader intact). */
.switch {
  position: relative;
  display: inline-flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--text-muted); cursor: pointer;
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; flex: none;
  width: 36px; height: 21px; border-radius: 999px;
  background: var(--line-strong);
  transition: background-color .3s var(--ease), transform .3s var(--ease);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px hsl(240 6% 20% / 0.3);
  transition: transform .4s var(--ease);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(15px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px var(--accent-soft); }
.switch input:disabled + .switch-track { opacity: .55; }
.switch:active .switch-track { transform: scale(.96); }

.inline-input { padding: 5px 9px; font-size: 13.5px; max-width: 260px; min-height: 32px; }

/* Races page: one row per truck, each lap a link chip. */
.lap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
a.lap-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 560; text-decoration: none;
  color: var(--text); background: var(--surface-sunk);
  border: 1px solid var(--line);
  transition: border-color .3s var(--ease), background-color .3s var(--ease), transform .3s var(--ease);
}
a.lap-chip:hover { border-color: var(--accent-line); background: var(--accent-soft); }
a.lap-chip:active { transform: scale(.98); }
a.lap-chip .mono { font-size: 11px; color: var(--text-faint); }
.series-meta { display: flex; align-items: center; gap: 10px; }
.attach-row td { background: var(--surface-sunk); }
.attach-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.attach-form .field { margin-bottom: 0; min-width: 200px; }
.attach-form .field.lap { min-width: 90px; max-width: 110px; }

/* --------------------------------------- general category checklist */

.form-grid-5 { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.1fr) minmax(0, 1fr) auto; }
.panel-sub { border-bottom: 1px solid var(--line); background: var(--surface-sunk); }
.inline-select { width: auto; padding: 5px 9px; font-size: 13px; min-height: 32px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ticks legend .faint { font-weight: 400; }

/* Admin tick editor on race.php: opens under the entry row. */
.tick-edit td { background: var(--surface-sunk); padding-top: 16px; padding-bottom: 16px; }
.tick-edit .field { margin-bottom: 14px; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 860px) {
  /* No rail on a phone: the top bar's menu button opens the drawer. */
  .rail { display: none; }
  .topbar, .main { margin-left: 0; }
  .topbar .menu-btn { display: grid; }
  .topbar { padding: 10px 16px; gap: 12px; }
  .topbar .brand-logo { width: 32px; height: 32px; }
  .sidebar { width: min(86vw, 320px); padding: 16px 14px 20px; }

  .main { width: 100%; padding: 24px 16px 110px; }
  .page-head h1 { font-size: 22px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:first-child { grid-column: 1 / -1; }
  /* Lead spans the row; with an even count the last one would sit alone
     next to an empty cell, so it spans too. */
  .stat:last-child:nth-child(even) { grid-column: 1 / -1; }
  .form-grid, .form-grid-4, .form-grid-5 { grid-template-columns: 1fr; }
  .tick-row { flex-direction: column; }
  .field label.tick { width: 100%; }
  .attach-form .field, .attach-form .field.lap { min-width: 0; max-width: none; width: 100%; }

  .login-shell { grid-template-columns: 1fr; }
  .login-aside { border-right: 0; border-bottom: 1px solid var(--line); padding: 28px 20px; gap: 24px; }
  .login-hero h1 { font-size: 30px; }
  .login-badge { width: 96px; height: 96px; margin-bottom: 18px; }
  .login-points { display: none; }
  .login-form-wrap { padding: 24px 16px 40px; }
  .login-form { max-width: none; padding: 22px; }

  .player-card { width: 100%; }
  .player-card-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
  .banner-figures { gap: 20px; }

  /* Player side on a phone: a bottom tab bar within thumb reach, beside the drawer. */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: var(--z-nav);
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px;   /* one column per tab */
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -12px 30px -20px hsl(215 14% 10% / 0.35);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 4px; border-radius: 12px;
    color: var(--text-muted); text-decoration: none;
    font-size: 11px; font-weight: 500; text-align: center; line-height: 1.2;
    transition: color .3s var(--ease), background-color .3s var(--ease), transform .3s var(--ease);
  }
  .tabbar a:active { transform: scale(.96); }
  .tabbar a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

  /* Pinned footer on a phone: one compact strip (wraps to two lines at
     most), sitting on top of the player tab bar where there is one. */
  .page-foot { left: 0; padding: 7px 16px calc(7px + env(safe-area-inset-bottom)); }
  .page-foot .powered { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0 6px; font-size: 11px; }
  .is-player .page-foot { bottom: calc(65px + env(safe-area-inset-bottom)); padding-bottom: 7px; }
  .is-player .main { padding-bottom: 170px; }
}
/* A printed page (results, lists) gets the footer once, in the flow, not
   pinned over the content; the phone chrome is left out. */
@media print {
  .topbar, .tabbar, .drawer-scrim { display: none !important; }
  .page-foot { position: static; padding: 18px 0 0; }
}
@keyframes drawer-item {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: none; }
}

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

/* ------------------------------------------------------------ truck map */
/* Live TruckGPS view: map left (wide), the trucks as cards on the right.
   The map is the one place tiles come from outside (OpenStreetMap). */
.tm-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 22px; align-items: start; }
.tm-map {
  height: min(68dvh, 640px); min-height: 360px;
  border-radius: var(--radius-lg); border: 1px solid var(--line);
  box-shadow: var(--shadow); overflow: hidden; background: var(--surface-sunk);
}
.tm-side { display: flex; flex-direction: column; gap: 10px; }
.tm-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--text-faint); }
.tm-card {
  display: flex; flex-direction: column; gap: 6px; width: 100%;
  padding: 14px 16px; text-align: left; cursor: pointer;
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow), var(--highlight);
  transition: transform .3s var(--ease), border-color .3s var(--ease);
  animation: fade .4s var(--ease) backwards;
}
.tm-card:hover { border-color: var(--accent-line); }
.tm-card:active { transform: scale(.98); }
.tm-card-top { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.tm-big { font-size: 24px; font-weight: 650; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.tm-big small { font-size: 13px; font-weight: 500; color: var(--text-muted); letter-spacing: 0; }
.tm-meta, .tm-muted { font-size: 12.5px; color: var(--text-muted); }
.tm-card.is-stale .tm-meta b { color: var(--warn); }
.tm-live {
  position: relative; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--ok);
}
.tm-live::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--ok);
  animation: ping 2.4s var(--ease) infinite;
}
.tm-live.is-stale, .tm-live.is-stale::after { background: var(--warn); }
.tm-empty {
  padding: 26px 20px; border: 1px dashed var(--line-strong); border-radius: 14px; background: var(--surface);
}
.tm-empty h3 { margin: 0 0 6px; font-size: 15px; font-weight: 620; }
.tm-empty p { margin: 0; font-size: 13.5px; color: var(--text-muted); }

/* Map markers (Leaflet divIcons). */
.tm-icon, .tm-lib { background: none; border: 0; }
.tm-dot {
  position: relative; display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--on-accent);
  background: linear-gradient(160deg, var(--accent-hi), var(--accent));
  border: 2px solid #fff;
  box-shadow: 0 6px 16px -6px hsl(212 40% 20% / .6);
}
.tm-icon.is-stale .tm-dot { filter: grayscale(.8); opacity: .8; }
.tm-arrow {
  position: absolute; inset: -9px; pointer-events: none;
}
.tm-arrow::before {
  content: ""; position: absolute; left: 50%; top: 0; margin-left: -5px;
  border: 5px solid transparent; border-bottom: 7px solid var(--accent); border-top: 0;
}
.tm-flag {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--surface); color: var(--ok); border: 2px solid var(--ok);
  box-shadow: 0 4px 12px -6px hsl(240 10% 10% / .5);
}
.leaflet-container { font: inherit; }

@media (max-width: 860px) {
  .tm-layout { grid-template-columns: minmax(0, 1fr); }
  .tm-side { order: -1; }
  .tm-map { height: 56dvh; }
}

/* ------------------------------------------------------- notifications */
/* Player dashboard list and the admin Announcements history. Dividers, not
   boxes: they are entries of one list. */
.notice-list { display: flex; flex-direction: column; }
.notice {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  animation: fade .4s var(--ease) backwards;
}
.notice:last-child { border-bottom: 0; }
.notice.is-race { background: linear-gradient(90deg, var(--ok-soft), transparent 60%); }
.notice.is-removed { opacity: .55; }
.notice-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.notice strong { font-size: 14.5px; font-weight: 620; letter-spacing: -0.01em; }
.notice p { margin: 0; color: var(--text-muted); font-size: 13.5px; white-space: pre-line; max-width: 75ch; }
.notice-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-faint); }
.counter { font-size: 12px; color: var(--text-faint); text-align: right; }
