/* leaderboard.css — shared leaderboard styles for index.html and wiki.html.
   Requires CSS custom properties from the Playful-C palette:
   --bg, --surface, --rule, --faint, --text, --muted, --cool, --gold,
   --accent, --green, --font-display, --font-ui. */

.lb-overlay {
  display: none; position: fixed; inset: 0;
  background: var(--bg); z-index: 300; flex-direction: column;
  align-items: stretch; justify-content: flex-start; padding: 0;
}
.lb-overlay.active { display: flex; }

.lb-header {
  display: flex; align-items: center; position: relative;
  /* Safe-area top: the .lb-overlay is position:fixed inset:0, and the pages
     now run viewport-fit=cover + contentInset:never, so this header sits at
     the PHYSICAL top of the screen. Without the env() inset it slides under
     the status bar / notch — the back + close buttons land behind the clock
     and stop receiving taps. env() is 0 on the web, so this is iOS-only. */
  padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px; border-bottom: 1px solid var(--rule); flex-shrink: 0;
}
/* Stacked layout: back button sits on its own row above the title block,
   so the "You reached [Goal] in [Time]" line gets the full width and the
   goal name doesn't get crushed by a side-by-side nav button. */
.lb-header--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.lb-header--stacked .lb-nav-btn {
  align-self: flex-start;
  width: 36px;
  height: 28px;
}
.lb-header--stacked .lb-header-center {
  width: 100%;
}
.lb-header-center { flex: 1; text-align: center; }
/* .wordmark class on host overrides font/letter-spacing; size dropped ~15%. */
.lb-header-name { font-size: 1rem; color: var(--text); }
.lb-header-sub {
  font-size: 0.82rem; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase; margin-top: 2px;
}
/* Structured completion title: "You reached [Goal] in [Time]" where the
   goal is highlighted green and truncates with an ellipsis if the article
   name is long, so the "in 2:45" suffix is always visible. */
