:root {
  --bg: #1b0020;
  --bg2: #260030;
  --card: #2f0a3a;
  --card2: #3a1046;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f6f0f8;
  --muted: #b9a6c0;
  --green: #00ff87;
  --cyan: #04f5ff;
  --pink: #ff2882;
  --gold: #ffd45a;
  --purple: #37003c;
  --up: #00e676;
  --down: #ff5470;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(68px + var(--safe-b));
  min-height: 100vh;
}
button, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: linear-gradient(120deg, #3d0045 0%, #2a0030 55%, #14002a 100%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; letter-spacing: -0.5px; color: var(--purple);
  background: linear-gradient(135deg, var(--green), var(--cyan));
}
.brand { flex: 1; }
.brand > div:last-child { min-width: 0; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
select {
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 10px; font-weight: 600; font-size: 14px;
}
.pill {
  font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 4px 8px; border-radius: 999px; background: var(--card2); color: var(--muted);
}
.pill:empty { display: none; }
.pill.live { background: rgba(255, 40, 130, 0.18); color: var(--pink); }
.pill.live::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--pink); margin-right: 5px; vertical-align: 1px; animation: pulse 1.4s infinite; }
.pill.final { background: rgba(0, 255, 135, 0.14); color: var(--green); }
.pill.provisional { background: rgba(255, 212, 90, 0.14); color: var(--gold); }
@keyframes pulse { 50% { opacity: 0.25; } }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }
.view { display: none; }
.view.active { display: block; }
.h2 { font-size: 18px; margin: 4px 0 12px; }
.note { color: var(--muted); font-size: 12px; margin: 12px 2px; }

/* ---------- Stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--card); border-radius: 12px; padding: 9px 10px; border: 1px solid var(--line); }
.stat b { display: block; font-size: 19px; font-weight: 800; }
.stat span { color: var(--muted); font-size: 11px; }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.seg { display: flex; background: var(--card); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 12px; border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; font-weight: 600; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--green); color: var(--purple); }

/* ---------- Standings ---------- */
.table { background: var(--card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.thead, .row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 48px 50px 52px;
  align-items: center; gap: 6px; padding: 10px 12px;
}
.thead { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; background: var(--bg2); }
.thead > :nth-child(n+3), .row > :nth-child(n+3) { text-align: right; }
.row { border-top: 1px solid var(--line); cursor: pointer; }
.row:hover { background: rgba(255, 255, 255, 0.03); }
.row.me { background: rgba(4, 245, 255, 0.07); }
.rank { font-weight: 800; font-size: 16px; line-height: 1; }
.mv { display: block; font-size: 10px; font-weight: 700; margin-top: 3px; }
.mv.up { color: var(--up); } .mv.down { color: var(--down); } .mv.same { color: var(--muted); }
.team { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mgr { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: flex; gap: 6px; align-items: center; margin-top: 3px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.badge { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px; letter-spacing: 0.3px; }
.badge.chip { background: var(--pink); color: #fff; }
.badge.c { background: var(--gold); color: #2b1a00; }
.badge.hit { background: rgba(255, 84, 112, 0.18); color: var(--down); }
.num { font-weight: 700; font-variant-numeric: tabular-nums; }
.num.big { font-size: 17px; font-weight: 800; }
.num.hl { color: var(--green); }
.sub { display: block; font-size: 10px; color: var(--muted); font-weight: 500; }

/* ---------- Lineup ---------- */
.lineup { display: none; border-top: 1px dashed var(--line); background: var(--bg2); padding: 8px 12px 12px; }
.lineup.open { display: block; }
.lu-title { font-size: 11px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 8px 0 4px; letter-spacing: 0.4px; }
.pl { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto 38px; gap: 6px; align-items: center; padding: 5px 0; font-size: 13px; }
.pl .pos { font-size: 10px; font-weight: 700; color: var(--muted); }
.pl .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .nm small { color: var(--muted); margin-left: 4px; }
.pl .ic { display: flex; gap: 4px; font-size: 11px; color: var(--muted); }
.pl .pt { text-align: right; font-weight: 800; }
.pl.out { opacity: 0.45; }
.pl.live .pt { color: var(--pink); }
.pl.pend .pt { color: var(--muted); font-weight: 500; }
.tag { font-size: 10px; font-weight: 800; padding: 1px 5px; border-radius: 5px; }
.tag.c { background: var(--gold); color: #2b1a00; }
.tag.vc { background: var(--card2); color: var(--gold); border: 1px solid var(--gold); }
.tag.in { background: rgba(0, 230, 118, 0.18); color: var(--up); }
.tag.outt { background: rgba(255, 84, 112, 0.18); color: var(--down); }
.tag.pb { background: rgba(4, 245, 255, 0.16); color: var(--cyan); }

/* ---------- Summary ---------- */
.sum-bar { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.sum-actions { display: flex; gap: 8px; }
.primary, .ghost { border-radius: 10px; padding: 8px 14px; font-weight: 700; font-size: 13px; cursor: pointer; border: 1px solid transparent; }
.primary { background: var(--green); color: var(--purple); }
.ghost { background: transparent; border-color: var(--line); color: var(--text); }

.card { background: linear-gradient(180deg, #34003c 0%, #22002a 100%); border-radius: 18px; overflow: hidden; border: 1px solid rgba(0, 255, 135, 0.18); }
.card-head { padding: 18px 18px 16px; background: linear-gradient(120deg, var(--green) 0%, var(--cyan) 100%); color: var(--purple); position: relative; }
.card-head .k { font-size: 12px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; opacity: 0.8; }
.card-head .t { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; line-height: 1.1; margin-top: 2px; }
.card-head .d { font-size: 12px; font-weight: 600; margin-top: 6px; opacity: 0.8; }
.card-head .gwbig { position: absolute; right: 16px; top: 8px; font-size: 64px; font-weight: 800; letter-spacing: -3px; opacity: 0.22; }
.blk { padding: 14px 18px; border-top: 1px solid var(--line); }
.blk-t { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.8px; color: var(--green); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.hero { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero > div { background: rgba(255, 255, 255, 0.05); border-radius: 12px; padding: 12px; }
.hero .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: 0.4px; }
.hero .who { font-size: 17px; font-weight: 800; margin-top: 4px; line-height: 1.2; }
.hero .pts { font-size: 30px; font-weight: 800; line-height: 1; margin-top: 6px; }
.hero .king .pts { color: var(--gold); }
.hero .last .pts { color: var(--down); }
.hero .ex { font-size: 11px; color: var(--muted); margin-top: 4px; }
.tie { font-size: 11px; color: var(--gold); margin-top: 8px; }
.kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpi div { text-align: center; background: rgba(255, 255, 255, 0.04); border-radius: 10px; padding: 8px 4px; }
.kpi b { display: block; font-size: 20px; font-weight: 800; }
.kpi span { font-size: 11px; color: var(--muted); }
.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini td { padding: 5px 2px; border-bottom: 1px solid var(--line); }
.mini tr:last-child td { border-bottom: 0; }
.mini td.r { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini td.p { width: 26px; color: var(--muted); font-weight: 700; }
.mini td.mvc { width: 34px; font-size: 11px; font-weight: 700; text-align: right; }
.mini .first td { color: var(--gold); }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 14px; }
.line span:last-child { font-weight: 700; text-align: right; }
.line .m { color: var(--muted); font-weight: 500; }
.chips-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-list span { background: rgba(255, 40, 130, 0.15); color: #ffd1e3; border-radius: 8px; padding: 4px 8px; font-size: 12px; font-weight: 600; }
.card-foot { padding: 12px 18px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; border-top: 1px solid var(--line); }
.empty { background: var(--card); border-radius: var(--radius); padding: 28px 18px; text-align: center; color: var(--muted); border: 1px solid var(--line); }

/* ---------- Chips view ---------- */
.chiprow { background: var(--card); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; border: 1px solid var(--line); }
.chiprow .team { font-size: 14px; }
.chiprow .chips-list { margin-top: 6px; }
.chiprow .none { color: var(--muted); font-size: 12px; }

/* ---------- Bottom tabs ---------- */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: rgba(27, 0, 32, 0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px 9px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.on { color: var(--green); }

/* ---------- Misc ---------- */
.install { max-width: 760px; margin: 10px auto 0; padding: 10px 14px; background: rgba(4, 245, 255, 0.1); border: 1px solid rgba(4, 245, 255, 0.3); border-radius: 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; justify-content: space-between; width: calc(100% - 32px); }
.install[hidden] { display: none; }
.install button { border: 0; background: var(--cyan); color: var(--purple); font-weight: 700; border-radius: 8px; padding: 6px 10px; cursor: pointer; flex: none; }
.install .x { background: transparent; color: var(--muted); padding: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); background: #fff; color: var(--purple); font-weight: 700; padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 20; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4); }
.skel { height: 54px; border-top: 1px solid var(--line); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
