/* ============ Local fonts ============ */
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 200 900; /* variable font, single file covers all weights */
  font-display: swap;
  src: url('../fonts/unbounded-var.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/barlow-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/barlow-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/barlow-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Barlow';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/barlow-700.woff2') format('woff2');
}

html { scrollbar-gutter: stable; }

body {
  background-color: var(--bg);
  color: var(--ink);
  font-family: 'Barlow', sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Stadium floodlight glow backdrop */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 420px at 50% -120px, rgb(var(--pitch-rgb) / 0.16), transparent 70%),
    radial-gradient(700px 500px at 110% 15%, rgb(var(--gold-rgb) / 0.05), transparent 65%),
    radial-gradient(700px 500px at -10% 25%, rgb(var(--pitch-rgb) / 0.05), transparent 65%);
}

/* Film grain overlay */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

main, header { position: relative; z-index: 2; }

.font-display { font-family: 'Unbounded', sans-serif; }
.tnum { font-variant-numeric: tabular-nums; }

/* ============ Tabs ============ */
.tab-btn {
  position: relative;
  transition: color 0.25s ease;
}
.tab-btn[aria-selected="true"] { color: var(--ink); }
.tab-btn[aria-selected="false"] { color: var(--ink-dim); }
.tab-btn[aria-selected="false"]:hover { color: var(--ink); }
.tab-btn::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--pitch);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.tab-btn[aria-selected="true"]::after { transform: scaleX(1); }

/* ============ Match cards ============ */
.match-card {
  background: var(--card);
  border: 1px solid var(--line);
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
  display: grid;
  align-items: center;
  column-gap: 1rem;
  row-gap: 0.5rem;
  /* Mobile: teams stacked on the left, kickoff/score block fills the right,
     venue + actions span the full width underneath */
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "team1 time"
    "team2 time"
    "meta  meta";
}
@media (min-width: 640px) {
  .match-card {
    column-gap: 1rem;
    row-gap: 0.625rem;
    grid-template-columns: 44px 1fr auto 1fr 200px;
    grid-template-areas: "grp team1 time team2 meta";
  }
}
.mc-grp { grid-area: grp; }
.mc-team1 { grid-area: team1; }
.mc-time { grid-area: time; }
.mc-team2 { grid-area: team2; }
.mc-meta { grid-area: meta; }
.match-card:hover {
  border-color: rgb(var(--pitch-rgb) / 0.35);
  background: rgb(var(--neutral-rgb) / 0.055);
  transform: translateY(-2px);
}
.match-card.is-past { opacity: 0.45; }
.match-card.is-past:hover { opacity: 0.8; }
.match-card.is-next {
  border-color: rgb(var(--pitch-rgb) / 0.5);
  box-shadow: 0 0 32px rgb(var(--pitch-rgb) / 0.1), inset 0 0 24px rgb(var(--pitch-rgb) / 0.04);
}
.match-card.is-live {
  border-color: rgb(var(--gold-rgb) / 0.55);
  box-shadow: 0 0 32px rgb(var(--gold-rgb) / 0.12), inset 0 0 24px rgb(var(--gold-rgb) / 0.05);
}
.match-card.is-live:hover { border-color: rgb(var(--gold-rgb) / 0.8); }

.flag {
  width: 30px;
  height: 21px;
  object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  outline: 1px solid rgba(255, 255, 255, 0.12);
  outline-offset: -1px;
}
.flag-sm {
  width: 16px;
  height: 11px;
  object-fit: cover;
  border-radius: 2px;
  outline: 1px solid rgba(255, 255, 255, 0.12);
  outline-offset: -1px;
}

/* Settings gear button + popup */
.icon-btn {
  border: 1px solid var(--line);
  color: var(--ink-dim);
  transition: all 0.2s ease;
}
.icon-btn:hover,
.icon-btn[aria-expanded="true"],
.icon-btn.is-on {
  border-color: rgb(var(--pitch-rgb) / 0.45);
  color: var(--pitch);
}

/* "Favorites only" disabled until at least one team is followed */
.fav-only-label.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
/* Theme picker swatches */
.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.theme-swatch:hover { transform: scale(1.08); }
/* Selected: a gap (border in popup colour) + an accent ring + slight lift */
.theme-swatch.is-active {
  border-color: var(--bg-soft);
  box-shadow: 0 0 0 2px var(--pitch);
  transform: scale(1.12);
}
.theme-swatch > span { width: 10px; height: 10px; border-radius: 50%; }

