:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #14181f;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #15803d;
  --accent-ink: #ffffff;
  --accent-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --info-soft: #e0f2fe;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 0.5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--ink); }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: 1rem; align-items: center; font-size: 0.925rem; }
nav a { color: var(--muted); }
nav a.active, nav a:hover { color: var(--ink); text-decoration: none; }

.container { max-width: 880px; margin: 0 auto; padding: 1.25rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit; font-size: 0.925rem; font-weight: 600;
  cursor: pointer;
  text-decoration: none !important;
}
.btn:hover { background: #f2f4f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #166534; }
.btn.sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.25rem; }
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%; padding: 0.55rem 0.7rem;
  border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: var(--card); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.field { margin-bottom: 0.9rem; }
.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.check input { width: auto; }

.pill {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase;
  background: #eef0f3; color: var(--muted);
}
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: #075985; }

.week-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.75rem 1.25rem; margin-bottom: 1rem;
  background: var(--ink); color: #fff; border-radius: var(--radius);
}
.week-banner strong { font-size: 1.1rem; }
.week-banner .muted { color: #b8c0cc; }

.matchup {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0; border-top: 1px solid var(--line);
}
.matchup:first-of-type { border-top: 0; }
.side { min-width: 0; }
.side .who { font-weight: 700; }
.side .pickline { font-size: 0.875rem; color: var(--muted); }
.side.b { text-align: right; }
.side.winner .who { color: var(--accent); }
.vs { font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.pts { font-size: 1.25rem; font-weight: 800; }

table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th, td { padding: 0.5rem 0.5rem; text-align: left; border-bottom: 1px solid var(--line); }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { background: #f8fafc; font-weight: 600; }
.table-wrap { overflow-x: auto; }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 0.5rem 0; }
.chip {
  padding: 0.3rem 0.7rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); font-size: 0.8rem; font-weight: 600; cursor: pointer;
}
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }

.player-row td { padding: 0.45rem 0.5rem; }
.player-row.ineligible { opacity: 0.4; }
.player-row.chosen-primary td { background: var(--accent-soft); }
.player-row.chosen-backup td { background: var(--info-soft); }
.pick-actions { white-space: nowrap; }

.picks-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 0.75rem; }
.picks-summary .slot {
  border: 1px dashed var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; min-height: 64px;
}
.picks-summary .slot.filled { border-style: solid; }
.picks-summary .slot .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.picks-summary .slot .nm { font-weight: 700; }
@media (max-width: 640px) { .picks-summary { grid-template-columns: 1fr; } }

.sticky-save {
  position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line);
  padding: 0.75rem 1.25rem; margin: 0 -1.25rem -1rem; border-radius: 0 0 var(--radius) var(--radius);
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
}

.hero { text-align: center; padding: 2rem 1rem 1rem; }
.hero h1 { font-size: 2.2rem; letter-spacing: -0.03em; }
.hero p { max-width: 520px; margin: 0.5rem auto 1rem; color: var(--muted); font-size: 1.05rem; }
.auth-card { max-width: 400px; margin: 0 auto; }
.error { color: var(--danger); font-size: 0.875rem; margin: 0.25rem 0 0.5rem; }
.empty { color: var(--muted); padding: 0.5rem 0; }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 0.6rem 1rem; border-radius: 8px;
  font-size: 0.925rem; box-shadow: var(--shadow); z-index: 10;
}
.toast.error { background: var(--danger); }
.how li { margin-bottom: 0.35rem; }

.slate-row {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.6rem 0; border-top: 1px solid var(--line);
}
.slate-row:first-of-type { border-top: 0; }
.slate-main { min-width: 0; }
.slate-actions { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
@media (max-width: 640px) { .slate-row { flex-direction: column; align-items: flex-start; } }

.nowrap { white-space: nowrap; }

.h2h .card-head { margin-bottom: 0.35rem; }
.h2h-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto;
  gap: 0.75rem; align-items: center;
  padding: 0.5rem 0; border-top: 1px solid var(--line);
}
.h2h-row:first-of-type { border-top: 0; }
.h2h-who { font-weight: 700; }
.h2h-player { font-size: 0.9rem; min-width: 0; }
.h2h-pts { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.h2h-row.winner .h2h-who, .h2h-row.winner .h2h-pts { color: var(--accent); }
.pill.live { background: #fee2e2; color: #b91c1c; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 0.4rem; vertical-align: middle; }
.dot.live { background: #dc2626; }
.dot.done { background: var(--muted); }
.dot.pre { background: transparent; border: 1px solid var(--line); }
@media (max-width: 640px) {
  .h2h-row { grid-template-columns: minmax(0, 1fr) auto; }
  .h2h-player { grid-column: 1 / -1; }
}

.share { width: 45%; min-width: 150px; }
.bar { background: #eef0f3; border-radius: 999px; height: 8px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.delta { font-size: 0.8rem; font-weight: 700; }
.delta.up { color: var(--accent); }
.delta.down { color: var(--danger); }
.hl-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 0.5rem; }
.hl { border-left: 3px solid var(--line); padding-left: 0.75rem; }
.hl .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.hl .nm { font-weight: 700; }
@media (max-width: 640px) { .hl-row { grid-template-columns: 1fr; } .share { width: auto; min-width: 110px; } }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; }
.tile .lbl { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.tile .val { font-size: 1.6rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }

.pill.bot { background: #ede9fe; color: #6d28d9; }
.bot-note { color: var(--muted); background: #faf5ff; border-left: 3px solid #ddd6fe; padding: 0.5rem 0.7rem; border-radius: 0 8px 8px 0; margin-top: 0.5rem; }

.ach {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem;
  align-items: center; padding: 0.6rem 0; border-top: 1px solid var(--line);
}
.ach:first-of-type { border-top: 0; }
.ach-name { font-weight: 700; }
.ach:not(.earned) .ach-main { opacity: 0.65; }
.ach-bar { min-width: 110px; }
tr.gap td { border-bottom: 0; padding: 0.15rem 0.5rem; }
