/* Magic Number reader site. One stylesheet for every page.
   The tokens below are carried over unchanged from the old site's chrome
   (the pre-reset site), light and dark, so the reset keeps the palette. */

@font-face{font-family:'Instrument Sans';font-style:normal;font-weight:400 700;
  font-display:swap;src:url('fonts/instrument-sans-var.woff2') format('woff2');}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:400;
  font-display:swap;src:url('fonts/ibm-plex-mono-400.woff2') format('woff2');}
@font-face{font-family:'IBM Plex Mono';font-style:normal;font-weight:600;
  font-display:swap;src:url('fonts/ibm-plex-mono-600.woff2') format('woff2');}

:root {
  --paper:#F8FAFD; --surface:#FFFFFF; --ink:#141923; --muted:#5E6875;
  --faint:#8B94A1; --line:#E4E9F1; --line-strong:#D0D8E4;
  --accent:#2D50D2; --mark-track:#AFBEE7;
  --qualify:#1F9D6B; --qualify-strong:#0E7A52;
  --out:#C4626A; --out-strong:#A8201A; --bubble:#D98A2B;
  --heat-lo:#E7B84D; --heat-hi:#D64828;
  --series-elo:#2D50D2; --series-base:#D98A2B;
  --radius:8px; --maxw:1000px;
  --sans:'Instrument Sans',ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --mono:'IBM Plex Mono',ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace;
  color-scheme:light;
}
@media (prefers-color-scheme:dark){
  :root{ --paper:#0C111A; --surface:#151C28; --ink:#EDF1F7; --muted:#A0AAB8;
    --faint:#6B7482; --line:#232B37; --line-strong:#33405A; --accent:#7894FF;
    --mark-track:#455989;
    --qualify:#37B583; --qualify-strong:#5CD3A2;
    --out:#D98A8F; --out-strong:#FF7A6B; --bubble:#E7A24C;
    --heat-lo:#C9922E; --heat-hi:#E0583A;
    --series-elo:#7894FF; --series-base:#C4862F; color-scheme:dark; }
}
:root[data-theme="light"]{ --paper:#F8FAFD; --surface:#FFFFFF; --ink:#141923; --muted:#5E6875;
  --faint:#8B94A1; --line:#E4E9F1; --line-strong:#D0D8E4; --accent:#2D50D2;
  --mark-track:#AFBEE7;
  --qualify:#1F9D6B; --qualify-strong:#0E7A52; --out:#C4626A; --out-strong:#A8201A;
  --bubble:#D98A2B; --heat-lo:#E7B84D; --heat-hi:#D64828;
  --series-elo:#2D50D2; --series-base:#D98A2B; color-scheme:light; }
:root[data-theme="dark"]{ --paper:#0C111A; --surface:#151C28; --ink:#EDF1F7; --muted:#A0AAB8;
  --faint:#6B7482; --line:#232B37; --line-strong:#33405A; --accent:#7894FF;
  --mark-track:#455989;
  --qualify:#37B583; --qualify-strong:#5CD3A2; --out:#D98A8F; --out-strong:#FF7A6B;
  --bubble:#E7A24C; --heat-lo:#C9922E; --heat-hi:#E0583A;
  --series-elo:#7894FF; --series-base:#C4862F; color-scheme:dark; }

/* --- base ---------------------------------------------------------------- */
*{box-sizing:border-box}
body{margin:0;background:var(--paper);color:var(--ink);font-family:var(--sans);
  font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased;
  font-variant-numeric:tabular-nums;}
a{color:var(--accent)}
h1,h2,h3{margin:0;text-wrap:balance;letter-spacing:0}
p{margin:0}
.wrap{--wrap-pad:clamp(16px,4vw,32px);max-width:var(--maxw);margin:0 auto;
  padding:0 var(--wrap-pad);}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;
  clip:rect(0,0,0,0);white-space:nowrap;border:0}
.num{font-family:var(--mono);font-variant-numeric:tabular-nums}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:4px}

/* --- masthead ------------------------------------------------------------ */
.mast{display:flex;align-items:center;justify-content:space-between;gap:12px 20px;
  flex-wrap:wrap;padding:clamp(16px,3vw,28px) 0 clamp(16px,3vw,24px);
  border-bottom:1px solid var(--line);margin-bottom:clamp(20px,4vw,32px)}
.brand{display:flex;flex-direction:column;gap:2px;min-width:0}
.mark{display:inline-flex;align-items:center;gap:9px;color:var(--ink);
  text-decoration:none;font-weight:700;font-size:1.25rem;line-height:1.1}
.mark svg{width:36px;height:36px;flex:none}
.mark .mk-notch{fill:var(--ink)}
.mark .mk-track{fill:var(--mark-track)}
.mark .mk-fill,.mark .mk-bar{fill:var(--accent)}
.mark .mk-stop{color:var(--accent)}
.descriptor{font-size:.82rem;color:var(--muted);padding-left:45px}

.nav{display:flex;align-items:center;gap:4px 16px;flex-wrap:wrap;font-size:.92rem}
.nav a{color:var(--muted);text-decoration:none}
.nav a:hover,.nav a[aria-current="page"]{color:var(--ink)}
.nav a[aria-current="page"]{font-weight:600}
.leagues{position:relative}
.leagues summary{cursor:pointer;list-style:none;color:var(--ink);font-weight:600}
.leagues summary::-webkit-details-marker{display:none}
.leagues summary::after{content:"\25BE";margin-left:4px;color:var(--muted);font-size:.8em}
.leagues ul{position:absolute;z-index:10;top:calc(100% + 8px);left:0;min-width:200px;
  margin:0;padding:6px;list-style:none;background:var(--surface);
  border:1px solid var(--line-strong);border-radius:var(--radius);
  box-shadow:0 8px 24px rgb(0 0 0 / .12)}
.leagues li a{display:block;padding:6px 10px;border-radius:6px;color:var(--ink)}
.leagues li a:hover{background:var(--paper)}
.theme{font:inherit;color:var(--muted);background:none;border:1px solid var(--line-strong);
  border-radius:999px;padding:2px 10px;cursor:pointer}
.theme:hover{color:var(--ink)}

/* --- footer -------------------------------------------------------------- */
.foot{margin-top:clamp(40px,6vw,64px);padding:20px 0 32px;border-top:1px solid var(--line);
  font-size:.82rem;color:var(--muted);display:flex;justify-content:space-between;
  gap:8px 20px;flex-wrap:wrap}
.foot a{color:var(--muted)}

/* --- shared pieces ------------------------------------------------------- */
.label{font-family:var(--mono);font-size:.75rem;letter-spacing:.08em;
  text-transform:uppercase;color:var(--muted)}
.dot{display:inline-block;width:7px;height:7px;border-radius:50%;
  background:var(--qualify);flex:none}
.dot.done{background:var(--faint)}
.fresh{display:flex;align-items:baseline;gap:7px;font-family:var(--mono);
  font-size:.75rem;line-height:1.45;color:var(--muted)}
.fresh .dot{position:relative;top:-1px}

/* --- home ---------------------------------------------------------------- */
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,290px),1fr));
  gap:14px}
