:root {
  color-scheme: dark;

  /* ---- Classic — the original NFL Picks palette (default) ---- */
  --bg: #0f1216;
  --panel: #171c22;
  --panel-2: #1e252d;
  --line: #2a323c;
  --text: #e8edf2;
  --muted: #94a1ad;
  --accent: #2fd27a;
  --accent-dim: #1c7a48;
  --accent-text: #05210f;
  --accent-wash: rgba(47, 210, 122, .12);
  --accent-wash-soft: rgba(47, 210, 122, .06);
  --gold: #f5c542;
  --wrong: #e5544b;
  --topbar-bg: linear-gradient(180deg, #1b222b, #12161c);
  --scrim: rgba(6, 9, 12, .82);
  --locked-head-bg: #221d12;

  --radius: 12px;
  font-synthesis: none;
}

/* ---- Lime — near-black neutral greys, one lime accent ---- */
:root[data-theme="lime"] {
  --bg: #121212;
  --panel: #1c1c1b;
  --panel-2: #242423;
  --line: #2b2b29;
  --text: #f2f2ef;
  --muted: #8f8f88;
  --accent: #b2ff66;
  --accent-dim: #5f8f3a;
  --accent-text: #0d1400;
  --accent-wash: rgba(178, 255, 102, .14);
  --accent-wash-soft: rgba(178, 255, 102, .07);
  --gold: #d9c14a;
  --wrong: #ff6b6a;
  --topbar-bg: linear-gradient(180deg, #242423, #161615);
  --scrim: rgba(8, 8, 7, .82);
  --locked-head-bg: #242320;
}

/* ---- Crimson — dark grey surfaces, red highlight ---- */
:root[data-theme="crimson"] {
  --bg: #1a1a1a;
  --panel: #232323;
  --panel-2: #2c2c2c;
  --line: #3a3a3a;
  --text: #ededed;
  --muted: #9b9b9b;
  --accent: #e5484d;
  --accent-dim: #7f2528;
  --accent-text: #ffffff;
  --accent-wash: rgba(229, 72, 77, .16);
  --accent-wash-soft: rgba(229, 72, 77, .08);
  --gold: #e0b341;
  --wrong: #f0883e;
  --topbar-bg: linear-gradient(180deg, #2c2c2c, #1b1b1b);
  --scrim: rgba(0, 0, 0, .82);
  --locked-head-bg: #2a2420;
}

* { box-sizing: border-box; }

/* the hidden attribute must always win, even over display:flex/grid rules */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

h1, h2 { margin: 0; }
button { font: inherit; cursor: pointer; }
select, input { font: inherit; }

/* ---- top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .ball { font-size: 30px; }
.brand h1 { font-size: 20px; letter-spacing: .3px; }
.season { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.themePicker {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 13px;
}
.whoBtn {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 12px;
  color: var(--text);
}
.whoBtn .who-text { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.whoBtn .lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.whoBtn .who { font-weight: 700; font-size: 14px; }
.whoBtn.unset { border-color: var(--gold); }
.whoBtn.unset .who { color: var(--gold); }

/* ---- profile overlay ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.overlay-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.overlay-card .ball { font-size: 34px; }
.overlay-card h2 { margin: 8px 0 6px; }
.overlay-card .hint { margin-bottom: 18px; }
.who-buttons { display: flex; flex-direction: column; gap: 10px; }
.who-buttons button {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 17px;
  font-weight: 700;
}
.who-buttons button .nm { flex: 1; }
.who-buttons button:hover { border-color: var(--accent); background: var(--accent-wash); }
.who-buttons .none { color: var(--muted); font-weight: 400; font-size: 14px; }
.who-close {
  margin-top: 16px;
  background: transparent;
  border: none;
  color: var(--muted);
  text-decoration: underline;
}

/* ---- tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  background: var(--bg);
  position: sticky;
  top: 61px;
  z-index: 4;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 14px;
  font-weight: 600;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
.tab[hidden] { display: none; }

/* ---- week nav ---- */
.weeknav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.wk-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  font-size: 18px;
}
.wk-btn:hover { border-color: var(--accent-dim); }
#weekPicker {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 600;
  flex: 1;
  min-width: 120px;
}
.seasonnav {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 8px;
  font-weight: 700;
}
.wk-btn.wide { width: auto; padding: 0 14px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.wk-btn.wide[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.weekmeta { color: var(--muted); font-size: 13px; width: 100%; }

/* ---- picks + overview layout ---- */
.picks-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.overview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  overflow-x: auto;
}
.overview h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.ovtable { border-collapse: collapse; width: 100%; font-size: 13px; }
.ovtable th, .ovtable td { border: 1px solid var(--line); padding: 6px 8px; text-align: center; white-space: nowrap; }
.ovtable th { background: var(--panel-2); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.ovtable td.match { text-align: left; }
.ovtable td.match .vs { color: var(--muted); }
.ovtable td.match .od { display: block; font-size: 11px; color: var(--muted); }
.ovtable td.sel { font-weight: 700; }
.ovtable td.sel.correct { color: var(--accent); }
.ovtable td.sel.wrong { color: var(--wrong); }
.ovtable td.sel.blank { color: var(--line); font-weight: 400; }
.ovtable tr.locked td.match { color: var(--muted); }
.ovtable td.match .lk { font-size: 11px; }

@media (min-width: 1080px) {
  body[data-tab="picks"].has-overview main { max-width: 1180px; }
  .has-overview .picks-layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .has-overview .overview { position: sticky; top: 110px; max-height: calc(100vh - 130px); overflow: auto; }
}

/* ---- two-column layout (Standings / History): main content + side panel ---- */
.cols { display: flex; flex-direction: column; gap: 18px; align-items: stretch; }
.cols > .col-main { min-width: 0; }
.cols > .col-side { min-width: 0; }
.cols > .col-side:empty { display: none; }
.cols > .col-side > :first-child { margin-top: 0; }

@media (min-width: 1000px) {
  body[data-tab="standings"] main,
  body[data-tab="history"] main { max-width: 1200px; }
  .cols { flex-direction: row; align-items: flex-start; }
  .cols > .col-main { flex: 1 1 auto; }
  .cols > .col-side {
    flex: 0 0 430px;
    position: sticky;
    top: 110px;
    max-height: calc(100vh - 128px);
    overflow: auto;
  }
}

/* ---- backfill banner ---- */
.backfillbar {
  background: var(--accent-wash-soft);
  border: 1px solid var(--accent-dim);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text);
}

/* ---- bye bar ---- */
.byebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
}
.byebar b { color: var(--gold); text-transform: uppercase; letter-spacing: .5px; font-size: 11px; }
.byebar .teams { color: var(--text); }

/* ---- game cards ---- */
.games { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
.card-head .lock { color: var(--gold); font-weight: 700; }
.card-head .final { color: var(--accent); font-weight: 700; letter-spacing: .5px; }
.card-head .mkt { color: var(--muted); font-variant-numeric: tabular-nums; }

/* a game that has kicked off: picks are frozen */
.card.locked { opacity: .82; }
.card.locked .card-head { background: var(--locked-head-bg); }
.side.locked { cursor: not-allowed; }
.card.locked .side .radio { opacity: .3; }
.card.locked .side.mypick { background: var(--accent-wash-soft); }
.card.locked .side.mypick .radio { opacity: 1; }

.side {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.side:last-child { border-bottom: none; }
.side.clickable:hover { background: var(--panel-2); }
.side.pickable { cursor: pointer; }
.side img { width: 36px; height: 36px; object-fit: contain; grid-column: 1; }
.side .tname { font-weight: 600; }
.side .tname small { color: var(--muted); font-weight: 400; display: block; font-size: 11px; }
.side .tname small .odds { color: var(--gold); font-weight: 700; font-variant-numeric: tabular-nums; }
.side .score { font-variant-numeric: tabular-nums; font-size: 20px; font-weight: 700; color: var(--muted); min-width: 28px; text-align: right; }
.side.won .score { color: var(--text); }
.side .radio {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
}
.side.mypick .radio { border-color: var(--accent); background: var(--accent); }
.side.mypick .radio::after { content: "✓"; font-size: 13px; color: var(--accent-text); font-weight: 900; }
.side.mypick { background: var(--accent-wash); }
.side.won { background: var(--accent-wash-soft); }
.side.mypick.correct .radio { border-color: var(--accent); background: var(--accent); }
.side.mypick.wrong .radio { border-color: var(--wrong); background: var(--wrong); }
.side.mypick.wrong .radio::after { content: "✕"; color: #2a0a08; }

.picks-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 12px;
}
.pick-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 3px 8px 3px 4px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
}
.pick-badge b { color: var(--text); }
.pick-badge.correct { border-color: var(--accent-dim); color: var(--accent); }
.pick-badge.wrong { border-color: var(--wrong); color: var(--wrong); }
.pick-badge.none { opacity: .5; }

/* ---- leaderboard ---- */
.leaderboard { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 24px; }
.lb-row {
  display: grid;
  grid-template-columns: 30px 32px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.lb-row .rank { font-size: 18px; font-weight: 800; color: var(--muted); text-align: center; }
.lb-row:first-child { border-color: var(--accent-dim); }
.lb-row:first-child .rank { color: var(--gold); }
.lb-row .name { font-weight: 600; }
.lb-row .pts { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.lb-row .pts small { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; }

/* ---- week table ---- */
.tablewrap { overflow-x: auto; margin: 12px 0; }
.weektable { border-collapse: collapse; width: 100%; font-size: 14px; }
.weektable th, .weektable td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
  white-space: nowrap;
}
.weektable th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.weektable td.wk { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.weektable tr:last-child td { font-weight: 800; }
.weektable tr:last-child td.wk { color: var(--text); }

/* ---- by-team record table ---- */
.teamtable { border-collapse: collapse; width: 100%; font-size: 13px; }
.teamtable th, .teamtable td {
  border: 1px solid var(--line);
  padding: 6px 9px;
  text-align: center;
  white-space: nowrap;
}
.teamtable tr:first-child th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.teamtable th.team {
  text-align: left;
  font-weight: 700;
  color: var(--text);
  position: sticky;
  left: 0;
  background: var(--panel);
}
.teamtable tr:first-child th.team { background: var(--panel-2); }
.teamtable td.sel .rate { font-weight: 700; font-variant-numeric: tabular-nums; }
.teamtable td.sel small { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.teamtable td.sel.correct .rate { color: var(--accent); }
.teamtable td.sel.wrong .rate { color: var(--wrong); }
.teamtable td.blank { color: var(--muted); }
.teamtable td.blank .rate { color: var(--muted); font-weight: 400; }

/* ---- history ---- */
.alltime { margin: 12px 0 24px; overflow-x: auto; }
.alltime table { border-collapse: collapse; width: 100%; font-size: 14px; }
.alltime th, .alltime td { border: 1px solid var(--line); padding: 8px 10px; text-align: center; white-space: nowrap; }
.alltime th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.alltime td.name { text-align: left; font-weight: 600; }
.alltime td.titles { color: var(--gold); font-weight: 800; }

.archivelist { display: flex; flex-direction: column; gap: 10px; }
.arch {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.arch > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.arch > summary::-webkit-details-marker { display: none; }
.arch > summary::before { content: "▸"; color: var(--muted); }
.arch[open] > summary::before { content: "▾"; }
.arch .yr { font-size: 17px; font-weight: 800; }
.arch .champ { color: var(--gold); font-weight: 700; }
.arch .champ.tie { color: var(--text); }
.arch .when { color: var(--muted); font-size: 12px; margin-left: auto; }
.arch .body { padding: 0 16px 16px; }
.arch .body .leaderboard { margin: 6px 0 16px; }
.arch .body .tablewrap { margin: 0; }
.arch .body .tablewrap + .tablewrap { margin-top: 10px; }
.arch .body .arch-h { margin: 16px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.arch .delrow { text-align: right; margin-top: 10px; }
.arch .delrow button {
  background: transparent; border: 1px solid var(--line);
  color: var(--wrong); border-radius: 8px; padding: 5px 12px; font-size: 12px;
}

.importbox { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.importbox code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.importbox textarea {
  width: 100%;
  margin: 8px 0;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace;
  resize: vertical;
}
.importbox > button {
  background: var(--accent); color: var(--accent-text); border: none;
  border-radius: 8px; padding: 9px 16px; font-weight: 700;
}
.importresult {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace;
  color: var(--muted);
  white-space: pre-wrap;
  max-height: 260px;
  overflow: auto;
}

.archivebox { background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--wrong); border-radius: 10px; padding: 12px 14px; }
.archiveform { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.archiveform label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.archiveform label.inline { flex-direction: row; align-items: center; text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--text); }
.archiveform input[type="text"], .archiveform input:not([type]), .archiveform input[type="number"] {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 12px; max-width: 260px;
}
button.danger { background: var(--wrong); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; font-weight: 700; align-self: flex-start; }

/* ---- settings ---- */
#tab-settings h2 { margin: 22px 0 10px; font-size: 16px; }
.playerlist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.playerlist li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.playerlist .pl-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.playerlist .pl-name { font-weight: 600; }
.playerlist .pl-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.playerlist button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--wrong);
  border-radius: 8px;
  padding: 4px 10px;
}
.playerlist .pl-upload {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.playerlist .pl-upload input { display: none; }
.playerlist .pl-clearav { color: var(--muted); }
.addplayer, .seasonform { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.addplayer input, .seasonform input {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  flex: 1;
  min-width: 140px;
}
.addplayer button, .seasonform button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 700;
}
.toggle { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.toggle input { margin-right: 8px; }
.hint { color: var(--muted); font-size: 12px; display: block; margin-top: 4px; }

/* ---- toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  z-index: 20;
}
.toast.err { border-left-color: var(--wrong); }

.loading, .empty { color: var(--muted); text-align: center; padding: 40px 0; }

/* ---- player avatars ---- */
.avatar {
  --sz: 28px;
  width: var(--sz);
  height: var(--sz);
  flex: 0 0 auto;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-weight: 700;
  font-size: calc(var(--sz) * 0.42);
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-row .avatar { --sz: 32px; }
.lb-row:first-child .avatar { border-color: var(--accent-dim); }
.ovtable th .avatar { --sz: 18px; margin: 0 auto 3px; }

@media (max-width: 480px) {
  .side { grid-template-columns: 36px 1fr auto auto; gap: 8px; padding: 10px; }
  .side img { width: 30px; height: 30px; }
  .brand h1 { font-size: 17px; }
  .topbar { gap: 8px; }
  .topbar-right { gap: 8px; }
  .themePicker { padding: 6px 7px; font-size: 12px; }
}
