:root {
  --bg: #10131a;
  --panel: #171b25;
  --panel-2: #1e2331;
  --line: #2a3040;
  --fg: #e6e9f0;
  --muted: #8c94a8;
  --accent: #4ea3ff;
  --mine: #35c17a;
  --taken: #6b7386;
  --watch: #f2c14e;
  --avoid: #e2604f;
  --pos-qb: #f08a8a;
  --pos-rb: #6ee7a8;
  --pos-wr: #7cc4ff;
  --pos-te: #f4c67a;
  --pos-def: #b9a7ff;
  --pos-pk: #9fb0c9;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.wrap { padding: 18px 22px 40px; }
.narrow { max-width: 720px; margin: 40px auto; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.muted, .hint { color: var(--muted); font-size: 13px; }
.error { color: var(--avoid); }

/* --- home ---------------------------------------------------------- */
.newdraft { margin: 24px 0 32px; }
.newdraft label { display: block; font-weight: 600; margin-bottom: 8px; }
.newdraft .row { display: flex; gap: 8px; }
input, button, select { font: inherit; }
input[type=text], input[type=search], .newdraft input {
  flex: 1; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--fg);
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button {
  padding: 9px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--fg);
}
button:hover { border-color: var(--accent); }
button.danger:hover { border-color: var(--avoid); color: var(--avoid); }
button.link {
  background: none; border: none; color: var(--muted);
  padding: 0; font-size: 13px; text-decoration: underline;
}
ul.drafts { list-style: none; padding: 0; }
ul.drafts li {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
ul.drafts .name { font-weight: 600; font-size: 16px; text-decoration: none; }
ul.drafts .meta { color: var(--muted); font-size: 13px; flex: 1; }
ul.drafts form { margin: 0; }
ul.drafts .lock { font-size: 13px; }
/* The passphrase field is a companion to the name, not an equal partner. */
.newdraft .pass { flex: 0 1 210px; }

/* --- passphrase panel --------------------------------------------- */
.lockpanel {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 10px 0 0; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
/* Needed because the display above would otherwise beat the browser's own
   [hidden] rule, which is how the padlock button toggles this panel. */
.lockpanel[hidden] { display: none; }
.lockpanel form { display: flex; align-items: center; gap: 8px; margin: 0; }
.lockpanel label { font-weight: 600; font-size: 13px; }
.lockpanel input[type=password] {
  padding: 7px 10px; border-radius: 8px; width: 170px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--fg);
}
.lockpanel .hint { margin: 0; }
.flash {
  margin: 10px 0 0; padding: 9px 14px; border-radius: 8px; font-size: 13px;
  background: var(--panel); border: 1px solid var(--line);
}
.flash.alert { color: var(--avoid); border-color: var(--avoid); }

/* --- board --------------------------------------------------------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px;
          flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.topbar .left { display: flex; align-items: center; gap: 12px; }
.topbar .right { display: flex; align-items: center; gap: 10px; }
.back { text-decoration: none; font-size: 20px; color: var(--muted); }
.counts { color: var(--muted); font-size: 13px; }

.controls {
  display: flex; align-items: center; justify-content: flex-start;
  gap: 8px; flex-wrap: wrap; margin: 14px 0;
}
/* Search and the position tabs stay reachable however far down the board you
   are. The sticky table header and sidebar sit directly below, offset by this
   bar's height -- measured in app.js, because the row wraps on narrow screens
   and a hard-coded offset would leave a gap or hide a row. */
.board .controls {
  position: sticky; top: 0; z-index: 3;
  margin: 0; padding: 14px 0;
  background: var(--bg);
}
.controls .sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }
.controls .searchbox { flex: 0 1 190px; min-width: 130px; position: relative; }
/* The input is a plain block at 100% of that box, not a flex item: as a flex
   item it would refuse to shrink below its intrinsic ~20-character width and
   spill out over the position tabs. The right padding is the X's parking space
   and display:block keeps the inline-baseline gap from padding the box out. */
.controls #search { display: block; width: 100%; padding: 7px 26px 7px 10px; }
/* One clear button is enough, and WebKit's own only appears in WebKit. */
#search::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.searchbox .clear {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  border: none; background: none; color: var(--muted);
  padding: 0 5px; font-size: 17px; line-height: 1; border-radius: 6px;
}
.searchbox .clear:hover { color: var(--fg); background: var(--panel-2); }
.searchbox .clear[hidden] { display: none; }
.tabs { display: flex; gap: 3px; }
.tabs button { padding: 6px 10px; font-size: 13px; }
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #08101c; font-weight: 600; }
.check {
  color: var(--muted); font-size: 13px; user-select: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.check input { margin: 0; }
.adpsel {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 13px; user-select: none;
}
.adpsel .check { gap: 4px; }
.adpsel input[disabled] + span, .adpsel .check:has(input[disabled]) { opacity: .45; }
.adpsel[hidden] { display: none; }

.columns { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 22px; align-items: start; }
@media (max-width: 900px) { .columns { grid-template-columns: 1fr; } }

table.players { width: 100%; border-collapse: collapse; }
table.players th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line);
  position: sticky; top: var(--controls-h, 0px); z-index: 2; background: var(--bg);
}
table.players td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.players .c { text-align: center; }
table.players .acts { width: 124px; }
tr.taken td:not(.acts) { color: var(--taken); text-decoration: line-through; }
tr.mine { background: rgba(53, 193, 122, .10); }
tr.mine .pname { color: var(--mine); font-weight: 600; }
tr.avoid td:not(.acts) { opacity: .45; }
tr.watch .pname::before { content: "\2605 "; color: var(--watch); }
.pname { font-weight: 500; }
.pos { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; background: var(--panel-2); }
.pos.QB, .spos.QB   { color: var(--pos-qb); }
.pos.RB, .spos.RB   { color: var(--pos-rb); }
.pos.WR, .spos.WR   { color: var(--pos-wr); }
.pos.TE, .spos.TE   { color: var(--pos-te); }
.pos.DEF, .spos.DEF { color: var(--pos-def); }
.pos.PK, .spos.PK   { color: var(--pos-pk); }
td.acts { white-space: nowrap; }
td.acts button {
  width: 27px; padding: 4px 0; margin-right: 3px;
  font-size: 13px; line-height: 1.2; text-align: center;
}
td.acts .pickno { color: var(--muted); font-size: 11px; margin-left: 2px; }
td.acts .pickno.mine { color: var(--mine); }
button.act-mine:hover  { border-color: var(--mine); color: var(--mine); }
button.act-taken:hover { border-color: var(--taken); color: var(--fg); }
button.on-watch { color: var(--watch); border-color: var(--watch); }
button.on-avoid { color: var(--avoid); border-color: var(--avoid); }
.empty { color: var(--muted); padding: 20px 8px; }

