:root {
  /* FIFA World Cup 26 host palette: green (Mexico), blue (USA), red (Canada) */
  --wc-green: #3cac3b;
  --wc-green-bright: #45c95a;
  --wc-blue: #2a398d;
  --wc-blue-light: #5163c8;
  --wc-red: #e61d25;

  --bg: #0a0c14;
  --bg-raised: #12151f;
  --bg-card: #161a26;
  --line: #272c3b;
  --text: #eef1f7;
  --muted: #99a2b8;
  --accent: var(--wc-green-bright);
  --accent-deep: var(--wc-blue);
  --gold: #ffffff;
  --live: var(--wc-red);
  --bbc: #9fb4ff;
  --bbc-bg: rgba(159, 180, 255, 0.16);
  --itv: #ffd34d;
  --itv-bg: rgba(255, 211, 77, 0.16);
  --surface: rgba(255, 255, 255, 0.05);
  --surface-hi: rgba(255, 255, 255, 0.10);
  --radius: 16px;
  --maxw: 640px;
  --header-h: 120px;
  --tab-h: 64px;
}

html[data-theme="light"] {
  --bg: #eef1f8;
  --bg-raised: #ffffff;
  --bg-card: #ffffff;
  --line: #dfe4ef;
  --text: #0e1733;
  --muted: #647089;
  --accent: #1f9d4d;
  --accent-deep: var(--wc-blue);
  --surface: rgba(14, 23, 51, 0.05);
  --surface-hi: rgba(14, 23, 51, 0.09);
  --bbc: #2b50d8;
  --bbc-bg: rgba(43, 80, 216, 0.12);
  --itv: #8a6d00;
  --itv-bg: rgba(255, 193, 7, 0.18);
}

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

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

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

/* ---------- header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(160deg, #20296b, #0c0f1c 80%);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 18px) 16px 14px;
  color: #eef1f7;
}
.app-header::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg,
    var(--wc-red) 0 33.3%, var(--wc-green) 33.3% 66.6%, var(--wc-blue-light) 66.6% 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--maxw);
  margin: 0 auto;
}

.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}

.brand h1 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.day-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--maxw);
  margin: 14px auto 0;
}

.nav-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: #eef1f7;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.nav-btn:active { transform: scale(0.94); }
.nav-btn:hover { background: rgba(255, 255, 255, 0.1); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }

.day-label {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  height: 44px;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #eef1f7;
  cursor: pointer;
}
.day-name { font-weight: 700; font-size: 15px; }
.day-date { font-size: 12px; color: rgba(255, 255, 255, 0.6); }

/* ---------- views ---------- */
.view {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 16px 24px;
  min-height: calc(100dvh - var(--header-h) - var(--tab-h));
}
.view:focus { outline: none; }

.loading, .empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 15px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin: 18px 2px 10px;
}
.section-title:first-child { margin-top: 4px; }

/* ---------- match card ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  margin-bottom: 12px;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.card-stage { font-weight: 600; }

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.badge.ns { background: var(--surface); color: var(--muted); }
.badge.live { background: var(--live); color: #fff; animation: pulse 1.6s infinite; }
.badge.ft { background: var(--surface-hi); color: var(--text); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

.teams { display: flex; flex-direction: column; gap: 10px; }

.team-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 11px;
}
.team-flag {
  width: 28px;
  height: 21px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--bg-raised);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
}
.team-name { font-weight: 600; font-size: 16px; }
.team-name.placeholder { color: var(--muted); font-weight: 500; }
.team-code { color: var(--muted); font-size: 12px; font-weight: 600; margin-left: 6px; }
.team-score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 19px;
  min-width: 18px;
  text-align: right;
}
.team-row.winner .team-name { color: var(--accent); }

.card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.kick { font-weight: 700; color: var(--text); }
.kick-local { color: var(--muted); font-weight: 500; }
.venue { margin-left: auto; text-align: right; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.chip.bbc { background: var(--bbc-bg); color: var(--bbc); }
.chip.itv { background: var(--itv-bg); color: var(--itv); }
.chip.tbc { background: var(--surface); color: var(--muted); }
.chip-stream { font-weight: 500; color: var(--muted); background: transparent; padding-left: 0; }

/* ---------- groups ---------- */
.group-block { margin-bottom: 22px; }
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
}
.table th, .table td { padding: 9px 6px; text-align: center; }
.table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; background: var(--bg-raised); }
.table td.tname, .table th.tname { text-align: left; padding-left: 12px; }
.table tbody tr { border-top: 1px solid var(--line); }
.table .pts { font-weight: 800; }
.table .qual td { background: rgba(60,172,59,0.12); }
.table .mini-flag { width: 18px; height: 13px; border-radius: 2px; vertical-align: -1px; margin-right: 7px; object-fit: cover; }
.table .tcode { color: var(--muted); }

