/* ============================================================
   Sunday Kart League — pit-wall timing screen theme
   ============================================================ */
:root {
  --bg:        #0C0F14;
  --bg-2:      #10141B;
  --surface:   #171C25;
  --surface-2: #1E2531;
  --line:      #28313F;
  --line-soft: #1C2431;
  --text:      #E9EEF4;
  --muted:     #8792A3;
  --faint:     #5A6577;

  --amber:     #FFB020;   /* leader / primary */
  --amber-ink: #1a1204;
  --purple:    #B14EFF;   /* fastest lap (motorsport convention) */
  --green:     #38D27A;   /* personal best / gain */
  --red:       #FF5468;   /* retired / drop */

  --pos1: #FFB020;
  --pos2: #C7D0DC;
  --pos3: #D98A4B;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --disp: "Saira Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(177,78,255,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(255,176,32,.05), transparent 55%),
    var(--bg);
  line-height: 1.5;
  letter-spacing: .01em;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3 { margin: 0; font-family: var(--disp); font-weight: 700; letter-spacing: .01em; line-height: 1.02; }

.container { width: min(1040px, 92vw); margin: 0 auto; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- eyebrow / section labels ---------- */
.eyebrow {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--faint);
  display: flex; align-items: center; gap: .6rem;
}
.eyebrow::before {
  content: ""; width: 22px; height: 2px; background: var(--amber); display: inline-block;
}

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .85rem clamp(1rem, 4vw, 2rem);
  background: rgba(12,15,20,.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav__brand {
  font-family: var(--disp); font-weight: 700; font-size: 1.28rem;
  text-transform: uppercase; letter-spacing: .04em;
  display: flex; align-items: center; gap: .6rem;
}
.nav__flag {
  width: 18px; height: 18px; border-radius: 3px;
  background-image:
    linear-gradient(45deg, var(--text) 25%, transparent 25%, transparent 75%, var(--text) 75%),
    linear-gradient(45deg, var(--text) 25%, transparent 25%, transparent 75%, var(--text) 75%);
  background-size: 9px 9px;
  background-position: 0 0, 4.5px 4.5px;
  background-color: #0C0F14;
  outline: 1.5px solid var(--text); outline-offset: -1px;
}
.nav__links { display: flex; gap: .3rem; }
.nav__links a {
  font-family: var(--mono); font-size: .8rem; letter-spacing: .06em;
  padding: .5rem .8rem; border-radius: 999px; color: var(--muted);
  transition: color .15s, background .15s;
}
.nav__links a:hover { color: var(--text); background: var(--surface); }
.nav__links a.is-active { color: var(--amber-ink); background: var(--amber); }

/* ---------- hero ---------- */
.hero { padding: clamp(2rem, 6vw, 4rem) 0 1.5rem; }
.hero__grid {
  display: grid; grid-template-columns: 1.3fr .9fr; gap: 1.1rem;
}
@media (max-width: 760px){ .hero__grid { grid-template-columns: 1fr; } }

.feature {
  position: relative; overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}
.feature--leader { border-color: rgba(255,176,32,.35); }
.feature--leader::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px;
  background: linear-gradient(var(--amber), rgba(255,176,32,.2));
}
.feature--fl { border-color: rgba(177,78,255,.35); }
.feature--fl::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 5px;
  background: linear-gradient(var(--purple), rgba(177,78,255,.2));
}
.feature__label { margin-bottom: 1rem; }
.feature__name {
  font-family: var(--disp); font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 3.6rem); line-height: .95;
  text-transform: uppercase; letter-spacing: .01em;
}
.feature__row { display: flex; align-items: baseline; gap: .7rem; margin-top: .2rem; }
.feature__big {
  font-family: var(--mono); font-weight: 600; font-size: 1.35rem;
}
.feature--leader .feature__big { color: var(--amber); }
.feature--fl .feature__big { color: var(--purple); }
.feature__sub { color: var(--muted); font-size: .9rem; }
.feature__meta {
  display: flex; gap: 1.4rem; margin-top: 1.1rem; padding-top: 1rem;
  border-top: 1px solid var(--line-soft);
}
.feature__meta > div { display: flex; flex-direction: column; gap: .1rem; }
.feature__meta .k { font-family: var(--mono); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.feature__meta .v { font-family: var(--disp); font-size: 1.5rem; font-weight: 600; }

/* small info cards under hero */
.strip { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; margin-top: 1.1rem; }
@media (max-width: 760px){ .strip { grid-template-columns: 1fr; } }
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 1.2rem 1.3rem;
}
.card h3 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .9rem; }

