/* =====================================================================
 * WC 2026 Predictor — design system (EPIC-8)
 * Mobile-first, host-nation-inspired palette (USA / Canada / México):
 * deep navy brand, with red, green and gold accents. No official
 * tournament marks — flags + generic football iconography only.
 * ===================================================================== */

:root {
  /* Surfaces & ink */
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --border: #dbe0ea;
  --text: #131722;
  --muted: #5a6473;

  /* Brand & accents */
  --brand: #14254c;          /* deep navy */
  --brand-2: #1d3a6e;        /* lighter navy for gradients */
  --brand-ink: #0c1830;
  --accent: #1f6feb;         /* action blue (links, primary buttons) */
  --accent-dark: #1657c2;
  --red: #d7263d;            /* USA / Canada / México red */
  --green: #128a4f;          /* México green */
  --gold: #e3a008;

  /* States */
  --ok: #1a7f37;
  --error: #c2371a;
  --locked: #8a9099;

  /* Podium medals */
  --medal-gold: #d4a017;
  --medal-silver: #9aa3ad;
  --medal-bronze: #b3793f;

  /* Geometry */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --maxw: 960px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 16px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  overflow-wrap: break-word;
}

a {
  color: var(--accent);
}

h1 {
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.2;
}

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem;
}

/* Keyboard users can skip the header straight to content. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  background: var(--brand);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  left: 0;
}

/* --- Header / brand / nav --------------------------------------------- */
.site-header {
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.6rem 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.brand__mark {
  display: inline-flex;
  color: #fff;
}

.brand__text {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
.brand__text b {
  color: var(--gold);
}
.brand__sub {
  margin-left: 0.4rem;
  padding-left: 0.5rem;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  font-weight: 500;
  opacity: 0.92;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
  margin-left: auto;
}

.site-nav a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-pill);
  line-height: 1;
}
.site-nav a:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.site-nav a.is-active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--gold);
}

.site-nav__cta {
  background: var(--gold);
  color: var(--brand-ink) !important;
}
.site-nav__cta:hover {
  background: #f0ac1a;
}

/* Profile menu (EPIC-19): a circular initial avatar pinned top-right opens a
   small menu with Change password / Logout, replacing the old inline controls
   so Logout can't be mis-tapped from the nav row on mobile. */
.profile-menu {
  position: relative;
  display: inline-flex;
  margin-left: 0.4rem;
}
.profile-menu__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 50%;
}
.profile-menu__trigger:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.profile-menu__avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--gold);
  color: var(--brand-ink);
  border: 1px solid rgba(255, 255, 255, 0.4);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
}

.profile-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-align: left;
  /* Hidden until opened; not focusable/clickable while hidden. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
/* No-JS fallback: focusing the trigger reveals the menu so the links stay
   reachable. With JS active (html.js) the explicit is-open toggle takes over. */
html:not(.js) .profile-menu:focus-within .profile-menu__panel,
.profile-menu.is-open .profile-menu__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.profile-menu__name {
  display: block;
  padding: 0.3rem 0.55rem 0.45rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.profile-menu__form {
  margin: 0;
}
/* Scoped under .profile-menu so these beat the white .site-nav a rule (the
   change-password item is an <a> inside .site-nav). */
.profile-menu .profile-menu__item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.55rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
}
.profile-menu .profile-menu__item:hover,
.profile-menu .profile-menu__item:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.profile-menu .profile-menu__item--logout {
  color: var(--red);
}

/* Stats dropdown (EPIC-26): the flat Stats nav link becomes a popover holding
   Player stats / Site stats, reusing the profile-menu show/hide interaction
   (one shared handler) but styled as an inline nav item that opens downward. */
.stats-menu {
  position: relative;
  display: inline-flex;
}
.stats-menu__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  border: 0;
  background: none;
  cursor: pointer;
  /* Match the .site-nav a pill styling so it sits flush with the other tabs. */
  color: rgba(255, 255, 255, 0.92);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-pill);
  line-height: 1;
}
.stats-menu__trigger:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.stats-menu__trigger.is-active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 0 -2px 0 var(--gold);
}
.stats-menu__trigger:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.stats-menu__caret {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
}
.stats-menu__panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 10rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
html:not(.js) .stats-menu:focus-within .stats-menu__panel,
.stats-menu.is-open .stats-menu__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
/* Scoped under .stats-menu so these beat the white .site-nav a rule. */
.stats-menu .stats-menu__item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.55rem;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  color: var(--text);
}
.stats-menu .stats-menu__item:hover,
.stats-menu .stats-menu__item:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.stats-menu .stats-menu__item[aria-current="page"] {
  color: var(--accent-dark);
  box-shadow: inset 2px 0 0 var(--gold);
}

