:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1c1b18;
  --muted: #6d6a62;
  --line: #e4e1d8;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --win: #b8860b;
  --warn: #b4401f;
  --soft: #e9f3ef;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #14130f; --card: #1f1d18; --ink: #f1efe8; --muted: #a29e92; --line: #38352d;
    --accent: #4fb89b; --accent-ink: #0d1a16; --win: #e3b341; --warn: #ef8a66; --soft: #1e2d28;
  }
}
:root[data-theme='dark'] {
  --bg: #14130f; --card: #1f1d18; --ink: #f1efe8; --muted: #a29e92; --line: #38352d;
  --accent: #4fb89b; --accent-ink: #0d1a16; --win: #e3b341; --warn: #ef8a66; --soft: #1e2d28;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 16px; padding-bottom: 96px; }
.wide main { max-width: 1280px; }
h1, h2, h3, h4 { margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; } h4 { font-size: .95rem; }
small, .muted { color: var(--muted); font-weight: 400; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; }
.hero { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.hero small { color: inherit; opacity: .85; }
.hero h2 { margin: 0; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; min-height: 44px;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--warn); border-color: var(--warn); }
button.big { width: 100%; padding: 16px; font-size: 1.1rem; }
button.win { background: var(--win); color: #1c1b18; border-color: var(--win); font-weight: 700; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.small { min-height: 34px; padding: 4px 10px; font-size: .9rem; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
input[type='checkbox'] { width: 22px; min-height: 22px; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.row > .fit { flex: 0 0 auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); gap: 8px; }
.picker button { text-align: left; }
.picker small { display: block; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: none; min-height: 56px; color: var(--muted); }
.tabs button[aria-selected='true'] { color: var(--accent); font-weight: 700; }
table.rank { width: 100%; border-collapse: collapse; }
table.rank th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 500; padding: 4px 6px; }
table.rank th.num { text-align: right; }
table.rank td { padding: 7px 6px; border-top: 1px solid var(--line); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.q td { background: var(--soft); }
.me { font-weight: 700; }
tr.me td { box-shadow: inset 0 0 0 1px var(--accent); }
.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.table { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--card); }
.table.done { border-color: var(--accent); }
.table.conflict { border-color: var(--warn); }
.table ul { list-style: none; margin: 0; padding: 0; }
.table li { display: flex; justify-content: space-between; padding: 3px 0; }
.table li.me span { color: var(--accent); }
.bracket { display: flex; gap: 14px; overflow-x: auto; }
.tour { min-width: 200px; flex: 1; }
.match { border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; margin-bottom: 8px; }
.side { display: flex; justify-content: space-between; padding: 2px 0; }
.side.won { color: var(--accent); font-weight: 700; }
.side.lost { color: var(--muted); text-decoration: line-through; }
.champion { text-align: center; font-size: 1.8rem; font-weight: 800; padding: 20px; background: var(--win); color: #1c1b18; border-radius: var(--radius); margin-bottom: 14px; }
.champion small { display: block; font-size: .9rem; font-weight: 500; color: inherit; }
.toast { position: fixed; left: 16px; right: 16px; top: 12px; max-width: 520px; margin: auto; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; z-index: 9; }
.toast.err { background: var(--warn); color: #fff; }
.pill { display: inline-block; font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--accent); }
.pill.warn { background: transparent; border: 1px solid var(--warn); color: var(--warn); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 40px; padding: 0; }
.stepper b { min-width: 28px; text-align: center; font-variant-numeric: tabular-nums; }
.bet { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.bet:first-of-type { border-top: 0; }
.odds { font-size: .85rem; color: var(--muted); }
.big-score { font-size: 2.4rem; font-weight: 800; text-align: center; margin: 6px 0; }
.admin-grid { display: grid; gap: 14px; }
.live-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.live-head h1 { font-size: 2rem; }
.wide .tables { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); font-size: 1.1rem; }
.cols { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 1000px) { .cols { grid-template-columns: 3fr 2fr; } }