.countdown { display: flex; align-items: baseline; gap: .6rem; }
.countdown .num { font-family: var(--disp); font-size: 2.6rem; font-weight: 700; color: var(--amber); }
.countdown .lbl { color: var(--muted); }

/* mini result list on home */
.miniresult { display: flex; flex-direction: column; gap: .35rem; }
.miniresult__row { display: flex; align-items: center; gap: .6rem; font-size: .92rem; }
.miniresult__pos { font-family: var(--mono); width: 1.6rem; color: var(--faint); }
.miniresult__bar { width: 3px; height: 16px; border-radius: 2px; }
.miniresult__name { flex: 1; }
.miniresult__time { font-family: var(--mono); color: var(--muted); font-size: .85rem; }

/* ---------- section header ---------- */
.section { padding: 2.2rem 0; }
.section__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.section__title { font-size: clamp(1.8rem, 4vw, 2.6rem); text-transform: uppercase; letter-spacing: .02em; }
.note {
  font-family: var(--mono); font-size: .78rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  padding: .45rem .7rem; border-radius: 999px;
}

/* ---------- timing tower ---------- */
.tower { display: flex; flex-direction: column; gap: 6px; }
.tower__head, .tower__row {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  align-items: center;
  gap: .8rem;
}
.tower__head {
  padding: 0 1rem .3rem;
  font-family: var(--mono); font-size: .68rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--faint);
}
.tower__head .th-stats { display: flex; gap: 1.4rem; justify-content: flex-end; }
.tower__head .th-stats span { width: 4.2rem; text-align: right; }

.tower__row {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: .7rem 1rem;
  transition: transform .12s ease, border-color .12s ease, background .12s;
}
.tower__row:hover { transform: translateX(3px); border-color: var(--line); background: var(--surface-2); }
.tower__row.is-link { cursor: pointer; }

.pos {
  font-family: var(--disp); font-weight: 700; font-size: 1.5rem;
  text-align: center; color: var(--muted); font-variant-numeric: tabular-nums;
}
.tower__row--p1 .pos { color: var(--pos1); }
.tower__row--p2 .pos { color: var(--pos2); }
.tower__row--p3 .pos { color: var(--pos3); }
.tower__row--p1 { border-color: rgba(255,176,32,.32); }