.lb-header-sub.lb-title-structured {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 4px;
  max-width: 100%;
  overflow: hidden;
  padding: 0 8px;
  box-sizing: border-box;
}
.lb-title-prefix,
.lb-title-suffix { flex-shrink: 0; white-space: nowrap; }
.lb-title-goal {
  color: var(--green);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-nav-btn {
  width: 36px; flex-shrink: 0; background: none; border: none;
  color: var(--text); font-size: 1.5rem; cursor: pointer; padding: 0;
  line-height: 1; opacity: 0.6; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.lb-nav-btn:hover { opacity: 1; }
.lb-nav-btn svg { display: block; width: 22px; height: 22px; }

.lb-filter-bar {
  display: flex; align-items: stretch; gap: 10px;
  margin: 14px 16px 0; flex-shrink: 0;
}
.lb-filter-bar .lb-tabs { margin: 0; flex: 1; }

/* V2 three-toggle filter bar (This Round/All Rounds · Points/Correct ·
   Everyone/Friends). Three equal-width tap-to-flip pills in one row; must fit a
   ~390px screen without wrapping, so labels stay short + text can ellipsize. */
.lb-filter-bar.lb-toggles { gap: 8px; }
.lb-toggle {
  flex: 1 1 0; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  height: 38px; padding: 0 8px; border-radius: 999px;
  border: 1.5px solid var(--rule); background: var(--surface);
  font-family: var(--font-ui); font-weight: 700; font-size: 0.86rem;
  color: var(--text); cursor: pointer; white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.08s;
}
.lb-toggle > span { overflow: hidden; text-overflow: ellipsis; }
.lb-toggle:active { transform: translateY(1px); }
.lb-toggle:hover { border-color: var(--faint); }
/* Engaged / non-default state (All Rounds, Correct, Friends) tints to the board
   accent so the active mode reads at a glance beyond the label text. */
.lb-toggle.on {
  border-color: var(--lb-accent, #E8784E);
  color: var(--lb-accent, #E8784E);
  background: color-mix(in srgb, var(--lb-accent, #E8784E) 12%, var(--surface));
}
.lb-toggle.lb-toggle-static { opacity: 0.6; cursor: default; }
.lb-toggle.lb-toggle-static:active { transform: none; }

.lb-friends-btn {
  flex-shrink: 0; width: 40px; height: 36px;
  background: none; border: 1px solid var(--rule);
  border-radius: 10px; color: var(--muted);
  cursor: pointer; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
/* In the stacked completion header (column layout) the friends toggle is
   pinned to the top-right corner so it doesn't push into the title block. */
.lb-header--stacked .lb-friends-btn {
  position: absolute; right: 16px;
  top: calc(14px + env(safe-area-inset-top, 0px));
}
.lb-friends-btn svg { width: 20px; height: 20px; display: block; }
.lb-friends-btn:hover { color: var(--text); border-color: var(--faint); }
/* Active state matches the lb-tab.active filled-pill treatment —
   cool-blue fill, white icon, soft blue shadow. Far more obvious than
   the gold glow it replaced, and consistent with the new segmented
   control treatment so 'Time / Taps' + 'Friends only' all read as
   active in the same visual language. */
.lb-friends-btn.active {
  background: var(--lb-accent, var(--cool));
  border-color: var(--lb-accent, var(--cool));
  color: #FFF;
  box-shadow: 0 2px 6px rgba(91, 143, 178, 0.35);
}

.lb-friends-prompt {
  font-size: 0.85rem; color: var(--muted);
  text-align: center; padding: 18px 16px; line-height: 1.5;
}
.lb-friends-prompt strong { color: #B58418; font-weight: 600; }
.lb-invite-btn {
  display: inline-block; margin-top: 12px;
  background: var(--surface); border: 1px solid rgba(232, 181, 71, 0.42);
  border-radius: 10px; color: #B58418;
  font-family: var(--font-ui); font-weight: 600;
  font-size: 0.85rem; letter-spacing: 0.04em;
  padding: 9px 24px; cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.lb-invite-btn:hover { border-color: var(--gold); background: rgba(232, 181, 71, 0.08); }

/* Segmented control: cream track with 4px inner padding so the active
   pill sits visually inset. Active state is a filled cool-blue pill —
   far more obvious than the previous near-white-on-cream pill, which
   blended into the track. Inactive tabs keep the muted-text-on-
   transparent treatment. The active state follows whichever tab JS
   has class="active" on (see LB.switchTab + LB.toggleFriends — both
   class-toggles, not index-based). */
.lb-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 4px;
  margin: 14px 16px 0;
  flex-shrink: 0;
}
.lb-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  padding: 8px 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
/* Drop the inter-tab separator: it was for the old hard-edged
   segmented look; against the filled active pill it reads as a
   misaligned stray bar. */
.lb-tab + .lb-tab { border-left: none; }
.lb-tab.active {
  background: var(--lb-accent, var(--cool));
  color: #FFF;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(91, 143, 178, 0.35);
}
.lb-tab:hover:not(.active) { color: var(--text); }

.lb-list {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 0 16px 80px; margin-top: 6px;
  /* Prevent iOS bounce-scroll from revealing content behind the overlay
     (wiki iframe, for example) when the list reaches either end. */
  overscroll-behavior: contain;
}
/* Anything pinned to the bottom of the viewport (share/challenge row, the
   anon sign-up bar, or both stacked) eats into the list's scroll runway —
   without matching padding the last rows are unreachable behind it. Mirror
   the :has() stacking logic the share row itself uses. */
:root:has(#ps-bar.active) .lb-list {
  padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px));
}
:root:has(.lb-share-row) .lb-list {
  padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}
:root:has(.lb-share-row):has(#ps-bar.active) .lb-list {
  padding-bottom: calc(200px + env(safe-area-inset-bottom, 0px));
}
/* Gated (name-entry) state: nothing is meant to scroll — skeletons are a
   static preview. Killing overflow here prevents the iOS rubber-band
   scroll that was exposing the wiki iframe through the overlay. */
.lb-list.lb-list-gated {
  overflow: hidden;
  padding-bottom: 16px;
}
/* Trivia round-complete: .trc-bar is a fixed bottom footer (countdown ring /
   Plus pill) layered OVER the board. Give the list a runway so its last rows —
   and, when gated, the name row's Save button — are never trapped behind it. */
:root:has(.trc-bar) .lb-list,
:root:has(.trc-bar) .lb-list.lb-list-gated {
  padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
}
/* Inline name-entry validation message (see LB._nameError). Without visible
   feedback a rejected name just silently re-focused, reading as "won't save". */
.lb-name-err {
  color: #B5512C;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 2px 0;
  text-align: left;
}

.lb-row {
  display: flex; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--rule);
  font-size: 0.95rem; min-height: 44px;
}
.lb-row:last-child { border-bottom: none; }
.lb-row.you { color: var(--lb-accent, var(--gold)); }
.lb-row.clickable { cursor: pointer; }
@media (hover: hover) {
  .lb-row.clickable:hover { background: rgba(31, 26, 20, 0.04); border-radius: 8px; }
}
.lb-row.open { border-bottom: none; }

.lb-rank {
  width: 28px; flex-shrink: 0;
  font-family: var(--font-display); font-weight: 700;
  font-size: 0.95rem; color: var(--faint); letter-spacing: -0.01em;
}
.lb-row.you .lb-rank { color: var(--lb-accent, var(--gold)); }
.lb-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  flex-shrink: 0; margin-right: 10px; overflow: hidden;
}
/* A photo avatar gets the account-colour ring too — otherwise only the players
   without a picture would be colour-coded. */
.lb-avatar-ring { border: 2px solid var(--faint); box-sizing: border-box; }
/* Tappable avatars — every leaderboard row opens its player's profile. */
.lb-avatar-tap { cursor: pointer; transition: transform 0.15s ease; }
.lb-avatar-tap:active { transform: scale(0.92); }
.lb-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.lb-avatar-init {
  background: var(--surface); border: 2px solid var(--faint);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem; font-weight: 600; color: var(--muted);
}
.lb-row.you .lb-avatar-init,
.lb-avatar-you { border-color: var(--lb-accent, var(--gold)); color: var(--lb-accent, var(--gold)); }
/* min-width:0 lets the name cell shrink below the text input's intrinsic width —
   without it, at larger accessibility font sizes the row can't shrink and the
   "Add your name" input slides under the submit (→) button. */
.lb-name { flex: 1; text-align: left; min-width: 0; }
/* Name is a profile trigger (mirrors .lb-avatar-tap). Keep flex:1 so the row's
   layout is unchanged — this only adds the affordance, not a new box. */
.lb-name-tap { cursor: pointer; }
.lb-name-tap:active { opacity: 0.6; }
/* In the name-ENTRY row, drop the score/time preview — at larger accessibility
   fonts it crams the input so "Add your name" clips to "Add your". The input needs
   the full width between the avatar and the → button to stay readable; the score is
   already implied by "…to see where you rank" and shows on the row once submitted. */
.lb-row.unclaimed .lb-time { display: none; }
.lb-time {
  color: var(--text);
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.05rem; letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.lb-row.you .lb-time { color: var(--lb-accent, var(--gold)); }

/* DNF rows — named players who started today's daily but never finished.
   Continue the list below the ranked rows (no header), visually de-emphasised
   (greyed avatar + name, muted "DNF" in place of a time) so they never compete
   with the real board. */
.lb-row.lb-dnf { color: var(--muted); }
.lb-row.lb-dnf .lb-rank { color: var(--faint); }
.lb-row.lb-dnf .lb-avatar img { opacity: 0.5; filter: grayscale(1); }
.lb-row.lb-dnf .lb-avatar-init { opacity: 0.7; border-color: var(--faint); color: var(--faint); }
.lb-row.lb-dnf .lb-name { color: var(--muted); }
.lb-row.lb-dnf .lb-time {
  color: var(--faint); font-family: var(--font-ui); font-weight: 700;
  font-size: 0.82rem; letter-spacing: 0.06em;
}
/* Trivia row: muted correct-count after the score (e.g. 184 · 17/20) */
.lb-tsub { color: var(--muted); font-family: var(--font-ui); font-weight: 600; font-size: 0.82rem; }
.lb-row.you .lb-tsub { color: var(--lb-accent, var(--gold)); opacity: 0.85; }

.lb-chevron {
  color: var(--faint); font-size: 1.6rem; margin-left: 8px;
  display: inline-block; transition: transform 0.2s; line-height: 1;
}
.lb-row.open .lb-chevron { transform: rotate(90deg); }

.lb-empty { font-size: 0.85rem; color: var(--muted); padding: 20px 0; text-align: center; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.lb-path-row {
  display: flex; flex-wrap: nowrap; align-items: center; overflow-x: auto;
  padding: 12px 0; gap: 6px; border-bottom: 1px solid var(--rule);
  scrollbar-width: none; overscroll-behavior-x: contain;
  animation: fadeIn 0.15s ease;
}
.lb-path-row::-webkit-scrollbar { display: none; }

/* Trivia per-question recap — the expand detail for a trivia leaderboard row
   (analogue of .lb-path-row). One cell per question: green correct / red wrong
   / faint unanswered. */
.lb-q-row {
  padding: 12px 0; border-bottom: 1px solid var(--rule);
  animation: fadeIn 0.15s ease;
}
.lb-q-grid { display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; }
.lb-q-cell { height: 14px; border-radius: 3px; background: var(--rule); }
.lb-q-cell.correct { background: var(--green); }
.lb-q-cell.wrong   { background: #D1544A; }

.lbp-node {
  font-size: 0.8rem; background: var(--bg); border: 1px solid var(--rule);
  border-radius: 999px; padding: 5px 12px; color: var(--text);
  white-space: nowrap; flex-shrink: 0;
}
.lbp-node.start { border-color: var(--accent); color: var(--accent); background: rgba(232,120,78,0.06); }
.lbp-node.goal  { border-color: var(--green);  color: var(--green);  background: rgba(92,159,110,0.06); font-weight: 600; }
.lbp-node.lbp-dnf { border-color: var(--faint); color: var(--muted); opacity: 0.7; }
.lbp-arrow { color: var(--faint); font-size: 0.82rem; flex-shrink: 0; }

/* ── Shared leaderboard frame ─────────────────────────────────────────────
   Wraps any leaderboard list. Full width on mobile, constrained with a
   subtle card-style outline on desktop. Use by setting class="lb-frame"
   on the container that holds the rows. */
.lb-frame {
  width: 100%;
  margin: 0 auto;
}
@media (min-width: 560px) {
  .lb-frame {
    max-width: 480px;
    border: 1px solid var(--rule);
    border-radius: 16px;
    padding: 8px 14px;
    background: var(--surface, transparent);
    box-shadow: 0 8px 24px -12px rgba(31, 26, 20, 0.10);
  }
}

/* Inside the overlay, the frame needs to behave as the flex child that
   fills remaining height so the inner .lb-list scrolls correctly. */
.lb-overlay .lb-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lb-overlay .lb-frame .lb-list {
  flex: 1;
  margin-top: 0;
}
@media (min-width: 560px) {
  .lb-overlay .lb-frame { margin-top: 14px; margin-bottom: 14px; }
  /* Keep the header and tab row aligned to the same 480px column so the
     nav bar and filters sit inside the leaderboard frame on desktop. */
  .lb-overlay .lb-header,
  .lb-overlay .lb-filter-bar,
  .lb-overlay .lb-tabs {
    width: 100%;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }
  .lb-overlay .lb-filter-bar { margin-top: 14px; }
  .lb-overlay .lb-filter-bar .lb-tabs { margin-top: 0; }
  .lb-overlay .lb-tabs { margin-top: 14px; }
}

/* ── Dynamic live/results list (versus results screen) ───────────────────
   Rows reorder live as players finish or advance; paths show expanded
   while racing, collapse-on-tap once the race is frozen. */
.lb-dynlist { position: relative; }

/* Row base — extends .lb-row semantics but applies to the dynlist rows. */
.lb-dynlist .lb-row { position: relative; will-change: transform; }

/* Pulsing ring for still-racing avatars inside a row (same keyframes as
   proximity.css but scoped to the flat avatar — no position-absolute).
   Colour is driven by --pulse-color set inline by leaderboard.js from the
   per-player colour (versus assigns each opponent a distinct palette entry
   at match start). color-mix() bakes in the 55% alpha at the start of the
   ripple and fades to transparent. */
@keyframes lb-avatar-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pulse-color, #c0392b) 55%, transparent); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.lb-avatar.pulsing { animation: lb-avatar-pulse 1.4s ease-out infinite; }

/* DNF row (timed out): normal colours — just a small "DNF" marker on the
   right. Path stays visible, name is NOT struck through and NOT greyed. */
.lb-row.dnf .lb-time {
  font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}
/* Left row (abandoned the match): greyed out + name struck through. */
.lb-row.left { opacity: 0.55; }
.lb-row.left .lb-name { text-decoration: line-through; text-decoration-thickness: 1px; }
.lb-row.left .lb-time {
  font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted);
}

/* Live path inside a still-racing row. Sits on a second line underneath
   the name/time line and scrolls right-to-left (latest pill always visible
   at the right edge). */
.lb-live-path {
  display: flex; flex-wrap: nowrap; align-items: center;
  gap: 6px; padding: 8px 0 4px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  overscroll-behavior-x: contain;
  scroll-behavior: smooth;
}
.lb-live-path::-webkit-scrollbar { display: none; }
.lb-live-path .lbp-node,
.lb-live-path .lbp-arrow { animation: fadeIn 0.2s ease; }

/* ── Gated leaderboard (skeleton + unclaimed row) ────────────────────────── */
/* Skeleton rows — shown when the leaderboard is gated (user hasn't signed up
   or hasn't entered their name yet). Grey pulsing pills signal "locked". */
@keyframes lb-skel-pulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.85; }
}
.lb-row.skeleton .lb-rank { color: var(--faint); opacity: 0.7; }
.lb-skel-pill {
  display: inline-block;
  height: 0.9rem; width: 110px;
  background: rgba(31, 26, 20, 0.08);
  border-radius: 6px;
  animation: lb-skel-pulse 1.6s ease-in-out infinite;
  vertical-align: middle;
}
.lb-skel-pill-sm { width: 42px; }
.lb-avatar-skeleton {
  background: rgba(31, 26, 20, 0.06);
  border: 2px solid var(--rule);
  animation: lb-skel-pulse 1.6s ease-in-out infinite;
}
.lb-row.skeleton .lb-name { overflow: hidden; }

/* Podium-shaped loading skeleton (LB._loadingHtml). Grey pulsing pillars +
   avatar so the board loads in its real shape rather than popping from a bare
   text line. No entrance animation (`.lb-podium.loading` omits `.animate`). */
.lb-podium.loading { pointer-events: none; }
.lb-podium-av.lb-avatar-skeleton {
  background: rgba(31, 26, 20, 0.06); border-color: var(--rule); color: transparent;
}
/* Neutral grey pulse for every loading pillar. High specificity (4 classes)
   so it beats the silver/bronze medal rules (.lb-podium-pillar.h2 .lb-podium-riser)
   — otherwise the loading pillars would flash the medal colours. */
.lb-podium.loading .lb-podium-pillar .lb-podium-riser {
  background: rgba(31, 26, 20, 0.07); border-color: var(--rule);
  animation: lb-skel-pulse 1.6s ease-in-out infinite;
}

/* Hint banner shown above the pinned name-entry row — tells the user
   WHY they're being asked for a name (so the gated skeleton state isn't
   just an unexplained "Add your name" form). */
.lb-nameentry-hint {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  padding: 14px 4px 6px;
  line-height: 1.35;
}
.lb-nameentry-hint strong {
  color: #B58418;
  font-weight: 600;
}
.lb-nameentry-hint--tap {
  cursor: pointer;
}
.lb-nameentry-hint--tap:hover strong {
  text-decoration: underline;
}

/* Unclaimed (pinned name-entry) row — highlighted with the player's gold
   accent and a subtle pulsing border to invite the interaction. */
@keyframes lb-unclaimed-pulse {
  0%, 100% { border-color: rgba(232, 181, 71, 0.42); }
  50%      { border-color: rgba(232, 181, 71, 0.95); }
}
.lb-row.unclaimed {
  border: 1px dashed rgba(232, 181, 71, 0.55);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 6px 0 10px;
  background: rgba(232, 181, 71, 0.08);
  animation: lb-unclaimed-pulse 1.8s ease-in-out infinite;
}
.lb-row.unclaimed .lb-rank { color: var(--gold); }
.lb-name-input {
  width: 100%;
  min-width: 0;   /* allow the flex row to shrink it instead of overlapping the → button */
  background: transparent;
  border: none;
  outline: none;
  color: #B58418;
  font-family: var(--font-ui);
  font-weight: 600;
  /* 16px min — anything smaller triggers iOS input-focus auto-zoom.
     Every other input in the app should follow this rule. */
  font-size: 16px;
  padding: 2px 0;
  letter-spacing: 0.02em;
}
.lb-name-input::placeholder {
  color: var(--muted); opacity: 0.85; font-style: italic; font-weight: 400;
}
/* Labelled pill, not a bare arrow — first-time users didn't read the old →
   glyph as a submit button. Gold outline while empty (visible affordance),
   solid gold once a valid name is typed. */
.lb-name-submit {
  background: var(--surface);
  border: 1.5px solid var(--gold);
  color: #B58418;
  border-radius: 999px;
  padding: 8px 14px;
  margin-left: 6px;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  flex-shrink: 0;
}
.lb-name-submit.ready {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--text);
}
.lb-name-submit:disabled { opacity: 0.6; cursor: default; }

/* Reveal animation — rows cross-fade in with a per-row delay after the gate
   drops (name submitted or sign-in completed). */
@keyframes lb-row-reveal {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.lb-revealing-row {
  animation: lb-row-reveal 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Slot-reel reveal — used when the player ranks outside the top window.
   The list becomes a viewport (overflow:hidden) and an inner .lb-reel
   wrapper translates upward past filler ranks, landing the "you" row
   centered. Both classes are transient — the cleanup step in
   _revealReel strips .lb-reeling and unwraps .lb-reel, returning the
   list to its normal scrollable state. */
.lb-list.lb-reeling {
  overflow: hidden;
  /* Disable overscroll rubber-banding while the reel runs. */
  overscroll-behavior: none;
}
.lb-reel {
  display: flex;
  flex-direction: column;
  will-change: transform;
}
/* Filler rows are parade-past decorations — inert, unselectable, no
   profile lookup, no path toggle. Keeps the visual of rapidly-scrolling
   ranks without any of the interaction surface of a real leaderboard row. */
.lb-row.lb-filler {
  pointer-events: none;
  user-select: none;
}

/* Dynlist rows: top line (rank/avatar/name/time/chevron — same geometry as
   historic rows) plus an optional full-width live-path line beneath. Only
   applies inside .lb-dynlist so static leaderboards stay untouched. */
.lb-dynlist .lb-row {
  flex-direction: column;
  align-items: stretch;
  padding: 0;
}
.lb-dynlist .lb-row-top {
  display: flex; align-items: center;
  padding: 14px 0;
  min-height: 44px;
}
.lb-dynlist .lb-row-top .lb-name { flex: 1; }
/* On dynlist rows, the bottom border belongs to the row wrapper so the
   live-path line sits above it. When a row is .open (expanded), we remove
   its border so the external .lb-path-row flows into it without a seam —
   same behaviour as the historic leaderboard. */
.lb-dynlist .lb-row { border-bottom: 1px solid var(--rule); }
.lb-dynlist .lb-row.open { border-bottom: none; }
.lb-dynlist .lb-row-top { border-bottom: none; }
.lb-dynlist .lb-live-path { padding: 0 0 12px; }
.lb-dynlist .lb-row:last-child { border-bottom: none; }


/* ─── POST-RACE ACTION ROW (Share / Challenge) ─────────────────────────────
   Injected by LB.open when the leaderboard opens as the completion screen
   (showShareButtons:true). Pins to the bottom of the viewport so it sits
   immediately above whichever auth UI is showing — full sign-up sheet,
   collapsed bar, or nothing. Position adjusts via :has() so the button
   "rides on top" of the auth state. */
.lb-share-row {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  z-index: 365;            /* below ps-bar (370) and ps-sheet (380) */
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  /* Default bottom safe-area cushion. Removed when auth UI is showing
     because the bar/sheet already accounts for it. */
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--rule);
}
/* Auth bar showing (minimised): lift share row to sit just above it.
   Selector starts at :root because the auth sheet/bar are appended to
   <html> (not <body>), so body:has(...) can't see them. */
:root:has(#ps-bar.active) .lb-share-row {
  bottom: calc(46px + env(safe-area-inset-bottom, 0px));
  padding-bottom: 12px;
}
/* Full sign-up sheet showing: hide share row entirely — it'd be behind
   the backdrop anyway, and the sheet is the focused action. The user
   minimises the sheet (✕) to bring the share row back. */
:root:has(#ps-sheet.active) .lb-share-row { display: none; }

.lb-share-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #B58418;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.lb-share-btn:hover { background: var(--bg); border-color: var(--gold); }
.lb-share-btn:active { transform: scale(0.97); }
.lb-share-btn svg { flex-shrink: 0; vertical-align: -2px; }

/* Challenge button is the primary CTA — gold fill, dark text, more visual
   weight than Share which is the secondary action. Dark text reads
   cleanly on gold (var(--bg) was navy in the legacy palette, which gave
   light-on-gold; on the cream palette it'd flip to cream-on-gold which
   has poor contrast — so we explicitly use --text). */
.lb-share-btn--primary {
  background: var(--gold);
  color: var(--text);
  border-color: #C99B33;
}
.lb-share-btn--primary:hover { background: var(--gold); filter: brightness(1.04); }

/* ═══════════════════════════════════════════════════════════════════════════
   PODIUM + RESULTS SYSTEM (shared: daily leaderboard + versus results)
   One podium(top-3) + ranked-list visual for every "you finished" moment.
   Game-aware only in copy/metric (handled in JS); the chrome is identical.
   Motion is CSS *keyframe animations* (not transitions) — per the spotlight
   pitfall, transitions stall when the WebView isn't actively painting, but
   keyframe animations run. --lb-accent (JS-set) is the per-game accent; gold
   is the "you"/winner colour everywhere.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Soft shades the podium needs, derived from the Playful-C palette. Scoped to
   the overlay/results so they don't leak into the global namespace. */
.lb-overlay, .lb-results {
  --gold-soft: #F3E6C4;   /* winner/you pillar top + chip fill */
  --gold-deep: #D9A43A;   /* winner/you pillar bottom + gradient end */
  --rule-soft: #EFE7D6;   /* fallback pedestal fill (dnf / no medal) */
  /* Medal pedestals — a proper gold/silver/bronze podium. Each is a
     top-light → bottom-deep gradient echoing the winner's gold treatment, so
     2nd/3rd read as medals rather than blank beige. Tones are warmed slightly
     to sit in the cream Playful-C palette instead of cold metal. */
  --silver-soft: #EDEEF1; --silver-deep: #C7C9CF; --silver-line: #B4B7BF; --silver-ink: #7E828B;
  --bronze-soft: #EDCEA4; --bronze-deep: #C68A54; --bronze-line: #B87F49; --bronze-ink: #8F5A2E;
}

/* ── Podium ──────────────────────────────────────────────────────────────── */
.lb-podium {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 12px; padding: 18px 14px 0; flex-shrink: 0;
}
.lb-podium-col { flex: 1; min-width: 0; text-align: center; }
/* The avatar/name/score block that sits on top of the pillar. */
.lb-podium-info { margin-bottom: 9px; }
.lb-podium-av {
  width: 46px; height: 46px; border-radius: 50%; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--faint); background: var(--surface); overflow: hidden;
  font-family: var(--font-ui); font-weight: 600; font-size: 1.1rem; color: var(--muted);
}
.lb-podium-av img { width: 100%; height: 100%; object-fit: cover; }
.lb-podium-col.win .lb-podium-av { width: 60px; height: 60px; font-size: 1.4rem; }
.lb-podium-col.you .lb-podium-av { border-color: var(--gold); background: var(--gold-soft); color: var(--text); }
.lb-podium-col.opp .lb-podium-av { border-color: var(--accent); }
.lb-podium-name {
  font-family: var(--font-ui); font-weight: 600; font-size: 0.9rem;
  color: var(--text); margin-top: 6px; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-podium-col.win .lb-podium-name { font-size: 1rem; }
.lb-podium-col.you .lb-podium-name { color: var(--gold); }
.lb-podium-col.opp .lb-podium-name { color: var(--accent); }
.lb-podium-you-tag { color: var(--faint); font-weight: 600; font-size: 0.72rem; }
.lb-podium-score {
  font-family: var(--font-display); font-weight: 600; font-size: 1.2rem;
  color: var(--text); letter-spacing: -0.01em; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.lb-podium-col.win .lb-podium-score { font-size: 1.65rem; }
.lb-podium-col.you .lb-podium-score { color: var(--gold); }
.lb-podium-col.dnf .lb-podium-score { color: var(--faint); font-family: var(--font-ui); font-size: 0.95rem; }
.lb-podium-sub { font-size: 0.78rem; color: var(--faint); font-weight: 600; margin-top: 1px; }

/* The rising pillar. Height by rank; overflow-clip so the inner riser can
   translateY from 100%→0 behind the clip (masked "grow up from the floor"). */
.lb-podium-pillar { border-radius: 12px 12px 0 0; overflow: hidden; }
.lb-podium-pillar.h1 { height: 104px; }
.lb-podium-pillar.h2 { height: 74px; }
.lb-podium-pillar.h3 { height: 56px; }
.lb-podium-riser {
  height: 100%; border-radius: 12px 12px 0 0;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 9px;
  font-family: var(--font-display); font-weight: 600; font-size: 1.3rem;
  background: var(--rule-soft); border: 1px solid var(--rule); color: var(--faint);
}
/* Medal pedestals by rank (pillar height class == rank). Silver = 2nd,
   bronze = 3rd. Only the WINNER's pillar (.win) overrides to gold below — the
   viewer's own pillar keeps its rank medal, so a 2nd/3rd-place "you" isn't
   confused with 1st. The "you" signal is carried by the gold name + score +
   avatar ring, not the pedestal. */
.lb-podium-pillar.h2 .lb-podium-riser {
  background: linear-gradient(180deg, var(--silver-soft), var(--silver-deep));
  border-color: var(--silver-line); color: var(--silver-ink);
}
.lb-podium-pillar.h3 .lb-podium-riser {
  background: linear-gradient(180deg, var(--bronze-soft), var(--bronze-deep));
  border-color: var(--bronze-line); color: var(--bronze-ink);
}
.lb-podium-col.win .lb-podium-riser {
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  border-color: var(--gold); color: var(--text);
}
.lb-podium-col.dnf .lb-podium-riser {
  background: var(--surface); border-color: var(--rule); color: var(--faint);
}

/* Duel (2-player versus): two pillars, winner taller. Reuses .lb-podium-col
   with .duel on the container for wider gaps + bigger avatars. */
.lb-podium.duel { gap: 16px; }
.lb-podium.duel .lb-podium-pillar.h1 { height: 150px; }
.lb-podium.duel .lb-podium-pillar.h2 { height: 96px; }
.lb-podium.duel .lb-podium-col.win .lb-podium-av { width: 70px; height: 70px; }

/* Compact podium (4-6 players: top-3 shrinks to leave room for the list). */
.lb-podium.compact .lb-podium-pillar.h1 { height: 88px; }
.lb-podium.compact .lb-podium-pillar.h2 { height: 64px; }
.lb-podium.compact .lb-podium-pillar.h3 { height: 48px; }
.lb-podium.compact .lb-podium-col.win .lb-podium-av { width: 52px; height: 52px; }

/* ── Podium entrance choreography (keyframes only) ───────────────────────── */
@keyframes lb-riser-rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes lb-pod-pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
/* animate mode: risers start hidden then rise; info blocks pop in after. Delays
   are set inline per-column in JS so 2·1·3 stagger with the winner landing last. */
.lb-podium.animate .lb-podium-riser { animation: lb-riser-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.lb-podium.animate .lb-podium-info  { animation: lb-pod-pop 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
@media (prefers-reduced-motion: reduce) {
  .lb-podium.animate .lb-podium-riser,
  .lb-podium.animate .lb-podium-info { animation: none; }
}

/* Divider between the podium and the ranked list (rank 4+). */
.lb-podium-divider { height: 1px; background: var(--rule); margin: 18px 4px 4px; }

/* ── Solo state (only you finished today) ────────────────────────────────── */
.lb-solo { padding: 26px 22px 8px; text-align: center; }
.lb-solo-hero { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.lb-solo-av {
  width: 78px; height: 78px; border-radius: 50%; overflow: hidden;
  border: 2px solid var(--gold); background: var(--gold-soft);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 600; font-size: 2rem; color: var(--text);
}
.lb-solo-av img { width: 100%; height: 100%; object-fit: cover; }
.lb-solo-title { font-weight: 600; font-size: 1.05rem; color: var(--gold); }
.lb-solo-score {
  font-family: var(--font-display); font-weight: 600; font-size: 2.6rem;
  color: var(--text); line-height: 1; font-variant-numeric: tabular-nums;
}
.lb-solo-unit { font-size: 1.2rem; color: var(--faint); font-weight: 500; }
.lb-solo-sub { font-size: 0.95rem; color: var(--muted); }
.lb-solo-card {
  margin-top: 24px; background: var(--surface); border: 1px solid var(--rule);
  border-radius: 18px; padding: 18px 20px; text-align: left;
  display: flex; gap: 14px; align-items: center;
}
.lb-solo-badge {
  width: 50px; height: 50px; border-radius: 50%; flex-shrink: 0;
  background: color-mix(in srgb, var(--accent) 14%, #fff);
  border: 1.5px solid color-mix(in srgb, var(--accent) 40%, #fff);
  display: flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
.lb-solo-ct { font-weight: 700; font-size: 1rem; }
.lb-solo-cd { font-size: 0.9rem; color: var(--muted); margin-top: 2px; }
.lb-solo.animate .lb-solo-hero { animation: lb-pod-pop 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: 120ms; }
.lb-solo.animate .lb-solo-card { animation: lb-pod-pop 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: 340ms; }
@media (prefers-reduced-motion: reduce) {
  .lb-solo.animate .lb-solo-hero, .lb-solo.animate .lb-solo-card { animation: none; }
}

/* ── Anon reveal: gold name-chip that flies from the input into your slot ─── */
.lb-fly-chip {
  position: fixed; left: 0; top: 0; z-index: 400; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 7px;
  background: var(--gold-soft); border: 1.5px solid var(--gold); border-radius: 999px;
  box-shadow: 0 8px 20px rgba(217, 164, 58, 0.4); will-change: transform;
}
.lb-fly-chip-av {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--gold); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-weight: 600; font-size: 0.85rem; color: var(--text);
}
.lb-fly-chip-name { font-family: var(--font-ui); font-weight: 600; font-size: 0.95rem; color: var(--gold); }
/* Landing flash on the destination row/column (settles to the persistent gold
   "you" treatment the row/column already carries). */
@keyframes lb-land-flash {
  0%   { background: var(--gold-soft); }
  100% { background: transparent; }
}
/* Keyframe pop on arrival (runs even when idle, unlike an opacity transition). */
.lb-landed { animation: lb-pod-pop 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
.lb-row.lb-landed { animation: lb-pod-pop 0.42s cubic-bezier(0.22, 1, 0.36, 1) both, lb-land-flash 1.1s ease 0.2s; border-radius: 10px; }
@media (prefers-reduced-motion: reduce) {
  .lb-fly-chip { display: none; }
  .lb-landed, .lb-row.lb-landed { animation: none; }
}

/* ── Challenge finish: opponent lit warm, gold highlight travels to you ────── */
.lb-podium-col.lb-challenge-lit .lb-podium-name,
.lb-podium-col.lb-challenge-lit .lb-podium-score { color: var(--accent); }
.lb-podium-col.lb-challenge-lit .lb-podium-av { border-color: var(--accent); }
.lb-row.lb-challenge-lit {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border-radius: 10px; color: var(--accent);
}
.lb-row.lb-challenge-lit .lb-name { color: var(--accent); }
/* The floating gold highlight that flies opponent → you. Translucent so the
   content underneath reads through as it passes. */
.lb-travel-hl {
  position: fixed; left: 0; top: 0; z-index: 390; pointer-events: none;
  border-radius: 12px;
  background: color-mix(in srgb, var(--gold) 20%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--gold), 0 8px 20px rgba(217, 164, 58, 0.35);
  will-change: transform, width, height;
}
@media (prefers-reduced-motion: reduce) { .lb-travel-hl { display: none; } }

/* ── Round-highlights carousel (versus results) ──────────────────────────── */
.lb-hl-label { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em; color: var(--cool); margin-bottom: 10px; padding: 0 4px; }
/* Pastel wash keyed to the active award's accent (--hl, set inline per slide),
   so the card cycles through soft colour instead of flat cream. The plain
   declarations are the fallback for engines without color-mix (older WebKit) —
   they keep the previous cream card rather than a broken transparent one. */
.lb-hl-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--hl, var(--cool)) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--hl, var(--cool)) 26%, var(--rule));
  border-radius: 18px; padding: 16px 18px; overflow: hidden;
  transition: background 0.42s ease, border-color 0.42s ease;
}
.lb-hl-inner { display: flex; gap: 16px; align-items: center; animation: lb-hl-slide 0.42s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes lb-hl-slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
.lb-hl-emoji {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: color-mix(in srgb, var(--hl) 14%, #fff);
  border: 1.5px solid color-mix(in srgb, var(--hl) 40%, #fff);
  display: flex; align-items: center; justify-content: center; font-size: 1.7rem;
}
.lb-hl-body { min-width: 0; }
.lb-hl-cat { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; color: var(--hl); }
.lb-hl-val { display: flex; align-items: baseline; gap: 10px; margin-top: 3px; }
.lb-hl-num { font-family: var(--font-display); font-weight: 600; font-size: 2rem; line-height: 1; letter-spacing: -0.01em; }
.lb-hl-sub { font-size: 0.9rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-hl-dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.lb-hl-dot { width: 7px; height: 7px; border-radius: 4px; background: var(--rule); transition: background 0.3s; }
.lb-hl-dot.on { background: var(--cool); }
@media (prefers-reduced-motion: reduce) { .lb-hl-inner { animation: none; } }

/* ── Header eyebrow (context line under the title) ───────────────────────── */
/* Reuses .lb-header-sub; the challenge variant tints green ("YOU BEAT SAM"). */
.lb-header-sub.lb-eyebrow-challenge { color: var(--green); }

/* ── Live poll: a row/podium column whose score just changed flashes an accent
   ring (box-shadow only — the row's transform is owned by the FLIP reorder). */
@keyframes lbLiveFlash {
  0%   { box-shadow: 0 0 0 0 rgba(232,120,78,0); }
  25%  { box-shadow: 0 0 0 3px rgba(232,120,78,0.30); }
  100% { box-shadow: 0 0 0 0 rgba(232,120,78,0); }
}
.lb-live-bump { animation: lbLiveFlash 0.8s ease; border-radius: 12px; }

/* ── Event ticker (shared by daily board #lb-ticker and Board tab #th-lbticker).
   One live "what just happened" line at a time; a pulsing dot signals a fresh
   event vs the resting top-player readout. */
.lb-ticker {
  display: flex; align-items: center; gap: 9px;
  /* Fixed height, ALWAYS reserved (even when empty) so a ticker line appearing
     or clearing never shifts the podium below it up/down. */
  height: 30px; margin: 10px 16px 2px; padding: 0 2px;
  font-family: var(--font-ui); font-weight: 600; font-size: 0.9rem;
  color: var(--muted); overflow: hidden; white-space: nowrap;
}
.lb-tick-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.lb-tick-dot.live {
  background: var(--lb-accent, #E8784E);
  animation: lbTickPulse 1.6s ease-out infinite;
}
@keyframes lbTickPulse {
  0%   { box-shadow: 0 0 0 0 rgba(232,120,78,0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(232,120,78,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,120,78,0); }
}
.lb-tick-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; animation: lbTickIn 0.32s ease; }
@keyframes lbTickIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
