* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Lilita One', cursive;
  background: #1e0340;
  color: #fff;
  overflow-x: hidden;
  min-height: 100vh;
}

header { will-change: transform; }

.sunburst-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  overflow: hidden;
  contain: layout paint;
  background: radial-gradient(ellipse at 50% 45%, #7c3aed 0%, #5b21b6 30%, #4c1d95 50%, #3b0764 70%, #1e0340 100%);
}
.sunburst-bg::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 250vmax; height: 250vmax;
  transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 0deg, rgba(255,255,255,0.045) 0deg 5deg, transparent 5deg 10deg);
  will-change: transform;
  animation: sunburst-spin 240s linear infinite;
}
.sunburst-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, transparent 30%, rgba(30,3,64,0.5) 80%);
  pointer-events: none;
}
@keyframes sunburst-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .sunburst-bg::before { animation: none !important; }
}

.particles-layer {
  position: fixed; top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.particle {
  position: absolute;
  width: 4px; height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  animation: float-particle linear infinite;
}
@keyframes float-particle {
  from { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  to   { transform: translateY(-10vh) scale(1); opacity: 0; }
}

.leaderboard-page {
  position: relative;
  z-index: 1;
  padding: 220px 20px 80px;
  max-width: 900px;
  margin: 0 auto;
  min-height: 100vh;
}

.leaderboard-page-title {
  text-align: center;
  font-size: 3.5rem;
  color: #fbbf24;
  text-shadow: 0 0 30px rgba(251,191,36,0.5), 0 0 60px rgba(251,191,36,0.2);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  opacity: 0;
  animation: fadeUp 0.6s ease-out forwards;
}

.leaderboard-page-subtitle {
  text-align: center;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.45);
  font-family: system-ui, sans-serif;
  font-weight: 400;
  margin-bottom: 40px;
  opacity: 0;
  animation: fadeUp 0.6s 0.1s ease-out forwards;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.leaderboard-card {
  background: rgba(15,5,40,0.7);
  border: 2px solid rgba(251,191,36,0.2);
  border-radius: 22px;
  padding: 32px;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.4), 0 0 20px rgba(251,191,36,0.08);
  opacity: 0;
  animation: fadeUp 0.6s 0.2s ease-out forwards;
}

.leaderboard-card-title {
  font-family: 'Lilita One', cursive;
  font-size: 2rem;
  color: #fbbf24;
  text-align: center;
  margin-bottom: 24px;
  text-shadow: 0 0 20px rgba(251,191,36,0.4);
  letter-spacing: 0.04em;
}

.total-players-box {
  text-align: center;
  margin-bottom: 24px;
  padding: 14px;
  background: rgba(124,58,237,0.08);
  border-radius: 14px;
  border: 1px solid rgba(124,58,237,0.2);
}

.total-players-label {
  font-size: 1.1rem;
  color: #a78bfa;
  margin-bottom: 4px;
}

.total-players-count {
  font-size: 1.8rem;
  color: #fbbf24;
  text-shadow: 0 0 12px rgba(251,191,36,0.4);
}

.total-players-sub {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.4);
  margin-top: 4px;
  font-family: system-ui, sans-serif;
  font-weight: 400;
}

.leaderboard-categories {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 24px;
}

.category-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.category-section-title {
  font-size: 1rem;
  color: #a78bfa;
  text-align: center;
  margin: 0;
}

.category-buttons-group {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.category-btn {
  padding: 8px 18px;
  border: 2px solid rgba(124,58,237,0.4);
  background: rgba(124,58,237,0.12);
  color: rgba(255,255,255,0.7);
  border-radius: 10px;
  cursor: url('/static/cursor/select.cur'), pointer !important;
  font-size: 0.85rem;
  font-family: 'Lilita One', cursive;
  box-shadow: 0 2px 10px rgba(124,58,237,0.15);
  transition: background 0.25s, box-shadow 0.25s, border-color 0.25s, color 0.25s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  min-width: 80px;
}

.category-btn * {
  cursor: url('/static/cursor/select.cur'), pointer !important;
}

.category-btn:hover {
  background: rgba(124,58,237,0.25);
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
  border-color: rgba(124,58,237,0.6);
  color: #fff;
}

.category-btn.active {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border-color: #a78bfa;
  box-shadow: 0 4px 18px rgba(124,58,237,0.5);
  color: #fff;
}

.leaderboard-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.leaderboard-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(124,58,237,0.3);
  box-shadow: 0 0 8px rgba(124,58,237,0.15);
  flex-shrink: 0;
}

.leaderboard-item {
  background: rgba(15,5,40,0.5);
  border-radius: 14px;
  padding: 20px 24px;
  border: 1.5px solid rgba(124,58,237,0.2);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  cursor: url('/static/cursor/select.cur'), pointer !important;
  position: relative;
}

