/* Layout: one 1120px column, sticky top bar, belt-plate cards for holders, ledgers for tables. */
:root {
  --paper: #f3f4ee;
  --panel: #fbfbf7;
  --ink: #17221b;
  --muted: #5c675f;
  --rule: #d6dacf;
  --gold: #9a6b0c;
  --gold-soft: #f1e3bf;
  --win: #2f7a46;
  --loss: #b0392c;
  --uefa: #3f63b5;
  --conmebol: #2b8a7a;
  --concacaf: #b5532f;
  --caf: #a8861b;
  --afc: #a63b62;
  --ofc: #6b58b8;
  --display: "Big Shoulders Display", "Arial Narrow", Impact, sans-serif;
  --body: "Libre Franklin", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1512; --panel: #161e19; --ink: #e6ebe3; --muted: #9aa69c; --rule: #2a352e;
    --gold: #e0b04a; --gold-soft: #3a2f16; --win: #63b77c; --loss: #e57063;
    --uefa: #7b9be6; --conmebol: #5cc2ae; --concacaf: #e48a62; --caf: #d6b648; --afc: #df7299; --ofc: #a594ec;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1512; --panel: #161e19; --ink: #e6ebe3; --muted: #9aa69c; --rule: #2a352e;
  --gold: #e0b04a; --gold-soft: #3a2f16; --win: #63b77c; --loss: #e57063;
  --uefa: #7b9be6; --conmebol: #5cc2ae; --concacaf: #e48a62; --caf: #d6b648; --afc: #df7299; --ofc: #a594ec;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 var(--body); }
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--gold); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 800; text-transform: uppercase; letter-spacing: .01em; line-height: 1; text-wrap: balance; margin: 0; }
h1 { font-size: clamp(2.6rem, 7vw, 4.6rem); }
h2 { font-size: clamp(1.7rem, 4vw, 2.3rem); }
h3 { font-size: 1.3rem; }
.num, td.n, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.label { font-size: .72rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }

/* top bar */
.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); border-bottom: 1px solid var(--rule); }
.bar-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 900; font-size: 1.5rem; text-transform: uppercase; text-decoration: none; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; }
nav { display: flex; gap: 4px 18px; flex-wrap: wrap; font-size: .85rem; font-weight: 600; }
nav a { text-decoration: none; color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
nav a.on, nav a:hover { color: var(--ink); border-bottom-color: var(--gold); }

main { max-width: 1120px; margin: 0 auto; padding: 32px 16px 64px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; }
section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; min-width: 0; }
.head { display: grid; gap: 10px; }
.lede { max-width: 62ch; font-size: 1.05rem; color: var(--muted); margin: 0; }
footer { max-width: 1120px; margin: 0 auto; padding: 24px 16px 40px; border-top: 1px solid var(--rule); color: var(--muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; }

/* belts */
.main-belt { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .main-belt { grid-template-columns: 1fr; } }
.plate { position: relative; background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 18px 20px; display: grid; gap: 6px; text-decoration: none; min-width: 0; }
.plate:hover { border-color: var(--gold); }
.plate .who { font-family: var(--display); font-weight: 900; text-transform: uppercase; font-size: 2rem; line-height: 1; }
.plate.big { background: var(--gold-soft); border-color: var(--gold); padding: 24px; align-content: space-between; }
.plate.big .who { font-size: clamp(2.8rem, 8vw, 4.4rem); }
.plate .meta { font-size: .85rem; color: var(--muted); }
.plate .stat { display: flex; gap: 18px; flex-wrap: wrap; font-size: .85rem; }
.plate .stat b { font-family: var(--mono); font-weight: 600; }
.belts { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.side-stack { display: grid; gap: 12px; }

/* ribbons */
.ribbons { display: grid; gap: 10px; }
.ribbon-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: center; }
.ribbon-row a { font-weight: 600; font-size: .85rem; text-decoration: none; }
.ribbon { position: relative; height: 22px; border-radius: 3px; overflow: hidden; background: var(--rule); }
.ribbon span { position: absolute; top: 0; bottom: 0; }
.ribbon span:hover { outline: 2px solid var(--ink); z-index: 1; }
.axis { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; }
.axis div { position: relative; height: 16px; font-family: var(--mono); font-size: .7rem; color: var(--muted); }
.axis span { position: absolute; transform: translateX(-50%); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; pointer-events: none; z-index: 10; background: var(--ink); color: var(--paper); padding: 6px 10px; border-radius: 4px; font-size: .8rem; max-width: 260px; }

/* tables */
.ledger { overflow-x: auto; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th { text-align: left; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 10px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; position: sticky; top: 0; background: var(--panel); }
td { padding: 7px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; white-space: nowrap; }
td.d { white-space: nowrap; font-family: var(--mono); font-size: .8rem; }
tr.zone-up td:first-child { box-shadow: inset 3px 0 var(--win); }
tr.zone-down td:first-child { box-shadow: inset 3px 0 var(--loss); }
tr.champ td { background: var(--gold-soft); }
tr.current td { background: var(--gold-soft); }
.pill { display: inline-block; font-size: .7rem; font-weight: 600; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--rule); color: var(--muted); white-space: nowrap; }
.pill.gold { border-color: var(--gold); color: var(--gold); }
.pill.up { border-color: var(--win); color: var(--win); }
.pill.down { border-color: var(--loss); color: var(--loss); }
.res-W { color: var(--win); font-weight: 700; }
.res-L { color: var(--loss); font-weight: 700; }
.res-D { color: var(--muted); font-weight: 700; }

/* controls */
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button, .btn { font: 600 .82rem var(--body); padding: 6px 12px; border-radius: 99px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
input[type="search"], select { font: .9rem var(--body); padding: 7px 12px; border-radius: 6px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); min-width: 0; }
input[type="search"] { width: min(320px, 100%); }
.yearnav { display: flex; align-items: center; gap: 10px; }
.yearnav .yr { font-family: var(--display); font-weight: 900; font-size: 3rem; line-height: 1; min-width: 3ch; text-align: center; }

/* stats strip */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts div { padding: 14px 16px 14px 0; display: grid; gap: 2px; }
.facts b { font-family: var(--display); font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 800; line-height: 1; }
@media (max-width: 520px) { .facts { grid-template-columns: 1fr 1fr; } .facts div { padding-right: 10px; } }

/* team grid */
.teamgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 4px 20px; }
.teamgrid a { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--rule); text-decoration: none; font-size: .9rem; }
.teamgrid a .num { color: var(--muted); font-size: .78rem; }
.conf-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: 1px; }

