:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #607080;
  --line: #d9e1e8;
  --surface: #ffffff;
  --soft: #f3f6f8;
  --stripe: #edf2f6;
  --navy: #183f5f;
  --navy-2: #28516d;
  --blue: #2e6692;
  --green: #087a45;
  --gold: #ffd21f;
  --gold-soft: rgb(255 210 31 / 50%);
  --red: #b5473d;
  --focus: #136f9f;
  --row-hover: #e9f1f8;
  --field-bg: #ffffff;
  --secondary-bg: #e7edf1;
  --secondary-ink: #17202a;
  --headshot-bg: #dde6ee;
  --page-bg:
    linear-gradient(90deg, rgb(255 255 255 / 90%), rgb(255 255 255 / 76%)),
    repeating-linear-gradient(135deg, #eef3f6 0 2px, #f9faf7 2px 18px);
  --shadow: 0 16px 40px rgb(23 32 42 / 10%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--page-bg);
}

body:not(.is-admin) .admin-only {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  font-weight: 750;
  padding: 0 14px;
}

button:hover {
  filter: brightness(0.96);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(19 111 159 / 25%);
  outline-offset: 2px;
}

.secondary {
  color: var(--secondary-ink);
  background: var(--secondary-bg);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  color: #fff;
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 2px solid rgb(255 255 255 / 28%);
  border-radius: 50%;
  color: var(--navy);
  background: var(--gold);
  font-weight: 900;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 1.18rem;
}

.brand p {
  color: rgb(255 255 255 / 75%);
  font-size: 0.85rem;
}

.tabs {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.tab {
  justify-content: start;
  width: 100%;
  color: rgb(255 255 255 / 82%);
  background: transparent;
  text-align: left;
}

.tab.is-active {
  color: var(--navy);
  background: #fff;
}

.auth-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px 0 20px;
  border-top: 1px solid rgb(255 255 255 / 22%);
  border-bottom: 1px solid rgb(255 255 255 / 22%);
}

.auth-panel h2 {
  margin: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-panel form {
  display: grid;
  gap: 10px;
}

.admin-status {
  display: grid;
  gap: 10px;
}

.admin-status span {
  color: rgb(255 255 255 / 82%);
  font-weight: 800;
}

.league-tools {
  display: grid;
  gap: 14px;
}

.new-league-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 8px;
  background: rgb(255 255 255 / 8%);
}

.league-tools h2 {
  margin: 0;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar label {
  color: rgb(255 255 255 / 78%);
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--field-bg);
  padding: 8px 10px;
}

.tool-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.import-label input {
  color: #fff;
  border-color: rgb(255 255 255 / 30%);
  background: rgb(255 255 255 / 8%);
}

