:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --text: #16181d;
  --muted: #5d6573;
  --border: #dde1e7;
  --accent: #0b7a4b;
  --accent-text: #ffffff;
  --accent-soft: #e2f3ea;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --won: #0b7a4b;
  --lost: #b42318;
  --pending: #8a5a00;
  --pending-soft: #fff4dc;
  --epl: #3d195b;
  --nfl: #013369;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --surface-2: #242830;
    --text: #e8eaee;
    --muted: #9aa2b1;
    --border: #2e333c;
    --accent: #2fb57a;
    --accent-text: #06140d;
    --accent-soft: #15301f;
    --danger: #f07167;
    --danger-soft: #3a1c1a;
    --won: #4cc98f;
    --lost: #f07167;
    --pending: #f0b44c;
    --pending-soft: #33291a;
    --epl: #b48be0;
    --nfl: #7ea6e0;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 820px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 17px; margin-right: auto; }
.wallet { display: flex; gap: 16px; align-items: baseline; }
.wallet .label { font-size: 12px; color: var(--muted); display: block; }
.wallet .value { font-weight: 700; font-size: 17px; }
.link-btn {
  background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px;
  text-decoration: underline;
}
nav.tabs {
  max-width: 820px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 4px;
}
nav.tabs button {
  flex: 1; background: none; border: none; border-bottom: 3px solid transparent;
  padding: 10px 4px; cursor: pointer; color: var(--muted); font-weight: 600;
}
nav.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 820px; margin: 0 auto; padding: 16px; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; }
h2:first-child { margin-top: 4px; }

/* ---------- filters ---------- */
.filters { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; cursor: pointer; font-size: 13px;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; margin-bottom: 10px;
}
.game-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 5px; border: 1px solid currentColor;
}
.badge.epl { color: var(--epl); }
.badge.nfl { color: var(--nfl); }
.kickoff { font-size: 13px; color: var(--muted); }
.teams { font-weight: 600; margin-bottom: 10px; }

.odds-row { display: grid; gap: 8px; grid-template-columns: repeat(var(--cols, 2), 1fr); }
.odds-btn {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px;
  padding: 8px 6px; cursor: pointer; text-align: center; min-height: 52px;
  display: flex; flex-direction: column; justify-content: center;
}
.odds-btn .who { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odds-btn .price { font-weight: 700; font-size: 16px; }
.odds-btn:hover:not(:disabled) { border-color: var(--accent); }
.odds-btn.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.odds-btn.selected .who { color: inherit; }
.odds-btn:disabled { cursor: default; opacity: .55; }
.odds-btn.picked { opacity: 1; border: 2px solid var(--accent); background: var(--accent-soft); }

.slip {
  margin-top: 10px; padding: 10px; border-radius: 8px; background: var(--surface-2);
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
}
.slip .stake-wrap { position: relative; flex: 1 1 120px; }
.slip .stake-wrap span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.slip input { width: 100%; padding: 9px 10px 9px 24px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.slip .returns { flex: 1 1 140px; font-size: 13px; }
.slip .error { flex-basis: 100%; color: var(--danger); font-size: 13px; }

.btn {
  border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-weight: 600;
  background: var(--accent); color: var(--accent-text);
}
.btn:disabled { opacity: .6; cursor: default; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #fff; }

.others { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; font-size: 13px; }
.others div { display: flex; justify-content: space-between; gap: 8px; }
.mybet { margin-top: 10px; font-size: 14px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: none; }
.table-scroll { overflow-x: auto; }

/* ---------- bets list ---------- */
.bet-line { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.bet-line .left { min-width: 0; }
.bet-line .right { text-align: right; white-space: nowrap; }
.status { font-size: 12px; font-weight: 700; padding: 2px 7px; border-radius: 5px; display: inline-block; }
.status.pending { color: var(--pending); background: var(--pending-soft); }
.status.won { color: var(--won); background: var(--accent-soft); }
.status.lost { color: var(--lost); background: var(--danger-soft); }
.status.void { color: var(--muted); background: var(--surface-2); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  max-width: calc(100% - 32px); z-index: 20;
}

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.login-card input {
  width: 100%; padding: 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
}
.login-card .btn { width: 100%; margin-top: 16px; padding: 11px; }
.login-card .error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 1em; }

/* ---------- admin ---------- */
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select {
  padding: 7px 8px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); min-width: 0;
}
.inline-form input.amount { width: 90px; }
.inline-form input.score { width: 52px; }
.inline-form input.note { flex: 1 1 120px; }
.inline-form .btn { padding: 7px 12px; }

@media (max-width: 480px) {
  #leaderboard th, #leaderboard td { padding: 8px 5px; font-size: 13px; }
  #leaderboard th:first-child, #leaderboard td:first-child { padding-left: 10px; }
}
.nowrap { white-space: nowrap; }
@media (max-width: 480px) {
  #leaderboard .col-cash { display: none; }
}