.leaderboard-item-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.25;
  z-index: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  border-radius: inherit;
  overflow: hidden;
}

.leaderboard-item > *:not(.leaderboard-item-bg) {
  position: relative;
  z-index: 1;
}

.leaderboard-item * {
  cursor: url('/static/cursor/select.cur'), pointer !important;
}

.leaderboard-item::after {
  content: '👤 View Profile';
  position: absolute;
  top: 10px;
  right: 10px;
  background: linear-gradient(135deg, rgba(124,58,237,0.9), rgba(109,40,217,0.9));
  color: #fff;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(124,58,237,0.3);
  z-index: 10;
}

.leaderboard-item:hover::after {
  opacity: 1;
  transform: scale(1.05);
}

.leaderboard-item.current-user::after {
  display: none;
}

.leaderboard-item:hover {
  transform: translateX(6px);
  box-shadow: 0 6px 20px rgba(124,58,237,0.2);
  border-color: rgba(124,58,237,0.35);
}

.leaderboard-item:hover .leaderboard-item-bg {
  opacity: 0.4;
}

.leaderboard-item.current-user {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(15,5,40,0.6));
  border-color: rgba(124,58,237,0.4);
  box-shadow: 0 0 16px rgba(124,58,237,0.15);
}

.leaderboard-item.top-1 {
  background: linear-gradient(135deg, rgba(251,191,36,0.12), rgba(15,5,40,0.6));
  border-color: rgba(251,191,36,0.35);
}

.leaderboard-item.top-2 {
  background: linear-gradient(135deg, rgba(192,192,192,0.1), rgba(15,5,40,0.6));
  border-color: rgba(192,192,192,0.3);
}

.leaderboard-item.top-3 {
  background: linear-gradient(135deg, rgba(205,127,50,0.1), rgba(15,5,40,0.6));
  border-color: rgba(205,127,50,0.3);
}

.leaderboard-item.has-vip {
  border: 3px solid rgba(251,191,36,0.6);
  background: linear-gradient(135deg, rgba(251,191,36,0.08), rgba(15,5,40,0.6));
  box-shadow: 0 0 20px rgba(251,191,36,0.2), inset 0 0 12px rgba(251,191,36,0.05);
}

.leaderboard-item.has-vip:hover {
  border-color: rgba(251,191,36,0.9);
  box-shadow: 0 0 32px rgba(251,191,36,0.4), inset 0 0 16px rgba(251,191,36,0.08);
}

.leaderboard-item.has-vip.gold {
  border: 3px solid rgba(234,179,8,0.8);
  background: linear-gradient(135deg, rgba(255,224,102,0.1), rgba(15,5,40,0.6));
  box-shadow: 0 0 24px rgba(234,179,8,0.3), inset 0 0 14px rgba(234,179,8,0.06);
  animation: vipGoldGlow 3s ease-in-out infinite;
}

.leaderboard-item.has-vip.gold:hover {
  border-color: rgba(255,224,102,1);
  box-shadow: 0 0 40px rgba(234,179,8,0.55), inset 0 0 20px rgba(234,179,8,0.1);
}

@keyframes vipGoldGlow {
  0%, 100% { box-shadow: 0 0 24px rgba(234,179,8,0.3), inset 0 0 14px rgba(234,179,8,0.06); }
  50% { box-shadow: 0 0 36px rgba(234,179,8,0.5), inset 0 0 18px rgba(234,179,8,0.1); }
}

.player-rank {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.rank-icon {
  font-size: 1.4rem;
}

.rank-number {
  font-size: 1rem;
  color: rgba(255,255,255,0.5);
  font-weight: bold;
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-name {
  font-size: 1.05rem;
  font-weight: 200;
  color: #e0d4ff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.vip-icon {
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 6px rgba(251,191,36,0.6));
  transition: transform 0.25s;
}

.vip-icon.gold {
  filter: drop-shadow(0 0 8px rgba(234,179,8,0.8));
  animation: vipGoldPulse 2s ease-in-out infinite;
}

@keyframes vipGoldPulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(234,179,8,0.8)); }
  50% { filter: drop-shadow(0 0 14px rgba(251,191,36,1)) drop-shadow(0 0 20px rgba(255,224,102,0.6)); }
}

.leaderboard-item:hover .vip-icon {
  transform: scale(1.15) rotate(-5deg);
}

.lb-rank-badge-right {
  width: 36px;
  height: 43px;
  flex-shrink: 0;
  margin-left: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.4));
  position: relative;
  z-index: 1;
}

.player-value {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  font-family: system-ui, sans-serif;
  font-weight: 400;
}

.player-stat-value {
  font-size: 0.85rem;
  color: #fbbf24;
  font-weight: bold;
}