/* --- Flash messages ---------------------------------------------------- */
ul.flash {
  max-width: var(--maxw);
  margin: 0.75rem auto 0;
  padding: 0 1rem;
  list-style: none;
}
ul.flash li {
  background: #e6f0ff;
  border: 1px solid #b9d2ff;
  color: var(--accent-dark);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
}

.error {
  color: var(--error);
}

/* --- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-block;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn:hover {
  background: var(--accent-dark);
}
.btn:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.4);
  outline-offset: 2px;
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
}
.btn--ghost:hover {
  background: rgba(31, 111, 235, 0.08);
}

.btn--save {
  padding: 0.55rem 1.25rem;
}

/* --- Hero (homepage) --------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 85% -20%, rgba(227, 160, 8, 0.22), transparent 55%),
    linear-gradient(125deg, var(--brand) 0%, var(--brand-2) 70%, #244a8c 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}
/* Subtle host-nation stripe accent along the top edge. */
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--red) 0 33%, #fff 33% 66%, var(--green) 66%);
  opacity: 0.85;
}
.hero__eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}
.hero__title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
}
.hero__intro {
  margin: 0;
  max-width: 52ch;
  color: rgba(255, 255, 255, 0.88);
}

/* --- Generic section heading ------------------------------------------ */
.section-head h1 {
  margin-bottom: 0.25rem;
}
.predictions__intro,
.admin__intro,
.leaderboard__intro,
.rules__intro {
  color: var(--muted);
  max-width: 62ch;
}

/* --- Stage navigation -------------------------------------------------- */
.stage-nav {
  position: sticky;
  top: 52px; /* sits below the sticky header */
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.6rem 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.stage-nav a {
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--brand);
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
}
.stage-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.stage__title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid var(--brand);
  font-size: 1.2rem;
}

.day-heading {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Fixture card ------------------------------------------------------ */
.fixture {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  scroll-margin-top: 6rem;
  box-shadow: var(--shadow-sm);
}
.fixture--locked {
  opacity: 0.8;
  background: var(--surface-2);
}

.fixture__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.7rem;
}
.fixture__meta time {
  font-weight: 700;
  color: var(--text);
}
.fixture__venue {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Badges ------------------------------------------------------------ */
.badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.12rem 0.55rem;
  white-space: nowrap;
}

.badge--locked {
  background: #e9e9ec;
  color: var(--locked);
  border-color: var(--locked);
}
.badge--entered {
  background: #e3f3e8;
  border-color: var(--ok);
  color: var(--ok);
}
.badge--pending {
  background: #fdece7;
  border-color: var(--error);
  color: var(--error);
}

