:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f5f7f2;
  --ink: #17211c;
  --muted: #627068;
  --line: #d9e0d8;
  --panel: #ffffff;
  --green: #1d6f4a;
  --mint: #dff3e8;
  --gold: #b88b2f;
  --blue: #244f80;
  --red: #a53b3b;
  --shadow: 0 18px 48px rgba(23, 33, 28, 0.08);
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --ink: #eef5f0;
  --muted: #a5b5ad;
  --line: #2c3832;
  --panel: #17201c;
  --green: #68c08d;
  --mint: #20392c;
  --gold: #d6ad54;
  --blue: #8eb8e6;
  --red: #ef8d8d;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--green);
  background: var(--green);
  color: white;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  background: var(--panel);
  color: var(--green);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0 24px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.96;
}

h2 {
  font-size: 1.05rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}

.theme-toggle {
  min-width: 78px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gold);
}

.status-dot.live {
  background: var(--green);
}

.status-dot.error {
  background: var(--red);
}

.summary,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 18px;
}

.summary strong {
  display: block;
  font-size: 0.98rem;
}

.teams {
  display: block;
  margin: 18px 0;
}

.pool-leaderboard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pool-header,
.pool-row summary {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 110px 24px;
  align-items: center;
  gap: 12px;
}

.pool-header {
  background: var(--mint);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  min-height: 42px;
  padding: 0 16px;
  text-transform: uppercase;
}

.pool-row {
  border-top: 1px solid var(--line);
}

.pool-row:first-of-type {
  border-top: 0;
}

.pool-row.leader {
  box-shadow: inset 4px 0 0 var(--green);
}

.pool-row summary {
  cursor: pointer;
  list-style: none;
  min-height: 58px;
  padding: 0 16px;
}

.pool-row summary::-webkit-details-marker {
  display: none;
}

.pool-row summary::after {
  color: var(--muted);
  content: "+";
  font-size: 1.15rem;
  font-weight: 900;
  grid-column: 4;
  justify-self: end;
}

.pool-row[open] summary::after {
  content: "-";
}

.pool-rank {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.pool-name {
  font-size: 1rem;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.pool-total {
  color: var(--green);
  font-size: 1.25rem;
  font-weight: 900;
  text-align: right;
}

.pool-picks {
  display: grid;
  gap: 0;
  padding: 0 16px 10px 112px;
}

.pick-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}

.player-name {
  font-weight: 750;
  overflow-wrap: anywhere;
}

.player-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.score {
  font-weight: 900;
  color: var(--blue);
}

.score.positive {
  color: var(--red);
}

.score.negative {
  color: var(--green);
}

.missing {
  color: var(--gold);
}

.panel {
  margin-top: 18px;
  padding: 18px;
}

.panel-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
}

.panel-head input {
  width: min(260px, 100%);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.roster-body[hidden] {
  display: none;
}

.roster-editor {
  display: grid;
  gap: 12px;
}

.pick-form {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) repeat(3, minmax(130px, 1fr)) auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.picker-status {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  margin: 0 0 14px;
  min-height: 1.2em;
}

.roster-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) repeat(3, minmax(130px, 1fr)) auto;
  align-items: center;
  gap: 10px;
}

.remove-team {
  min-width: 92px;
}

.add-team {
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
}

.table-wrap[hidden] {
  display: none;
}

.cut-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 620px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: var(--mint);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.cut-info strong {
  color: var(--ink);
  font-size: 0.98rem;
}

.pool-cut-info {
  min-width: 0;
  margin: 18px 0 -6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  border-top: 1px solid var(--line);
  padding: 11px 8px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td:nth-child(1),
td:nth-child(3),
td:nth-child(4),
td:nth-child(5) {
  width: 90px;
  font-weight: 800;
}

.cut-row td {
  border-top: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
}

tr.outside-cut {
  opacity: 0.68;
}

@media (max-width: 900px) {
  .summary,
  .pick-form,
  .roster-row {
    grid-template-columns: 1fr 1fr;
  }

  .summary button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .summary {
    display: none;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    font-size: 2.5rem;
  }

  .summary,
  .pick-form,
  .roster-row {
    grid-template-columns: 1fr;
  }

  .pool-header,
  .pool-row summary {
    grid-template-columns: 52px minmax(0, 1fr) 72px 18px;
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .pool-picks {
    padding-left: 62px;
    padding-right: 10px;
  }

  .pool-total {
    font-size: 1rem;
  }

  .table-wrap {
    overflow-x: hidden;
  }

  .cut-info {
    align-items: flex-start;
    flex-direction: column;
    min-width: 0;
  }

  table {
    min-width: 0;
    table-layout: fixed;
  }

  th,
  td {
    font-size: 0.76rem;
    padding: 8px 4px;
  }

  th {
    font-size: 0.64rem;
    letter-spacing: 0.02em;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 38px;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: auto;
  }

  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4) {
    width: 46px;
  }

  th:nth-child(5),
  td:nth-child(5) {
    width: 42px;
  }

  .table-wrap .player-meta {
    font-size: 0.66rem;
    margin-top: 0;
  }
}