.level-value::before { content: "Lv. "; color: #a78bfa; }
.streak-value::before { content: "🔥 "; }
.coins-value::before { content: "💰 "; }
.elo-value { color: #fbbf24; }
.elo-value::before { content: "🏆 "; }

.player-value.mode-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.player-value.mode-stats .mode-score {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e9d5ff;
  font-family: 'Lilita One', system-ui, sans-serif;
}
.player-value.mode-stats .mode-time {
  font-size: 0.82rem;
  color: #a78bfa;
  font-weight: 600;
}
.player-value.mode-stats .mode-games {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.3);
  font-weight: 400;
}

.you-indicator {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: bold;
  flex-shrink: 0;
}

.leaderboard-empty {
  text-align: center;
  padding: 28px;
  color: rgba(255,255,255,0.4);
  font-size: 1rem;
  font-style: italic;
  font-family: system-ui, sans-serif;
}

.back-button {
  position: absolute;
  top: 100px;
  left: 150px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  text-decoration: none;
  border-radius: 14px;
  font-family: 'Lilita One', cursive;
  font-size: 1.1rem;
  transition: transform 0.25s, box-shadow 0.25s;
  box-shadow: 0 4px 18px rgba(124,58,237,0.4);
  border: none;
  letter-spacing: 0.04em;
  cursor: url('/static/cursor/select.cur'), pointer !important;
  opacity: 0;
  animation: fadeUp 0.5s 0.1s ease-out forwards;
}

.back-button * {
  cursor: url('/static/cursor/select.cur'), pointer !important;
}

.back-button:hover {
  transform: scale(1.06) translateY(-2px);
  box-shadow: 0 6px 28px rgba(124,58,237,0.55);
}

.back-button svg,
.back-button span {
  pointer-events: none;
}

.back-button svg {
  width: 20px; height: 20px;
}

.profile-modal {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(10px);
  animation: profileFadeIn 0.3s ease;
}

.profile-modal.show { display: flex; }

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

.profile-modal-content {
  position: relative;
  width: 90%;
  max-width: 700px;
  animation: profileSlideIn 0.4s ease;
}

@keyframes profileSlideIn {
  from { transform: translateY(-50px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.profile-modal iframe {
  width: 700px; height: 480px;
  border: none;
  border-radius: 22px;
  background: rgba(15,5,40,0.95);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 30px rgba(124,58,237,0.2);
  display: block;
}

.profile-modal-close {
  position: absolute;
  top: -15px; right: -15px;
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: url('/static/cursor/select.cur'), pointer !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 10001;
  box-shadow: 0 4px 15px rgba(239,68,68,0.4);
}

.profile-modal-close:hover {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 6px 20px rgba(239,68,68,0.6);
}

footer {
  position: relative;
  z-index: 5;
  padding-bottom: 60px;
}

@media (max-width: 1100px) {
  .back-button { left: 10px; }
}

@media (max-width: 900px) {
  .back-button {
    top: 90px;
    left: 10px;
    padding: 10px 18px;
    font-size: 1rem;
  }
  .back-button svg { width: 18px; height: 18px; }
}

@media (max-width: 768px) {
  .leaderboard-page {
    padding: 160px 14px 70px;
  }
  .leaderboard-page-title {
    font-size: 2.2rem;
    margin-bottom: 6px;
  }
  .leaderboard-page-subtitle {
    font-size: 0.95rem;
    margin-bottom: 24px;
  }
  .leaderboard-card { padding: 22px 16px; }
  .leaderboard-card-title { font-size: 1.5rem; margin-bottom: 18px; }
  .leaderboard-item { padding: 12px 14px; gap: 10px; }
  .leaderboard-avatar { width: 40px; height: 40px; }
  .player-rank { width: 34px; height: 34px; }
  .rank-icon { font-size: 1.2rem; }
  .rank-number { font-size: 0.9rem; }
  .player-name { font-size: 0.95rem; }
  .category-btn { padding: 6px 14px; font-size: 0.8rem; min-width: 70px; }
  .leaderboard-item::after { font-size: 0.7rem; padding: 4px 10px; }

  .profile-modal-content { width: auto; max-width: 85vh; margin: 0 auto; transform: rotate(90deg) scale(0.7); transform-origin: center center; }
  .profile-modal iframe { width: 520px; height: 320px; border-radius: 12px; }
  .profile-modal-close { top: -15px; right: 50%; transform: translateX(50%); width: 32px; height: 32px; font-size: 1.2rem; }
}

@media (max-width: 480px) {
  .leaderboard-page {
    padding: 140px 10px 60px;
  }
  .leaderboard-page-title { font-size: 1.8rem; }
  .leaderboard-card { padding: 18px 12px; border-radius: 16px; }
  .leaderboard-avatar { width: 34px; height: 34px; }
  .leaderboard-item { padding: 10px 12px; gap: 8px; }

  .back-button {
    top: 62px;
    left: 8px;
    padding: 8px 14px;
    font-size: 0.9rem;
    gap: 6px;
  }
  .back-button svg { width: 16px; height: 16px; }
}
