:root {
  color-scheme: light;
  --bg: #f8f5ee;
  --surface: #fffdf8;
  --surface-2: #edf6fb;
  --text: #18151d;
  --muted: #69727b;
  --line: #dbe4e9;
  --accent: #4a204f;
  --accent-soft: #efe6f1;
  --accent-blue: #8fc5e8;
  --accent-blue-soft: #e4f3fb;
  --title-fill: #4a204f;
  --title-trim: #8fc5e8;
  --gold: #d6a11f;
  --silver: #aab2bd;
  --bronze: #c27a3d;
  --shadow: 0 18px 50px rgba(50, 37, 56, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111018;
  --surface: #191722;
  --surface-2: #23202c;
  --text: #fbf7ef;
  --muted: #aeb5bd;
  --line: #332d3d;
  --accent: #9bcbed;
  --accent-soft: #292435;
  --accent-blue: #9bcbed;
  --accent-blue-soft: #1d3340;
  --title-fill: #fbf7ef;
  --title-trim: #9bcbed;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

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

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: var(--title-fill);
  display: inline-block;
  font-size: 72px;
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: 0;
  padding-bottom: 10px;
  position: relative;
  text-shadow: none;
}

h1::after {
  position: absolute;
  right: 4px;
  bottom: 0;
  left: 4px;
  height: 5px;
  border-radius: 999px;
  background: var(--title-trim);
  content: "";
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.theme-toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 13px;
}

.team-summary {
  min-width: 430px;
}

.summary-kvs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kv-inline {
  border-right: 1px solid var(--line);
  padding: 13px 14px;
}

.kv-inline:last-child {
  border-right: 0;
}

.kv-inline span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.kv-inline strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  line-height: 1;
}

