/* ---------- Design tokens ----------
   Background:  #12181A  (chalkboard ink)
   Surface:     #1C2426
   Surface-2:   #232D2F
   Border:      #2E3A3C
   Text:        #EDEDE3  (chalk)
   Text-muted:  #8A9591
   Signature:   #F2B705  (marker yellow — used sparingly)
   Positions:   QB #E4572E  RB #3AAED8  WR #6FCF97  TE #B389D9  K #C9C9C9  DST #D8536F
------------------------------------- */

:root {
  --bg: #12181A;
  --surface: #1C2426;
  --surface-2: #232D2F;
  --border: #2E3A3C;
  --text: #EDEDE3;
  --text-muted: #8A9591;
  --accent: #F2B705;
  --accent-ink: #171200;
  --danger: #D8536F;
  --pos-qb: #E4572E;
  --pos-rb: #3AAED8;
  --pos-wr: #6FCF97;
  --pos-te: #B389D9;
  --pos-k:  #C9C9C9;
  --pos-dst:#D8536F;

  --font-display: 'Teko', sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
}

button { font-family: inherit; }
input, select { font-family: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.screen { display: none; min-height: 100vh; }
.screen.visible { display: block; }

/* ---------- Auth screens ---------- */
#screen-login.visible,
#screen-invite.visible {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% -10%, rgba(242,183,5,0.08), transparent 45%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 32px 28px 28px;
}

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 6px 9px 4px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}
.brand h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: 0.5px;
  margin: 0;
}
.brand-sm h1 { font-size: 24px; }

.auth-sub { color: var(--text-muted); margin: 6px 0 22px; font-size: 14px; }

form label {
  display: block;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
form label input, form label select {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 7px;
  font-size: 15px;
}
form label input:focus, form label select:focus { border-color: var(--accent); }

.form-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
}
.form-success {
  color: var(--pos-wr);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
}

.btn {
  font-weight: 600;
  font-size: 14px;
  border-radius: 7px;
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.06s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #ffcb2e; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- App shell ---------- */
#screen-app.visible { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.league-picker { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 180px; }
.league-picker select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 14px;
  max-width: 260px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-chip { font-size: 13px; color: var(--text-muted); }

/* ---------- Mobile pane tabs ---------- */
.mobile-tabs { display: none; }
.mobile-tab {
  flex: 1;
  background: var(--surface);
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px;
  font-weight: 600;
  font-size: 14px;
}
.mobile-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Layout ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  overflow: hidden;
}

.pane { overflow-y: auto; }
.pane-board { padding: 16px 18px 40px; border-right: 1px solid var(--border); }
.pane-roster { padding: 16px 16px 40px; background: var(--surface); }

/* ---------- Board controls ---------- */
.board-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  background: var(--bg);
  padding-top: 2px;
  z-index: 5;
}

#search-input {
  flex: 1 1 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 14px;
}
#search-input:focus { border-color: var(--accent); }

.pos-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.pos-tab {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
}
.pos-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- Board list ---------- */
.board-head {
  display: grid;
  grid-template-columns: 52px 1fr 130px 96px;
  gap: 10px;
  padding: 6px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.board-list { display: flex; flex-direction: column; }

.player-row {
  display: grid;
  grid-template-columns: 52px 1fr 130px 96px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.5s ease;
}
.player-row:hover { background: var(--surface); }
.player-row.flash { background: rgba(242,183,5,0.16); transition: background 0.05s ease; }

.rank-chip {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  width: 40px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--bg);
  line-height: 1;
}
.rank-chip.pos-QB { background: var(--pos-qb); }
.rank-chip.pos-RB { background: var(--pos-rb); }
.rank-chip.pos-WR { background: var(--pos-wr); }
.rank-chip.pos-TE { background: var(--pos-te); }
.rank-chip.pos-K  { background: var(--pos-k); }
.rank-chip.pos-DST{ background: var(--pos-dst); }

.player-row.is-drafted .rank-chip {
  background: var(--surface-2);
  color: var(--text-muted);
}

.player-name-wrap { min-width: 0; }
.player-name { font-size: 15px; font-weight: 500; }
.player-meta { font-size: 12px; color: var(--text-muted); }
.pos-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-right: 6px;
  color: var(--bg);
}
.pos-tag.pos-QB { background: var(--pos-qb); }
.pos-tag.pos-RB { background: var(--pos-rb); }
.pos-tag.pos-WR { background: var(--pos-wr); }
.pos-tag.pos-TE { background: var(--pos-te); }
.pos-tag.pos-K  { background: var(--pos-k); }
.pos-tag.pos-DST{ background: var(--pos-dst); }

.player-row.is-drafted .player-name {
  text-decoration: line-through;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 2px;
  color: var(--text-muted);
}

.col-team { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }

.col-action { display: flex; justify-content: flex-end; }
.draft-btn {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}
.draft-btn:hover { border-color: var(--accent); color: var(--accent); }
.draft-btn.is-mine { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.empty-state { color: var(--text-muted); text-align: center; padding: 40px 0; }

/* ---------- Roster panel ---------- */
.roster-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.roster-head h2 { font-family: var(--font-display); font-size: 22px; font-weight: 600; margin: 0; letter-spacing: 0.3px; }
.roster-count { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.roster-list { display: flex; flex-direction: column; gap: 6px; }
.roster-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  min-height: 44px;
}
.roster-slot.empty { border-style: dashed; }
.slot-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  width: 46px;
  flex-shrink: 0;
}
.slot-player-name { font-size: 14px; font-weight: 500; }
.slot-empty-text { font-size: 13px; color: var(--text-muted); font-style: italic; }
.slot-player-meta { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

/* ---------- Modals ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
}
.modal h2 { font-family: var(--font-display); font-weight: 600; font-size: 24px; margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .mobile-tabs { display: flex; }
  .pane-roster, .pane-board { border-right: none; }
  .pane { display: none; }
  .pane.pane-visible { display: block; }
  .board-head .col-team, .player-row .col-team { display: none; }
  .board-head, .player-row { grid-template-columns: 44px 1fr 88px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
