/* Alcúdia Cup: "Boxenfunk" design. F1 broadcast timing tower on asphalt.
   Colors carry meaning: purple = leader/best, green = gain/done, yellow = open/next, red = live/loss/new. */
:root {
  --bg: #131a23;
  --panel: #1a2330;
  --deep: #0f151d;
  --line: #2a3646;
  --ink: #eef2f6;
  --mute: #8697aa;
  --purple: #b36bff;
  --green: #22d07a;
  --yellow: #ffd60a;
  --red: #ff3b30;
  --gold: #f2c14e;
  --silver: #c7d0da;
  --bronze: #d08a57;
  --font: "Titillium Web", "Segoe UI", system-ui, sans-serif;
  --num: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  --gutter: 12px;
  --tower: 22px 10px 3px 26px minmax(0, 1fr) auto 44px 38px;
  --cut: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
  --cut-btn: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.45 var(--font);
  padding-bottom: calc(66px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }
[hidden] { display: none !important; }
p { margin: 0; }

/* ---------- Type ---------- */
h1, h2, h3 { margin: 0; line-height: 1.05; font-family: var(--font); }
h1 { font-size: clamp(28px, 7vw, 46px); font-weight: 700; font-style: italic; letter-spacing: 0.005em; }
h2 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--mute); }
h3 { font-size: 17px; font-weight: 700; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; font-weight: 700; letter-spacing: 0.01em; }
.muted { color: var(--mute); }
.faint { color: var(--mute); opacity: 0.85; }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.stack > * + * { margin-top: 12px; }
.stack-l > * + * { margin-top: 18px; }
a.lnk, .section-title a, .card-head a { color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--yellow); }

