/* One layout, five edition palettes, each in a light and a dark mode.
   Type, shapes and the outline cursor are PES5's for every edition;
   [data-theme] only sets colours: page art, bars, cursor, accent and links.
   [data-mode] sets the surfaces (panels, text, rows, inputs); editions tint them
   where their menus need it. Palettes follow each edition's menus and packaging,
   without any game artwork. */

:root {
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: Bahnschrift, "DIN Alternate", "Segoe UI", Arial, sans-serif;
  --display-style: normal;
  --display-weight: 700;
  --display-stretch: expanded;
  --display-spacing: .09em;
  --panel-radius: 10px;
  --button-radius: 6px;
  --cursor-text: var(--panel-text);
  --div-1: #e7b416; --div-2: #b9c0c9; --div-3a: #c4813c; --div-3b: #5b88b8; --div-a: #8c939c;
  --div-ink: #111;
}

/* PES5: a misty floodlit pitch, translucent grey panels, charcoal title strips,
   a yellow cursor. */
[data-theme="pes5"] {
  --art:
    radial-gradient(ellipse 120% 55% at 50% -12%, rgba(255, 255, 255, .85), rgba(255, 255, 255, 0) 65%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 90px, rgba(255, 255, 255, 0) 90px 180px),
    linear-gradient(180deg, #d4dcd8 0%, #9bb796 28%, #4a8443 52%, #2c6129 78%, #1f4a1d 100%);
  --scrim-light: rgba(236, 241, 243, .5);
  --scrim-dark: rgba(6, 10, 14, .74);
  --header-bg: linear-gradient(180deg, #5d636b, #2b2f35);
  --header-text: #fff;
  --header-border: #f2b705;
  --nav-active-bg: #ffd23f;
  --nav-active-text: #111;
  --bar-bg: linear-gradient(180deg, #555b63, #24282e);
  --bar-text: #fff;
  --bar-mark: #f2b705;
  --cursor: rgba(255, 210, 63, .2);
  --cursor-ring: #ffd23f;
  --accent: linear-gradient(180deg, #ffd23f, #e9a400);
  --accent-text: #1a1200;
  --link-light: #6e4700;
  --link-dark: #ffd23f;
  --focus: #ffd23f;
}

/* WE9: a stormy grey sky, black plates, a red 9. */
[data-theme="we9"] {
  --art:
    linear-gradient(168deg, rgba(255, 255, 255, .16) 0 18%, rgba(255, 255, 255, 0) 38%),
    radial-gradient(ellipse 90% 70% at 50% 38%, #a3a8ae, #5d6268 55%, #222428 100%);
  --scrim-light: rgba(238, 240, 242, .62);
  --scrim-dark: rgba(10, 11, 13, .62);
  --header-bg: #0b0b0b;
  --header-text: #fff;
  --header-border: #c8102e;
  --nav-active-bg: #fff;
  --nav-active-text: #0b0b0b;
  --bar-bg: linear-gradient(180deg, #2c2c2c, #050505);
  --bar-text: #fff;
  --bar-mark: #c8102e;
  --cursor: rgba(200, 16, 46, .14);
  --cursor-ring: #c8102e;
  --accent: #c8102e;
  --accent-text: #fff;
  --link-light: #a50d24;
  --link-dark: #ff7186;
  --focus: #c8102e;
}

/* WE9 Liveware Evolution: a crimson stadium crowd, white plates edged in black, flag blue. */
[data-theme="we9le"] {
  --art:
    radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1.6px) 0 0 / 11px 11px,
    radial-gradient(circle at 30% 0%, #e5233f, #a30d22 45%, #5e0612);
  --scrim-light: rgba(255, 255, 255, .06);
  --scrim-dark: rgba(22, 0, 5, .58);
  --header-bg: #fff;
  --header-text: #111;
  --header-border: #111;
  --nav-active-bg: #0047a0;
  --nav-active-text: #fff;
  --bar-bg: linear-gradient(180deg, #2e2e2e, #0b0b0b);
  --bar-text: #fff;
  --bar-mark: #0047a0;
  --cursor: rgba(0, 71, 160, .14);
  --cursor-ring: #0047a0;
  --accent: #0047a0;
  --accent-text: #fff;
  --link-light: #0047a0;
  --link-dark: #9cc2ff;
  --focus: #ffd23f;
}

/* PES6: amber light swirls on cream, black bars with yellow type. */
[data-theme="pes6"] {
  --art:
    radial-gradient(ellipse 55% 45% at 72% 36%, rgba(255, 251, 228, .95), rgba(255, 238, 170, 0) 70%),
    repeating-radial-gradient(ellipse 150% 95% at 88% 62%, rgba(255, 255, 255, 0) 0 34px,
      rgba(255, 246, 205, .6) 36px 38px, rgba(255, 255, 255, 0) 41px 72px),
    linear-gradient(115deg, #fff6d2 0%, #f8cd4f 34%, #db8d00 68%, #7c4400 100%);
  --scrim-light: rgba(255, 250, 236, .32);
  --scrim-dark: rgba(22, 12, 0, .74);
  --header-bg: rgba(255, 249, 230, .94);
  --header-text: #111;
  --header-border: #111;
  --footer-bg: #000;
  --footer-text: #fff;
  --nav-active-bg: #111;
  --nav-active-text: #ffd400;
  --bar-bg: linear-gradient(180deg, #3b3b3b, #050505);
  --bar-text: #ffd400;
  --bar-mark: #ffc400;
  --cursor: rgba(255, 196, 0, .24);
  --cursor-ring: #d99a00;
  --accent: linear-gradient(180deg, #3b3b3b, #000);
  --accent-text: #ffd400;
  --link-light: #874800;
  --link-dark: #ffd24a;
  --focus: #d71920;
}

/* WE2007 (inferred from the packaging): white and silver swooshes over a strip
   of pitch, chrome bars, a red accent. */
[data-theme="we2007"] {
  --art:
    radial-gradient(ellipse 130% 45% at 50% 118%, #3d8c2e 0 42%, rgba(61, 140, 46, 0) 43%),
    radial-gradient(ellipse 150% 60% at 8% 18%, rgba(255, 255, 255, 0) 0 48%,
      rgba(178, 185, 194, .55) 49% 51%, rgba(255, 255, 255, 0) 52%),
    radial-gradient(ellipse 170% 70% at 92% 28%, rgba(255, 255, 255, 0) 0 55%,
      rgba(160, 167, 177, .45) 56% 58%, rgba(255, 255, 255, 0) 59%),
    linear-gradient(180deg, #fff, #e3e6ea 60%, #c6cbd1);
  --scrim-light: rgba(255, 255, 255, 0);
  --scrim-dark: rgba(12, 14, 17, .84);
  --header-bg: linear-gradient(180deg, #fdfdfd, #d3d7dc 55%, #b5bac1);
  --header-text: #111;
  --header-border: #d71920;
  --nav-active-bg: #d71920;
  --nav-active-text: #fff;
  --bar-bg: linear-gradient(180deg, #f5f6f8, #c4c9cf 50%, #9ba1a9);
  --bar-text: #111;
  --bar-mark: #d71920;
  --cursor: rgba(215, 25, 32, .12);
  --cursor-ring: #d71920;
  --accent: #d71920;
  --accent-text: #fff;
  --link-light: #b0141b;
  --link-dark: #ff7d75;
  --focus: #d71920;
}

/* Modes: neutral surfaces first, then each edition's tints. */
[data-mode="light"] {
  --path: #a87400;
  color-scheme: light;
  --scrim: var(--scrim-light);
  --link: var(--link-light);
  --page-fill: #dfe3e8;
  --page-text: #121417;
  --page-muted: #474e58;
  --panel-bg: rgba(255, 255, 255, .95);
  --panel-text: #141619;
  --panel-muted: #575e68;
  --panel-border: #c3c8cf;
  --panel-shadow: 0 4px 16px rgba(0, 0, 0, .14);
  --row-alt: rgba(0, 0, 0, .035);
  --row-line: rgba(0, 0, 0, .09);
  --button-bg: #fff;
  --button-text: #141619;
  --button-border: #a9afb7;
  --input-bg: #fff;
  --input-border: #8d949d;
}
[data-mode="dark"] {
  --path: #f5c518;
  color-scheme: dark;
  --scrim: var(--scrim-dark);
  --link: var(--link-dark);
  --page-fill: #0d1014;
  --page-text: #eef1f5;
  --page-muted: #b3bbc6;
  --panel-bg: rgba(16, 19, 25, .9);
  --panel-text: #eef1f5;
  --panel-muted: #a6afbb;
  --panel-border: rgba(210, 218, 230, .28);
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --row-alt: rgba(255, 255, 255, .04);
  --row-line: rgba(255, 255, 255, .08);
  --button-bg: rgba(255, 255, 255, .08);
  --button-text: #eef1f5;
  --button-border: rgba(210, 218, 230, .4);
  --input-bg: rgba(0, 0, 0, .35);
  --input-border: rgba(210, 218, 230, .45);
}
[data-theme="pes5"][data-mode="light"] {
  --panel-bg: rgba(231, 235, 239, .9);
  --panel-border: rgba(255, 255, 255, .8);
  --row-alt: rgba(255, 255, 255, .5);
  --page-text: #0f1419;
}
[data-theme="we9le"][data-mode="light"] {
  --page-text: #fff;
  --page-muted: #f8d6dc;
  --panel-border: #111;
  --button-border: #111;
  --input-border: #111;
  --row-alt: #f7f1f2;
  --row-line: #e9dfe1;
}
[data-theme="pes6"][data-mode="light"] {
  --page-text: #111;
  --page-muted: #4a3600;
  --panel-bg: rgba(255, 252, 240, .94);
  --panel-border: rgba(0, 0, 0, .28);
  --panel-shadow: 0 8px 24px rgba(80, 50, 0, .28);
  --row-alt: #fff6d6;
  --row-line: #efe2b4;
}
[data-theme="pes6"][data-mode="dark"] {
  --page-text: #fff6dc;
  --page-muted: #e3cf9c;
  --panel-bg: rgba(22, 15, 4, .9);
  --header-bg: #0c0904;
  --header-text: #fff;
  --header-border: #ffc400;
  --nav-active-bg: #ffd400;
  --nav-active-text: #000;
}
[data-theme="we2007"][data-mode="dark"] { --panel-bg: rgba(30, 33, 38, .94); }

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--page-fill); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(var(--scrim), var(--scrim)), var(--art); background-attachment: fixed;
  color: var(--page-text);
  font: 15px/1.5 var(--font-body);
}
a { color: var(--link); text-underline-offset: 2px; }
.panel a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
img { max-width: 100%; }
.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 16px; }
main.wrap { flex: 1; padding-top: 24px; padding-bottom: 40px; }
.display, .panel-title, .brand, .nav a, .button, .eyebrow, .stat dt, .table th, .tabs a {
  font-family: var(--font-display); font-stretch: var(--display-stretch); text-transform: uppercase;
  font-style: var(--display-style); letter-spacing: var(--display-spacing);
}
.display { margin: 0; font-size: clamp(1.9rem, 5vw, 3rem); font-weight: var(--display-weight); line-height: 1.05; }
.muted { color: var(--panel-muted); }
.page-head .muted, .hero .muted { color: var(--page-muted); }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.visually-hidden, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 10; padding: 8px 12px; background: #fff; color: #111; }

/* Masthead */
.masthead {
  position: sticky; top: 0; z-index: 5; background: var(--header-bg); color: var(--header-text);
  border-bottom: 3px solid var(--header-border); box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.masthead-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; min-height: 58px; flex-wrap: wrap; }
.brand {
  display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none;
  font-size: 1.3rem; font-weight: 800;
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 35%, #fff 0 18%, transparent 19%),
              conic-gradient(var(--header-border) 0 25%, currentColor 0 50%, var(--header-border) 0 75%, currentColor 0);
  box-shadow: 0 0 0 2px currentColor;
}
.nav { background: rgba(127, 127, 127, .12); border-top: 1px solid rgba(127, 127, 127, .25); }
.nav-row { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-top: 4px; padding-bottom: 4px; }
.nav a {
  color: inherit; text-decoration: none; font-size: .95rem; font-weight: 700; padding: 6px 14px;
  white-space: nowrap; clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.nav a:hover { background: rgba(127, 127, 127, .2); }
.nav a[aria-current="page"] { background: var(--nav-active-bg); color: var(--nav-active-text); }
.masthead-tools { display: flex; align-items: center; gap: 10px; }
.theme-picker { display: flex; align-items: center; gap: 6px; font-size: .8rem; text-transform: uppercase; }
.theme-picker select {
  font: inherit; text-transform: none; padding: 4px 6px; border-radius: 4px;
  border: 1px solid currentColor; background: transparent; color: inherit;
}
.theme-picker option { color: #111; background: #fff; }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px;
  border: 1px solid var(--button-border); border-radius: var(--button-radius);
  background: var(--button-bg); color: var(--button-text); font-size: .9rem; font-weight: 700;
  text-decoration: none; cursor: pointer; line-height: 1.2;
}
.button:hover { filter: brightness(1.1); }
.button-accent, .panel .button-accent { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.button[aria-disabled="true"] { opacity: .4; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Panels */
.panel {
  background: var(--panel-bg); color: var(--panel-text); border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius); box-shadow: var(--panel-shadow); overflow: hidden; margin-bottom: 24px;
}
.panel-title {
  position: relative; margin: 0; padding: 9px 16px 9px 22px; background: var(--bar-bg);
  color: var(--bar-text); font-size: 1rem; font-weight: 800;
}
.panel-title::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 7px; background: var(--bar-mark); }
.panel-title::after {
  content: ""; position: absolute; inset: 0 0 0 auto; width: 30%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .12)); pointer-events: none;
}
.panel-body { padding: 16px; }
.panel-body > :first-child { margin-top: 0; }
.panel-body > :last-child { margin-bottom: 0; }
.panel.narrow { max-width: 560px; margin-inline: auto; }
.more { text-align: right; margin: 12px 0 0; font-weight: 600; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 24px; }
.subhead { margin: 18px 0 6px; font-size: .9rem; text-transform: uppercase; }

/* Home */
.hero { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: center; margin-bottom: 28px; }
.eyebrow { margin: 0 0 6px; color: var(--page-muted); font-weight: 700; }
.lead { font-size: 1.1rem; max-width: 46ch; color: var(--page-text); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; }
.stat {
  background: var(--panel-bg); color: var(--panel-text); border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius); padding: 12px 14px; box-shadow: var(--panel-shadow);
}
.stat dt { font-size: .75rem; font-weight: 700; color: var(--panel-muted); }
.stat dd { margin: 2px 0 0; font: 800 1.7rem/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.stat-live dd::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: middle;
  border-radius: 50%; background: #2fd15c; box-shadow: 0 0 0 3px rgba(47, 209, 92, .25);
}
.stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.stats-grid .stat { box-shadow: none; }
.stats-grid .stat dd { font-size: 1.35rem; white-space: nowrap; }
.live-list, .lobby-list { list-style: none; margin: 0; padding: 0; }
.live-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 4px 10px;
  align-items: center; padding: 10px 0; border-bottom: 1px solid var(--row-line);
}
.live-item:last-child, .lobby-list li:last-child { border-bottom: 0; }
.live-status, .live-lobby { grid-row: 1; font-size: .72rem; color: var(--panel-muted); text-transform: uppercase; }
.live-status { grid-column: 1 / 3; font-weight: 700; }
.live-lobby { grid-column: 3; text-align: right; }
.live-home { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.live-away { font-weight: 600; overflow-wrap: anywhere; }
.live-score, .score {
  font: 800 1.05rem var(--font-display); font-variant-numeric: tabular-nums; padding: 2px 10px;
  background: var(--bar-bg); color: var(--bar-text); border-radius: 4px; white-space: nowrap;
}
.lobby-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--row-line); }
.empty { color: var(--panel-muted); text-align: center; padding: 16px 0; }

/* Page headings, tabs, search */
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-head p { margin: 0; }
.page-head a { color: inherit; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a {
  padding: 6px 14px; border: 1px solid var(--button-border); border-radius: var(--button-radius);
  background: var(--button-bg); color: var(--button-text); text-decoration: none; font-weight: 700; font-size: .85rem;
}
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.search { display: flex; gap: 8px; flex: 1 1 320px; max-width: 480px; }
.search input { flex: 1; min-width: 0; }
.crumbs { font-weight: 600; }
.crumbs a[aria-current] { text-decoration: none; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th {
  text-align: left; font-size: .78rem; font-weight: 700; color: var(--panel-muted);
  padding: 8px 10px; border-bottom: 2px solid var(--panel-border); white-space: nowrap;
}
.table th a { color: inherit; text-decoration: none; }
.table th a:hover { text-decoration: underline; }
.sort-mark { margin-left: 4px; font-size: .7em; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--row-line); }
.table tbody tr:nth-child(even) { background: var(--row-alt); }
.table tbody tr:hover {
  background: var(--cursor); color: var(--cursor-text);
  outline: 2px solid var(--cursor-ring); outline-offset: -2px;
}
.table tbody tr:hover a, .table tbody tr:hover .muted { color: inherit; }
.table .num { text-align: right; }
.table .center { text-align: center; }
.table .right { text-align: right; }
.pos { font-weight: 800; }
.matches th.num, .matches th.center, .matches td.center, .matches td:last-child, .matches th:last-child { width: 1%; white-space: nowrap; }
.matches .tag { display: block; width: max-content; margin: 4px auto 0; }
.badge { width: 20px; height: 20px; object-fit: contain; vertical-align: middle; }
button.score { border: 0; cursor: pointer; }
button.score:hover { outline: 2px solid var(--cursor-ring); outline-offset: 1px; }

/* Goals-by-period popup: a native popover, light-dismissed on outside click or Esc */
.match-card {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius); background: var(--panel-bg); color: var(--panel-text);
  box-shadow: var(--panel-shadow); backdrop-filter: blur(8px);
}
.match-card::backdrop { background: rgba(0, 0, 0, .45); }
.match-card-head {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center;
  padding: 14px 16px; background: var(--bar-bg); color: var(--bar-text); font-weight: 700;
  border-top: 3px solid var(--bar-mark);
}
.match-card-head .score { font-size: 1.3rem; background: rgba(0, 0, 0, .35); }
.periods { width: 100%; border-collapse: collapse; table-layout: fixed; }
.periods th { width: 34%; }
.periods td { text-align: left; }
.periods td:last-child { width: auto; white-space: normal; }
.periods th, .periods td { padding: 8px 12px; border-bottom: 1px solid var(--row-line); }
.periods th { text-align: left; font-weight: 600; color: var(--panel-muted); white-space: nowrap; }
.periods td.center { font: 700 1rem var(--font-display); font-variant-numeric: tabular-nums; width: 4.5em; text-align: center; }
.periods td.right { text-align: right; }
.periods .kicks { background: var(--row-alt); }
.periods .kicks th::before { content: "\25CF  "; color: var(--bar-mark); }
.goal-mark { width: 16px; max-width: none; height: 16px; margin: 0 1px; vertical-align: middle; image-rendering: pixelated; }
.match-card-foot { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: 10px 16px; }
.tag {
  display: inline-block; margin-left: 6px; padding: 0 6px; border: 1px solid currentColor; border-radius: 3px;
  font-size: .68rem; text-transform: uppercase; opacity: .75; vertical-align: middle;
}
.division {
  display: inline-block; min-width: 2.2em; padding: 1px 6px; border-radius: 4px; text-align: center;
  font: 800 .8rem var(--font-display); color: var(--div-ink); background: var(--div-a);
}
.division-1 { background: var(--div-1); }
.division-2 { background: var(--div-2); }
.division-3a { background: var(--div-3a); }
.division-3b { background: var(--div-3b); color: #fff; }

/* Pager */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 16px; }
.pager-info { color: var(--panel-muted); }
.pager-size { margin-left: auto; color: var(--panel-muted); display: flex; gap: 6px; align-items: center; }
.pager-size a { padding: 2px 6px; border-radius: 3px; text-decoration: none; }
.pager-size a[aria-current] {
  background: var(--cursor); color: var(--cursor-text);
  outline: 2px solid var(--cursor-ring); outline-offset: -2px;
}

/* Player card */
.player-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.player-head p { margin: 0; }
.player-head .division { font-size: 1rem; padding: 4px 10px; }
.big { font: 800 1.6rem var(--font-display); }
.chat-icon { display: block; height: 32px; image-rendering: pixelated; }
.credits { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.credits dt { font-weight: 700; }
.credits dd { margin: 0; }
.guide-intro { max-width: 72ch; margin: 0 0 16px; }
.guide-steps { columns: 300px 3; column-gap: 24px; }
.guide-steps .panel { break-inside: avoid; }
.guide ul { padding-left: 20px; }
.guide li + li { margin-top: 4px; }
.commands { margin: 12px 0; }
.commands dt { margin-top: 10px; }
.commands dt:first-child { margin-top: 0; }
.commands dd { margin: 2px 0 0; color: var(--panel-muted); }
.guide code { white-space: nowrap; }

/* Forms and notices */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 4px; align-content: start; }
.field label { font-weight: 700; }
input, select { font: inherit; }
.form input:not([type="checkbox"]), .search input {
  padding: 9px 11px; border-radius: var(--button-radius); border: 1px solid var(--input-border);
  background: var(--input-bg); color: var(--panel-text);
}
.search input { color: var(--panel-text); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.hint { margin: 0; font-size: .82rem; color: var(--panel-muted); }
.form-error, .notice-error { color: #fff; background: #b3261e; padding: 10px 12px; border-radius: 4px; margin: 0; }
.notice { padding: 12px 14px; border-radius: 4px; background: var(--panel-bg); color: var(--panel-text); border: 1px solid var(--panel-border); }
.notice-ok { background: #1e7d34; color: #fff; border-color: transparent; }
.panel .search { margin-bottom: 14px; max-width: none; }
form.inline { display: inline; }
.toolbar { margin-bottom: 16px; }

/* Dialogs */
.dialog {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: auto;
  border: 1px solid var(--panel-border); border-radius: var(--panel-radius);
  background: var(--panel-bg); color: var(--panel-text);
}
.dialog::backdrop { background: rgba(0, 0, 0, .55); }
.dialog > .form { padding: 0 20px 20px; }
.dialog-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  margin: 0 -20px; padding: 14px 20px; background: var(--panel-bg); border-bottom: 1px solid var(--panel-border);
}
.dialog-head h2 { margin: 0; font: 800 1.15rem var(--font-display); }
.dialog-close { border: 0; background: none; color: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.dialog-section { display: grid; gap: 12px; margin: 0; padding: 14px 0 0; border: 0; border-top: 1px solid var(--panel-border); }
.dialog-section[hidden] { display: none; }
.dialog-section h3 { margin: 0; font-size: 1rem; }
.dialog-section h3 small { font-weight: 400; color: var(--panel-muted); }
.dialog-actions {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px;
  margin: 0 -20px -20px; padding: 14px 20px; background: var(--panel-bg); border-top: 1px solid var(--panel-border);
}
.advanced summary { cursor: pointer; font-weight: 700; }
.grid-2, .grid-3 { display: grid; gap: 12px 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
fieldset.bare { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.bare[hidden] { display: none; }
fieldset.stack { display: grid; gap: 12px; padding-left: 14px; border-left: 3px solid var(--bar-mark); }
fieldset.stack h4 { margin: 4px 0 0; font-size: .95rem; }
.preview { margin: 0; padding: 8px 10px; border-radius: var(--button-radius); background: var(--input-bg); font-weight: 600; }
.preview:empty { display: none; }
.leaderboard tr.through .pos { box-shadow: inset 4px 0 var(--bar-mark); }
.form select { padding: 9px 11px; border-radius: var(--button-radius); border: 1px solid var(--input-border); background: var(--input-bg); color: var(--panel-text); }
.field .label { font-weight: 700; }
.fixed { padding: 9px 0; color: var(--panel-muted); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; padding: 0; border: 0; }
.segmented legend { padding: 0; margin-bottom: 6px; font-weight: 700; }
.segmented label {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; cursor: pointer;
  border: 1px solid var(--input-border); border-radius: var(--button-radius); background: var(--input-bg);
}
.segmented label:has(input:checked) { border-color: var(--focus); box-shadow: 0 0 0 2px var(--focus); }
.segmented input { margin-top: 3px; }
.segmented span { display: grid; gap: 2px; }
.segmented small { color: var(--panel-muted); }
.button-danger { background: #b3261e; color: #fff; border-color: transparent; }
td .button { padding: 4px 10px; font-size: .78rem; }
.log {
  margin: 0; max-height: 70vh; overflow: auto; padding: 12px; border-radius: 4px; font: 12px/1.45 ui-monospace, Consolas, monospace;
  background: #0b0d10; color: #d6dae0; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* Footer */
.footer {
  background: var(--footer-bg, var(--header-bg)); color: var(--footer-text, var(--header-text));
  border-top: 3px solid var(--header-border); font-size: .88rem;
}
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 16px; padding-bottom: 16px; }
.footer p { margin: 0; }
.footer a { color: inherit; }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; }
  .masthead { position: static; }
  .masthead-row { padding-top: 8px; padding-bottom: 8px; }
  .brand { font-size: 1.1rem; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .nav-row { flex-wrap: wrap; }
  .stats.stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid .stat dd { font-size: 1.15rem; white-space: normal; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat dd { font-size: 1.3rem; }
  .pager-size { margin-left: 0; }
  .table td, .table th { padding: 7px 6px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Competitions */
.ties .through { font-weight: 700; }
.ties .badge { vertical-align: middle; }
.ties .tag { display: block; width: max-content; margin: 4px auto 0; }
.columns.groups { grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); align-items: start; }

/* Round pager: one round at a time */
.pager-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.pager-step { padding: 6px 14px; font-size: 1.1rem; }
.pager-step:disabled { opacity: .4; cursor: default; }
.pager-pick { flex: 1; min-width: 0; max-width: 320px; padding: 7px 10px; border-radius: var(--button-radius); border: 1px solid var(--input-border); background: var(--input-bg); color: var(--panel-text); font-weight: 700; }
.group-matches { margin-top: 14px; }
.group-matches > summary { list-style: none; }
.group-matches > summary::-webkit-details-marker { display: none; }
.group-matches > summary::before { content: "\25B8"; }
.group-matches[open] > summary::before { content: "\25BE"; }
.group-matches[open] > summary { margin-bottom: 12px; }

/* Knockout bracket */
.bracket-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.bracket-tools .button { padding: 6px 12px; }
.bracket-view { overflow: auto; max-height: 75vh; border: 1px solid var(--row-line); border-radius: var(--button-radius); cursor: grab; overscroll-behavior: contain; }
.bracket-view.dragging { cursor: grabbing; user-select: none; }
.bracket-tree { display: flex; width: max-content; padding: 0 16px 16px; }
.bracket-round { display: flex; flex-direction: column; width: 250px; margin-right: 44px; }
.bracket-round:last-child { margin-right: 0; }
.bracket-head { position: sticky; top: 0; z-index: 1; margin: 0 0 8px; padding: 6px 0; font-size: .95rem; text-align: center; background: var(--panel-bg); backdrop-filter: blur(8px); border-bottom: 1px solid var(--row-line); }
.bracket-head small { display: block; font-weight: 400; color: var(--panel-muted); font-size: .78rem; }
.bracket-round.current .bracket-head { color: var(--link); }
.bracket-slots { flex: 1; display: flex; flex-direction: column; }
.bracket-pair { flex: 1; display: flex; flex-direction: column; justify-content: space-around; position: relative; }
.bracket-pair.two::before, .bracket-pair.two::after { content: ""; position: absolute; right: -22px; height: 25%; border-right: 2px solid var(--panel-border); }
.bracket-pair.two::before { top: 25%; }
.bracket-pair.two::after { top: 50%; }
.bracket-match { position: relative; margin: 8px 0; height: 62px; display: flex; flex-direction: column; border: 1px solid var(--panel-border); border-radius: var(--button-radius); background: var(--row-alt); }
.bracket-match::after { content: ""; position: absolute; right: -23px; top: 50%; width: 22px; border-top: 2px solid var(--panel-border); }
.bracket-round:not(:first-child) .bracket-match::before { content: ""; position: absolute; left: -23px; top: 50%; width: 22px; border-top: 2px solid var(--panel-border); }
.bracket-round:last-child .bracket-match::after { display: none; }
.bracket-round.current .bracket-match.open { border-color: var(--bar-mark); box-shadow: 0 0 0 1px var(--bar-mark); }
.bracket-match.tbd { border-style: dashed; background: none; }
.bracket-match.winner { height: 40px; border-color: var(--bar-mark); }
.bracket-side { flex: 1; display: flex; align-items: center; gap: 6px; padding: 0 8px; min-width: 0; }
.bracket-side + .bracket-side { border-top: 1px solid var(--row-line); }
.bracket-side.won { font-weight: 700; box-shadow: inset 3px 0 var(--path); }
/* The way a winner goes: out of their tie, along their half of the joint, into the next tie. */
.bracket-round .bracket-match.advanced::after, .bracket-round .bracket-match.fed::before,
.bracket-pair.won-top::before, .bracket-pair.won-bottom::after { border-color: var(--path); z-index: 1; }
.bracket-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bracket-name small { font-weight: 400; }
.bracket-goals { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.bracket-note { position: absolute; top: 2px; right: -12px; color: var(--panel-muted); }