.who { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.chip {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  font-family: var(--disp); font-weight: 700; font-size: .82rem;
  color: #0c0f14;
}
.who__name { font-family: var(--disp); font-weight: 600; font-size: 1.25rem; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who__sub { font-family: var(--mono); font-size: .7rem; color: var(--faint); letter-spacing: .04em; }

.tags { display: flex; gap: .35rem; align-items: center; }
.tag {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .08em;
  padding: .18rem .4rem; border-radius: 5px; text-transform: uppercase;
}
.tag--fl { color: var(--purple); border: 1px solid rgba(177,78,255,.4); background: rgba(177,78,255,.1); }
.tag--retired { color: var(--red); border: 1px solid rgba(255,84,104,.35); background: rgba(255,84,104,.08); }

.stats { display: flex; gap: 1.4rem; justify-content: flex-end; align-items: baseline; }
.stat { width: 4.2rem; text-align: right; }
.stat .n { font-family: var(--mono); font-weight: 600; font-size: 1.05rem; }
.stat .u { font-family: var(--mono); font-size: .6rem; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; display: block; }
.stat--pts .n { color: var(--amber); }
.stat--time .n { color: var(--text); }

@media (max-width: 620px){
  .tower__head { display: none; }
  .tower__row { grid-template-columns: 38px 1fr; grid-auto-rows: auto; row-gap: .5rem; }
  .pos { font-size: 1.3rem; }
  .who { grid-column: 2; }
  .stats { grid-column: 1 / -1; justify-content: flex-start; gap: 1.1rem; padding-left: 0; }
  .stat { text-align: left; width: auto; min-width: 3.4rem; }
  .who__name { font-size: 1.1rem; }
}

/* ---------- driver profile ---------- */
.profile__head {
  display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap;
  padding: 1.6rem 0 1.2rem;
}
.profile__chip {
  width: 68px; height: 68px; border-radius: 14px; flex: none;
  display: grid; place-items: center; color: #0c0f14;
  font-family: var(--disp); font-weight: 700; font-size: 1.8rem;
}
.profile__name { font-size: clamp(2rem, 6vw, 3rem); text-transform: uppercase; }
.profile__sub { font-family: var(--mono); color: var(--muted); font-size: .82rem; letter-spacing: .05em; }

.statgrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin: 1rem 0 1.6rem;
}
@media (max-width: 720px){ .statgrid { grid-template-columns: repeat(2,1fr); } }
.statbox {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); padding: 1rem 1.1rem;
}
.statbox .k { font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.statbox .v { font-family: var(--disp); font-weight: 700; font-size: 2.1rem; line-height: 1.1; margin-top: .25rem; }
.statbox .v small { font-size: .95rem; color: var(--muted); font-family: var(--mono); font-weight: 500; }
.statbox--fl .v { color: var(--purple); }
.statbox--best .v { color: var(--green); }

/* data table */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.log { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 460px; }
table.log th, table.log td { padding: .7rem 1rem; text-align: left; }
table.log th {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); background: var(--bg-2); border-bottom: 1px solid var(--line);
}
table.log td { border-bottom: 1px solid var(--line-soft); }
table.log tr:last-child td { border-bottom: 0; }
table.log td.num, table.log th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.log .pts { color: var(--amber); font-family: var(--mono); }
table.log .fl { color: var(--purple); }

/* ---------- buttons & controls ---------- */
.btn {
  font-family: var(--mono); font-size: .82rem; letter-spacing: .04em;
  padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); font-weight: 600; }