/* ---------- Top bar ---------- */
.topbar { background: var(--deep); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 8px var(--gutter); padding-top: max(8px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 12px; min-height: 52px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-style: italic; font-size: 17px; text-decoration: none; letter-spacing: 0.01em; white-space: nowrap; }
.flag { width: 20px; height: 14px; flex: none; background: repeating-conic-gradient(var(--ink) 0 25%, transparent 0 50%) 0 0 / 7px 7px; transform: skewX(-14deg); }
.topnav { display: none; gap: 2px; margin-left: 18px; }
.topnav a { text-decoration: none; font-weight: 600; font-size: 14px; padding: 14px 12px 12px; color: var(--mute); box-shadow: inset 0 -2px 0 transparent; }
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--red); }
.topnav a.neu { color: #fff; background: var(--red); padding: 6px 16px; margin: 0 6px; align-self: center; clip-path: var(--cut-btn); box-shadow: none; }
.topbar-end { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me { font-size: 17px; text-decoration: none; padding: 2px 8px 2px 10px; box-shadow: inset 3px 0 0 var(--c); background: var(--panel); }
.day { font-size: 19px; color: var(--mute); white-space: nowrap; }
.day b { color: var(--ink); font-weight: 700; }
.iconbtn { width: 38px; height: 38px; display: grid; place-items: center; color: var(--mute); text-decoration: none; border: 1px solid var(--line); background: transparent; cursor: pointer; flex: none; }
.iconbtn:hover { color: var(--ink); border-color: var(--mute); }

/* ---------- Page header ---------- */
.pagehead { border-bottom: 1px solid var(--line); }
.pagehead-in { max-width: 1180px; margin: 0 auto; padding: 18px var(--gutter) 16px; }
.pagehead-in.tinted { box-shadow: inset 3px 0 0 var(--tint); padding-left: calc(var(--gutter) + 12px); }
.kicker { font-size: 12px; font-weight: 600; color: var(--yellow); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }
.lede { margin-top: 8px; max-width: 62ch; color: var(--mute); }
h1 .big { font-size: 1.25em; font-style: normal; font-weight: 800; color: var(--ink); }

main { max-width: 1180px; margin: 0 auto; padding: 14px var(--gutter) 28px; }
main.slide { animation: slide-in 250ms ease-out; }
@keyframes slide-in { from { transform: translateX(28px); opacity: 0; } }

/* ---------- Tab bar (phone) ---------- */
.tabbar { position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--deep); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: grid; justify-items: center; align-content: center; gap: 1px; height: 58px; text-decoration: none; color: var(--mute); font-size: 11px; font-weight: 600; }
.tabbar a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 2px 0 var(--red); }
.tabbar a.neu svg { background: var(--red); color: #fff; padding: 4px; width: 36px; height: 30px; transform: skewX(-10deg); stroke-width: 2.4; }
.tabbar a.neu { color: var(--ink); }

@media (min-width: 900px) {
  :root { --gutter: 20px; }
  body { padding-bottom: 32px; }
  .topnav { display: flex; }
  .tabbar { display: none !important; }
}

/* ---------- Layout ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.grid > *, .stack > * { min-width: 0; }
@media (min-width: 900px) {
  .grid.split { grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.65fr); align-items: start; }
  .grid.halves { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
}
.card, .panel { background: var(--panel); padding: 16px; }
.card.flush, .panel.flush { padding: 0; overflow: hidden; }
.card > h2:first-child, .panel > h2:first-child { margin-bottom: 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.flush > .card-head { padding: 14px 16px 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 22px 0 8px; }
.stack > .section-title:first-child, section > .section-title:first-child { margin-top: 4px; }
.free { padding: 14px; border: 1px dashed var(--line); color: var(--mute); font-size: 14px; }
.free a { color: var(--ink); }

.flash { padding: 10px 14px; margin-bottom: 12px; font-weight: 600; background: var(--panel); border-left: 3px solid var(--green); }
.flash:not(.ok):not(.err) { border-left-color: var(--yellow); font-weight: 400; color: var(--mute); }
.flash.err { border-left-color: var(--red); color: #ffb3ad; }

/* ---------- Tags, chips, medals ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.6; padding: 1px 14px 1px 8px; clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 100%, 0 100%); background: var(--line); color: var(--ink); white-space: nowrap; }
.tag.live { background: var(--red); color: #fff; }
.tag.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: pulse 1.6s ease-in-out infinite; }
.tag.next { background: var(--yellow); color: var(--bg); }
.tag.done { background: var(--green); color: var(--bg); }
.tag.out { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
@keyframes pulse { 50% { opacity: 0.15; } }
@media (prefers-reduced-motion: reduce) {
  .tag.live::before { animation: none; }
  main.slide { animation: none; }
  .tower li.gained a { animation: none; }
}

.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 2px 8px; border: 1px solid var(--line); color: var(--mute); white-space: nowrap; }
.chip.on { color: var(--ink); border-color: var(--ink); }

.mds { display: flex; gap: 3px; justify-content: flex-end; min-width: 0; }
.md { width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; line-height: 1; color: var(--bg); }
.md.g { background: var(--gold); }
.md.s { background: var(--silver); }
.md.b { background: var(--bronze); }

.form { display: inline-flex; gap: 3px; }
.form i { font-style: normal; width: 22px; height: 22px; display: grid; place-items: center; font-size: 15px; background: var(--deep); color: var(--mute); border: 1px solid var(--line); }
.form i.p1 { background: var(--purple); color: #fff; border-color: var(--purple); }
.form i.pod { color: var(--ink); border-color: var(--mute); }
.form i.top { color: var(--green); }

/* ---------- Avatars ---------- */
.av { width: 26px; flex: none; text-align: center; font-size: 19px; line-height: 1; }
.av.ini { width: 26px; height: 22px; display: grid; place-items: center; background: var(--c); color: var(--bg); font: 700 13px/1 var(--num); }
.av.s { width: 22px; font-size: 16px; }
.av.l { width: 40px; font-size: 30px; }
.av.xl { width: 64px; font-size: 52px; }
.av.ini.l, .av.ini.xl { height: 40px; font-size: 20px; }
.avs { display: flex; gap: 1px; }
.av.ph { height: 26px; }
.av.ph img { width: 100%; height: 100%; object-fit: cover; }
.av.ph.s { height: 22px; }
.av.ph.l { height: 40px; }
.av.ph.xl { height: 64px; }
.tv .av.ph { height: 38px; }
.cls .av.ph.s, .ranklist .av.ph.s { height: 26px; }
/* ---------- Driver select ---------- */
.av.ch { background: transparent; }
.dsel { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 16px; align-items: center; background: var(--panel); border-left: 3px solid var(--c); clip-path: var(--cut); margin-bottom: 14px; }
.dsel-img { background: var(--bg); padding: 10px; clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 100%, 0 100%); }
.dsel-img img { width: 112px; height: 112px; display: block; }
.dsel.pop .dsel-img img { animation: pop 220ms ease-out; }
@keyframes pop { from { transform: scale(0.82) rotate(-6deg); } }
.dsel-p { display: inline-block; background: var(--c); color: var(--bg); font-size: 17px; padding: 0 8px; }
.dsel h2 { color: var(--ink); text-transform: none; letter-spacing: 0; font: 700 italic 26px/1.1 var(--font); margin: 6px 0 4px; }
.dsel p { color: var(--mute); font-size: 13px; padding-right: 12px; }
.roster { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
@media (min-width: 700px) { .roster { grid-template-columns: repeat(5, minmax(0, 1fr)); } .dsel { grid-template-columns: 200px minmax(0, 1fr); } .dsel-img img { width: 180px; height: 180px; } }
@media (min-width: 1000px) { .roster { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.roster label { position: relative; cursor: pointer; }
.roster input { position: absolute; opacity: 0; pointer-events: none; }
.roster .tile { display: grid; justify-items: center; gap: 2px; padding: 6px 4px 5px; background: color-mix(in srgb, var(--bg) 70%, #131a23); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.roster .tile img { width: 100%; max-width: 70px; aspect-ratio: 1; }
.roster .tile b { font-size: 10px; font-weight: 700; text-align: center; line-height: 1.15; min-height: 2.3em; display: grid; align-items: center; }
.roster input:checked + .tile { background: var(--bg); box-shadow: inset 0 0 0 3px var(--ink); }
.roster input:focus-visible + .tile { outline: 2px solid var(--yellow); outline-offset: 2px; }
.roster .taken { cursor: not-allowed; }
.roster .taken .tile { filter: grayscale(1); opacity: 0.4; }
.roster .tile em { position: absolute; top: 3px; right: 3px; font-style: normal; background: var(--bg); color: var(--ink); font-size: 13px; padding: 0 4px; }
@media (prefers-reduced-motion: reduce) { .dsel.pop .dsel-img img { animation: none; } }
.photo-pick { display: flex; gap: 12px; align-items: center; }
.photo-pick .av { flex: none; }

/* ---------- Timing tower (signature) ---------- */
.thead, .tower a { display: grid; grid-template-columns: var(--tower); gap: 6px; align-items: center; }
.thead { font-size: 10px; color: var(--mute); letter-spacing: 0.05em; text-transform: uppercase; padding: 0 0 4px; }
.thead span:nth-last-child(-n+3) { text-align: right; }
.tower { list-style: none; margin: 0; padding: 0; }
.tower li { border-bottom: 1px solid var(--line); }
.tower a { height: 40px; text-decoration: none; }
.tower a:hover { background: var(--panel); }
.pos { background: var(--ink); color: var(--bg); font-size: 17px; font-weight: 800; text-align: center; line-height: 22px; height: 22px; }
.lead .pos, .pos.lead { background: var(--purple); color: #fff; }
/* Trend glyphs stay in the markup for screen readers; the visible mark is a centered CSS shape. */
.tr { font-size: 0; display: grid; place-items: center; height: 22px; }
.tr::before { content: ""; width: 8px; height: 7px; background: currentColor; }
.tr.up::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tr.down::before { clip-path: polygon(0 0, 100% 0, 50% 100%); }
.tr.same::before { width: 5px; height: 5px; }
.tr.same[aria-hidden]::before { display: none; }
.tr.up { color: var(--green); }
.tr.down { color: var(--red); }
.tr.same { color: var(--mute); }
.st { display: block; width: 3px; height: 22px; background: var(--c); }
.nm { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.nm b { font-size: 20px; font-weight: 700; letter-spacing: 0.03em; flex: none; }
.nm > span { font-size: 12px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bn { color: var(--green); font-style: normal; font-weight: 700; }
.gap { font-size: 17px; color: var(--mute); text-align: right; white-space: nowrap; }
.fl { color: var(--purple); font: 700 11px/1 var(--font); text-transform: uppercase; letter-spacing: 0.03em; }
.tower .pt { font-size: 21px; font-weight: 800; text-align: right; }
.tower .lead .pt { color: var(--purple); }
.tower li.gained a { animation: gained 1.2s ease-out 1; }
@keyframes gained { 0%, 35% { background: color-mix(in srgb, var(--green) 30%, transparent); } }
@media (min-width: 520px) {
  :root { --tower: 24px 12px 3px 28px minmax(0, 1fr) 64px 54px 44px; }
  .tower a { height: 42px; }
}

/* ---------- Live block ---------- */
.liveblock { display: block; text-decoration: none; background: var(--panel); border-left: 3px solid var(--red); padding: 10px 14px 12px; clip-path: var(--cut); }
.liveblock.soon { border-left-color: var(--yellow); }
.lrow { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.lrow .ev { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .fmt { margin-left: auto; color: var(--mute); white-space: nowrap; }
.lrow.sm { font-size: 12px; color: var(--mute); }
.lrow .next { margin-left: auto; text-align: right; }
.lrow .next b { color: var(--ink); font-weight: 600; }
.duel { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 9px; margin: 6px 0 9px; }
.duel .lbl { color: var(--yellow); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.tla { font-size: 36px; font-weight: 800; line-height: 1; letter-spacing: 0.02em; }
.tla.sm { font-size: 26px; }
.duel .v { color: var(--mute); font-size: 13px; }
.segs { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 2px; margin: 0 0 7px; }
.segs i { height: 6px; background: var(--line); transform: skewX(-20deg); }
.segs i.on { background: var(--green); }
.liveblock .segs i:not(.on) { background: var(--yellow); }
.liveblock.soon .segs i:not(.on) { background: var(--line); }

/* ---------- Event rows (program) ---------- */
.evlist { display: grid; gap: 4px; }
.evrow { --g: var(--line); display: grid; grid-template-columns: 46px 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px 8px 12px; background: var(--panel); text-decoration: none; box-shadow: inset 3px 0 0 var(--g); }
.evrow:hover { background: #202b3a; }
.evrow .when { font-size: 22px; line-height: 1; }
.evrow .when small { display: block; font: 600 11px/1.4 var(--font); color: var(--mute); text-transform: uppercase; }
.evrow .e { font-size: 22px; text-align: center; }
.evrow .what { min-width: 0; }
.evrow .what b { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evrow .what small { display: block; font-size: 12px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w { color: var(--yellow); font-style: normal; font-weight: 700; }
.evrow.done { opacity: 0.6; }
.evrow.live { box-shadow: inset 3px 0 0 var(--red); }
.evrow + .evrow { margin-top: 0; }

/* ---------- Plan ---------- */
.days { display: flex; gap: 4px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.days a { flex: none; width: 52px; padding: 6px 0 7px; text-decoration: none; display: grid; justify-items: center; background: var(--panel); color: var(--mute); border-top: 2px solid transparent; }
.days a b { font: 800 22px/1.05 var(--num); color: var(--ink); }
.days a span { font-size: 11px; font-weight: 600; text-transform: uppercase; }
.days a.today { border-top-color: var(--red); }
.days a.has::after { content: ""; width: 10px; height: 3px; background: var(--yellow); margin-top: 3px; transform: skewX(-20deg); }
.dayhead { display: flex; align-items: baseline; gap: 10px; margin: 22px 0 8px; }
.dayhead .n { font: 800 15px/1 var(--num); background: var(--ink); color: var(--bg); padding: 3px 7px; text-transform: uppercase; }
.dayhead.today .n { background: var(--red); color: #fff; }
.dayhead h2 { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 16px; }

/* ---------- Event page ---------- */
.evhero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; margin-bottom: 12px; }
.evhero .e { font-size: 38px; line-height: 1; }
.evhero h1 { font-size: clamp(26px, 6vw, 40px); }
.evhero .sub { font-size: 13px; color: var(--mute); margin-top: 4px; }
.evhero .sub span { color: var(--yellow); margin-left: 8px; font-weight: 600; white-space: nowrap; }
.evhero .sub .w { margin-left: 8px; }
.segnote { font-size: 15px; color: var(--mute); }

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; font: 600 14px/1 var(--font); padding: 12px 16px; color: var(--mute); cursor: pointer; white-space: nowrap; box-shadow: inset 0 -2px 0 transparent; }
.tabs button[aria-selected="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--red); }

.round { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--yellow); margin: 16px 0 6px; }
.round:first-child { margin-top: 0; }
.fold { margin-bottom: 8px; }
.fold > summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; list-style: none; padding: 10px 12px; background: var(--panel); font-weight: 700; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: "▾"; color: var(--mute); margin-left: 4px; }
.fold[open] > summary { background: transparent; padding: 4px 0 6px; color: var(--mute); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.fold[open] > summary::after { content: "▴"; }

.match { background: var(--panel); }
.match + .match { margin-top: 6px; }
.match .side { --c: var(--line); display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 6px 12px 6px 14px; box-shadow: inset 3px 0 0 var(--c); min-height: 42px; }
.match .side + .side { border-top: 1px solid var(--line); }
.match .side .n { display: flex; align-items: baseline; gap: 7px; font-size: 13px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .side .n b { font-size: 19px; color: var(--ink); letter-spacing: 0.03em; }
.match .side .sc { font-size: 24px; font-weight: 800; min-width: 26px; text-align: right; }
.match .side.win .sc { color: var(--green); }
.match .side.lose { opacity: 0.55; }
.match .side.tbd .n { font-style: italic; }
.match .foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 5px 12px; background: var(--deep); font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.04em; }
.match input.score { width: 56px; height: 36px; min-height: 36px; text-align: center; font: 800 22px/1 var(--num); padding: 0; }
.match.bye { opacity: 0.5; background: transparent; border: 1px dashed var(--line); }
.match summary, summary.more { cursor: pointer; color: var(--ink); font-weight: 600; list-style: none; font-size: 13px; text-transform: none; letter-spacing: 0; }
.match summary::-webkit-details-marker, summary.more::-webkit-details-marker { display: none; }
summary.more::before { content: "▸ "; color: var(--yellow); }
details[open] > summary.more::before { content: "▾ "; }

.bracket { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 26px; overflow-x: auto; padding: 4px 2px 12px; }
.bracket .col { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.bracket .col > .round { margin: 0 0 4px; }
.bracket .pair { display: flex; flex-direction: column; justify-content: space-around; gap: 10px; position: relative; flex: 1; }
.bracket .slot { position: relative; }
.bracket .col:not(:last-child) .slot::after { content: ""; position: absolute; right: -14px; top: 50%; width: 13px; border-top: 1px solid var(--mute); }
.bracket .col:not(:last-child) .pair::after { content: ""; position: absolute; right: -14px; top: 25%; bottom: 25%; border-right: 1px solid var(--mute); }
.bracket .col:not(:first-child) .slot::before { content: ""; position: absolute; left: -13px; top: 50%; width: 13px; border-top: 1px solid var(--mute); }
.bracket .match + .match { margin-top: 0; }

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { font-size: 10px; font-weight: 600; color: var(--mute); text-align: right; padding: 10px 10px 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.table td { padding: 7px 10px; text-align: right; border-top: 1px solid var(--line); font-family: var(--num); font-size: 17px; }
.table th:nth-child(2), .table td:nth-child(2) { text-align: left; }
.table td:first-child { width: 34px; text-align: center; }
.table td:first-child { font-weight: 800; color: var(--mute); }
.table tr:first-child td:first-child { color: var(--purple); }
.table td.b { font-weight: 800; font-size: 20px; }
.table tr.q td:first-child { box-shadow: inset 3px 0 0 var(--green); color: var(--green); }
.table .who { display: flex; align-items: center; gap: 8px; font: 600 14px var(--font); }

.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.team { background: var(--deep); padding: 10px 12px; border-left: 3px solid var(--yellow); }
.team b { display: block; font-weight: 700; margin-bottom: 6px; }
.team .mem { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.team .mem + .mem { margin-top: 3px; }

.heat { background: var(--panel); padding: 12px 14px; }
.heat + .heat { margin-top: 6px; }
.gh { font-size: 10px; color: var(--mute); letter-spacing: 0.06em; text-transform: uppercase; margin: 10px 0 6px; }
.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.slot { --c: var(--ink); border-top: 2px solid var(--c); padding: 4px 0 2px; font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slots .slot:nth-child(even) { margin-top: 14px; }
.slot span { color: var(--mute); font-size: 15px; margin-right: 5px; }
.places { display: grid; gap: 6px; margin-top: 10px; }
.places label { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; font: 800 18px var(--num); }

/* Classification lists (heat finish, event standings, player results) */
.cls, .ranklist { list-style: none; margin: 8px 0 0; padding: 0; }
.cls li, .ranklist li { display: grid; grid-template-columns: 30px 3px 26px minmax(0, 1fr) auto; gap: 9px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--line); }
.cls .pos, .ranklist .pos { height: 26px; line-height: 26px; font-size: 19px; }
.cls .st, .ranklist .st { height: 26px; }
.cls .av.s, .ranklist .av.s { width: 26px; font-size: 20px; }
.ranklist a { text-decoration: none; min-width: 0; }
.gain { color: var(--green); font-size: 20px; font-weight: 800; text-align: right; }
.lead .gain { color: var(--purple); }
.val { color: var(--ink); font-style: normal; margin-left: 4px; }

/* ---------- Forms ---------- */
label.f { display: grid; gap: 5px; font-size: 11px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: 0.05em; }
label.f small { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 12px; }
input, select, textarea {
  font: 400 16px/1.3 var(--font);
  color: var(--ink);
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
input[type="checkbox"], input[type="radio"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--green); }
input.votes { width: 64px; min-height: 34px; padding: 4px 8px; font: 700 17px var(--num); text-align: center; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.prow { border-top: 1px solid var(--line); padding-top: 12px; }
fieldset.prow > div:first-child { display: grid; grid-template-columns: auto 64px 1fr; gap: 10px; align-items: center; }
legend { font-size: 11px; font-weight: 600; color: var(--mute); margin-bottom: 8px; padding: 0; text-transform: uppercase; letter-spacing: 0.05em; }
.fields { display: grid; gap: 14px; }
.row2 { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.row3 { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 15px; color: var(--ink); }
.moderow { justify-content: space-between; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }

.pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px; }
.pick label { position: relative; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick .opt { --g: var(--line); display: grid; justify-items: center; gap: 5px; padding: 10px 6px; background: var(--deep); font-size: 13px; font-weight: 600; text-align: center; line-height: 1.2; box-shadow: inset 0 0 0 1px var(--line); }
.pick .opt .e { font-size: 26px; }
.pick input:checked + .opt { box-shadow: inset 0 0 0 2px var(--ink), inset 0 3px 0 0 var(--g); background: var(--panel); }
.pick input:focus-visible + .opt { outline: 2px solid var(--yellow); }
.pick.people .opt { padding: 9px 4px; }
.pick.people input:not(:checked) + .opt { opacity: 0.4; }

.chips-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.chips-pick label { cursor: pointer; }
.chips-pick input { position: absolute; opacity: 0; pointer-events: none; }
.chips-pick span { display: inline-flex; align-items: center; padding: 8px 14px; background: var(--deep); font-weight: 600; font-size: 14px; box-shadow: inset 0 0 0 1px var(--line); }
.chips-pick input:checked + span { background: var(--ink); color: var(--bg); box-shadow: none; }
.chips-pick input:focus-visible + span { outline: 2px solid var(--yellow); }

.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches label { cursor: pointer; }
.swatches input { position: absolute; opacity: 0; pointer-events: none; }
.swatches span { display: block; width: 28px; height: 28px; background: var(--c); transform: skewX(-10deg); }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }
.swatches input:focus-visible + span { outline: 2px solid var(--yellow); outline-offset: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 22px; border: 0; border-radius: 0; cursor: pointer; text-decoration: none; font: 700 15px/1 var(--font); background: var(--ink); color: var(--bg); clip-path: var(--cut-btn); }
.btn:hover { background: #fff; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: #ff5a50; }
.btn.ghost { background: transparent; color: var(--ink); clip-path: none; box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1px var(--mute); }
.btn.danger { background: transparent; color: var(--red); clip-path: none; box-shadow: inset 0 0 0 1px var(--red); }
.btn.sm { min-height: 34px; padding: 0 16px; font-size: 13px; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.linkbtn { border: 0; background: none; padding: 0; font: 600 12px/1 var(--font); color: var(--mute); cursor: pointer; text-decoration: underline; }
.sticky-save { position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 5; }
@media (min-width: 900px) { .sticky-save { bottom: 16px; } }

/* ---------- Games & modes ---------- */
.gamegrid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.game { --g: var(--line); background: var(--panel); display: flex; flex-direction: column; box-shadow: inset 3px 0 0 var(--g); }
.game .top { display: flex; gap: 12px; align-items: center; padding: 12px 12px 8px 16px; }
.game .gtile { font-size: 30px; line-height: 1; flex: none; width: 36px; text-align: center; }
.game h3 { font-size: 17px; }
.game .body { padding: 0 14px 10px 16px; font-size: 13px; color: var(--mute); flex: 1; }
.game .modes { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 14px 12px 16px; }
.game .foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 8px 16px; background: var(--deep); }
.game .edit { width: 34px; height: 34px; display: grid; place-items: center; color: var(--mute); border: 1px solid var(--line); text-decoration: none; flex: none; }
.game .edit:hover { color: var(--ink); border-color: var(--mute); }
.game.out { opacity: 0.5; }
.votebar { height: 4px; background: var(--line); margin-top: 6px; }
.votebar i { display: block; height: 100%; background: var(--g); }
.seg { display: inline-flex; gap: 2px; }
.seg button { border: 0; background: var(--panel); font: 600 12px/1 var(--font); padding: 8px 10px; cursor: pointer; color: var(--mute); text-transform: uppercase; letter-spacing: 0.04em; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.seg button[aria-pressed="true"][value="yes"] { background: var(--green); }
.seg button[aria-pressed="true"][value="open"] { background: var(--yellow); }
.seg button[aria-pressed="true"][value="no"] { background: var(--red); color: #fff; }

.modelist { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.mode { display: block; text-decoration: none; background: var(--panel); padding: 14px 16px; border-left: 3px solid var(--yellow); }
.mode:hover { background: #202b3a; }
.mode .fmt { font-size: 11px; font-weight: 700; color: var(--yellow); text-transform: uppercase; letter-spacing: 0.06em; }
.mode h3 { margin: 4px 0 6px; }
.mode p { font-size: 13px; color: var(--mute); }
.mode .params { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }

.settings-nav { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.settings-nav a { display: flex; gap: 10px; align-items: center; padding: 12px 14px; background: var(--panel); text-decoration: none; font-weight: 600; border-left: 3px solid var(--line); }
.settings-nav a:hover { border-left-color: var(--red); }
.settings-nav a span { font-size: 20px; }

.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--mute); }
.steps b { color: var(--ink); }
pre.copy { white-space: pre-wrap; background: var(--deep); border: 1px solid var(--line); padding: 12px; font: 14px/1.5 var(--font); margin: 0; }

/* ---------- Chart ---------- */
.race { position: relative; }
.race svg { width: 100%; height: auto; overflow: visible; }
.race .grid line { stroke: var(--line); }
.race .axis text { fill: var(--mute); font: 600 13px var(--num); }
.race .line { fill: none; stroke: var(--mute); stroke-width: 1.5; opacity: 0.22; stroke-linejoin: round; }
.race .line.sel { stroke-width: 2.5; opacity: 1; }
.race .lbl { font: 700 15px var(--num); fill: var(--ink); letter-spacing: 0.03em; }
.race .cross { stroke: var(--mute); stroke-dasharray: 3 3; }
.race .tip { position: absolute; pointer-events: none; background: var(--deep); border: 1px solid var(--line); border-left: 3px solid var(--yellow); padding: 8px 10px; font-size: 13px; min-width: 150px; transform: translate(-50%, -105%); }
.race .tip b { display: block; margin-bottom: 4px; }
.race .tip div { display: flex; justify-content: space-between; gap: 12px; font-family: var(--num); font-size: 16px; }
.race .tip i { display: inline-block; width: 3px; height: 12px; margin-right: 6px; vertical-align: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.legend button { display: inline-flex; align-items: center; gap: 6px; border: 0; padding: 5px 9px; background: transparent; color: var(--mute); font: 700 15px/1 var(--num); letter-spacing: 0.03em; cursor: pointer; box-shadow: inset 0 0 0 1px var(--line); }
.legend button i { width: 3px; height: 13px; opacity: 0.35; }
.legend button[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 0 0 1px var(--mute); }
.legend button[aria-pressed="true"] i { opacity: 1; }

/* ---------- Player page ---------- */
.prof { display: flex; gap: 14px; align-items: center; }
.prof .pos { width: 46px; height: 46px; line-height: 46px; font-size: 34px; flex: none; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.stat { background: var(--panel); padding: 12px 14px; }
.stat b { display: block; font-size: 36px; line-height: 1; font-weight: 800; }
.stat:first-child b { color: var(--purple); }
.stat span { font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- TV ---------- */
body.tv { padding: 28px 40px 0; min-height: 100vh; display: flex; flex-direction: column; gap: 20px; --tower: 36px 16px 4px 38px minmax(0, 1fr) 84px 70px 62px; overflow: hidden; }
.tvh { display: flex; align-items: center; gap: 24px; }
.tvh .brand { font-size: 32px; gap: 14px; }
.tvh .flag { width: 34px; height: 24px; background-size: 12px 12px; }
.tvt { font-size: 22px; color: var(--mute); border-left: 1px solid var(--line); padding-left: 24px; }
.clock { margin-left: auto; font-size: 30px; color: var(--mute); display: flex; gap: 18px; align-items: baseline; }
.clock .day { font-size: 30px; }
.clock > b { color: var(--ink); }
.tvg { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 36px; flex: 1; min-height: 0; }
.tv .thead { font-size: 13px; padding-bottom: 6px; }
.tv .tower a { height: clamp(52px, 7.4vh, 80px); gap: 12px; }
.tv .pos { font-size: 26px; height: 34px; line-height: 34px; }
.tv .st { height: 34px; }
.tv .av { width: 38px; font-size: 28px; }
.tv .nm b { font-size: 30px; }
.tv .nm > span { font-size: 17px; }
.tv .md { width: 22px; height: 22px; font-size: 15px; }
.tv .gap { font-size: 26px; }
.tv .fl { font-size: 15px; }
.tv .tower .pt { font-size: 32px; }
.tv .tr { height: 34px; }
.tv .tr::before { width: 11px; height: 10px; }
.tv .liveblock { padding: 18px 22px; }
.tv .lrow { font-size: 19px; }
.tv .lrow.sm { font-size: 17px; }
.tv .tag { font-size: 15px; }
.tv .duel .lbl { font-size: 17px; }
.tv .tla { font-size: 68px; }
.tv .tla.sm { font-size: 44px; }
.tv .duel .v { font-size: 19px; }
.tv .segs i { height: 10px; }
.up { margin-top: 24px; }
.up h3 { font-size: 14px; color: var(--mute); letter-spacing: 0.08em; text-transform: uppercase; margin: 0 0 4px; font-weight: 600; }
.uplist { list-style: none; margin: 0; padding: 0; }
.uplist li { display: grid; grid-template-columns: 54px 92px minmax(0, 1fr); align-items: baseline; border-bottom: 1px solid var(--line); padding: 10px 0; }
.dd { color: var(--mute); font-size: 17px; text-transform: uppercase; }
.tt { font-size: 32px; }
.uplist li:first-child .tt { color: var(--yellow); }
.nmx { font-size: 23px; font-weight: 700; line-height: 1.15; }
.nmx small { display: block; font-size: 15px; color: var(--mute); font-weight: 400; }
.ticker { display: flex; gap: 34px; background: var(--panel); padding: 12px 20px; margin: 0 -40px; font-size: 19px; white-space: nowrap; overflow: hidden; border-left: 4px solid var(--yellow); }
.ticker b { color: var(--yellow); font-weight: 700; margin-right: 9px; }
.tv .free { font-size: 20px; }
@media (max-width: 1100px) {
  body.tv { padding: 18px 16px 0; overflow: auto; }
  .tvg { grid-template-columns: minmax(0, 1fr); }
  .ticker { margin: 0 -16px; }
}

/* The logged-in player's own matches, heats and value rows */
.match.mine, .heat.mine { outline: 1px solid var(--yellow); outline-offset: -1px; }
label.check.mine { box-shadow: inset 3px 0 0 var(--yellow); }
.mybox { margin-bottom: 18px; }

/* Results still missing (home + TV) */
.openres { border: 1px solid var(--yellow); background: var(--panel); padding: 12px 14px; }
.openres h2 { color: var(--yellow); }
.openres ul { list-style: none; margin: 8px 0 0; padding: 0; }
.openres li + li { border-top: 1px solid var(--line); }
.openres a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; color: var(--ink); text-decoration: none; }
.openres small { color: var(--mute); }
