/* Fonts are served from this site (no requests to Google). All three families use the SIL Open Font License. */
@font-face { font-family: "Big Shoulders Display"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/big-shoulders-display-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Big Shoulders Display"; font-style: normal; font-weight: 800; font-display: swap; src: url("fonts/big-shoulders-display-latin-800-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

/* Layout: ad rail | stacked league tables | ad rail. Tiers run top to bottom, the way the pyramid does. */
:root {
  --paper: #F2F4F0;        /* touchline chalk */
  --sheet: #FFFFFF;
  --ink: #121B2A;          /* floodlight navy */
  --muted: #5A6577;
  --rule: #DCE1DA;
  --rule-strong: #AEB7AD;
  --accent: #2440C4;       /* cobalt */
  --accent-soft: #E5E9FB;
  --accent-line: #9AA9EC;
  --accent-flash: #C3CDF6;
  --up: #17834A;
  --mid: #B07506;
  --down: #C2362C;
  --hover: #F6F8F5;
  --hatch: rgba(18, 27, 42, 0.06);
  --display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E141C; --sheet: #151D28; --ink: #E6EBF0; --muted: #96A1B3;
    --rule: #243041; --rule-strong: #3A4B62;
    --accent: #8EA2FF; --accent-soft: #1C2547; --accent-line: #4256A8; --accent-flash: #2D3C7A;
    --up: #45C47E; --mid: #E6AA3A; --down: #F26B60;
    --hover: #18212D; --hatch: rgba(230, 235, 240, 0.06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E141C; --sheet: #151D28; --ink: #E6EBF0; --muted: #96A1B3;
  --rule: #243041; --rule-strong: #3A4B62;
  --accent: #8EA2FF; --accent-soft: #1C2547; --accent-line: #4256A8; --accent-flash: #2D3C7A;
  --up: #45C47E; --mid: #E6AA3A; --down: #F26B60;
  --hover: #18212D; --hatch: rgba(230, 235, 240, 0.06);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 25; background: var(--paper);
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.bar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.bar-inner {
  max-width: 1320px; margin: 0 auto;
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-text { display: grid; line-height: 1; }
.brand-text small {
  margin-bottom: 3px; font-family: var(--mono); font-size: 10px; font-weight: 500;
  letter-spacing: 0.3em; text-transform: uppercase; color: var(--accent);
}
.brand-text span {
  font-family: var(--display); font-weight: 800; font-size: 27px;
  letter-spacing: 0.07em; text-transform: uppercase;
}
.glyph { display: inline-grid; justify-items: center; gap: 3px; }
.glyph i { display: block; height: 5px; border-radius: 1px; background: var(--accent); }
.glyph i:nth-child(1) { width: 10px; }
.glyph i:nth-child(2) { width: 18px; }
.glyph i:nth-child(3) { width: 26px; }

.nav { display: flex; gap: 2px; order: 2; }
.nav a {
  font-family: var(--display); font-weight: 700; font-size: 18px; line-height: 1;
  letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none;
  padding: 8px 10px; border-radius: 6px; color: var(--muted); white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--sheet); }
.nav a[aria-current="page"] { color: var(--paper); background: var(--ink); }
.nav .long { display: none; }

.finder { position: relative; margin-left: auto; order: 3; }
.finder svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.finder input {
  width: 220px; height: 36px; padding: 0 32px 0 32px;
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 8px;
}
.finder input::placeholder { color: var(--muted); }
.finder input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.finder button {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer;
}
.finder button:hover { background: var(--hover); color: var(--ink); }

@media (min-width: 1040px) {
  .nav .long { display: inline; }
  .nav .short { display: none; }
}
@media (max-width: 699px) {
  .brand-text span { font-size: 22px; letter-spacing: 0.05em; }
  .brand-text small { font-size: 9px; letter-spacing: 0.24em; }
  .finder { flex: 1 1 130px; min-width: 0; }
  .finder input { width: 100%; }
  .nav { order: 4; flex: 1 1 100%; justify-content: space-between; }
  .nav a { flex: 1; text-align: center; }
}

/* ---------- Shell ---------- */
.shell {
  max-width: 1320px; margin: 0 auto;
  padding-block: 28px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px;
}
main { min-width: 0; width: 100%; max-width: 820px; justify-self: center; }
.rail { display: none; }
.rail .stick { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); display: grid; gap: 16px; }
@media (min-width: 1060px) {
  .shell { grid-template-columns: minmax(0, 1fr) 300px; }
  .rail-right { display: block; }
  main { justify-self: end; }
}
@media (min-width: 1320px) {
  .shell { grid-template-columns: 160px minmax(0, 1fr) 300px; }
  .rail-left { display: block; }
  main { justify-self: center; }
}

/* ---------- Ad slots ---------- */
.ad {
  width: 100%; height: var(--h, 250px);
  display: grid; place-content: center; justify-items: center; gap: 2px;
  border: 1px dashed var(--rule-strong); border-radius: 8px;
  background: repeating-linear-gradient(135deg, transparent 0 10px, var(--hatch) 10px 11px), var(--paper);
  color: var(--muted); text-align: center;
}
.ad-tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.ad-size { font-family: var(--display); font-weight: 700; font-size: 24px; letter-spacing: 0.03em; color: var(--ink); opacity: 0.7; }
.ad-note { font-size: 12px; }
.ad-inline { --h: 100px; max-width: 320px; margin: 40px auto 0; }
@media (min-width: 760px) { .ad-inline { --h: 90px; max-width: 728px; } }
@media (min-width: 1060px) { .ad-inline { display: none; } }
.ad-inline .ad-size .wide { display: none; }
@media (min-width: 760px) { .ad-inline .ad-size .wide { display: inline; } .ad-inline .ad-size .narrow { display: none; } }

/* ---------- Intro ---------- */
.eyebrow { margin: 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
h1 {
  margin: 8px 0 0; max-width: 20ch;
  font-family: var(--display); font-weight: 800; font-size: clamp(2.4rem, 6.4vw, 3.9rem);
  line-height: 0.98; letter-spacing: 0.005em; text-wrap: balance;
}
.lede { margin: 14px 0 0; max-width: 60ch; color: var(--muted); font-size: 16px; }
.stamp {
  display: inline-flex; align-items: center; gap: 8px; margin: 16px 0 0;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mid); flex: none; }
.stamp.live .dot { background: var(--up); }
@media (prefers-reduced-motion: no-preference) {
  .stamp.live .dot { animation: pulse 2s ease-in-out infinite; }
}
@keyframes pulse { 50% { opacity: 0.35; } }

/* Pyramid figure: bar width is to scale with clubs per tier */
.pyr {
  margin: 28px 0 0; padding: 18px 18px 14px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px;
}
.pyr-rows { display: grid; gap: 6px; }
.pyr-row {
  display: grid; grid-template-columns: 54px minmax(0, 1fr); align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
}
.pyr-tier { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.pyr-track { position: relative; height: 34px; display: flex; align-items: center; justify-content: center; }
.pyr-bar {
  position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: var(--w); border-radius: 4px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
}
.pyr-label {
  position: relative; display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap;
  font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: 0.04em; text-transform: uppercase;
}
.pyr-label small { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted); }
a.pyr-row:hover .pyr-bar { border: 2px solid var(--accent); }
a.pyr-row:hover .pyr-label span { text-decoration: underline; text-underline-offset: 3px; }
.pyr-row.soon .pyr-bar { background: transparent; border: 1px dashed var(--rule-strong); }
.pyr-row.soon .pyr-label { color: var(--muted); }
.pyr figcaption { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.nm-short { display: none; }
@media (max-width: 480px) {
  .nm-long { display: none; }
  .nm-short { display: inline; }
  .pyr { padding: 14px 12px 12px; }
  .pyr-row { grid-template-columns: 44px minmax(0, 1fr); gap: 6px; }
  .pyr-tier { font-size: 10px; letter-spacing: 0.02em; }
  .pyr-label { font-size: 15px; gap: 6px; }
}

/* ---------- Tier sections ---------- */
.tier { margin-top: 52px; scroll-margin-top: 84px; }
@media (max-width: 699px) { .tier { scroll-margin-top: 124px; } }
.tier-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; }
.tier-num { margin: 0; flex: 1 1 100%; font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.tier h2 {
  margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(2.1rem, 5.4vw, 2.9rem);
  line-height: 0.95; letter-spacing: 0.02em; text-transform: uppercase; text-wrap: balance;
}
.tier-meta { margin: 0 0 0 auto; font-size: 13px; color: var(--muted); }
.legend { list-style: none; margin: 14px 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; background: currentColor; flex: none; }
.legend .k-top i { color: var(--up); }
.legend .k-mid i { color: var(--mid); }
.legend .k-down i { color: var(--down); }

.table-wrap { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; font-size: 14px; }
thead th {
  padding: 10px 8px; text-align: right; font-weight: 500;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--rule); white-space: nowrap;
}
tbody td, tbody th { padding: 8px; text-align: right; border-bottom: 1px solid var(--rule); }
tbody tr:last-child > * { border-bottom: 0; }
thead .c-club, tbody .c-club { text-align: left; }
thead abbr { text-decoration: none; cursor: help; }
tbody th.c-club { font-weight: 500; }
.c-pos { width: 44px; text-align: center !important; font-weight: 600; color: var(--muted); }
.c-n { width: 40px; }
.c-gd { width: 50px; }
.c-pts { width: 52px; padding-right: 14px !important; font-weight: 700; }
.c-form { width: 120px; }
tbody tr:hover > * { background: var(--hover); }
tr.z-top .c-pos { box-shadow: inset 4px 0 0 var(--up); color: var(--up); }
tr.z-mid .c-pos { box-shadow: inset 4px 0 0 var(--mid); color: var(--mid); }
tr.z-down .c-pos { box-shadow: inset 4px 0 0 var(--down); color: var(--down); }
tbody tr.edge > * { border-bottom: 2px solid var(--rule-strong); }
tbody tr.is-mine > * { background: var(--accent-soft); }
tbody tr.is-mine .c-club { font-weight: 700; }
tbody tr.is-mine .c-club::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--accent); vertical-align: 2px; }
@media (prefers-reduced-motion: no-preference) {
  tbody tr.flash > * { animation: flash 1.6s ease-out; }
}
@keyframes flash { 0%, 35% { background: var(--accent-flash); } 100% { background: var(--accent-soft); } }
.ded {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 500; line-height: 18px; vertical-align: 1px;
  color: var(--down); border: 1px solid currentColor;
}
.form { display: inline-flex; gap: 3px; }
.form b { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 3px; font-family: var(--mono); font-size: 10px; font-weight: 500; color: var(--sheet); }
.form .W { background: var(--up); } .form .D { background: var(--muted); } .form .L { background: var(--down); }
.tier-notes { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

@media (max-width: 599px) {
  .c-w, .c-d, .c-l, .c-gf, .c-ga, .c-form { display: none; }
  table { font-size: 14px; }
  tbody td, tbody th { padding: 9px 6px; }
  .c-pos { width: 36px; }
  .tier-meta { margin-left: 0; flex: 1 1 100%; }
}
@media (max-width: 899px) { .c-form { display: none; } }

/* Promotion and relegation between tiers */
.band { position: relative; margin: 18px 0 0 6px; padding: 2px 0 2px 22px; display: grid; gap: 3px; font-size: 14px; }
.band::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; border-radius: 1px; background: var(--rule-strong); }
.band p { margin: 0; }
.band-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.band .arw { display: inline-block; width: 18px; font-size: 11px; }
.band-down .arw { color: var(--down); }
.band-up .arw { color: var(--up); }

