*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f8fafc;
  --bg-card:     #ffffff;
  --bg-card2:    #f1f5f9;
  --border:      #e2e8f0;
  --accent:      #2563eb;
  --accent2:     #0891b2;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --text-dim:    #94a3b8;
  --good:        #16a34a;
  --good-bg:     #16a34a14;
  --live:        #dc2626;
  --radius:      14px;
  --radius-sm:   10px;
  --shadow:      0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.05);
  --shadow-lg:   0 8px 30px rgba(37,99,235,.12);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: radial-gradient(1200px 400px at 50% -120px, #2563eb14, transparent), var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1040px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) clamp(0.85rem, 4vw, 2rem) 3rem; }

/* Header */
.eyebrow { font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.35rem; }
h1 { font-size: clamp(2.1rem, 7vw, 3.4rem); font-weight: 900; letter-spacing: -0.04em; line-height: 1; margin-bottom: 0.55rem; }
h1 a { color: inherit; text-decoration: none; display: inline-flex; align-items: baseline; }
h1 .ball { height: 0.8em; width: auto; align-self: center; margin-right: 0.32em; flex-shrink: 0; }
h1 .yr { background: linear-gradient(100deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.subtitle { color: var(--text-muted); font-size: 1.02rem; max-width: 60ch; }

.status-bar { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.9rem; font-size: 0.82rem; color: var(--text-muted); background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.85rem; box-shadow: var(--shadow); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); display: inline-block; }
.dot.live { background: var(--live); animation: pulse 1.5s infinite; }
.dot.ok { background: var(--good); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #dc262688; } 70% { box-shadow: 0 0 0 7px #dc262600; } 100% { box-shadow: 0 0 0 0 #dc262600; } }

.banner { margin-top: 1rem; padding: 0.8rem 1rem; border-radius: var(--radius-sm); background: #fef3c7; border: 1px solid #fde68a; color: #92400e; font-size: 0.875rem; }
.banner.hidden { display: none; }

/* Live strip (sits below the tab bar so the tabs never shift when it appears) */
#livestrip { margin: 1.25rem 0 1.5rem; }
#livestrip.hidden { display: none; }
.live-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--live); }
.live-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0.75rem; }
.live-card { background: linear-gradient(180deg, #fff, #fff7f7); border: 1px solid #fecaca; border-left: 4px solid var(--live); border-radius: var(--radius-sm); padding: 0.85rem 1rem; box-shadow: var(--shadow); }
.live-card .lc-top { display:flex; justify-content:space-between; font-size:0.68rem; color:var(--text-dim); font-weight:700; text-transform:uppercase; letter-spacing:0.05em; margin-bottom:0.4rem; }
.live-card .lc-min { color: var(--live); }
.lc-row { display:grid; grid-template-columns: 1fr auto; align-items:center; gap:0.5rem; padding:0.15rem 0; }
.lc-team { display:flex; align-items:center; gap:0.5rem; font-weight:700; }
.lc-score { font-family:'JetBrains Mono',monospace; font-weight:700; font-size:1.25rem; }
.cm-feed { margin-top: 0.65rem; padding-top: 0.55rem; border-top: 1px dashed var(--border); display: grid; gap: 0.32rem; }
.live-card .cm-feed { border-top-color: #fecaca; }
.cm-line { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 0.55rem; font-size: 0.8rem; color: var(--text-muted); }
.cm-min { font-family:'JetBrains Mono',monospace; font-weight:700; font-size:0.7rem; color: var(--live); }
.cm-text { line-height: 1.35; }
.cm-score { font-family:'JetBrains Mono',monospace; font-weight:700; font-size:0.76rem; color: var(--text); }
.cm-tag { font-size: 0.8rem; line-height: 1; text-align: right; }
.cm-line:first-child .cm-text { color: var(--text); font-weight: 600; }
.cm-line.cm-red .cm-text { color: var(--live); font-weight: 600; }

/* Collapsible timeline on finished result cards */
.cm-toggle { margin-top: 0.55rem; }
.cm-summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.74rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; color: var(--accent);
  padding: 0.42rem 0.9rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg-card2); user-select: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
.cm-summary:hover { background: #e8effe; border-color: var(--accent); box-shadow: var(--shadow); }
.cm-summary::-webkit-details-marker { display: none; }
.cm-summary::before { content: '▸'; font-size: 0.6rem; transition: transform .15s; }
details[open] > .cm-summary::before { transform: rotate(90deg); }
.cm-summary .lbl-hide { display: none; }
details[open] > .cm-summary .lbl-show { display: none; }
details[open] > .cm-summary .lbl-hide { display: inline; }
.cm-sum-count { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--text-dim); }
.cm-toggle[open] { margin-bottom: 0.2rem; }

/* Lineups panel */
.lu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.5rem; margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px dashed var(--border); }
.lu-col { min-width: 0; }
.lu-team { font-weight: 800; font-size: 0.86rem; }
.lu-meta { font-size: 0.66rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 0.1rem; margin-bottom: 0.5rem; }
.lu-list { list-style: none; margin: 0; padding: 0; }
.lu-list li { display: flex; align-items: baseline; gap: 0.5rem; font-size: 0.82rem; padding: 0.13rem 0; }
.lu-num { font-family: 'JetBrains Mono', monospace; font-size: 0.7rem; color: var(--text-dim); min-width: 1.4em; text-align: right; flex-shrink: 0; }
.lu-pn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lu-bench-h { font-size: 0.64rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 0.55rem 0 0.15rem; }
.lu-bench li { color: var(--text-muted); font-size: 0.78rem; }
.lu-empty { font-size: 0.8rem; color: var(--text-dim); padding: 0.3rem 0; }
@media (max-width: 520px) { .lu-grid { grid-template-columns: 1fr; gap: 0.85rem; } }

/* View panel — reserve height so the footer doesn't bounce while data loads */
#view { min-height: 55vh; }

/* Nav */
.tabs { display: flex; gap: 0.3rem; margin: 1.75rem 0 1.25rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 0.3rem; box-shadow: var(--shadow); width: fit-content; max-width: 100%; }
a.tab { padding: 0.5rem 1.2rem; font-weight: 700; font-size: 0.9rem; color: var(--text-muted); text-decoration: none; border-radius: 999px; transition: color .15s, background .15s; white-space: nowrap; }
a.tab:hover { color: var(--text); }
a.tab.active { color: #fff; background: linear-gradient(100deg, var(--accent), var(--accent2)); box-shadow: var(--shadow-lg); }

/* Ad slot */
.ad-wrap { margin: 1.5rem 0; }
.ad-label { font-size: 0.6rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); text-align: center; margin-bottom: 0.3rem; }

/* Day grouping */
.day { margin-bottom: 1.5rem; }
.day-label { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); margin: 0 0.2rem 0.55rem; }

/* Match card */
.match { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin-bottom: 0.55rem; box-shadow: var(--shadow); border-left: 4px solid var(--g, var(--border)); transition: transform .12s, box-shadow .12s; }
.match:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(15,23,42,.08); }
.match-main { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.6rem; }
.side { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.side.home { justify-content: flex-end; text-align: right; }
.side.away { justify-content: flex-start; }
.tname { font-weight: 700; font-size: 0.98rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.crest { width: 26px; height: 26px; border-radius: 5px; object-fit: contain; flex-shrink: 0; background: var(--bg-card2); }
.crest-fb { display: inline-flex; align-items: center; justify-content: center; font-size: 0.6rem; font-weight: 800; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; border: 1px solid var(--border); }

.center { text-align: center; min-width: 92px; }
.score { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 1.3rem; letter-spacing: 0.04em; }
.kickoff { font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 700; }
.meta { font-size: 0.66rem; color: var(--text-dim); margin-top: 0.12rem; display:flex; gap:0.3rem; align-items:center; justify-content:center; flex-wrap:wrap; }

.gchip { display: inline-block; font-size: 0.6rem; font-weight: 800; letter-spacing: 0.04em; padding: 0.08rem 0.4rem; border-radius: 5px; color: #fff; background: var(--g, var(--text-dim)); }
.badge { display:inline-block; font-size:0.6rem; font-weight:800; letter-spacing:0.05em; text-transform:uppercase; padding:0.08rem 0.4rem; border-radius:5px; }
.badge.live { background: var(--live); color:#fff; }
.badge.ft { background: var(--bg-card2); color: var(--text-muted); }

.recap { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px dashed var(--border); font-size: 0.82rem; color: var(--text-muted); font-style: italic; }
.recap b { color: var(--text); font-style: normal; }
/* AI-written recap: a touch more prominent than the muted template line. */
.recap-ai { font-style: normal; color: var(--text); font-size: 0.86rem; line-height: 1.5; }
.recap-ai::before { content: "RECAP"; display: inline-block; margin-right: 0.5rem; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.08em; color: #fff; background: var(--g, var(--accent)); padding: 0.05rem 0.4rem; border-radius: 3px; vertical-align: middle; }

/* Link pills (navigate away): highlights + match details share one solid look, so they read
   as "this takes you somewhere" — distinct from the ghost expander pills that open in place.
   Detailed sizing/colour is defined alongside .match-link below. */

/* Standings */
.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.group-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; box-shadow: var(--shadow); }
.group-card h3 { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: #fff; padding: 0.55rem 0.9rem; background: var(--g, var(--accent)); }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 0.42rem 0.5rem; text-align: center; }
th { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); font-weight: 800; }
td.team-cell { text-align: left; font-weight: 700; }
.tc-inner { display: flex; align-items: center; gap: 0.45rem; }
td.num { font-family: 'JetBrains Mono', monospace; }
tbody tr.qualify { background: var(--good-bg); }
tbody tr.qualify .pos { color: var(--good); }
.pos { color: var(--text-dim); font-family: 'JetBrains Mono', monospace; font-size: 0.78rem; font-weight: 700; }
tbody tr + tr td { border-top: 1px solid var(--border); }

.legend { font-size: 0.78rem; color: var(--text-muted); margin-top: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--good-bg); border: 1px solid var(--good); display: inline-block; }

/* Golden Boot / top scorers */
.scorers-card { max-width: 760px; }
.scorers td.player-cell { text-align: left; }
.scorers .tc-inner { gap: 0.5rem; flex-wrap: wrap; }
.scorers .pl-name { font-weight: 700; }
.scorers .pl-team { color: var(--text-dim); font-weight: 600; font-size: 0.78rem; }
.scorers .gb-goals b { color: var(--accent); font-size: 0.95rem; }
.scorers tr.gb-lead { background: var(--good-bg); }
.scorers tr.gb-lead .pos { color: var(--good); }

.empty { color: var(--text-dim); padding: 2.5rem 1rem; text-align: center; font-size: 0.92rem; }

footer { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--text-dim); text-align: center; }
footer a { color: var(--accent); text-decoration: none; }

@media (max-width: 520px) {
  .match-main { gap: 0.35rem; }
  .tname { font-size: 0.88rem; }
  .crest { width: 22px; height: 22px; }
  a.tab { padding: 0.5rem 0.85rem; font-size: 0.82rem; }
}

/* Link pills (navigate away): identical solid treatment for highlights + match details. */
.hl-link, .match-link { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 0.55rem; padding: 0.42rem 0.9rem; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; color: #fff; text-decoration: none; background: linear-gradient(100deg, var(--accent), var(--accent2)); border: 1px solid transparent; border-radius: 999px; box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, filter .12s; }
.hl-link:hover, .match-link:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); filter: brightness(1.04); text-decoration: none; }

/* Card action bar: toggles + links sit in one horizontal row on desktop and wrap (stack) on
   narrow screens. An opened timeline/lineups panel breaks onto its own full-width row so its
   content isn't squeezed into a flex column. */
.card-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0.5rem; margin-top: 0.7rem; }
.card-actions > details, .card-actions > .hl-link, .card-actions > .match-link, .card-actions > .cm-toggle { margin-top: 0; }
.card-actions > details[open] { flex: 1 1 100%; }

