:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-elevated: #121820;
  --panel: #161b22;
  --line: #2a3340;
  --text: #f0f6fc;
  --muted: #8b949e;
  --green: #7ee787;
  --green-dim: #1a2e1f;
  --danger: #ff9b9b;
  --header-height: 64px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.55 "DM Sans", system-ui, sans-serif;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, #1a2e1f 0%, transparent 55%),
    var(--bg);
  color: var(--text);
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-height);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}

.site-header-inner {
  width: min(1040px, calc(100% - 32px));
  height: 100%;
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: block;
}

.brand-name {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.35rem;
  font-weight: 400;
}

.site-nav {
  display: flex;
  align-items: stretch;
  height: 100%;
  margin-right: -8px;
}

.site-nav .tab {
  display: inline-flex;
  align-items: center;
  height: 100%;
  margin: 0;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}

.site-nav .tab:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--green-dim) 40%, transparent);
}

.site-nav .tab[aria-current="page"] {
  color: #07120a;
  background: var(--green);
}

.page {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 72px;
}

.page-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  padding: 28px 24px 32px;
}

.page-panel h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.page-panel h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 500;
}

.section-copy {
  margin: 0 0 20px;
  color: var(--muted);
}

.section {
  padding: 22px 0;
  border-top: 1px solid var(--line);
}

.section:first-child {
  padding-top: 0;
  border-top: 0;
}

.section:last-child { padding-bottom: 0; }

.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--green);
  color: #07120a;
  font-weight: 500;
  text-decoration: none;
}

.download:hover { filter: brightness(1.05); }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #07120a;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

button.secondary {
  color: var(--text);
  background: #222936;
  border: 1px solid var(--line);
}

button:disabled { cursor: not-allowed; opacity: 0.55; }

label {
  display: grid;
  gap: 6px;
  color: #d9dde8;
  font-weight: 400;
}

input, textarea {
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  background: #0b0f14;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
}

input[type="file"] { padding: 8px 10px; color: var(--muted); }
textarea { min-height: 128px; resize: vertical; }

