.leaderboard-page {
  --content-width: 78rem;
  --header-height: 6.5rem;
  --board-muted: #576b8e;
  position: relative;
  isolation: isolate;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--page);
}

.leaderboard-page::before,
.leaderboard-page::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.leaderboard-page::before {
  top: calc(var(--header-height) + .25rem);
  left: max(.4375rem, calc((100% - var(--content-width)) / 2 - 5.5625rem));
  width: 5.25rem;
  height: 10.375rem;
  background-image: url("./assets/edge-tubes.svg");
}

.leaderboard-page::after {
  right: max(.25rem, calc((100% - var(--content-width)) / 2 - 5.75rem));
  bottom: .4375rem;
  width: 8.625rem;
  height: 10.9375rem;
  background-image: url("./assets/edge-flask.svg");
}

.leaderboard-page .app-header .button-primary {
  min-width: 8.75rem;
  min-height: 3rem;
  border-radius: .75rem;
}

.board {
  width: min(calc(100% - var(--page-gutter) * 2), var(--content-width));
  margin-inline: auto;
  padding-block: 2.625rem 3rem;
}

.board-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1.375rem;
  background: var(--surface);
  box-shadow: 0 .375rem 0 #e8effb;
}

.board-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  min-height: 5.125rem;
  padding: .75rem 1.6875rem;
}

.board-controls p { margin: 0; font-size: 1.125rem; font-weight: 700; }

.pagination-toggle {
  gap: .72rem;
  min-width: 8rem;
  padding-inline: .95rem;
  font-size: .9375rem;
}

.pagination-icon {
  position: relative;
  flex: 0 0 .69rem;
  width: .69rem;
  height: .94rem;
  color: var(--accent);
}

.pagination-icon::before,
.pagination-icon::after {
  content: "";
  position: absolute;
  inset-block: 0;
  width: .25rem;
  border-radius: .0625rem;
  background: currentColor;
}