/* ---------- Match detail page ---------- */
.md-back { display: inline-block; margin: 0 0 1rem; padding: 0; color: var(--accent); background: none; border: none; box-shadow: none; text-transform: none; letter-spacing: normal; font-size: 0.85rem; font-weight: 700; }
.md-back:hover { transform: none; box-shadow: none; filter: none; text-decoration: underline; }
.md-ctx { font-size: 0.74rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 1rem; }
.md-score { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem; background: var(--bg-card); border: 1px solid var(--border); border-left: 4px solid var(--g, var(--accent)); border-radius: var(--radius); padding: 1.6rem 1.25rem; box-shadow: var(--shadow); }
.md-team { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; text-align: center; min-width: 0; }
.md-crest .crest, .md-crest .crest-fb { width: 58px; height: 58px; border-radius: 9px; }
.md-tn { font-weight: 800; font-size: 1.05rem; line-height: 1.2; }
.md-center { text-align: center; }
.md-score-n { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 2.4rem; letter-spacing: 0.04em; }
.md-kick { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 1.4rem; }
.md-pens { font-size: 0.78rem; color: var(--text-muted); font-weight: 700; margin-top: 0.2rem; }
.md-badge { margin-top: 0.45rem; }
.md-h { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 1.6rem 0 0.6rem; }
.md .cm-feed { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem 1rem; box-shadow: var(--shadow); }
.md .lu-grid { border-top: none; margin-top: 0; padding-top: 0; }
.md .recap, .md .recap-ai { border-top: none; padding-top: 0; margin-top: 1.25rem; }
.md .hl-link { margin-top: 1.25rem; }
.md-refs { margin-top: 1.1rem; font-size: 0.78rem; color: var(--text-dim); }
@media (max-width: 520px) {
  .md-score { padding: 1.1rem 0.6rem; gap: 0.4rem; }
  .md-crest .crest, .md-crest .crest-fb { width: 44px; height: 44px; }
  .md-tn { font-size: 0.86rem; }
  .md-score-n { font-size: 1.9rem; }
}