.next-tiers { margin-top: 44px; padding: 18px 20px; border: 1px dashed var(--rule-strong); border-radius: 10px; }
.next-tiers h2 { margin: 4px 0 6px; font-family: var(--display); font-weight: 800; font-size: 1.9rem; line-height: 1; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }
.next-tiers p { margin: 0; max-width: 60ch; font-size: 14px; color: var(--muted); }

/* ---------- Home: country cards ---------- */
.countries {
  list-style: none; margin: 28px 0 0; padding: 0;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
}
.countries a {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name mini" "meta mini";
  align-items: center; gap: 4px 16px; height: 100%; padding: 12px 14px;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px;
  text-decoration: none; color: var(--ink);
}
.c-name { grid-area: name; }
.c-meta { grid-area: meta; }
.mini { grid-area: mini; }
@media (min-width: 640px) {
  .countries { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
  .countries a { grid-template-columns: minmax(0, 1fr); grid-template-areas: "name" "mini" "meta"; gap: 10px; padding: 14px 14px 12px; }
  .countries .mini { width: 100%; max-width: 84px; justify-self: start; }
}
.countries a:hover { border-color: var(--accent); }
.c-name { font-family: var(--display); font-weight: 800; font-size: clamp(18px, 2.2vw, 22px); line-height: 1; letter-spacing: 0.04em; text-transform: uppercase; }
.c-meta { font-size: 12.5px; color: var(--muted); }
.mini { display: grid; gap: 3px; justify-items: center; width: 84px; }
.mini i { display: block; height: 5px; border-radius: 1px; background: var(--accent-line); width: var(--w); }
.countries a:hover .mini i { background: var(--accent); }

/* ---------- Groups inside a tier ---------- */
.group + .group { margin-top: 22px; }
.group-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 12px; margin: 0 0 8px; }
.group-head h3 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.4rem; line-height: 1; letter-spacing: 0.03em; text-transform: uppercase; }
.group-head span { font-size: 12.5px; color: var(--muted); }

