/* ============================================================================
 * leaderboard.css | Live leaderboard — podium, ranked table, my-rank card
 * ----------------------------------------------------------------------------
 * Mobile-first. Every colour comes from the tokens in style.css, so light and
 * dark themes are inherited rather than redeclared.
 * ========================================================================== */

/* -------------------------------------------------------------- HERO ----- */
.lb2-hero { padding-bottom: 28px; }
.lb2-hero__row {
  display: grid;
  gap: 20px;
  align-items: end;
}
.lb2-hero h1 { margin: 6px 0 10px; }
.lb2-tagline {
  max-width: 60ch;
  color: var(--text-2);
  font-size: clamp(0.98rem, 2.2vw, 1.08rem);
  line-height: 1.65;
}
.lb2-live {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent);
  animation: lb2-pulse 2s infinite;
  vertical-align: 1px;
}
.lb2-live.is-off { background: var(--muted); animation: none; }
@keyframes lb2-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 55%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.lb2-season {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.lb2-season__lab {
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--brand);
}
.lb2-season__title { font-size: 1.12rem; }
.lb2-season__track {
  height: 6px; border-radius: 99px; background: var(--bg-2); overflow: hidden;
}
.lb2-season__track span {
  display: block; height: 100%; width: 0;
  background: var(--brand-grad); border-radius: inherit;
  transition: width 0.8s var(--ease);
}
.lb2-season__foot { font-size: 0.8rem; color: var(--muted); }

/* ------------------------------------------------------------ LAYOUT ----- */
.lb2 { padding-top: 8px; }
.lb2-layout { display: grid; gap: 22px; }
.lb2-main { min-width: 0; }

