:root {
  color-scheme: light;
  --surface: #fff;
  --ink: rgb(0 0 0 / 87%);
  --muted: rgb(0 0 0 / 58%);
  --faint: rgb(0 0 0 / 38%);
  --line: rgb(0 0 0 / 12%);
  --line-strong: rgb(0 0 0 / 20%);
  --hover: rgb(0 0 0 / 3%);
  --primary: #4051b5;
  --accent: #ffd54f;
  --gold: #8a6900;
  --silver: #596870;
  --bronze: #8d4d2d;
  --page-padding: clamp(1rem, 5vw, 5rem);
  --content-width: 85rem;
  --team-width: 10.5rem;
  --member-width: 13.5rem;
  --header-height: 3.5rem;
  --sidebar-width: min(20rem, calc(100vw - 2rem));
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--surface);
  color: var(--ink);
  font-family:
    "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC",
    "Microsoft YaHei", sans-serif;
  font-size: 1.0625rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
summary {
  font: inherit;
}

button,
a {
  color: inherit;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  min-height: var(--header-height);
  padding-inline: var(--page-padding);
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 0.1rem 0.25rem rgb(0 0 0 / 8%);
  backdrop-filter: blur(0.5rem);
}

.menu-toggle {
  display: inline-flex;
  flex-direction: column;
  gap: 0.27rem;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  margin-right: 0.65rem;
  padding: 0.5rem;
  border: 0;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.menu-toggle:hover,
.menu-close:hover {
  background: var(--hover);
}

.menu-toggle:focus-visible,
.menu-close:focus-visible,
.sidebar-link:focus-visible,
.sidebar-folder-toggle:focus-visible,
.board-link:focus-visible,
.back-link:focus-visible {
  outline: 0.15rem solid var(--primary);
  outline-offset: -0.15rem;
}

.menu-toggle span {
  display: block;
  width: 1.25rem;
  height: 0.12rem;
  border-radius: 1rem;
  background: currentColor;
}

.brand {
  display: inline-flex;
  gap: 0.75rem;
  align-items: center;
  text-decoration: none;
}

.brand-logo {
  width: 2.25rem;
  height: 2.25rem;
  object-fit: contain;
}

.brand-name {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0;
}

.page-title {
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.98rem;
  white-space: nowrap;
}

.site-sidebar {
  position: fixed;
  z-index: 50;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0.5rem 0 1.5rem rgb(0 0 0 / 12%);
  transform: translateX(-100%);
  transition: transform 180ms ease;
}

.site-sidebar.is-open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 0 0.9rem 0 1.25rem;
  border-bottom: 1px solid var(--line);
}

.sidebar-heading {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}

.menu-close {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.75rem;
  line-height: 1;
}

.sidebar-nav {
  padding: 0.8rem 0.65rem 1.5rem;
}

.sidebar-link,
.sidebar-folder-toggle,
.board-folder-summary,
.board-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 2.45rem;
  padding: 0.45rem 0.65rem;
  border: 0;
  border-radius: 0.25rem;
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1.4;
  text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.is-active,
.sidebar-folder-toggle:hover,
.board-folder-summary:hover,
.board-link:hover,
.board-link.is-active {
  background: var(--hover);
}

.sidebar-folder-toggle {
  gap: 0.55rem;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.folder-chevron {
  width: 0.48rem;
  height: 0.48rem;
  border-right: 0.1rem solid currentColor;
  border-bottom: 0.1rem solid currentColor;
  transform: rotate(-45deg);
  transition: transform 150ms ease;
}

.sidebar-folder-toggle[aria-expanded="true"] .folder-chevron {
  transform: rotate(45deg);
}

.board-tree {
  margin: 0.2rem 0 0.3rem 0.55rem;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line);
}

.board-folder-summary {
  cursor: pointer;
  list-style: none;
}

.board-folder-summary::-webkit-details-marker {
  display: none;
}

.board-folder-summary::before {
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.62rem;
  border-right: 0.1rem solid currentColor;
  border-bottom: 0.1rem solid currentColor;
  content: "";
  transform: rotate(-45deg);
  transition: transform 150ms ease;
}

