/**
 * Shared cross-session leaderboard styling. Pairs with rankings.js.
 *
 * Deliberately theme-neutral, the same contract as fun_stats.css: a game sets
 * --lb-accent (and optionally the text/edge/panel tokens) on any ancestor, so
 * the identical markup reads as native in Tron's cyan, Zombie's rot-green and
 * Shooter's amber. Fonts are inherited, never declared.
 *
 * ANCESTOR is the operative word. In the OVERLAY form the Close button is a
 * sibling of .lb-panel, not a child, so tokens set on `.lb-panel` alone leave
 * it on the defaults below and it hovers the wrong colour. Set them on
 * `.lb-panel, .lb-card` (or on the page) when the game uses `button:`.
 */

:root {
  --lb-accent: #ffd700;
  --lb-text: #e8e8e8;
  --lb-dim: rgba(232, 232, 232, 0.55);
  --lb-edge: rgba(255, 255, 255, 0.12);
  --lb-panel: rgba(255, 255, 255, 0.05);
}

/* ---------------- panel ---------------- */

.lb-panel {
  text-align: left;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--lb-edge);
  border-radius: 10px;
  background: var(--lb-panel);
  color: var(--lb-text);
}

.lb-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--lb-accent);
}

.lb-body.lb-muted { color: var(--lb-dim); }
.lb-empty { font-size: 12.5px; padding: 4px 0; }

/* ---------------- table ---------------- */

/* Grid rather than <table>: the column count is set per game by rankings.js,
   and a grid keeps every row's columns aligned without a colspan dance. */
.lb-table { display: grid; grid-template-columns: 1fr; gap: 1px; }

.lb-row {
  display: grid;
  grid-template-columns: 2.1em minmax(0, 1fr) repeat(var(--lb-cols, 1), minmax(3.2em, auto));
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 12.5px;
  border-bottom: 1px solid transparent;
}

.lb-head {
  color: var(--lb-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--lb-edge);
  padding-bottom: 4px;
  margin-bottom: 2px;
}

.lb-rank { text-align: center; font-variant-numeric: tabular-nums; }

/* A long name ellipsizes instead of pushing the stat columns off the row.
   min-width:0 is what makes that work inside a grid track. */
.lb-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.lb-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--lb-dim);
}

.lb-row.lb-top .lb-val { color: var(--lb-text); }
.lb-top1 .lb-rank { color: #ffd700; }
.lb-top2 .lb-rank { color: #c0c0c0; }
.lb-top3 .lb-rank { color: #cd7f32; }

/* The local player's row — the one row they came to find. */
.lb-row.lb-mine {
  background: color-mix(in srgb, var(--lb-accent) 16%, transparent);
  border-radius: 5px;
}

/* ---------------- overlay form ---------------- */

.lb-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
}

.lb-overlay.lb-hidden { display: none; }

.lb-card {
  width: min(560px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  padding: 14px 16px 16px;
  border: 1px solid var(--lb-edge);
  border-radius: 12px;
  background: #10131c;
  color: var(--lb-text);
}

.lb-card .lb-panel { margin-top: 0; border: none; background: none; padding: 0; }

.lb-close {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--lb-text);
  background: var(--lb-panel);
  border: 1px solid var(--lb-edge);
  border-radius: 8px;
  cursor: pointer;
}

.lb-close:hover { border-color: var(--lb-accent); }

@media (max-width: 480px) {
  .lb-row { font-size: 12px; gap: 6px; }
  .lb-card { padding: 12px; }
}

/* A qualifier that belongs to the name — a hero's class, a lap's map. */
.lb-sub { color: var(--lb-dim); font-size: 0.85em; }
