/* ================================================================
   Leaderboard — shared styles for all games
   ================================================================ */

.lb-panel {
  max-width: 480px;
  margin: 1rem auto;
  background: #1a1a2e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 1rem;
  font-family: system-ui, -apple-system, sans-serif;
  color: #e0e0e0;
}

.lb-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  text-align: center;
  color: #fff;
  letter-spacing: 0.05em;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.lb-table th {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #444;
  color: #a3a3b8;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lb-table th:last-child {
  text-align: right;
}

.lb-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid #2a2a3e;
}

.lb-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.lb-table tr:last-child td {
  border-bottom: none;
}

.lb-row-me td {
  background: rgba(100, 200, 255, 0.1);
  color: #7df;
  font-weight: 600;
}

.lb-rank {
  width: 2.5rem;
  text-align: center !important;
}

.lb-rank-1::before {
  content: '\1F451';
  margin-right: 0.2rem;
}

.lb-empty {
  text-align: center;
  padding: 1.5rem 0.5rem;
  color: #a3a3b8;
  font-style: italic;
}

.lb-loading {
  text-align: center;
  padding: 1.5rem 0.5rem;
  color: #a3a3b8;
}

/* ── Nickname overlay ─────────────────────────────────────── */

.lb-nickname-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: lbFadeIn 0.2s ease;
}

.lb-nickname-modal {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 12px;
  padding: 1.5rem;
  width: min(90vw, 340px);
  text-align: center;
  color: #e0e0e0;
  font-family: system-ui, -apple-system, sans-serif;
}

.lb-nickname-modal h3 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: #fff;
}

.lb-nickname-modal input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 1px solid #555;
  border-radius: 8px;
  background: #0f0f1a;
  color: #fff;
  text-align: center;
  outline: none;
}

.lb-nickname-modal input:focus {
  border-color: #7df;
  box-shadow: 0 0 0 2px rgba(100, 200, 255, 0.25);
}

.lb-nickname-modal button {
  margin-top: 1rem;
  padding: 0.55rem 1.5rem;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  background: #3a7;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

.lb-nickname-modal button:hover {
  background: #4b8;
}

.lb-nickname-modal button:disabled {
  background: #555;
  cursor: default;
}

@keyframes lbFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Leaderboard toggle button — hidden on desktop, shown on mobile ── */
.lb-toggle-btn {
  display: none;
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.15s ease, transform 0.15s ease;
}
.lb-toggle-btn:hover {
  background: rgba(0,210,255,0.1);
  transform: scale(1.1);
}
.lb-toggle-btn:active {
  transform: scale(0.95);
}

/* --- Mobile: compact leaderboard + slide-up panel --- */
@media (max-width: 600px) {
  .lb-panel {
    max-width: 100%;
    margin: 0.5rem auto;
    padding: 0.75rem;
    border-radius: 10px;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
  }

  .lb-panel h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }

  .lb-table {
    font-size: 0.8rem;
  }

  .lb-table th {
    padding: 0.3rem 0.4rem;
    font-size: 0.68rem;
  }

  .lb-table td {
    padding: 0.35rem 0.4rem;
  }

  .lb-toggle-btn {
    display: flex;
  }

  /* Leaderboard slides up from bottom, doesn't steal space from game */
  #leaderboardPanel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 35vh;
    overflow-y: auto;
    z-index: 100;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    pointer-events: none;
  }

  #leaderboardPanel.lb-visible {
    transform: translateY(0);
    pointer-events: auto;
  }

  #leaderboardPanel .lb-panel {
    border-radius: 12px 12px 0 0;
    margin: 0;
    max-width: 100%;
  }
}