/* Stage badge: neutral base, with a left tick of stage colour. */
.badge--stage {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--border);
  box-shadow: inset 3px 0 0 var(--brand);
  padding-left: 0.6rem;
}
.badge--stage-group { box-shadow: inset 3px 0 0 var(--muted); color: var(--muted); }
.badge--stage-r32   { box-shadow: inset 3px 0 0 var(--accent); color: var(--accent-dark); }
.badge--stage-r16   { box-shadow: inset 3px 0 0 var(--green); color: var(--green); }
.badge--stage-qf    { box-shadow: inset 3px 0 0 #c77d0a; color: #b56f08; }
.badge--stage-sf    { box-shadow: inset 3px 0 0 var(--red); color: var(--red); }
.badge--stage-third_place { box-shadow: inset 3px 0 0 var(--medal-bronze); color: var(--medal-bronze); }
.badge--stage-final { box-shadow: inset 3px 0 0 var(--gold); color: #a9760a; }

/* --- Flags ------------------------------------------------------------- */
.flag {
  font-size: 1.15rem;
  line-height: 1;
  flex: 0 0 auto;
}
/* Placeholder teams (e.g. "Winner Group A") get a neutral marker. */
.flag--tbc {
  display: inline-block;
  width: 1.15rem;
  height: 0.8rem;
  border-radius: 2px;
  border: 1px dashed var(--border);
  background: repeating-linear-gradient(
    45deg, var(--surface-2), var(--surface-2) 3px, #e7eaf1 3px, #e7eaf1 6px
  );
}

/* --- Score row --------------------------------------------------------- */
.fixture__score {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.4rem 0.6rem;
}
.team {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}
.team--home {
  justify-content: flex-end;
}
.team--away {
  justify-content: flex-start;
}
.team__name {
  font-weight: 600;
  min-width: 0;
  /* Prefer word-boundary wrapping ("Bosnia & Herzegovina" breaks at the space,
     not "Herzegovin / a"); a single word wider than its column still breaks as a
     last resort (BUG-4). */
  overflow-wrap: break-word;
}

.score {
  width: 3rem;
  height: 2.75rem; /* >=44px touch target */
  text-align: center;
  font-size: 1.1rem; /* >=16px avoids iOS focus zoom */
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.score:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}
.score:disabled {
  background: #e9e9ec;
  color: var(--muted);
}
.score-sep {
  color: var(--muted);
  font-weight: 700;
}

.penalties {
  margin-top: 0.65rem;
  font-size: 0.9rem;
}
.penalties select {
  margin-left: 0.4rem;
  min-height: 2.6rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
}

.is-hidden {
  display: none;
}

.fixture__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 0.75rem;
  margin-top: 0.7rem;
}
.outcome {
  font-weight: 700;
  color: var(--brand);
}
.status {
  font-size: 0.85rem;
  transition: opacity 0.8s ease;
}
.status.is-fading { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .status { transition: none; }
}
.status--ok { color: var(--ok); }
.status--error { color: var(--error); }
.status--locked { color: var(--locked); }

.countdown {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.no-prediction {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--locked);
}

/* --- Post-kickoff reveal (EPIC-14) ------------------------------------- */
/* A collapsible panel under each locked fixture showing everyone's picks.
   Native <details>/<summary> so it works with no JavaScript. */
.reveal {
  margin: -0.4rem 0 0.75rem;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--surface-2);
}
.reveal__summary {
  cursor: pointer;
  list-style-position: inside;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}
.reveal__summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.reveal__teaser {
  font-weight: 400;
  color: var(--muted);
}
.reveal__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.reveal__table th,
.reveal__table td {
  text-align: left;
  padding: 0.4rem 1rem;
  border-top: 1px solid var(--border);
}
.reveal__table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 700;
}
.reveal__player { font-weight: 600; }
.reveal__you { font-weight: 400; color: var(--muted); }
.reveal__pick { font-variant-numeric: tabular-nums; white-space: nowrap; }
.reveal__pens-name { overflow-wrap: break-word; }
.reveal__dash { color: var(--muted); }
.reveal__pts-col,
.reveal__pts {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
/* The requesting user's own row is highlighted. */
.reveal__row--self {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--brand);
}
.reveal__row--self .no-prediction { color: var(--muted); }

/* EPIC-18: full-time result row at the top of the reveal table. */
.reveal__result {
  background: var(--surface);
  font-weight: 600;
}
.reveal__result-label {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
}
.reveal__result-score {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.reveal__result--pending .reveal__result-score {
  color: var(--muted);
  font-weight: 400;
}

/* EPIC-18: correct-prediction highlights — a stronger treatment for an exact
   score than for a correct outcome. Placed after --self so the background wins
   while self's left bar still shows when a row is both. The ★/✓ markers carry
   the meaning without relying on colour alone. */
.reveal__row--outcome { background: #e3f3e8; box-shadow: inset 3px 0 0 var(--ok); }
.reveal__row--exact {
  background: #fbf0d6;
  box-shadow: inset 4px 0 0 var(--gold);
  font-weight: 600;
}
.reveal__hit { margin-left: 0.3rem; font-size: 0.8rem; }

/* EPIC-20: per-game award badges (Lone Wolf / Agent of Chaos) on a reveal row.
   Each badge is a chip that reveals its description on hover/focus/tap — so the
   meaning is reachable on touch, where a `title` tooltip never shows. */
.reveal-badge {
  position: relative;
  display: inline-block;
  margin-left: 0.3rem;
}
.reveal-badge__trigger {
  cursor: pointer;
  padding: 0.05rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: inherit;
  white-space: nowrap;
}
.reveal-badge__trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.reveal-badge__popover {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: min(16rem, 72vw);
  padding: 0.4rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.72rem;
  font-weight: 400;
  white-space: normal;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.reveal-badge.is-up .reveal-badge__popover {
  top: auto;
  bottom: calc(100% + 4px);
}
.reveal-badge:hover .reveal-badge__popover,
.reveal-badge:focus-within .reveal-badge__popover,
.reveal-badge.is-open .reveal-badge__popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* BUG-1: standings column-header tooltips ("Exact" / "Scored"). A bare
   abbr/title never reveals on touch, so the header becomes a small popover
   trigger driven by awards.js — reveal on hover, keyboard focus, or tap. The
   popover anchors to the header's right edge (these are right-aligned numeric
   columns) so it grows leftward and never causes horizontal scroll on phones. */
.col-tip {
  position: relative;
  display: inline-block;
}
.col-tip__trigger {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-transform: inherit;
  letter-spacing: inherit;
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
}
.col-tip__trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.col-tip__popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  width: max-content;
  max-width: min(14rem, 70vw);
  padding: 0.4rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  text-align: left;
  color: var(--text);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
.col-tip.is-up .col-tip__popover {
  top: auto;
  bottom: calc(100% + 6px);
}
.col-tip:hover .col-tip__popover,
.col-tip:focus-within .col-tip__popover,
.col-tip.is-open .col-tip__popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* --- Admin results page ------------------------------------------------ */
.admin__summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0;
}
.admin__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.admin__filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}
/* Pending fixtures get a warm left edge so they're easy to spot. */
.fixture--pending {
  border-left: 4px solid var(--error);
}

