:root {
  --bg: #0a0e16;
  --panel: rgba(255, 255, 255, 0.055);
  --panel-2: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef2f8;
  --muted: rgba(238, 242, 248, 0.62);
  --dim: rgba(238, 242, 248, 0.40);
  --accent: #1ed98a;
  --accent-2: #38bdf8;
  --live: #ff4d4d;
  --gold: #f5c518;
  --warn: #fbbf24;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --mono: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overscroll-behavior-y: none;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1100px 540px at 85% -12%, rgba(30, 217, 138, 0.16), transparent 60%),
    radial-gradient(900px 480px at -5% 110%, rgba(56, 189, 248, 0.12), transparent 55%),
    linear-gradient(165deg, #0e1626 0%, #0a0e16 55%, #06080e 100%);
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: linear-gradient(180deg, rgba(10, 14, 22, 0.92), rgba(10, 14, 22, 0.55));
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; cursor: pointer; }
.brand-mark { font-size: 22px; }
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.topbar-right { display: flex; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 17px; cursor: pointer;
  display: grid; place-items: center; transition: background .15s, transform .1s;
}
.icon-btn:active { transform: scale(0.92); background: var(--panel-2); }
.icon-btn.spin { animation: spin .7s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- View ---------- */
.view { max-width: 760px; margin: 0 auto; padding: 12px 14px 24px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 2px 10px;
}
.section-head h2 { font-size: 15px; font-weight: 700; margin: 0; letter-spacing: -0.2px; }
.section-head .sub { font-size: 12px; color: var(--muted); }

/* ---------- League chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer;
  white-space: nowrap; transition: all .15s; display: flex; align-items: center; gap: 6px;
}
.chip.active { background: var(--text); color: #0a0e16; border-color: var(--text); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live); }

/* ---------- Date nav ---------- */
.datenav { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 2px 0 12px; }
.datenav button { background: var(--panel); border: 1px solid var(--border); color: var(--text); width: 36px; height: 36px; border-radius: 10px; font-size: 16px; cursor: pointer; }
.datenav .label { font-size: 14px; font-weight: 700; min-width: 150px; text-align: center; }
.datenav .label small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }

/* ---------- Game cards ---------- */
.league-group { margin-bottom: 18px; }
.league-group > .lg-title {
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 1px; margin: 6px 4px 8px; display: flex; align-items: center; gap: 7px;
}
.games { display: flex; flex-direction: column; gap: 10px; }
.game {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; cursor: pointer; transition: background .15s, border-color .15s, transform .08s;
  position: relative; overflow: hidden;
}
.game:active { transform: scale(0.992); }
.game.live { border-color: rgba(255, 77, 77, 0.35); }
.game.live::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--live); box-shadow: 0 0 12px var(--live); }
.game-status { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.status-text { font-size: 12px; font-weight: 600; color: var(--muted); }
.status-text.live { color: var(--live); display: flex; align-items: center; gap: 6px; }
.status-text.live .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--live); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }
.status-meta { font-size: 11px; color: var(--dim); }

.team-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.team-row + .team-row { margin-top: 2px; }
.team-logo { width: 26px; height: 26px; object-fit: contain; flex: 0 0 26px; }
.team-name { flex: 1; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 7px; min-width: 0; }
.team-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-name .rec { font-size: 11px; color: var(--dim); font-weight: 500; }
.team-row.loser { opacity: 0.5; }
.team-score { font-family: var(--mono); font-size: 19px; font-weight: 700; min-width: 30px; text-align: right; }
.team-row .star { font-size: 12px; color: var(--gold); }
.possession { color: var(--accent); font-size: 10px; }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty .big { font-size: 38px; margin-bottom: 12px; }
.empty .sub { font-size: 13px; color: var(--dim); margin-top: 6px; }

