/* ============================================================
   Leaderboard — stage #017B redesign
   Mobile: compact podium CARD (2nd · 1st · 3rd on stepped bases,
   crown pinned to #1's avatar) + efficient #4+ list.
   Desktop: two columns — left: contest summary + podium (sticky),
   right: the full ranked list 1..N.
   ============================================================ */

.segmented {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
}
.segmented button {
  padding: 7px 16px;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.segmented button[aria-pressed="true"] {
  background: var(--gold-faint);
  border-color: rgba(244, 176, 33, 0.4);
  color: var(--gold);
}

/* ---------- page chrome ---------- */
.lb-head { margin-bottom: 12px; }
.lb-note { margin-bottom: 12px; }
.lb-note b { color: var(--txt); }
#lb-cats { margin-bottom: 14px; }

/* ---------- layout grid ---------- */
.lb-grid { display: grid; gap: 18px; }
@media (min-width: 1024px) {
  .lb-grid {
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: 24px;
    align-items: start;
  }
  .lb-main {
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
}

/* ---------- contest summary (desktop left column) ---------- */
.lb-summary {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}
.lb-summary-title { margin-top: 12px; font-size: 16px; }
.lb-summary-prize {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: var(--gold);
  margin-top: 6px;
}
.lb-summary-prize span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 2px;
}
.lb-summary .rail-facts { margin: 14px 0 0; }
@media (max-width: 1023.98px) {
  .lb-summary { display: none; }
}

/* ---------- podium card ---------- */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  padding: 22px 14px 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
  min-height: 238px;
}
.pod { display: flex; flex-direction: column; align-items: center; width: min(106px, 27vw); min-width: 0; }
/* content wrapper must be constrained to the pod column, or the
   nowrap name/title grow the pod beyond the podium and spill out
   of the viewport (22px body overflow found at 393px widths) */
.pod-body { display: flex; flex-direction: column; align-items: center; max-width: 100%; min-width: 0; }
.pod-av-wrap { position: relative; flex: none; }
.pod-av {
  width: 54px; height: 54px;
  border-radius: 50%;
  margin: 0 auto 7px;
  border: 2px solid var(--line);
  object-fit: cover;
}
.pod-1 .pod-av {
  width: 66px; height: 66px;
  border-color: rgba(244, 176, 33, 0.75);
  box-shadow: 0 0 0 3px rgba(244, 176, 33, 0.14), 0 0 20px rgba(244, 176, 33, 0.16);
}
/* crown: pinned badge on #1's avatar — nothing floats */
.pod-crown {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #1d1406;
  border: 1px solid rgba(244, 176, 33, 0.6);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}
.pod-crown svg { width: 13px; height: 13px; }
.pod-medal {
  position: absolute;
  top: -5px;
  right: -6px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #211b12;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pod-name {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pod-title {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.pod-votes {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 3px;
}
.pod-votes svg { width: 11px; height: 11px; }
.pod-base {
  width: 100%;
  margin-top: 9px;
  border-radius: 10px 10px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.pod-place {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.pod-3 .pod-base { height: 46px; }
.pod-2 .pod-base { height: 74px; }
.pod-1 .pod-base {
  height: 106px;
  background: linear-gradient(180deg, rgba(244, 176, 33, 0.18), rgba(244, 176, 33, 0.03));
  border-color: rgba(244, 176, 33, 0.4);
}
.pod-1 .pod-place { color: var(--gold); }
.podium-one .pod { width: min(120px, 32vw); }
.podium-one .pod-1 .pod-base { height: 84px; }

/* tablet widths: the podium card hugs its trio instead of floating
   three small pods inside a full-width card */
@media (min-width: 640px) and (max-width: 1023.98px) {
  .podium { max-width: 620px; margin-left: auto; margin-right: auto; gap: 16px; }
  .pod { width: min(140px, 22vw); }
  .podium-one .pod { width: min(150px, 24vw); }
}

/* ---------- ranked list ---------- */
.lb-list { display: flex; flex-direction: column; gap: 5px; }
.lb-row {
  display: grid;
  grid-template-columns: 30px 42px minmax(0, 1fr) 44px auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s, border-color 0.2s;
}
.lb-row:hover { background: rgba(255, 255, 255, 0.045); border-color: var(--line); }
.lb-rank { font-weight: 800; color: var(--muted); text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.lb-rank.top { color: var(--gold); }
.lb-av { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.lb-info { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.lb-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-thumb { width: 44px; height: 58px; border-radius: 7px; object-fit: cover; border: 1px solid var(--line); }
.lb-votes {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 56px;
  text-align: right;
}
.lb-votes svg { width: 12px; height: 12px; color: var(--gold); flex: none; }
/* rows without a thumbnail (winners final ranking) drop the thumb column */
.lb-row.lb-no-thumb { grid-template-columns: 30px 42px minmax(0, 1fr) auto; }

@media (max-width: 1023.98px) {
  /* podium covers ranks 1–3 on mobile; the list starts at #4 */
  .lb-row.lb-top3 { display: none; }
  .lb-row { grid-template-columns: 26px 38px minmax(0, 1fr) auto; padding: 8px 10px; }
  .lb-row.lb-no-thumb { grid-template-columns: 26px 38px minmax(0, 1fr) auto; }
  .lb-av { width: 36px; height: 36px; }
}
@media (max-width: 419.98px) {
  .lb-thumb { display: none; }
}

/* ---------- empty state ---------- */
.lb-empty { grid-column: 1 / -1; padding: 40px 18px; }
.lb-empty p { max-width: 280px; }

/* ---------- skeleton (matches final geometry) ---------- */
.sk-podium { min-height: 238px; }
.sk-podium .skeleton { width: min(106px, 27vw); }
.sk-podium .skeleton:nth-child(2) { height: 196px; }
.sk-podium .skeleton:nth-child(1),
.sk-podium .skeleton:nth-child(3) { height: 150px; }
.sk-lb-row { height: 58px; border-radius: var(--r-md); }
.sk-lb-row + .sk-lb-row { margin-top: 5px; }