/* BUG-3: fixtures that haven't kicked off are read-only until the game starts —
   dimmed, with a neutral left edge overriding the pending warmth and a marker
   where the Save button would be. */
.fixture--future {
  opacity: 0.85;
}
.fixture--future.fixture--pending {
  border-left-color: var(--locked);
}
.fixture__future-note {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
}

.btn--small {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}

/* --- Bracket resolution warning (EPIC-16) ------------------------------ */
.bracket-warning {
  margin: 1rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--error);
  border-left: 4px solid var(--error);
  border-radius: var(--radius-sm);
  background: #fdece7;
  color: #7a2a16;
  font-size: 0.9rem;
  max-width: 70ch;
}
.bracket-warning p {
  margin: 0.4rem 0;
}
.bracket-warning ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
}
.bracket-tie {
  margin-top: 0.9rem;
}
.bracket-tie__msg {
  margin: 0 0 0.4rem;
  font-weight: 600;
}
.bracket-tie__table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface, #fff);
  color: var(--text, #1a1a2e);
  font-size: 0.85rem;
}
.bracket-tie__table th,
.bracket-tie__table td {
  padding: 0.3rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border, #e2e2ea);
}
.bracket-tie__table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted, #5a5a72);
}
.bracket-tie__team {
  text-align: left;
  white-space: nowrap;
}
.bracket-tie__row--tied {
  background: #fde2cf;
  font-weight: 600;
}

/* --- Admin override page (EPIC-10) ------------------------------------- */
.override-warning {
  margin: 0.9rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--error);
  border-left: 4px solid var(--error);
  border-radius: var(--radius-sm);
  background: #fdece7;
  color: #7a2a16;
  font-size: 0.9rem;
  max-width: 70ch;
}
.overrides__list {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.25rem;
}
.override-row__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.override-row__user {
  font-weight: 700;
  font-size: 1.05rem;
}
.badge--points {
  background: #e3f3e8;
  border-color: var(--ok);
  color: var(--ok);
}
.override-row__reason {
  display: block;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.override-row__optional {
  font-weight: 400;
}
.override-row__reason input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--text);
}