.card{display:flex;flex-direction:column;gap:8px;padding:16px 16px 14px;
  background:var(--surface);border:1px solid var(--line);border-radius:12px;
  color:var(--ink);text-decoration:none;
  transition:border-color .12s ease,transform .12s ease}
a.card:hover{border-color:var(--accent)}
.card h2{font-size:1.2rem;font-weight:700;line-height:1.2}
.card .sec{margin-top:6px}
.card ol,.card ul{list-style:none;margin:0;padding:0}
.card li{display:flex;justify-content:space-between;gap:12px;padding:4px 0;
  border-top:1px solid var(--line);font-size:.92rem}
.card li:first-child{border-top:0}
.card li .num{color:var(--ink);font-weight:600}
.card li .word{color:var(--muted);font-size:.85rem}
.card .game{font-size:.92rem}
.card .note{font-size:.9rem;color:var(--muted)}
.card.empty{background:transparent;border-style:dashed}
.card .more{margin-top:auto;padding-top:6px;font-size:.82rem;color:var(--accent)}

/* --- page heads and sections ------------------------------------------- */
.page-head{display:flex;flex-direction:column;gap:6px;margin-bottom:20px}
.page-head h1{font-size:clamp(1.6rem,4vw,2.1rem);font-weight:700;line-height:1.1}
.page-head .season{color:var(--muted);font-weight:400}
.page-head .label a{color:var(--muted);text-decoration:none}
.page-head .label a:hover{color:var(--accent)}
.standing{font-size:1rem;color:var(--ink)}
section{margin-top:clamp(28px,5vw,44px)}
section h2{font-size:1.2rem;font-weight:700;margin-bottom:6px}
section h3{font-size:.95rem;font-weight:600;margin:18px 0 6px}
h3.group{font-family:var(--mono);font-size:.75rem;letter-spacing:.08em;text-transform:uppercase;
  color:var(--muted);font-weight:600;margin:22px 0 4px}