.kv-inline.is-accent strong {
  color: var(--accent);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.view-tabs {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.view-tab {
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  padding: 8px 13px;
}

.view-tab.is-active {
  background: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent-blue) 55%, transparent);
  color: white;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-top: 16px;
  overflow: hidden;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.section-title h2 {
  font-size: 20px;
  line-height: 1;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.calendar-button,
.section-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.calendar-button {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  text-decoration: none;
}

.calendar-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.calendar-button.is-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.calendar-menu {
  position: relative;
}

.calendar-menu summary {
  list-style: none;
}

.calendar-menu summary::-webkit-details-marker {
  display: none;
}

.calendar-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 5;
  display: grid;
  min-width: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.calendar-option {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 11px 14px;
  text-align: left;
  text-decoration: none;
}

.calendar-option:last-child {
  border-bottom: 0;
}

.calendar-option:hover {
  background: var(--surface-2);
  color: var(--accent);
}

.section-link {
  color: var(--accent);
  padding: 0 2px;
}

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

.leader-board {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 15px 16px 14px;
}

.leader-board:nth-child(3n) {
  border-right: 0;
}

.leader-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.leader-ranks {
  display: grid;
  gap: 5px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.leader-rank {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rank-1 .rank-number {
  background: color-mix(in srgb, var(--gold) 24%, transparent);
  border-color: color-mix(in srgb, var(--gold) 55%, var(--line));
  color: var(--gold);
}

.rank-2 .rank-number {
  background: color-mix(in srgb, var(--silver) 24%, transparent);
  border-color: color-mix(in srgb, var(--silver) 55%, var(--line));
}

.rank-3 .rank-number {
  background: color-mix(in srgb, var(--bronze) 22%, transparent);
  border-color: color-mix(in srgb, var(--bronze) 55%, var(--line));
  color: var(--bronze);
}

.rank-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-rank strong {
  font-weight: 800;
}

.leader-empty {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 750;
}

.schedule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 18px;
}

.schedule-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  column-gap: 16px;
  row-gap: 3px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  min-width: 0;
  padding: 13px 14px;
}

.schedule-card.is-break,
.schedule-card.is-rescheduled {
  background: var(--surface);
}

.schedule-week {
  grid-row: span 3;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.schedule-card strong {
  font-size: 16px;
  line-height: 1.15;
  min-width: 0;
  overflow-wrap: break-word;
}

.schedule-card p {
  font-weight: 700;
  min-width: 0;
  overflow-wrap: break-word;
}

.schedule-card p b,
.schedule-card p em {
  display: inline-block;
  margin-right: 8px;
  color: var(--accent);
  font-style: normal;
}

.schedule-card small {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: break-word;
}

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

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

th,
td {
  height: 42px;
  border-bottom: 1px solid var(--line);
  padding: 0 14px;
  text-align: right;
  white-space: nowrap;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  user-select: none;
}

th.is-left,
td.is-left {
  text-align: left;
}

th.is-number,
td.is-number {
  width: 44px;
  color: var(--muted);
}

th.is-sorted,
td.is-sorted-col {
  background: var(--accent-soft);
}

td.is-accent {
  color: var(--accent);
  font-weight: 850;
}

tbody tr:hover:not(.totals-row) {
  background: var(--surface-2);
}

.player-cell .name {
  font-weight: 750;
}

.totals-row {
  background: var(--surface-2);
  font-weight: 850;
}

.totals-row td {
  border-bottom: 0;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.35);
}

.drawer {
  width: min(640px, 100%);
  height: 100%;
  overflow: auto;
  background: var(--surface);
  box-shadow: -20px 0 45px rgba(0, 0, 0, 0.2);
}

.drawer-head,
.drawer-body {
  padding: 24px;
}

.drawer-head {
  border-bottom: 1px solid var(--line);
}

.drawer-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.drawer-meta,
.drawer-section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.drawer h3 {
  margin: 6px 0 0;
  font-size: 34px;
}

.drawer-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.slash-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 20px;
}

.slash-stat span,
.mini-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.slash-stat strong {
  display: block;
  margin-top: 3px;
  color: var(--accent);
  font-size: 26px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-top: 10px;
}

.mini-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.mini-cell strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.game-log {
  margin-top: 24px;
}

@media (max-width: 860px) {
  .page-shell {
    width: min(1180px, calc(100% - 20px));
    padding: 16px 0 36px;
  }

  .site-header,
  .nav-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .site-header {
    gap: 14px;
    margin-bottom: 14px;
    position: relative;
  }

  .title-block {
    padding-right: 90px;
  }

  h1 {
    font-size: 54px;
    padding-bottom: 8px;
  }

  h1::after {
    height: 4px;
  }

  .header-actions {
    display: block;
  }

  .theme-toggle {
    min-height: 34px;
    position: absolute;
    top: 0;
    right: 0;
    padding: 7px 12px;
    width: auto;
  }

  .team-summary {
    margin-top: 14px;
    width: 100%;
    min-width: 0;
  }

  .panel {
    border-radius: 12px;
    margin-top: 12px;
  }

  .section-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
  }

  .section-title h2 {
    font-size: 18px;
  }

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

  .leader-board {
    padding: 10px 12px;
  }

  .leader-board:nth-child(2n) {
    border-right: 0;
  }

  .leader-board:nth-child(3n) {
    border-right: 1px solid var(--line);
  }

  .leader-title {
    font-size: 11px;
  }

  .leader-ranks {
    gap: 3px;
    margin-top: 8px;
  }

  .leader-rank {
    grid-template-columns: 20px minmax(0, 1fr) auto;
    gap: 6px;
    min-height: 22px;
    font-size: 13px;
  }

  .rank-number {
    width: 20px;
    height: 20px;
    font-size: 11px;
  }

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

  .summary-kvs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kv-inline:nth-child(2) {
    border-right: 0;
  }

  .kv-inline:nth-child(3) {
    border-top: 1px solid var(--line);
  }

  .view-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 100%;
    overflow: hidden;
    width: 100%;
  }

  .view-tab {
    min-width: 0;
    overflow: hidden;
    padding: 7px 10px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .section-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .roster-section .section-title {
    padding: 13px 14px 10px;
  }

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

  .roster-section table {
    min-width: 0;
    table-layout: fixed;
  }

  .roster-section th,
  .roster-section td {
    height: 34px;
    padding: 0 5px;
    font-size: 13px;
  }

  .roster-section th {
    font-size: 10px;
  }

  .roster-section th:nth-child(1),
  .roster-section td:nth-child(1),
  .roster-section th:nth-child(3),
  .roster-section td:nth-child(3),
  .roster-section th:nth-child(10),
  .roster-section td:nth-child(10),
  .roster-section th:nth-child(11),
  .roster-section td:nth-child(11),
  .roster-section th:nth-child(13),
  .roster-section td:nth-child(13) {
    display: none;
  }

  .roster-section th:nth-child(2),
  .roster-section td:nth-child(2) {
    width: 25%;
  }

  .roster-section th:nth-child(12),
  .roster-section td:nth-child(12) {
    width: 48px;
  }

  .player-cell .name {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .drawer-head,
  .drawer-body {
    padding: 18px;
  }

  .drawer h3 {
    font-size: 28px;
  }

  .slash-stats {
    gap: 14px;
    margin-top: 16px;
  }

  .slash-stat strong {
    font-size: 22px;
  }

  .mini-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-log table {
    min-width: 700px;
  }
}

@media (max-width: 480px) {
  .page-shell {
    width: calc(100% - 16px);
    padding-top: 14px;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 11px;
  }

  h1 {
    font-size: 42px;
  }

  .summary-kvs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border-radius: 10px;
  }

  .kv-inline {
    padding: 10px 12px;
  }

  .kv-inline:nth-child(2),
  .kv-inline:nth-child(4) {
    border-right: 0;
  }

  .kv-inline span {
    font-size: 10px;
  }

  .kv-inline strong {
    font-size: 18px;
  }

  .section-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    width: 100%;
  }

  .calendar-menu {
    min-width: 0;
  }

  .calendar-menu .calendar-button {
    width: 100%;
  }

  .calendar-options {
    right: auto;
    left: 0;
    width: min(210px, 100%);
  }

  .section-link {
    min-height: 30px;
    padding: 0 2px;
  }

  .schedule-grid {
    gap: 6px;
    padding: 12px;
  }

  .schedule-card {
    grid-template-columns: 58px minmax(0, 1fr);
    column-gap: 10px;
    padding: 10px 11px;
  }

  .schedule-week {
    font-size: 10px;
  }

  .schedule-card strong {
    font-size: 14px;
  }
}