.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--mono); }
.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.chart .champ { fill: var(--gold); }
.chart .band { fill: var(--panel); }
.chartbox { background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; padding: 12px; overflow-x: auto; }

.prose { max-width: 66ch; display: grid; gap: 12px; align-content: start; }
.prose p, .prose ul { margin: 0; }
.prose li { margin-bottom: 6px; }
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
@media (max-width: 820px) { .two { grid-template-columns: 1fr; } }
.loading { color: var(--muted); padding: 40px 0; }
@media (prefers-reduced-motion: no-preference) { main { animation: rise .25s ease-out; } }
@keyframes rise { from { transform: translateY(4px); } to { transform: none; } }
.sortb { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; }
.sortb[aria-sort="ascending"], .sortb[aria-sort="descending"] { color: var(--ink); }
.sortb:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
th.n .sortb { text-align: right; }

/* flag crests: shape picked per team, flag clipped inside a thin ink rim */
.crest { display: inline-block; flex: none; width: var(--s); height: calc(var(--s) * 1.2); padding: max(1px, calc(var(--s) / 22)); background: var(--ink); vertical-align: middle; }
.crest img { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--rule); }
.tl { display: inline-flex; align-items: center; gap: .45em; }
.plate .who { display: flex; align-items: center; gap: .3em; }
.plate .who > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.teamh { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.plate .next { font-size: .85rem; border-top: 1px dashed var(--rule); padding-top: 8px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.plate.big .next { border-top-color: var(--gold); }
input[type="date"] { font: .9rem var(--body); padding: 6px 10px; border-radius: 6px; border: 1px solid var(--rule); background: var(--panel); color: var(--ink); }
#bmine { gap: 6px; }
#bmine .btn { text-decoration: none; font-size: .78rem; }
.vsbox { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); }
#bsel button { font: 600 .8rem var(--body); padding: 4px 10px; border-radius: 99px; border: 1px solid var(--gold); background: var(--gold-soft); color: var(--ink); cursor: pointer; }

/* club crests: colours and initials instead of a flag */
.crest.club > span { display: grid; place-items: center; width: 100%; height: 100%; }
.crest.club b { font: 800 calc(var(--s) * .34)/1 var(--display); color: #fff; letter-spacing: .02em; text-shadow: 0 1px 2px rgba(0,0,0,.55); }
.brand .sub { font-size: .9rem; color: var(--muted); letter-spacing: .08em; }
[hidden] { display: none !important; }
