:root {
  --bg: #0b0e17;
  --panel: #151a28;
  --panel-2: #1d2438;
  --line: #2a3350;
  --text: #e9edf6;
  --muted: #8b96b2;
  --accent: #f7531f;     /* NBA orange */
  --accent-2: #1d8fff;
  --gold: #ffce4d;
  --good: #34d399;
  --bad: #f3576b;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #1a2138 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* ---------- Menu ---------- */
#screen-menu { display: grid; place-items: center; padding: 24px; }
.menu-card { text-align: center; max-width: 640px; }
.logo {
  font-size: clamp(40px, 8vw, 86px); font-weight: 900; letter-spacing: 2px;
  margin: 0 0 8px; line-height: 0.95;
}
.logo span { color: var(--accent); display: block; }
.tagline { color: var(--muted); font-size: 17px; line-height: 1.6; margin: 18px 0 34px; }

.big-btn {
  background: linear-gradient(180deg, var(--accent), #d8410f);
  color: #fff; border: none; border-radius: 12px;
  font-size: 19px; font-weight: 800; letter-spacing: 0.4px;
  padding: 16px 34px; cursor: pointer;
  box-shadow: 0 10px 30px rgba(247, 83, 31, 0.35);
  transition: transform 0.08s ease, box-shadow 0.15s ease, filter 0.15s ease;
}
.big-btn:hover { transform: translateY(-2px); filter: brightness(1.07); }
.big-btn:active { transform: translateY(0); }
.big-btn:disabled { filter: grayscale(0.6) brightness(0.7); cursor: default; box-shadow: none; }

/* ---------- Account bar + Google button ---------- */
.account-bar { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0 0 26px; }
.acc-in {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 8px 8px 12px;
}
.acc-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.acc-avatar.ph { display: grid; place-items: center; background: var(--accent-2); color: #fff; font-weight: 800; }
.acc-meta { display: flex; flex-direction: column; text-align: left; line-height: 1.25; }
.acc-meta b { font-size: 15px; }
.acc-meta small { color: var(--muted); font-size: 12px; }
.acc-note { color: var(--muted); font-size: 12px; }
.gbtn {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff; color: #1f2330; border: 1px solid #dadce0; border-radius: 8px;
  font-size: 15px; font-weight: 600; padding: 10px 18px; cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.08s ease;
}
.gbtn:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.35); transform: translateY(-1px); }
.gicon { width: 18px; height: 18px; }

/* ---------- Mode select ---------- */
.mode-select { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.mode-card {
  display: flex; flex-direction: column; gap: 8px; text-align: left;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px; padding: 22px 20px; cursor: pointer; color: var(--text);
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.mode-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 12px 26px rgba(0,0,0,0.4); }
.mode-card.rated:hover { border-color: var(--gold); box-shadow: 0 12px 26px rgba(255,206,77,0.18); }
.mc-title { font-size: 24px; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.mode-card.rated .mc-title { color: var(--gold); }
.mc-desc { color: var(--muted); font-size: 13px; line-height: 1.5; }
.mc-lock { font-size: 14px; }
@media (max-width: 560px) { .mode-select { grid-template-columns: 1fr; } }

/* ---------- Rating bits (battle + result) ---------- */
.mode-badge {
  display: inline-block; font-size: 13px; font-weight: 900; letter-spacing: 1px; color: var(--muted);
}
.mode-badge.rated { color: var(--gold); }
.rtg-chip {
  font-size: 13px; font-weight: 800; color: var(--gold);
  background: rgba(255,206,77,0.12); border: 1px solid rgba(255,206,77,0.4);
  border-radius: 999px; padding: 1px 9px; vertical-align: middle;
}
.sr-rating {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 0 auto 16px; max-width: 460px; padding: 12px 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
}
.sr-rating.up { border-color: var(--good); }
.sr-rating.down { border-color: var(--bad); }
.rtg-delta { font-size: 30px; font-weight: 900; }
.sr-rating.up .rtg-delta { color: var(--good); }
.sr-rating.down .rtg-delta { color: var(--bad); }
.rtg-line { font-size: 14px; color: var(--text); text-align: left; }
.rtg-line small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Leaderboards ---------- */
.lb-link { display: inline-block; margin-top: 8px; }
#screen-leaders { display: grid; place-items: start center; padding: 36px 20px; }
.lb-card { width: 100%; max-width: 660px; text-align: center; }
.lb-card h1 { font-size: 34px; margin: 0 0 18px; }
.lb-tabs { display: flex; gap: 6px; width: fit-content; margin: 0 auto 20px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px; }
.lb-tabs.lb-era { margin-bottom: 10px; }
.lb-tab { background: transparent; border: none; color: var(--muted); font-weight: 700; font-size: 14px;
  padding: 9px 20px; border-radius: 999px; cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.lb-tab.active { background: var(--accent); color: #fff; }
.lb-body { min-height: 140px; margin-bottom: 18px; }
.lb-loading, .lb-empty { color: var(--muted); padding: 36px 12px; line-height: 1.6; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb-table th, .lb-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.lb-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.lb-table th.num, .lb-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.lb-table td.lb-rank { color: var(--muted); font-weight: 800; width: 40px; }
.lb-table tr:first-child td.lb-rank { color: var(--gold); }
.lb-who small { display: block; color: var(--muted); font-size: 12px; }
.lb-rtg { font-weight: 800; color: var(--gold); }
.lb-pct { font-weight: 800; }
.lb-table tr.me td { background: rgba(29,143,255,0.10); }
.lb-table tr.clickable { cursor: pointer; }
.lb-table tr.clickable:hover td { background: rgba(247,83,31,0.10); }
.lb-hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }
.lb-you { font-size: 10px; background: var(--accent-2); color: #fff; padding: 1px 7px;
  border-radius: 999px; margin-left: 6px; vertical-align: middle; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 28, 0.6); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(6px);
}
.brand { font-weight: 900; letter-spacing: 1px; font-size: 20px; }
.brand span { color: var(--accent); }
.meters { display: flex; gap: 14px; }
.meter {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 16px; text-align: center; min-width: 96px;
}
.meter-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.meter-val { font-size: 22px; font-weight: 800; }
.meter-val.low { color: var(--gold); }
.meter-val.crit { color: var(--bad); }

/* ---------- Draft layout ---------- */
.draft-body {
  display: grid; grid-template-columns: 1fr 380px; gap: 24px;
  max-width: 1180px; margin: 0 auto; padding: 26px;
}
.left { min-height: 60vh; }
.hint { color: var(--muted); font-size: 14px; margin: 14px 2px; min-height: 18px; }

.offer-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-top: 6px;
}
.player-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 14px 14px;
  text-align: left; color: var(--text); cursor: pointer; position: relative;
  transition: transform 0.08s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.player-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 10px 24px rgba(0,0,0,0.4); }
.pc-pos {
  position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 800;
  color: var(--accent-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
  background: rgba(29,143,255,0.08);
}
.pc-name { font-size: 18px; font-weight: 800; margin: 2px 38px 4px 0; line-height: 1.15; }
.pc-meta { color: var(--muted); font-size: 13px; }
.pc-price { margin-top: 12px; font-size: 22px; font-weight: 900; color: var(--gold); }

/* ---------- Roster ---------- */
.right h2 { margin: 0 0 12px; font-size: 18px; }
.roster-group-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted);
  margin: 14px 4px 8px;
}
.roster-group-title:first-child { margin-top: 0; }
.slot {
  display: grid; grid-template-columns: 54px 1fr auto; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px; min-height: 50px;
}
.slot.filled { border-color: #34406a; }
.slot-tag {
  font-size: 12px; font-weight: 800; color: var(--accent); text-align: center;
  background: rgba(247,83,31,0.1); border-radius: 6px; padding: 4px 0;
}
.slot-player { display: flex; flex-direction: column; line-height: 1.2; }
.slot-player b { font-size: 15px; }
.slot-player small { color: var(--muted); font-size: 12px; }
.slot-empty { color: #586181; font-style: italic; font-size: 14px; }
.slot-price { font-weight: 800; color: var(--gold); }
@keyframes flash { 0% { background: rgba(247,83,31,0.35); } 100% { background: var(--panel); } }
.slot.flash { animation: flash 0.8s ease; }

/* ---------- Done screen ---------- */
#screen-done { display: grid; place-items: start center; padding: 36px 20px; }
.done-card { width: 100%; max-width: 820px; text-align: center; }
.done-card h1 { font-size: 40px; margin: 4px 0 18px; }
.done-card h1 span.grade { color: var(--gold); }
.done-summary { display: flex; justify-content: center; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.done-summary > div {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 22px; min-width: 110px;
}
.done-summary span { display: block; font-size: 28px; font-weight: 900; }
.done-summary label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.reveal { width: 100%; border-collapse: collapse; margin: 8px 0 22px; font-size: 14px; }
.reveal th, .reveal td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.reveal th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.reveal td small { color: var(--muted); margin-left: 6px; }
.reveal td.ovr { font-weight: 800; }
.deal-STEAL { color: var(--good); font-weight: 800; }
.deal-good { color: #8fe3bf; }
.deal-fair { color: var(--muted); }
.deal-overpaid { color: var(--bad); }
.done-note { color: var(--muted); margin: 18px 0 22px; }

/* projected stats screen */
.done-card.wide { max-width: 940px; }
.banner-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; margin: 0 0 14px; }
.team-total { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 8px; }
.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-width: 78px; }
.pill span { display: block; font-size: 24px; font-weight: 900; color: var(--gold); }
.pill label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.tbl-title { font-size: 16px; text-align: left; margin: 26px 0 8px; }
.tbl-wrap { overflow-x: auto; }
table.box { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
table.box th, table.box td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
table.box th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
table.box th:nth-child(n+3), table.box td.num { text-align: right; }
table.box td.slot-c { color: var(--accent); font-weight: 800; font-size: 12px; }
table.box td small { color: var(--muted); margin-left: 6px; }
table.box tr.grp td {
  color: var(--accent-2); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  background: rgba(29,143,255,0.05); border-bottom: none; padding-top: 12px;
}
table.box tr.total-row td {
  font-weight: 900; font-size: 14px; color: var(--text);
  border-top: 2px solid var(--line); border-bottom: none;
}

/* ---------- Set minutes screen ---------- */
#screen-minutes { display: grid; place-items: start center; padding: 30px 18px; }
.min-card { width: 100%; max-width: 720px; }
.min-card h1 { text-align: center; margin: 0 0 6px; font-size: 32px; }
.min-sub { color: var(--muted); text-align: center; font-size: 14px; line-height: 1.6; margin: 0 0 14px; }
.min-sub #min-left { display: inline-block; color: var(--gold); font-weight: 700; }
.min-actions { text-align: center; margin-bottom: 12px; }
.min-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }
.min-row {
  display: grid; grid-template-columns: 50px 1fr 150px 38px 54px; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px;
}
.min-row.over { border-color: #6b3a2a; background: rgba(247,83,31,0.06); }
.mr-slot { color: var(--accent); font-weight: 800; font-size: 12px; }
.mr-name { font-size: 14px; }
.mr-name small { display: block; color: var(--muted); font-size: 12px; }
.mr-slider { width: 100%; accent-color: var(--accent); cursor: pointer; }
.mr-min { font-weight: 800; font-size: 16px; text-align: right; }
.mr-fat { font-size: 12px; font-weight: 700; text-align: right; }
.mr-fat.ok { color: var(--good); }
.mr-fat.warn { color: var(--bad); }
.mr-fat.dnp { color: #586181; }
.min-card .big-btn { display: block; margin: 0 auto; }

/* ---------- Battle screen ---------- */
.tr-min.tired { color: var(--bad); }
.tr-min.dnp { color: #586181; }
.battle-body { max-width: 1000px; margin: 0 auto; padding: 22px; }
.done-btns { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }

.scoreboard {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 26px; margin-bottom: 18px;
}
.sb-side { display: flex; align-items: center; justify-content: center; gap: 18px; }
.sb-side:last-child { flex-direction: row-reverse; }
.sb-name { font-size: 20px; font-weight: 800; }
.sb-name.you { color: var(--accent-2); }
.sb-wins { font-size: 44px; font-weight: 900; min-width: 44px; text-align: center; }
.sb-mid { text-align: center; }
.sb-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.sb-dash { font-size: 28px; color: var(--muted); }

.matchup { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.team-col { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.team-name { margin: 0 0 12px; font-size: 18px; }
.team-name.you { color: var(--accent-2); }
.team-roster { display: flex; flex-direction: column; gap: 4px; }
.tr-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 8px; font-size: 13px; padding: 3px 0; }
.tr-slot { color: var(--accent); font-weight: 800; font-size: 11px; }
.tr-name small { color: var(--muted); margin-left: 6px; }
.tr-min { color: var(--muted); font-size: 12px; }

/* Per-group offense/defense matchup table */
.team-matchup { display: flex; flex-direction: column; gap: 3px; margin-bottom: 14px; }
.tm-row { display: grid; grid-template-columns: 1fr 38px 38px; align-items: center; gap: 6px; }
.tm-head { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 1px; }
.tm-head span:not(:first-child) { text-align: center; }
.tm-grp { font-weight: 700; color: var(--accent); font-size: 12px; }
.rt-cell { text-align: center; border-radius: 6px; padding: 3px 0; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.rt-empty { background: var(--panel-2); color: var(--muted); }

/* Live draft team summary (overall + per-group matchup) */
#draft-ratings { margin-bottom: 14px; }
.dr-ovr { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.dr-ovr-val { font-size: 26px; font-weight: 800; color: var(--gold); line-height: 1; }
.dr-ovr label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

.battle-controls { text-align: center; margin: 8px 0 18px; }

.game-log { max-width: 620px; margin: 0 auto; }
.log-title { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 6px 0 10px; }
.log-row {
  display: grid; grid-template-columns: 70px 90px 60px 1fr; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; margin-bottom: 7px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--line); border-left-width: 4px;
}
.log-row.win { border-left-color: var(--good); }
.log-row.loss { border-left-color: var(--bad); }
.lg-game { color: var(--muted); font-size: 12px; }
.lg-score b { font-size: 16px; }
.lg-res { font-weight: 800; font-size: 12px; }
.log-row.win .lg-res { color: var(--good); }
.log-row.loss .lg-res { color: var(--bad); }
.lg-top { color: var(--muted); font-size: 12px; text-align: right; }

/* per-game box scores */
.game-box { margin: 6px 0 22px; }
.gb-title { font-size: 15px; text-align: center; color: var(--text); margin: 0 0 12px; }
.gb-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.gb-team { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.gb-team.won { border-color: var(--good); }
.gb-team-name { font-weight: 800; margin-bottom: 8px; font-size: 15px; }
.gb-team.won .gb-team-name { color: var(--good); }
table.bx { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
table.bx th, table.bx td { padding: 4px 5px; border-bottom: 1px solid var(--line); text-align: right; }
table.bx th { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 0.3px; }
table.bx th:first-child, table.bx td.bx-name { text-align: left; }
table.bx td.bx-name { font-size: 12px; }
table.bx td.bx-name small { color: var(--muted); margin-left: 5px; font-size: 10px; }
table.bx td.bx-pts { font-weight: 800; color: var(--gold); }
table.bx tr.dnp td { color: #586181; font-style: italic; }
table.bx tr.bx-tot td { font-weight: 800; border-top: 2px solid var(--line); border-bottom: none; color: var(--text); }
@media (max-width: 820px) { .gb-tables { grid-template-columns: 1fr; } }

/* ---------- Live game reveal ---------- */
.team-life { text-align: center; color: var(--muted); font-size: 12px;
  text-transform: uppercase; letter-spacing: 1.5px; margin: -8px 0 16px; }
.live {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 16px; padding: 26px 20px; text-align: center;
  margin: 6px 0 22px; transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.live.win { border-color: var(--good); box-shadow: 0 0 44px rgba(52,211,153,0.22); }
.live.loss { border-color: var(--bad); box-shadow: 0 0 44px rgba(243,87,107,0.18); }
.live-q { font-size: 13px; font-weight: 900; letter-spacing: 3px; color: var(--gold);
  text-transform: uppercase; min-height: 16px; }
.live-q.flash { animation: qflash 0.4s ease; }
.live-score { display: flex; align-items: center; justify-content: center; gap: clamp(16px, 6vw, 40px); margin: 14px 0 4px; }
.ls-team { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 110px; }
.ls-pts { font-size: clamp(48px, 12vw, 72px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.ls-team.you .ls-pts { color: var(--accent-2); }
.live.win .ls-team.you .ls-pts { color: var(--good); }
.live.loss .ls-team:not(.you) .ls-pts { color: var(--bad); }
.ls-name { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.ls-vs { color: var(--muted); font-weight: 800; font-size: 14px; }
.live-qs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 14px; min-height: 24px; }
.q-chip { font-size: 12px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 11px; opacity: 0; font-variant-numeric: tabular-nums; }
.q-chip.in { animation: chipIn 0.3s ease forwards; }
.reveal-rows tbody tr { opacity: 0; animation: rowIn 0.35s ease forwards; }
.sb-wins.bump { animation: pop 0.4s ease; }
.sr-cap { color: var(--muted); font-size: 13px; margin: 4px 0 16px; }
.sr-cap.done { color: var(--gold); font-weight: 700; }
@keyframes qflash { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }
@keyframes chipIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes rowIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 35% { transform: scale(1.55); } 100% { transform: scale(1); } }

.series-result {
  text-align: center; border-radius: 16px; padding: 22px; margin-bottom: 18px;
  border: 1px solid var(--line);
}
.series-result.win { background: linear-gradient(180deg, rgba(52,211,153,0.16), transparent); border-color: var(--good); }
.series-result.loss { background: linear-gradient(180deg, rgba(243,87,107,0.14), transparent); border-color: var(--bad); }
.series-result h2 { margin: 0 0 6px; font-size: 28px; }
.sr-score { font-size: 40px; font-weight: 900; margin-bottom: 16px; }
.sr-btns { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }
.sr-mvp {
  max-width: 560px; margin: 0 auto 18px; padding: 14px 16px;
  background: var(--panel); border: 1px solid var(--gold); border-radius: 12px;
}
.mvp-tag { color: var(--gold); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 6px; }
.mvp-name { font-size: 20px; font-weight: 900; }
.mvp-name small { display: block; color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 2px; }
.mvp-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin-top: 10px; }
.mvp-line span { font-size: 13px; color: var(--muted); }
.mvp-line b { color: var(--text); font-size: 16px; font-weight: 800; margin-right: 3px; }

@media (max-width: 720px) {
  .matchup { grid-template-columns: 1fr; }
}

/* ---------- Placement modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(6, 9, 16, 0.72); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
}
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px 26px; width: 100%; max-width: 460px; text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.modal-card.wide { max-width: 580px; }
.modal-card h3 { margin: 0 0 4px; font-size: 22px; }
.modal-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.modal-slots { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 16px; }
.slot-btn {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; min-width: 120px;
  color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 3px; align-items: center;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.slot-btn b { font-size: 16px; }
.slot-btn small { font-size: 11px; color: var(--muted); }
.slot-btn:hover:not(.disabled) { transform: translateY(-2px); border-color: var(--accent); }
.slot-btn .kind { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent-2); }
.slot-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.slot-btn.disabled small { color: var(--bad); }
.text-btn {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px;
  text-decoration: underline; padding: 6px;
}
.text-btn:hover { color: var(--text); }

@media (max-width: 820px) {
  .draft-body { grid-template-columns: 1fr; }
}

/* ---------- Player headshots ---------- */
.headshot {
  --hs-size: 36px;
  width: var(--hs-size); height: var(--hs-size); flex: 0 0 auto;
  border-radius: 50%; object-fit: cover; object-position: center 12%;
  background: #141b29; border: 1px solid var(--line);
  display: inline-block; vertical-align: middle;
}
.headshot.hs-lg { --hs-size: 52px; }
.headshot.hs-xs { --hs-size: 26px; }
/* fallback badge (span swapped in when a photo 404s) */
.hs-badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; letter-spacing: .02em; font-size: calc(var(--hs-size) * 0.36);
  color: hsl(var(--hs-hue, 210) 70% 85%);
  background: hsl(var(--hs-hue, 210) 42% 30%);
  border-color: hsl(var(--hs-hue, 210) 40% 42%);
}

/* offer card: headshot + name/meta header row (pos badge stays absolute top-right) */
.pc-top { display: flex; align-items: center; gap: 12px; margin-right: 32px; }
.pc-id { min-width: 0; }
.pc-id .pc-name { margin: 0 0 2px; }

/* roster slot: photo left of the stacked name/meta */
.slot-player { flex-direction: row; align-items: center; gap: 9px; }
.sp-id { display: flex; flex-direction: column; min-width: 0; }

/* minutes row + battle team column: photo left of name */
.mr-name { display: flex; align-items: center; gap: 9px; }
.mrn-txt { min-width: 0; }
.tr-name { display: flex; align-items: center; gap: 7px; min-width: 0; }
.trn-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* team-detail modal table: small photo in the Player cell */
.td-player { display: flex; align-items: center; gap: 8px; }
.td-player small { display: block; color: var(--muted); }

/* series MVP: photo beside the name */
.mvp-head { display: flex; align-items: center; justify-content: center; gap: 14px; }
.mvp-head .mvp-name { text-align: left; }

/* ============================================================================
   MOBILE UI OVERHAUL  ·  additive, scoped, desktop untouched
   ----------------------------------------------------------------------------
   Everything below lives inside media queries so the desktop layout (all rules
   above) is byte-for-byte unchanged. No HTML/JS markup or features are altered.
     · @media (hover: none)   — touch-device feel: kill sticky :hover, add press
     · @media (max-width:768px) — phones + portrait tablets: spacing/sizing/flow
     · @media (max-width:380px) — small-phone fine-tuning
   ============================================================================ */

@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.98); } to { opacity: 1; transform: none; } }

/* ---- Touch devices: sticky :hover looks broken, so neutralize the lift/glow
        and give a quick scale press instead, so taps feel native. ------------ */
@media (hover: none) {
  .mode-card:hover        { transform: none; border-color: var(--line); box-shadow: none; }
  .mode-card.rated:hover  { border-color: var(--line); box-shadow: none; }
  .player-card:hover      { transform: none; border-color: var(--line); box-shadow: none; }
  .slot-btn:hover:not(.disabled) { transform: none; border-color: var(--line); }
  .gbtn:hover             { transform: none; box-shadow: none; }
  .big-btn:hover          { transform: none; filter: none; }

  .mode-card:active, .player-card:active, .slot-btn:active:not(.disabled),
  .gbtn:active, .big-btn:active:not(:disabled), .lb-tab:active, .text-btn:active {
    transform: scale(0.97);
    transition: transform 0.05s ease;
  }
}

/* ---- Phones + portrait tablets --------------------------------------------- */
@media (max-width: 768px) {
  html { -webkit-text-size-adjust: 100%; }   /* stop iOS bumping font sizes on rotate */
  .screen { min-height: 100dvh; }            /* dynamic vh: no content hidden under mobile toolbars */

  /* primary CTAs go full-width & a touch smaller for thumb reach */
  .big-btn { font-size: 17px; padding: 15px 22px; border-radius: 11px; }
  #draft-next, #play-game, #min-start { width: 100%; }
  .done-btns, .sr-btns { flex-direction: column; gap: 10px; }
  .done-btns .big-btn, .sr-btns .big-btn { width: 100%; }
  .text-btn { padding: 10px 8px; font-size: 13px; }

  /* ----- Menu ----- */
  #screen-menu { padding: 28px 16px; }
  .logo { letter-spacing: 1px; }
  .tagline { font-size: 14.5px; line-height: 1.55; margin: 14px 0 24px; }
  .account-bar { margin-bottom: 18px; }
  .acc-in { flex-wrap: wrap; justify-content: center; max-width: 100%; border-radius: 14px; }
  .acc-meta { min-width: 0; }
  .acc-meta small { font-size: 11px; }
  .mode-select { grid-template-columns: 1fr; gap: 12px; }
  .mode-card { padding: 16px; border-radius: 14px; }
  .mc-title { font-size: 19px; }
  .mc-desc { font-size: 12.5px; }

  /* ----- Top bar (draft + battle) ----- */
  .topbar { padding: 10px 14px; flex-wrap: wrap; gap: 8px 10px; }
  .brand { font-size: 14px; letter-spacing: 0.3px; }
  .meters { gap: 8px; }
  .meter { padding: 5px 8px; min-width: 60px; border-radius: 9px; }
  .meter-label { font-size: 9px; letter-spacing: 0.5px; }
  .meter-val { font-size: 16px; }
  .mode-badge { font-size: 10px; letter-spacing: 0.5px; }

  /* ----- Draft ----- */
  .draft-body { padding: 14px 12px 32px; gap: 16px; }
  .left { min-height: 0; }
  .hint { font-size: 13px; margin: 10px 2px; }
  .offer-grid { grid-template-columns: 1fr 1fr; gap: 10px; }   /* 9 offers -> 2-up, compact */
  .player-card { padding: 12px 11px; border-radius: 12px; display: flex; flex-direction: column; }
  .player-card .headshot.hs-lg { --hs-size: 42px; }
  .pc-name { font-size: 15px; }
  .pc-meta { font-size: 11.5px; }
  .pc-pos { top: 10px; right: 10px; font-size: 10px; padding: 1px 5px; }
  .pc-price { font-size: 18px; margin-top: auto; padding-top: 10px; }  /* pin price -> aligns across the row */

  .right h2 { font-size: 16px; margin-bottom: 10px; }
  .roster-group-title { margin: 12px 4px 6px; }
  .slot { grid-template-columns: 46px 1fr auto; gap: 8px; padding: 8px 10px; min-height: 44px; }
  .slot-player b { font-size: 14px; }
  .slot-player small { font-size: 11px; }
  .slot-price { font-size: 14px; }

  /* ----- Draft complete: continue button up top, tables below for review -----
     Reorder the card with flexbox `order` (specificity climbs so the rest stay
     in source order) so you can proceed without scrolling past three tables. */
  #screen-done { padding: 22px 12px 36px; }
  .done-card { display: flex; flex-direction: column; }
  .done-card > * { order: 3; }                            /* tables + the rest, in source order */
  .done-card > h1 { order: 0; }
  .done-card > .done-summary { order: 1; }
  .done-card > .done-note { order: 2; margin: 2px 0 10px; }   /* doubles as the button's subtitle */
  .done-card > .done-btns { order: 2; margin-bottom: 6px; }
  .done-card h1 { font-size: 26px; margin-bottom: 14px; }
  .done-summary { gap: 8px; }
  .done-summary > div { min-width: 0; flex: 1 1 calc(50% - 8px); padding: 10px 8px; }  /* 2-up */
  .done-summary span { font-size: 20px; }
  .done-summary label { font-size: 10px; }
  .tbl-title { font-size: 15px; margin: 18px 0 8px; }
  .banner-label { margin: 14px 0 10px; }
  .team-total { gap: 7px; }
  .pill { min-width: 0; flex: 1 1 calc(33.333% - 7px); padding: 8px 6px; text-align: center; }  /* 3-up stat grid */
  .pill span { font-size: 18px; }
  .pill label { font-size: 10px; }
  .done-note { font-size: 13px; }

  /* ----- Stat tables on mobile -----
     The battle box score (.bx) stays a contained, swipeable table with a frozen
     player column. iOS keeps grid/flex items at content width (min-width:auto),
     so min-width:0 lets the wide table scroll *inside* its wrapper. */
  .gb-tables, .gb-team, .matchup, .team-col, .tbl-wrap { min-width: 0; }
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-wrap::-webkit-scrollbar { height: 5px; }
  .tbl-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }
  #tm-body .tbl-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
  table.box { font-size: 12px; }
  table.box th, table.box td { padding: 6px 8px; }
  table.bx { font-size: 11px; }
  table.bx th, table.bx td { padding: 5px 6px; }
  table.bx th:first-child, table.bx td:first-child {
    position: sticky; left: 0; z-index: 1; background: var(--panel);
    max-width: 118px; overflow: hidden; text-overflow: ellipsis;
    box-shadow: 6px 0 8px -6px rgba(0,0,0,0.45);
  }

  /* ----- Draft-complete tables -> per-player cards -----
     A 12-column box score can't fit a phone, so a wide table forced the browser to
     shrink the whole page (everything tiny + pinch-zoom). Reflow each row into a
     card: name on top, stats as labeled chips that wrap. The data-label attributes
     come from app.js and are simply ignored by the desktop table. */
  #screen-done { display: block; }                       /* definite width: nothing can blow out the page */
  #screen-done .tbl-wrap { overflow: visible; background: none; border: none; padding: 0; }
  #screen-done table.box, #screen-done table.box > tbody { display: block; }
  #screen-done table.box > thead { display: none; }
  #screen-done table.box > tbody > tr {
    display: block; position: relative; white-space: normal;   /* base table sets nowrap; let chips wrap */
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    padding: 9px 12px; margin-bottom: 8px;
  }
  #screen-done table.box > tbody > tr.grp {              /* "Starters" / "Bench" divider */
    background: none; border: none; padding: 12px 2px 2px; margin: 0;
  }
  #screen-done table.box > tbody > tr.grp td {
    color: var(--accent-2); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px;
  }
  #screen-done table.box > tbody > tr.total-row { border-color: var(--gold); }
  #screen-done table.box > tbody > tr > td { display: inline-block; border: none; padding: 0; text-align: left; }
  #screen-done table.box td.slot-c {                     /* slot badge, pinned top-right */
    position: absolute; top: 9px; right: 10px;
    font-size: 10px; font-weight: 800; color: var(--accent);
    background: rgba(247,83,31,0.12); border-radius: 6px; padding: 2px 7px;
  }
  #screen-done table.box > tbody > tr > td:nth-child(2) {  /* player name = card title */
    display: block; font-weight: 700; font-size: 14px; margin: 0 60px 7px 0;
  }
  #screen-done table.box td small { color: var(--muted); margin-left: 6px; font-weight: 400; }
  #screen-done table.box td.num {                        /* stat -> labeled chip */
    min-width: 46px; margin: 0 13px 3px 0; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
  }
  #screen-done table.box td.num::before {
    content: attr(data-label); display: block;
    font-size: 9px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 1px;
  }
  #screen-done table.box > tbody > tr.total-row > td:first-child:empty { display: none; }

  /* ----- Set rotation (minutes) — was overflowing badly; go 2-row per player ----- */
  #screen-minutes { padding: 18px 12px 32px; }
  .min-card h1 { font-size: 24px; }
  .min-sub { font-size: 12.5px; line-height: 1.5; }
  .min-list { gap: 8px; }
  .min-row {
    grid-template-columns: auto 1fr auto auto;
    grid-template-areas:
      "slot name min fat"
      "slider slider slider slider";
    gap: 6px 10px; padding: 10px 12px; align-items: center;
  }
  .mr-slot   { grid-area: slot; }
  .mr-name   { grid-area: name; }
  .mr-min    { grid-area: min; }
  .mr-fat    { grid-area: fat; }
  .mr-slider { grid-area: slider; width: 100%; height: 26px; }  /* full-width, taller tap target */

  /* Find Opponent up top so you don't scroll past all 8 sliders to continue
     (minutes auto-balance on load, so the button is usable immediately). */
  .min-card { display: flex; flex-direction: column; }
  .min-card > * { order: 3; }
  .min-card > h1 { order: 0; }
  .min-card > .min-sub { order: 1; }
  .min-card > #min-start { order: 2; margin-bottom: 12px; }

  /* ----- Battle ----- */
  .battle-body { padding: 14px 12px 30px; }
  .scoreboard { padding: 14px 12px; gap: 10px; border-radius: 14px; }
  .sb-side { gap: 10px; }
  .sb-name { font-size: 14px; }
  .sb-wins { font-size: 32px; min-width: 32px; }
  .sb-dash { font-size: 22px; }
  .sb-label { font-size: 10px; }
  .matchup { grid-template-columns: 1fr; gap: 12px; }
  .team-col { padding: 12px; border-radius: 12px; }
  .team-name { font-size: 16px; }
  .battle-controls { margin: 6px 0 14px; }
  .live { padding: 20px 14px; border-radius: 14px; }
  .live-qs { gap: 6px; }
  .series-result { padding: 18px 14px; border-radius: 14px; }
  .series-result h2 { font-size: 21px; }
  .sr-score { font-size: 30px; margin-bottom: 12px; }
  .sr-mvp { padding: 12px; }
  .mvp-name { font-size: 18px; }
  .sr-rating { gap: 12px; padding: 12px; }
  .rtg-delta { font-size: 26px; }
  /* series log: two-line rows so the top-scorer line never gets crushed */
  .log-row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "game score res"
      "top  top   top";
    gap: 3px 10px; padding: 9px 12px;
  }
  .lg-game  { grid-area: game; }
  .lg-score { grid-area: score; text-align: center; }
  .lg-res   { grid-area: res; }
  .lg-top   { grid-area: top; text-align: left; }

  /* ----- Leaderboards ----- */
  #screen-leaders { padding: 22px 12px 32px; }
  .lb-card h1 { font-size: 24px; margin-bottom: 14px; }
  .lb-tabs { margin-bottom: 12px; padding: 4px; }
  .lb-tabs.lb-era { margin-bottom: 8px; }
  .lb-tab { padding: 8px 14px; font-size: 13px; }
  .lb-table { font-size: 13px; }
  .lb-table th, .lb-table td { padding: 8px; }
  .lb-table td.lb-rank { width: 28px; }
  .lb-who small { font-size: 11px; }

  /* ----- Modals (placement + team detail) ----- */
  .modal { padding: 14px; }
  .modal-card { padding: 20px 16px; max-height: 88vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch; animation: modalIn 0.2s ease; }
  .modal-card h3 { font-size: 19px; }
  .modal-slots { gap: 10px; }
  .slot-btn { min-width: 0; flex: 1 1 calc(50% - 10px); padding: 13px 12px; }  /* 2-up */
}

/* ---- Small phones ---------------------------------------------------------- */
@media (max-width: 380px) {
  .logo { font-size: 32px; }
  .brand { font-size: 13px; }
  .meter { min-width: 54px; }
  .offer-grid { gap: 8px; }
  .player-card { padding: 10px 9px; }
  .pc-price { font-size: 17px; }
  .sb-wins { font-size: 28px; }
}