.settings-popup {
  background: var(--bg-soft);
  border: 1px solid rgb(var(--neutral-rgb) / 0.12);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55);
  animation: rise-in 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Clickable team name in a card */
.team-link { cursor: pointer; }
.team-link:hover .tname { color: var(--pitch); }

/* Followed-team chips */
.fav-chip {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: border-color 0.2s ease, background 0.2s ease;
}
.fav-chip:hover { border-color: rgb(var(--pitch-rgb) / 0.4); }
.fav-chip.is-active {
  border-color: rgb(var(--gold-rgb) / 0.6);
  background: rgb(var(--gold-rgb) / 0.08);
}
.fav-chip-x { color: var(--ink-dim); transition: all 0.15s ease; }
.fav-chip-x:hover { color: var(--gold); background: rgb(var(--gold-rgb) / 0.15); }

/* Follow / team-calendar action buttons */
.action-btn {
  border: 1px solid var(--line);
  color: var(--ink-dim);
  transition: all 0.2s ease;
}
.action-btn:hover { border-color: var(--gold); color: var(--gold); }
.action-btn.is-on {
  border-color: rgb(var(--gold-rgb) / 0.5);
  background: rgb(var(--gold-rgb) / 0.1);
  color: var(--gold);
}

/* Bell button states */
.bell-btn {
  border: 1px solid var(--line);
  color: var(--ink-dim);
  transition: all 0.2s ease;
}
.bell-btn:hover { border-color: var(--gold); color: var(--gold); }
.bell-btn.is-on {
  border-color: var(--gold);
  background: rgb(var(--gold-rgb) / 0.12);
  color: var(--gold);
}
.ics-btn {
  border: 1px solid var(--line);
  color: var(--ink-dim);
  transition: all 0.2s ease;
}
.ics-btn:hover { border-color: var(--pitch); color: var(--pitch); }

/* Highlights search link (replaces the bell once a match has kicked off) */
.hl-btn {
  border: 1px solid var(--line);
  color: var(--ink-dim);
  transition: all 0.2s ease;
}
.hl-btn:hover { border-color: var(--pitch); color: var(--pitch); }

/* Live label breathing */
@keyframes live-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.live-pulse { animation: live-breathe 2s ease-in-out infinite; }

/* Projection marker (🔮): the emoji is dark, so brighten it and add a soft halo
   so it stands out against the dark card background */
.proj-icon {
  display: inline-block;
  font-size: 1.05em;
  filter: brightness(1.45) saturate(1.15) drop-shadow(0 0 3px rgba(255, 255, 255, 0.4));
}

/* NEXT pulse dot */
@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 0 rgb(var(--pitch-rgb) / 0.55); }
  60% { box-shadow: 0 0 0 7px rgb(var(--pitch-rgb) / 0); }
}
.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pitch);
  animation: pulse-dot 1.8s ease-out infinite;
}

/* ============ Staggered section reveal ============ */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal {
  opacity: 0;
  animation: rise-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ============ UTC toggle switch ============ */
.switch {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: rgb(var(--neutral-rgb) / 0.12);
  transition: background 0.25s ease;
  flex: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2.5px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink-dim);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), background 0.25s ease;
}
input:checked + .switch { background: var(--pitch-dim); }
input:checked + .switch::after {
  transform: translateX(16px);
  background: var(--pitch);
}
input:focus-visible + .switch { outline: 2px solid var(--pitch); outline-offset: 2px; }

/* ============ Filter input ============ */
.filter-input {
  background: var(--card);
  border: 1px solid var(--line);
  transition: border-color 0.2s ease;
}
.filter-input:focus {
  outline: none;
  border-color: rgb(var(--pitch-rgb) / 0.5);
}
.filter-input::placeholder { color: var(--ink-dim); opacity: 0.7; }

/* ============ Groups tables ============ */
.group-card {
  background: var(--card);
  border: 1px solid var(--line);
  transition: border-color 0.25s ease;
}
.group-card:hover { border-color: rgb(var(--pitch-rgb) / 0.25); }
/* Table zones from the season data (a zone's "tone", else its order in the stage):
   primary (pitch), secondary (slate; the bar is lightened vs --third to offset the
   perceptual darkening of a thin line sitting on the lighter card background), tertiary
   (gold), down (relegation, a fixed red in every theme). "none" (e.g. "eliminated"):
   no bar, the absence is the signal. */
