:root {
  --bg: #f4f6f4;
  --card: #ffffff;
  --ink: #15201a;
  --muted: #5f6d65;
  --line: #e2e7e3;
  --brand: #0e5c3a;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1e9;
  --gold: #c9951f;
  --gold-soft: #fbf1d8;
  --win: #11813f;
  --loss: #c23b2e;
  --loss-soft: #fbe6e3;
  --push: #6b6f78;
  --pick: #f7f9f7;
  --shadow: 0 1px 2px rgba(20, 40, 30, .06), 0 2px 8px rgba(20, 40, 30, .05);
  --radius: 14px;
  --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1411;
    --card: #16201b;
    --ink: #e8efe9;
    --muted: #93a39a;
    --line: #26332c;
    --brand: #2fae6f;
    --brand-ink: #06140d;
    --brand-soft: #173526;
    --gold: #f0c35a;
    --gold-soft: #3a2f14;
    --win: #45c77f;
    --loss: #f07366;
    --loss-soft: #3b1d19;
    --push: #9aa0a8;
    --pick: #1b2721;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.4 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.splash { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- layout ---------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px calc(var(--nav-h) + 96px + env(safe-area-inset-bottom)); }
header.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--brand); color: var(--brand-ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
}
header.top .in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
header.top .league { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
header.top .league small { display: block; font-weight: 500; font-size: 12px; opacity: .8; }
header.top .bal { text-align: right; }
header.top .bal b { display: block; font-size: 20px; font-weight: 800; line-height: 1.1; }
header.top .bal span { font-size: 11px; opacity: .8; text-transform: uppercase; letter-spacing: .04em; }
header.top .me {
  width: 34px; height: 34px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.18); color: inherit; font-weight: 700;
}

nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs .in { max-width: 640px; margin: 0 auto; display: flex; }
nav.tabs button {
  flex: 1; height: var(--nav-h); border: 0; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
nav.tabs button svg { width: 22px; height: 22px; }
nav.tabs button.on { color: var(--brand); }

h2 { font-size: 20px; margin: 20px 0 10px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); }
.pad { padding: 14px; }

