:root {
  --bg: #0b1220;
  --bg-2: #121c30;
  --bg-3: #1b2740;
  --line: #26334d;
  --txt: #e8eefc;
  --txt-dim: #93a2c2;
  --txt-faint: #64749a;
  --accent: #4da3ff;
  --pos-F: #34d399;
  --pos-D: #60a5fa;
  --pos-G: #fbbf24;
  --danger: #f87171;
  --me: #a78bfa;
  --mock: #f59e0b;   /* mock mode — deliberately unlike the purple 'your turn' */
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* A class selector like `.toast { display: flex }` outbids the user-agent
   `[hidden] { display: none }` rule, which would leave hidden elements on
   screen swallowing taps. Keep this ahead of every component rule. */
[hidden] { display: none !important; }

/* Pull-to-refresh suppression.
   overscroll-behavior alone covers Chrome and Safari 16+, but the guarantee is
   that the DOCUMENT never scrolls: the shell is exactly viewport height with
   overflow hidden, and scrolling happens inside .view. With no document-level
   overscroll there is nothing for a downward drag at the top to trigger, on any
   browser. dvh accounts for the collapsing mobile URL bar; vh is the fallback. */
html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------- top bar */

.topbar {
  flex: none; z-index: 30;
  background: linear-gradient(180deg, #111c33, #0d1526);
  border-bottom: 1px solid var(--line);
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
}
/* Ken is on the clock — the one moment in the draft that must not be missed. */
.topbar.is-mine {
  background: linear-gradient(180deg, #2b1f52, #1b1533);
  box-shadow: inset 0 4px 0 var(--me);
}

/* Equal-width flanks so the team name sits truly centred between the pick
   number and the undo button, whatever those two happen to measure. */
.clockline {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 8px;
}
.clockline .pill { justify-self: start; }
.clockline .undo-btn { justify-self: end; }

.pill {
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 999px;
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px;
  color: var(--txt-dim); flex: none;
}
.onclock-wrap {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 0;
}
/* Opens the off-board pick dialog for whoever is on the clock. */
.addpick {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--txt-dim); font-size: 22px; font-weight: 400; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 0 2px;
}
.addpick:active { background: var(--accent); border-color: var(--accent); color: #0b1220; }
.topbar.is-mine .addpick { border-color: rgba(255, 255, 255, .35); color: #fff; }

.onclock {
  font-weight: 800; font-size: 26px; text-align: center; min-width: 0;
  letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.onclock .me-tag {
  color: #0b1220; background: var(--me);
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  margin-left: 8px; padding: 2px 6px; border-radius: 4px;
}
.topbar.is-mine .onclock { color: #ffffff; }

.undo-btn {
  flex: none; height: 34px; padding: 0 12px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; color: var(--txt-dim); font-size: 13px; font-weight: 600;
}
.undo-btn:disabled { opacity: .35; }

.turnline {
  margin-top: 5px; font-size: 22px; font-weight: 600; color: var(--txt-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: -.01em;
}
.turnline b { color: var(--accent); font-size: 1.1em; font-weight: 800; }
.turnline.is-mine { color: #ffffff; font-weight: 800; }
.turnline.is-mine b { color: #ffffff; }

/* --------------------------------------------------------------- tabs */

.tabs {
  flex: none; z-index: 25;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.tab {
  background: none; border: 0; padding: 11px 4px;
  color: var(--txt-faint); font-size: 14px; font-weight: 600;
  border-bottom: 2px solid transparent;
}
.tab.is-active { color: var(--txt); border-bottom-color: var(--accent); }

.view { display: none; }
.view.is-active {
  display: block;
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Keeps a fling inside the list from chaining out to the shell. */
  overscroll-behavior: contain;
  padding-bottom: calc(28px + var(--safe-b));
}

/* The board's chrome does not scroll. Every control stays reachable mid-draft:
   the mock clock, the search box, the position chips and the sort headers.

   Structural rather than `position: sticky` on each piece, for the same reason
   the document itself is unscrollable rather than merely `overscroll-behavior`
   — a guarantee beats a per-element rule. Sticky was also quietly wrong here:
   with the mock strip above it, `.controls` slid up by the strip's height
   before it caught, so the search box moved after all. */
#view-board.is-active {
  display: flex; flex-direction: column;
  overflow: hidden;    /* the view no longer scrolls; the list does */
  padding-bottom: 0;   /* moves onto the scrolling child */
}
#view-board > .mockstrip,
#view-board > .mocksummary,
#view-board > .controls,
#view-board > .searchnote,
#view-board > .holdhint,
#view-board > .listhead,
#view-board > .emptymsg { flex: none; }

#view-board > .playerlist {
  flex: 1 1 auto;
  /* Without this the list refuses to shrink below its content height and
     pushes the whole view past the viewport instead of scrolling. */
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: calc(28px + var(--safe-b));
}

/* ----------------------------------------------------------- controls */

.controls {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 6px 12px;
}

.searchrow { display: flex; align-items: center; gap: 8px; }
.searchwrap { position: relative; flex: 1 1 auto; min-width: 0; }
.search {
  width: 100%; height: 38px; padding: 0 34px 0 12px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--txt);
}
.search::placeholder { color: var(--txt-faint); }
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.clear-btn {
  position: absolute; right: 2px; top: 2px;
  width: 34px; height: 34px; background: none; border: 0;
  color: var(--txt-faint); font-size: 22px; line-height: 1;
}

.chips { display: flex; gap: 6px; margin-top: 6px; }
.chip {
  height: 38px; border-radius: 8px; padding: 0 6px;
  background: var(--bg-2); border: 1px solid var(--line);
  color: var(--txt-faint); font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
/* "All" only needs its label, so it takes just what it needs and leaves the
   rest of the row to the three-part position chips. */
.chip-all { flex: 0 0 auto; padding: 0 12px; }

/* roster counter | position letter | tier badge — the 1fr flanks keep the
   letter centred whatever the two sides measure. */
.chip-pos {
  flex: 1 1 0; min-width: 0;
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: center; gap: 3px;
}
.chip-count {
  justify-self: start;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--txt-faint); white-space: nowrap;
}
.chip-count.is-full { color: var(--pos-F); }
.chip-pos.is-on .chip-count { color: rgba(11, 18, 32, .65); }
.chip-pos.is-on .chip-count.is-full { color: #0b1220; }
.chip-letter { font-size: 15px; font-weight: 800; }
.chip-pos .tierbadge { justify-self: end; }

/* Shows the best tier still unowned at this position. The RING COLOUR reports
   how many players remain in that tier — 7+ plenty, 4-6 thinning, 1-3 nearly
   gone — so it warns about a run ending, not about which tier it happens to be.
   A thick ring over a constant dark fill keeps the badge legible whether or not
   the chip is toggled on; a solid fill would collide with the chip's own
   position colour. */
.tierbadge {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  border: 3px solid var(--txt-faint);
  color: var(--txt);
  /* Dark halo OUTSIDE the ring. Without it the ring colour collides with the
     chip's own fill when they match — a green ring vanishes on a selected F,
     amber on a selected G — losing the very signal the ring carries. Framed by
     dark on both sides, the ring reads against any chip state. */
  box-shadow: 0 0 0 2px var(--bg);
}
.tierbadge[data-level="good"]    { border-color: #34d399; color: #6ee7b7; }
.tierbadge[data-level="concern"] { border-color: #fbbf24; color: #fcd34d; }
.tierbadge[data-level="danger"]  { border-color: #f43f5e; color: #fda4af; }

.chip.is-on { color: #0b1220; }
.chip-all.is-on { background: var(--txt-dim); border-color: var(--txt-dim); }
.chip-F.is-on { background: var(--pos-F); border-color: var(--pos-F); }
.chip-D.is-on { background: var(--pos-D); border-color: var(--pos-D); }
.chip-G.is-on { background: var(--pos-G); border-color: var(--pos-G); }

.showdrafted {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  height: 38px; padding: 0 2px;
  font-size: 12px; color: var(--txt-faint); white-space: nowrap;
}
.showdrafted input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }

/* ------------------------------------------------------------ list */

.listhead {
  display: grid; align-items: stretch;
  grid-template-columns: 28px 1fr 46px 60px 62px;
  gap: 8px; padding: 0 12px;
  font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--txt-faint); border-bottom: 1px solid var(--line);
}
.listhead > span { display: flex; align-items: center; padding: 5px 0; }
.lh-name { justify-content: flex-start; }
.lh-sort.lh-rank { justify-content: flex-start; }

/* Tapping a column sorts by it; tapping the active one reverses. */
.lh-sort {
  display: flex; align-items: center; justify-content: flex-end; gap: 2px;
  min-width: 0;
  padding: 7px 0; background: none; border: 0;
  font: inherit; font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--txt-faint); white-space: nowrap;
}
.lh-sort.is-active { color: var(--accent); font-weight: 700; }
.lh-sort:active { color: var(--txt); }
.lh-arrow { font-size: 8px; line-height: 1; }

.playerlist { list-style: none; margin: 0; padding: 0; }

.prow {
  display: grid; align-items: center;
  grid-template-columns: 28px 1fr 46px 60px 62px;
  gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid rgba(38, 51, 77, .55);
  border-left: 6px solid transparent;
}
/* The row itself is the press target: suppress the OS text-selection and
   callout that a long press would otherwise trigger, while leaving vertical
   scrolling intact (pan-y). */
.prow.is-actionable {
  cursor: pointer;
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.prow.is-holding { background: rgba(77, 163, 255, .12); }
.prow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Position tint: FLAT across the row rather than a left-to-right wash, so the
   colour is still there under the ADP/VORP/Pts columns and position can be read
   without looking back to the left edge. A bright ramp at the left was both
   harder on the eyes and absent exactly where it was needed. Only the last
   fifth softens, to avoid a hard edge at the end of the row. Alpha kept low —
   at .16 and above the amber goalie rows go muddy against the navy. */
.prow.pos-F {
  border-left-color: #3ee9a4;
  background-image: linear-gradient(90deg, rgba(62, 233, 164, .10) 0%, rgba(62, 233, 164, .10) 82%, rgba(62, 233, 164, 0) 100%);
}
.prow.pos-D {
  border-left-color: #7ab8ff;
  background-image: linear-gradient(90deg, rgba(122, 184, 255, .10) 0%, rgba(122, 184, 255, .10) 82%, rgba(122, 184, 255, 0) 100%);
}
.prow.pos-G {
  border-left-color: #ffcb3d;
  background-image: linear-gradient(90deg, rgba(255, 203, 61, .10) 0%, rgba(255, 203, 61, .10) 82%, rgba(255, 203, 61, 0) 100%);
}
.prow.is-taken { opacity: .4; }

/* Projected to be gone by the time this pick comes round. The row tint that
   used to carry this has been dropped: layered under the positional tint it
   muddied the colour that actually matters, particularly on amber goalie rows.
   The rank number alone now carries it — free, and it muddies nothing. */
/* Scoped through .playerlist so it outranks the sort-emphasis rule
   `.playerlist[data-sort="rank"] .p-rank`, which is equally specific and
   declared later — without this the projection marker silently loses. */
.playerlist .prow.is-projected-gone .p-rank { color: var(--me); font-weight: 800; }

.p-rank {
  font-size: 13px; color: var(--txt-faint);
  font-variant-numeric: tabular-nums;
}
.p-main { min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
.p-name {
  font-weight: 600; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.p-sub {
  display: flex; align-items: baseline; gap: 7px;
  font-size: 14px; color: var(--txt-dim); margin-top: 3px;
}
.p-pos { font-weight: 900; font-size: 15px; letter-spacing: .04em; }
.pos-F .p-pos { color: var(--pos-F); }
.pos-D .p-pos { color: var(--pos-D); }
.pos-G .p-pos { color: var(--pos-G); }
.p-owner { color: var(--txt-dim); font-style: italic; }
.p-owner.is-keeper { color: var(--pos-G); font-style: normal; }

.p-num {
  text-align: right; font-size: 24px; line-height: 1.05;
  font-variant-numeric: tabular-nums; color: var(--txt-dim);
}
/* Tier now rides with the position letter rather than owning a column. */
.p-tier-chip {
  font-weight: 800; font-size: 12px; letter-spacing: .02em;
  color: var(--txt-faint);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 0 4px; line-height: 16px;
}

/* The column the board is sorted by gets the emphasis. */
.playerlist[data-sort="adp"]    .p-adp,
.playerlist[data-sort="vorp"]   .p-vorp,
.playerlist[data-sort="points"] .p-pts { color: var(--txt); font-weight: 700; }
.playerlist[data-sort="rank"]   .p-rank { color: var(--txt); }

.holdhint {
  margin: 0; padding: 5px 12px; font-size: 11px;
  color: var(--txt-faint); background: var(--bg-2);
  border-bottom: 1px solid var(--line); text-align: center;
}
.holdhint b { color: var(--accent); }

/* the "board by my next pick" divider */
.divider {
  list-style: none; position: relative;
  margin: 0; padding: 4px 12px 4px;
  background: linear-gradient(90deg, rgba(167,139,250,.16), transparent 70%);
  border-top: 2px dashed var(--me);
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.divider-label {
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: var(--me);
}
.divider-note { font-size: 11px; color: var(--txt-faint); }

.searchnote {
  margin: 0; padding: 7px 12px; font-size: 11px;
  color: var(--accent); background: rgba(77, 163, 255, .08);
  border-bottom: 1px solid var(--line);
}

.emptymsg { text-align: center; color: var(--txt-faint); padding: 28px 12px; }
.hint { color: var(--txt-faint); font-size: 12px; padding: 10px 12px 0; margin: 0 0 4px; }

/* ------------------------------------------------------------ teams */

.teamlist { padding: 8px 12px; display: grid; gap: 8px; }

.teamcard {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden;
}
.teamcard.is-mine { border-color: var(--me); }

.tc-head {
  width: 100%; display: grid; grid-template-columns: 1fr auto;
  gap: 8px; align-items: center; padding: 10px 12px;
  background: none; border: 0; text-align: left;
}
.tc-name { font-weight: 700; font-size: 15px; }
.tc-name .slot { color: var(--txt-faint); font-weight: 600; font-size: 12px; margin-right: 6px; }
.tc-name .me-tag { color: var(--me); font-size: 11px; font-weight: 800; margin-left: 6px; }

.tc-counts { display: flex; gap: 8px; margin-top: 4px; font-size: 11px; }
.tc-counts span { color: var(--txt-faint); font-variant-numeric: tabular-nums; }
.tc-counts .c-F { color: var(--pos-F); }
.tc-counts .c-D { color: var(--pos-D); }
.tc-counts .c-G { color: var(--pos-G); }
.tc-counts .is-full { font-weight: 800; }

.tc-score { text-align: right; }
.tc-eff { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tc-raw { font-size: 11px; color: var(--txt-faint); font-variant-numeric: tabular-nums; }

.tc-body { border-top: 1px solid var(--line); padding: 4px 0; }
.tc-empty { padding: 10px 12px; color: var(--txt-faint); font-size: 12px; }

.rrow {
  display: grid; grid-template-columns: 22px 1fr auto auto;
  gap: 8px; align-items: center; padding: 5px 12px; font-size: 13px;
}
.rrow.is-bench { opacity: .45; }
.rrow .r-pos { font-weight: 800; font-size: 11px; }
.rrow.pos-F .r-pos { color: var(--pos-F); }
.rrow.pos-D .r-pos { color: var(--pos-D); }
.rrow.pos-G .r-pos { color: var(--pos-G); }
.rrow .r-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow .r-tag { font-size: 10px; color: var(--pos-G); font-weight: 700; }
.rrow .r-pts { font-variant-numeric: tabular-nums; color: var(--txt-dim); }

/* ------------------------------------------------------------ setup */

.card {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 12px; margin: 10px 12px; padding: 12px;
}
.card h2 {
  margin: 0 0 4px; font-size: 15px;
  display: flex; align-items: center; gap: 8px;
}
.card .hint { padding: 0; margin: 0 0 10px; }
.counter {
  margin-left: auto; font-size: 12px; color: var(--txt-faint);
  font-variant-numeric: tabular-nums; font-weight: 600;
}

.teamsetup { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tsrow { display: grid; grid-template-columns: 26px 1fr 44px; gap: 8px; align-items: center; }
.tsrow .ts-slot { color: var(--txt-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.tsrow input[type=text] {
  height: 38px; padding: 0 10px; border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--txt);
  min-width: 0;
}
.tsrow.is-mine input[type=text] { border-color: var(--me); }
.ts-me { display: flex; align-items: center; justify-content: center; gap: 4px; }
.ts-me input { width: 18px; height: 18px; accent-color: var(--me); }

.keeperteams { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; }
.ktbtn {
  height: 40px; border-radius: 8px; padding: 0 6px;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--txt-dim); font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; justify-content: center; gap: 1px;
  white-space: nowrap; overflow: hidden;
}
.ktbtn .kt-n { font-size: 10px; color: var(--txt-faint); font-variant-numeric: tabular-nums; }
.ktbtn.is-full { border-color: var(--pos-F); }
.ktbtn.is-full .kt-n { color: var(--pos-F); }
.ktbtn.is-sel { background: var(--accent); border-color: var(--accent); color: #0b1220; }
.ktbtn.is-sel .kt-n { color: rgba(11,18,32,.7); }

.keeperpanel { margin-top: 12px; }
.kp-slots { display: grid; gap: 5px; margin-bottom: 10px; }
.kp-slot {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 7px 10px; border-radius: 8px;
  background: var(--bg-3); border: 1px dashed var(--line); font-size: 13px;
}
.kp-slot.is-filled { border-style: solid; }
.kp-slot .kp-empty { color: var(--txt-faint); font-style: italic; }
.kp-x {
  width: 30px; height: 30px; border-radius: 6px;
  background: none; border: 1px solid var(--line); color: var(--danger);
  font-size: 16px; line-height: 1;
}
.kp-search {
  width: 100%; height: var(--tap); padding: 0 12px; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--txt);
}
.kp-results { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
.kp-result {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 8px;
  align-items: center; padding: 9px 10px; text-align: left;
  background: none; border: 0; border-bottom: 1px solid rgba(38,51,77,.55);
  border-left: 3px solid transparent;
}
.kp-result.pos-F { border-left-color: var(--pos-F); }
.kp-result.pos-D { border-left-color: var(--pos-D); }
.kp-result.pos-G { border-left-color: var(--pos-G); }
.kp-result:disabled { opacity: .4; }
.kp-result .kr-sub { font-size: 11px; color: var(--txt-faint); }
.kp-result .kr-pts { font-size: 12px; color: var(--txt-dim); font-variant-numeric: tabular-nums; }

/* Off-board pick form. */
.addform { display: grid; gap: 10px; }
.addfield { display: grid; gap: 4px; }
.addfield-label {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--txt-faint);
}
.addfield-input {
  height: 46px; padding: 0 12px; border-radius: 10px; width: 100%;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--txt);
  font-size: 16px; /* 16px or iOS zooms the page on focus */
}
.addfield-input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
select.addfield-input { appearance: none; -webkit-appearance: none; }

.rrow .r-tag.is-custom { color: var(--accent); }

.statusgrid { display: grid; gap: 6px; margin-bottom: 10px; font-size: 13px; }
.statusgrid div { display: flex; justify-content: space-between; gap: 8px; }
.statusgrid .ok { color: var(--pos-F); }
.statusgrid .warn { color: var(--pos-G); }

.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btn {
  flex: 1 1 auto; min-height: var(--tap); padding: 0 14px; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--txt); font-weight: 600; font-size: 14px;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #0b1220; font-weight: 800; }
.btn-danger { color: var(--danger); border-color: rgba(248,113,113,.4); }

.version { text-align: center; color: var(--txt-faint); font-size: 11px; margin: 16px 0 0; }

/* ------------------------------------------------------------ sheet */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(4, 8, 16, .6);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-height: 82vh; overflow-y: auto;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  padding: 0 12px calc(16px + var(--safe-b));
}
.sheet-grab {
  width: 36px; height: 4px; border-radius: 2px;
  background: var(--line); margin: 8px auto 4px;
}
.sheet-head { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0 10px; }
.sheet-head h3 { margin: 0; font-size: 17px; }
.sheet-sub { margin: 2px 0 0; font-size: 12px; color: var(--txt-faint); }
.sheet-close {
  margin-left: auto; width: 34px; height: 34px; flex: none;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; color: var(--txt-dim); font-size: 20px; line-height: 1;
}
.sheet-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--txt-faint); margin: 12px 0 6px;
}
.teamgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.tgbtn {
  min-height: 44px; border-radius: 8px; padding: 4px 6px;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--txt); font-size: 12px; font-weight: 600;
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  overflow: hidden;
}
.tgbtn .tg-sub { font-size: 10px; color: var(--txt-faint); font-variant-numeric: tabular-nums; }
.tgbtn.is-onclock { border-color: var(--accent); }
.tgbtn.is-mine { border-color: var(--me); }
.tgbtn.is-full { opacity: .5; }

.resetopt {
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px 12px; margin-bottom: 8px;
}
.resetopt.is-severe { border-color: rgba(248, 113, 113, .45); }
.resetopt-title { font-weight: 700; font-size: 14px; }
.resetopt-detail {
  font-size: 12px; color: var(--txt-faint);
  margin: 3px 0 10px; line-height: 1.45;
}
.resetopt .btn { width: 100%; flex: none; }
.resetopt .btn.is-armed {
  background: var(--danger); border-color: var(--danger);
  color: #0b1220; font-weight: 800;
}

.sheet-warn {
  margin: 10px 0 0; padding: 8px 10px; border-radius: 8px; font-size: 12px;
  background: rgba(251,191,36,.12); color: var(--pos-G);
  border: 1px solid rgba(251,191,36,.3);
}

/* ------------------------------------------------------- mock draft mode */

/* Mock mode has to be unmissable from a glance at the top of the screen: the
   whole point of separate storage is defeated if he thinks a mock is the real
   draft. Amber on the border rather than a box-shadow, so it survives the
   purple "your turn" treatment instead of being overwritten by it. */
body.is-mock .topbar { border-bottom: 3px solid var(--mock); }

/* A row of its own rather than an item in the clock line: that line is a
   three-column grid whose flanks are width-matched to centre the team name, so
   a fourth item pushes Undo onto a second row. */
.modebadge {
  background: var(--mock); color: #241505;
  font-size: 11px; font-weight: 900; letter-spacing: .07em;
  text-transform: uppercase; text-align: center;
  padding: 3px 8px; border-radius: 5px; margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.mockstrip {
  flex: none;
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, .08);
  border-bottom: 1px solid rgba(245, 158, 11, .28);
}
.mockstrip-row { display: flex; align-items: center; gap: 8px; }

.mbtn {
  flex: none; height: 32px; padding: 0 12px;
  background: var(--bg-3); color: var(--txt);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; font-weight: 700;
}
.mbtn[disabled] { opacity: .4; }
.mbtn-go {
  background: var(--mock); border-color: var(--mock); color: #241505;
  min-width: 78px;
}
.mbtn-go.is-running { background: transparent; color: var(--mock); }
/* A dimmed amber fill reads as a muddy brown, which looks like a rendering
   fault rather than a disabled control. Drop the fill instead. */
.mbtn-go[disabled] {
  background: transparent; color: var(--mock);
  border-color: rgba(245, 158, 11, .45);
}

.mockstate {
  margin-left: auto; font-size: 12px; color: var(--txt-dim);
  text-transform: uppercase; letter-spacing: .06em;
}

.mockspeed label { font-size: 12px; color: var(--txt-faint); flex: none; }
.mockspeed input[type=range] { flex: 1; min-width: 0; accent-color: var(--mock); }
.mockspeed output {
  flex: none; width: 42px; text-align: right;
  font-size: 12px; font-variant-numeric: tabular-nums; color: var(--txt-dim);
}

.mocksummary { border-color: rgba(245, 158, 11, .4); }
.ms-place { margin: 0 0 6px; font-size: 15px; }
.ms-place b { color: var(--mock); }

/* Live / Mock switch on the setup tab. */
.segmented {
  display: flex; gap: 0; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.seg {
  flex: 1; min-width: 0; height: 38px;
  background: transparent; color: var(--txt-dim);
  border: 0; font-size: 13px; font-weight: 700;
}
.seg + .seg { border-left: 1px solid var(--line); }
.seg.is-on { background: var(--bg-3); color: var(--txt); }
.seg[data-mode="mock"].is-on { background: rgba(245, 158, 11, .18); color: var(--mock); }

/* The last pick made, in mock mode. Its own line, because the big name in the
   clock line is the team picking NEXT — putting the player beside it would read
   as though that team took them. */
.lastpick {
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 5px; padding: 3px 8px; border-radius: 6px;
  font-size: 13px; line-height: 1.3;
  white-space: nowrap; overflow: hidden;
  border: 1px solid rgba(245, 158, 11, .35);
  background: rgba(245, 158, 11, .10);
}
.lp-pick {
  flex: none; font-variant-numeric: tabular-nums;
  font-size: 11px; font-weight: 700; color: var(--txt-faint);
}
.lp-team { flex: none; font-weight: 800; color: var(--mock); }
.lp-arrow { flex: none; color: var(--txt-faint); }
.lp-name {
  min-width: 0; font-weight: 700; color: var(--txt);
  overflow: hidden; text-overflow: ellipsis;
}
.lp-meta {
  flex: none; margin-left: auto; padding-left: 8px;
  font-size: 11px; font-weight: 700; color: var(--txt-faint);
}

/* ---------------------------------------------------------- player notes */

/* Sits in the sub line, so it costs the name no width — the row grid is
   already tight at 320px. The hit area is grown with padding and pulled back
   with negative margins, so the row height (and the 10-row density target)
   is unchanged. */
.p-notes {
  flex: none;
  /* A thumb needs ~30px square. The glyph is ~4px wide, so the target is made
     of padding and a min-width, and the negative margins pull the row height
     back to what it was — the 10-row density target is unaffected. */
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; min-height: 30px;
  margin: -8px 0 -8px 2px;
  padding: 0;
  background: none; border: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic; font-weight: 700; font-size: 14px; line-height: 1;
  color: var(--accent);
  -webkit-touch-callout: none; user-select: none; -webkit-user-select: none;
  /* The row uses pan-y for its press gesture; this is a plain tap target. */
  touch-action: manipulation;
}
.p-notes:active { color: #fff; }

/* Above the sheet (41) because it can be opened while nothing else is, and
   must win the shared backdrop if both ever coincide. */
.notemodal {
  position: fixed; z-index: 45;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(400px, calc(100vw - 24px));
  max-height: min(78vh, 560px); overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 20px 56px rgba(0, 0, 0, .65);
  padding: 14px 16px 16px;
}
.note-head { display: flex; align-items: flex-start; gap: 10px; }
.note-title { min-width: 0; }
.note-head h3 {
  margin: 0; font-size: 20px; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis;
}
.note-sub {
  margin: 3px 0 0; font-size: 12px; color: var(--txt-faint);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.note-facts {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
}
.note-fact {
  display: inline-flex; align-items: baseline; gap: 4px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 7px;
}
.nf-label {
  font-size: 10px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--txt-faint);
}
.nf-value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }

.note-text {
  margin: 12px 0 0; font-size: 14px; line-height: 1.5; color: var(--txt);
}
.note-text.is-empty { color: var(--txt-faint); font-style: italic; }

.note-meta {
  margin: 10px 0 0; font-size: 11px; color: var(--txt-faint);
}

/* ------------------------------------------------------------ toast */

/* During a press this is the only thing that matters on screen, so it is sized
   like a dialog rather than a tooltip — roughly four times the area it had —
   with the drafting team as the largest element, since that is the fact being
   checked before the pick commits. */
.holdpop {
  position: fixed; z-index: 60;
  transform: translateX(-50%);
  pointer-events: none;
  width: min(360px, calc(100vw - 24px));
  background: var(--bg-3);
  border: 2px solid var(--accent);
  border-radius: 16px; padding: 16px 18px 18px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .7);
}
/* Pointer back toward the finger. */
.holdpop::after {
  content: ''; position: absolute; left: 50%; margin-left: -10px;
  border: 10px solid transparent;
}
.holdpop:not(.is-below)::after { top: 100%; border-top-color: var(--accent); }
.holdpop.is-below::after { bottom: 100%; border-bottom-color: var(--accent); }
/* Clamped against a screen edge, the tail would point at nothing. */
.holdpop.is-clamped::after { display: none; }

.holdpop-text {
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 2px;
}
.holdpop-player {
  font-weight: 700; font-size: 20px; line-height: 1.15;
  color: var(--txt);
}
.holdpop-verb {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--txt-faint); margin-top: 4px;
}
.holdpop-team {
  font-weight: 900; font-size: 38px; line-height: 1.1;
  color: var(--accent); letter-spacing: -.02em;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.holdpop-track {
  margin-top: 14px; height: 12px; border-radius: 6px;
  background: rgba(255, 255, 255, .12); overflow: hidden;
}
.holdpop-bar {
  height: 100%; width: 0%; border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--pos-F));
}

/* ------------------------------------------------------------ toast */

.toast {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(12px + var(--safe-b)); z-index: 50;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  font-size: 13px;
}
.toast span { flex: 1; min-width: 0; }
.toast-undo {
  flex: none; background: none; border: 0;
  color: var(--accent); font-weight: 800; font-size: 13px; padding: 4px 2px;
}

/* Very narrow phones: tighten the chip row a little. */
@media (max-width: 380px) {
  .chips { gap: 4px; }
  .chip { padding: 0 4px; gap: 2px; }
  .chip-all { padding: 0 8px; }
  .chip-count { font-size: 10px; }
  .chip-letter { font-size: 14px; }
  .tierbadge { width: 20px; height: 20px; font-size: 10px; border-width: 3px; }
}

/* Short viewports (iPhone SE and friends): trim chrome so the board still
   shows 10+ players without scrolling. */
@media (max-height: 700px) {
  .topbar { padding-top: max(5px, env(safe-area-inset-top)); padding-bottom: 5px; }
  .onclock { font-size: 15px; }
  .turnline { font-size: 12px; margin-top: 2px; }
  .undo-btn { height: 30px; }
  .tab { padding: 7px 4px; }
  .controls { padding: 5px 12px; }
  .search { height: 34px; }
  .clear-btn { height: 30px; width: 30px; }
  .chips { margin-top: 5px; }
  .chip { height: 30px; }
  .searchrow { gap: 6px; }
  .modebadge { font-size: 10px; padding: 2px 6px; margin-bottom: 4px; }
  .mockstrip { padding: 5px 12px; gap: 4px; }
  .mbtn { height: 28px; padding: 0 9px; font-size: 12px; }
  .showdrafted { height: 34px; }
  .listhead { font-size: 9px; }
  .lh-sort { padding: 5px 0; font-size: 9px; }
  .listhead > span { padding: 4px 0; }
  .prow { padding: 5px 12px; }
  .p-name { font-size: 14px; }
  .p-sub { font-size: 12px; margin-top: 1px; }
  .p-pos { font-size: 13px; }
  .p-num { font-size: 19px; }
  .p-tier-chip { font-size: 11px; line-height: 15px; }
  .turnline { font-size: 17px; }
  .divider { padding: 4px 12px 3px; }
  .divider-note { display: none; }
  .holdhint { padding: 3px 12px; }
  .tab { padding: 6px 4px; font-size: 13px; }
  .onclock { font-size: 20px; }
  .addpick { width: 26px; height: 26px; font-size: 19px; }
}

@media (min-width: 640px) {
  .teamlist { grid-template-columns: repeat(2, 1fr); }
  .prow, .listhead { grid-template-columns: 26px 1fr 44px 58px 60px; }
  .prow { padding: 6px 12px; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .16s ease-out; }
  .sheet { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(12px); opacity: 0; } }

  /* A mock pick announces itself, then spends itself over exactly one pick
     interval, so the flash is done as the next pick lands. The 2s here is only
     a fallback — the real duration is set from the live speed slider in JS.
     Only the motion is gated on reduced motion; the line itself still appears
     and reads correctly without it. */
  @keyframes pickflash {
    0%   { opacity: 1;   background-color: rgba(245, 158, 11, .38); }
    12%  { opacity: 1;   background-color: rgba(245, 158, 11, .20); }
    100% { opacity: .45; background-color: rgba(245, 158, 11, 0); }
  }
  .lastpick.is-flash { animation: pickflash 2s ease-out both; }

  /* The row flashes but must return to normal: no opacity change and no
     fill-mode, or a drafted row would sit permanently dimmed and stripped of
     its position tint. Only background-color moves, so the tint — which is a
     gradient, i.e. background-image — survives underneath. */
  @keyframes rowflash {
    0%   { background-color: rgba(245, 158, 11, .38); }
    12%  { background-color: rgba(245, 158, 11, .22); }
    100% { background-color: rgba(245, 158, 11, 0); }
  }
  .prow.is-justpicked { animation: rowflash 2s ease-out; }
}