.btn--primary:hover { background: #ffc147; }
.btn--ghost { background: transparent; }
.btn--danger { color: var(--red); border-color: rgba(255,84,104,.3); }
.btn--danger:hover { background: rgba(255,84,104,.1); }
.btn--sm { padding: .35rem .6rem; font-size: .72rem; }

.back { font-family: var(--mono); font-size: .8rem; color: var(--muted); display: inline-flex; gap: .4rem; margin: 1.2rem 0; }
.back:hover { color: var(--amber); }

/* ---------- forms (admin) ---------- */
label.field { display: flex; flex-direction: column; gap: .35rem; }
label.field > span { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
input, select {
  font-family: var(--body); font-size: .92rem;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem;
}
input:focus, select:focus { outline: 2px solid var(--amber); outline-offset: 1px; border-color: transparent; }
input.mono { font-family: var(--mono); }

/* focus visibility everywhere */
a:focus-visible, .btn:focus-visible, .tower__row:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- footer ---------- */
.footer {
  border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.6rem 0 2.4rem;
  font-family: var(--mono); font-size: .74rem; color: var(--faint); letter-spacing: .04em;
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.footer a:hover { color: var(--amber); }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 2.5rem 1.5rem; text-align: center; color: var(--muted);
  font-family: var(--mono); font-size: .9rem;
}

@media (prefers-reduced-motion: reduce){
  * { transition: none !important; animation: none !important; }
}

/* ---------- responsive nav ---------- */
@media (max-width: 700px){
  .nav { flex-wrap: wrap; gap: .5rem .8rem; }
  .nav__brand { font-size: 1.1rem; }
  .nav__links { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .nav__links::-webkit-scrollbar { height: 0; }
  .nav__links a { white-space: nowrap; }
}

/* ---------- gap-to-leader stat ---------- */
.stat--gap .n { color: var(--muted); font-size: .95rem; }
.stat--gap .n.leader { color: var(--amber); }

/* ---------- race archive ---------- */
.arch { display: flex; flex-direction: column; gap: 8px; }
.arch__row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 1rem;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: 10px;
  padding: .8rem 1.1rem; transition: transform .12s, border-color .12s, background .12s;
}
.arch__row:hover { transform: translateX(3px); border-color: var(--line); background: var(--surface-2); }
.arch__date { font-family: var(--mono); font-size: .78rem; color: var(--muted); width: 5.4rem; }
.arch__track { font-family: var(--disp); font-weight: 600; font-size: 1.2rem; }
.arch__win { font-family: var(--mono); font-size: .74rem; color: var(--faint); }
.arch__win b { color: var(--text); font-weight: 500; }
.arch__meta { display: flex; align-items: center; gap: .8rem; }
.arch__flag { font-family: var(--mono); font-size: .68rem; color: var(--purple); }
.arch__go { color: var(--faint); font-family: var(--mono); }

/* ---------- attendance matrix ---------- */
.matrix-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table.matrix { border-collapse: collapse; width: 100%; font-size: .82rem; }
table.matrix th, table.matrix td { padding: .55rem .6rem; text-align: center; white-space: nowrap; }
table.matrix thead th { font-family: var(--mono); font-size: .64rem; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); background: var(--bg-2); border-bottom: 1px solid var(--line); }
table.matrix th.driver, table.matrix td.driver {
  text-align: left; position: sticky; left: 0; background: var(--surface);
  font-family: var(--disp); font-weight: 600; font-size: 1rem; z-index: 1;
  border-right: 1px solid var(--line);
}
table.matrix thead th.driver { background: var(--bg-2); }
table.matrix td { border-bottom: 1px solid var(--line-soft); font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.matrix tr:last-child td { border-bottom: 0; }
.cell-pos { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 6px; font-weight: 600; }
.cell-pos.p1 { background: rgba(255,176,32,.18); color: var(--amber); }
.cell-pos.p3 { background: rgba(56,210,122,.12); color: var(--green); }
.cell-abs { color: var(--faint); }
.dot-driver { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: .4rem; vertical-align: middle; }
td.total { font-family: var(--mono); color: var(--amber); font-weight: 600; }

/* ---------- compare / head to head ---------- */
.vs-pickers { display: grid; grid-template-columns: 1fr auto 1fr; gap: .8rem; align-items: end; margin-bottom: 1.4rem; }
.vs-pickers .vs-mid { font-family: var(--disp); font-weight: 700; color: var(--faint); padding-bottom: .5rem; }
@media (max-width: 560px){ .vs-pickers { grid-template-columns: 1fr 1fr; } .vs-pickers .vs-mid { display: none; } }
.vs-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.vs-name { font-family: var(--disp); font-weight: 700; font-size: clamp(1.4rem,4vw,2.2rem); text-transform: uppercase; }
.vs-name.right { text-align: right; }
.vs-record { text-align: center; font-family: var(--mono); }
.vs-record .rc { font-family: var(--disp); font-weight: 700; font-size: 1.8rem; }
.vs-record .rc small { color: var(--faint); font-size: .7rem; font-family: var(--mono); }
.vs-rows { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.vs-line { display: grid; grid-template-columns: 1fr 8rem 1fr; align-items: center; }
.vs-line + .vs-line { border-top: 1px solid var(--line-soft); }
.vs-line .lbl { text-align: center; font-family: var(--mono); font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }
.vs-line .val { font-family: var(--mono); font-weight: 600; font-size: 1.1rem; padding: .7rem 1.1rem; }
.vs-line .val.left { text-align: left; }
.vs-line .val.right { text-align: right; }
.vs-line .val.win { color: var(--amber); }
