.rank-page {
  min-height: calc(100svh - 78px);
}

.rank-page [hidden] { display: none !important; }
.rank-filter-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.rank-filter-buttons button {
  min-height: 37px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: #1b182b;
  color: var(--muted);
  cursor: pointer;
  font: 500 .75rem/1.3 var(--mono);
  text-align: left;
}

.rank-filter-buttons button:hover { border-color: var(--signal); color: var(--text); }
.rank-filter-buttons button[aria-pressed="true"] { border-color: var(--cyan); background: #253049; color: var(--signal); }
.rank-fill-input {
  width: 100%;
  min-height: 45px;
  padding: 8px 12px;
  border: 1px solid #455c5e;
  border-radius: 7px;
  background: var(--terminal);
  color: var(--text);
  font: inherit;
}

.rank-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); align-items: start; gap: 16px; }
.rank-sidebar { display: grid; align-content: start; min-width: 0; gap: 16px; }
.rank-panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #211b30, var(--panel));
}

.rank-board { align-self: start; }
.rank-panel-heading { padding: 16px clamp(13px, 2.5vw, 24px); border-bottom: 1px solid var(--line); }
.rank-heading-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 3px 12px; }
.rank-panel h2 { margin: 0; font: 600 clamp(1.08rem, 1.8vw, 1.6rem)/1.27 var(--mono); letter-spacing: -.045em; }
.rank-panel-heading p { flex: 0 0 auto; color: var(--muted); font-size: .82rem; }
.rank-board-status { padding: 18px clamp(13px, 2.5vw, 24px); color: var(--muted); font-size: .93rem; }
.rank-retry { margin: 0 clamp(13px, 2.5vw, 24px) 16px; }
.rank-board table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rank-table-caption { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.rank-place-col { width: 10%; }
.rank-metric-col { width: 14%; }
.rank-board th, .rank-board td { padding: 11px clamp(7px, 1.4vw, 15px); border-top: 1px solid var(--line); }
.rank-board thead th { border-top: 0; }
.rank-board th { color: var(--signal); font: 600 .83rem/1.5 var(--mono); text-align: right; }
.rank-board th:first-child, .rank-board th:nth-child(2) { text-align: left; }
.rank-board th:first-child, .rank-board td:first-child { padding-left: clamp(10px, 2vw, 25px); }
.rank-board th:last-child, .rank-board td:last-child { padding-right: clamp(10px, 2vw, 25px); }
.rank-board tbody { background: #1112229c; }
.rank-board tbody tr:hover { background: #23243a; }
.rank-board td { color: var(--muted); font: .92rem/1.4 var(--mono); text-align: right; }
.rank-board td:first-child, .rank-board td:nth-child(2) { text-align: left; }
.rank-board td:nth-child(3) { color: var(--text); font-weight: 660; }
.rank-board tbody tr[data-rank="1"] td:nth-child(3) { color: var(--cyan); }
.rank-medal {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: var(--medal-surface);
  box-shadow: inset 0 0 0 3px #12191b70;
  color: var(--medal-accent);
  font-weight: 670;
}
.rank-medal[data-medal="gold"] { --medal-accent: #f0cc77; --medal-surface: #362c1c; }
.rank-medal[data-medal="silver"] { --medal-accent: #e1e9ed; --medal-surface: #2a373c; }
.rank-medal[data-medal="bronze"] { --medal-accent: #e7a989; --medal-surface: #392820; }
.rank-learner { display: grid; gap: 3px; color: var(--text); font: 620 1rem/1.35 var(--sans); }
.rank-learner, .rank-learner span { overflow-wrap: anywhere; }
.rank-learner:hover { color: var(--cyan); }
.rank-learner span { color: var(--signal); font: .74rem/1.3 var(--mono); }

.rank-side-panel { padding: clamp(15px, 2.5vw, 25px); border-top-color: #a05674; }
.rank-side-panel > p:not(:empty) { margin-top: 7px; color: var(--muted); font-size: .9rem; }
.rank-sidebar-status:not(:empty) { margin-top: 8px; color: var(--signal); font-size: .88rem; }
.rank-guest-sign-in { margin-top: 10px; }
.rank-challenges { margin: 12px 0 0; padding: 0; list-style: none; }
.rank-challenge {
  display: grid;
  gap: 5px;
  padding: 12px 0 9px;
  border-top: 1px solid var(--line);
  scroll-margin-top: 110px;
}

.rank-challenge[data-selected] { padding-inline-start: 10px; box-shadow: inset 2px 0 var(--cyan); }
.rank-challenge strong { overflow-wrap: anywhere; font-size: .94rem; }
.rank-challenge > span { color: var(--muted); font: .75rem/1.35 var(--mono); }
.rank-challenge-actions, .rank-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rank-challenge-actions .button { min-height: 36px; padding: 6px 10px; font-size: .82rem; }
.rank-challenge-actions a:not(.button) { padding: 6px 0; color: var(--cyan); font: 600 .75rem/1.3 var(--mono); }
.rank-challenge-actions a:not(.button):hover { text-decoration: underline; }
.rank-participation .rank-actions { margin-top: 13px; }
.rank-page button:not(:disabled) { cursor: pointer; }
.rank-page button:disabled { cursor: default; opacity: .62; transform: none; }

.public-redesign .rank-quiz-shell { width: min(760px, calc(100% - 32px)); padding-block: clamp(20px, 5vw, 59px); }
.rank-quiz {
  --panel: #111719;
  --terminal: #0b1011;
  --text: #f4f5f3;
  --muted: #abb5b1;
  --lime: #d0ff55;
  --signal: #86d6df;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
  padding: clamp(15px, 3.8vw, 36px);
  border-color: #405559;
  border-top-color: #6b8759;
  border-radius: 15px;
  background: linear-gradient(149deg, #1b282a, #141d20 43%, var(--panel) 85%);
  box-shadow: 0 18px 44px #0006, inset 0 1px #a9d5c313;
  color: var(--text);
  font-family: var(--sans);
}
.public-redesign .rank-quiz .button { border-color: transparent; border-radius: 6px; background: var(--lime); color: #14190b; font: 660 .92rem/1.32 var(--sans); }
.public-redesign .rank-quiz .button:hover { background: #e0ff93; }
.public-redesign .rank-quiz .button-outline { border-color: #405458; background: #131d20; color: var(--text); }
.public-redesign .rank-quiz .button-outline:hover { border-color: var(--signal); background: #19282a; color: var(--signal); }
.rank-quiz-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 11px 24px; }
.rank-quiz h1 { margin-top: 7px; font-size: clamp(1.7rem, 4.5vw, 2.62rem); font-weight: 680; line-height: 1.02; letter-spacing: -.055em; overflow-wrap: anywhere; }
.rank-quiz-header .button { flex: 0 0 auto; min-height: 42px; padding-inline: 12px; }
.rank-quiz-progress { display: flex; justify-content: space-between; gap: 6px 12px; margin-top: 22px; color: var(--muted); font: .85rem/1.4 var(--mono); }
.rank-quiz-progress p:first-child { color: var(--signal); }
.rank-question-jump { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; margin: 8px 0 26px; }
.rank-question-jump button {
  min-height: 39px;
  padding: 4px;
  border: 1px solid #3a5153;
  border-radius: 6px;
  background: #0f191b;
  color: var(--muted);
  font: .92rem/1 var(--mono);
}

.rank-question-jump button[data-answered] { border-color: #729153; color: var(--lime); }
.rank-question-jump button[aria-current="step"] { border-color: var(--signal); background: #1e3c41; color: var(--text); }
.rank-question-fields { min-width: 0; margin: 0; padding: 0; border: 0; }
.rank-question-fields legend { padding: 0 0 12px; font-size: clamp(1.15rem, 3vw, 1.5rem); font-weight: 650; line-height: 1.35; }
#rank-question-answers { display: grid; gap: 8px; }
.rank-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid #3a5053;
  border-radius: 8px;
  background: #10191b;
  cursor: pointer;
}

.rank-option input { margin: 4px 0 0; accent-color: var(--lime); }
.rank-option:has(:checked) { border-color: #9cb658; background: #1c2a1c; }
.rank-fill-label { color: var(--muted); font-size: .88rem; }
.rank-quiz-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.rank-result { padding-block: 20px 6px; }
.rank-result .rank-actions { margin-top: 14px; }
.rank-result-score { margin-bottom: 5px; color: var(--lime); font-size: clamp(1.4rem, 4vw, 2.05rem); font-weight: 660; }
.rank-result p + p { color: var(--muted); }
@media (max-width: 850px) {
  .rank-layout { grid-template-columns: minmax(0, 1fr); }
  .rank-filter-buttons button, .rank-challenge-actions .button { min-height: 44px; }
}

@media (max-width: 590px) {
  .rank-place-col { width: 15%; }
  .rank-metric-col { width: 16%; }
  .rank-board th, .rank-board td { padding-inline: 4px; }
  .rank-board th, .rank-board td { font-size: .79rem; }
  .rank-learner { font-size: .87rem; }
  .rank-learner span { font-size: .67rem; }
  .rank-quiz-header { flex-wrap: wrap; }
}

@media (max-width: 385px) {
  .rank-question-jump { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
