/* ===========================================================================
   BOARD — the public leaderboards (js/core/board-ui.js): the block under a
   results screen, the full board over a game, and the setup screen's button.
   All of it lives inside the arena, so it uses the arena's dark palette in
   both page themes, and the game's own accent.
   =========================================================================== */

.lb[hidden],
.lb-open[hidden] { display: none; }

.lb {
  width: 100%;
  padding: 14px 14px 12px;
  border-radius: var(--r-lg);
  text-align: left;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--arena-line);
}

.lb--result { margin-top: 6px; }

.lb__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.lb__title {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--arena-ink-2);
}

.lb__title svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #FFD447;
  filter: drop-shadow(0 0 6px rgba(255, 212, 71, 0.5));
}

.lb__title small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: inherit;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--arena-ink-3);
}

.lb__title small::before { content: '· '; }

.lb__rank {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--game-accent);
}

.lb__list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.lb__row {
  display: grid;
  grid-template-columns: 2.1em minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 6px 12px 6px 6px;
  border-radius: 11px;
  font-size: 0.9rem;
  background: var(--arena-chip);
  animation: fade-up 0.4s var(--ease) both;
}

.lb__row:nth-child(2) { animation-delay: 0.04s; }
.lb__row:nth-child(3) { animation-delay: 0.08s; }
.lb__row:nth-child(n+4) { animation-delay: 0.12s; }

.lb__pos {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  color: var(--arena-ink-3);
}

.lb__row[data-place="1"] .lb__pos { color: #FFD447; text-shadow: 0 0 10px rgba(255, 212, 71, 0.7); }
.lb__row[data-place="2"] .lb__pos { color: #DCE4F5; text-shadow: 0 0 10px rgba(220, 228, 245, 0.5); }
.lb__row[data-place="3"] .lb__pos { color: #F0A066; text-shadow: 0 0 10px rgba(240, 160, 102, 0.5); }

.lb__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--arena-ink);
}

.lb__score {
  font-family: var(--font-display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--arena-ink);
}

.lb__row.is-me {
  background: var(--game-soft);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--game-accent) 60%, transparent),
              0 0 18px -6px var(--game-glow);
}

.lb__row.is-me .lb__name::after {
  content: ' · you';
  font-weight: 600;
  color: var(--game-accent);
}

.lb__gap {
  padding: 1px 0;
  line-height: 1;
  text-align: center;
  letter-spacing: 0.3em;
  color: var(--arena-ink-3);
}

.lb__row--skeleton {
  background: linear-gradient(90deg, var(--arena-chip) 20%, rgba(255, 255, 255, 0.1) 50%, var(--arena-chip) 80%);
  background-size: 220% 100%;
  animation: lb-shimmer 1.3s linear infinite;
}

@keyframes lb-shimmer {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}

.lb__empty {
  margin: 0 auto;
  padding: 10px 6px;
  font-size: 0.86rem;
  text-align: center;
  color: var(--arena-ink-3);
}

.panel .lb__empty { max-width: none; }

.lb__foot {
  margin-top: 10px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--arena-ink-2);
}

.lb__foot:empty { display: none; }

.panel .lb__foot p,
.panel .lb-sheet__you p {
  max-width: none;
  font-size: 0.86rem;
  line-height: 1.5;
}

.lb__foot b,
.lb-sheet__you b { color: var(--arena-ink); }

.lb__form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.lb__input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 8px 15px;
  border-radius: var(--r-full);
  font: 600 0.95rem var(--font-sans);
  color: var(--arena-ink);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--arena-line-strong);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.lb__input::placeholder { color: var(--arena-ink-3); }

.lb__input:focus {
  outline: none;
  border-color: var(--game-accent);
  box-shadow: 0 0 0 3px var(--game-soft);
}

.lb__form .btn { min-height: 40px; }

.panel .lb__error {
  min-height: 1.2em;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--arena-bad);
}

.panel .lb__note {
  margin-top: 2px;
  font-size: 0.76rem;
  color: var(--arena-ink-3);
}

.lb__more,
.lb__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--game-accent);
  transition: gap var(--t-fast) var(--ease), filter var(--t-fast) var(--ease);
}

.lb__more {
  margin-top: 10px;
  font-size: 0.86rem;
}

.lb__more svg {
  width: 15px;
  height: 15px;
}

.lb__more:hover { gap: 9px; filter: brightness(1.15); }

.lb__link {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- The setup screen's button --- */
.lb-open svg {
  width: 17px;
  height: 17px;
  color: #FFD447;
}

/* --- The full board, over the arena (and over whatever panel is up) --- */
.lb-sheet {
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-overlay) + 2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--scrim);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in 0.22s var(--ease);
}

.lb-sheet__card.panel {
  max-width: 480px;
  align-items: stretch;
  text-align: left;
  padding-top: 24px;
}

.lb-sheet__card .panel__eyebrow { align-self: flex-start; }

.lb-sheet__card h2 { padding-right: 44px; }

.lb-sheet__close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--arena-ink-2);
  background: var(--arena-chip);
  border: 1px solid var(--arena-line);
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.lb-sheet__close svg { width: 18px; height: 18px; }

.lb-sheet__close:hover {
  color: var(--arena-ink);
  background: var(--arena-chip-strong);
}

.lb-sheet__mode {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 42px;
  padding: 9px 40px 9px 16px;
  border-radius: var(--r-full);
  font: 600 0.92rem var(--font-display);
  color: var(--arena-ink);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A3AACF' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 16px,
    var(--arena-chip);
  border: 1px solid var(--arena-line-strong);
  cursor: pointer;
}

.lb-sheet__mode:focus-visible {
  outline: none;
  border-color: var(--game-accent);
  box-shadow: 0 0 0 3px var(--game-soft);
}

.lb-sheet__mode option {
  color: #EEF1FF;
  background: #0C1022;
}

.lb--sheet .lb__list {
  max-height: min(52vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.lb-sheet__you {
  font-size: 0.86rem;
  color: var(--arena-ink-2);
}

@media (max-width: 520px) {
  .lb { padding: 12px 10px 10px; }
  .lb__row { gap: 8px; font-size: 0.86rem; }
  .lb-sheet { padding: 10px; }
}
