:root {
  --bg: #0a0e1a;
  --surface: #141824;
  --card: #1c2235;
  --border: #252d45;
  --accent: #cc0000;
  --accent2: #e63900;
  --gold: #f0a500;
  --green: #2ecc71;
  --blue: #3b82f6;
  --text: #e8eaf0;
  --muted: #6b7394;
  --radius: 8px;
  --pos-qb: #e74c3c;
  --pos-rb: #27ae60;
  --pos-wr: #3498db;
  --pos-te: #e67e22;
  --pos-k: #9b59b6;
  --pos-dst: #1abc9c;
  --pos-flex: #f39c12;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Layout ─── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.logo span { color: var(--text); }

nav {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
}
.nav-btn:hover { color: var(--text); background: var(--card); }
.nav-btn.active { color: var(--text); background: var(--accent); }

.header-actions { display: flex; gap: 8px; margin-left: auto; }

main { flex: 1; padding: 16px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ─── Views ─── */
.view { display: none; }
.view.active { display: block; }

/* ─── Cards ─── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--card); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-icon { padding: 6px 8px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-green { background: var(--green); color: #fff; }
.btn-blue { background: var(--blue); color: #fff; }

/* ─── Position badges ─── */
.pos-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 34px;
  text-align: center;
}
.pos-QB { background: var(--pos-qb); color: #fff; }
.pos-RB { background: var(--pos-rb); color: #fff; }
.pos-WR { background: var(--pos-wr); color: #fff; }
.pos-TE { background: var(--pos-te); color: #fff; }
.pos-K { background: var(--pos-k); color: #fff; }
.pos-DST,.pos-D\/ST { background: var(--pos-dst); color: #fff; }
.pos-FLEX { background: var(--pos-flex); color: #fff; }

/* ─── Home ─── */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mode-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.mode-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.mode-card .icon { font-size: 2rem; margin-bottom: 10px; }
.mode-card h3 { font-size: 1rem; margin-bottom: 4px; }
.mode-card p { font-size: 0.82rem; color: var(--muted); line-height: 1.4; }

/* ─── Draft Board ─── */
.draft-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 12px;
  height: calc(100vh - 100px);
}
@media (max-width: 900px) {
  .draft-layout { grid-template-columns: 1fr; height: auto; }
}

.draft-main { display: flex; flex-direction: column; gap: 8px; min-height: 0; }

.draft-sidebar { display: flex; flex-direction: column; gap: 8px; min-height: 0; }

/* Draft status bar */
.draft-status {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.draft-status .pick-info { font-weight: 700; font-size: 1.05rem; }
.draft-status .round-info { color: var(--muted); font-size: 0.85rem; }
.draft-status .turn-badge {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
}
.turn-badge.your-turn { background: var(--green); color: #000; animation: pulse 1s infinite; }
.turn-badge.waiting { background: var(--border); color: var(--muted); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }

/* Draft timer */
.draft-timer {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--gold);
  min-width: 36px;
  text-align: center;
}
.draft-timer.urgent { color: var(--accent); animation: pulse 0.5s infinite; }

/* Player search & filters */
.player-controls {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.search-input {
  flex: 1;
  min-width: 150px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }

.pos-filter {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pos-filter-btn {
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.pos-filter-btn:hover { color: var(--text); }
.pos-filter-btn.active { color: #fff; border-color: transparent; }
.pos-filter-btn.active[data-pos="ALL"] { background: var(--accent); }
.pos-filter-btn.active[data-pos="QB"] { background: var(--pos-qb); }
.pos-filter-btn.active[data-pos="RB"] { background: var(--pos-rb); }
.pos-filter-btn.active[data-pos="WR"] { background: var(--pos-wr); }
.pos-filter-btn.active[data-pos="TE"] { background: var(--pos-te); }
.pos-filter-btn.active[data-pos="K"] { background: var(--pos-k); }
.pos-filter-btn.active[data-pos="D/ST"] { background: var(--pos-dst); }

/* Player list */
.player-list-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.player-list-header {
  display: grid;
  grid-template-columns: 36px 1fr 60px 70px 70px 80px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.player-list {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.player-row {
  display: grid;
  grid-template-columns: 36px 1fr 60px 70px 70px 80px;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  align-items: center;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.875rem;
}
.player-row:hover { background: rgba(255,255,255,0.04); }
.player-row.drafted { opacity: 0.35; pointer-events: none; }

.player-rank { color: var(--muted); font-size: 0.8rem; }
.player-name-col { display: flex; flex-direction: column; }
.player-name { font-weight: 600; }
.player-nfl { color: var(--muted); font-size: 0.75rem; }
.player-proj { font-weight: 600; color: var(--gold); }
.player-adp { color: var(--muted); font-size: 0.8rem; }
.player-bye { color: var(--muted); font-size: 0.8rem; }

.pick-btn {
  padding: 4px 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: background 0.15s;
}
.pick-btn:hover { background: var(--accent2); }
.pick-btn:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

/* ─── Roster Panel ─── */
.roster-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
}

.roster-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  margin-bottom: 4px;
  font-size: 0.83rem;
}
.roster-slot.empty { border-color: var(--border); border-style: dashed; color: var(--muted); }
.roster-slot.filled { background: var(--surface); border-color: var(--border); }
.roster-slot-pos { min-width: 42px; }
.roster-player-name { flex: 1; font-weight: 600; }
.roster-player-nfl { color: var(--muted); font-size: 0.75rem; }

/* ─── Draft Board Grid ─── */
.board-grid-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 400px;
}

.board-grid {
  display: table;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.board-grid th, .board-grid td {
  padding: 5px 8px;
  border: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: top;
}
.board-grid th { background: var(--surface); color: var(--muted); font-weight: 700; position: sticky; top: 0; z-index: 1; }
.board-grid td { background: var(--card); }
.board-grid td.my-pick { background: rgba(204,0,0,0.15); }
.board-grid td.current-pick { background: rgba(240,165,0,0.2); animation: pulse 1s infinite; }

.mini-pick { line-height: 1.3; }
.mini-pick .mp-name { font-weight: 600; }
.mini-pick .mp-pos { font-size: 0.7rem; }

/* ─── Companion Mode ─── */
.companion-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 12px;
}
@media (max-width: 900px) {
  .companion-layout { grid-template-columns: 1fr; }
}

/* ─── Settings ─── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.form-group { margin-bottom: 12px; }
.form-label { display: block; margin-bottom: 4px; font-size: 0.82rem; color: var(--muted); font-weight: 600; }
.form-control {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
}
.form-control:focus { border-color: var(--accent); }

/* ─── Rankings View ─── */
.rankings-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.rankings-table th { background: var(--surface); padding: 8px 12px; text-align: left; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; position: sticky; top: 0; border-bottom: 1px solid var(--border); }
.rankings-table td { padding: 7px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.rankings-table tr:hover td { background: rgba(255,255,255,0.03); }
.rankings-table .tier-header td { background: var(--surface); color: var(--muted); font-weight: 700; font-size: 0.78rem; padding: 4px 12px; }

/* ─── Toast ─── */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.875rem;
  max-width: 300px;
  animation: slideIn 0.2s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--accent); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 100%;
}
.modal h2 { margin-bottom: 16px; font-size: 1.2rem; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }

/* ─── AI thinking indicator ─── */
.ai-thinking {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}
.dots { display: flex; gap: 4px; }
.dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  animation: bounce 1s infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce { 0%,80%,100% { transform: scale(0.8); } 40% { transform: scale(1.2); } }

/* ─── Recommendation ─── */
.rec-card {
  background: var(--surface);
  border: 1px solid var(--green);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
}
.rec-card h4 { font-size: 0.85rem; color: var(--green); margin-bottom: 8px; }
.rec-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.rec-player:last-child { border-bottom: none; }
.rec-player:hover { opacity: 0.8; }
.rec-rank { font-size: 0.78rem; color: var(--muted); min-width: 20px; }
.rec-info { flex: 1; }
.rec-name { font-weight: 600; font-size: 0.9rem; }
.rec-detail { font-size: 0.75rem; color: var(--muted); }
.rec-proj { font-size: 0.85rem; color: var(--gold); font-weight: 700; }
.rec-reason { font-size: 0.72rem; color: var(--green); margin-top: 2px; }

/* ─── History / Stats ─── */
.stat-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.stat-row:last-child { border-bottom: none; }
.stat-val { font-weight: 700; color: var(--gold); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  main { padding: 8px; }
  .player-list-header, .player-row {
    grid-template-columns: 30px 1fr 48px 54px 50px 64px;
    font-size: 0.8rem;
    padding: 6px 8px;
  }
  header { padding: 0 10px; }
  .draft-timer { font-size: 1rem; }
}

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.pick-log {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
}
.pick-log-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.82rem;
}
.pick-log-item.my-pick { background: rgba(204,0,0,0.1); border-radius: 4px; padding: 5px 6px; }
.pick-num { color: var(--muted); min-width: 28px; font-size: 0.75rem; }
.pick-team { color: var(--muted); font-size: 0.78rem; flex: 1; }

.highlight { color: var(--gold); font-weight: 700; }
.text-muted { color: var(--muted); }
.text-green { color: var(--green); }
.text-red { color: var(--accent); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.fw-700 { font-weight: 700; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { font-size: 0.85rem; }

/* Install prompt */
#install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  z-index: 300;
  max-width: 340px;
  width: calc(100% - 32px);
}
#install-prompt.hidden { display: none; }
#install-prompt p { flex: 1; font-size: 0.85rem; }

.speed-btn {
  padding: 4px 10px;
  background: var(--border);
  border: none;
  border-radius: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
}
.speed-btn.active { background: var(--accent); color: #fff; }

.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.tab-btn {
  flex: 1;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
  text-align: center;
}
.tab-btn.active { background: var(--card); color: var(--text); }

/* Need meter */
.need-bars { display: flex; flex-direction: column; gap: 4px; }
.need-row { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; }
.need-pos { min-width: 36px; }
.need-bar-bg { flex: 1; height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; }
.need-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.need-score { min-width: 20px; text-align: right; font-weight: 700; color: var(--gold); }

/* ─── News Feed ─── */
.news-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.news-item:hover { border-color: var(--accent); }
.news-headline {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text);
}
.news-header { display: flex; gap: 10px; }
.news-body {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.news-body.hidden { display: none; }

/* Live badge */
.live-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
  margin-right: 4px;
  vertical-align: middle;
}