/* --- Homepage leaderboard --------------------------------------------- */
.podium {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 0 0 1.75rem;
}
.podium__slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
/* Medal colour follows the true rank, so joint places share a medal colour. */
.podium__slot--rank-1 { border-top-color: var(--medal-gold); background: #fffaf0; }
.podium__slot--rank-2 { border-top-color: var(--medal-silver); background: #f8fafc; }
.podium__slot--rank-3 { border-top-color: var(--medal-bronze); background: #fdf6f0; }

.podium__medal { font-size: 1.7rem; line-height: 1; }
.podium__rank {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
}
.podium__name { font-size: 1.15rem; font-weight: 700; }
.podium__points { font-weight: 700; color: var(--brand); }
.podium__meta { font-size: 0.8rem; color: var(--muted); }

.podium__empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  color: var(--muted);
  max-width: 52ch;
  margin: 0 auto;
}

/* On wider screens, arrange as a real podium: 2nd, 1st (tallest), 3rd. */
@media (min-width: 640px) {
  .podium {
    flex-direction: row;
    align-items: flex-end;
    justify-content: center;
    gap: 1rem;
  }
  .podium__slot {
    flex: 1 1 0;
    max-width: 13rem;
    justify-content: flex-end;
  }
  /* Layout position keeps the raised 2-1-3 podium well-formed regardless of
     ties: each of left/centre/right is filled exactly once by display order. */
  .podium__slot--pos-1 { order: 2; padding-top: 1.85rem; }
  .podium__slot--pos-2 { order: 1; padding-top: 1.15rem; }
  .podium__slot--pos-3 { order: 3; }
}

/* --- Standings table --------------------------------------------------- */
.standings {
  width: 100%;
  /* Separated borders (not collapsed) with visible overflow so an award popover
     opening from a bottom row is not clipped by the table box (EPIC-17). Rounded
     corners are restored on the corner cells below. */
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  box-shadow: var(--shadow-sm);
}
.standings th,
.standings td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.standings thead th:first-child { border-top-left-radius: var(--radius); }
.standings thead th:last-child { border-top-right-radius: var(--radius); }
.standings tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.standings tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }
.standings thead th {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
}
.standings tbody tr:last-child td {
  border-bottom: none;
}
.standings__rank {
  width: 2.5rem;
  font-weight: 700;
  text-align: center;
}
.standings__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.standings__name {
  font-weight: 600;
}
.standings__row--top {
  background: #fffdf6;
}

.leaderboard__note {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

/* --- Award badges + popover (EPIC-17) ---------------------------------- */
/* A player with no awards renders as plain text (.player, no trigger). A holder
   gets a focusable trigger that reveals a popover on hover, keyboard focus, or
   tap (awards.js). The popover is server-rendered, so hover/focus work with no
   JS. */
.player {
  position: relative;
  display: inline-flex;
}
.player__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  /* A subtle dotted underline signals the name is interactive. */
  text-decoration: underline dotted var(--muted);
  text-underline-offset: 3px;
}
.player__trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.player__medal {
  font-size: 0.85em;
  line-height: 1;
}

.player__popover {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 13rem;
  max-width: min(18rem, 78vw);
  /* Never taller than the viewport — scroll within if a player holds many
     awards — so a long list stays fully readable (EPIC-20 fix). */
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.6rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  text-align: left;
  /* awards.js sets --popover-shift to nudge the popover back on-screen when a
     wide phone popover would run off either viewport edge (BUG-4); 0 on desktop
     and for popovers that never overflow, so this is inert there. */
  transform: translateX(var(--popover-shift, 0px));
  /* Hidden until revealed; not focusable/clickable while hidden. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
/* Flip above the trigger when there isn't room below (set by awards.js), so the
   popover for a bottom-of-table row never runs off the screen edge. */
.player.is-up .player__popover {
  top: auto;
  bottom: calc(100% + 6px);
}
.player:hover .player__popover,
.player:focus-within .player__popover,
.player.is-open .player__popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.player__popover-title {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.badge-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
}
.badge-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
}
.badge-chip__emoji {
  font-size: 1.15rem;
  line-height: 1;
  flex: none;
}
.badge-chip__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.badge-chip__name {
  font-weight: 600;
  font-size: 0.86rem;
}
.badge-chip__blurb {
  font-size: 0.72rem;
  color: var(--muted);
}
.badge-chip__value {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--brand);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 0.1rem 0.5rem;
  font-size: 0.85rem;
}

/* EPIC-23: round Champion badges — pinned bold above the overall awards, with a
   gold accent and a divider separating them from the regular award list. */
.badge-list--champion {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.badge-chip--champion .badge-chip__name {
  font-weight: 800;
  color: var(--gold);
}

/* --- Auth pages (login / change password) ----------------------------- */
.auth-card {
  max-width: 26rem;
  margin: 1.5rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  margin-top: 0;
}
.auth-card label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.85rem;
}
.auth-card input[type="text"],
.auth-card input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.7rem;
  font: inherit;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.auth-card input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}
.auth-card button[type="submit"] {
  width: 100%;
  margin-top: 0.25rem;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.auth-card button[type="submit"]:hover {
  background: var(--accent-dark);
}
.auth-card .error {
  background: #fdece7;
  border: 1px solid #f3c2b4;
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
}

/* --- Footer ------------------------------------------------------------ */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  max-width: var(--maxw);
  margin: 2.5rem auto 1.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--muted);
}
.site-footer a {
  font-weight: 600;
  text-decoration: none;
}
/* "What's new" re-open trigger: a <button> that reads as a footer text link. */
.site-footer__link {
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
}
.site-footer__link:hover { text-decoration: underline; }
.site-footer__note {
  flex: 1 1 16rem;
  min-width: 0;
}
.site-footer__brand {
  font-weight: 600;
}