/* ---------- Knockout bracket ---------- */
.bk-scroll { overflow-x: auto; padding-bottom: 0.75rem; -webkit-overflow-scrolling: touch; }
.bk-grid { display: flex; gap: 1rem; min-width: max-content; align-items: stretch; }
.bk-col { display: flex; flex-direction: column; min-width: 196px; }
.bk-col-h { font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); text-align: center; margin-bottom: 0.6rem; }
.bk-col-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 0.55rem; }
.bk-match { display: block; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem 0.6rem; box-shadow: var(--shadow); text-decoration: none; color: inherit; transition: border-color .12s, box-shadow .12s, transform .12s; }
a.bk-match:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.bk-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.58rem; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.32rem; }
.bk-when .bk-live { color: var(--live); font-weight: 800; }
.bk-when .bk-ft { color: var(--text-muted); }
.bk-row { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; padding: 0.14rem 0; }
.bk-team { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; font-weight: 700; min-width: 0; }
.bk-team .crest, .bk-team .crest-fb { width: 18px; height: 18px; border-radius: 4px; flex-shrink: 0; }
.bk-tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-tbd { color: var(--text-dim); font-weight: 600; font-size: 0.73rem; }
.bk-sc { font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 0.92rem; flex-shrink: 0; }
.bk-row.bk-win .bk-team { color: var(--accent); }
.bk-row.bk-win .bk-sc { color: var(--accent); }
.bk-penline { font-size: 0.64rem; color: var(--text-dim); text-align: right; margin-top: 0.1rem; }
.bk-pen { white-space: nowrap; }
.bk-third { margin-top: 1.75rem; max-width: 240px; }
@media (max-width: 520px) { .bk-col { min-width: 158px; } .bk-team { font-size: 0.76rem; } }
