@media (min-width: 801px) {
  .page-results .result-main {
    width: calc(100% - 64px);
    max-width: none;
    padding: 0;
    background: transparent;
    border-radius: 0;
  }
}

.result-record {
  width: min(1080px, 100%);
  margin: 28px auto 0;
  padding: 20px 24px 28px;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-card);
}

.result-record:not(:has(#result-empty:not([hidden]), #result-current:not([hidden]), #result-history:not([hidden]))) {
  display: none;
}

.result-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 20px;
  margin: 16px 0;
}

.result-metrics div {
  background: transparent;
  color: var(--ink);
  border: 0;
  padding: 0;
  min-width: 0;
}

.result-metrics dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.result-metrics dd {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.result-metrics div:first-child dd { font-size: 40px; }

.result-times p + p { margin-top: 4px; }

.result-page { margin: 16px 0; background: var(--surface); color: var(--ink); }

.result-page img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  background: var(--surface);
  border-radius: 12px;
}

.result-page a { display: inline-block; margin-top: 8px; }

.history-list { display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 8px; }

.history-list button[aria-current="true"] {
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.entry-list { margin: 8px 0 16px; padding-left: 18px; }

.entry-list li { white-space: pre-wrap; }

#result-time-details { margin: 8px 0 12px; }

#result-empty h2 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }

#result-empty p { color: var(--body); margin-bottom: 12px; }

#result-invalid:not([hidden]) { margin-bottom: 8px; }

.scoreboard { margin-bottom: 28px; }

.scoreboard-top {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 16px;
}

#scoreboard-own { margin-right: auto; }

.scoreboard-cutoff {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.scoreboard-cutoff[hidden] { display: none !important; }

#scoreboard-updated,
#scoreboard-own,
#scoreboard-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

#scoreboard-updated { text-align: right; white-space: nowrap; font-size: 12px; font-weight: 500; }

#scoreboard-own,
#scoreboard-note { margin-top: 6px; color: var(--body); }

#scoreboard-note:empty,
#scoreboard-own:empty,
#scoreboard-updated:empty { display: none; }

.scoreboard-scroll {
  position: relative;
  overflow: auto;
  max-height: min(70vh, 720px);
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.scoreboard-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 100%;
  font-size: 13px;
}

.scoreboard-table tr.is-cutoff-after > th,
.scoreboard-table tr.is-cutoff-after > td {
  border-bottom: 2px dashed #3d4a57;
}

.scoreboard-table th,
.scoreboard-table td {
  padding: 4px 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
}

.scoreboard-table .col-rank,
.scoreboard-table .col-name,
.scoreboard-table .col-score,
.scoreboard-table .col-solved {
  position: sticky;
  z-index: 2;
}

.scoreboard-table .col-rank { left: 0; width: 52px; min-width: 52px; text-align: right; }
.scoreboard-table .col-name { left: 52px; width: 148px; min-width: 148px; max-width: 148px; text-align: left; }
.scoreboard-table .col-score { left: 200px; width: 76px; min-width: 76px; text-align: right; }
.scoreboard-table .col-solved { left: 276px; width: 52px; min-width: 52px; text-align: right; }

.scoreboard-table .col-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.scoreboard-table thead th { position: sticky; top: 0; z-index: 3; background: var(--canvas); }
.scoreboard-table thead .col-rank,
.scoreboard-table thead .col-name,
.scoreboard-table thead .col-score,
.scoreboard-table thead .col-solved {
  z-index: 4;
  background: var(--canvas);
  vertical-align: bottom;
}

.scoreboard-table thead .col-rank,
.scoreboard-table thead .col-score,
.scoreboard-table thead .col-solved { text-align: right; }

.scoreboard-table thead .col-name { text-align: left; }

.scoreboard-group,
.scoreboard-middle {
  height: 28px;
  max-height: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 16px;
}
.scoreboard-group { color: var(--body); }
.scoreboard-middle { color: var(--muted); }

.scoreboard-table thead tr:nth-child(2) > th { top: 28px; }
.scoreboard-table thead tr:nth-child(3) > th { top: 56px; }

.scoreboard-challenge {
  box-sizing: border-box;
  width: 104px;
  min-width: 96px;
  max-width: 104px;
  height: 64px;
  max-height: 64px;
  padding: 8px;
  overflow: hidden;
  writing-mode: horizontal-tb;
  white-space: normal;
  vertical-align: bottom;
  text-align: left;
  contain: paint;
}

.challenge-label {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  width: 100%;
  max-height: 48px;
  line-height: 16px;
  font-size: 12px;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  writing-mode: horizontal-tb;
}

.scoreboard-table .cell-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--solved);
  font-variant-numeric: tabular-nums;
}

.scoreboard-table tr.is-ours td { background: var(--accent-weak); font-weight: 700; }
.scoreboard-table tr.is-ours .col-rank,
.scoreboard-table tr.is-ours .col-name,
.scoreboard-table tr.is-ours .col-score,
.scoreboard-table tr.is-ours .col-solved { background: var(--accent-weak); }

.scoreboard-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.scoreboard-pager button:disabled { opacity: 0.45; }

@media (max-width: 680px) {
  .result-metrics { grid-template-columns: 1fr 1fr; }
  .result-metrics dd { font-size: 22px; }
  .result-metrics div:first-child dd { font-size: 32px; }
}
