/* Solo Sim Leaderboard — shared styles for the board, live timing, profile and PIN pages.
   Dark by design: these pages live on an office TV. No external fonts, so the
   second-screen TV works with no internet. */
:root {
  --bg: #0b0d12;
  --surface: #141824;
  --surface-2: #1b2131;
  --border: #283044;
  --text: #edf0f6;
  --muted: #8f98ad;
  --faint: #5d667b;
  --accent: #e10600;
  --record: #b26cff;   /* motorsport purple: fastest overall */
  --pb: #2fd071;       /* green: personal best / valid */
  --bad: #ff5a5f;
  --warn: #ffb020;
  --gold: #f5c542;
  --silver: #c9d1dc;
  --bronze: #d38b5d;
  --radius: 12px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.num, .time { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

/* ---- layout ---------------------------------------------------------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px 48px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 0; border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 10px; height: 28px; background: var(--accent); border-radius: 2px; transform: skewX(-14deg); }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 13px; }
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.nav a:hover, .nav a.on { background: var(--surface-2); color: var(--text); }

/* ---- live pill ------------------------------------------------------- */
.live-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: rgba(225, 6, 0, .14); border: 1px solid rgba(225, 6, 0, .45); font-size: 13px; text-decoration: none;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.stale { color: var(--warn); font-size: 12px; }
.sim-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sim-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.sim-status.on .dot { background: var(--pb); }
.sim-status.off { color: var(--faint); }

/* ---- record strip ---------------------------------------------------- */
.records { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.record-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; text-align: left; transition: border-color .15s;
}
.record-card:hover, .record-card.on { border-color: var(--record); }
.record-card .car { font-weight: 650; font-size: 15px; }
.record-card .track { color: var(--muted); font-size: 12px; margin-top: 2px; }
.record-card .rec { display: flex; align-items: baseline; justify-content: space-between; margin-top: 12px; gap: 8px; }
.record-card .rec .time { font-size: 26px; font-weight: 700; color: var(--record); }
.record-card .holder { font-size: 13px; color: var(--muted); text-align: right; }

/* ---- tabs ------------------------------------------------------------ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.tab {
  background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; font-size: 15px;
}
.tab.on { color: var(--text); border-bottom-color: var(--accent); }

/* ---- tables ---------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 16px; }
table.board { width: 100%; border-collapse: collapse; }
.board th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .6px; padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.board td { padding: 10px 12px; border-bottom: 1px solid rgba(40, 48, 68, .6); vertical-align: middle; }
.board tr:last-child td { border-bottom: 0; }
.board .r { text-align: right; }
.board tr.me td { background: rgba(178, 108, 255, .08); }
.pos { width: 44px; font-weight: 700; font-size: 16px; }
.pos.p1 { color: var(--gold); } .pos.p2 { color: var(--silver); } .pos.p3 { color: var(--bronze); }
.best { font-weight: 650; font-size: 16px; }
.best.record { color: var(--record); }
.gap { color: var(--muted); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ---- driver chip ----------------------------------------------------- */
.who { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.who .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.filter { background: var(--surface); border: 1px solid var(--border); color: var(--muted); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; }
.filter.on { color: var(--text); border-color: var(--accent); background: rgba(225, 6, 0, .12); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; object-fit: cover; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: #fff;
}
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }

/* ---- badges ---------------------------------------------------------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: rgba(47, 208, 113, .14); color: var(--pb); }
.badge.bad { background: rgba(255, 90, 95, .14); color: var(--bad); }
.badge.wait { background: rgba(255, 176, 32, .14); color: var(--warn); }
.badge.practice { background: rgba(143, 152, 173, .16); color: var(--muted); }
.badge.official { background: rgba(225, 6, 0, .16); color: #ff6b66; }
.badge.record { background: rgba(178, 108, 255, .18); color: var(--record); }

/* ---- record history -------------------------------------------------- */
details.history { margin-top: 16px; }
details.history summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li {
  display: grid; grid-template-columns: 110px 1fr auto auto; gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(40, 48, 68, .6);
}

/* ---- live timing ----------------------------------------------------- */
.live-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.live-hero { padding: 24px; }
.live-hero .driver { display: flex; align-items: center; gap: 16px; }
.live-hero .driver .name { font-size: 28px; font-weight: 700; }
.big-time { font-size: 76px; font-weight: 700; letter-spacing: -1px; line-height: 1; margin: 22px 0 6px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { padding: 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.stat .value.record { color: var(--record); }
.stat .value.pb { color: var(--pb); }
.stat .value.bad { color: var(--bad); }
.sectors { display: flex; gap: 8px; margin-top: 14px; }
.sector { flex: 1; padding: 10px; border-radius: 8px; background: var(--surface-2); text-align: center; }
.sector.on { outline: 1px solid var(--accent); }
.sector .label { font-size: 11px; color: var(--muted); }
.banner {
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 600;
  background: rgba(255, 176, 32, .12); border: 1px solid rgba(255, 176, 32, .4); color: var(--warn);
}

/* ---- celebration overlay (TV) --------------------------------------- */
.celebrate {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 50;
  background: rgba(11, 13, 18, .86); animation: fade .3s ease-out;
}
.celebrate .box { text-align: center; padding: 40px; }
.celebrate .kicker { color: var(--record); font-weight: 700; letter-spacing: 3px; text-transform: uppercase; }
.celebrate .who-big { font-size: 64px; font-weight: 800; margin: 12px 0; }
.celebrate .time { font-size: 96px; font-weight: 800; color: var(--record); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- forms (PIN page) ------------------------------------------------ */
.narrow { max-width: 440px; margin: 48px auto; padding: 0 16px; }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], select, textarea {
  width: 100%; padding: 11px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(225, 6, 0, .5); border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  font-weight: 600; text-decoration: none; font-size: 14px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.msg { margin-top: 12px; font-size: 14px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--pb); }

/* ---- TV mode --------------------------------------------------------- */
body.tv { cursor: none; }
body.tv .wrap { max-width: none; padding: 0 3vw 2vw; }
body.tv .nav, body.tv .tv-hide { display: none !important; }
body.tv .topbar { padding: 2vh 0; }
body.tv .brand-name { font-size: 2.4vw; }
body.tv .brand-sub { font-size: 1.2vw; }
body.tv .board td { padding: 1.1vh 1vw; font-size: 1.5vw; }
body.tv .board th { font-size: .9vw; padding: 1vh 1vw; }
body.tv .best { font-size: 1.8vw; }
body.tv .avatar { width: 2.8vw; height: 2.8vw; font-size: 1vw; }
body.tv .record-card .rec .time { font-size: 2.4vw; }
body.tv .view-title { font-size: 2vw; }
.view-title { font-size: 20px; font-weight: 700; margin: 4px 0 12px; display: flex; align-items: baseline; gap: 12px; }
.view-title .sub { color: var(--muted); font-weight: 400; font-size: .7em; }

@media (max-width: 760px) {
  .live-grid { grid-template-columns: 1fr; }
  .big-time { font-size: 56px; }
  .hide-sm { display: none; }
  .board td, .board th { padding: 9px 8px; }
  .history-list li { grid-template-columns: 90px 1fr auto; }
  .history-list li .hide-sm { display: none; }
}
