:root {
  --bg: #e6ebf2;
  --text: #2a3343;
  --muted: #7d889b;
  --faint: #a7b0bf;
  --light: #ffffff;
  --dark: #c2c9d6;
  --accent: #1f9d68;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 157, 104, .12);
  --danger: #e5484d;
  --warn: #e39a12;
  --info: #3b82f6;
  --sh: 7px 7px 16px var(--dark), -7px -7px 16px var(--light);
  --sh-sm: 4px 4px 9px var(--dark), -4px -4px 9px var(--light);
  --sh-xs: 2px 2px 5px var(--dark), -2px -2px 5px var(--light);
  --in: inset 4px 4px 9px var(--dark), inset -4px -4px 9px var(--light);
  --in-sm: inset 2px 2px 5px var(--dark), inset -2px -2px 5px var(--light);
  --r: 22px;
  --r-sm: 14px;
  --tab-h: 74px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #262b33; --text: #e7ebf2; --muted: #98a2b3; --faint: #6b7586;
    --light: #313741; --dark: #1b1f25; --accent: #34c48a; --accent-ink: #0e2a1e; --accent-soft: rgba(52, 196, 138, .14);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; user-select: none; -webkit-user-select: none; }
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- app shell ---------- */
#app { max-width: 480px; margin: 0 auto; min-height: 100dvh; position: relative; }
.page { padding: calc(var(--safe-t) + 10px) 18px calc(var(--tab-h) + var(--safe-b) + 28px); animation: pageIn .22s ease; }
.page.no-tabs { padding-bottom: calc(var(--safe-b) + 28px); }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 52px; margin-bottom: 6px; }
.topbar .title { flex: 1; font-size: 17px; font-weight: 650; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.largetitle { font-size: 31px; font-weight: 750; letter-spacing: -.02em; margin: 2px 0 18px; }
.eyebrow { font-size: 13px; color: var(--muted); font-weight: 500; }
.section-h { display: flex; align-items: center; justify-content: space-between; margin: 26px 4px 12px; }
.section-h h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.section-h a, .section-h button { font-size: 14px; color: var(--accent); font-weight: 600; }

.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; box-shadow: var(--sh-sm); flex: none; background: var(--bg); }
.icon-btn:active { box-shadow: var(--in-sm); }
.icon-btn svg { width: 20px; height: 20px; }
.spacer { width: 42px; flex: none; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + var(--safe-b)); width: calc(100% - 24px); max-width: 456px;
  height: 64px; border-radius: 26px; background: var(--bg); box-shadow: var(--sh); display: flex; justify-content: space-around; align-items: center; z-index: 20; padding: 0 6px;
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--faint); padding: 7px 0; border-radius: 18px; transition: color .15s; }
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on .tab-ic { box-shadow: var(--in-sm); }
.tab-ic { width: 44px; height: 30px; border-radius: 12px; display: grid; place-items: center; transition: box-shadow .2s; }