/* ---------- Skeleton ---------- */
.skel { background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius); height: 84px; margin-bottom: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Game detail ---------- */
.back-btn { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); color: var(--text); padding: 8px 13px; border-radius: 11px; font-size: 13px; font-weight: 600; cursor: pointer; margin-bottom: 12px; }
.gd-header { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.gd-status { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
.gd-status.live { color: var(--live); }
.gd-teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.gd-team { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.gd-team img { width: 52px; height: 52px; object-fit: contain; }
.gd-team .tn { font-size: 13px; font-weight: 700; }
.gd-team .tr { font-size: 11px; color: var(--dim); }
.gd-score { font-family: var(--mono); font-size: 40px; font-weight: 800; }
.gd-vs { font-size: 13px; color: var(--dim); font-weight: 700; }
.gd-sep { color: var(--dim); font-size: 26px; padding: 0 4px; }

.tabs-row { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs-row::-webkit-scrollbar { display: none; }
.subtab { flex: 0 0 auto; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.subtab.active { background: var(--accent); color: #062018; border-color: var(--accent); }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 0 12px; }

/* line score table */
.linescore { width: 100%; border-collapse: collapse; font-size: 13px; }
.linescore th, .linescore td { padding: 7px 4px; text-align: center; }
.linescore th { color: var(--dim); font-weight: 600; font-size: 11px; }
.linescore td.team { text-align: left; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.linescore td.team img { width: 20px; height: 20px; }
.linescore td.tot { font-family: var(--mono); font-weight: 800; font-size: 15px; }
.linescore .num { font-family: var(--mono); color: var(--muted); }
.linescore tr + tr td { border-top: 1px solid var(--border); }

/* box score player tables */
.box-scroll { overflow-x: auto; margin: 0 -4px; scrollbar-width: thin; }
.box-table { border-collapse: collapse; font-size: 12px; white-space: nowrap; min-width: 100%; }
.box-table th { color: var(--dim); font-weight: 600; font-size: 10px; padding: 6px 9px; text-align: right; text-transform: uppercase; letter-spacing: .3px; }
.box-table th.pl, .box-table td.pl { text-align: left; position: sticky; left: 0; background: #131825; }
.box-table td { font-family: var(--mono); color: var(--muted); padding: 8px 9px; text-align: right; }
.box-table td.pl { font-family: var(--font); color: var(--text); font-weight: 600; }
.box-table tr + tr td { border-top: 1px solid var(--border); }

/* team stats compare */
.statline { margin-bottom: 13px; }
.statline .lbl { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.statline .lbl .name { color: var(--muted); }
.statline .lbl .v { font-family: var(--mono); font-weight: 700; }
.statbar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: rgba(255,255,255,0.06); }
.statbar .a { background: var(--accent); }
.statbar .b { background: var(--accent-2); }
.compare-key { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 14px; }
.compare-key .k { display: flex; align-items: center; gap: 6px; }
.compare-key .sw { width: 10px; height: 10px; border-radius: 3px; }

/* win probability */
.wp-wrap { margin-top: 4px; }
.wp-bar { display: flex; height: 30px; border-radius: 9px; overflow: hidden; font-size: 12px; font-weight: 800; }
.wp-bar .home { background: linear-gradient(90deg, var(--accent), #14b87a); color: #062018; display: grid; place-items: center; }
.wp-bar .away { background: linear-gradient(90deg, #2b6fa8, var(--accent-2)); color: #04141f; display: grid; place-items: center; }
.wp-spark { width: 100%; height: 54px; margin-top: 10px; }
.wp-teams { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 7px; }

/* plays / scoring */
.play { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.play:last-child { border-bottom: none; }
.play .clk { flex: 0 0 54px; font-family: var(--mono); font-size: 11px; color: var(--dim); padding-top: 1px; }
.play .body { flex: 1; }
.play .body .t { font-weight: 600; }
.play .body .d { color: var(--muted); font-size: 12px; margin-top: 2px; }
.play .sc { font-family: var(--mono); font-weight: 700; font-size: 12px; color: var(--accent); white-space: nowrap; }
.play.goal .ic, .play .ic { font-size: 14px; }

/* leaders */
.leader-grp { margin-bottom: 16px; }
.leader-grp h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 8px; }
.leader { display: flex; align-items: center; gap: 11px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.leader:last-child { border-bottom: none; }
.leader img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--panel-2); }
.leader .info { flex: 1; min-width: 0; }
.leader .info .n { font-size: 14px; font-weight: 600; }
.leader .info .m { font-size: 11px; color: var(--dim); }
.leader .val { font-family: var(--mono); font-weight: 800; font-size: 16px; color: var(--accent); }

/* standings table */
.stand-group { margin-bottom: 16px; }
.stand-group h3 { font-size: 13px; font-weight: 700; margin: 0 0 8px; padding: 0 2px; }
.stand-table { width: 100%; border-collapse: collapse; font-size: 13px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stand-table th { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--dim); font-weight: 600; padding: 9px 6px; text-align: right; }
.stand-table th.tm { text-align: left; }
.stand-table td { padding: 10px 6px; text-align: right; font-family: var(--mono); color: var(--muted); }
.stand-table td.tm { text-align: left; font-family: var(--font); color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.stand-table td.tm img { width: 20px; height: 20px; object-fit: contain; }
.stand-table td.tm .rk { color: var(--dim); font-size: 11px; width: 16px; }
.stand-table tr.fav td.tm { color: var(--gold); }
.stand-table tr + tr td { border-top: 1px solid var(--border); }
.stand-table td.w { color: var(--accent); }

/* following */
.follow-team { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 9px; }
.follow-team img { width: 32px; height: 32px; object-fit: contain; }
.follow-team .ftn { flex: 1; font-weight: 600; font-size: 14px; }
.follow-team .ftl { font-size: 11px; color: var(--dim); }
.follow-team button { background: rgba(255,77,77,0.12); border: 1px solid rgba(255,77,77,0.3); color: #ff8585; padding: 6px 12px; border-radius: 9px; font-size: 12px; font-weight: 600; cursor: pointer; }

.add-fav { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px,1fr)); gap: 8px; margin-top: 8px; }
.add-fav .ft { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 11px 6px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; transition: all .12s; text-align: center; }
.add-fav .ft.on { border-color: var(--gold); background: rgba(245,197,24,0.08); }
.add-fav .ft img { width: 30px; height: 30px; object-fit: contain; }
.add-fav .ft span { font-size: 11px; font-weight: 600; line-height: 1.2; }

.toast { position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: var(--text); color: #0a0e16; padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 700; box-shadow: var(--shadow); z-index: 200; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.err-note { background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.25); color: var(--warn); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 12px; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  display: flex; justify-content: space-around;
  padding: 8px 8px calc(env(safe-area-inset-bottom) + 6px);
  background: linear-gradient(0deg, rgba(8, 11, 18, 0.96), rgba(8, 11, 18, 0.78));
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-top: 1px solid var(--border);
}
.tab { flex: 1; background: none; border: none; color: var(--dim); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; cursor: pointer; padding: 4px; transition: color .15s; }
.tab .ti { font-size: 19px; filter: grayscale(1) opacity(0.7); transition: filter .15s; }
.tab.active { color: var(--text); }
.tab.active .ti { filter: none; }

@media (min-width: 600px) {
  .gd-team img { width: 64px; height: 64px; }
  .gd-score { font-size: 48px; }
}