/* ----------------------------------------------------- TABS + REFRESH --- */
.lb2-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.lb2-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 4px; padding: 4px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  flex: 1 1 360px;
  max-width: 520px;
}
.lb2-tab {
  border: 0; background: transparent; color: var(--text-2);
  font: inherit; font-weight: 700; font-size: 0.88rem;
  padding: 9px 6px; border-radius: 10px; cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.lb2-tab[aria-selected="true"] { background: var(--brand); color: #fff; }
.lb2-tab:focus-visible, .lb2-refresh:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.lb2-refresh {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 0.82rem; font-weight: 600;
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
}
.lb2-refresh.is-busy span:first-child { animation: lb2-spin 0.8s linear infinite; display: inline-block; }
@keyframes lb2-spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------- SUMMARY ----- */
.lb2-summary {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 18px;
}
.lb2-sum {
  display: grid; gap: 2px;
  padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--border);
}
.lb2-sum__lab { font-size: 0.74rem; color: var(--muted); font-weight: 600; }
.lb2-sum b { font-size: 1.2rem; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ AVATAR ----- */
.lb2-av {
  --s: 38px;
  flex: 0 0 auto;
  width: var(--s); height: var(--s); border-radius: 50%;
  display: inline-grid; place-items: center; overflow: hidden;
  font-weight: 800; font-size: calc(var(--s) * 0.36); color: #fff;
  background: hsl(var(--h, 240) 60% 52%);
}
.lb2-av img { width: 100%; height: 100%; object-fit: cover; }

/* ------------------------------------------------------------ PODIUM ----- */
.lb2-podium {
  display: grid; grid-template-columns: 1fr 1.12fr 1fr;
  gap: 10px; align-items: end; margin-bottom: 16px;
}
.lb2-podium:empty { display: none; }
.lb2-pod {
  position: relative;
  display: grid; justify-items: center; gap: 6px;
  padding: 18px 10px 14px; text-align: center;
  border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 0;
}
.lb2-pod--1 { order: 2; padding-top: 26px; border-color: #f5c84c; background: linear-gradient(180deg, color-mix(in srgb, #fbbf24 16%, var(--surface)), var(--surface) 70%); }
.lb2-pod--2 { order: 1; border-color: #cbd5e1; }
.lb2-pod--3 { order: 3; border-color: #e3a676; }
.lb2-pod--empty { opacity: 0.55; box-shadow: none; border-style: dashed; }
.lb2-pod .lb2-av { --s: 52px; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--medal, #cbd5e1); }
.lb2-pod--1 .lb2-av { --s: 64px; --medal: #f5b50a; }
.lb2-pod--2 .lb2-av { --medal: #94a3b8; }
.lb2-pod--3 .lb2-av { --medal: #d97706; }
.lb2-pod__medal { position: absolute; top: -12px; font-size: 1.35rem; line-height: 1; }
.lb2-pod__name {
  font-weight: 800; font-size: 0.92rem; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lb2-pod__pts { font-size: 1.15rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; }
.lb2-pod__pts small { font-size: 0.7rem; color: var(--muted); font-weight: 700; margin-left: 2px; }
.lb2-pod__meta { font-size: 0.74rem; color: var(--muted); }
.lb2-pod.is-me { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ------------------------------------------------------------- TABLE ----- */
.lb2-table {
  border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--border);
  overflow: hidden;
}
.lb2-table.is-empty { display: none; }
.lb2-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 70px;
  align-items: center; gap: 10px;
  padding: 11px 14px;
  border-top: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.lb2-row--head {
  border-top: 0; background: var(--surface-2);
  font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  padding-top: 9px; padding-bottom: 9px;
}
.lb2-row .c-q, .lb2-row .c-acc { display: none; }
.lb2-row .c-rank { font-weight: 800; color: var(--text-2); text-align: center; }
.lb2-row .c-pts { text-align: right; font-weight: 800; }
.lb2-row .c-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.lb2-who { min-width: 0; display: grid; }
.lb2-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.94rem; }
.lb2-who small { color: var(--muted); font-size: 0.76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb2-you {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 99px;
  background: var(--brand); color: #fff; font-size: 0.66rem; font-weight: 800;
  vertical-align: 2px;
}
.lb2-row.is-me { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); }
.lb2-row.is-me .c-rank { color: var(--brand); }
.lb2-acc { display: inline-flex; align-items: center; gap: 6px; }
.lb2-acc i {
  display: block; width: 38px; height: 5px; border-radius: 99px; background: var(--bg-2); overflow: hidden;
}
.lb2-acc i::after {
  content: ""; display: block; height: 100%; width: var(--w, 0%);
  background: var(--success); border-radius: inherit;
}

/* skeleton rows */
.lb2-sk { height: 60px; border-top: 1px solid var(--border); position: relative; overflow: hidden; }
.lb2-sk::after {
  content: ""; position: absolute; inset: 14px 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--bg-2), var(--surface-2), var(--bg-2));
  background-size: 200% 100%;
  animation: lb2-shimmer 1.2s infinite linear;
}
@keyframes lb2-shimmer { to { background-position: -200% 0; } }

/* ------------------------------------------------------------- STATES ---- */
.lb2-state {
  text-align: center; padding: 34px 20px;
  border-radius: var(--r-md);
  background: var(--surface); border: 1px dashed var(--border);
}
.lb2-state__art { font-size: 2.4rem; line-height: 1; margin-bottom: 10px; }
.lb2-state h2 { font-size: clamp(1.05rem, 2.4vw, 1.25rem); margin-bottom: 6px; }
.lb2-state p { color: var(--text-2); max-width: 46ch; margin: 0 auto; }
.lb2-state .btn-row { justify-content: center; margin-top: 16px; }

/* ------------------------------------------------------------ MY CARD ---- */
.lb2-side { display: grid; gap: 16px; align-content: start; }
.lb2-me {
  border-radius: var(--r-lg);
  padding: 18px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.lb2-me:empty { display: none; }
.lb2-me__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.lb2-me__head .lb2-av { --s: 46px; }
.lb2-me__name { font-weight: 800; line-height: 1.25; }
.lb2-me__sub { font-size: 0.8rem; color: var(--muted); }
.lb2-me__rank {
  display: flex; align-items: baseline; gap: 8px;
  padding: 14px 16px; border-radius: var(--r-md);
  background: var(--brand-grad); color: #fff; margin-bottom: 12px;
}
.lb2-me__rank b { font-size: 2rem; letter-spacing: -0.02em; line-height: 1; }
.lb2-me__rank span { font-size: 0.85rem; opacity: 0.92; }
.lb2-me__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lb2-me__cell {
  display: grid; gap: 2px; text-align: center;
  padding: 10px 4px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border);
}
.lb2-me__cell b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.lb2-me__cell span { font-size: 0.7rem; color: var(--muted); font-weight: 600; }
.lb2-me__note { font-size: 0.84rem; color: var(--text-2); margin: 12px 0 0; line-height: 1.55; }
.lb2-me .btn { width: 100%; justify-content: center; margin-top: 12px; }
.lb2-me__join h2 { font-size: 1.12rem; margin-bottom: 6px; }
.lb2-me__join p { font-size: 0.9rem; color: var(--text-2); line-height: 1.55; }
.lb2-me__perks { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; font-size: 0.86rem; }
.lb2-me__perks li::before { content: "✓"; color: var(--success); font-weight: 800; margin-right: 8px; }
.lb2-me .btn-google {
  display: inline-flex; align-items: center; gap: 10px;
  background: #fff; color: #1f2937; border: 1px solid #dadce0; font-weight: 700;
}

/* ------------------------------------------------------------- RULES ----- */
.lb2-rules {
  border-radius: var(--r-lg); padding: 18px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.lb2-rules h2 { font-size: 1rem; margin-bottom: 10px; }
.lb2-rules ul { margin: 0; padding-left: 18px; display: grid; gap: 7px; font-size: 0.86rem; color: var(--text-2); line-height: 1.5; }
.lb2-rules b { color: var(--text); }

/* ------------------------------------------------------- MOBILE DOCK ----- */
.lb2-dock {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(56px + 10px + env(safe-area-inset-bottom, 0px)); /* above .mobile-nav */
  z-index: 95;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 16px;
  background: var(--text); color: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
}
.lb2-dock[hidden] { display: none; }
.lb2-dock b { font-size: 1.1rem; }
.lb2-dock .lb2-av { --s: 30px; }
.lb2-dock__pts { margin-left: auto; font-weight: 800; }

/* ============================================================== CTA ====== */
.lb-cta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 15px;
  margin-bottom: 26px;
}
.lb-cta { display: block; padding: 19px; text-decoration: none; color: inherit; }
.lb-cta__ico { font-size: 1.5rem; display: block; margin-bottom: 9px; }
.lb-cta__t { font-size: 1.02rem; font-weight: 800; letter-spacing: -0.01em; margin-bottom: 5px; }
.lb-cta__d { font-size: 0.87rem; color: var(--text-2); line-height: 1.55; }
@media (hover: hover) {
  .lb-cta:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
  .lb2-row:not(.lb2-row--head):hover { background: var(--surface-2); }
  .lb2-row.is-me:hover { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); }
}

/* ===================================================== WIDER SCREENS ===== */
@media (max-width: 420px) {
  .lb2-tab { font-size: 0.8rem; padding: 9px 2px; }
  .lb2-sum { padding: 10px; }
  .lb2-sum b { font-size: 1.05rem; }
  .lb2-pod { padding-left: 6px; padding-right: 6px; }
  .lb2-pod .lb2-av { --s: 44px; }
  .lb2-pod--1 .lb2-av { --s: 54px; }
}
@media (min-width: 640px) {
  .lb2-row { grid-template-columns: 44px minmax(0, 1fr) 76px 110px 84px; }
  .lb2-row .c-q, .lb2-row .c-acc { display: block; text-align: center; }
  .lb2-row .c-acc { display: flex; justify-content: center; }
  .lb2-row--head .c-acc { display: block; }
  .lb2-podium { gap: 16px; }
}
@media (min-width: 900px) {
  .lb2-hero__row { grid-template-columns: minmax(0, 1fr) 320px; }
  .lb2-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .lb2-side { position: sticky; top: calc(var(--header-h) + 16px); }
  .lb2-dock { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .lb2-live, .lb2-sk::after, .lb2-refresh.is-busy span:first-child { animation: none !important; }
  .lb-cta, .lb2-season__track span { transition: none !important; transform: none !important; }
}
.lb2-summary[hidden] { display: none; }
