:root {
  --bg: #0a0e1a;
  --bg-elevated: #121a2b;
  --card: #161f33;
  --card-2: #1b2540;
  --card-border: #26314d;
  --gold: #d4af37;
  --gold-bright: #f4d374;
  --gold-dim: #a9862a;
  --text: #f4f6fb;
  --text-dim: #9aa5bd;
  --text-faint: #6b7590;
  --green: #3ecf8e;
  --red: #e5566d;
  --amber: #e8b64a;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 8px 24px rgba(212, 175, 55, 0.28);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(212, 175, 55, 0.10) 0%, transparent 45%),
    radial-gradient(circle at 85% 0%, rgba(62, 111, 207, 0.08) 0%, transparent 40%),
    radial-gradient(circle at top, #10182a 0%, var(--bg) 55%, #05070d 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

a { color: var(--gold); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeUp 0.5s var(--ease) both; }

#main-content { animation: fadeUp 0.35s var(--ease) both; }

button {
  font-family: inherit;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.12s var(--ease), box-shadow 0.2s var(--ease), opacity 0.15s ease, filter 0.2s ease;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold) 55%, var(--gold-dim));
  color: #1a1300;
  box-shadow: var(--shadow-gold);
}
.btn-primary:hover { box-shadow: 0 10px 28px rgba(212, 175, 55, 0.45); filter: brightness(1.05); transform: translateY(-1px); }
.btn-secondary {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover { border-color: var(--gold-dim); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--card-border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-faint); }
.btn-danger {
  background: rgba(229, 86, 109, 0.15);
  color: var(--red);
  border: 1px solid rgba(229, 86, 109, 0.4);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; }

input, select, textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.field { margin-bottom: 16px; }

/* Auth screens */
.auth-screen {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.auth-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px circle at 50% 0%, rgba(212, 175, 55, 0.08), transparent 60%);
  pointer-events: none;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(165deg, var(--card-2) 0%, var(--card) 60%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 36px 30px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  position: relative;
  z-index: 1;
}
.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 26px;
  text-align: center;
}
.auth-logo img {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  margin-bottom: 16px;
  box-shadow: 0 10px 28px rgba(212, 175, 55, 0.3), 0 0 0 1px rgba(212, 175, 55, 0.25);
}
.auth-logo h1 {
  font-size: 24px;
  margin: 0 0 6px;
  letter-spacing: 0.01em;
  font-weight: 800;
}
.auth-logo .gold-script {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-logo .tagline {
  color: var(--text-faint);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.auth-error {
  background: rgba(229, 86, 109, 0.12);
  border: 1px solid rgba(229, 86, 109, 0.35);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  animation: fadeUp 0.25s var(--ease) both;
}
.auth-toggle {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-dim);
}
.auth-toggle button {
  background: none;
  border: none;
  color: var(--gold);
  font-weight: 600;
  font-size: 14px;
  padding: 0;
}
.auth-toggle button:hover { text-decoration: underline; }
.payment-note {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.5;
}

/* App shell */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand img { width: 36px; height: 36px; border-radius: 9px; box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3); }
.topbar-brand span { font-weight: 800; font-size: 16px; letter-spacing: 0.03em; }
.topbar-brand .gold {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-dim); }
.badge-admin {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.22), rgba(212, 175, 55, 0.1));
  color: var(--gold-bright);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--card-border);
  background: linear-gradient(180deg, var(--bg-elevated), rgba(18, 26, 43, 0.6));
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s var(--ease);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1300;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
  transform: translateY(-1px);
}

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

.card {
  background: linear-gradient(165deg, var(--card-2) 0%, var(--card) 65%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  animation: fadeUp 0.35s var(--ease) both;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.card h2 { margin: 0 0 14px; font-size: 18px; font-weight: 800; letter-spacing: 0.01em; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--text-dim); font-weight: 700; }

.empty-state {
  text-align: center;
  padding: 44px 20px;
  color: var(--text-faint);
}
.empty-state .icon {
  font-size: 42px;
  margin-bottom: 14px;
  filter: drop-shadow(0 4px 12px rgba(212, 175, 55, 0.25));
}

.league-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.league-chip {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.2s var(--ease);
}
.league-chip:hover { border-color: var(--gold-dim); color: var(--text); }
.league-chip.active {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.14), rgba(212, 175, 55, 0.05));
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.15);
}
.league-chip.disconnected { opacity: 0.55; }

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.team-card {
  background: linear-gradient(165deg, var(--card-2), var(--bg-elevated));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.team-card:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35); }
