/* Leaderboard — mobile first.
   Tokens locales; el resto sale de tokens.css. */
.lb {
  --lb-gold: #e2bb55;
  --lb-silver: #c4cbd9;
  --lb-bronze: #cf8f5f;
  --lb-glass: rgb(255 255 255 / .04);
  --lb-line: rgb(255 255 255 / .08);
  --lb-ease: cubic-bezier(.2, .8, .2, 1);
  max-width: 44rem;
  margin-inline: auto;
  font-variant-numeric: tabular-nums;
}

/* ── Cabecera ─────────────────────────────────────────────────────────── */
.lb-head { margin-bottom: 1.1rem; }
.lb-eyebrow {
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--cyan);
}
.lb-title {
  margin: .4rem 0 .55rem;
  font-size: clamp(2.1rem, 9vw, 3rem);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.lb-sub {
  max-width: 36ch;
  font-size: .9rem;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

/* ── Selector de ranking (chips con scroll horizontal, pegajoso) ──────── */
.lb-chips {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: .5rem;
  margin-inline: calc(-1 * clamp(1rem, 4vw, 2rem));    /* = el margen lateral de <main> */
  padding: .6rem clamp(1rem, 4vw, 2rem) .9rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
}
.lb-chips::-webkit-scrollbar { display: none; }

.lb-chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: .5rem;
  min-height: 44px;
  padding: 5px;
  border-radius: 14px;
  background: var(--lb-glass);
  border: 1px solid var(--lb-line);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  scroll-snap-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s, border-color .2s, box-shadow .2s, transform .15s;
}
.lb-chip img {
  display: block;
  width: 60px;
  height: 34px;
  object-fit: cover;
  border-radius: 9px;
  opacity: .75;
  transition: opacity .2s;
}
.lb-chip-label {
  display: none;
  padding-right: .65rem;
  color: var(--text);
  white-space: nowrap;
}
.lb-chip-global { padding: 0 .95rem; gap: .45rem; }
.lb-chip-global svg { width: 18px; height: 18px; flex: none; }
.lb-chip-global .lb-chip-label { display: inline; padding: 0; color: inherit; }
.lb-chip:active { transform: scale(.97); }
.lb-chip:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.lb-chip[aria-current] {
  color: var(--cyan);
  background: rgb(var(--cyan-rgb) / .1);
  border-color: rgb(var(--cyan-rgb) / .55);
  box-shadow: 0 8px 24px -10px rgb(var(--cyan-rgb) / .6);
}
.lb-chip[aria-current] img { opacity: 1; }
.lb-chip[aria-current] .lb-chip-label { display: inline; }
@media (hover: hover) {
  .lb-chip:hover { border-color: rgb(var(--cyan-rgb) / .4); }
  .lb-chip:hover img { opacity: 1; }
}

/* ── Temporadas ───────────────────────────────────────────────────────── */
.lb-seasons {
  display: flex;
  gap: .4rem;
  padding: .75rem 0 .1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.lb-seasons::-webkit-scrollbar { display: none; }
.lb-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 40px;
  padding: 0 1rem;
  border-radius: 999px;
  background: var(--lb-glass);
  border: 1px solid var(--lb-line);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .2s, color .2s, border-color .2s;
}
.lb-pill:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.lb-pill[aria-current] { color: #06191a; background: var(--cyan); border-color: var(--cyan); }
.lb-pill-tag { font-size: .6rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }

.lb-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: 1rem 0 .75rem;
  font-size: .78rem;
  color: var(--muted);
}

/* ── Podio ────────────────────────────────────────────────────────────── */
.podium {
  position: relative;
  isolation: isolate;
  margin-bottom: .9rem;
  padding: 1.75rem .75rem 0;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--lb-line);
  background: var(--surface);
}
.podium-bg {
  position: absolute;
  inset: -25%;
  z-index: -2;
  background-size: cover;
  background-position: center;
  filter: blur(28px) saturate(1.4) brightness(.5);
}
.podium::before {                      /* foco dorado sobre el 1.º + degradado inferior */
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(55% 55% at 50% 0%, rgb(226 187 85 / .25), transparent 72%),
    linear-gradient(180deg, transparent 55%, rgb(13 15 19 / .7));
}
.podium-cols {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: .5rem;
  list-style: none;
}
.pod {
  flex: 1 1 0;
  min-width: 0;
  max-width: 12rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: lb-rise .65s var(--lb-ease) both;
  animation-delay: calc(var(--i) * 90ms);
}
.pod-1 { order: 2; }                   /* orden visual 2.º · 1.º · 3.º, el DOM sigue 1-2-3 */
.pod-2 { order: 1; }
.pod-3 { order: 3; }

