:root {
  --bg: #F5F1E7;
  --surface: #FFFDF8;
  --surface-alt: #EFE9DC;
  --ink: #14232B;
  --ink-soft: #4F5E66;
  --border: #DED7C8;
  --promo: #1B7A55;
  --promo-bg: #E5F4ED;
  --releg: #BF432E;
  --releg-bg: #FBEBE8;
  --brass: #B57B1C;
  --brass-bg: #FCF2DE;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 35, 43, 0.06);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.app-shell {
  width: 100%;
  max-width: 460px;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-bottom: 78px;
}

.topbar {
  background: var(--ink);
  color: #FBF8F1;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 2px solid #233844;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #223845;
  border: 1px solid rgba(251, 248, 241, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: Georgia, "Iowan Old Style", serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.5px;
  color: #FBF8F1;
  flex-shrink: 0;
}

.brand-name {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.1;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: #B9C8D0;
  font-variant-numeric: tabular-nums;
}

.fairplay-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 11px;
  font-weight: 600;
  color: #E7F5EE;
  white-space: nowrap;
  flex-shrink: 0;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #36C284;
}

.main-content {
  padding: 14px 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.card-dark {
  background: var(--ink);
  color: #FBF8F1;
  border: 1px solid #243843;
}

.loading-card {
  text-align: center;
  padding: 36px 16px;
  color: var(--ink-soft);
}

/* Matchup Header */
.matchup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.div-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--brass);
  background: var(--brass-bg);
  padding: 3px 8px;
  border-radius: 6px;
}

.matchup-date {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.versus-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

.player-box {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-box.right {
  text-align: right;
  align-items: flex-end;
}

.player-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
}

.player-name {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.player-meta {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.vs-chip {
  font-family: Georgia, serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 9px;
}

/* Scouting Strip */
.scout-toggle {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.scout-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.scout-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink);
}

.scout-hint {
  font-size: 11px;
  color: var(--ink-soft);
}

.scout-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
}

.scout-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.scout-item-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px;
  font-size: 11.5px;
}

.scout-cat {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-weight: 600;
}

.scout-pct {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.scout-pct.weak { color: var(--releg); }
.scout-pct.mid { color: var(--brass); }
.scout-pct.strong { color: var(--promo); }

.bar-track {
  height: 5px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

.bar-fill.weak { background: var(--releg); }
.bar-fill.mid { background: var(--brass); }
.bar-fill.strong { background: var(--promo); }

/* Step Switcher */
.step-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--surface-alt);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.step-btn {
  min-height: 44px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
}

.step-btn.active {
  background: var(--ink);
  color: #FBF8F1;
  box-shadow: 0 2px 6px rgba(20, 35, 43, 0.16);
}

.step-pill-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-variant-numeric: tabular-nums;
}

.step-btn:not(.active) .step-pill-count {
  background: rgba(20, 35, 43, 0.08);
  color: var(--ink);
}

/* Question Card */
.q-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.q-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.q-left-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.q-num {
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: 13px;
  color: #FBF8F1;
  background: var(--ink);
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.q-cat {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer-badge {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--ink);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.timer-badge.running {
  background: var(--brass-bg);
  color: #7D510A;
  border-color: #E2BE79;
}

.timer-badge.done {
  background: var(--promo-bg);
  color: var(--promo);
  border-color: #AAD8C4;
}

.q-prompt {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}

.q-input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #FFFFFF;
  color: var(--ink);
  font-size: 15px;
  font-family: inherit;
}

.q-input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(20, 35, 43, 0.12);
}

.q-reveal-btn {
  min-height: 46px;
  width: 100%;
  border-radius: 10px;
  border: 1.5px dashed #B9B09E;
  background: var(--surface-alt);
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.diff-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.diff-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #D9D2C3;
}

.diff-dot.on {
  background: var(--brass);
}

/* Guard Allocation */
.guard-budget {
  position: sticky;
  top: 66px;
  z-index: 12;
  background: var(--ink);
  color: #FBF8F1;
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 6px 16px rgba(20, 35, 43, 0.18);
}

