:root {
  --bg: #0b1020;
  --bg-soft: #121a31;
  --card: #161f3a;
  --line: #243153;
  --text: #e9eefc;
  --muted: #94a3c4;
  --accent: #4ade80;
  --accent-2: #38bdf8;
  --warn: #fbbf24;
  --gold: #c8a24a;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(900px 500px at -10% 10%, rgba(74, 222, 128, 0.10), transparent),
    var(--bg);
  min-height: 100vh;
}

header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
  background: rgba(11, 16, 32, 0.7);
  border-bottom: 1px solid var(--line);
}

.bar {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px 20px;
  /* respect the iPhone notch / safe areas in full-screen mode */
  padding-top: max(16px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  margin-right: auto;   /* push the refresh button to the right edge of row 1 */
}
/* FIFA 26 emblem (white 26 + gold trophy) — shown in full, no cropping */
.brand .brand-logo {
  height: 34px; flex: 0 0 auto;
  display: inline-flex; align-items: center;
}
.brand .brand-logo img {
  height: 100%; width: auto; display: block;
}
.brand-text { display: inline; }
.byline {
  font-size: 11px;
  font-weight: 600;
  font-style: italic;
  color: var(--accent-2);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* tabs sit on their own full-width row beneath the brand/refresh */
/* ---- native-style bottom tab bar (Mundial app build) ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 200;
  display: flex; align-items: stretch;
  background: rgba(11, 16, 32, 0.9);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; padding: 8px 2px 7px; text-decoration: none;
  color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.2px;
  -webkit-tap-highlight-color: transparent; transition: color 0.15s ease;
}
.tabbar a .tabicon { width: 25px; height: 25px; display: block; }
.tabbar a.active { color: var(--accent); }
/* the knockouts bracket is the tallest view — give it a little extra room */
#knockouts-content { padding-bottom: 24px; }

/* hide scrollbars everywhere — it's a native app, no need for them */
::-webkit-scrollbar { width: 0; height: 0; display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

nav.tabs { flex-basis: 100%; display: flex; gap: 8px; }
nav.tabs a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}
nav.tabs a:hover { color: var(--text); background: var(--bg-soft); }
nav.tabs a.active {
  color: var(--bg);
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.refresh-btn:hover { border-color: var(--accent); background: var(--card); }
.refresh-btn:disabled { opacity: 0.7; cursor: default; }
.refresh-btn .ic { font-size: 15px; line-height: 1; display: inline-block; }
.refresh-btn.spin .ic { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main {
  max-width: 1000px;
  margin: 0 auto;
  /* generous bottom padding so content clears the fixed tab bar with breathing room */
  padding: 28px 20px calc(104px + env(safe-area-inset-bottom));
}

/* single-page views: switch with a subtle fade; swipe/tab nav slides the new
   page in from the direction of travel (set via .from-left / .from-right) */
.view { display: none; }
.view.view-active { display: block; animation: viewIn 0.18s ease both; }
.view.view-active.from-right { animation: slideFromRight 0.26s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
.view.view-active.from-left  { animation: slideFromLeft  0.26s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slideFromRight { from { opacity: 0; transform: translateX(34px); } to { opacity: 1; transform: none; } }
@keyframes slideFromLeft  { from { opacity: 0; transform: translateX(-34px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .view.view-active, .view.view-active.from-right, .view.view-active.from-left { animation: viewIn 0.12s ease both; }
}

/* current / next match: highlight + scroll anchor that clears the sticky header */
.match { scroll-margin-top: 116px; }
.match.is-current { border-color: var(--accent-2); box-shadow: var(--shadow); }
.match.is-live { border-color: var(--accent); box-shadow: var(--shadow); }
/* brief glow on a match you were just directed to (e.g. tapped in the bracket) */
.match.flash { animation: flashMatch 2.6s ease-out; }
@keyframes flashMatch {
  0%, 65% { box-shadow: 0 0 0 2px var(--accent-2), 0 0 18px 3px rgba(56, 189, 248, 0.55), var(--shadow); }
  100%    { box-shadow: var(--shadow); }
}
@media (prefers-reduced-motion: reduce) { .match.flash { animation-duration: 1.2s; } }
.current-tag { font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; color: var(--accent-2); margin-bottom: 8px; }
.current-tag.live { color: var(--accent); }

.page-title {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0 4px;
}
.page-sub { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

/* ---------- status / errors ---------- */
.notice {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 14px;
}
.notice.error { border-color: #5b2330; background: #2a1620; color: #ffd5dd; }

.skeleton {
  height: 64px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--card) 37%, var(--bg-soft) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  margin-bottom: 12px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ---------- fixtures ---------- */
/* thin labelled divider between tournament phases (Group Stage / R32 / R16 …) */
.phase-sep { display: flex; align-items: center; gap: 12px; margin: 30px 2px 16px; }
.phase-sep:first-child { margin-top: 4px; }
.phase-sep::before, .phase-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.phase-sep span { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }

.round-group { margin-bottom: 30px; }
.round-head {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent-2);
  font-weight: 700;
  margin: 0 0 12px;
}

.match {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.match-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

/* scorers / cards strip under a finished match */
.events {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 18px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
}
.events .away-ev { text-align: right; }
.events .ev { display: block; line-height: 1.7; color: var(--muted); }
.events .min { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
.events .tag { font-size: 10px; opacity: 0.8; }
.events .ic { font-size: 11px; }

/* penalty shoot-out: separated block, two columns of takers + running tally */
.pso { margin-top: 6px; }
.pso .phase-sep { margin: 12px 0 8px; }
.pso-head span { color: var(--muted); }
.pso-win span { color: var(--accent); }
.pk-list { display: flex; flex-direction: column; gap: 5px; }
.pk-row { display: flex; align-items: center; gap: 8px; }
.pk { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; }
.pk-row > .pk:first-child { justify-content: flex-end; text-align: right; }
.pk-row > .pk:last-child  { justify-content: flex-start; text-align: left; }
.pk-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk.miss .pk-name { color: var(--muted); }
.pk.made .pk-name { color: var(--text); }
.pk-ic { flex: none; font-weight: 800; }
.pk.made .pk-ic { color: var(--accent); }
.pk.miss .pk-ic { color: var(--muted); }
.pk-tally { flex: none; min-width: 36px; text-align: center; font-size: 11px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.team {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  min-width: 0;
}
.team.away { justify-content: flex-end; text-align: right; }
.team .name { min-width: 0; overflow-wrap: anywhere; line-height: 1.2; }
.flag {
  width: 34px; height: 26px;
  border-radius: 6px;
  background: var(--bg-soft);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1; flex: 0 0 auto;
  border: 1px solid var(--line);
  overflow: hidden;
  vertical-align: middle;   /* align flag with the team name in table rows */
}
/* rectangular flag image fills its box */
.flag-img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* larger flags on the match cards */
.match .flag { width: 46px; height: 34px; font-size: 30px; }
/* candidate teams for an unresolved knockout game: two mini flags + abbreviations */
.team .cand-flags { display: inline-flex; gap: 3px; flex: 0 0 auto; }
.match .flag.mini { width: 22px; height: 16px; }
.cand-names { font-size: 12px; font-weight: 700; color: var(--muted); }

.score {
  text-align: center;
  min-width: 92px;
}
.score .nums { font-size: 22px; font-weight: 800; letter-spacing: 1px; white-space: nowrap; }
.score .nums .pk-side { font-size: 0.55em; color: var(--accent); font-weight: 700; letter-spacing: 0; vertical-align: 0.18em; }
.score .vs { color: var(--muted); font-weight: 700; }
.status {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
}
.status.live { background: rgba(74, 222, 128, 0.20); color: var(--accent); animation: livePulse 1.4s ease-in-out infinite; }
@keyframes livePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.status.ft   { background: var(--bg-soft); color: var(--muted); }
.status.ns   { background: var(--bg-soft); color: var(--muted); }
.kickoff { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pens { font-size: 11px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }

/* tap-to-expand attack momentum chart — the whole .mom-toggle zone (bar + chart)
   is a big, obvious target so momentum is easy to open without hitting the card */
.mom-toggle { cursor: pointer; margin-top: 4px; }
.mom-hint { margin-top: 8px; padding: 11px 8px 9px; text-align: center; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); cursor: pointer; user-select: none; border-top: 1px dashed var(--line); }
.match.expanded .mom-hint { color: var(--accent-2); }
.mom-hint .chev { display: inline-block; transition: transform 0.2s ease; }
.match.expanded .mom-hint .chev { transform: rotate(180deg); }
.mom-wrap { display: none; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.match.expanded .mom-wrap { display: block; }
.mom-head { display: flex; justify-content: space-between; align-items: center; font-size: 10px; font-weight: 700; margin-bottom: 4px; }
.mom-title { color: var(--muted); font-weight: 600; letter-spacing: 0.4px; }
.m-hc { color: var(--accent-2); }
.m-ac { color: var(--gold); }
.mom-chart { position: relative; padding: 9px 0; }
.mom-svg { width: 100%; height: 56px; display: block; }
/* goal marker: ⚽ on the scorer's edge, with a thin stem in the team's colour
   running to the midline so the goal moment stands out on the chart */
.mgoal {
  position: absolute; transform: translateX(-50%);
  font-size: 11px; line-height: 1; user-select: none;
}
.mgoal::after {
  content: ""; position: absolute; left: 50%; transform: translateX(-50%);
  width: 1.5px; height: 26px; opacity: 0.55;
}
.mgoal.h { top: -1px; }
.mgoal.h::after { top: 100%; background: var(--accent-2); }
.mgoal.a { bottom: -1px; }
.mgoal.a::after { bottom: 100%; background: var(--gold); }
.mom-svg .m-h { fill: var(--accent-2); }
.mom-svg .m-a { fill: var(--gold); }
.mom-svg .m-line { stroke: var(--line); stroke-width: 0.6; }

/* ---------- standings ---------- */
.group-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}
.group-card h3 {
  margin: 0;
  padding: 14px 18px;
  font-size: 15px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
}
thead th.team-col, tbody td.team-col { text-align: left; }
tbody td { padding: 12px 6px; text-align: center; vertical-align: middle; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:nth-child(-n+2) td:first-child { font-weight: 800; }
.rank {
  display: inline-flex; width: 22px; height: 22px;
  align-items: center; justify-content: center;
  border-radius: 6px; font-weight: 700; font-size: 12px;
}
/* top 2 — qualify (green) */
tbody tr.q-top .rank { background: rgba(74, 222, 128, 0.16); color: var(--accent); }
tbody tr.q-top td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
tbody tr.q-top td { background: rgba(74, 222, 128, 0.05); }
/* best third — qualify (blue) */
tbody tr.q-third .rank { background: rgba(56, 189, 248, 0.18); color: var(--accent-2); }
tbody tr.q-third td:first-child { box-shadow: inset 3px 0 0 var(--accent-2); }
tbody tr.q-third td { background: rgba(56, 189, 248, 0.05); }
/* eliminated (greyed) */
tbody tr.out td { opacity: 0.45; }
tbody tr.out .rank { background: var(--bg-soft); color: var(--muted); }

/* legend */
/* inline advance-colour dots in the Standings subtitle */
.q-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: baseline; margin-right: 1px; }
.q-dot.green { background: var(--accent); }
.q-dot.blue { background: var(--accent-2); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 0 0 22px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .dot { width: 12px; height: 12px; border-radius: 4px; }
.legend .dot.adv { background: var(--accent); }
.legend .dot.third { background: var(--accent-2); }
.legend .dot.out { background: var(--muted); opacity: 0.5; }
.pts { font-weight: 800; }
.form { display: inline-flex; gap: 3px; }
.form span {
  width: 16px; height: 16px; border-radius: 4px;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  color: #0b1020;
}
.form .W { background: var(--accent); }
.form .D { background: var(--warn); }
.form .L { background: #f87171; }

/* ---------- top players ---------- */
.players-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}
.player { font-weight: 600; }
.tag { font-size: 10px; color: var(--muted); font-weight: 600; }

/* ---------- knockouts bracket (flags only, mirrored tree, fits page width) ---------- */
/* single tree: 5 round-columns left -> right, tall enough to give every R32 game room (scroll down) */
.bracket.tree { position: relative; width: 100%; display: flex; align-items: stretch; gap: 4px; min-height: 1280px; }
.bracket.tree .bk-col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.bk-col-final .bk-col-body { justify-content: center; }
/* round label on top of each column */
.bk-col-head {
  text-align: center; font-size: 11px; font-weight: 800; letter-spacing: 0.5px;
  color: var(--accent-2); margin-bottom: 8px;
}
.bk-final-head { color: var(--gold); }
/* cards shrink to the flag and centre in their column (column gives the spacing) */
.bk-col-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; align-items: center; }

/* one card = one match: the two teams tight together with a small gap; the
   space-around between cards gives the larger gap between separate matches */
.bk-match {
  position: relative; z-index: 1; width: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 3px; padding: 4px;
}
.bk-match[data-fx] { cursor: pointer; transition: border-color 0.15s ease; }
.bk-match[data-fx]:hover { border-color: var(--accent-2); }
/* flag + its score beside it; fixed score column keeps every card the same width
   (so flags stay aligned down the column) */
.bk-team { position: relative; display: grid; grid-template-columns: auto 20px; align-items: center; justify-content: center; gap: 3px; }
/* big flag that fills its card; scales with the viewport, capped on big screens */
/* bare flag (no individual box) — the match card is the group */
.bracket.tree .bk-team .flag {
  /* as big as the 5 columns allow WITHOUT horizontal scroll: each column is
     ~(100vw - page padding - gaps)/5, minus the score column + card chrome */
  width: clamp(28px, calc(20vw - 42px), 48px); height: auto; aspect-ratio: 3 / 2;
  line-height: 1; border: none; background: none; border-radius: 4px; overflow: hidden;
}
.bracket.tree .bk-team.tbd .flag { border: 1.5px dashed var(--line); background: none; opacity: 0.45; }
.bk-score {
  text-align: center; line-height: 1; white-space: nowrap; color: var(--text);
  font-size: clamp(11px, 2.6vw, 13px); font-weight: 800; font-variant-numeric: tabular-nums;
}
.bk-score .bk-pk { font-size: 0.74em; font-weight: 700; }   /* pen score beside the goals */

.bk-lines { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 0; }
.bk-col-final .bk-match { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold), var(--shadow); }
.bk-trophy { width: clamp(38px, 9vw, 64px); height: auto; margin: 0 auto 12px; display: block; }

@media (max-width: 560px) {
  .bracket.tree { gap: 3px; min-height: 1180px; }
  .bk-col-head { font-size: 9px; margin-bottom: 5px; }
}

footer {
  max-width: 1000px; margin: 0 auto; padding: 20px;
  color: var(--muted); font-size: 12px; text-align: center;
}

@media (max-width: 720px) {
  .players-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  /* compact header — keep the safe-area insets so the bar clears the iOS notch
     in "Add to Home Screen" standalone mode (don't reset padding-top to 12px) */
  .bar {
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .brand { font-size: 16px; }
  .brand .brand-logo { height: 30px; }
  nav.tabs { gap: 6px; justify-content: space-between; }
  nav.tabs a { padding: 7px 12px; font-size: 13px; }
  .refresh-btn { font-size: 11px; padding: 5px 11px; gap: 5px; margin-left: 0; }
  .refresh-btn .ic { font-size: 13px; }
  .upd-pre { display: none; }   /* show just "2m ago" on mobile */
  .page-title { font-size: 22px; }

  .match { padding: 12px; }
  .match-row { gap: 8px; }
  /* let full team names show (wrap fully, no ellipsis) */
  .team .name { font-size: 13px; white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.2; }
  .match .flag { width: 32px; height: 24px; font-size: 21px; }
  .score { min-width: 60px; }
  .score .nums { font-size: 18px; }
  .events { gap: 4px 10px; }
  .events .ev { font-size: 11px; }
  thead th.hide-sm, tbody td.hide-sm, .hide-sm { display: none; }   /* also hides the team-name span on Players (flags only on mobile) */
  /* tables: smaller flags + tighter cells so names fit beside the flag */
  .group-card .flag { width: 28px; height: 21px; font-size: 18px; }
  table { font-size: 13px; }
  tbody td { padding: 11px 5px; }
}

/* ============ match detail page (full-screen, slides in) ============ */
.detail {
  position: fixed; inset: 0; z-index: 400;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(56, 189, 248, 0.12), transparent),
    radial-gradient(900px 500px at -10% 10%, rgba(74, 222, 128, 0.10), transparent),
    var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateX(100%); opacity: 0; visibility: hidden;
  transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.26s ease, visibility 0s linear 0.26s;
}
.detail.open { transform: translateX(0); opacity: 1; visibility: visible; transition: transform 0.26s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.2s ease; }
@media (prefers-reduced-motion: reduce) { .detail, .detail.open { transition: opacity 0.15s ease; transform: none; } }
body.detail-open { overflow: hidden; }

/* top bar with back button */
.d-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  backdrop-filter: blur(10px); background: rgba(11, 16, 32, 0.72);
  border-bottom: 1px solid var(--line);
}
.d-back {
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 700; padding: 6px 14px 6px 10px;
  border-radius: 999px; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.d-back:hover { border-color: var(--accent); }
.d-phase { font-size: 12px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }

/* score header */
.d-score {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px;
  padding: 22px 16px 20px; border-bottom: 1px solid var(--line);
}
.d-team { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.d-team .flag { width: 58px; height: 42px; font-size: 38px; }
.d-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
.d-mid { text-align: center; min-width: 84px; }
.d-nums { font-size: 34px; font-weight: 800; letter-spacing: 1px; white-space: nowrap; }
.d-nums .d-colon { color: var(--muted); }
.d-status { margin-top: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.d-status.live { color: var(--accent); animation: livePulse 1.4s ease-in-out infinite; }

.d-body { max-width: 640px; margin: 0 auto; padding: 6px 16px calc(40px + env(safe-area-inset-bottom)); }
.d-sec { margin-top: 22px; }
.d-sec-h { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--accent-2); margin: 0 0 14px; }

/* stat comparison bars */
.st-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; margin-bottom: 14px; }
.st-v { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 34px; }
.st-row .st-v:last-of-type { text-align: right; }
.st-k { text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.st-bar { grid-column: 1 / -1; display: flex; gap: 4px; height: 6px; }
.st-bar span { height: 100%; border-radius: 3px; }
.st-h { background: var(--accent-2); }
.st-a { background: var(--gold); margin-left: auto; }

/* line-ups pitch */
.d-forms { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 8px; padding: 0 4px; }
.pitch-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: linear-gradient(180deg, #0e4d2a, #0a3a20); }
.pitch { width: 100%; height: auto; display: block; }
.pitch .pf { fill: none; stroke: rgba(255, 255, 255, 0.28); stroke-width: 0.6; }
.pitch .pl { stroke: rgba(255, 255, 255, 0.28); stroke-width: 0.6; }
.pitch .jersey { stroke: rgba(0, 0, 0, 0.3); stroke-width: 0.25; stroke-linejoin: round; }
.pitch .jersey.h { fill: var(--accent-2); }
.pitch .jersey.a { fill: var(--gold); }
.pitch .pnum { font-size: 3px; font-weight: 800; fill: #0b1020; }
.pitch .pname { font-size: 2.7px; font-weight: 700; fill: #eafff2; paint-order: stroke; stroke: rgba(6, 11, 22, 0.6); stroke-width: 0.5px; }

.subs { margin-top: 14px; }
.subs-h { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.sub { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text); background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; margin: 0 6px 6px 0; }
.sub .sn { font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }

/* timeline */
.tl { display: flex; flex-direction: column; gap: 8px; }
.tl-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; font-size: 13px; }
.tl-min { min-width: 34px; text-align: center; font-weight: 800; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-side { min-width: 0; }
.tl-row.h .tl-side:first-child { text-align: right; }
.tl-row.a .tl-side:last-child { text-align: left; }
.tl-ic { font-size: 12px; }
.tl-d { font-size: 11px; color: var(--muted); }
.tl-in { color: var(--accent); font-weight: 600; }
.tl-out { color: var(--muted); }

.d-meta { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.d-loading { padding: 20px 4px; }
/* pen score flanking the detail header score, e.g. (4) 0 : 0 (3) */
.d-nums .d-pk { font-size: 0.5em; color: var(--accent); font-weight: 700; vertical-align: 0.4em; letter-spacing: 0; }
/* penalty shoot-out section on the detail page (reuses the fixtures .pso block) */
.d-pso { padding-top: 2px; }
.d-pso .pso { margin-top: 0; }
/* pull-to-refresh: body follows the finger, a subtle indicator shows while loading */
.detail .d-body { transform: translateY(var(--pull, 0px)); }
.detail.refreshing::after {
  content: "↻ Refreshing…";
  position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 46px);
  text-align: center; font-size: 11px; font-weight: 700; letter-spacing: 0.4px;
  color: var(--accent-2); z-index: 5; pointer-events: none;
}
/* detail header controls: share + reminder (right) and a favourite star per team */
.d-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.d-bell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-soft); color: var(--muted); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.d-bell svg { width: 17px; height: 17px; }
.d-bell:active { transform: scale(0.94); }
.d-bell.on { color: var(--warn); border-color: var(--warn); }
.d-fav { border: none; background: none; cursor: pointer; padding: 2px 6px; margin-top: 3px; font-size: 19px; line-height: 1; color: var(--muted); -webkit-tap-highlight-color: transparent; }
.d-fav.on { color: var(--gold); }
/* favourite star in the standings table */
.st-fav { border: none; background: none; cursor: pointer; padding: 0 3px; font-size: 14px; color: var(--line); vertical-align: middle; -webkit-tap-highlight-color: transparent; }
.st-fav.on { color: var(--gold); }
/* favourite marker beside a team on a fixture card */
.fav-star { color: var(--gold); font-size: 0.82em; }

/* ===== team filter (lives in the sticky top banner, Fixtures only) ===== */
.filter-chip {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--muted); font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.filter-chip[hidden] { display: none; }   /* beat the .filter-chip display:inline-flex */
.filter-chip svg { width: 16px; height: 16px; flex: 0 0 auto; }
.filter-chip.active { color: var(--text); border-color: var(--accent-2); background: rgba(56, 189, 248, 0.12); }
.filter-chip .filter-lbl { display: inline-flex; align-items: center; gap: 6px; }
.filter-chip .flag.mini { width: 20px; height: 14px; }

/* bottom sheet team picker */
.sheet { position: fixed; inset: 0; z-index: 500; visibility: hidden; }
.sheet.open { visibility: visible; }
.sheet-back { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); opacity: 0; transition: opacity 0.25s ease; }
.sheet.open .sheet-back { opacity: 1; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 78vh;
  background: var(--bg-soft); border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
.sheet.open .sheet-panel { transform: translateY(0); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; font-size: 15px; font-weight: 800; border-bottom: 1px solid var(--line); }
.sheet-close { border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; -webkit-tap-highlight-color: transparent; }
.sheet-grid { overflow-y: auto; padding: 14px 16px 20px; display: flex; flex-wrap: wrap; gap: 8px; }
.pick-sec { flex-basis: 100%; font-size: 11px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); margin: 8px 2px 0; }
.pick-team {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-size: 13px; font-weight: 700;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pick-team.on { border-color: var(--accent-2); background: rgba(56, 189, 248, 0.14); }
.pick-team .flag.mini { width: 22px; height: 15px; }
.pick-all { font-weight: 800; }
body.sheet-open { overflow: hidden; }

/* ============ branded intro splash (cold start) — glowing app-icon reveal ============ */
#splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(95% 75% at 50% 45%, #141f3c 0%, #0b1020 52%, #070b16 100%);
  opacity: 1; transition: opacity 0.6s ease;
}
#splash.hide { opacity: 0; pointer-events: none; }
.splash-content { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; }
.splash-glow {
  position: absolute; top: 50%; left: 50%;
  width: 480px; height: 480px; margin: -240px 0 0 -240px; border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 140, 255, 0.42), rgba(74, 140, 255, 0.12) 42%, transparent 66%);
  filter: blur(24px); will-change: transform, opacity;
  animation: splashGlow 3s ease-in-out infinite;
}
.splash-logo { display: inline-flex; }
.splash-logo img {
  width: 172px; height: 172px; display: block;
  border-radius: 39px;                 /* large iOS-style app-icon tile */
  box-shadow:
    0 34px 80px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 66px rgba(74, 140, 255, 0.22);
  will-change: transform, opacity;
  animation: splashPop 1s cubic-bezier(0.2, 0.8, 0.24, 1.08) both;
}
@keyframes splashPop { 0% { opacity: 0; transform: scale(0.8); } 55% { opacity: 1; } 100% { opacity: 1; transform: scale(1); } }
@keyframes splashGlow { 0%, 100% { opacity: 0.5; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) {
  .splash-logo img { animation-duration: 0.3s; }
  .splash-glow { animation: none; }
}