/* Cost breakdown popover (EPIC-22): the footer cost figure reveals a
   per-service breakdown on hover (desktop) or tap/focus (mobile), reusing the
   profile-menu mechanics. The panel opens upwards since the footer sits at the
   page bottom. */
.cost-breakdown {
  position: relative;
  display: inline-flex;
}
.cost-breakdown__trigger {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
.cost-breakdown__trigger:hover {
  color: var(--text);
}
.cost-breakdown__trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
.cost-breakdown__panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 30;
  min-width: 13rem;
  max-width: min(20rem, calc(100vw - 2rem));
  padding: 0.5rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  color: var(--text);
  /* Hidden until opened; not focusable/clickable while hidden. */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
}
/* No-JS fallback: hover or focusing the trigger reveals the panel. With JS
   active (html.js) the explicit is-open toggle takes over for tap. */
.cost-breakdown:hover .cost-breakdown__panel,
html:not(.js) .cost-breakdown:focus-within .cost-breakdown__panel,
.cost-breakdown.is-open .cost-breakdown__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.cost-breakdown__row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.2rem 0;
  font-size: 0.82rem;
}
.cost-breakdown__amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.cost-breakdown__coffee {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
}
.cost-breakdown__coffee:hover {
  background: var(--accent-dark);
}

/* --- Rules page -------------------------------------------------------- */
.rules h2 {
  margin-top: 1.75rem;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 0.25rem;
}
.rules section p {
  max-width: 65ch;
}

.rules__awards {
  display: grid;
  gap: 0.6rem;
  margin: 1.25rem 0;
}
.award {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}
.award__points {
  flex: 0 0 auto;
  min-width: 3.4rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.award--4 { border-left-color: var(--medal-gold); }
.award--3 { border-left-color: var(--ok); }
.award--2 { border-left-color: var(--accent); }
.award--0 { border-left-color: var(--locked); }

.badge--pts {
  font-weight: 700;
  color: #fff;
  border: none;
}
.award--4.badge--pts { background: var(--medal-gold); }
.award--3.badge--pts { background: var(--ok); }
.award--2.badge--pts { background: var(--accent); }
.award--0.badge--pts { background: var(--locked); }

.examples { display: block; }
.example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow-sm);
}
.example__lines {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.example__line { font-size: 0.92rem; }
.example__verdict {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.example__why {
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 32ch;
}

/* --- Stats page (EPIC-21) --------------------------------------------- */
.stats__head { margin-bottom: 0.75rem; }
.stats__intro { color: var(--muted); max-width: 46rem; }

.stats-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stats-filter__label {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.stats-filter__options { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.stats-filter__reset { margin-left: auto; }
.stats-filter__hint { flex-basis: 100%; margin: 0; color: var(--muted); font-size: 0.82rem; }

.round-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.round-chip input { margin: 0; accent-color: var(--accent); }
.round-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.stats__empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.stats-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.stats-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}
.stats-table th,
.stats-table td {
  padding: 0.5rem 0.7rem;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
/* The stat-name column stays put while the player columns scroll. */
.stats-table__rowhead {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  font-weight: 600;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.stats-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--brand);
  color: #fff;
  font-size: 0.8rem;
}
.stats-table thead th.stats-table__rowhead {
  z-index: 3;
  background: var(--brand);
  color: #fff;
}
.stats-table__player { font-weight: 700; }
.stats-table__section th {
  text-align: left;
  background: var(--surface-2);
  color: var(--brand);
  position: sticky;
  left: 0;
  padding: 0;
}
/* The whole section header is a collapse toggle. */
.stats-section__toggle {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
}
.stats-section__toggle:hover { background: rgba(20, 37, 76, 0.06); }
.stats-section__chevron {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform 0.15s ease;
}
/* Collapsed: hide the stat rows and point the chevron right. */
.stats-section.is-collapsed .stats-section__row { display: none; }
.stats-section.is-collapsed .stats-section__chevron { transform: rotate(-90deg); }
.stats-table__cell.is-leader {
  background: rgba(227, 160, 8, 0.18);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(227, 160, 8, 0.45);
}

/* --- Small-screen tuning ---------------------------------------------- */
@media (max-width: 28rem) {
  main { padding: 0.85rem; }

  .stats-filter__actions { margin-left: 0; }
  .stats-table th,
  .stats-table td { padding: 0.45rem 0.55rem; font-size: 0.82rem; }

  /* Leave room below the (possibly two-row) sticky header. */
  .stage-nav { top: 92px; }

  /* Tighten the score row; long team names wrap instead of scrolling. */
  .fixture__score { gap: 0.35rem 0.4rem; }
  .score { width: 2.85rem; }
  .team { gap: 0.35rem; }

  .site-nav a { font-size: 0.86rem; padding: 0.35rem 0.5rem; }

  /* Five standings columns (rank, name, exact, scored, points) must fit a
     narrow phone with no horizontal scroll: trim cell padding and the rank
     gutter so the numeric columns stay on one line. */
  .standings th,
  .standings td { padding: 0.55rem 0.4rem; }
  .standings__rank { width: 1.9rem; }
  .standings thead th { font-size: 0.7rem; letter-spacing: 0.02em; }

  /* Reveal panel: trim padding so the per-player table fits a narrow phone
     with no horizontal scroll. The pens flag is decorative; hide its long
     text label and keep the flag chip + scoreline + points on one line. */
  .reveal__summary { padding: 0.5rem 0.7rem; }
  .reveal__table th,
  .reveal__table td { padding: 0.4rem 0.5rem; }
  .reveal__pens-name { display: none; }

  /* Award popover on phones: keep it inside the viewport (no horizontal scroll).
     Table names sit near the left, so anchor there; the vertically-stacked
     podium names are centred, so centre the popover under them. */
  /* The popover's containing block is the narrow .player span, so a shrink-to-fit
     width collapses to min-width and long blurbs wrap one-to-two words per line.
     width: max-content sizes to the content's natural width instead, then the
     max-width clamps it to (nearly) the viewport; awards.js shifts it back
     on-screen when a left/right-edge name would otherwise overflow (BUG-4). */
  .player__popover {
    min-width: 10.5rem;
    width: max-content;
    max-width: calc(100vw - 1rem);
  }
  .podium .player__popover {
    left: 50%;
    transform: translateX(calc(-50% + var(--popover-shift, 0px)));
  }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* --- Tournament-winner modal (EPIC-24) -------------------------------- */
/* The "View final results" re-open button sits in the hero; a light gold pill
   echoing the host-nation accent without competing with the brand. */
.winner-reopen {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand-ink);
  background: var(--gold);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.winner-reopen:hover { background: #f0ad1c; }
.winner-reopen:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* Full-screen overlay; [hidden] keeps it out of the layout/a11y tree until JS
   (or the reopen button) shows it. */
.winner-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.winner-modal[hidden] { display: none; }
body.winner-modal-open { overflow: hidden; }

.winner-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 24, 48, 0.62);
}

.winner-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 28rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem 1.5rem;
  text-align: center;
}
/* Gold host-nation accent across the top of the card. */
.winner-modal__dialog::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red) 0 33%, var(--gold) 33% 66%, var(--green) 66%);
  border-radius: var(--radius) var(--radius) 0 0;
}