.stack { display: grid; gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.setting-toggle {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  width: fit-content;
  font-weight: 500;
  cursor: pointer;
}

.setting-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--green);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.rank-set-switcher {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 12px 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.rank-set-switch {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.rank-set-switch:hover { color: var(--text); }

.rank-set-switch[aria-selected="true"] {
  color: #07120a;
  background: var(--green);
}

.rank-set-panels {
  max-width: 520px;
}

.rank-set-panel[hidden] { display: none; }

.rank-set-panel h3 {
  margin: 0 0 4px;
}

.rank-set-panel .field-help {
  margin: 0 0 12px;
}

.auth-form[hidden],
.auth-session[hidden],
.password-reset[hidden] { display: none; }

.auth-form,
.password-reset {
  max-width: 360px;
}

#draftkings-username {
  max-width: 360px;
}

.auth-session,
.password-reset { display: grid; gap: 14px; }

.logged-in-as {
  margin: 0;
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.3;
}

.logged-in-as span {
  display: block;
  margin-top: 2px;
  color: var(--green);
  font-size: 1rem;
  font-weight: 400;
  overflow-wrap: anywhere;
}

.admin-badge {
  display: inline-flex;
  width: fit-content;
  margin-top: 8px;
  padding: 3px 8px;
  border: 1px solid var(--green);
  border-radius: 4px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.admin-badge[hidden] { display: none; }

.rank-actions { margin-top: -4px; }

.capital-targets {
  max-width: 420px;
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.capital-header,
.capital-row {
  display: grid;
  grid-template-columns: 48px repeat(3, 88px);
  gap: 12px;
  align-items: center;
}

.capital-header {
  padding: 0 12px 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-align: center;
}

.capital-header span:first-child {
  visibility: hidden;
}

.capital-row {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.capital-row strong {
  color: var(--green);
  font-weight: 500;
}

.capital-row input {
  width: 88px;
  padding: 8px 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}

.capital-row input::-webkit-outer-spin-button,
.capital-row input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.status { color: var(--muted); }
.status[data-kind="error"] { color: var(--danger); }
.status[data-kind="ok"] { color: var(--green); }

.field-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #0b0f14;
  font-size: 0.92em;
}

ol {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--muted);
}

ol li { margin-bottom: 8px; }
ol li:last-child { margin-bottom: 0; }

.site-footer {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover { color: var(--green); }

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.button-link.secondary {
  background: #222936;
  border: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.grade-page { max-width: 800px; }

.grade-page h1,
.leaderboard-heading h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
}

.grade-preview {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px 20px;
  align-items: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.grade-preview-score,
.public-grade-mark {
  display: grid;
  place-items: center;
  min-width: 82px;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b0f14;
}

.grade-preview-score strong,
.public-grade-mark strong { font-size: 2rem; line-height: 1; }
.grade-preview-score span { margin-top: 4px; color: var(--green); font-weight: 700; }
.grade-preview p { margin: 3px 0 0; color: var(--muted); }

.grade-preview-metrics {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.grade-preview-metrics div,
.public-grade-details div {
  padding: 10px;
  border-radius: 6px;
  background: #0b0f14;
}

.grade-preview-metrics dt,
.public-grade-details dt {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
}

.grade-preview-metrics dd,
.public-grade-details dd { margin: 3px 0 0; font-weight: 500; }

.published-link {
  display: grid;
  gap: 5px;
  padding: 14px;
  border-left: 3px solid var(--green);
  background: var(--green-dim);
}

.published-link a { overflow-wrap: anywhere; }
.published-link span { color: var(--muted); font-size: 0.9rem; }
.status-error { color: var(--danger); }

.leaderboard-page { display: grid; gap: 28px; }
.leaderboard-heading { max-width: 620px; }
.leaderboard-heading > p:last-child { margin: 8px 0 0; color: var(--muted); }
.leaderboard-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
.leaderboard-filters label {
  display: grid;
  gap: 6px;
  min-width: min(100%, 220px);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}
.leaderboard-filters select { min-height: 40px; }

.leaderboard-shelves {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.leaderboard-shelves > div,
.all-grades { min-width: 0; }
.leaderboard-shelves h2 { margin: 0 0 10px; font-size: 1.1rem; }

.leaderboard-list,
.all-grades-list { display: grid; gap: 8px; padding: 0; list-style: none; }

.leaderboard-entry {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.leaderboard-entry:hover { border-color: var(--green); }
.entry-rank { display: grid; place-items: center; min-height: 34px; border-radius: 5px; font-weight: 800; }
.grade-a { color: #07120a; background: var(--green); }
.grade-b { color: #061016; background: #67e8f9; }
.grade-c { color: #251a00; background: #f8d46e; }
.grade-d, .grade-f { color: #fff4f4; background: #de5962; }
.entry-name { min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-name small { display: block; margin-top: 2px; color: var(--muted); font-size: 0.78rem; font-weight: 400; }
.leaderboard-entry > strong { font-size: 1.15rem; }

.section-heading,
.grade-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 0; }
.count-pill { padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 0.8rem; }

.public-grade-mark { flex: 0 0 116px; min-height: 116px; }
.public-grade-mark strong { font-size: 2.7rem; }
.public-grade-mark span { margin-top: 6px; font-size: 1.1rem; font-weight: 800; }

.grade-component-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.grade-component-grid article {
  display: grid;
  gap: 3px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.grade-component-grid span { color: var(--muted); font-size: 0.84rem; }
.grade-component-grid strong { font-size: 1.35rem; }
.public-grade-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }

.public-grade-correlation { align-items: start; }
.public-grade-correlation dd { min-width: 0; }
.public-grade-stack-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.public-grade-stack-badge {
  display: grid;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 8px;
  color: var(--text);
  border: 1px solid var(--grade-stack-color, #8f96a8);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.public-grade-stack-badge strong {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.public-grade-stack-badge span {
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.25;
}

.public-grade-bringback-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
  padding: 5px 8px;
  color: var(--text);
  border: 1.5px solid transparent;
  border-radius: 6px;
  background:
    linear-gradient(#0b0f14, #0b0f14) padding-box,
    linear-gradient(90deg, var(--grade-team-a, #8f96a8) 0 50%, var(--grade-team-b, #8f96a8) 50% 100%) border-box;
}

.public-grade-bringback-badge strong {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.public-grade-bringback-badge span {
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.public-grade-empty { color: var(--muted); }

@media (max-width: 760px) {
  .leaderboard-shelves,
  .public-grade-details,
  .grade-component-grid,
  .grade-preview-metrics { grid-template-columns: 1fr; }
  .grade-hero { align-items: flex-start; }
  .public-grade-mark { flex-basis: 82px; min-height: 82px; }
  .public-grade-mark strong { font-size: 2rem; }
  .section-heading { align-items: flex-start; }
}

@media (max-width: 760px) {
  .capital-header,
  .capital-row {
    grid-template-columns: 40px repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .capital-row input {
    width: 100%;
  }

  .site-header-inner {
    padding: 0;
    flex-direction: column;
    align-items: stretch;
    height: auto;
  }

  .site-header {
    height: auto;
  }

  .brand {
    min-height: 52px;
    padding: 0 0 0 2px;
  }

  .site-nav {
    margin-right: 0;
    border-top: 1px solid var(--line);
  }

  .site-nav .tab {
    flex: 1;
    justify-content: center;
    min-height: 44px;
    padding: 0 10px;
    font-size: 0.85rem;
  }

  .page-panel { padding: 22px 16px 28px; }
}
