.global-leaderboard { list-style: none; padding: 0; margin: 0; max-height: 440px; overflow: auto; }
.global-leaderboard li {
  display: grid;
  grid-template-columns: 2.375rem minmax(0, 1fr);
  align-items: center;
  gap: .5rem;
  padding: .4rem .25rem;
  border-bottom: 1px solid #123f4714;
}
.global-leaderboard li:last-child { border-bottom: 0; }
.global-leaderboard li:target {
  border-radius: .625rem;
  outline: 2px solid var(--purple, #8052c5);
  outline-offset: -2px;
}
.global-rank-number {
  width: 2.125rem;
  height: 2.125rem;
  display: grid;
  place-items: center;
  border-radius: .625rem;
  background: #f0e9fa;
  color: #6847a0;
  font-size: .875rem;
  font-weight: 900;
}
.global-leaderboard li:is([value="1"], :not([value]):nth-child(1)) .global-rank-number { background: #f8dd88; color: #674900; }
.global-leaderboard li:is([value="2"], :not([value]):nth-child(2)) .global-rank-number { background: #dfd0f3; color: #523584; }
.global-leaderboard li:is([value="3"], :not([value]):nth-child(3)) .global-rank-number { background: #bdebd7; color: #176451; }
.global-rank-entry {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: .75rem;
  padding: .45rem .625rem;
  border: 1px solid transparent;
  border-radius: .875rem;
}
.global-rank-entry.has-streak {
  --heat: calc(clamp(1, var(--streak), var(--streak-max, 10)) / var(--streak-max, 10));
  border-color: rgb(216 117 24 / calc(.28 + var(--heat) * .65));
  background: linear-gradient(100deg,
    rgb(255 215 83 / calc(.30 + var(--heat) * .50)),
    rgb(255 236 162 / calc(.35 + var(--heat) * .55)) 54%,
    rgb(255 132 49 / calc(.16 + var(--heat) * .58)));
  box-shadow: 0 .2rem .45rem rgb(225 119 16 / calc(var(--heat) * .30));
}
.global-rank-avatar, .nearby-rank-avatar {
  width: var(--rank-avatar-size, 38px);
  height: var(--rank-avatar-size, 38px);
  border: 2px solid #fff;
  border-radius: 50%;
  background: #d1f4f0;
  object-fit: cover;
  box-shadow: 0 2px 7px #123f471c;
}
.global-rank-avatar { --rank-avatar-size: 3.625rem; }
.global-rank-player { min-width: 0; display: flex; align-items: center; gap: .5rem; }
.global-rank-name { min-width: 0; overflow-wrap: anywhere; font-size: 1rem; font-weight: 800; line-height: 1.25; }
a.global-rank-name { color: inherit; text-decoration: underline; text-underline-offset: .15em; }
.global-rank-streak, .nearby-rank-streak { flex: none; border-radius: 999px; font-weight: 900; white-space: nowrap; }
.nearby-rank-streak { padding: 4px 7px; background: #fff3dc; color: #a85e20; font-size: 10px; }
.global-rank-streak {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .25rem .55rem;
  background: #fff4cf;
  color: #803808;
  font-size: .875rem;
  line-height: 1;
}
.global-rank-flame { font-size: 1.35rem; }
.global-rank-score {
  display: grid;
  gap: 2px;
  text-align: right;
  white-space: nowrap;
}
.global-rank-score strong { color: #176451; font-size: 1.1875rem; line-height: 1.2; }
.global-rank-score time { color: #536664; font-size: .75rem; line-height: 1.3; }
@media (max-width: 520px) {
  .global-leaderboard li { grid-template-columns: 1.75rem minmax(0, 1fr); gap: .25rem; }
  .global-rank-number { width: 1.75rem; height: 1.75rem; }
  .global-rank-entry { gap: .375rem; padding-inline: .375rem; }
  .global-rank-avatar { --rank-avatar-size: 3rem; }
  .global-rank-player { align-items: flex-start; flex-direction: column; gap: .2rem; }
  .global-rank-score strong { font-size: 1rem; }
}

.course-exam-ranking {
  margin-top: clamp(2rem, 5vw, 4rem);
  padding: clamp(.75rem, 3vw, 1.75rem);
  border: 1px solid #123f4725;
  border-radius: 1.125rem;
  background: #fffdf7;
  color: #123f47;
}
.course-exam-ranking h2 { margin: 0 0 .35rem; font-size: clamp(1.4rem, 3vw, 2rem); }
.course-exam-ranking h3 { margin: 1rem 0 0; font-size: 1rem; }
.course-exam-ranking .global-leaderboard { max-height: none; }
.course-exam-ranking .global-rank-score span,
.course-exam-meta, .course-exam-rules { color: #536664; font-size: .875rem; }
.course-exam-meta { margin: 0 0 .75rem; }
.course-exam-rules { margin: .75rem 0 0; line-height: 1.5; }
.course-exam-rules summary { cursor: pointer; font-weight: 700; }
.course-exam-rules p { margin: .5rem 0 0; }
.course-exam-ranking .global-leaderboard li.is-viewer .global-rank-name small { color: #536664; }

.subject-exam-ranking { margin-top: 1.4rem; }
.course-exam-ranking .global-rank-score time { font-size: .875rem; }
.course-exam-ranking .global-rank-entry {
  grid-template-columns: auto minmax(0, 1fr) auto 8rem;
}
.course-exam-completed {
  display: grid;
  gap: 2px;
  color: #536664;
  font-size: .875rem;
  text-align: right;
}
.course-exam-completed span { font-size: .75rem; font-weight: 700; }
.course-exam-completed time { font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .course-exam-ranking .global-rank-entry {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }
  .course-exam-completed {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: baseline;
    column-gap: .375rem;
  }
}