.note{font-size:.88rem;color:var(--muted);margin:4px 0 10px;max-width:68ch}
.decided{font-size:1.05rem;margin:4px 0 0;max-width:68ch}
.up{color:var(--qualify-strong)} .down{color:var(--out-strong)}

/* --- tables -------------------------------------------------------------- */
.table-wrap{overflow-x:auto;margin:8px 0 4px;border:1px solid var(--line);border-radius:10px;
  background:var(--surface);-webkit-overflow-scrolling:touch}
/* A table wider than its frame shows a shadow at the right edge, so a reader
   can see there is more to scroll to. The cover scrolls with the content and
   hides the shadow once the last column is in view. No script. */
.table-wrap{background:
  linear-gradient(to left,var(--surface) 16px,transparent) right/32px 100% no-repeat local,
  radial-gradient(farthest-side at 100% 50%,color-mix(in srgb,var(--ink) 32%,transparent),transparent)
    right/16px 100% no-repeat scroll,
  var(--surface)}
table{border-collapse:separate;border-spacing:0;width:100%;font-size:.9rem}
caption{caption-side:top;text-align:left;padding:10px 12px 4px;font-weight:600;font-size:.92rem}
th,td{padding:7px 10px;text-align:left;border-bottom:1px solid var(--line);white-space:nowrap;vertical-align:middle}
tbody tr:last-child>*{border-bottom:0}
thead th{font-family:var(--mono);font-size:.75rem;letter-spacing:.06em;text-transform:uppercase;
  color:var(--muted);font-weight:600;border-bottom:1px solid var(--line-strong)}
.n{text-align:right;font-family:var(--mono);font-variant-numeric:tabular-nums}
td.strong{font-weight:600}
td.word{color:var(--muted);font-family:var(--sans);font-size:.85rem}
.rk{width:1%;color:var(--muted);font-family:var(--mono);text-align:right;padding-right:4px}
th.club{font-weight:500}
th.club a{color:var(--ink);text-decoration:none}
th.club a:hover{color:var(--accent);text-decoration:underline}
/* The club column stays put while a wide table scrolls under it. */
.race-table th.club{position:sticky;left:0;background:var(--surface);z-index:1}
/* Every column is at least as wide as its widest cell, so a number never runs
   into the next column (#940). The club column
   takes the spare width; the floors keep a league's division tables lined up
   with each other. A table wider than its frame scrolls inside it. */
.race-table th.club{width:100%;min-width:144px}
.race-table thead th.n{min-width:76px}
.race-table thead th.n.rec{min-width:44px}
.race-table thead th.n.record{min-width:76px}
.race-table thead th.n.lead{min-width:132px}
.final .race-table th.club{width:auto}
.final .race-table .ach{width:100%}
td.lead .bar{display:inline-block;width:56px;height:6px;border-radius:3px;background:var(--line);
  overflow:hidden;vertical-align:middle;margin-right:8px}
td.lead .bar i{display:block;height:100%;background:var(--accent);border-radius:3px}
thead th.lead{color:var(--ink)}
tr.cut>*{border-top:2px dashed var(--accent)}
td.ach{white-space:normal;min-width:180px;color:var(--ink)}

/* --- games that matter --------------------------------------------------- */
.game-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(min(100%,260px),1fr));gap:12px;margin-top:8px}
.game{background:var(--surface);border:1px solid var(--line);border-radius:10px;padding:12px 14px;
  display:flex;flex-direction:column;gap:6px}
.game ul{list-style:none;margin:0;padding:0}
.game li{display:flex;justify-content:space-between;gap:10px;padding:4px 0;font-size:.92rem;
  border-top:1px solid var(--line)}
.game li:first-child{border-top:0}
.game li a{color:var(--ink);text-decoration:none;font-weight:500}
.game li a:hover{color:var(--accent)}
.game .num{font-size:.82rem;color:var(--ink);text-align:right}
.game .range{color:var(--muted)}
.race-name{display:block;font-family:var(--sans);font-size:.75rem;color:var(--muted)}
.rbar{display:flex;height:6px;border-radius:3px;overflow:hidden;gap:2px;margin-top:2px}
.rbar i{display:block;height:100%}
.rbar .h{background:var(--accent)} .rbar .d{background:var(--line-strong)} .rbar .a{background:var(--faint)}
.rwords{font-family:var(--mono);font-size:.75rem;color:var(--muted)}