.winner-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.winner-modal__close:hover { color: var(--text); background: var(--surface-2); }

.winner-modal__trophy {
  margin: 0.25rem 0 0.4rem;
  font-size: 3rem;
  line-height: 1;
}
.winner-modal__title {
  margin: 0 0 0.5rem;
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  color: var(--brand);
}
.winner-modal__summary {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.winner-modal__stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
  margin: 0 0 1.5rem;
}
.winner-modal__stat {
  margin: 0;
  padding: 0.6rem 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.winner-modal__stat-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.winner-modal__stat-value {
  margin: 0.15rem 0 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
}

/* Points-over-time chart (EPIC-27): the champion's line bold, the pack dimmed. */
.winner-modal__chart {
  margin: 0 0 1.5rem;
  padding: 0.6rem 0.65rem 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.winner-modal__chart-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.winner-modal__chart-box {
  position: relative;
  height: 180px;
}

.winner-modal__done {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.winner-modal__done:hover { background: var(--accent-dark); }

@media (max-width: 28rem) {
  .winner-modal__stats { grid-template-columns: 1fr; }
  .winner-modal__dialog { padding: 1.5rem 1.1rem 1.25rem; }
  .winner-modal__chart-box { height: 150px; }
}

/* --- "Latest update" changelog modal ---------------------------------- */
/* Reuses the winner-modal overlay/dialog language (backdrop, card, close, gold
   accent bar) but left-aligned with grouped change lists rather than centred
   stats. [hidden] keeps it out of the layout/a11y tree until JS shows it. */
.changelog-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.changelog-modal[hidden] { display: none; }
body.changelog-modal-open { overflow: hidden; }

.changelog-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 24, 48, 0.62);
}

.changelog-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 30rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem 1.5rem;
}
/* Gold host-nation accent across the top of the card. */
.changelog-modal__dialog::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red) 0 33%, var(--gold) 33% 66%, var(--green) 66%);
  border-radius: var(--radius) var(--radius) 0 0;
}