.standings tr.zone-primary td:first-child { box-shadow: inset 2px 0 0 var(--pitch); }
.standings tr.zone-secondary td:first-child { box-shadow: inset 2px 0 0 var(--third-bar); }
.standings tr.zone-tertiary td:first-child { box-shadow: inset 2px 0 0 var(--zone-tertiary); }
.standings tr.zone-down td:first-child { box-shadow: inset 2px 0 0 var(--zone-down); }
.zone-swatch-primary { background: var(--pitch); }
.zone-swatch-secondary { background: var(--third); }
.zone-swatch-tertiary { background: var(--zone-tertiary); }
.zone-swatch-down { background: var(--zone-down); }

.standings { table-layout: fixed; }
.standings tbody tr { border-top: 1px solid var(--line); }
.standings td, .standings th { padding: 6px 4px; }
/* Narrow, fixed stat columns so the team column takes the rest and truncates
   long names — keeps each group table inside the card (no horizontal scroll) */
.standings th:nth-child(1), .standings td:nth-child(1) { width: 1.4rem; }   /* # */
.standings th:nth-child(3), .standings td:nth-child(3),
.standings th:nth-child(4), .standings td:nth-child(4),
.standings th:nth-child(5), .standings td:nth-child(5),
.standings th:nth-child(6), .standings td:nth-child(6) { width: 1.55rem; }  /* P W D L */
.standings th:nth-child(7), .standings td:nth-child(7) { width: 2.8rem; }   /* GF:GA (hidden on mobile) */
.standings th:nth-child(8), .standings td:nth-child(8) { width: 2.1rem; }   /* GD */
.standings th:nth-child(9), .standings td:nth-child(9) { width: 1.9rem; }   /* Pts */

/* ============ Toasts ============ */
.toast {
  animation: rise-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  background: var(--bg-soft);
  color: var(--ink);
  border: 1px solid rgb(var(--pitch-rgb) / 0.4);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.55);
}
.toast.toast-out { transition: opacity 0.4s ease, transform 0.4s ease; opacity: 0; transform: translateY(8px); }

/* Back-to-top quick link: hidden until the page is scrolled down */
.scroll-top-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 40;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink-dim);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.15s ease, border-color 0.15s ease;
}
.scroll-top-btn.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.scroll-top-btn:hover { color: var(--pitch); border-color: rgb(var(--pitch-rgb) / 0.45); }

/* Tab panel transition */
.panel-enter { animation: rise-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards; }

::selection { background: rgb(var(--pitch-rgb) / 0.3); }

/* ===== Knockout bracket ===== */
.bracket-scroll {
  position: relative;
  overflow: hidden;
  height: 56vh;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgb(var(--neutral-rgb) / 0.02);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.bracket-scroll.is-grabbing { cursor: grabbing; }
.bracket-zoom { transform-origin: 0 0; will-change: transform; }

/* Floating map-style zoom controls */
/* Containing block of the zoom control: it sits inside the bottom-right corner of the
   bracket box. (The old app got this only as a side effect of the tab-switch animation's
   transform, so a page opened directly on the bracket tab would misplace it.) */
#panel-bracket { position: relative; }
.bracket-zoom-ctl {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
}
.bracket-zoom-ctl button {
  width: 38px;
  height: 36px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink-dim);
  background: transparent;
  transition: color 0.15s ease, background 0.15s ease;
}
.bracket-zoom-ctl button:hover { color: var(--ink); background: rgb(var(--neutral-rgb) / 0.07); }
.bracket-zoom-ctl button + button { border-top: 1px solid var(--line); }
.bracket-zoom-ctl [data-zoom="fit"] { font-size: 14px; }

.bracket {
  --col-w: 150px;
  --gx: 36px;
  --bh: 644px;
  --bk-head: 30px;
  --bk-line: rgb(var(--neutral-rgb) / 0.22);
  display: flex;
  align-items: stretch;
  gap: var(--gx);
  width: max-content;
  margin: 0;
  transform-origin: top left;
}

.side { display: flex; gap: var(--gx); }
.bk-col,
.bk-final-col {
  display: flex;
  flex-direction: column;
  width: var(--col-w);
  height: var(--bh);
}
.bk-final-col { position: relative; }

.bk-col-label {
  flex: none;
  height: var(--bk-head);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
}