/* ---------- surfaces ---------- */
.card { background: var(--bg); border-radius: var(--r); box-shadow: var(--sh); padding: 18px; }
.card + .card { margin-top: 16px; }
.card.tap:active { box-shadow: var(--sh-xs); transform: scale(.995); }
.well { border-radius: var(--r-sm); box-shadow: var(--in); padding: 14px; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.bold { font-weight: 650; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { text-align: center; }
.mt { margin-top: 14px; } .mt2 { margin-top: 22px; } .mb { margin-bottom: 14px; }
.hr { height: 1px; background: linear-gradient(90deg, transparent, var(--dark), transparent); margin: 14px 0; opacity: .7; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 50px; padding: 0 22px; border-radius: 16px;
  background: var(--bg); box-shadow: var(--sh-sm); font-weight: 650; font-size: 15px; transition: box-shadow .12s, transform .12s;
}
.btn:active { box-shadow: var(--in-sm); transform: scale(.98); }
.btn.block { display: flex; width: 100%; }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 5px 5px 12px var(--dark), -5px -5px 12px var(--light), inset 1px 1px 0 rgba(255,255,255,.25); }
.btn.primary:active { box-shadow: inset 3px 3px 8px rgba(0,0,0,.2); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.fab {
  position: fixed; right: max(20px, calc(50% - 240px + 20px)); bottom: calc(var(--tab-h) + var(--safe-b) + 18px); width: 58px; height: 58px; border-radius: 20px;
  background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 6px 6px 16px var(--dark), -6px -6px 16px var(--light); z-index: 15;
}
.fab:active { transform: scale(.94); }
.fab svg { width: 26px; height: 26px; }

/* ---------- segmented ---------- */
.seg { display: flex; padding: 5px; border-radius: 16px; box-shadow: var(--in); gap: 4px; }
.seg button { flex: 1; height: 38px; border-radius: 12px; font-size: 13.5px; font-weight: 600; color: var(--muted); transition: all .15s; }
.seg button.on { background: var(--bg); color: var(--text); box-shadow: var(--sh-xs); }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { height: 38px; padding: 0 15px; border-radius: 13px; box-shadow: var(--sh-xs); font-size: 14px; font-weight: 550; display: inline-flex; align-items: center; gap: 7px; background: var(--bg); }
.chip.on { box-shadow: var(--in-sm); color: var(--accent); font-weight: 700; }
.chip[disabled] { opacity: .4; pointer-events: none; }
.chip .dot { width: 8px; height: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; box-shadow: var(--in-sm); color: var(--muted); }
.pill.live { color: var(--danger); }
.pill.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: pulse 1.4s infinite; }
.pill.green { color: var(--accent); }
.pill.warn { color: var(--warn); }
@keyframes pulse { 50% { opacity: .25; } }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- forms ---------- */
.field { display: block; }
.field > span { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 4px 8px; }
.input { width: 100%; height: 52px; border: 0; outline: 0; border-radius: 16px; background: var(--bg); box-shadow: var(--in); padding: 0 18px; font-size: 16px; }
.input::placeholder { color: var(--faint); }
.search { position: relative; }
.search svg { position: absolute; left: 16px; top: 16px; width: 20px; height: 20px; color: var(--faint); }
.search .input { padding-left: 46px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 40px; height: 40px; border-radius: 13px; box-shadow: var(--sh-xs); font-size: 20px; font-weight: 600; }
.stepper button:active { box-shadow: var(--in-sm); }
.stepper b { min-width: 34px; text-align: center; font-size: 18px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 2px; }
.setting + .setting { border-top: 1px solid color-mix(in srgb, var(--dark) 55%, transparent); }
.setting .lbl { font-weight: 600; }
.setting .sub { font-size: 12.5px; color: var(--muted); }
.switch { width: 54px; height: 32px; border-radius: 99px; box-shadow: var(--in-sm); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: var(--bg); box-shadow: var(--sh-xs); transition: transform .2s; }
.switch.on { background: var(--accent-soft); }
.switch.on::after { transform: translateX(22px); background: var(--accent); }

/* ---------- list ---------- */
.list { border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.li { display: flex; align-items: center; gap: 14px; padding: 13px 16px; position: relative; }
.li + .li::before { content: ""; position: absolute; top: 0; left: 70px; right: 16px; height: 1px; background: var(--dark); opacity: .55; }
.li:active { background: color-mix(in srgb, var(--dark) 25%, transparent); }
.li .chev { color: var(--faint); width: 18px; height: 18px; flex: none; }
.li .check { width: 26px; height: 26px; border-radius: 9px; box-shadow: var(--in-sm); display: grid; place-items: center; flex: none; color: transparent; }
.li .check.on { color: var(--accent-ink); background: var(--accent); box-shadow: none; }
.li .check svg { width: 16px; height: 16px; }
.avatar { width: 42px; height: 42px; border-radius: 15px; display: grid; place-items: center; font-weight: 700; font-size: 15px; box-shadow: var(--sh-xs); flex: none; color: var(--av, var(--accent)); }
.avatar.lg { width: 92px; height: 92px; border-radius: 32px; font-size: 32px; box-shadow: var(--sh); }
.avatar.sm { width: 32px; height: 32px; border-radius: 11px; font-size: 12px; }

/* ---------- match cards ---------- */
.mcard .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; gap: 8px; }
.mcard .tline { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.mcard .tline .nm { flex: 1; font-weight: 600; min-width: 0; }
.mcard .tline .sc { font-weight: 700; font-size: 16px; }
.mcard .tline .ov { color: var(--muted); font-size: 12.5px; margin-left: 4px; font-weight: 500; }
.mcard .tline.dim .nm, .mcard .tline.dim .sc { color: var(--muted); font-weight: 550; }
.mcard .foot { margin-top: 10px; font-size: 13px; color: var(--accent); font-weight: 600; }
.mcard .foot.muted { color: var(--muted); }

/* ---------- score hero ---------- */
.hero { text-align: center; padding: 22px 18px; }
.hero .bt { font-size: 14px; color: var(--muted); font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.hero .big { font-size: 54px; font-weight: 780; letter-spacing: -.03em; line-height: 1.05; margin: 6px 0 2px; }
.hero .big small { font-size: 22px; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.hero .meta { display: flex; justify-content: center; gap: 18px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.hero .meta b { color: var(--text); font-weight: 700; }
.hero .eq { margin-top: 12px; font-weight: 650; color: var(--accent); font-size: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-grid.three { grid-template-columns: repeat(3, 1fr); }
.stat { border-radius: 16px; box-shadow: var(--sh-sm); padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; font-weight: 750; }
.stat span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- tables ---------- */
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; text-align: right; padding: 6px 4px; }
table.t td { padding: 9px 4px; text-align: right; border-top: 1px solid color-mix(in srgb, var(--dark) 55%, transparent); }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t td.nm { font-weight: 600; max-width: 150px; }
table.t td.nm .tiny { font-weight: 450; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.t tr.q td { color: var(--text); }
table.t tr.q td:first-child { box-shadow: inset 3px 0 0 var(--accent); padding-left: 8px; }
.striker::after { content: " *"; color: var(--accent); }

/* ---------- balls ---------- */
.balls { display: flex; flex-wrap: wrap; gap: 8px; }
.ball { min-width: 34px; height: 34px; padding: 0 6px; border-radius: 12px; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; box-shadow: var(--in-sm); color: var(--muted); }
.ball.b4 { color: var(--info); }
.ball.b6 { color: var(--accent); box-shadow: var(--sh-xs); }
.ball.bw { color: #fff; background: var(--danger); box-shadow: none; }
.ball.bx { color: var(--warn); }
.ball.empty { opacity: .35; }
.over-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; }
.over-row + .over-row { border-top: 1px solid color-mix(in srgb, var(--dark) 55%, transparent); }
.over-row .on { width: 46px; flex: none; }
.over-row .on b { display: block; font-size: 15px; }

/* ---------- scoring pad ---------- */
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; }
.key { height: 62px; border-radius: 19px; box-shadow: var(--sh-sm); font-size: 22px; font-weight: 750; display: grid; place-items: center; background: var(--bg); transition: box-shadow .08s, transform .08s; }
.key:active { box-shadow: var(--in-sm); transform: scale(.97); }
.key.sm { font-size: 14px; font-weight: 700; height: 52px; letter-spacing: .03em; }
.key.k4 { color: var(--info); }
.key.k6 { color: var(--accent); }
.key.kw { color: #fff; background: var(--danger); box-shadow: 4px 4px 10px var(--dark), -4px -4px 10px var(--light); }
.key.kx { color: var(--warn); }
.key.ghost { color: var(--muted); font-size: 13px; }
.key svg { width: 22px; height: 22px; }

/* ---------- sheets / toast ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(20, 26, 36, .35); z-index: 40; animation: fade .2s; backdrop-filter: blur(2px); }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: 100%; max-width: 480px; max-height: 88dvh; overflow: auto;
  background: var(--bg); border-radius: 28px 28px 0 0; z-index: 41; padding: 10px 20px calc(24px + var(--safe-b)); animation: up .26s cubic-bezier(.2,.9,.3,1);
  box-shadow: 0 -10px 30px rgba(0,0,0,.18);
}
.sheet .grab { width: 42px; height: 5px; border-radius: 9px; background: var(--dark); margin: 0 auto 14px; }
.sheet h2 { margin: 0 0 4px; font-size: 21px; }
.sheet .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
@keyframes up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes fade { from { opacity: 0; } }
.toast {
  position: fixed; bottom: calc(var(--tab-h) + var(--safe-b) + 22px); left: 50%; transform: translateX(-50%); z-index: 60; padding: 12px 18px; border-radius: 16px;
  background: var(--bg); box-shadow: var(--sh); font-weight: 600; font-size: 14px; max-width: calc(100% - 40px); animation: drop .25s;
}
.toast.err { color: var(--danger); }
@keyframes drop { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .ic { width: 72px; height: 72px; border-radius: 26px; box-shadow: var(--in); display: grid; place-items: center; margin: 0 auto 14px; color: var(--faint); }
.empty .ic svg { width: 32px; height: 32px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tile { border-radius: 20px; box-shadow: var(--sh-sm); padding: 16px 8px 12px; text-align: center; font-size: 12.5px; font-weight: 650; }
.tile:active { box-shadow: var(--in-sm); }
.tile .ic { width: 44px; height: 44px; border-radius: 15px; margin: 0 auto 8px; display: grid; place-items: center; box-shadow: var(--in-sm); color: var(--accent); }
.tile .ic svg { width: 22px; height: 22px; }
.banner { display: flex; align-items: center; gap: 14px; }
.banner .ic { width: 50px; height: 50px; border-radius: 17px; display: grid; place-items: center; box-shadow: var(--in-sm); color: var(--warn); flex: none; }
.banner .ic svg { width: 26px; height: 26px; }
.leader { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.leader .rank { width: 22px; color: var(--faint); font-weight: 700; font-size: 13px; }
.leader .val { font-weight: 750; font-size: 17px; }
.hscroll { display: flex; gap: 14px; overflow-x: auto; margin: 0 -18px; padding: 6px 18px 18px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex: 0 0 84%; }
.teamcol { border-radius: 18px; box-shadow: var(--sh-sm); padding: 12px; }
.teamcol + .teamcol { margin-top: 14px; }
.loading { display: grid; place-items: center; height: 70dvh; color: var(--muted); }
.spin { width: 34px; height: 34px; border-radius: 50%; box-shadow: var(--in-sm); border-top: 3px solid var(--accent); animation: rot .9s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

@media (min-width: 520px) {
  body { background: color-mix(in srgb, var(--bg) 92%, #000); }
  #app { background: var(--bg); box-shadow: 0 0 40px rgba(0,0,0,.08); }
}
