:root {
  --navy: #1F2A44;
  --navy-2: #2c3a5c;
  --bg: #f4f5f8;
  --card: #ffffff;
  --text: #1b2130;
  --muted: #5d6578;
  --line: #dfe2ea;
  --accent: #2557d6;
  --accent-soft: #e6edfc;
  --win: #1d7f45;
  --win-soft: #def3e6;
  --loss: #b3261e;
  --loss-soft: #fbe3e1;
  --push: #6b6f7a;
  --push-soft: #eceef2;
  --dog: #a86b00;
  --dog-soft: #fff1cc;
  --solo: #c2410c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 2px 8px rgba(20, 30, 60, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1420; --card: #182033; --text: #e7eaf2; --muted: #9aa3b8; --line: #2a3450;
    --accent: #7ea2ff; --accent-soft: #22305a; --win: #5fd08f; --win-soft: #173a29; --loss: #ff8a80; --loss-soft: #4a1f1f;
    --push: #b5bac6; --push-soft: #2a3040; --dog: #f2c14e; --dog-soft: #3d3216; --solo: #ff9a5c;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1420; --card: #182033; --text: #e7eaf2; --muted: #9aa3b8; --line: #2a3450;
  --accent: #7ea2ff; --accent-soft: #22305a; --win: #5fd08f; --win-soft: #173a29; --loss: #ff8a80; --loss-soft: #4a1f1f;
  --push: #b5bac6; --push-soft: #2a3040; --dog: #f2c14e; --dog-soft: #3d3216; --solo: #ff9a5c;
  --shadow: none; color-scheme: dark;
}

* { 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, Arial, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
h3 { font-size: 15px; }

/* header */
.top { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; font-size: 17px; }
.who { font-size: 13px; opacity: .85; text-align: right; }
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  color: #cfd6e8; text-decoration: none; padding: 8px 12px 10px; font-weight: 600; font-size: 14px;
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a.on { color: #fff; border-bottom-color: #f2c14e; }
main { padding-top: 16px; padding-bottom: 24px; min-height: 60vh; }
.foot { color: var(--muted); font-size: 12.5px; padding-bottom: 32px; }

/* week header */
.week-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.week-nav { display: flex; align-items: center; gap: 6px; }
.week-nav select { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.btn {
  font: inherit; font-weight: 600; font-size: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 9px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--loss); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.icon { padding: 6px 10px; }
.pillbar { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.pill {
  font: inherit; font-size: 13px; font-weight: 600; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); cursor: pointer;
}
.pill.on { background: var(--navy); color: #fff; border-color: var(--navy); }
:root[data-theme="dark"] .pill.on { background: var(--accent); border-color: var(--accent); color: #0f1420; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.on { background: var(--accent); border-color: var(--accent); color: #0f1420; } }

.banner { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); border-radius: var(--radius); padding: 12px 14px; margin: 12px 0; }
.banner.warn { background: var(--dog-soft); border-color: color-mix(in srgb, var(--dog) 35%, transparent); }
.progress { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; font-size: 14px; }
.bar { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* game cards */
.day { margin: 18px 0 8px; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.games { display: grid; gap: 10px; }
.game { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; }
.game-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.game-meta .lock { font-weight: 600; }
.game-meta .live { color: var(--loss); font-weight: 700; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side {
  font: inherit; text-align: left; border: 2px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 10px; padding: 9px 10px; cursor: pointer; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px;
  min-height: 58px;
}
.side .code { font-weight: 800; font-size: 17px; letter-spacing: .01em; }
.side .name { grid-column: 1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .spread { grid-row: 1 / span 2; grid-column: 2; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.side .score { grid-row: 1 / span 2; grid-column: 2; font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.side:not(:disabled):hover { border-color: var(--accent); }
.side.mine { border-color: var(--accent); background: var(--accent-soft); }
.side.mine.win { border-color: var(--win); background: var(--win-soft); }
.side.mine.loss { border-color: var(--loss); background: var(--loss-soft); }
.side.mine.push { border-color: var(--push); background: var(--push-soft); }
.side:disabled { cursor: default; }
.side.covered .code::after { content: " ✓"; color: var(--win); }
.tag { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 6px; vertical-align: 1px; }
.tag.dog { background: var(--dog-soft); color: var(--dog); }
.tag.win { background: var(--win-soft); color: var(--win); }
.tag.loss { background: var(--loss-soft); color: var(--loss); }
.tag.push { background: var(--push-soft); color: var(--push); }
.tag.solo { background: color-mix(in srgb, var(--solo) 15%, transparent); color: var(--solo); }
.who-picked { margin-top: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.who-picked .col { display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; }
.chip { border-radius: 99px; padding: 2px 8px; background: var(--push-soft); font-size: 12.5px; font-weight: 600; }
.chip.win { background: var(--win-soft); color: var(--win); }
.chip.loss { background: var(--loss-soft); color: var(--loss); }
.chip.me { outline: 2px solid var(--accent); outline-offset: -2px; }
.split { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; display: flex; margin-top: 8px; }
.split span { background: var(--navy-2); }
:root[data-theme="dark"] .split span { background: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .split span { background: var(--accent); } }
.byes { font-size: 13.5px; margin: 14px 0; }

/* tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: color-mix(in srgb, var(--line) 35%, var(--card)); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.c, th.c { text-align: center; }
.sticky-col { position: sticky; left: 0; background: var(--card); z-index: 1; }
th.sticky-col { z-index: 2; background: color-mix(in srgb, var(--line) 35%, var(--card)); }
td.cell { text-align: center; font-weight: 700; font-size: 12.5px; }
td.cell.win { background: var(--win-soft); color: var(--win); }
td.cell.loss { background: var(--loss-soft); color: var(--loss); }
td.cell.push { background: var(--push-soft); color: var(--push); }
td.cell.solo { box-shadow: inset 0 0 0 2px var(--solo); }
td.cell.dogpick::after { content: "•"; color: var(--dog); margin-left: 2px; }
tr.leader td { font-weight: 700; }
.rank { color: var(--muted); width: 28px; }
td.best { font-weight: 800; color: var(--win); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat .v { font-size: 15px; font-weight: 700; margin-top: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--muted); margin: 8px 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* admin */
.admin-grid { display: grid; gap: 14px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select, textarea {
  font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text);
}
input[type=number] { width: 72px; }
input.team { width: 64px; text-transform: uppercase; }
table.edit td { padding: 4px 5px; }
table.edit input, table.edit select { padding: 4px 6px; font-size: 13px; }
.issues li { margin: 4px 0; }
.ok { color: var(--win); font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); z-index: 50; max-width: calc(100% - 32px);
}
.toast.bad { background: var(--loss); }
.linkbox { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; background: var(--push-soft); padding: 8px; border-radius: 8px; }
details summary { cursor: pointer; font-weight: 600; }

@media (max-width: 520px) {
  .side .name { display: none; }
  .side { min-height: 50px; }
  h1 { font-size: 20px; }
}
.admin-grid > * { min-width: 0; }
#pgrid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
@media (max-width: 520px) {
  .fullname { display: none; }
}
