@font-face { font-family: "Newsreader"; src: url("/fonts/newsreader.woff2") format("woff2-variations"), url("/fonts/newsreader.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Libre Franklin"; src: url("/fonts/libre-franklin.woff2") format("woff2-variations"), url("/fonts/libre-franklin.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --text: #22180f;
  --muted: #6f6253;
  --border: #e5ddd1;
  --accent: #b5561c;
  --accent-ink: #ffffff;
  --accent-soft: #fbe7d6;
  --good: #1f7a4a;
  --warn: #a96500;
  --bad: #b3261e;
  --live: #d93025;
  --shadow: 0 1px 2px rgba(40, 25, 10, .06), 0 2px 8px rgba(40, 25, 10, .05);
  --radius: 12px;
  --serif: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: "Libre Franklin", "Franklin Gothic Medium", "Helvetica Neue", Arial, sans-serif;
  --brand-grad: linear-gradient(90deg, #4f68f5, #9b5fe0 50%, #e2509f);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15110d;
    --surface: #1f1a15;
    --surface-2: #2a231c;
    --text: #f3ece3;
    --muted: #a99b8b;
    --border: #3a3128;
    --accent: #e98a4c;
    --accent-ink: #1a0f06;
    --accent-soft: #3b2616;
    --good: #57c08a;
    --warn: #e6a640;
    --bad: #f2867f;
    --live: #ff6b5e;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15110d; --surface: #1f1a15; --surface-2: #2a231c; --text: #f3ece3; --muted: #a99b8b;
  --border: #3a3128; --accent: #e98a4c; --accent-ink: #1a0f06; --accent-soft: #3b2616;
  --good: #57c08a; --warn: #e6a640; --bad: #f2867f; --live: #ff6b5e; --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 var(--sans);
  font-feature-settings: "tnum" 1;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 700; font-size: 17px; }
.brand { gap: 10px; }
.brand img { width: 64px; height: 64px; border-radius: 14px; display: block; object-fit: cover; box-shadow: 0 0 0 1px var(--border); }
.brand-name { font-family: var(--serif); font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1; color: var(--text); }
.live-status { font-size: 12px; color: var(--muted); text-align: right; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.live { background: var(--live); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.tabs {
  position: sticky; top: 0; z-index: 5;
  display: flex; gap: 2px; padding: 6px 8px; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.tabs a {
  flex: 1 0 auto; text-align: center; padding: 8px 6px; border-radius: 999px;
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap;
}
.tabs a.active { background: var(--accent-soft); color: var(--accent); }

.app { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 22px; margin: 22px 0 10px; line-height: 1.15; }
h3 { font-size: 18px; margin: 16px 0 8px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }

/* games strip */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.games > .card.game { margin: 0; padding: 8px 12px; min-width: 0; }
.game .row { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.game .row.lose { color: var(--muted); font-weight: 500; }
.game .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 8px; }
.game.in .meta .st { color: var(--live); font-weight: 700; }

/* standings */
.standings { display: grid; gap: 10px; }
.team summary { list-style: none; cursor: pointer; padding: 12px 14px; display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; }
.team summary::-webkit-details-marker { display: none; }
.rank { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); font-weight: 700; font-size: 13px; }
.team[data-rank="1"] .rank { background: var(--accent); color: var(--accent-ink); }
.team .name { font-family: var(--serif); font-weight: 700; font-size: 19px; line-height: 1.15; }
.team .sub { font-size: 12px; color: var(--muted); }
.team .total { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 4px; border-radius: 2px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.roster { border-top: 1px solid var(--border); }
.prow { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); }
.prow:last-child { border-bottom: 0; }
.slot { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 6px; text-align: center; padding: 3px 0; }
.pname { font-weight: 600; }
.pmeta { font-size: 12px; color: var(--muted); }
.pts { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 48px; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--surface-2); color: var(--muted); vertical-align: 1px; }
.tag.live { background: color-mix(in srgb, var(--live) 15%, transparent); color: var(--live); }
.tag.inj { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.tag.mgr { background: var(--accent-soft); color: var(--accent); }
.tag.ovr { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.grid-2 { display: grid; gap: 16px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 3fr 2fr; align-items: start; } }

.list .prow { grid-template-columns: 28px 1fr auto; }

/* players */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 12px; }
.chips { display: flex; gap: 6px; overflow-x: auto; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
input[type="search"], input[type="text"], input[type="number"], input[type="password"], select, textarea {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px; max-width: 100%;
}
textarea { width: 100%; min-height: 160px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
input[type="number"] { width: 90px; }
.grow { flex: 1 1 180px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.drafted .pname { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }

/* buttons */
.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px; font-weight: 600; cursor: pointer; min-height: 38px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

/* tables */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { font-size: 12px; color: var(--muted); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; }
.ok { color: var(--good); font-weight: 700; }
.warn { color: var(--warn); font-weight: 700; }
.err { color: var(--bad); }

/* admin */
.admin-nav { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.section { padding: 14px; }
.section > h2:first-child { margin-top: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: 14px; }
.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.score-grid label { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--border); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(30px); opacity: 0; transition: .2s; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; pointer-events: none; max-width: calc(100vw - 32px); z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.error { background: var(--bad); color: #fff; }

/* ---------- Classic mode: Google Sheets look (always light) ---------- */
.sheet-wrap { margin: 0 -16px; background: #fff; color: #000; border-top: 1px solid #c7c7c7; border-bottom: 1px solid #c7c7c7; }
.sheet-scroll { overflow: auto; max-height: calc(100vh - 190px); -webkit-overflow-scrolling: touch; }
table.sheet { border-collapse: collapse; font: 13px/1.25 Arial, Helvetica, sans-serif; color: #000; background: #fff; table-layout: fixed; }
table.sheet td, table.sheet th { border: 1px solid #e2e3e3; height: 21px; padding: 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
table.sheet th { background: #f8f9fa; color: #5f6368; font-weight: 400; font-size: 11px; text-align: center; position: sticky; top: 0; z-index: 2; border-color: #c7c7c7; }
table.sheet th.rh { position: sticky; left: 0; z-index: 1; width: 40px; min-width: 40px; }
table.sheet thead th.rh { z-index: 3; }
table.sheet td.n { text-align: right; }
table.sheet td.b { font-weight: 700; }
table.sheet td.o::after { content: ""; position: absolute; top: 0; right: 0; border-style: solid; border-width: 0 6px 6px 0; border-color: transparent #f29900 transparent transparent; }
table.sheet td.dim { color: #9aa0a6; }
table.sheet td.live { background: #fff4e5; }
.sheet-tabs { display: flex; gap: 2px; background: #f1f3f4; border-top: 1px solid #c7c7c7; padding: 0 8px; overflow-x: auto; font: 13px Arial, Helvetica, sans-serif; }
.sheet-tabs a { padding: 8px 14px; color: #444; text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; }
.sheet-tabs a.active { background: #fff; color: #188038; font-weight: 700; border-bottom-color: #188038; }
.sheet-bar { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #f9fbfd; border-bottom: 1px solid #c7c7c7; font: 12px Arial, sans-serif; color: #444; }
.sheet-bar .fx { font-style: italic; color: #777; }

/* live draft */
.clock { padding: 14px 16px; margin-bottom: 12px; border-left: 4px solid var(--accent); }
.clock-name { font-family: var(--serif); font-size: 30px; font-weight: 700; line-height: 1.1; }
.confirm { padding: 12px; margin: 10px 0; background: var(--accent-soft); border-color: var(--accent); }
button.prow { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); text-align: left; cursor: pointer; }
button.prow:hover { background: var(--surface-2); }
.pickbtn .pts { color: var(--accent); font-size: 13px; }
table.board { width: 100%; table-layout: fixed; font-size: 13px; }
table.board td, table.board th { vertical-align: top; overflow-wrap: anywhere; padding: 6px 6px; }
table.board td.now { background: var(--accent-soft); }
table.board td:first-child, table.board th:first-child { min-width: 36px; width: 36px; }

.notice { padding: 12px 14px; margin-bottom: 12px; border-left: 4px solid var(--accent); }
.order-row { grid-template-columns: 34px 1fr auto; }
.order-row .btn { min-height: 32px; padding: 4px 12px; }

/* NHL + Rules */
.tag.nhl { background: color-mix(in srgb, #1d6fd8 15%, transparent); color: #1d6fd8; }
.strip-label { margin: 6px 0 4px; }
.rules { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.rules-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.rules-grid .card { padding: 10px 12px; }
.rules-h { font-weight: 700; margin-bottom: 4px; }
.pad-s { padding: 6px 0 0; margin: 0; }
.draft-notice { border-left-color: var(--warn); }

/* League logo */
.rules-hero { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.rules-hero img { width: 96px; height: 96px; border-radius: 14px; object-fit: cover; flex: none; }
.rules-hero h1 { margin: 0; font-size: 34px; line-height: 1.05; }
.rules-hero p { margin: 2px 0 0; }

/* Expandable NHL games */
.nhl-games { margin: 4px 0 8px; }
.nhl-games > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-weight: 600; font-size: 14px; }
.nhl-games > summary::-webkit-details-marker { display: none; }
.nhl-games .chev { width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; margin-top: -4px; }
.nhl-games[open] .chev { transform: rotate(-135deg); margin-top: 4px; }
.nhl-games[open] > summary { margin-bottom: 8px; }
.live-txt { color: var(--live); }
/* Placeholders before games start */
.prow.placeholder .ph-bar { height: 10px; width: 60%; border-radius: 5px; background: var(--surface-2); margin: 3px 0; }
.prow.placeholder .ph-bar.short { width: 35%; }
.game .meta { white-space: nowrap; }
.game .meta .st { flex: none; }
.game .meta .bc { overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Draft room: highlighted player + sticky "Drafted by" bar */
.pickbtn.selected { background: var(--accent-soft); outline: 2px solid var(--accent); outline-offset: -2px; }
.confirm-bar { position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 6; margin-top: 10px; padding: 12px 14px; display: grid; gap: 8px; border: 2px solid var(--accent); box-shadow: 0 6px 24px rgba(40, 25, 10, .18); }
.cb-player { display: flex; gap: 10px; align-items: center; }
.cb-mgr { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.cb-mgr select { flex: 1; font-size: 16px; padding: 8px; }
table.board td.editable { cursor: pointer; }
table.board td.bsel { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }

/* Draft board: table on wide screens, round lists on phones */
.round-list { display: none; }
@media (max-width: 760px) {
  .board-desk { display: none; }
  .round-list { display: grid; gap: 10px; }
}
.round-card { padding: 6px 0; }
.round-h { font-family: var(--serif); font-weight: 700; font-size: 17px; padding: 4px 14px 6px; }
.rl-row { display: grid; grid-template-columns: 28px 70px 1fr; gap: 8px; align-items: baseline; padding: 7px 14px; border-top: 1px solid var(--border); font-size: 14px; }
.rl-row.now { background: var(--accent-soft); }
.rl-row.editable { cursor: pointer; }
.rl-row.bsel { outline: 2px solid var(--accent); outline-offset: -2px; }
.rl-mgr { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.accent { color: var(--accent); font-weight: 600; }
.clock.tbd { border-left-color: var(--warn); }
a.btn { text-decoration: none; display: inline-block; }

/* Header logo + full-size view */
.logo-btn { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 14px; }
.logo-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a.brand-name { text-decoration: none; }
@media (min-width: 761px) { .brand img { width: 76px; height: 76px; } .brand-name { font-size: 30px; } }
.logo-dialog { padding: 0; border: 0; background: transparent; max-width: min(92vw, 640px); width: 100%; overflow: visible; }
.logo-dialog::backdrop { background: rgba(10, 6, 3, .82); }
.logo-dialog img { width: 100%; height: auto; display: block; border-radius: 18px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.logo-close { position: absolute; top: -14px; right: -6px; width: 40px; height: 40px; border-radius: 50%; border: 0; background: #fff; color: #222; font-size: 26px; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }

/* ---------- player info card ---------- */
.plink { all: unset; cursor: pointer; color: inherit; font: inherit; border-bottom: 1px dotted color-mix(in srgb, currentColor 45%, transparent); }
.plink:hover, .plink:focus-visible { color: var(--accent); border-bottom-color: var(--accent); }
.plink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
td.pcell { cursor: pointer; }
td.pcell:hover { text-decoration: underline; }
.tag.deep { background: transparent; border: 1px dashed var(--border); }
.pickrow { display: flex; align-items: stretch; gap: 6px; }
.pickrow .pickbtn { flex: 1; min-width: 0; }
.info-btn { flex: 0 0 40px; height: 40px; align-self: center; border: 1px solid var(--border); background: var(--surface); color: var(--accent); border-radius: 10px; font: italic 700 17px var(--serif); cursor: pointer; }
.info-btn:hover { background: var(--accent-soft); }
.player-dialog { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); width: min(94vw, 460px); max-height: 88vh; overflow: auto; box-shadow: 0 12px 40px rgba(0, 0, 0, .35); }
.player-dialog::backdrop { background: rgba(10, 6, 3, .6); }
.pc-close { position: sticky; top: 8px; float: right; margin: 8px 8px 0 0; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--text); font-size: 22px; line-height: 1; cursor: pointer; z-index: 1; }
.pc-head { display: flex; gap: 14px; align-items: center; padding: 18px 18px 12px; }
.pc-shot { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: 0 0 84px; }
.pc-init { display: grid; place-items: center; font: 600 28px var(--serif); color: var(--muted); }
.pc-head h3 { margin: 0 0 4px; font-size: 22px; line-height: 1.15; }
.pc-sec { padding: 10px 18px; border-top: 1px solid var(--border); }
.pc-sec h4 { margin: 0 0 6px; font: 700 11px var(--sans); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.pc-big { font: 600 28px var(--serif); }
.pc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.pc-grid div { background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.pc-grid b { display: block; font-size: 16px; }
.pc-grid span { font-size: 11px; color: var(--muted); }
.pc-break { width: 100%; border-collapse: collapse; font-size: 13px; }
.pc-break td { padding: 3px 0; border-bottom: 1px solid var(--border); }
.pc-break td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.pc-break tr.total td { font-weight: 700; border-bottom: 0; }
.pc-foot { padding: 12px 18px 18px; display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--border); }

/* classic sheet: tabs on top for phones, zoom controls */
.sheet-tabs.top { display: none; border-top: 0; border-bottom: 1px solid #c7c7c7; }
@media (max-width: 760px) {
  .sheet-tabs.top { display: flex; position: sticky; top: 0; z-index: 4; }
  .sheet-tabs.bottom { display: none; }
  .sheet-tabs.top a { flex: 1; text-align: center; padding: 10px 6px; }
  .sheet-tabs.top a.active { border-bottom-color: #188038; }
  .sheet-bar .sb-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
}
.sheet-bar .sb-txt { flex: 1; min-width: 0; }
.zoom { display: inline-flex; flex: 0 0 auto; border: 1px solid #c7c7c7; border-radius: 6px; overflow: hidden; background: #fff; }
.zoom button { border: 0; border-left: 1px solid #e2e3e3; background: #fff; color: #333; font: 13px Arial, sans-serif; padding: 4px 9px; min-width: 32px; cursor: pointer; }
.zoom button:first-child { border-left: 0; }
.zoom button:hover { background: #f1f3f4; }
.sheet-zoom { width: max-content; }