.guard-budget-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.guard-budget-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.guard-total {
  font-family: Georgia, serif;
  font-size: 15px;
  font-weight: 700;
  color: #F0C46B;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.guard-chips-status {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.budget-slot {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 5px 4px;
  text-align: center;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.budget-slot.ok {
  background: rgba(27, 122, 85, 0.3);
  border-color: rgba(54, 194, 132, 0.55);
  color: #C7F5DF;
}

.budget-slot.over {
  background: rgba(191, 67, 46, 0.35);
  border-color: rgba(242, 139, 120, 0.7);
  color: #FFD7CF;
}

.guard-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guard-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.opp-rate-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.opp-rate-pill.weak { background: var(--releg-bg); color: var(--releg); }
.opp-rate-pill.mid { background: var(--brass-bg); color: #8A5B0E; }
.opp-rate-pill.strong { background: var(--promo-bg); color: var(--promo); }

.guard-snippet {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.guard-btn-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.guard-pick {
  min-height: 46px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.guard-pick.selected {
  background: var(--ink);
  color: #FBF8F1;
  border-color: var(--ink);
}

.guard-pick.selected.w3 {
  background: var(--brass);
  border-color: #93610E;
  color: #FFFDF8;
}

.guard-pick.selected.w0 {
  background: #485A63;
  border-color: #36454D;
  color: #FBF8F1;
}

/* Primary & Secondary CTAs */
.btn-primary {
  width: 100%;
  min-height: 50px;
  border: none;
  border-radius: 12px;
  background: var(--promo);
  color: #FFFFFF;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 12px 16px;
  box-shadow: 0 4px 12px rgba(27, 122, 85, 0.24);
}

.btn-primary:disabled {
  background: #A9B5B0;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  width: 100%;
  min-height: 44px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 10px 14px;
}

.cta-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* Result Scoreboard */
.scoreboard-hero {
  text-align: center;
  padding: 18px 16px;
}

.outcome-banner {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.outcome-banner.W { background: rgba(54, 194, 132, 0.22); color: #A6F2CE; }
.outcome-banner.D { background: rgba(240, 196, 107, 0.22); color: #FCE1A6; }
.outcome-banner.L { background: rgba(214, 90, 69, 0.26); color: #FFC6BC; }

.score-digits {
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.score-names {
  margin-top: 6px;
  font-size: 13px;
  color: #C7D4DB;
}

.result-kpis {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kpi-val {
  font-family: Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.kpi-lbl {
  font-size: 11px;
  color: #B4C3CC;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.share-box {
  margin-top: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  color: var(--ink);
  text-align: left;
}

.breakdown-card {
  border-left: 4px solid var(--border);
}

.breakdown-card.correct { border-left-color: var(--promo); }
.breakdown-card.wrong { border-left-color: var(--releg); }

.breakdown-answers {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 13px;
}

.ans-tag {
  font-weight: 700;
}

.ans-tag.ok { color: var(--promo); }
.ans-tag.no { color: var(--releg); }

.breakdown-expl {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.guard-delta-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
  font-weight: 700;
}

.delta-pill {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--ink);
}

.delta-pill.earned { background: var(--promo-bg); color: var(--promo); }
.delta-pill.blocked { background: var(--brass-bg); color: #8A5B0E; }

/* Standings Table */
.league-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.league-chip {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.league-chip.active {
  background: var(--ink);
  color: #FBF8F1;
  border-color: var(--ink);
}

.zone-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: middle;
}

.legend-dot.promo { background: var(--promo); }
.legend-dot.releg { background: var(--releg); }

.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.standings-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--ink-soft);
  padding: 6px 4px;
  border-bottom: 1.5px solid var(--border);
}

.standings-table th.num,
.standings-table td.num {
  text-align: right;
}

.standings-table td {
  padding: 9px 4px;
  border-bottom: 1px solid #ECE6D9;
  font-size: 13px;
}

.standings-table tr.zone-promotion td:first-child {
  box-shadow: inset 3.5px 0 0 var(--promo);
}

.standings-table tr.zone-relegation td:first-child {
  box-shadow: inset 3.5px 0 0 var(--releg);
}

.standings-table tr.is-you {
  background: var(--brass-bg);
  font-weight: 700;
}

.rank-num {
  font-weight: 700;
  padding-left: 8px !important;
  width: 28px;
}

.player-cell {
  max-width: 122px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.you-tag {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  background: var(--ink);
  color: #FBF8F1;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}

.pts-cell {
  font-weight: 800;
  color: var(--ink);
}

/* Profile / Scout */
.profile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.integrity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--promo-bg);
  color: var(--promo);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.stat-tile {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}

.stat-tile-num {
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-tile-lbl {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
  box-shadow: 0 -4px 16px rgba(20, 35, 43, 0.06);
}

.nav-btn {
  min-height: 50px;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  border-radius: 10px;
  font-size: 11.5px;
  font-weight: 700;
}

.nav-btn.active {
  color: var(--ink);
  background: var(--surface-alt);
}

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: #FBF8F1;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 40;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
