:root {
  /* Deep navy + teal, unconditionally — a fixed brand look (same idea as
     Sleeper's own app), not something toggled by the device's light/dark
     setting. A @media (prefers-color-scheme) override here would get
     re-overridden right back to light by most phones' default reporting,
     which is exactly why the first version of this never actually showed up. */
  --bg: #0a0e1a;
  --surface: #131a2b;
  --surface-2: #1b2338;
  --text: #f3f5fa;
  --text-dim: #d3d7e6; /* was #8b93ac, then #b3bad0 — pushed further after both still read as too grey on a real device at the small sizes used everywhere */
  --border: #232c44;
  --accent: #17e0b3;
  --accent-2: #17e0b3;
  --live: #17e0b3;
  --q: #f0c53e;
  --d: #ffb066; /* was #ff9d4d — brightened alongside text-dim, since "proj" text was called out specifically */
  --o: #ff5c72;
  --ir: #d1495c;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.league-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.league-avatar { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--surface-2); }
.league-text { min-width: 0; }
.league-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.league-sub { font-size: 12px; color: var(--text-dim); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.refresh-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 0 0 rgba(23,224,179,.6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(23,224,179,.5); }
  70% { box-shadow: 0 0 0 6px rgba(23,224,179,0); }
  100% { box-shadow: 0 0 0 0 rgba(23,224,179,0); }
}

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); }

.last-updated {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  padding: 6px 0 0;
}

.error-banner {
  margin: 10px 16px 0;
  padding: 10px 12px;
  background: rgba(224, 67, 90, 0.12);
  border: 1px solid var(--o);
  color: var(--o);
  border-radius: 10px;
  font-size: 13px;
}

.injury-banner {
  margin: 10px 16px 0;
  padding: 10px 12px;
  background: rgba(216, 119, 43, 0.12);
  border: 1px solid var(--d);
  border-radius: 10px;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}
.injury-banner:not([hidden]) { display: flex; }
.injury-banner-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--d);
}
.injury-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px 3px 10px;
  cursor: pointer;
}

.section-note {
  font-size: 11px;
  color: var(--text-dim);
  margin: -4px 4px 8px;
  line-height: 1.4;
}
.section-note a { color: var(--accent-2); font-weight: 700; }

main { flex: 1; padding: 10px 16px 24px; }

.section-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 18px 4px 8px;
}
.section-heading:first-child { margin-top: 4px; }

.stack { display: flex; flex-direction: column; gap: 10px; }