/* --- team panels --------------------------------------------------------- */
.panels{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:12px}
.panel{margin-top:0;background:var(--surface);border:1px solid var(--line);border-radius:12px;
  padding:14px 16px;display:flex;flex-direction:column;gap:6px}
.panel h2{font-family:var(--mono);font-size:.75rem;letter-spacing:.08em;text-transform:uppercase;
  color:var(--muted);font-weight:600;margin:0 0 4px}
.odds{list-style:none;margin:0;padding:0}
.odds li{display:grid;grid-template-columns:1fr auto;gap:2px 12px;padding:6px 0;border-top:1px solid var(--line)}
.odds li:first-child{border-top:0}
.odds li .bar{grid-column:1/-1;height:5px;border-radius:3px;background:var(--line);overflow:hidden}
.odds li .bar i{display:block;height:100%;background:var(--faint);border-radius:3px}
.odds li.lead span:first-child,.odds li.lead .num{font-weight:700}
.odds li.lead .bar i{background:var(--accent)}
.countdown{display:flex;justify-content:space-between;font-size:.9rem;padding-top:6px;border-top:1px solid var(--line)}
.opp{font-size:1.1rem;font-weight:600}
.opp a{color:var(--ink)}
.branches{list-style:none;margin:0;padding:0}
.branches li{display:flex;justify-content:space-between;padding:3px 0;font-size:.92rem}
.sched td a{color:var(--ink)}