.place-1 { --ring: linear-gradient(135deg, #f8e19a, #d2a63f 55%, #8f6b22); --tone: var(--lb-gold); }
.place-2 { --ring: linear-gradient(135deg, #f1f3f8, #9aa3b5);              --tone: var(--lb-silver); }
.place-3 { --ring: linear-gradient(135deg, #efbc92, #a9683b);              --tone: var(--lb-bronze); }

.pod-avatar {
  position: relative;
  padding: 3px;
  border-radius: 50%;
  background: var(--ring);
  box-shadow: 0 10px 28px -8px color-mix(in srgb, var(--tone) 55%, transparent);
}
.pod-avatar .avatar-img,
.pod-avatar .avatar-fallback { display: block; border: 2px solid var(--bg); }
.pod-avatar .avatar-fallback { background: var(--elevated); color: var(--text); }
.pod-medal {
  position: absolute;
  left: 50%;
  bottom: -9px;
  translate: -50% 0;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid var(--bg);
  background: var(--ring);
  color: #1a1204;
  font-size: .72rem;
  font-weight: 800;
}
.pod-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  max-width: 100%;
  margin-top: 1rem;
  padding-inline: .15rem;
  font-size: .9rem;
  font-weight: 700;
}
.pod-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-score { margin-top: .1rem; font-size: .72rem; color: var(--muted); }
.pod-score b { margin-right: .15rem; font-size: 1.2rem; font-weight: 800; color: var(--text); }
.pod-step {
  width: 100%;
  margin-top: .8rem;
  border: 1px solid color-mix(in srgb, var(--tone) 45%, transparent);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 42%, transparent), color-mix(in srgb, var(--tone) 6%, transparent));
}
.place-1 .pod-step { height: 68px; }
.place-2 .pod-step { height: 46px; }
.place-3 .pod-step { height: 30px; }

.you {
  flex: none;
  padding: .15rem .4rem;
  border-radius: 6px;
  background: var(--cyan);
  color: #06191a;
  font-size: .6rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* ── Resto del ranking ────────────────────────────────────────────────── */
.rank-list { display: grid; gap: .5rem; list-style: none; }
.rank-row {
  display: grid;
  grid-template-columns: 1.75rem 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: .75rem;
  padding: .7rem .9rem;
  border-radius: 18px;
  background: var(--lb-glass);
  border: 1px solid var(--lb-line);
  animation: lb-rise .5s var(--lb-ease) both;
  animation-delay: calc(min(var(--i), 12) * 40ms + 250ms);
}
.rank-row .avatar-fallback { background: var(--elevated); color: var(--text); }
.rank-num { font-size: .95rem; font-weight: 800; color: var(--muted); text-align: center; }
.rank-name { display: flex; align-items: center; gap: .4rem; min-width: 0; font-size: .95rem; font-weight: 600; }
.rank-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { height: 4px; margin-top: .5rem; overflow: hidden; border-radius: 99px; background: rgb(255 255 255 / .07); }
.rank-bar i {
  display: block;
  width: var(--pct);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
  transform-origin: left;
  animation: lb-grow .8s var(--lb-ease) both;
  animation-delay: calc(min(var(--i), 12) * 40ms + 400ms);
}
.rank-score { text-align: right; line-height: 1.1; }
.rank-score b { font-size: 1.2rem; font-weight: 800; }
.rank-score small { display: block; margin-top: .1rem; font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rank-row.is-me {
  background: rgb(var(--cyan-rgb) / .08);
  border-color: rgb(var(--cyan-rgb) / .5);
  box-shadow: 0 0 0 1px rgb(var(--cyan-rgb) / .15);
}

/* ── Barra "tu posición" ──────────────────────────────────────────────── */
.me-bar {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom, 0px) + .75rem);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: 1rem;
  padding: .55rem .55rem .55rem 1rem;
  border-radius: 18px;
  border: 1px solid rgb(var(--cyan-rgb) / .4);
  background: color-mix(in srgb, var(--elevated) 82%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  box-shadow: 0 14px 32px -12px rgb(0 0 0 / .85);
  animation: lb-rise .4s var(--lb-ease) both;
}
.me-bar[hidden] { display: none; }
.me-bar-info { display: flex; align-items: baseline; gap: .6rem; min-width: 0; font-size: .85rem; }
.me-bar-rank { font-size: 1.15rem; font-weight: 800; color: var(--cyan); }
.me-bar-btn {
  min-height: 40px;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 12px;
  background: var(--cyan);
  color: #06191a;
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
.me-bar-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ── Estado vacío ─────────────────────────────────────────────────────── */
.lb-empty {
  display: grid;
  justify-items: center;
  gap: .5rem;
  margin-top: 1.25rem;
  padding: 3rem 1.5rem;
  text-align: center;
  border-radius: 24px;
  border: 1px dashed rgb(255 255 255 / .14);
  background:
    radial-gradient(80% 60% at 50% 0%, rgb(var(--cyan-rgb) / .09), transparent 70%),
    var(--lb-glass);
}
.lb-empty svg { width: 56px; height: 56px; margin-bottom: .4rem; color: var(--cyan); }
.lb-empty h2 { font-size: 1.1rem; font-weight: 700; text-wrap: balance; }
.lb-empty p { max-width: 34ch; font-size: .88rem; line-height: 1.55; color: var(--muted); text-wrap: pretty; }

/* ── Pantallas medianas y grandes ─────────────────────────────────────── */
@media (min-width: 640px) {
  /* Con ratón no se desliza cómodamente: los chips se reparten en varias líneas */
  .lb-chips {
    position: static;
    flex-wrap: wrap;
    margin-inline: 0;
    padding: 0 0 .9rem;
    overflow: visible;
    background: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .podium { padding: 2.25rem 1.5rem 0; }
  .podium-cols { gap: 1rem; }
  .pod-name { font-size: 1rem; }
  .place-1 .pod-step { height: 84px; }
  .place-2 .pod-step { height: 56px; }
  .place-3 .pod-step { height: 38px; }
  .rank-row { padding: .8rem 1.1rem; }
}

@keyframes lb-rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes lb-grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) {
  .pod, .rank-row, .rank-bar i, .me-bar { animation: none; }
  .lb-chip { transition: none; }
}