.changelog-modal__close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.changelog-modal__close:hover { color: var(--text); background: var(--surface-2); }

.changelog-modal__eyebrow {
  margin: 0.25rem 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.changelog-modal__title {
  margin: 0 0 0.2rem;
  font-size: clamp(1.3rem, 4.5vw, 1.6rem);
  color: var(--brand);
}
.changelog-modal__date {
  margin: 0 0 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.changelog-modal__section { margin: 0 0 1.25rem; }
.changelog-modal__heading {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.changelog-modal__list {
  margin: 0;
  padding-left: 1.1rem;
}
.changelog-modal__item {
  margin: 0 0 0.4rem;
  line-height: 1.4;
  color: var(--text);
}
.changelog-modal__item:last-child { margin-bottom: 0; }

.changelog-modal__done {
  width: 100%;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.changelog-modal__done:hover { background: var(--accent-dark); }

@media (max-width: 28rem) {
  .changelog-modal__dialog { padding: 1.5rem 1.1rem 1.25rem; }
}

/* --- Site stats page (EPIC-26) ---------------------------------------- */
.site-stats__intro {
  max-width: 60ch;
  color: var(--muted);
  margin-top: 0.35rem;
}
.site-stats__empty {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}
.site-stats__section-title {
  margin: 1.75rem 0 0.75rem;
  font-size: 1.15rem;
}

/* Headline tiles. */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
  margin-top: 1rem;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.85rem 1rem;
  text-align: center;
}
.stat-tile__value {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand);
  line-height: 1.1;
}
.stat-tile__label {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Chart cards. Each canvas lives in a fixed-height box so Chart.js can size
   responsively without collapsing or growing unbounded. */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
}
.chart-card {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 0.85rem 0.95rem 1rem;
}
.chart-card--wide { grid-column: 1 / -1; }
.chart-card figcaption {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}
.chart-box {
  position: relative;
  height: 230px;
}
.chart-summary {
  margin: 0.6rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Per-page performance / views-per-page tables. */
.site-stats__table-wrap {
  margin-top: 0.9rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.site-stats__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.site-stats__caption {
  text-align: left;
  font-weight: 700;
  padding: 0.7rem 0.8rem 0;
}
.site-stats__table th,
.site-stats__table td {
  padding: 0.55rem 0.8rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.site-stats__table thead th { color: var(--muted); font-size: 0.78rem; }
/* The first column holds page names (left-aligned th[scope="row"]); align its
   header left to match, while numeric headers stay right over their figures. */
.site-stats__table thead th:first-child { text-align: left; }
.site-stats__table th[scope="row"] { text-align: left; font-weight: 600; }
.site-stats__table tbody tr:last-child td,
.site-stats__table tbody tr:last-child th { border-bottom: 0; }

@media (max-width: 28rem) {
  .stat-tiles { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat-tile__value { font-size: 1.25rem; }
  .chart-grid { grid-template-columns: 1fr; gap: 0.7rem; }
  .chart-box { height: 200px; }
  .site-stats__table th,
  .site-stats__table td { padding: 0.45rem 0.55rem; font-size: 0.82rem; }
}

/* --- Player stats: points-over-time chart (EPIC-27) ------------------- */
/* Split the page into two self-describing blocks (graph, then table) so the
   round filter reads as belonging to the table alone. */
.stats-section-block { margin-top: 1.75rem; }
.stats-section-block + .stats-section-block {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.stats-section-block__title { margin: 0 0 0.35rem; font-size: 1.2rem; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.progression { margin: 1.25rem 0 0.5rem; }
.progression__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.progression__title { font-weight: 700; font-size: 0.95rem; }

/* Segmented control for the X-axis units (match number / date). */
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg, var(--surface));
  padding: 2px;
}
.seg__btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}
.seg__btn.is-active {
  background: var(--accent);
  color: #fff;
}

/* Clickable player legend; tapping a chip bolds that player's line. */
.progression__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text, inherit);
  font: inherit;
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
}
.legend-chip__dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.legend-chip.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  font-weight: 700;
}

@media (max-width: 28rem) {
  .progression__head { flex-direction: column; align-items: flex-start; }
}
