/* Leaderboard overlay (shared/leaderboard.js). Everything is scoped under .lb-root so it cannot
 * leak into a game's own styles; --lb-accent is set per game. */
.lb-root {
  --lb-accent: #2f7df6;
  --lb-bg: #ffffff;
  --lb-fg: #1d1f24;
  --lb-muted: #6b7079;
  --lb-line: #e7e8ec;
  --lb-me: color-mix(in srgb, var(--lb-accent) 16%, transparent);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}
.lb-root.lb-dark {
  --lb-bg: var(--lb-dark-bg, #1c1f27);
  --lb-fg: #f2f3f5;
  --lb-muted: #9ba1ad;
  --lb-line: color-mix(in srgb, var(--lb-fg) 14%, var(--lb-bg));
}
.lb-root [hidden] { display: none !important; }
.lb-root button { font: inherit; cursor: pointer; }
.lb-backdrop:focus, .lb-dialog:focus { outline: none; }

.lb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  animation: lb-fade .15s ease-out;
}
@keyframes lb-fade { from { opacity: 0; } }
/* A game played sideways on a portrait screen: turn the dialog with it (same transform as
 * Headlock's own menu: game top = screen right). */
@media (orientation: portrait) {
  .lb-landscape .lb-backdrop {
    inset: auto;
    top: 0;
    left: 0;
    width: 100vh;
    height: 100vw;
    transform-origin: 0 0;
    transform: rotate(90deg) translateY(-100%);
  }
}

.lb-dialog {
  width: min(420px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--lb-bg);
  color: var(--lb-fg);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  overflow: hidden;
  animation: lb-pop .18s ease-out;
}
@keyframes lb-pop { from { transform: scale(.94); opacity: 0; } }

.lb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 12px 12px 20px;
  border-top: 5px solid var(--lb-accent);
}
.lb-title { flex: 1; display: flex; flex-direction: column; font-weight: 700; font-size: 1.25em; }
.lb-kicker { font-size: .7em; font-weight: 600; color: var(--lb-muted); text-transform: uppercase; letter-spacing: .06em; }
.lb-close {
  width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--lb-muted); font-size: 28px !important; line-height: 1;
}
.lb-close:hover { background: var(--lb-line); }

.lb-form { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 10px; }
.lb-intro { margin: 0 0 4px; color: var(--lb-muted); }
.lb-input {
  font: inherit;
  font-size: 18px; /* 16px+ keeps iOS from zooming in */
  padding: 12px 14px;
  border: 2px solid var(--lb-line);
  border-radius: 12px;
  background: var(--lb-bg);
  color: var(--lb-fg);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.lb-input:focus { border-color: var(--lb-accent); }
.lb-error { min-height: 1.35em; font-size: .85em; color: #d4343c; }
.lb-dark .lb-error { color: #ff7a73; }
.lb-actions { display: flex; gap: 10px; justify-content: flex-end; }
.lb-primary, .lb-secondary {
  min-width: 96px; padding: 11px 18px; border-radius: 12px; font-weight: 700;
}
.lb-primary { border: 0; background: var(--lb-accent); color: var(--lb-on-accent, #fff); }
.lb-primary:disabled { opacity: .6; }
.lb-secondary { border: 2px solid var(--lb-line); background: transparent; color: var(--lb-fg); }

/* One tab per mode, for a game with several boards. */
.lb-tabs {
  display: flex; gap: 6px; padding: 0 20px 12px; overflow-x: auto; scrollbar-width: none;
}
.lb-tabs::-webkit-scrollbar { display: none; }
.lb-tab {
  flex: none; padding: 6px 12px; border-radius: 999px; font-size: .85em !important; font-weight: 600;
  border: 2px solid var(--lb-line); background: transparent; color: var(--lb-muted);
}
.lb-tab[aria-selected="true"] { border-color: var(--lb-accent); background: var(--lb-accent); color: var(--lb-on-accent, #fff); }

.lb-you {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px;
  padding: 0 20px 12px; color: var(--lb-muted); font-size: .9em;
}
.lb-you b { color: var(--lb-fg); }
.lb-standing { margin-left: auto; font-weight: 700; color: var(--lb-fg); }
.lb-link {
  border: 0; padding: 0; background: none; color: var(--lb-accent); font-weight: 600;
  text-decoration: underline; text-underline-offset: 2px;
}
.lb-dark .lb-link { filter: brightness(1.4); }

.lb-cols, .lb-row {
  display: grid;
  grid-template-columns: 3.2em 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 0 20px;
}
.lb-cols {
  font-size: .72em; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--lb-muted); padding-bottom: 6px; border-bottom: 1px solid var(--lb-line);
}
.lb-cols span:last-child { text-align: right; }
.lb-list { list-style: none; margin: 0; padding: 4px 0 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.lb-row { min-height: 40px; font-variant-numeric: tabular-nums; }
.lb-row:nth-child(-n + 3) .lb-rank { color: var(--lb-accent); }
.lb-rank { font-weight: 700; color: var(--lb-muted); }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 700; text-align: right; }
.lb-me { background: var(--lb-me); }
.lb-me .lb-name { font-weight: 700; }
.lb-gap { text-align: center; color: var(--lb-muted); line-height: 1; padding: 2px 0 6px; }
.lb-note { padding: 18px 20px; color: var(--lb-muted); text-align: center; }

/* The account line under the board (shared/cloud.js). */
.lb-account { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px;
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--lb-line); font-size: 13px; color: var(--lb-muted); }