.seg { display: flex; background: var(--line); border-radius: 10px; padding: 3px; margin: 14px 0 10px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.btn {
  border: 0; border-radius: 10px; padding: 12px 16px; font-weight: 700;
  background: var(--brand); color: var(--brand-ink);
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.danger { background: var(--loss-soft); color: var(--loss); }
.btn.sm { padding: 7px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

input.field, select.field, textarea.field {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 16px;
}
label.lbl { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 6px; }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: 48px 20px; }
.auth .logo { width: 64px; height: 64px; }
.auth h1 { font-size: 28px; margin: 14px 0 4px; }
.auth p { color: var(--muted); margin: 0 0 20px; }

/* ---------- games ---------- */
.search { margin: 0 0 10px; }
.day { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.game { padding: 12px; margin-bottom: 10px; }
.game .when { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 8px; }
.game .when .live { color: var(--loss); font-weight: 700; }
.game .grid { display: grid; grid-template-columns: 1fr 88px 88px; gap: 6px; align-items: center; }
.game .grid .hd { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; text-transform: uppercase; }
.game .team { font-weight: 600; display: flex; justify-content: space-between; gap: 6px; min-width: 0; }
.game .team span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game .team .score { font-weight: 800; }
.pickbtn {
  border: 1px solid var(--line); background: var(--pick); border-radius: 9px;
  padding: 7px 4px; text-align: center; line-height: 1.15; min-height: 44px;
}
.pickbtn b { display: block; font-size: 14px; }
.pickbtn small { font-size: 12px; color: var(--muted); }
.pickbtn.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.pickbtn.on small { color: inherit; opacity: .85; }
.pickbtn:disabled { opacity: .45; cursor: default; }
.game .book { font-size: 11px; color: var(--muted); margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---------- slip ---------- */
.slipbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 25;
  padding: 0 16px 10px; pointer-events: none;
}
.slipbar button {
  pointer-events: auto; display: flex; width: 100%; max-width: 608px; margin: 0 auto;
  align-items: center; justify-content: space-between;
  background: var(--gold); color: #1c1403; border: 0; border-radius: 12px;
  padding: 13px 16px; font-weight: 800; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 88vh; overflow: auto; background: var(--bg);
  border-radius: 18px 18px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet .in { max-width: 608px; margin: 0 auto; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 8px; }
.sheet .head { display: flex; align-items: center; justify-content: space-between; }
.sheet .head h2 { margin: 8px 0; }
.x { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--muted); padding: 4px 8px; }
.leg { padding: 10px 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.leg .what { font-weight: 700; }
.leg .game-n { font-size: 12px; color: var(--muted); }
.leg input { width: 96px; padding: 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); text-align: right; font-size: 16px; }
.warn { background: var(--gold-soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin: 8px 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; font-weight: 600; font-size: 13px; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.summary { display: flex; justify-content: space-between; margin: 12px 0; font-size: 14px; }
.summary b { font-size: 18px; }
.stakebox { display: flex; gap: 8px; align-items: center; }
.stakebox input { flex: 1; }

/* ---------- board ---------- */
.lead { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.lead:last-child { border-bottom: 0; }
.lead .rk { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--line); flex: none; }
.lead.first .rk { background: var(--gold); color: #1c1403; }
.lead.you { background: var(--brand-soft); }
.lead .nm { font-weight: 700; }
.lead .nm .tag { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 5px; margin-left: 6px; vertical-align: 1px; }
.tag.bust { background: var(--loss-soft); color: var(--loss); }
.tag.you { background: var(--brand); color: var(--brand-ink); }
.lead .tot { text-align: right; }
.lead .tot b { font-size: 17px; display: block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 4px; }
.stat { padding: 12px; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat b { display: block; font-size: 18px; }

/* ---------- bets ---------- */
.bet { padding: 12px 14px; margin-bottom: 10px; }
.bet .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bet .kind { font-weight: 800; text-transform: capitalize; }
.bet .legs { margin: 8px 0 0; padding: 0; list-style: none; }
.bet .legs li > :last-child { white-space: nowrap; flex: none; }
.bet .legs li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-top: 1px dashed var(--line); font-size: 14px; }
.st { font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 6px; text-transform: uppercase; }
.st.won { background: var(--brand-soft); color: var(--win); }
.st.lost { background: var(--loss-soft); color: var(--loss); }
.st.push, .st.void { background: var(--line); color: var(--push); }
.st.pending { background: var(--gold-soft); color: var(--gold); }
.res-won { color: var(--win); font-weight: 700; }
.res-lost { color: var(--loss); font-weight: 700; }
.res-push, .res-void { color: var(--push); font-weight: 700; }

/* ---------- commish ---------- */
.list-item { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.code { font: 800 26px/1 ui-monospace, Menlo, monospace; letter-spacing: .12em; }
table.tt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tt th, table.tt td { padding: 4px; text-align: center; }
table.tt input { width: 100%; padding: 6px 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); text-align: center; font-size: 14px; }
.score-in { width: 58px !important; text-align: center; }

#toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -150%);
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 10px; z-index: 60;
  font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); transition: transform .25s;
}
#toast.show { transform: translate(-50%, 0); }
#toast.err { background: var(--loss); color: #fff; }

/* ---------- additions for sign-in, approvals ---------- */
.btn.google { background: var(--card); color: var(--ink); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; gap: 10px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 600; text-decoration: underline; }
nav.tabs button { position: relative; }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--loss); color: #fff; font: 700 11px/18px Inter, system-ui, sans-serif; font-style: normal; }
.notice { display: block; width: 100%; text-align: left; margin: 14px 0 0; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--gold-soft); color: var(--ink); font-weight: 700; }
.auth .card { text-align: left; }
.auth .row .field { min-width: 0; }
form.list-item { flex-wrap: wrap; }
form.list-item > .grow { flex: 1 1 100%; }
