/* ==============================================
   LEADERBOARD OVERLAY
   ============================================== */
.leaderboard-overlay {
  position: fixed; inset: 0;
  background: rgba(7,9,15,0.88);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: none; align-items: center; justify-content: center;
  z-index: 150; padding: 20px;
}
.leaderboard-overlay.show { display: flex; }

.leaderboard-modal {
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-xl);
  padding: 28px 24px; text-align: center;
  min-width: 300px; max-width: 400px; width: 100%;
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,255,255,0.04);
  animation: popIn 0.38s cubic-bezier(0.175,0.885,0.32,1.275);
}

.leaderboard-modal h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 20px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Loading --- */
.lb-loading {
  padding: 40px;
  display: flex;
  justify-content: center;
}
.lb-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border-2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: lbSpin 0.8s linear infinite;
}
@keyframes lbSpin {
  to { transform: rotate(360deg); }
}

/* --- Empty state --- */
.lb-empty {
  padding: 30px 0;
}
.lb-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}
.lb-empty p {
  color: var(--text-2);
  font-size: 0.9rem;
  margin-bottom: 6px;
}
.lb-empty-sub {
  color: var(--text-3) !important;
  font-size: 0.78rem !important;
}

/* --- List --- */
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  border: 1px solid transparent;
  transition: background 0.18s;
}
.lb-row:hover {
  background: rgba(255,255,255,0.06);
}

/* Highlight current user */
.lb-me {
  background: rgba(139,92,246,0.12) !important;
  border-color: rgba(139,92,246,0.3) !important;
}

/* Top 3 styling */
.lb-rank-1 {
  background: rgba(245,158,11,0.08);
  border-color: rgba(245,158,11,0.2) !important;
}
.lb-rank-2 {
  background: rgba(148,163,184,0.06);
  border-color: rgba(148,163,184,0.15) !important;
}
.lb-rank-3 {
  background: rgba(217,119,6,0.06);
  border-color: rgba(217,119,6,0.15) !important;
}

.lb-rank {
  width: 28px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  flex-shrink: 0;
}
.lb-rank-1 .lb-rank { color: #fbbf24; }
.lb-rank-2 .lb-rank { color: #94a3b8; }
.lb-rank-3 .lb-rank { color: #d97706; }

.lb-avatar-wrap {
  flex-shrink: 0;
}
.lb-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border-2);
}
.lb-avatar-placeholder {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.lb-name {
  flex: 1;
  text-align: left;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-me .lb-name {
  color: #a78bfa;
}

.lb-score {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
}
.lb-unit {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-3);
  margin-left: 2px;
}

/* --- My rank (if outside top 10) --- */
.lb-my-rank {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.lb-my-rank-label {
  font-size: 0.78rem;
  color: var(--text-3);
  font-weight: 600;
}
.lb-my-rank-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: #a78bfa;
}
.lb-my-rank-score {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-2);
}

/* --- Leaderboard button in result overlay --- */
.btn-leaderboard {
  background: rgba(245,158,11,0.1) !important;
  border-color: rgba(245,158,11,0.3) !important;
  color: #fbbf24 !important;
}
.btn-leaderboard:hover {
  background: rgba(245,158,11,0.2) !important;
  color: #fde68a !important;
}