/* The sidebar rides along as the board scrolls; if its own panels outgrow the
   viewport it scrolls internally rather than pushing off screen. */
@media (min-width: 901px) {
  aside {
    position: sticky;
    top: calc(var(--controls-h, 0px) + 12px);
    max-height: calc(100vh - var(--controls-h, 0px) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
  }
  aside::-webkit-scrollbar { width: 8px; }
  aside::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
  aside::-webkit-scrollbar-track { background: transparent; }
}

aside section { background: var(--panel); border: 1px solid var(--line);
                border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
aside section:last-child { margin-bottom: 0; }
aside h2 { margin: 0 0 8px; display: flex; justify-content: space-between; }
.pill { background: var(--panel-2); color: var(--fg); border-radius: 20px;
        padding: 1px 8px; font-size: 11px; }
ul.side, ol.side { list-style: none; margin: 0; padding: 0; font-size: 13px; }
ol.side { list-style: decimal inside; }
.side li { padding: 4px 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; }
.side li:last-child { border-bottom: none; }
.side .spos { font-size: 11px; font-weight: 700; min-width: 28px; letter-spacing: .03em; }
.side .sname { flex: 1; }
.side .tick { color: var(--muted); font-size: 11px; }
.side .gone { color: var(--taken); text-decoration: line-through; }
.side .empty { padding: 4px 0; }
.recent .who { color: var(--muted); }
.recent .who.me { color: var(--mine); }
.recent { list-style: none; }

/* week-1 matchup column (defense tab) */
th.wkcol, td.wkcol { width: 78px; }
.opp { font-size: 13px; font-weight: 600; }
.opp.home { color: var(--fg); }
.opp.away { color: var(--muted); }
tr.taken .opp { color: var(--taken); }

/* tier badge, only present when the pool was imported with tiers */
.tier { display: block; font-size: 10px; color: var(--accent); letter-spacing: .04em; }

/* tier separators on the board */
tr.tierbreak td {
  padding: 10px 8px 4px;
  border-bottom: 1px solid var(--accent);
  color: var(--accent);
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em;
}
tr.tierbreak + tr td { border-top: none; }

/* drag-to-reorder watchlist (pointer events: mouse, finger or stylus) */
.side li.draggable { cursor: grab; align-items: baseline; user-select: none; }
.side li.draggable.dragging {
  opacity: .5; cursor: grabbing;
  background: var(--panel-2); border-radius: 6px;
}
.side .grip {
  color: var(--line); font-size: 12px; letter-spacing: -2px;
  touch-action: none;              /* the grip drags, it never scrolls */
  padding: 6px 4px; margin: -6px 0 -6px -4px;
}
.side li.draggable:hover .grip { color: var(--muted); }

/* fingers need a bigger target than a mouse pointer does */
@media (pointer: coarse) {
  .side li.draggable { padding: 9px 0; }
  .side .grip { font-size: 17px; padding: 10px 8px; margin: -10px 0 -10px -6px; }

  /* the rest of the board wants thumb-sized targets too */
  table.players td { padding: 11px 8px; }
  td.acts button { width: 36px; padding: 9px 0; font-size: 15px; }
  table.players .acts { width: 160px; }
  .tabs button { padding: 10px 15px; font-size: 14px; }
  /* the bigger touch target needs a bit more room reserved for it */
  .searchbox .clear { padding: 0 9px; font-size: 19px; }
  .controls #search { padding-right: 34px; }
  .check { font-size: 14px; }
  .topbar .right button { padding: 11px 15px; }
}

/* depth chart slot, e.g. RB1 - the club's own ordering, not a ranking */
.depth {
  font-size: 10px; font-weight: 700; letter-spacing: .03em; margin-left: 6px;
  padding: 1px 4px; border-radius: 4px;
  background: var(--panel-2); color: var(--muted);
}
.depth.starter { color: var(--mine); }
.side .depth { margin-left: 4px; }

/* injury designations (Sleeper feed) */
.inj {
  display: inline-block;            /* keeps the strike-through off the badge */
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 1px 4px; margin-left: 6px; border-radius: 3px;
  border: 1px solid currentColor; vertical-align: 1px;
}
.inj.q   { color: var(--watch); }
.inj.out { color: var(--avoid); }
.side .inj { margin-left: 4px; }

/* rookies panel */
.side li.clickable { cursor: pointer; }
.side li.clickable:hover .sname { color: var(--accent); }
.side li.clickable .tick { color: var(--mine); font-weight: 700; }
/* POS | name | TEAM | ADP - the team and ADP columns line up down the list. */
.side .steam { color: var(--muted); font-size: 11px; min-width: 26px; text-align: right; }
.rookies .tick { min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }
