/* ===== 愛心排行榜樣式 ===== */

.leaderboard-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.leaderboard-panel.show {
  opacity: 1;
  pointer-events: auto;
}

.leaderboard-content {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: slideIn 0.3s ease;
}

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

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  color: white;
}

.leaderboard-header h2 {
  margin: 0;
  font-size: 28px;
  font-weight: bold;
}

.leaderboard-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
}

.leaderboard-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(90deg);
}

.leaderboard-description {
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  margin-bottom: 20px;
}

.leaderboard-list {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  padding: 15px;
  margin-bottom: 20px;
}

.leaderboard-item {
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  margin-bottom: 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: all 0.3s ease;
  animation: fadeInUp 0.3s ease forwards;
  opacity: 0;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.leaderboard-item:hover {
  transform: translateX(5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.leaderboard-item:nth-child(1) {
  animation-delay: 0.05s;
  background: linear-gradient(135deg, #FFD700, #FFA500);
  color: #fff;
}

.leaderboard-item:nth-child(2) {
  animation-delay: 0.1s;
  background: linear-gradient(135deg, #C0C0C0, #A8A8A8);
  color: #333;
}

.leaderboard-item:nth-child(3) {
  animation-delay: 0.15s;
  background: linear-gradient(135deg, #CD7F32, #B87333);
  color: #fff;
}

.leaderboard-item:nth-child(n+4) {
  animation-delay: calc(0.2s + (var(--index) * 0.05s));
}

.rank-badge {
  font-size: 24px;
  font-weight: bold;
  min-width: 40px;
  text-align: center;
}

.user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.5);
}

.user-info {
  text-align: center;
  align-items: center;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.user-name {
  font-size: 18px;
  font-weight: bold;
}

.user-loves {
  font-size: 16px;
  opacity: 0.8;
}

.loading {
  text-align: center;
  color: white;
  padding: 20px;
  font-size: 18px;
}

.leaderboard-user-rank {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  padding: 20px;
  color: white;
  text-align: center;
}

.leaderboard-user-rank h3 {
  margin: 0 0 15px 0;
  font-size: 20px;
}

.user-rank-info {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  padding: 15px;
  border-radius: 10px;
}

.rank-number,
.rank-username,
.rank-loves {
  font-size: 18px;
  font-weight: bold;
}

/* 手機版適配 */
@media (max-width: 600px) {
  .leaderboard-content {
    padding: 20px;
    max-width: 95%;
  }

  .leaderboard-header h2 {
    font-size: 22px;
  }

  .leaderboard-item {
    padding: 10px;
    gap: 10px;
  }

  .user-avatar {
    width: 40px;
    height: 40px;
  }

  .user-name {
    font-size: 16px;
  }

  .user-loves {
    font-size: 14px;
  }

  .rank-badge {
    font-size: 20px;
    min-width: 30px;
  }
}

/* ===== 大頭貼樣式 ===== */
.player-avatar-container {
  position: relative;
  width: 40px;
  height: 40px;
  margin: 0 10px;
  flex-shrink: 0;
}

.player-avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.player-avatar:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.avatar-upload-btn {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 2px solid white;
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.avatar-upload-btn:hover {
  transform: scale(1.15);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

.avatar-upload-btn:active {
  transform: scale(0.95);
}

/* 當沒有大頭貼時的佔位符 */
.player-avatar-container:not(:has(.player-avatar)) {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.3);
}

/* 上傳訊息動畫 */
@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ===== 展開按鈕樣式 ===== */
.leaderboard-expand-btn {
  width: 90%;
  margin: 10px auto;
  padding: 10px 15px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: block;
}

.leaderboard-expand-btn:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.4) 0%, rgba(118, 75, 162, 0.4) 100%);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.leaderboard-expand-btn:active {
  transform: translateY(0);
}

/* ===== 標題點擊展開樣式 ===== */
.side-leaderboard-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
  position: relative;
  padding: 12px 15px;
}

.side-leaderboard-header:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.side-leaderboard-header h3 {
  margin: 0;
  font-size: 18px;
}

/* 展開提示文字 */
.expand-hint {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  transition: color 0.2s;
}

.side-leaderboard-header:hover .expand-hint {
  color: rgba(255, 255, 255, 0.9);
}

/* ===== 虛擬滾動容器樣式 ===== */
.clusterize-scroll {
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
}

.side-leaderboard.expanded .clusterize-scroll {
  max-height: 70vh;
}

.clusterize-content {
  /* 高度由 clusterize.js 自動管理 */
}

/* 優化滾動條樣式 */
.clusterize-scroll::-webkit-scrollbar {
  width: 8px;
}

.clusterize-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

.clusterize-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.clusterize-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== 月球模式：隱藏排行榜 ===== */
body.moon-mode .leaderboard-panel {
  display: none !important;
}
