/* ── Leaderboard Modal ── */
#leaderboard-modal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  /* background on the dialog itself as fallback for browsers
     where ::backdrop doesn't apply (some Android Chrome versions) */
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: none;
  padding: 20px 0;
  margin: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

#leaderboard-modal[open] { display: flex; }

#leaderboard-modal::backdrop {
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lb-modal-content {
  width: 92%;
  max-width: 480px;
  margin: 0 auto;
  padding: 30px;
  background: rgba(10, 10, 25, 0.98);
  border: 2px solid #00f3ff;
  border-radius: 12px;
  box-shadow: 0 0 30px rgba(0, 243, 255, 0.4), inset 0 0 20px rgba(0, 243, 255, 0.05);
  font-family: 'Courier New', monospace;
}

/* ── Header ── */
.lb-title {
  font-size: 22px;
  color: #00f3ff;
  text-align: center;
  letter-spacing: 4px;
  margin: 0 0 4px;
  text-shadow: 0 0 15px rgba(0, 243, 255, 0.5);
  text-transform: uppercase;
}

.lb-subtitle {
  font-size: 11px;
  color: rgba(0, 243, 255, 0.45);
  text-align: center;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin: 0 0 14px;
}

/* ── Tabs ── */
.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.lb-tab {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(0, 243, 255, 0.25);
  border-radius: 6px;
  color: rgba(0, 243, 255, 0.5);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
  padding: 9px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.3s ease;
}

.lb-tab.active {
  border-color: #00f3ff;
  color: #00f3ff;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.lb-tab:hover:not(.active) {
  border-color: rgba(0, 243, 255, 0.4);
  color: rgba(0, 243, 255, 0.75);
}

.lb-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #00f3ff, transparent);
  margin-bottom: 18px;
}

/* ── List ── */
.lb-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-entry {
  display: grid;
  grid-template-columns: 28px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 243, 255, 0.12);
  border-radius: 6px;
  transition: border-color 0.2s ease;
}

.lb-entry:hover {
  border-color: rgba(0, 243, 255, 0.3);
}

/* ── Medal positions ── */
.lb-pos-1 {
  border-color: rgba(255, 215, 0, 0.5);
  background: rgba(255, 215, 0, 0.05);
}
.lb-pos-1 .lb-medal { color: #FFD700; text-shadow: 0 0 10px rgba(255, 215, 0, 0.7); }

.lb-pos-2 {
  border-color: rgba(192, 192, 192, 0.4);
  background: rgba(192, 192, 192, 0.04);
}
.lb-pos-2 .lb-medal { color: #C0C0C0; text-shadow: 0 0 8px rgba(192, 192, 192, 0.5); }

.lb-pos-3 {
  border-color: rgba(205, 127, 50, 0.4);
  background: rgba(205, 127, 50, 0.04);
}
.lb-pos-3 .lb-medal { color: #CD7F32; text-shadow: 0 0 8px rgba(205, 127, 50, 0.5); }

/* ── Current user highlight ── */
.lb-self {
  border-color: rgba(0, 255, 136, 0.4) !important;
  background: rgba(0, 255, 136, 0.05) !important;
}
.lb-self .lb-username { color: #00ff88; }

/* ── Entry parts ── */
.lb-medal {
  font-size: 15px;
  color: rgba(0, 243, 255, 0.5);
  text-align: center;
}

.lb-username {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-rank {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.lb-xp {
  font-size: 12px;
  font-weight: bold;
  color: #00f3ff;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* ── State messages ── */
.lb-message {
  text-align: center;
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(0, 243, 255, 0.75);
  text-transform: uppercase;
  padding: 24px 0;
  list-style: none;
}

.lb-error { color: rgba(255, 0, 85, 0.85); }

/* ── Updated timestamp ── */
.lb-updated {
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(0, 243, 255, 0.3);
  text-align: right;
  text-transform: uppercase;
  margin: 0 0 16px;
}

/* ── Actions ── */
.lb-actions {
  display: flex;
  gap: 8px;
}

.lb-refresh-btn {
  flex: 1;
  background: transparent;
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 6px;
  color: rgba(0, 243, 255, 0.6);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 10px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.3s ease;
}

.lb-refresh-btn:hover {
  border-color: #00f3ff;
  color: #00f3ff;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.2);
}

.lb-close-btn {
  flex: 1;
  background: transparent;
  border: 2px solid #ff0055;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Courier New', monospace;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
  padding: 10px;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.3s ease;
}

.lb-close-btn:hover {
  background: #ff0055;
  color: #000; /* NOSONAR */
  box-shadow: 0 0 15px #ff0055;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .lb-modal-content { padding: 20px 14px; }
  .lb-title { font-size: 18px; letter-spacing: 3px; }
  .lb-entry { grid-template-columns: 24px 1fr auto; gap: 6px; padding: 8px 10px; }
  .lb-rank { display: none; }
  .lb-xp { font-size: 11px; }
}
