/**
 * 热门排行榜页面样式
 * 九宫格布局 + 滚动条 + 战力显示
 */

/* 页面容器 */
.ranking-page {
  max-width: 500px;
  margin: 0 auto;
  padding: 0;
}

/* 加载状态 */
.ranking-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
}

.ranking-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.ranking-loading-text {
  margin-top: 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 错误状态 */
.ranking-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  text-align: center;
}

.ranking-error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.ranking-error-text {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 20px;
}

.ranking-retry-btn {
  padding: 10px 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 20px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

/* 顶部信息区 */
.ranking-header {
  text-align: center;
  margin-bottom: 20px;
}

.ranking-my-power {
  font-size: 20px;
  margin-bottom: 8px;
}

.power-label {
  color: rgba(255, 255, 255, 0.8);
}

.power-value {
  font-size: 32px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* 滚动条 */
.ranking-scroll-bar {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 12px 16px;
  margin-bottom: 24px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scroll-content {
  font-size: 13px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

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

.scroll-nickname {
  color: #ffd700;
  font-weight: bold;
}

.scroll-text {
  color: rgba(255, 255, 255, 0.7);
  margin: 0 4px;
}

.scroll-ranking {
  color: #4fc3f7;
}

.scroll-score {
  color: #ff7043;
  font-weight: bold;
  font-size: 15px;
}

.scroll-empty {
  color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   列表样式（V2）
   ============================================ */

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.list-item {
  display: flex;
  background: linear-gradient(135deg, rgba(88, 86, 138, 0.9) 0%, rgba(61, 55, 102, 0.9) 100%);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.list-item:active {
  transform: scale(0.98);
}

.list-item:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.list-item-left {
  width: 130px;
  min-height: 140px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.list-item-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-item-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  background: rgba(255, 255, 255, 0.1);
}

.list-item-right {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.list-item-label {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 24px;
  width: auto;
}

.list-item-name {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 8px;
}

.list-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.list-item-avatars {
  display: flex;
  align-items: center;
}

.list-item-avatars .avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
  margin-left: -8px;
}

.list-item-avatars .avatar-img:first-child {
  margin-left: 0;
}

.list-item-avatars .avatar-count {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  margin-left: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 10px;
}

.list-item-count {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

.list-item-count strong {
  color: #fff;
}

.list-item-btn {
  display: inline-block;
  padding: 8px 24px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  max-width: 120px;
}

.list-item-btn.participated {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}

.list-item-btn.not-participated {
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ============================================
   九宫格样式（保留）
   ============================================ */

/* 九宫格 */
.ranking-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.grid-item {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.grid-item:active {
  transform: scale(0.95);
}

.grid-item.participated {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
  border-color: rgba(102, 126, 234, 0.5);
}

.grid-item.not-participated {
  background: rgba(128, 128, 128, 0.2);
  opacity: 0.7;
}

.grid-item-icon {
  font-size: 32px;
  margin-bottom: 8px;
  /* 背景色由 JS 通过 inline style 动态设置 */
}

.grid-item-icon-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.grid-item-name {
  font-size: 12px;
  font-weight: 500;
  /* 文字颜色由 JS 通过 inline style 动态设置 */
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.grid-item-status {
  font-size: 11px;
}

.status-score {
  /* 颜色由 JS 通过 inline style 动态设置 */
  font-weight: bold;
}

.status-text {
  /* 颜色由 JS 通过 inline style 动态设置 */
}

/* 预览弹窗 */
.ranking-preview-overlay,
.ranking-loading-overlay,
.ranking-result-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.ranking-preview-modal,
.ranking-result-modal {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 20px;
  padding: 30px 24px;
  width: 85%;
  max-width: 320px;
  text-align: center;
  position: relative;
  animation: slideUp 0.3s ease;
}

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

.preview-close-btn,
.result-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-icon,
.result-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.preview-name,
.result-name {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 8px;
}

.preview-desc {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 12px;
  line-height: 1.5;
}

.preview-participants {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 20px;
}

.preview-start-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 25px;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
}

/* Loading弹窗 */
.ranking-loading-content {
  text-align: center;
}

.loading-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.loading-text {
  font-size: 18px;
  color: #fff;
  margin-bottom: 8px;
}

.loading-subtext {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

/* 结果弹窗 */
.result-score {
  margin: 16px 0;
}

.score-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.score-value {
  font-size: 36px;
  font-weight: bold;
  color: #ffd700;
}

.result-rank {
  margin-bottom: 8px;
}

.rank-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.rank-value {
  font-size: 18px;
  color: #4fc3f7;
  font-weight: bold;
}

.result-beat {
  font-size: 14px;
  color: #81c784;
  margin-bottom: 8px;
}

.result-total {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 20px;
}

.result-back-btn {
  width: 100%;
  padding: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 25px;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}

/* ============================================
   等级说明表格样式
   ============================================ */

.ranking-levels-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  text-align: left;
}

.levels-section-title {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  margin-bottom: 16px;
  text-align: center;
}

.levels-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.levels-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.levels-table thead th {
  background: rgba(102, 126, 234, 0.3);
  color: rgba(255, 255, 255, 0.9);
  padding: 10px 6px;
  text-align: center;
  font-weight: 500;
  position: sticky;
  top: 0;
}

.levels-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.levels-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.levels-table tbody tr.current {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.levels-table tbody td {
  padding: 10px 6px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  vertical-align: middle;
}

.levels-table .level-col {
  font-weight: bold;
  color: #4fc3f7;
  width: 40px;
}

.levels-table .icon-col {
  font-size: 16px;
  width: 36px;
}

.levels-table .title-col {
  font-weight: 500;
  color: #ffd700;
  min-width: 80px;
}

.levels-table .skill-col {
  color: rgba(255, 255, 255, 0.7);
  text-align: left;
  font-size: 11px;
  min-width: 100px;
}

/* ============================================
   分数明细表格样式（内测）
   ============================================ */

.ranking-details-section {
  background: rgba(255, 100, 100, 0.1);
  border: 1px dashed rgba(255, 100, 100, 0.3);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  text-align: left;
}

.details-section-title {
  font-size: 14px;
  font-weight: bold;
  color: #ff7043;
  margin-bottom: 16px;
  text-align: center;
}

.details-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.details-table thead th {
  background: rgba(255, 112, 67, 0.2);
  color: rgba(255, 255, 255, 0.9);
  padding: 8px 6px;
  text-align: center;
  font-weight: 500;
}

.details-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.details-table tbody td {
  padding: 8px 6px;
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
}

.details-table tbody td.contribution {
  font-weight: bold;
  color: #81c784;
}

/* V2新增：特殊规则明细行样式 */
.details-table tbody tr.rule-row {
  background: rgba(255, 215, 0, 0.08);
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

.details-table tbody td.rule-name {
  text-align: left;
  color: #ffd700;
  font-style: italic;
}

.details-table tbody td.contribution.positive {
  color: #81c784;  /* 正分绿色 */
}

.details-table tbody td.contribution.negative {
  color: #ef5350;  /* 负分红色 */
}

/* V2新增：加分汇总显示 */
.details-bonus-summary {
  background: rgba(255, 215, 0, 0.15);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  text-align: center;
  color: #ffd700;
  font-size: 13px;
  font-weight: 500;
}

/* ============================================
   结果页 V2 样式
   ============================================ */

.ranking-result-page-v2 {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  z-index: 10000;
  overflow-y: auto;
  animation: fadeIn 0.3s ease;
}

.result-v2-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  position: sticky;
  top: 0;
  background: rgba(26, 26, 46, 0.95);
  z-index: 10;
}

.result-v2-back {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.result-v2-back .back-arrow {
  font-size: 28px;
  color: #fff;
  font-weight: 300;
}

.result-v2-title {
  font-size: 18px;
  font-weight: bold;
  color: #fff;
}

.result-v2-placeholder {
  width: 40px;
}

.result-v2-content {
  padding: 20px;
}

/* 主卡片 - 正方形 300x300 */
.result-v2-card {
  width: 300px;
  height: 300px;
  border-radius: 20px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
  background-color: rgba(88, 86, 138, 0.5);
  margin: 0 auto 20px;
  position: relative;
}

.result-v2-card-overlay {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.3) 50%, rgba(0,0,0,0.7) 100%);
  padding: 100px 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  text-align: center;
  box-sizing: border-box;
}

.result-v2-rank-number {
  font-size: 48px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  margin-bottom: 4px;
}

.result-v2-rank-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 16px;
}

.result-v2-beat {
  font-size: 16px;
  color: #f8bbd9;
  font-weight: 500;
  margin-bottom: 8px;
}

.result-v2-total {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}

/* 邀请按钮 */
.result-v2-invite-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 30px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  margin-bottom: 20px;
  transition: transform 0.2s ease;
}

.result-v2-invite-btn:active {
  transform: scale(0.98);
}

/* 底部分数条 */
.result-v2-score-bar {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 20px;
  gap: 12px;
}

.score-bar-icon {
  font-size: 32px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px;
}

.score-bar-score {
  font-size: 24px;
  font-weight: bold;
  color: #fff;
}

.score-bar-level {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.score-bar-level .level-tag {
  background: rgba(102, 126, 234, 0.3);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  color: #a8b4f0;
}

.score-bar-level .level-icon {
  font-size: 16px;
}

.score-bar-level .level-title {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

/* 返回按钮 */
.result-v2-back-btn {
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 25px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
}