/* Matchup card */
.matchup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.matchup-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}
.matchup-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.matchup-team { flex: 1; min-width: 0; }
.matchup-team-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matchup-team-meta { font-size: 11px; color: var(--text-dim); }
.matchup-score { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
.matchup-score.winning { color: var(--accent-2); }
.matchup-divider { height: 1px; background: var(--border); margin: 2px 0; }
.matchup-bye { text-align: center; color: var(--text-dim); font-size: 13px; padding: 8px 0; }
.matchup-card.clickable { cursor: pointer; }
.matchup-tap-hint { text-align: center; font-size: 10px; color: var(--text-dim); padding-top: 6px; margin-top: 2px; border-top: 1px solid var(--border); }

/* Standings */
.standings-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.standings-table th, .standings-table td { text-align: left; padding: 10px 8px; font-size: 13px; border-bottom: 1px solid var(--border); }
.standings-table th { color: var(--text-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.standings-table tbody tr:last-child td { border-bottom: none; }
.rank-col { width: 28px; }
.standings-table td.rank-col { font-weight: 700; color: var(--text-dim); }
.standings-team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.standings-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.standings-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42vw; }
.standings-name.me { color: var(--accent); font-weight: 700; }
.standings-table td:nth-child(4), .standings-table td:nth-child(5),
.standings-table th:nth-child(4), .standings-table th:nth-child(5) { font-variant-numeric: tabular-nums; }

/* My team */
.myteam-header {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 4px;
}
.myteam-header img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: var(--surface-2); }
.myteam-title { font-weight: 700; font-size: 16px; }
.myteam-record { font-size: 12px; color: var(--text-dim); }
.myteam-summary { margin-left: auto; text-align: right; flex-shrink: 0; }
.myteam-summary-pts { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.myteam-summary-meta { font-size: 11px; color: var(--text-dim); }

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
}
.player-slot {
  font-size: 10px;
  font-weight: 700;
  color: var(--text); /* was --text-dim — a 2-4 char badge gains nothing from being dimmed and loses a lot of legibility at 10px */
  width: 34px;
  flex-shrink: 0;
  text-align: center;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 3px 0;
}
.player-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.player-info { flex: 1; min-width: 0; }
.player-name-row { display: flex; align-items: center; gap: 6px; }
.player-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta { font-size: 11px; color: var(--text-dim); }
.player-points { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; flex-shrink: 0; }

.badge {
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 5px;
  color: #fff;
  flex-shrink: 0;
  line-height: 1.5;
  background: #555b66;
}
.badge-Q { background: var(--q); }
.badge-D { background: var(--d); }
.badge-O { background: var(--o); }
.badge-IR { background: var(--ir); }
.badge-PUP { background: var(--ir); }
.badge-SUS { background: #555b66; }
.badge-NA { background: #555b66; }

.empty-state { text-align: center; color: var(--text-dim); font-size: 13px; padding: 30px 10px; }

/* Start/sit suggestions */
.suggestion-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
}
.suggestion-slot {
  font-size: 10px;
  font-weight: 700;
  color: var(--text); /* was --text-dim — same reasoning as .player-slot */
  width: 34px;
  flex-shrink: 0;
  text-align: center;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 3px 0;
  margin-top: 2px;
}
.suggestion-body { flex: 1; min-width: 0; }
.suggestion-swap { font-size: 14px; font-weight: 600; }
.suggestion-swap .sit { color: var(--text-dim); text-decoration: line-through; }
.suggestion-swap .arrow { color: var(--text-dim); margin: 0 4px; }
.suggestion-swap .start { color: var(--accent-2); }
.suggestion-reason { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.trade-suggestion-team { font-size: 11px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 4px; }
.trade-suggestion-swap { font-size: 14px; font-weight: 600; }
.trade-suggestion-swap > div { margin-bottom: 2px; }
.trade-suggestion-swap .sit { color: var(--text-dim); }
.trade-suggestion-swap .start { color: var(--accent-2); }
.trade-suggestion-edge { font-size: 12px; font-weight: 700; color: var(--accent-2); margin-top: 4px; }
.trade-suggestion-load {
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

/* Waiver wire */
.waiver-note { font-size: 11px; color: var(--text-dim); margin: -4px 0 2px; }

/* Tab strip */
.tabstrip {
  position: sticky;
  top: 57px;
  z-index: 9;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.tabstrip::-webkit-scrollbar { display: none; }
.tab-chip {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.pos-filter-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
  margin-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.pos-filter-strip::-webkit-scrollbar { display: none; }
.pos-chip {
  flex-shrink: 0;
  padding: 5px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.pos-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.tab-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Settings modal */
.settings-modal {
  border: none;
  border-radius: 16px;
  padding: 18px;
  width: min(92vw, 420px);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.settings-modal::backdrop { background: rgba(0,0,0,0.5); }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 17px; margin: 0; }

.matchup-detail-modal {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  border-radius: 0;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(14px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.matchup-detail-header-row:not([hidden]) { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 4px; gap: 10px; }
.matchup-detail-team-heading { font-size: 13px; font-weight: 700; }
.matchup-detail-team-heading.right { text-align: right; }
.matchup-detail-total { font-size: 13px; font-weight: 700; }
.matchup-detail-yts { font-size: 11px; font-weight: 600; color: var(--text-dim); }
.matchup-detail-yts.right { text-align: right; }
.matchup-detail-rows { display: flex; flex-direction: column; gap: 8px; }
.matchup-slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 8px;
}
.matchup-slot-label {
  flex-shrink: 0;
  width: 34px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text); /* was --text-dim — same reasoning as .player-slot, even smaller here at 9px */
  background: var(--surface-2);
  border-radius: 6px;
  padding: 3px 0;
}
.slot-side { flex: 1; min-width: 0; }
.slot-side.right { text-align: right; }
.slot-side-name-row { display: flex; align-items: center; gap: 4px; }
.slot-side.right .slot-side-name-row { flex-direction: row-reverse; }
.slot-side-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-side-meta { font-size: 10px; color: var(--text-dim); }
.slot-side-pts { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.slot-side-proj { font-size: 11px; font-weight: 700; color: var(--d); margin-left: 5px; }
.slot-side.right .slot-side-proj { margin-left: 0; margin-right: 5px; }

.matchup-detail-bench-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin: 18px 4px 8px;
}
.matchup-detail-bench-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bench-compact-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 8px;
}
.bench-compact-name { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; }
.bench-compact-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bench-compact-meta { font-size: 10px; color: var(--text-dim); margin-top: 1px; }
.bench-compact-pts { font-size: 13px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.modal-hint { font-size: 12px; color: var(--text-dim); margin: 6px 0 14px; }
.owner-picker { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.owner-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}
.owner-option.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }
.owner-option img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface); }
.owner-option-name { font-size: 14px; font-weight: 600; }
.owner-option-sub { font-size: 11px; color: var(--text-dim); }

/* Trade check */
.trade-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 420px) {
  .trade-columns { grid-template-columns: 1fr; }
}
.trade-side-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.trade-add-btn {
  width: 100%;
  margin-top: 8px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.trade-total {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.trade-verdict {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
  font-size: 15px;
  font-weight: 700;
}
.trade-verdict.favor { border-color: var(--accent-2); color: var(--accent-2); }
.trade-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
}
.player-search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  margin-bottom: 12px;
}

@media (min-width: 480px) {
  main { padding-left: 20px; padding-right: 20px; }
}
