:root {
  --bg: #111418; --panel: #1a1f26; --line: #2a313b; --text: #e8ebef; --dim: #8b95a3;
  --accent: #4da3ff; --good: #3ecf6e; --bad: #ff5a5a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
header { display: flex; align-items: baseline; gap: 16px; padding: 14px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header h1 { font-size: 20px; margin: 0; }
header .crumbs { color: var(--dim); }
main { padding: 16px 20px; }
section { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
section h2 { font-size: 15px; margin: 0 0 10px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--dim); font-weight: 600; }
td.best { color: var(--good); font-weight: 700; }
.small { color: var(--dim); font-size: 13px; }
.chip { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input[type=text], input[type=password] { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
button { background: var(--accent); color: #000; border: 0; border-radius: 6px; padding: 8px 14px; font-weight: 700; cursor: pointer; }
.error { color: var(--bad); }
.scroll { overflow-x: auto; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, 1fr); } }
#map { height: max(480px, calc(100vh - 330px)); border-radius: 8px; }
.chart h3 { margin: 4px 0; font-size: 13px; color: var(--dim); font-weight: 600; }
.standings { display: flex; gap: 22px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.standings div b { font-size: 22px; }
.u-legend { color: var(--text); font-size: 12px; }
.replay { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.replay select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 6px; }
button.quiet { background: var(--line); color: var(--text); }
.replay-clock { margin-left: auto; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dot { border: 2px solid #000; border-radius: 50%; color: #000; font: 700 12px/1 system-ui; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px rgba(255,255,255,.7); }
.piece-popup .maplibregl-popup-content { background: var(--panel); color: var(--text); font-size: 13px; }
#readout { margin-top: 6px; font-variant-numeric: tabular-nums; }
.rider-tag { color: #000; font: 700 12px/1 system-ui; padding: 4px 8px; border-radius: 10px; border: 2px solid #000; box-shadow: 0 0 0 2px rgba(255,255,255,.7); white-space: nowrap; }
.sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; margin-bottom: 10px; font-size: 13px; color: var(--dim); }
.sliders label { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.sliders input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); }
@media (max-width: 700px) { .sliders { grid-template-columns: 1fr; } }
.inline-select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; font: inherit; text-transform: none; }
table.live { margin-top: 8px; font-size: 17px; }
table.live td, table.live th { padding: 5px 10px; }

/* Phones: tighter, a shorter map, and the rider column pinned while the grid scrolls. */
@media (max-width: 700px) {
  main { padding: 10px; }
  header { padding: 10px 12px; }
  section { padding: 12px; }
  #map { height: 60vh; }
  th, td { padding: 6px 7px; }
  .replay-clock { margin-left: 0; }
  table.live { font-size: 14px; }
  table.live td, table.live th { padding: 5px 5px; }
  #grid th:first-child, #grid td:first-child { position: sticky; left: 0; background: var(--panel); z-index: 1; }
}
.toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 10px; }
.toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; }