.pagination-icon::before { inset-inline-start: 0; }
.pagination-icon::after { inset-inline-end: 0; }
.pagination-toggle[data-paused="true"] .pagination-icon::after { display: none; }
.pagination-toggle[data-paused="true"] .pagination-icon::before {
  width: 100%;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.board-notice {
  margin: 0;
  padding: .625rem 1.6875rem;
  background: #fff3e8;
  color: #854819;
  font-size: .9375rem;
}

.board-table-frame {
  position: relative;
  isolation: isolate;
  overflow: clip;
  border-top: 1px solid var(--line);
}

.board-watermarks {
  position: absolute;
  z-index: -1;
  top: clamp(4.625rem, 32%, 11.3125rem);
  right: .25rem;
  left: 33.25%;
  aspect-ratio: 830 / 267;
  pointer-events: none;
  background: url("./assets/leaderboard-watermarks.svg") center / contain no-repeat;
}

.board-table-frame[data-empty="true"] .board-watermarks {
  top: auto;
  bottom: 1rem;
}

.scoreboard { position: relative; }

.scoreboard table {
  width: 100%;
  table-layout: fixed;
  border-spacing: 0;
  text-align: center;
}

.scoreboard thead { background: #f6f8fc; }

.scoreboard th,
.scoreboard td {
  padding: .55rem .4rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  line-height: 1.2;
}

.scoreboard thead th {
  height: 3.5rem;
  color: var(--board-muted);
  font-size: .9375rem;
  font-weight: 650;
}

.scoreboard thead th[rowspan="2"] { height: 5.5rem; }

.scoreboard thead .activity-group-heading {
  height: 2rem;
  padding-block: .33rem;
  border-inline: 1px solid #dee7fc;
  color: var(--accent);
  background: #edf3ff;
  font-weight: 750;
}

.scoreboard tbody tr { height: 4.125rem; }
.scoreboard tbody tr:nth-child(even) { background: rgb(236 242 252 / .32); }

.rank-heading { width: 8.33%; }
.name-heading { width: 17.31%; }
.total-heading { width: 9.94%; }

.scoreboard .name-heading,
.scoreboard .name-cell {
  padding-left: .75rem;
  text-align: left;
  overflow-wrap: anywhere;
}

.scoreboard .name-cell {
  font-size: 1.1875rem;
  font-weight: 550;
}

.name-cell small {
  margin-inline-start: .4em;
  font-size: .8em;
  font-weight: 400;
  color: var(--board-muted);
  white-space: nowrap;
}

.scoreboard .total-heading,
.scoreboard .total-cell {
  border-inline: 1px solid #dee7fc;
  color: var(--accent);
  background: #eef2fe;
}

.scoreboard tbody tr:nth-child(even) .total-cell { background: #eaf0fc; }
.scoreboard .total-heading { font-weight: 750; }

.score-sort-mark {
  display: inline-block;
  width: .4rem;
  height: .4rem;
  margin-inline-start: .25rem;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-.18rem) rotate(45deg);
}

.scoreboard .activity-heading {
  color: var(--ink);
  font-weight: 550;
  overflow-wrap: anywhere;
}

.score-maximum {
  display: block;
  margin-top: .25rem;
  color: var(--board-muted);
  font-size: .8125rem;
  font-weight: 500;
}

.score-value,
.rank-number {
  font-family: var(--font-numeric, Nunito, system-ui, sans-serif);
  font-variant-numeric: tabular-nums;
}

.rank-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.125rem;
  height: 2.125rem;
  padding-inline: .125rem;
  border-radius: .6875rem;
  color: var(--board-muted);
  font-size: 1.375rem;
  font-weight: 700;
}

.rank-number[data-rank="1"] { color: #8b5500; background: #fff0d4; }
.rank-number[data-rank="2"] { color: #2f55c1; background: #e7edff; }
.rank-number[data-rank="3"] { color: #975322; background: #f8eadf; }
.mobile-label, .mobile-maximum { display: none; }

.total-cell .score-value { font-size: clamp(1.45rem, 2.65vw, 2rem); font-weight: 800; }
.total-cell .score-value-long { font-size: clamp(.9375rem, 1.7vw, 1.5rem); }
.activity-cell .score-value { font-size: 1.5rem; font-weight: 700; }
.activity-cell .score-value-long { font-size: clamp(1.0625rem, 1.45vw, 1.375rem); }
.score-value.unrecorded { color: #697d9e; font-weight: 550; }

.board-footer {
  display: flex;
  align-items: center;
  gap: .5rem 1rem;
  min-height: 4.1875rem;
  padding: .5rem 1.6875rem;
}

.score-legend,
.page-number {
  color: var(--board-muted);
  font-size: .875rem;
}

.board-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .625rem;
  margin-inline-start: auto;
}

.page-announcement {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.board-pagination .button {
  padding-inline: .75rem;
  font-size: .875rem;
}

.page-number {
  text-align: center;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.board-empty {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: .8rem;
  min-height: clamp(12rem, 30vh, 17rem);
  padding: 1rem;
  color: var(--board-muted);
  text-align: center;
}

.board-empty .app-mark {
  width: 2.75rem;
  height: 2.75rem;
  opacity: .67;
}

@media (max-width: 87rem) {
  .leaderboard-page::before,
  .leaderboard-page::after { display: none; }
}

@media (max-width: 53rem) {
  .leaderboard-page { --header-height: 5rem; }
  .leaderboard-page .app-header .button-primary { min-width: auto; }
  .board { padding-block: 1rem 1.75rem; }
  .board-panel { border-radius: .95rem; }
  .board-controls { min-height: 3.75rem; padding: .5rem .75rem; }
  .board-controls p { font-size: .975rem; }
  .pagination-toggle { min-width: auto; padding-inline: .6rem; }
  .board-watermarks { display: none; }
  .board-notice, .board-footer { padding-inline: .75rem; }
  .scoreboard table, .scoreboard tbody { display: block; }

  .scoreboard thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .scoreboard tbody tr {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: center;
    gap: .4rem .25rem;
    border-bottom: 1px solid var(--line);
    height: auto;
    padding: .65rem .6rem;
  }

  .scoreboard tbody tr > * { padding: 0; border: 0; }
  .scoreboard .name-cell { grid-column: span 3; padding-left: 0; font-size: 1rem; }

  .scoreboard .total-cell {
    display: inline-flex;
    grid-column: span 2;
    justify-self: end;
    justify-content: flex-end;
    align-items: baseline;
    flex-wrap: wrap;
    gap: .1rem .3rem;
    max-width: 100%;
    padding: .325rem .4rem;
    border: 0;
    border-radius: .55rem;
  }

  .total-cell .mobile-label {
    display: inline;
    flex-basis: 100%;
    font-size: .75rem;
    font-weight: 650;
    text-align: right;
  }
  .total-cell .score-value { font-size: 1.375rem; }
  .total-cell .score-value-long { font-size: clamp(.8rem, 3.5vw, 1.1rem); }
  .mobile-maximum { display: inline; color: var(--board-muted); font-size: .75rem; white-space: nowrap; }
  .activity-cell { grid-column: span 2; }
  .activity-cell .mobile-label {
    display: block;
    margin-bottom: .2rem;
    color: var(--board-muted);
    font-size: .875rem;
    overflow-wrap: anywhere;
  }
  .activity-cell .mobile-maximum { margin-inline-start: .2rem; }
  .activity-cell .score-value { font-size: 1.15rem; }
  .rank-number { font-size: 1.125rem; }
}

@media (max-width: 460px) {
  .leaderboard-page { --header-height: 4.5rem; }

  .board-footer {
    display: grid;
    align-content: center;
    min-height: 5.5rem;
  }

  .board-pagination { gap: .4rem; margin: 0; }
  .board-pagination .button { padding-inline: .45rem; }
  .page-number { font-size: .8125rem; }
}