.more { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; font-weight: 600; font-size: 14px; color: var(--accent); text-decoration: none; }
.more:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Text pages (privacy, about) ---------- */
.prose { max-width: 68ch; }
.prose h1 { max-width: none; }
.prose h2 {
  margin: 40px 0 8px; font-family: var(--display); font-weight: 800; font-size: 1.65rem; line-height: 1.05;
  letter-spacing: 0.02em; text-transform: uppercase; text-wrap: balance;
}
.prose p, .prose li { font-size: 16px; line-height: 1.65; }
.prose p { margin: 0 0 14px; }
.prose ul { margin: 0 0 14px; padding-left: 20px; display: grid; gap: 6px; }
.prose a { color: var(--accent); text-underline-offset: 3px; }
.prose .updated { margin: 12px 0 0; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.prose .summary { margin: 24px 0 0; padding: 16px 18px; background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }
.prose .summary p:last-child { margin-bottom: 0; }
.email-line { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 16px; }
.email-line a { font-family: var(--mono); font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.copy {
  font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  color: var(--ink); background: var(--sheet); border: 1px solid var(--rule-strong);
}
.copy:hover { border-color: var(--accent); }

/* ---------- Footer ---------- */
footer { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--rule); display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
footer p { margin: 0; max-width: 72ch; }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 6px; }
.foot-links a, .foot-links button { color: var(--ink); font: inherit; font-size: 13px; text-underline-offset: 3px; }
.foot-links button { padding: 0; border: 0; background: none; text-decoration: underline; cursor: pointer; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: calc(100% - 32px); padding: 10px 14px; border-radius: 8px;
  background: var(--ink); color: var(--paper); font-size: 14px;
}

/* Until ads are switched on (ADS in scripts/leagues.mjs), hide the slots and centre the tables. */
body.no-ads .rail, body.no-ads .ad-inline { display: none !important; }
body.no-ads .shell { grid-template-columns: minmax(0, 1fr) !important; }
body.no-ads main { justify-self: center !important; }
