:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel2: #1e222b;
    --line: #2a2f3a;
    --text: #e6e8ec;
    --muted: #9aa3b2;
    --accent: #ffcc00;
    --accent2: #38bdf8;
    --good: #34d399;
}

* { box-sizing: border-box; }

/* Hide scrollbar chrome on every page (page body + the overflow-x table wrappers)
   while keeping the content scrollable via wheel/trackpad/drag. */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 10px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.topbar nav { display: flex; gap: 6px; flex-wrap: wrap; }
.topbar nav a {
    padding: 6px 12px;
    border-radius: 6px;
    color: var(--muted);
}
.topbar nav a:hover { background: var(--panel2); text-decoration: none; }
.topbar nav a.active { background: var(--panel2); color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 18px; }

h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 20px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 16px;
}

table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--panel2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kart { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 5px; background: #2b2f3a; color: var(--accent); font-weight: 700; text-align: center; }
.rid { margin-left: 5px; color: var(--muted); font-size: 0.82em; font-variant-numeric: tabular-nums; }
/* "that's me" highlight */
tr.me, tr.me:hover { background: rgba(255, 196, 0, 0.16); }
tr.me td { font-weight: 600; }
.me-tag, td.cell.me, th.me { box-shadow: inset 0 0 0 2px rgba(255, 196, 0, 0.55); border-radius: 4px; }
.name.me, .rn.me { color: #ffce3a; font-weight: 700; }

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

.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--muted); }
.seg a.active { background: var(--accent); color: #111; font-weight: 700; }
.seg a:hover { text-decoration: none; }

select, button {
    background: var(--panel2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px 10px;
    font: inherit;
}

.badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; background: var(--panel2); color: var(--muted); }
.badge.live { background: #3b0d0d; color: #ff6b6b; }
.badge.on { background: #0d3b1f; color: var(--good); }

/* live lap grid */
.grid-wrap { overflow-x: auto; }
.lapgrid td, .lapgrid th { border: 1px solid var(--line); text-align: center; font-size: 12px; padding: 3px 4px; }
/* Narrow cells: name / id / kart / time stack vertically; long names wrap instead of
   forcing the column wide (overrides the global `td { white-space: nowrap }`). */
.lapgrid .cell { min-width: 46px; max-width: 68px; white-space: normal; }
.lapgrid .cell .rn { color: var(--text); font-weight: 600; line-height: 1.12; word-break: break-word; }
.lapgrid .cell .rid { margin-left: 0; display: block; line-height: 1.15; }
.lapgrid .cell .kline { line-height: 1.4; margin: 1px 0; }
.lapgrid .cell .lt { color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 1px; }
.lapgrid .best .lt { color: var(--good); }
/* fastest lap time across all racers on that lap (the lap leader) */
.lapgrid td.leadlap { background: rgba(94, 168, 255, 0.20); }
.lapgrid td.leadlap .lt { color: #cfe2ff; font-weight: 700; }
.lapgrid td.leadlap.best .lt { color: var(--good); }
.leadlap-key { color: #cfe2ff; font-weight: 700; }
.best-key { color: var(--good); font-weight: 700; }

td.active-col, th.active-col { background: rgba(255,204,0,.08); color: var(--accent); }

/* popularity heatmap */
.heat td { text-align: center; font-size: 12px; padding: 0; }
.heat .rowlabel { text-align: right; color: var(--muted); padding: 4px 6px; }
/* clickable slot: the anchor fills the whole cell so the entire box is a target */
.heat td .slotlink,
.heat td .slotempty { display: block; padding: 4px 6px; min-height: 1.2em; text-decoration: none; }
.heat td .slotlink:hover { text-decoration: none; box-shadow: inset 0 0 0 2px var(--accent); }
/* ring marking the track's open hours */
.heat td.open { box-shadow: inset 0 0 0 2px rgba(239,68,68,.70); }