.status-text {
  margin: -2px 0 0;
  color: rgb(255 255 255 / 72%);
  font-size: 0.78rem;
  line-height: 1.35;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.topbar h2,
.section-heading h2 {
  margin: 0;
  font-size: clamp(1.45rem, 2.2vw, 2.1rem);
  letter-spacing: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  min-width: min(420px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-strip div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border-left: 1px solid var(--line);
}

.summary-strip div:first-child {
  border-left: 0;
}

.summary-strip span {
  font-size: 1.35rem;
  font-weight: 900;
}

.summary-strip small {
  color: var(--muted);
  font-weight: 750;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.load-error {
  max-width: 680px;
  margin: 12vh auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.standings-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.standings-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.standings-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.standings-table.is-full {
  min-width: 1280px;
}

.standings-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: #fff;
  background: var(--blue);
  text-align: left;
  text-transform: none;
}

.standings-table th:first-child {
  border-top-left-radius: 8px;
}

.standings-table th:last-child {
  border-top-right-radius: 8px;
}

.standings-table th,
.standings-table td {
  padding: 10px 8px;
  vertical-align: middle;
}

.standings-table tbody tr {
  background: var(--surface);
}

.standings-table tbody tr.alt {
  background: var(--stripe);
}

.team-row {
  cursor: pointer;
}

.team-row:hover,
.team-row:focus-visible {
  background: var(--row-hover);
}

.caret {
  display: inline-block;
  width: 1em;
  margin-right: 4px;
  color: var(--muted);
}

.rank-pill {
  display: inline-grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
  font-weight: 850;
}

.rank-1 .rank-pill {
  color: #5b4300;
  background: #ffd76a;
}

.rank-2 .rank-pill {
  color: #3c4a58;
  background: #d7dee6;
}

.rank-3 .rank-pill {
  color: #5d3a1a;
  background: #e7b98f;
}

.team-name-cell {
  min-width: 126px;
  font-weight: 850;
}

.total-col,
.total {
  text-align: center;
}

.total {
  color: var(--ink);
  background-image: linear-gradient(90deg, var(--gold-soft) var(--pct, 0%), transparent var(--pct, 0%));
  font-weight: 900;
}

.sticky-col {
  position: sticky;
  z-index: 1;
  background-color: inherit;
}

th.sticky-col {
  z-index: 3;
  background-color: var(--blue);
}

.col-rank {
  left: 0;
  width: 46px;
  min-width: 46px;
}

.col-team {
  left: 46px;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
}

.col-total {
  left: 206px;
  width: 64px;
  min-width: 64px;
}

.detail-row td {
  border-top: 1px solid var(--line);
  background: var(--soft);
  padding: 12px;
}

.pick-detail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.pick-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.pick-chip-text {
  min-width: 0;
}

.pick-chip small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pick-chip strong {
  display: block;
  font-size: 0.85rem;
}

.pick-chip .hrs {
  width: auto;
  margin-left: auto;
}

.headshot {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--headshot-bg);
  object-fit: cover;
}

.headshot-fallback {
  display: inline-grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
}

.hrs-col,
.hrs {
  width: 48px;
  text-align: right;
}

.hrs {
  color: var(--green);
  font-weight: 900;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.signup-panel {
  display: grid;
  max-width: 980px;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.signup-picks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.signup-pick-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.signup-pick-row select {
  flex: 1;
  min-width: 0;
}

.signup-pick-row .headshot {
  width: 40px;
  height: 40px;
}

.link-btn {
  min-height: 0;
  padding: 4px 0;
  color: rgb(255 255 255 / 72%);
  background: transparent;
  font-weight: 750;
  text-align: left;
  text-decoration: underline;
}

.link-btn:hover {
  color: #fff;
  filter: none;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.form-message {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.team-card,
.pool {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.team-card {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.team-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--gold-soft);
  font-weight: 900;
  padding: 0 10px;
}

.icon-btn {
  display: inline-grid;
  width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  color: #fff;
  background: var(--red);
  font-size: 1.25rem;
  line-height: 1;
}

.team-fields,
.pick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pick-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.pools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.pool {
  overflow: hidden;
}

.pool-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  color: #fff;
  background: var(--navy-2);
}

.pool-head label {
  flex: 1;
  min-width: 0;
  color: rgb(255 255 255 / 78%);
}

.pool-head input {
  color: #fff;
  border-color: rgb(255 255 255 / 28%);
  background: rgb(255 255 255 / 12%);
  font-weight: 850;
}

.pool-head span {
  color: rgb(255 255 255 / 72%);
  font-size: 0.8rem;
  font-weight: 800;
}

.pool-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.add-player-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 90px 120px 120px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}

.pool-list {
  display: grid;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 90px 120px 38px;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.player-row-head {
  color: var(--muted);
  background: var(--soft);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.player-row input {
  min-height: 34px;
}

.player-row input[data-field="name"],
.new-player-name {
  font-weight: 750;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  main {
    padding: 20px 14px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-strip {
    min-width: 0;
  }
}

@media (max-width: 560px) {
  .tool-row,
  .team-fields,
  .add-player-row {
    grid-template-columns: 1fr;
  }

  .team-grid,
  .pools {
    grid-template-columns: 1fr;
  }

  .tabs {
    grid-template-columns: 1fr;
  }

  .player-row {
    grid-template-columns: 1fr 74px 1fr 36px;
  }

  .player-row-head {
    display: none;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e8eef4;
    --muted: #9db0c2;
    --line: #2c3c4c;
    --surface: #15212d;
    --soft: #101a25;
    --stripe: #1a2836;
    --navy: #0d2237;
    --navy-2: #1c3850;
    --blue: #2e6692;
    --green: #53c98e;
    --gold: #f0c33c;
    --gold-soft: rgb(240 195 60 / 28%);
    --red: #c75f55;
    --row-hover: #20344a;
    --field-bg: #0f1923;
    --secondary-bg: #283a4b;
    --secondary-ink: #dbe6f0;
    --headshot-bg: #243648;
    --page-bg: #0c151e;
    --shadow: 0 16px 40px rgb(0 0 0 / 45%);
  }

  .rank-pill {
    color: #7db3dd;
  }
}