/* ---------- bracket ---------- */
.bracket-round { margin-bottom: 22px; }
.bracket-match {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.bracket-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 14px;
}
.bracket-line .mini-flag { width: 20px; height: 15px; border-radius: 2px; object-fit: cover; }
.bracket-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.bracket-line .ph { color: var(--muted); }

/* ---------- tabbar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  background: var(--bg-raised);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1;
  height: var(--tab-h);
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.tab.is-active { color: var(--accent); }

.update-note {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 6px 0 2px;
}
.app-version {
  text-align: center;
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
  opacity: 0.7;
  padding: 8px 0 4px;
}

/* ---------- install prompt ---------- */
.install-scrim {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s;
}
.install-scrim.show { opacity: 1; }

.install-sheet {
  position: fixed;
  z-index: 40;
  left: 0; right: 0; bottom: 0;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  transform: translateY(110%);
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.install-sheet.show { transform: translateY(0); }

.install-card {
  max-width: var(--maxw);
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}

.install-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.install-logo { width: 38px; height: auto; flex: 0 0 auto; }
.install-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.install-sub { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.install-close {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.install-steps {
  list-style: none;
  margin: 14px 0 2px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.install-step {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
}
.install-ico {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--wc-blue);
  color: #fff;
}
.install-step-text { color: var(--text); }

.install-btn {
  width: 100%;
  margin-top: 14px;
  height: 48px;
  border: none;
  border-radius: 12px;
  background: var(--wc-green);
  color: #04210f;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.install-btn:active { transform: scale(0.99); }

/* ---------- theme toggle ---------- */
.theme-toggle {
  margin-left: auto;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: #eef1f7;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.theme-toggle:active { transform: scale(0.92); }
.theme-toggle:hover { background: rgba(255, 255, 255, 0.12); }
.theme-toggle svg { width: 18px; height: 18px; display: block; }
.theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* ---------- tappable card + news screen ---------- */
.card.tappable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.card.tappable:active { transform: scale(0.99); }
.card-top-right { display: flex; align-items: center; gap: 8px; }
.card-go { color: var(--muted); font-size: 18px; line-height: 1; }

.news-back {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 13px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
}
.news-fixture {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin: 2px 2px 18px;
}
.news-section { margin-bottom: 24px; }
.news-team {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 2px 11px;
}
.news-flag {
  border-radius: 3px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.news-team-name { font-size: 15px; font-weight: 700; }
.news-empty { color: var(--muted); font-size: 13px; padding: 2px 2px 2px; }

.news-row {
  display: flex;
  gap: 12px;
  align-items: center;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 10px;
  transition: transform 0.1s;
}
.news-row:active { transform: scale(0.995); }
.news-thumb {
  width: 84px;
  height: 60px;
  flex: 0 0 auto;
  border-radius: 9px;
  object-fit: cover;
  background: var(--bg-raised);
}
.news-thumb-empty { background: var(--surface); }
.news-body { flex: 1; min-width: 0; }
.news-title { font-size: 14px; font-weight: 600; line-height: 1.32; }
.news-meta { font-size: 12px; color: var(--muted); margin-top: 5px; }

/* ---------- goal scorers on a match card ---------- */
.card-scorers {
  display: flex;
  gap: 12px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.scorer-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scorer-col.scorer-away { text-align: right; }
.scorer { line-height: 1.3; }