.board-folder[open] > .board-folder-summary::before {
  transform: rotate(45deg);
}

.board-folder-children {
  margin-left: 0.55rem;
  padding-left: 0.55rem;
  border-left: 1px solid var(--line);
}

.board-link {
  color: var(--ink);
}

.sidebar-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgb(0 0 0 / 18%);
  cursor: default;
}

body.menu-open {
  overflow: hidden;
}

main {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--page-padding);
}

.board-page {
  min-width: 0;
  padding-block: clamp(1rem, 3vw, 2rem) 3rem;
}

.board-page-header {
  display: flex;
  align-items: center;
  min-height: 2.5rem;
  margin-bottom: 0.8rem;
}

.back-link {
  color: var(--primary);
  font-size: 0.98rem;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.board-frame-wrap {
  width: 100%;
  min-height: calc(100vh - 8rem);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.3rem;
  background: #f8f9fa;
}

.board-frame {
  display: block;
  width: 100%;
  height: max(52rem, calc(100vh - 8rem));
  border: 0;
  background: #fff;
}

.calendar-page {
  padding-block: clamp(2rem, 5vw, 4rem) 5rem;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 2.6rem minmax(0, 1fr) 2.6rem;
  align-items: center;
  width: 100%;
  margin: 0 auto 1.25rem;
}

.calendar-month {
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 600;
  text-align: center;
}

.calendar-nav-button {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
}

.calendar-nav-button:hover {
  background: var(--hover);
}

.calendar-nav-button:focus-visible {
  outline: 0.15rem solid var(--primary);
  outline-offset: 0.15rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  width: 100%;
  margin-inline: auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 0.35rem;
}

.calendar-weekday {
  padding: 0.6rem;
  border-bottom: 1px solid var(--line-strong);
  background: rgb(64 81 181 / 5%);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
}

.calendar-day {
  min-height: 9.5rem;
  padding: 0.55rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.calendar-day-adjacent {
  opacity: 0.42;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day-number {
  margin: 0 0 0.45rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.calendar-day.is-today .calendar-day-number {
  display: grid;
  place-items: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}

.calendar-event {
  display: grid;
  gap: 0.12rem;
  margin-top: 0.35rem;
  padding: 0.32rem 0.4rem;
  border-left: 0.2rem solid var(--primary);
  border-radius: 0.15rem;
  background: rgb(64 81 181 / 7%);
  font-size: 0.78rem;
  line-height: 1.35;
}

.calendar-event-type {
  color: var(--ink);
}

.calendar-event-detail {
  color: var(--muted);
}

.awards {
  min-width: 0;
  padding-block: clamp(2rem, 5vw, 4rem) 5rem;
}

.loading-status {
  padding: 1.25rem 0;
  color: var(--muted);
}

.loading-status:empty,
.loading-status[hidden] {
  display: none;
}

.season-list {
  display: grid;
  min-width: 0;
  gap: 0.85rem;
}

.season {
  min-width: 0;
  overflow: clip;
  border: 1px solid #d4d4d5;
  border-radius: 0.28571429rem;
  background: var(--surface);
  box-shadow: 0 1px 2px 0 rgb(34 36 38 / 8%);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.season[open] {
  border-color: #bcbdbd;
  box-shadow: 0 2px 5px 0 rgb(34 36 38 / 12%);
}

.season > summary {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) auto 1.75rem;
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
  min-height: 4.5rem;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  list-style: none;
  transition: background-color 150ms ease;
}

.season > summary:hover {
  background: var(--hover);
}

.season[open] > summary {
  border-bottom: 1px solid rgb(34 36 38 / 15%);
}

.season > summary::-webkit-details-marker {
  display: none;
}

.season > summary:focus-visible,
.person-button:focus-visible,
.contest-button:focus-visible,
.dialog-close:focus-visible {
  outline: 0.15rem solid var(--primary);
  outline-offset: -0.15rem;
}

.season-title {
  display: flex;
  align-items: baseline;
}

.season-years {
  color: var(--ink);
  font-family: "Fira Mono", "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}

.medal-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  justify-self: end;
}

.wf-badge {
  display: inline-block;
  background: linear-gradient(
    90deg,
    #e53935 0%,
    #fb8c00 18%,
    #f9a825 34%,
    #43a047 50%,
    #1e88e5 68%,
    #5e35b1 84%,
    #d81b60 100%
  );
  background-clip: text;
  color: #5e35b1;
  font-family: "Fira Sans", "Segoe UI", sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.wf-season-badge,
.wf-season-placeholder {
  width: 2.5rem;
  font-size: 1.15rem;
  text-align: center;
}

.wf-season-placeholder {
  visibility: hidden;
}

.wf-team-badge {
  margin-right: 0.5rem;
  font-size: 0.9rem;
  white-space: nowrap;
}

.medal-count {
  display: inline-grid;
  grid-template-columns: 1em 2ch;
  column-gap: 0.45rem;
  align-items: baseline;
  font-size: 1rem;
  white-space: nowrap;
}

.medal-count > span {
  font-size: 1.15rem;
  font-weight: 500;
}

.medal-count strong {
  width: 2ch;
  font-size: 1.4rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

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

.podium-champion {
  color: #b04a00;
}

.podium-runner-up {
  color: #8b3a62;
}

.podium-third {
  color: #087f8c;
}

.medal-count.podium-champion,
.medal-count.podium-runner-up,
.medal-count.podium-third {
  font-weight: 700;
}

.medal-silver {
  color: var(--silver);
}

.medal-bronze {
  color: var(--bronze);
}

.season-toggle {
  position: relative;
  width: 1.75rem;
  height: 1.75rem;
  color: var(--muted);
}

.season-toggle::before {
  position: absolute;
  top: 0.45rem;
  left: 0.5rem;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 0.12rem solid currentColor;
  border-bottom: 0.12rem solid currentColor;
  content: "";
  transform: rotate(45deg);
  transition: transform 150ms ease;
}

.season[open] .season-toggle::before {
  transform: translateY(0.25rem) rotate(225deg);
}

.season-content {
  min-width: 0;
  max-width: 100%;
  padding: 0.4rem 1.25rem 1.2rem;
}

.season-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.season-table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
  font-size: 1rem;
}

.season-table th,
.season-table td {
  padding: 0.75rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.season-table thead {
  border-bottom: 0.12rem solid var(--line-strong);
}

.season-table thead th {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.4;
}

.season-table tbody tr {
  border-bottom: 1px solid var(--line);
}

.season-table tbody tr:last-child {
  border-bottom: 0;
}

.season-table tbody tr:hover {
  background: rgb(64 81 181 / 4%);
}

.season-table .team-heading,
.season-table .team-cell {
  width: var(--team-width);
  min-width: var(--team-width);
  padding-left: 0;
}

.season-table .member-heading,
.season-table .member-cell {
  width: var(--member-width);
  min-width: var(--member-width);
}

.contest-heading,
.result-cell {
  width: 7rem;
  min-width: 7rem;
}

.team-cell {
  max-width: var(--team-width);
  font-weight: 500;
  line-height: 1.55;
}

.member-cell {
  line-height: 1.7;
  white-space: nowrap;
}

.person-button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #000000;
  cursor: pointer;
}

.contest-button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.contest-heading .contest-button {
  color: inherit;
  font-weight: inherit;
}

.person-button:hover,
.contest-button:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.member-separator {
  color: var(--faint);
}

.result-cell {
  white-space: nowrap;
}

.result {
  display: flex;
  gap: 0.32rem;
  align-items: center;
  margin-bottom: 0.2rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.result.podium-champion,
.result.podium-runner-up,
.result.podium-third {
  width: fit-content;
  padding: 0.08rem 0.4rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-weight: 700;
}

.result.podium-champion {
  background: #fff0e5;
}

.result.podium-runner-up {
  background: #fcecf3;
}

.result.podium-third {
  background: #e8f7f8;
}

.first-blood-balloon {
  position: relative;
  display: inline-grid;
  flex: 0 0 1.12rem;
  place-items: center;
  width: 1.12rem;
  height: 1.12rem;
  margin-right: 0.08rem;
  border-radius: 50% 50% 46% 46%;
  background: var(--balloon-color);
  color: var(--balloon-text);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1;
}

.first-blood-balloon::after {
  position: absolute;
  bottom: -0.13rem;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 0.16rem solid transparent;
  border-bottom: 0;
  border-left: 0.16rem solid transparent;
  border-top: 0.19rem solid var(--balloon-color);
  content: "";
  transform: translateX(-50%);
}

.result-rank {
  color: var(--muted);
  font-weight: 400;
}

.person-dialog {
  width: min(68rem, calc(100vw - 2rem));
  max-height: min(48rem, calc(100vh - 2rem));
  padding: 0;
  overflow: hidden;
  border: 1px solid #d4d4d5;
  border-radius: 0.28571429rem;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 3px 10px 2px rgb(34 36 38 / 18%);
}

.person-dialog::backdrop {
  background: rgb(255 255 255 / 84%);
  backdrop-filter: blur(2px);
}

.dialog-shell {
  position: relative;
  max-height: min(48rem, calc(100vh - 2rem));
  overflow: auto;
  background: var(--surface);
}

.dialog-close {
  position: absolute;
  z-index: 1;
  top: 0.75rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1;
}

.dialog-close:hover {
  background: rgb(0 0 0 / 5%);
}

.dialog-header {
  padding: 1.15rem 4.5rem 1.15rem 1.5rem;
  border-bottom: 1px solid rgb(34 36 38 / 15%);
}

.dialog-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0;
}

.person-records-wrap {
  padding: 1.25rem 1.5rem 1.5rem;
  overflow-x: auto;
}

.person-records {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
  font-size: 1rem;
}

.person-records th,
.person-records td {
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid rgb(34 36 38 / 10%);
  text-align: left;
  vertical-align: top;
}

.person-records thead {
  border-bottom: 1px solid rgb(34 36 38 / 15%);
}

.person-records th {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}

.person-records th:nth-child(1) {
  width: 22%;
}

.person-records th:nth-child(2) {
  width: 36%;
}

.person-records th:nth-child(3) {
  width: 28%;
}

.person-records th:nth-child(4) {
  width: 14%;
}

.contest-records {
  min-width: 32rem;
}

.contest-records th:nth-child(1) {
  width: 25%;
}

.contest-records th:nth-child(2) {
  width: 55%;
}

.contest-records th:nth-child(3) {
  width: 20%;
}

.person-records td:first-child {
  white-space: nowrap;
}

body:has(.person-dialog[open]) {
  overflow: hidden;
}

@media (max-width: 760px) {
  :root {
    --page-padding: 1rem;
  }

  .site-header {
    min-height: 3.25rem;
  }

  :root {
    --header-height: 3.25rem;
  }

  .brand-logo {
    width: 2rem;
    height: 2rem;
  }

  .page-title {
    max-width: 36vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .season-list {
    gap: 0.75rem;
  }

  .season > summary {
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    min-height: 5.5rem;
    padding: 0.75rem 0.9rem;
  }

  .medal-counts {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
  }

  .season-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  .season-content {
    padding-inline: 0.9rem;
  }

  .board-page {
    padding-top: 0.75rem;
  }

  .board-frame-wrap {
    margin-inline: -0.9rem;
    width: calc(100% + 1.8rem);
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .calendar-page {
    margin-inline: -0.2rem;
    padding-top: 1.5rem;
  }

  .calendar-grid {
    border-right: 0;
    border-left: 0;
    border-radius: 0;
  }

  .calendar-weekday {
    padding-inline: 0.15rem;
    font-size: 0.75rem;
  }

  .calendar-day {
    min-height: 6.25rem;
    padding: 0.35rem;
  }

  .calendar-day-number {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
  }

  .calendar-event {
    padding: 0.2rem 0.25rem;
    font-size: 0.68rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .season,
  .season > summary,
  .season-toggle::before {
    transition: none;
  }
}
