/* Layout: one phone-width column; a green "field" header with yard lines, game cards below,
   a sticky submit bar at the bottom. Pylon orange is the one accent. */
:root {
  --bg: #f2f5f1;
  --surface: #ffffff;
  --surface-2: #e8eee8;
  --ink: #142019;
  --muted: #56665c;
  --line: #d4ddd5;
  --field: #123b25;
  --field-2: #0d2e1c;
  --chalk: #f7faf6;
  --accent: #e8590c;
  --accent-ink: #ffffff;
  --win: #18794a;
  --win-bg: #def3e6;
  --loss: #b42d1e;
  --loss-bg: #fbe3df;
  --shadow: 0 1px 2px rgba(18, 40, 26, .08), 0 4px 14px rgba(18, 40, 26, .06);
  --font-display: "Saira Condensed", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c140f; --surface: #15211a; --surface-2: #1c2a22; --ink: #ecf2ed; --muted: #9db0a3;
    --line: #2a3b31; --field: #0b2717; --field-2: #081d11; --chalk: #f1f6f2; --accent: #ff7b2f;
    --accent-ink: #1a0d04; --win: #5fd394; --win-bg: #143423; --loss: #ff8a78; --loss-bg: #3a1813;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c140f; --surface: #15211a; --surface-2: #1c2a22; --ink: #ecf2ed; --muted: #9db0a3;
  --line: #2a3b31; --field: #0b2717; --field-2: #081d11; --chalk: #f1f6f2; --accent: #ff7b2f;
  --accent-ink: #1a0d04; --win: #5fd394; --win-bg: #143423; --loss: #ff8a78; --loss-bg: #3a1813;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 18px/1.45 var(--font-body);
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}
button { font: inherit; color: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap {
  max-width: 640px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 24px;
}

/* header */
.top {
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(10% - 2px), rgba(255,255,255,.07) calc(10% - 2px) 10%),
    linear-gradient(180deg, var(--field), var(--field-2));
  color: var(--chalk);
  padding-top: env(safe-area-inset-top, 0px);
  position: sticky; top: 0; z-index: 5;
}
.top-inner, .tabs {
  max-width: 640px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px 8px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark { width: 14px; height: 40px; border-radius: 3px; background: var(--accent); flex: none; box-shadow: inset 0 -10px 0 rgba(0,0,0,.18); }
.brand h1 { margin: 0; white-space: nowrap; font: 800 clamp(22px, 6.6vw, 28px)/1 var(--font-display); letter-spacing: .02em; text-transform: uppercase; }
.brand-sub { margin: 2px 0 0; font-size: 14px; opacity: .8; letter-spacing: .04em; }
.who {
  flex: none; border: 2px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08);
  border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 16px; color: var(--chalk); cursor: pointer;
  min-height: 44px;
}
.tabs { display: flex; gap: 4px; padding-block: 0 0; }
.tab {
  flex: 1; background: none; border: 0; border-bottom: 4px solid transparent; color: var(--chalk);
  font: 600 20px/1 var(--font-display); text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 8px 10px; cursor: pointer; opacity: .75; min-height: 48px;
}
.tab[aria-current="page"] { opacity: 1; border-bottom-color: var(--accent); }

.loading { color: var(--muted); text-align: center; padding: 48px 0; }

/* week navigation */
.weeknav { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; gap: 8px; margin-bottom: 10px; }
.weeknav button {
  height: 56px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  font-size: 26px; cursor: pointer; box-shadow: var(--shadow);
}
.weeknav button:disabled { opacity: .35; cursor: default; }
.weeknav-title { text-align: center; }
.weeknav-title h2 { margin: 0; font: 800 34px/1 var(--font-display); text-transform: uppercase; letter-spacing: .02em; }
.weeknav-title p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.weekstrip { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 8px; scrollbar-width: thin; }
.weekchip {
  flex: none; min-width: 44px; height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font: 600 18px/1 var(--font-display); cursor: pointer; font-variant-numeric: tabular-nums;
}
.weekchip.is-now { border-color: var(--accent); }
.weekchip[aria-current="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* banners */
.banner { border-radius: var(--radius); padding: 12px 14px; margin: 0 0 14px; font-size: 16px; background: var(--surface-2); }
.banner strong { display: block; font-size: 17px; }
.banner.backfill { border-left: 6px solid var(--accent); }

/* week scoreboard */
.board {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px;
}
.board-cell {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 8px;
  text-align: center; box-shadow: var(--shadow); position: relative; min-width: 0;
}
.board-cell.is-top { border: 2px solid var(--accent); }
.board-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-rec { font: 800 32px/1.05 var(--font-display); font-variant-numeric: tabular-nums; }
.board-note { font-size: 13px; color: var(--muted); }
.board-note.win { color: var(--accent); font-weight: 700; }

/* games */
.day { margin: 18px 0 8px; font: 600 18px/1 var(--font-display); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.game {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px; margin-bottom: 12px;
}
.game-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); margin: 0 2px 8px; }
.game-meta .state { font-weight: 700; }
.state.final { color: var(--ink); }
.state.locked { color: var(--muted); }
.matchup { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr); align-items: stretch; gap: 6px; }
.at { align-self: center; text-align: center; font: 600 16px/1 var(--font-display); color: var(--muted); text-transform: uppercase; }
.team {
  --tc: #555;
  position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  min-height: 88px; padding: 10px 10px 10px 18px; border-radius: 12px; text-align: left;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; min-width: 0; overflow: hidden;
}
.team::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 8px; background: var(--tc); }
.team .city { font-size: 14px; color: var(--muted); line-height: 1.1; }
.team .nick { font: 800 clamp(17px, 5.4vw, 24px)/1.05 var(--font-display); text-transform: uppercase; letter-spacing: 0; overflow-wrap: normal; word-break: keep-all; max-width: 100%; }
.team .score { font: 800 26px/1 var(--font-display); font-variant-numeric: tabular-nums; margin-top: 4px; }
.team .mark { align-self: flex-start; order: -1; margin-bottom: 4px; font-size: 13px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.team.is-picked { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, var(--surface)); box-shadow: inset 0 0 0 1px var(--tc); }
.team.is-picked .mark { background: var(--tc); color: #fff; }
.team.is-winner .nick::after { content: " ★"; color: var(--accent); }
.team.is-loser { opacity: .62; }
.team:disabled { cursor: default; }
.team.is-picked.right .mark { background: var(--win); }
.team.is-picked.wrong .mark { background: var(--loss); }

.others { margin: 10px 2px 0; display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 15px; }
.other { display: inline-flex; gap: 6px; align-items: baseline; }
.other b { font-weight: 700; }
.other .r { font-weight: 700; padding: 0 6px; border-radius: 6px; }
.other .r.right { color: var(--win); background: var(--win-bg); }
.other .r.wrong { color: var(--loss); background: var(--loss-bg); }
.other .muted { color: var(--muted); }

.admin { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.admin button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 6px 10px; cursor: pointer; min-height: 36px; }
.admin button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* save bar */
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.08);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.savebar-inner {
  max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 10px;
}
.save-status { margin: 0; flex: 1; font-size: 15px; color: var(--muted); min-width: 0; }
.save-status strong { color: var(--ink); }
.save-btn {
  flex: none; min-height: 56px; padding: 0 22px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); font: 800 22px/1 var(--font-display); text-transform: uppercase; letter-spacing: .04em;
}
.save-btn:disabled { background: var(--surface-2); color: var(--muted); cursor: default; }

/* chooser */
.chooser { position: fixed; inset: 0; z-index: 20; background: rgba(8, 20, 12, .72); display: grid; place-items: center; padding: 16px; }
.chooser-card { width: min(440px, 100%); background: var(--surface); border-radius: 20px; padding: 24px 20px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.chooser-card h2 { margin: 0; font: 800 36px/1 var(--font-display); text-transform: uppercase; }
.chooser-card p { margin: 8px 0 18px; color: var(--muted); }
.chooser-list { display: grid; gap: 12px; }
.chooser-list button {
  min-height: 72px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface-2);
  font: 800 30px/1 var(--font-display); text-transform: uppercase; letter-spacing: .03em; cursor: pointer;
}
.chooser-list button:hover { border-color: var(--accent); }

/* standings */
.section-title { margin: 8px 0 12px; font: 800 30px/1 var(--font-display); text-transform: uppercase; }
.standings { display: grid; gap: 10px; margin-bottom: 26px; }
.stand {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow);
}
.stand .rank { font: 800 34px/1 var(--font-display); color: var(--muted); text-align: center; }
.stand.first .rank { color: var(--accent); }
.stand .name { font-weight: 700; font-size: 20px; }
.stand .sub { font-size: 14px; color: var(--muted); }
.stand .rec { font: 800 34px/1 var(--font-display); font-variant-numeric: tabular-nums; text-align: right; }
.stand .pct { font-size: 14px; color: var(--muted); text-align: right; }

.grid-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
table.weeks { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 17px; }
table.weeks th, table.weeks td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.weeks th { font: 600 15px/1.2 var(--font-display); text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
table.weeks tr:last-child td { border-bottom: 0; }
table.weeks td:first-child, table.weeks th:first-child { text-align: left; }
table.weeks .wk { background: none; border: 0; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; color: var(--ink); }
table.weeks .lead { font-weight: 700; color: var(--accent); }
table.weeks .none { color: var(--muted); }

.rules { margin-top: 26px; font-size: 15px; color: var(--muted); }
.rules h3 { color: var(--ink); font: 600 20px/1 var(--font-display); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 8px; }
.rules ul { margin: 0; padding-left: 20px; }

.commish { margin-top: 26px; padding: 14px; border-radius: var(--radius); background: var(--surface-2); font-size: 15px; }
.commish summary { cursor: pointer; font-weight: 700; color: var(--ink); min-height: 32px; }
.commish form { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.commish input { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); width: 140px; }
.commish button { border: 0; border-radius: 10px; padding: 8px 14px; background: var(--ink); color: var(--bg); font-weight: 700; cursor: pointer; min-height: 44px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(92px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

@media (min-width: 560px) {
  .team .nick { font-size: 28px; }
}
@media (prefers-reduced-motion: no-preference) {
  .team { transition: background-color .15s, border-color .15s; }
}

/* tiebreaker */
.tb { background: var(--surface); border: 2px dashed var(--accent); border-radius: var(--radius); padding: 14px; margin: 4px 0 16px; }
.tb h3 { margin: 0; font: 800 22px/1 var(--font-display); text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.tb p { margin: 6px 0 10px; font-size: 16px; }
.tb-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tb-step { width: 52px; height: 56px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); font-size: 28px; cursor: pointer; }
.tb-step:disabled { opacity: .4; cursor: default; }
.tb-input {
  width: 96px; height: 56px; text-align: center; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface); color: var(--ink); font: 800 30px/1 var(--font-display); font-variant-numeric: tabular-nums;
}
.tb-note { font-size: 14px; color: var(--muted); }
.admin input { width: 64px; font: inherit; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