.team-card.mine { border-color: var(--green); box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.25); }
.team-card .team-name { font-weight: 700; margin-bottom: 4px; }
.team-card .team-record { font-size: 13px; color: var(--text-dim); }
.mine-tag {
  display: inline-block;
  background: rgba(62, 207, 142, 0.15);
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  margin-left: 6px;
  text-transform: uppercase;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--text-faint); font-weight: 700; padding: 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
td { padding: 11px 10px; border-top: 1px solid var(--card-border); }
tr { transition: background 0.15s ease; }
tr:hover td { background: rgba(212, 175, 55, 0.04); }

.pos-pill {
  display: inline-block;
  background: var(--card-border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}
.status-pill { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; }
.status-out, .status-ir { background: rgba(229, 86, 109, 0.15); color: var(--red); }
.status-questionable, .status-doubtful { background: rgba(232, 182, 74, 0.15); color: var(--amber); }
.status-active { background: rgba(62, 207, 142, 0.12); color: var(--green); }

.flag {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.45;
  animation: fadeUp 0.3s var(--ease) both;
}
.flag-high { background: linear-gradient(135deg, rgba(229, 86, 109, 0.12), rgba(229, 86, 109, 0.04)); border: 1px solid rgba(229, 86, 109, 0.3); }
.flag-medium { background: linear-gradient(135deg, rgba(232, 182, 74, 0.12), rgba(232, 182, 74, 0.04)); border: 1px solid rgba(232, 182, 74, 0.3); }
.flag-icon { font-size: 19px; flex-shrink: 0; }

.watchlist-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: var(--bg-elevated);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: border-color 0.2s ease, transform 0.15s ease;
}
.watchlist-row:hover { border-color: var(--card-border); }
.watchlist-rank {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1300;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(212, 175, 55, 0.3);
}
.watchlist-row.drafted { opacity: 0.45; }
.watchlist-row.drafted .watchlist-rank { background: var(--text-faint); box-shadow: none; }
.watchlist-name { flex: 1; }
.watchlist-name .name { font-weight: 600; }
.watchlist-name .meta { font-size: 12px; color: var(--text-faint); }

.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--card-border); }
.settings-row:first-child { border-top: none; }

.bookmarklet-box {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--gold-dim);
  background: rgba(212, 175, 55, 0.06);
}
.bookmarklet-box .btn { cursor: grab; }
.bookmarklet-box .btn:active { cursor: grabbing; }

.note-banner {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.03));
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.55;
  animation: fadeUp 0.3s var(--ease) both;
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 50px;
  color: var(--text-faint);
  font-size: 13px;
}
.spinner-ring {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid var(--card-border);
  border-top-color: var(--gold);
  animation: spin 0.8s linear infinite;
}

.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.draft-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  font-size: 13px;
  border-top: 1px solid var(--card-border);
}
.draft-pick-row:first-child { border-top: none; }
.pick-num { color: var(--text-faint); width: 40px; flex-shrink: 0; font-weight: 700; }

@media (max-width: 600px) {
  main { padding: 14px; }
  .topbar-user span.username-label { display: none; }
}

/* Rankings tab */
.rankings-pos-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pos-tab-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s var(--ease);
}
.pos-tab-btn:hover { border-color: var(--gold-dim); color: var(--text); }
.pos-tab-btn.active {
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  color: #1a1300;
  border-color: transparent;
}
.rankings-table { width: 100%; }
.rank-move-btns { display: flex; flex-direction: column; gap: 2px; }
.rank-move-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-dim);
  border-radius: 4px;
  width: 22px;
  height: 18px;
  font-size: 9px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.rank-move-btn:hover:not(:disabled) { color: var(--gold-bright); border-color: var(--gold-dim); }
.rank-move-btn:disabled { opacity: 0.25; cursor: default; }
.rankings-table tr.tier-divider td {
  padding: 10px 10px 6px;
  border-top: none;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
  background: linear-gradient(90deg, rgba(212, 175, 55, 0.1), transparent);
}
.rankings-table tr.tier-divider:first-child td { padding-top: 0; }
.injury-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot-active { background: var(--green); }
.dot-questionable { background: var(--amber); }
.dot-out { background: var(--red); }
.discrepancy-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--amber);
  background: rgba(232, 182, 74, 0.15);
  border-radius: 5px;
  padding: 1px 6px;
  cursor: help;
}
