:root {
  --bg: #f3f4f7;
  --card: #ffffff;
  --ink: #121621;
  --muted: #646b7a;
  --line: #e2e5eb;
  --accent: #1d4ed8;
  --accent-soft: #e6ecfc;
  --follow: #fff5d6;
  --follow-line: #f0d27a;
  --sa: #1d4ed8;
  --ucl: #4338ca;
  --ci: #0f7a55;
  --warn: #9a3412;
  --warn-soft: #fff1e6;
  --tab-bg: rgba(250, 251, 253, 0.92);
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0e14;
    --card: #161a23;
    --ink: #eef1f6;
    --muted: #9aa3b2;
    --line: #262c38;
    --accent: #7aa2ff;
    --accent-soft: #1b2440;
    --follow: #2a2412;
    --follow-line: #6b5a22;
    --sa: #7aa2ff;
    --ucl: #a5a0ff;
    --ci: #4fd1a1;
    --warn: #ffb48a;
    --warn-soft: #2b1c12;
    --tab-bg: rgba(18, 21, 29, 0.92);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}
button { font: inherit; color: inherit; }

.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 6px max(16px, env(safe-area-inset-left));
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: 30px; line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
.status { margin: 2px 0 0; font-size: 13px; color: var(--muted); min-height: 18px; }
.status.warn { color: var(--warn); }
.icon-btn {
  width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--card);
  display: grid; place-items: center; color: var(--accent); cursor: pointer;
}
.icon-btn.spin svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

main { padding: 6px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); outline: none; }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }
h2:first-child { margin-top: 8px; }

.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.card + .card { margin-top: 10px; }
.empty { color: var(--muted); padding: 16px; font-size: 15px; }

/* next match */
.hero { padding: 16px; }
.hero .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 13px; color: var(--muted); }
.hero .teams { font-size: 24px; font-weight: 700; letter-spacing: -0.01em; margin: 10px 0 2px; line-height: 1.2; overflow-wrap: anywhere; }
.hero .teams .vs { color: var(--muted); font-weight: 500; }
.hero .when { font-size: 17px; font-weight: 600; margin-top: 8px; }
.hero .when .time { color: var(--accent); }
.hero .where { font-size: 14px; color: var(--muted); margin-top: 2px; }
.hero .tvs { margin-top: 12px; }
.countdown { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* chips */
.chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 700; letter-spacing: 0.02em; color: #fff; white-space: nowrap; }
.chip.SA { background: var(--sa); }
.chip.UCL { background: var(--ucl); }
.chip.CI { background: var(--ci); }
@media (prefers-color-scheme: dark) { .chip { color: #0b0e14; } }
.ha { font-size: 12px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 11px; padding: 1px 8px; }

.tv { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 5px; border: 1.5px solid var(--ink); font-size: 11px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.tvs { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tv-none { font-size: 12px; color: var(--muted); }

/* filters / segmented */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; margin-top: 4px; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 0 0 auto; min-height: 36px; border: 0; border-radius: 18px; padding: 0 14px; background: var(--card); color: var(--ink); font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* match rows */
.row { display: grid; grid-template-columns: 56px 1fr; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: start; }
.row:first-child { border-top: 0; }
.row .d { text-align: center; line-height: 1.1; padding-top: 2px; }
.row .d .wd { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.row .d .dn { font-size: 22px; font-weight: 700; }
.row .d .mo { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.row .m { min-width: 0; }
.row .line1 { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.row .line1 .t { color: var(--ink); font-weight: 600; font-size: 14px; }
.row .line1 .t.tbd { color: var(--warn); font-weight: 600; }
.row .teams { font-size: 16px; font-weight: 600; margin-top: 3px; overflow-wrap: anywhere; }
.row .teams .me { font-weight: 800; }
.row .sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.row .tvs { margin-top: 6px; }
.row.follow { background: var(--follow); box-shadow: inset 3px 0 0 var(--follow-line); }
.score { font-variant-numeric: tabular-nums; font-weight: 800; padding: 0 4px; }

/* turno */
.turno-nav { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; margin-top: 4px; }
.turno-nav .lbl { text-align: center; }
.turno-nav .lbl b { display: block; font-size: 18px; }
.turno-nav .lbl span { font-size: 13px; color: var(--muted); }
.turno-nav button { width: 44px; height: 44px; border: 0; border-radius: 22px; background: var(--card); font-size: 22px; cursor: pointer; color: var(--accent); }
.turno-nav button:disabled { opacity: 0.35; cursor: default; }
.trow { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; padding: 12px 14px 10px; border-top: 1px solid var(--line); }
.trow:first-child { border-top: 0; }
.trow .h { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.trow .a { font-weight: 600; overflow-wrap: anywhere; }
.trow .c { text-align: center; font-size: 14px; font-weight: 700; color: var(--accent); white-space: nowrap; min-width: 52px; }
.trow .c.tbd { color: var(--warn); font-size: 12px; }
.trow .me { font-weight: 800; }
.trow .foot { grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.trow.follow { background: var(--follow); box-shadow: inset 3px 0 0 var(--follow-line); }
.daysep { padding: 8px 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); background: var(--bg); border-top: 1px solid var(--line); }
.daysep:first-child { border-top: 0; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.tbl th { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: right; padding: 8px 5px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 5px; text-align: right; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .pos { width: 30px; text-align: center; color: var(--muted); font-weight: 600; }
.tbl .tm { text-align: left; font-weight: 600; max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .pts { font-weight: 800; padding-right: 12px; }
.tbl th.tm { text-align: left; }
.tbl tr.follow td { background: var(--follow); }
.tbl tr.me td { background: var(--accent-soft); }
.tbl tr.me .tm { font-weight: 800; }
.tbl tr.cut td { border-bottom: 2px solid var(--muted); }
.tbl .opt { display: table-cell; }
@media (max-width: 359px) { .tbl .opt { display: none; } }
.legend { font-size: 12px; color: var(--muted); margin: 8px 4px 0; }

/* teams list */
.team { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 6px 14px; border-top: 1px solid var(--line); }
.team:first-child { border-top: 0; }
.team .n { font-weight: 600; }
.team .n small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.toggle { position: relative; width: 51px; height: 31px; flex: 0 0 auto; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.toggle span { position: absolute; inset: 0; border-radius: 16px; background: var(--line); transition: background 0.15s; pointer-events: none; }
.toggle span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform 0.15s; }
.toggle input:checked + span { background: #34c759; }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.fixed { font-size: 13px; color: var(--muted); }

.info { padding: 14px 16px; font-size: 14px; }
.info p { margin: 0 0 8px; }
.info p:last-child { margin-bottom: 0; }
.info a { color: var(--accent); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.banner { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 14px; margin: 6px 0 4px; }

.more { display: block; width: 100%; min-height: 44px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--accent); font-weight: 600; cursor: pointer; }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--tab-bg);
  -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--line);
  padding: 4px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
}
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; }
.tabs a svg { width: 26px; height: 26px; }
.tabs a[aria-current="page"] { color: var(--accent); }