.bn {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
}
.bn-third {
  flex: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
}
.bk-third-label {
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 5px;
}

.bx {
  position: relative;
  z-index: 1;
  width: 100%;
  background: var(--card);
  border: 1px solid rgb(var(--neutral-rgb) / 0.1);
  border-radius: 10px;
  padding: 6px 8px;
}
.bx.is-live { border-color: rgb(var(--gold-rgb) / 0.5); }
.bn-final .bx {
  border-color: rgb(var(--pitch-rgb) / 0.45);
  background: rgb(var(--pitch-rgb) / 0.06);
}

.bk-rows { display: flex; flex-direction: column; gap: 2px; }
.bk-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 2px;
  border-radius: 5px;
}
.bk-row[data-team] { cursor: pointer; }
.bk-row[data-team]:hover { background: rgb(var(--pitch-rgb) / 0.08); }

.bk-flag {
  width: 19px;
  height: 13px;
  object-fit: cover;
  border-radius: 2px;
  flex: none;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.15);
}
.bk-flag-tbd { background: rgb(var(--neutral-rgb) / 0.08); box-shadow: none; }

.bk-name {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bk-name.bk-tbd {
  font-style: italic;
  font-weight: 400;
  font-size: 11.5px;
  color: var(--ink-dim);
}
.bn-final .bk-name { font-size: 13.5px; }
.bk-proj { flex: none; font-size: 10px; }

.bk-score {
  flex: none;
  min-width: 12px;
  text-align: right;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.bk-row.is-won .bk-name,
.bk-row.is-won .bk-score { color: var(--pitch); font-weight: 800; }
.bk-row.is-lost { opacity: 0.45; }

.bk-foot { display: flex; justify-content: flex-end; margin-top: 3px; }
.bk-status {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.bk-status.bk-live { color: var(--gold); font-weight: 700; }

/* Connector lines, drawn in the gutters between columns.
   Outgoing stub on each card; incoming vertical+horizontal on receiving matches. */
.side-left .bx::after,
.side-right .bx::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(var(--gx) / 2);
  height: 2px;
  background: var(--bk-line);
}
.side-left .bx::after { left: 100%; }
.side-right .bx::after { right: 100%; }

.bn.recv::before,
.bn.recv::after { content: ''; position: absolute; background: var(--bk-line); }
.side-left .bn.recv::before { top: 25%; height: 50%; width: 2px; left: calc(var(--gx) / -2); }
.side-left .bn.recv::after { top: 50%; height: 2px; width: calc(var(--gx) / 2); left: calc(var(--gx) / -2); }
.side-right .bn.recv::before { top: 25%; height: 50%; width: 2px; right: calc(var(--gx) / -2); }
.side-right .bn.recv::after { top: 50%; height: 2px; width: calc(var(--gx) / 2); right: calc(var(--gx) / -2); }

/* The final's two incoming stubs reach toward each semi-final */
.bn-final::before,
.bn-final::after {
  content: '';
  position: absolute;
  top: 50%;
  height: 2px;
  width: calc(var(--gx) / 2);
  background: var(--bk-line);
}
.bn-final::before { left: calc(var(--gx) / -2); }
.bn-final::after { right: calc(var(--gx) / -2); }

/* ================= Home page (step 4): ported from the approved prototype ================= */
/* Header: brand + competition switcher + display settings */
.site-header { padding-top: 1.75rem; padding-bottom: 1rem; z-index: 20; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.brand { display: inline-flex; flex-direction: column; flex: none; }
.brand-tagline { font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 0.35rem; }
.brand-name {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}
.brand-name .dot { color: var(--pitch); }
@media (min-width: 640px) { .brand-name { font-size: 1.75rem; } }
/* The tagline wraps awkwardly next to the switcher on phones */
@media (max-width: 520px) { .brand-tagline { display: none; } }
@media (max-width: 400px) { .brand-name { font-size: 1.15rem; } }
/* The brand never shrinks; the switcher label truncates instead */
.header-actions { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
/* Competition pages: the same bar, slim, so the competition header and matches stay high */
.site-header-compact { padding-top: 0.9rem; padding-bottom: 0; }
.site-header-compact .brand-tagline { display: none; }
.site-header-compact .brand-name { font-size: 1.05rem; }
.site-header-compact .switcher-btn { height: 36px; font-size: 0.85rem; }
@media (min-width: 640px) { .site-header-compact .brand-name { font-size: 1.2rem; } }

.label { font-size: 10px; letter-spacing: 0.25em; text-transform: uppercase; color: var(--ink-dim); font-weight: 400; }
.theme-name { text-transform: none; letter-spacing: normal; color: var(--pitch); font-size: 12px; margin-left: 4px; }

.switcher { position: relative; min-width: 0; }
.switcher-btn {
  height: 40px;
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0 0.75rem 0 0.85rem;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
  background: rgb(var(--neutral-rgb) / 0.03);
  font-weight: 600;
  font-size: 0.9rem;
  transition: border-color 0.2s ease;
  max-width: 100%;
}
.switcher-btn:hover, .switcher-btn[aria-expanded="true"] { border-color: rgb(var(--pitch-rgb) / 0.45); }
.switcher-btn .sw-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switcher-btn .chev { flex: none; color: var(--ink-dim); transition: transform 0.2s ease; }
.switcher-btn[aria-expanded="true"] .chev { transform: rotate(180deg); color: var(--pitch); }
.switch-popup {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  z-index: 30;
  width: 19rem;
  padding: 0.5rem;
  border-radius: 0.75rem;
}
/* On phones the switcher becomes a full-width sheet under the header */
@media (max-width: 520px) {
  .switcher { position: static; }
  .switch-popup { left: 1rem; right: 1rem; width: auto; top: calc(100% - 0.25rem); }
}
.switch-item {
  display: flex; align-items: center; gap: 0.7rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  border-radius: 0.5rem;
  transition: background 0.15s ease;
}
.switch-item:hover, .switch-item:focus-visible { background: rgb(var(--pitch-rgb) / 0.08); outline: none; }
.switch-item[aria-current="page"] { background: rgb(var(--pitch-rgb) / 0.1); }
.switch-item .si-text { flex: 1; min-width: 0; }
.switch-item .si-name { font-weight: 600; font-size: 0.92rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch-item .si-path { font-size: 11.5px; color: var(--ink-dim); }
.switch-sep { height: 1px; background: var(--line); margin: 0.35rem 0.4rem; }

/* Competition monogram: text on the competition's accent (config theme.accentRgb),
   deliberately not an official logo */
.mono {
  --c: var(--pitch-rgb);
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 10.5px;
  letter-spacing: 0.02em;
  /* Blend the hue toward the theme ink so light hues stay readable on light themes */
  color: color-mix(in srgb, rgb(var(--c)) 72%, var(--ink));
  background: rgb(var(--c) / 0.14);
  border: 1px solid rgb(var(--c) / 0.35);
}
.mono-lg { width: 46px; height: 46px; font-size: 13px; border-radius: 12px; }
.mono-home { --c: var(--ink-dim-rgb); font-size: 15px; }
.mono-lg.mono-home { font-size: 20px; }

/* Hero */
.hero { padding: 1.5rem 0 1.25rem; }
.hero h1 {
  font-family: 'Unbounded', sans-serif;
  font-weight: 900;
  font-size: clamp(1.9rem, 7vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.01em;
  margin-top: 0.6rem;
}
.hero h1 .accent { color: var(--pitch); }
.hero .sub { color: var(--ink-dim); margin-top: 0.85rem; max-width: 34rem; line-height: 1.55; }

/* No public competition yet */
.home-empty {
  display: flex; align-items: center; gap: 1rem;
  margin-top: 0.75rem;
  padding: 1.1rem 1.15rem;
  border-radius: 0.9rem;
  background: var(--card);
  border: 1px dashed rgb(var(--neutral-rgb) / 0.2);
  animation: rise-in 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.home-empty-title { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1rem; line-height: 1.25; }
.home-empty-text { color: var(--ink-dim); margin-top: 0.3rem; line-height: 1.5; }

/* Continue where you left off */
.continue {
  margin: 0.5rem 0 1.75rem;
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  background: rgb(var(--pitch-rgb) / 0.06);
  border: 1px solid rgb(var(--pitch-rgb) / 0.35);
  box-shadow: 0 0 32px rgb(var(--pitch-rgb) / 0.08);
  animation: rise-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
.continue .c-text { flex: 1; min-width: 0; }
.continue .c-label { font-size: 9.5px; margin-bottom: 0.2rem; }
.continue .c-name { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue .c-meta { font-size: 0.85rem; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-primary {
  flex: none;
  display: inline-flex; align-items: center; gap: 0.35rem;
  height: 36px; padding: 0 0.9rem;
  border-radius: 0.5rem;
  font-family: 'Unbounded', sans-serif;
  font-weight: 700; font-size: 11.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--bg);
  background: var(--pitch);
  transition: transform 0.2s ease, filter 0.2s ease;
}
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-ghost-x {
  flex: none;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-dim);
  transition: all 0.15s ease;
}
.btn-ghost-x:hover { color: var(--gold); background: rgb(var(--gold-rgb) / 0.12); }
@media (max-width: 420px) {
  .continue { flex-wrap: wrap; }
  .continue .c-text { flex-basis: calc(100% - 46px - 28px - 1.8rem); }
  .continue .btn-primary { order: 3; width: 100%; justify-content: center; }
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.label-live { color: var(--gold); letter-spacing: 0.12em; }

/* My teams (3.7) */
.my-teams { margin-bottom: 2rem; }
.my-teams-body {
  padding: 0.35rem 1rem;
  border-radius: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
}
.my-teams-hint { color: var(--ink-dim); font-size: 0.92rem; line-height: 1.5; padding: 0.55rem 0; }
.mt-day + .mt-day { border-top: 1px solid var(--line); }
.mt-day-label { font-size: 9.5px; padding-top: 0.7rem; }
.mt-list { list-style: none; }

/* Match row (My teams) */
.mrow {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.mt-list li:last-child .mrow { border-bottom: 0; }
.mrow:hover .teams { color: var(--pitch); }
.mrow .teams { min-width: 0; font-size: 0.9rem; line-height: 1.35; transition: color 0.15s ease; }
.mrow .team { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow .team.is-followed { color: var(--pitch); font-weight: 600; }
.mrow .mside { text-align: right; font-size: 0.85rem; }
.mrow .score { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 0.85rem; }
.mrow .when { font-weight: 600; color: var(--accent3); }
.mrow .sub { display: block; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); margin-top: 0.1rem; }
.mrow.is-live .score, .mrow.is-live .sub { color: var(--gold); }

/* Competition cards */
.comp-grid { display: grid; grid-template-columns: 1fr; gap: 0.9rem; }
@media (min-width: 640px) { .comp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .comp-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.comp-card {
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0;
  padding: 1rem;
  border-radius: 0.9rem;
  background: var(--card);
  border: 1px solid var(--line);
  transition: border-color 0.25s ease, background 0.25s ease, transform 0.25s ease;
  opacity: 0;
  animation: rise-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.comp-card:hover {
  border-color: rgb(var(--pitch-rgb) / 0.35);
  background: rgb(var(--neutral-rgb) / 0.055);
  transform: translateY(-2px);
}
.comp-card.is-live {
  border-color: rgb(var(--gold-rgb) / 0.55);
  box-shadow: 0 0 32px rgb(var(--gold-rgb) / 0.12), inset 0 0 24px rgb(var(--gold-rgb) / 0.05);
}
.comp-card.is-live:hover { border-color: rgb(var(--gold-rgb) / 0.8); }
/* The whole card is clickable through a stretched link; the tab links sit above it */
.comp-card .card-link::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.comp-card .card-link:focus-visible { outline: none; }
.comp-card:has(.card-link:focus-visible) { outline: 2px solid var(--pitch); outline-offset: 2px; }
.cc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.cc-title { min-width: 0; margin-top: 0.8rem; }
.cc-name { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 0.98rem; line-height: 1.2; }
.cc-path { font-size: 11.5px; color: var(--ink-dim); margin-top: 0.2rem; }
.cc-stage { margin-top: 0.85rem; font-size: 0.9rem; color: var(--ink-dim); line-height: 1.4; }
.cc-stage strong { color: var(--ink); font-weight: 600; }
.cc-stage .cc-match { display: block; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.comp-card.is-live .cc-stage { color: var(--gold); font-weight: 600; }
.cc-foot { margin-top: auto; padding-top: 0.9rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.cc-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; min-width: 0; }
.cc-tabs a {
  position: relative; z-index: 1;
  font-size: 11.5px; font-weight: 600;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink-dim);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.cc-tabs a:hover { color: var(--pitch); border-color: rgb(var(--pitch-rgb) / 0.45); }
.cc-open { flex: none; font-size: 0.85rem; font-weight: 600; color: var(--pitch); display: inline-flex; align-items: center; gap: 0.3rem; }

/* Status pill */
.status {
  flex: none;
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid var(--line);
  color: var(--ink-dim);
}
.status-sm { font-size: 8.5px; padding: 0.15rem 0.45rem; }
.status .sdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-progress { color: var(--pitch); border-color: rgb(var(--pitch-rgb) / 0.4); background: rgb(var(--pitch-rgb) / 0.08); }
.status-upcoming { color: var(--accent3); border-color: rgb(var(--accent3-rgb) / 0.35); }
.status.status-live { color: var(--gold); border-color: rgb(var(--gold-rgb) / 0.5); background: rgb(var(--gold-rgb) / 0.1); }
.status-live .sdot { animation: live-breathe 2s ease-in-out infinite; }

/* Support (Buy Me a Coffee) */
.home-cta { margin-top: 3.5rem; text-align: center; }
.centerline { display: flex; align-items: center; width: min(20rem, 70vw); margin: 0 auto 2rem; }
.centerline::before, .centerline::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.centerline .circle { width: 34px; height: 34px; border: 1px solid rgb(var(--neutral-rgb) / 0.18); border-radius: 50%; flex: none; position: relative; }
.centerline .circle::after { content: ''; position: absolute; inset: 50% auto auto 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgb(var(--neutral-rgb) / 0.3); }
.cta-label { color: var(--ink); line-height: 1.6; margin-bottom: 1.1rem; }
.bmc { display: inline-block; transition: transform 0.2s ease; }
.bmc:hover { transform: translateY(-3px); }
.bmc img { height: 46px; width: auto; display: block; }

@media (prefers-reduced-motion: reduce) {
  .comp-card, .continue, .home-empty { animation: none; opacity: 1; }
}

/* ================= Step 6: league-knockout (UCL) ================= */
/* Competition accent from the config (theme.accentRgb, 3.3): header accent word and the
   active tab marker only; the global theme (3.8) keeps everything else. */
.comp-header .comp-accent { color: rgb(var(--comp-rgb, var(--pitch-rgb))); }
.comp-header .tab-btn::after { background: rgb(var(--comp-rgb, var(--pitch-rgb))); }

/* Club crests (D8, 5.3): shown small, never cropped or recoloured (object-fit: contain, no
   outline or shadow). Missing/disabled crest -> neutral badge with the short code. */
.crest { object-fit: contain; flex: none; }
.crest.flag { width: 26px; height: 26px; border-radius: 0; box-shadow: none; outline: none; }
.crest.flag-sm { width: 18px; height: 18px; border-radius: 0; outline: none; }
.crest.bk-flag { width: 16px; height: 16px; border-radius: 0; box-shadow: none; }
.crest-badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  background: rgb(var(--neutral-rgb) / 0.1);
  color: var(--ink-dim);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}
.crest-badge.flag { width: 26px; height: 26px; font-size: 8px; box-shadow: none; outline: none; }
.crest-badge.flag-sm { width: 18px; height: 18px; font-size: 6px; outline: none; }
.crest-badge.bk-flag { width: 16px; height: 16px; font-size: 5.5px; box-shadow: none; }

/* League-phase table: one wide card, 36 rows */
.league-card { grid-column: 1 / -1; }
.standings td.pos-level { color: var(--ink-dim); font-style: italic; }
.zone-swatch-none { background: transparent; box-shadow: inset 0 0 0 1px rgb(var(--neutral-rgb) / 0.3); }

/* Two-leg tie cells */
.bx-tie .bk-legs {
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bx-tie .bk-foot { justify-content: space-between; gap: 6px; }
.bk-cands { display: flex; gap: 2px; flex: none; }
.bk-cands .bk-flag { margin-left: -4px; }
.bk-cands .bk-flag:first-child { margin-left: 0; }

/* A node fed by one earlier node on the same row: straight connector (play-off -> R16) */
.bn.recv1::after { content: ''; position: absolute; top: 50%; height: 2px; width: calc(var(--gx) / 2); background: var(--bk-line); }
.side-left .bn.recv1::after { left: calc(var(--gx) / -2); }
.side-right .bn.recv1::after { right: calc(var(--gx) / -2); }

/* Live card hint: free-plan scores are delayed (D2, 5.1) */
.delayed-hint { font-size: 9px; letter-spacing: 0.08em; color: var(--ink-dim); text-transform: none; }

/* Footer notice (crest rules) */
.site-notice a { text-underline-offset: 2px; }
/* Tie cells carry two crests per projected side: slightly wider columns */
.bracket.bracket-ties { --col-w: 164px; }

/* Matchday selector (league format): a native select, so phones get their own picker.
   The arrow is drawn here because appearance:none removes the platform one; the option
   list takes the page colours. */
.md-select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%),
    linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}
.md-select:focus { outline: none; border-color: rgb(var(--pitch-rgb) / 0.5); }
.md-select option { background: var(--bg); color: var(--ink); }
.icon-btn:disabled { opacity: 0.35; cursor: default; pointer-events: none; }

/* ============ Followed teams (3.7, D18) ============
   Colour, not extra UI: one class "is-followed", styled from the theme's accent. Tint
   strength is a theme variable (themes.css: --followed-rgb, --followed-a). */
.match-card.is-followed,
.match-card.is-followed:hover {
  background:
    linear-gradient(90deg, rgb(var(--followed-rgb)) 0 3px, transparent 3px),
    rgb(var(--followed-rgb) / var(--followed-a));
}
.match-card.is-followed:hover { background-color: rgb(var(--followed-rgb) / calc(var(--followed-a) + 0.04)); }
.tname.is-followed,
.standings tr.is-followed .tname { color: var(--pitch); font-weight: 600; }
.standings tr.is-followed td { background: rgb(var(--followed-rgb) / var(--followed-a)); }
.bk-row.is-followed { background: rgb(var(--followed-rgb) / calc(var(--followed-a) + 0.04)); }
.bk-row.is-followed .bk-name { color: var(--pitch); }

/* Follow toggle next to a team name */
.fav-star {
  flex: none;
  display: inline-grid; place-items: center;
  min-width: 24px; min-height: 24px;
  margin: -4px 0;
  font-size: 13px; line-height: 1;
  color: var(--ink-dim);
  opacity: 0.5;
  border-radius: 6px;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.fav-star:hover, .fav-star:focus-visible { opacity: 1; color: var(--gold); background: rgb(var(--gold-rgb) / 0.1); outline: none; }
.fav-star.is-on { color: var(--gold); opacity: 1; }

/* Home: followed-team chips and the team search (3.7) */
.followed-teams { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.ft-chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.25rem 0.3rem 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem; font-weight: 600;
  background: rgb(var(--followed-rgb) / var(--followed-a));
  border: 1px solid rgb(var(--pitch-rgb) / 0.3);
}
.ft-x {
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 999px;
  color: var(--ink-dim); font-size: 15px; line-height: 1;
}
.ft-x:hover, .ft-x:focus-visible { color: var(--ink); background: rgb(var(--neutral-rgb) / 0.1); outline: none; }
.team-search { position: relative; margin-top: 0.75rem; }
.team-search .ts-icon { position: absolute; left: 0.8rem; top: 0.8rem; color: var(--ink-dim); pointer-events: none; }
.team-search input {
  width: 100%;
  padding: 0.6rem 0.9rem 0.6rem 2.2rem;
  border-radius: 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.92rem;
}
.team-search input::placeholder { color: var(--ink-dim); }
.team-search input:focus { outline: none; border-color: rgb(var(--pitch-rgb) / 0.5); }
.ts-results {
  list-style: none;
  margin-top: 0.4rem;
  padding: 0.25rem 0.75rem;
  border-radius: 0.75rem;
  background: var(--card);
  border: 1px solid var(--line);
}
.ts-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}
.ts-row:last-child { border-bottom: 0; }
.ts-name { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-row.is-followed .ts-name { color: var(--pitch); }
.ts-comps { display: flex; gap: 0.25rem; }
.ts-none { color: var(--ink-dim); font-size: 0.9rem; padding: 0.45rem 0; }
.ts-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 0.5rem;
  font-size: 0.8rem; font-weight: 600;
  border: 1px solid rgb(var(--pitch-rgb) / 0.4);
  color: var(--pitch);
  white-space: nowrap;
}
.ts-btn:hover, .ts-btn:focus-visible { background: rgb(var(--pitch-rgb) / 0.1); outline: none; }
.ts-btn.is-on { color: var(--gold); border-color: rgb(var(--gold-rgb) / 0.45); }
.mono-sm { width: 24px; height: 24px; font-size: 7.5px; border-radius: 6px; }
.mrow .team { display: flex; align-items: center; gap: 0.4rem; }
.mrow .team .tn { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