/* --- chart --------------------------------------------------------------- */
:root{--s1:#2D50D2;--s2:#eb6834;--s3:#1baf7a;--s4:#eda100;--s5:#e87ba4;--s6:#008300}
@media (prefers-color-scheme:dark){:root{--s1:#3987e5;--s2:#d95926;--s3:#199e70;--s4:#c98500;--s5:#d55181;--s6:#008300}}
:root[data-theme="light"]{--s1:#2D50D2;--s2:#eb6834;--s3:#1baf7a;--s4:#eda100;--s5:#e87ba4;--s6:#008300}
:root[data-theme="dark"]{--s1:#3987e5;--s2:#d95926;--s3:#199e70;--s4:#c98500;--s5:#d55181;--s6:#008300}
.chart-wrap{position:relative;margin:8px 0 0;background:var(--surface);border:1px solid var(--line);
  border-radius:10px;padding:10px 8px 8px}
.chart{display:block;width:100%;height:auto;overflow:visible}
/* Two drawings of the same chart; a phone gets the narrow one, so its text
   stays legible instead of scaling down with a wide drawing. */
.chart.narrow{display:none}
@media (max-width:600px){.chart.wide{display:none}.chart.narrow{display:block}}
.chart .grid{stroke:var(--line);stroke-width:1}
.chart .axis{fill:var(--muted);font-family:var(--mono);font-size:12px}
.chart .ln{fill:none;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
.chart .ln.ctx{stroke:var(--line-strong);stroke-width:1}
.chart .lbl{font-family:var(--sans);font-size:12px;fill:var(--ink)}
.chart .cross{stroke:var(--faint);stroke-width:1}
.chart [hidden]{display:none}
.chart .s1{stroke:var(--s1)} .chart .s2{stroke:var(--s2)} .chart .s3{stroke:var(--s3)}
.chart .s4{stroke:var(--s4)} .chart .s5{stroke:var(--s5)} .chart .s6{stroke:var(--s6)}
.chips{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
.chip{font:inherit;font-size:.78rem;padding:2px 9px;border-radius:999px;cursor:pointer;
  border:1px solid var(--line-strong);background:transparent;color:var(--muted)}
.chip[aria-pressed="true"]{color:var(--ink);border-color:currentColor;font-weight:600}
.chip[data-slot]{border-left-width:4px}
.chip[data-slot="1"]{border-left-color:var(--s1)} .chip[data-slot="2"]{border-left-color:var(--s2)}
.chip[data-slot="3"]{border-left-color:var(--s3)} .chip[data-slot="4"]{border-left-color:var(--s4)}
.chip[data-slot="5"]{border-left-color:var(--s5)} .chip[data-slot="6"]{border-left-color:var(--s6)}
.chip:disabled{opacity:.45;cursor:not-allowed}
.tip{position:absolute;z-index:5;pointer-events:none;background:var(--surface);
  border:1px solid var(--line-strong);border-radius:8px;padding:6px 9px;font-size:.78rem;
  box-shadow:0 6px 18px rgb(0 0 0 / .14);min-width:140px}
.tip p{display:flex;justify-content:space-between;gap:12px}
.tip .k{font-family:var(--mono);font-size:.75rem;color:var(--muted);margin-bottom:2px}
.tip i{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px}

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

/* --- freshness (MNR-25) ---------------------------------------------------- */
.fresh.late .dot{background:var(--bubble)}
.late-note{margin-top:12px;padding:10px 12px;border:1px solid var(--line-strong);
  border-left:4px solid var(--bubble);border-radius:var(--radius);
  background:var(--surface);font-size:.9rem;line-height:1.45}
.late-note[hidden]{display:none}

/* --- how it works, track record, notices (MNR-26) ----------------------- */
.page-head .lede{color:var(--muted);max-width:62ch}
.prose{max-width:70ch}
.prose h2{margin-top:28px}
.prose h2:first-child{margin-top:0}
.prose p{margin:0 0 12px}
.prose .table-wrap{max-width:none}
.plain{padding-left:20px;margin:0 0 12px}
.plain li{margin:2px 0}
.sched.skill td.strong{font-weight:600}
.calib-wrap{margin:12px 0 4px;max-width:420px}
.calib{width:100%;height:auto;display:block}
.calib .grid{stroke:var(--line);stroke-width:1}
.calib .axis{font-family:var(--mono);font-size:12px;fill:var(--muted)}
.calib .diag{stroke:var(--faint);stroke-width:1.5;stroke-dasharray:4 4}
.calib .cl{fill:none;stroke:var(--accent);stroke-width:2;stroke-linejoin:round}
.calib .pt{fill:var(--accent);stroke:var(--surface);stroke-width:2}
.calib .pt.thin{fill:var(--surface);stroke:var(--accent)}
.numbers{margin:8px 0 0}
.numbers summary{cursor:pointer;color:var(--accent);font-size:.9rem}

/* --- knockout tournaments (src/reader_site/tournament.py) ------------------ */
.more-teams{margin-top:8px}
.more-teams summary{cursor:pointer;font-size:.88rem;color:var(--accent);padding:4px 0}
abbr[title]{text-decoration:none;cursor:help}
/* The bracket: each section a row of columns, one per round. Every column
   spreads its games evenly over the same height, so a game sits level with
   the two games that feed it. A section wider than a phone scrolls in its
   own frame. */
.bk-sec{margin-top:6px}
.bk-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;padding-bottom:4px}
.bk-grid{display:grid;grid-template-columns:repeat(4,minmax(132px,1fr));gap:0 14px;min-width:580px}
.bk-grid.three{grid-template-columns:repeat(3,minmax(132px,1fr));min-width:440px}
.bk-col{display:flex;flex-direction:column;min-width:0}
.bk-h{font-family:var(--mono);font-size:.7rem;letter-spacing:.06em;text-transform:uppercase;
  color:var(--muted);display:flex;justify-content:space-between;gap:6px;margin-bottom:4px}
.bk-h span{color:var(--faint);text-transform:none;letter-spacing:0}
.bk-games{flex:1;display:flex;flex-direction:column;justify-content:space-around;gap:8px}
.bk-g{position:relative;background:var(--surface);border:1px solid var(--line);border-radius:6px}
/* A short tick to the right of every game but the last column's points at the next round. */
.bk-col:not(:last-child) .bk-g::after{content:"";position:absolute;right:-15px;top:50%;width:14px;
  border-top:1px solid var(--line-strong)}
.bk-t{display:flex;justify-content:space-between;align-items:baseline;gap:6px;padding:3px 8px;
  font-size:.8rem;line-height:1.35;cursor:pointer}
.bk-t+.bk-t{border-top:1px solid var(--line)}
.bk-t .nm{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bk-t .v{font-family:var(--mono);font-size:.72rem;color:var(--muted);flex:none}
.bk-t.won .nm{font-weight:600}
.bk-t.won .v{color:var(--ink)}
.bk-t.lost .nm{color:var(--faint);text-decoration:line-through;text-decoration-color:var(--line-strong)}
.bk-t.proj .nm{color:var(--muted);font-style:italic}
.bk-t.on,tr.on>*{background:color-mix(in srgb,var(--accent) 16%,var(--surface))}
.bk-t.on .nm{color:var(--ink)}
