:root {
  --night: #2b1747;        /* header: grape */
  --night-deep: #1d0f33;
  --jelly: #c7469a;        /* accent: jelly */
  --jelly-soft: #f7e3f0;
  --gold: #f4b740;         /* winners, locked */
  --paper: #f6f4f8;
  --surface: #ffffff;
  --ink: #1d1726;
  --ink-soft: #5f566b;
  --rule: #e2dce8;
  --win: #18794e;
  --lose: #c0352b;
  --warn: #9a5b00;
  --radius-s: 8px;
  --radius-m: 12px;
  --cond: 'Archivo Narrow', 'Arial Narrow', sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #120c1b;
    --surface: #1c1428;
    --ink: #efe9f6;
    --ink-soft: #a99db8;
    --rule: #2f2440;
    --jelly-soft: #3a1d33;
    --win: #4cc38a;
    --lose: #ff7a6e;
    --warn: #f0b35a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
a { color: var(--jelly); }
button, input, select { font: inherit; }
.muted { color: var(--ink-soft); }
.pad { padding: 16px; }
.small { font-size: 13px; }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: var(--night); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); flex-wrap: wrap; }
.brand { font: 700 22px/1 var(--cond); color: #fff; text-decoration: none; letter-spacing: .3px; }
.brand span { color: var(--gold); }
.tabs { display: flex; gap: 4px; order: 3; width: 100%; overflow-x: auto; }
.tabs a { color: #d9cdea; text-decoration: none; font: 600 15px/1 var(--cond); text-transform: uppercase; letter-spacing: .6px; padding: 9px 12px; border-radius: 999px; white-space: nowrap; }
.tabs a.on { background: rgba(255,255,255,.14); color: #fff; }
.acct { margin-left: auto; color: #d9cdea; font-size: 14px; text-decoration: none; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 720px) { .tabs { order: 0; width: auto; } }
@media (max-width: 420px) { .tabs { gap: 0; justify-content: space-between; } .tabs a { padding: 9px 8px; font-size: 14px; letter-spacing: .3px; } }

main { max-width: 720px; margin: 0 auto; padding: 12px 16px 80px; }
h1 { font: 700 26px/1.15 var(--cond); margin: 8px 0 4px; }
h2 { font: 700 18px/1.2 var(--cond); text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); margin: 22px 0 8px; }

/* forms */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 16px; }
form.card { display: grid; gap: 12px; max-width: 420px; margin: 16px auto; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; }
input { padding: 12px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--paper); color: var(--ink); font-size: 16px; }
.btn { appearance: none; border: 0; border-radius: var(--radius-s); background: var(--jelly); color: #fff; font-weight: 700; padding: 12px 16px; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--jelly); border: 1px solid var(--jelly); }
.btn:disabled { opacity: .5; cursor: default; }
.err { color: var(--lose); font-size: 14px; min-height: 1em; }

/* slate */
.summary { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; padding: 3px 8px; border-radius: 999px; background: var(--jelly-soft); color: var(--jelly); white-space: nowrap; }
.chip.gold { background: #fdf1d6; color: #7a5200; }
.chip.lock { background: var(--night); color: var(--gold); }
.chip.warn { background: #fdecd2; color: var(--warn); }
@media (prefers-color-scheme: dark) { .chip.gold { background: #3b2c0c; color: var(--gold); } .chip.warn { background: #3b2a10; } }
.filter { margin-left: auto; font-size: 14px; display: flex; gap: 6px; align-items: center; font-weight: 500; }
.day { font: 700 15px/1 var(--cond); text-transform: uppercase; letter-spacing: .8px; color: var(--ink-soft); margin: 20px 2px 8px; }
.game { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 12px; margin-bottom: 10px; }
.game.need { border-left: 4px solid var(--jelly); }
.ghead { display: flex; align-items: baseline; gap: 8px; }
.gname { font-weight: 700; font-size: 15px; flex: 1; min-width: 0; }
.gtime { font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0 8px; }
.side { appearance: none; border: 2px solid var(--rule); background: var(--paper); color: var(--ink); border-radius: var(--radius-s); padding: 10px 8px; text-align: left; cursor: pointer; min-height: 58px; display: grid; gap: 2px; }
.side .team { font-weight: 700; font-size: 15px; line-height: 1.2; }
.side .num { font: 700 18px/1 var(--cond); color: var(--ink-soft); }
.side.on { border-color: var(--jelly); background: var(--jelly-soft); }
.side.on .num { color: var(--jelly); }
.side:disabled { cursor: default; }
.side.covered { box-shadow: inset 0 0 0 2px var(--gold); }
.side .who { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.side .stake { font-size: 12px; font-weight: 600; }
.lineinfo { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); }
.lineinfo b { color: var(--ink); }
details.books { margin-top: 6px; font-size: 13px; color: var(--ink-soft); }
details.books summary { cursor: pointer; }
.booktbl { width: 100%; border-collapse: collapse; margin-top: 6px; table-layout: fixed; font-size: 12px; }
.booktbl td, .booktbl th { padding: 4px 2px; text-align: center; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.booktbl td:first-child, .booktbl th:first-child { width: 26%; }
.booktbl .t { display: block; font-size: 11px; white-space: nowrap; }
.booktbl th { font-weight: 600; font-size: 12px; }
.booktbl td:first-child, .booktbl th:first-child { text-align: left; }
.result { margin-top: 8px; font-size: 14px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.pos { color: var(--win); font-weight: 700; }
.neg { color: var(--lose); font-weight: 700; }
.nopick { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.empty { text-align: center; padding: 40px 16px; }

/* standings */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-m); overflow: hidden; border: 1px solid var(--rule); }
.tbl th, .tbl td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--rule); font-variant-numeric: tabular-nums; }
.tbl th { font: 600 12px/1 var(--body); text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); }
.tbl td.name, .tbl th.name { text-align: left; }
.tbl td.rank { color: var(--ink-soft); width: 28px; }
.tbl tr.me td { background: var(--jelly-soft); }
.tbl td.name { font-weight: 600; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl .badges { display: block; font-size: 12px; line-height: 1.2; }
.tbl .pct { display: block; font-size: 12px; color: var(--ink-soft); }
@media (max-width: 420px) { .tbl th, .tbl td { padding: 9px 5px; } }

/* commissioner */
select { font: inherit; font-size: 16px; padding: 11px 10px; border: 1px solid var(--rule); border-radius: var(--radius-s); background: var(--paper); color: var(--ink); width: 100%; }
.card.adm { display: grid; gap: 10px; margin: 12px 0; }
.card.adm h2 { margin: 0; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.row label, .row input { min-width: 0; width: 100%; }
.row .btn { width: 100%; }
details.act { border-top: 1px solid var(--rule); padding-top: 8px; }
details.act summary { font-weight: 600; cursor: pointer; padding: 6px 0; }
details.act form { display: grid; gap: 10px; padding: 8px 0 4px; }
.btn.danger { background: var(--lose); }
ul.pays, ul.log { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pay { display: flex; flex-direction: row; gap: 10px; align-items: center; font-weight: 400; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 10px; }
.pay input { width: 22px; height: 22px; flex: none; }
ul.log li { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-s); padding: 10px 12px; display: grid; gap: 2px; }

/* rules */
.rules ol { padding-left: 22px; }
.rules li { margin-bottom: 8px; }

#toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--night); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }
