/* stats.css — leaderboard page */

/* ── Ranking page tab strip ── */
.ranking-tab-row {
  position: relative;
  display: flex;
  max-width: 920px;
  margin: 0 auto 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  width: fit-content;
  gap: 0;
}
.ranking-tab-slider {
  position: absolute;
  top: 4px; bottom: 4px; left: 4px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue2), var(--blue));
  box-shadow: 0 2px 8px rgba(90,160,204,0.28);
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), width 0.22s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}
.ranking-tab-btn {
  position: relative; z-index: 1;
  padding: 8px 28px;
  border: none; background: none;
  border-radius: 10px;
  font-size: 13px; font-family: 'Noto Sans SC', sans-serif; font-weight: 500;
  color: var(--text3); cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
}
.ranking-tab-btn.active { color: #fff; }
.ranking-tab-btn:not(.active):hover { color: var(--blue2); }

/* ── My rank cards ── */
.my-rank-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 920px;
  margin: 0 auto 16px;
}
.my-rank-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 16px;
  text-align: center;
}
.my-rank-icon { font-size: 22px; margin-bottom: 6px; }
.my-rank-label { font-size: 11px; color: var(--text3); letter-spacing: .5px; margin-bottom: 6px; }
.my-rank-num {
  font-size: 22px; font-weight: 700;
  color: var(--blue2); margin-bottom: 4px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.my-rank-value { font-size: 11px; color: var(--text3); }

/* ── Rank trend arrows ── */
.rank-trend {
  font-size: 11px; font-weight: 600;
  padding: 1px 4px; border-radius: 4px; flex-shrink: 0;
}
.rank-trend-up   { color: var(--ok);     background: rgba(34,197,94,.12); }
.rank-trend-down { color: var(--danger); background: rgba(239,68,68,.10); }
.rank-trend-flat { color: var(--text3);  background: rgba(0,0,0,.06); }

/* ── Activity heatmap ── */
#myHeatmapCard {
  max-width: 920px; margin: 0 auto 16px;
}
/* Outer wrapper: scroll horizontally on small screens */
.activity-heatmap-wrap { overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px; }
/* Month labels row above the grid. Padding-left and label width match the
   day-axis (14) + body-gap (4) and cell-width (12) below so month labels
   sit directly above the corresponding week column. */
.heatmap-month-axis {
  display: flex; gap: 3px; padding-left: 18px; margin-bottom: 3px;
}
.heatmap-month-label {
  width: 12px; flex-shrink: 0;
  font-size: 10px; color: var(--text3); white-space: nowrap;
}
/* Body = day axis + grid side by side */
.heatmap-body { display: flex; gap: 4px; align-items: flex-start; }
/* Day labels column */
.heatmap-day-axis {
  display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; padding-top: 1px;
}
.heatmap-day-label {
  height: 12px; width: 14px;
  font-size: 9px; color: var(--text3);
  display: flex; align-items: center; justify-content: flex-end;
  line-height: 1;
}
/* Grid */
.heatmap-grid  { display: flex; gap: 3px; }
.heatmap-week  { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.heatmap-cell  { width: 12px; height: 12px; border-radius: 2px; background: rgba(var(--blue-rgb), 0.07); cursor: default; }
.heatmap-cell[data-level="-1"] { background: transparent; }
.heatmap-cell[data-level="1"]  { background: rgba(var(--blue-rgb), 0.25); }
.heatmap-cell[data-level="2"]  { background: rgba(var(--blue-rgb), 0.45); }
.heatmap-cell[data-level="3"]  { background: rgba(var(--blue-rgb), 0.65); }
.heatmap-cell[data-level="4"]  { background: var(--blue2); }
.heatmap-legend {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text3);
}
.heatmap-swatch {
  width: 10px; height: 10px; border-radius: 2px;
  background: rgba(var(--blue-rgb), 0.07);
}
.heatmap-swatch[data-level="1"] { background: rgba(var(--blue-rgb), 0.25); }
.heatmap-swatch[data-level="2"] { background: rgba(var(--blue-rgb), 0.45); }
.heatmap-swatch[data-level="3"] { background: rgba(var(--blue-rgb), 0.65); }
.heatmap-swatch[data-level="4"] { background: var(--blue2); }


/* ── /me page ── */
.me-auth-card {
  max-width: 420px;
  margin: 0 auto 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 28px 24px;
}
.me-auth-title { text-align: center; margin-bottom: 20px; }
.me-auth-title h2 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.me-auth-title p  { font-size: 12px; color: var(--text3); margin: 0; }

.me-profile-card, .me-section-card {
  max-width: 920px; margin: 0 auto 16px;
}
.my-rank-grid {
  max-width: 920px; margin: 0 auto 16px;
}
#meHeatmapCard { max-width: 920px; margin: 0 auto 16px; }

.me-profile {
  display: flex; align-items: center; gap: 16px;
}
.me-avatar { flex-shrink: 0; }
.me-avatar .avatar-frame-wrap { width: 56px; height: 56px; }
.me-avatar .avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.me-profile-info { display: flex; flex-direction: column; gap: 6px; }
.me-profile-name { font-size: 18px; font-weight: 600; color: var(--text); }
.me-profile-guard { display: inline-flex; }

.me-songs-summary { font-size: 13px; color: var(--text3); margin-bottom: 10px; }
.me-songs-summary b { color: var(--text); }
.me-songs-list { max-height: 280px; overflow-y: auto; margin-bottom: 10px; }
.me-songs-link {
  display: inline-block; font-size: 12px; color: var(--blue2);
  text-decoration: none; padding: 4px 0;
}
.me-songs-link:hover { text-decoration: underline; }

.me-pool-rank {
  font-size: 12px; font-weight: 600; color: var(--blue2);
  white-space: nowrap; flex-shrink: 0;
}

.me-sc-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: 600px; overflow-y: auto;
}
@media (max-width: 600px) {
  .me-sc-list { grid-template-columns: 1fr; }
}
.me-sc-item {
  border-radius: 6px; overflow: hidden;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.me-sc-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  background: rgba(0,0,0,.18);
  font-size: 12px;
}
.me-sc-price { font-weight: 700; }
.me-sc-time  { opacity: .85; }
.me-sc-body {
  padding: 10px 12px; font-size: 13px; line-height: 1.5;
  word-break: break-word; white-space: pre-wrap;
  min-height: 18px;
}
.me-sc-item[data-tier="0"] { background: #2a60b2; }
.me-sc-item[data-tier="1"] { background: #427d9e; }
.me-sc-item[data-tier="2"] { background: #e2b52b; }
.me-sc-item[data-tier="3"] { background: #e09443; }
.me-sc-item[data-tier="4"] { background: #e54d4d; }
.me-sc-item[data-tier="5"] { background: #e54d4d; }

/* ── SC 墙（公开） ── */
.sc-wall-meta { max-width: 920px; margin: 0 auto 12px; font-size: 12px; color: var(--text3); text-align: right; }
.sc-wall-list { max-width: 920px; margin: 0 auto; max-height: none; }
.sc-wall-pager {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  max-width: 920px; margin: 16px auto 0;
}
.sc-page-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 6px 16px;
  font-size: 13px; cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.sc-page-btn:hover:not([disabled]) { color: var(--blue2); border-color: var(--blue2); }
.sc-page-btn[disabled] { opacity: .4; cursor: not-allowed; }
.sc-page-info { font-size: 13px; color: var(--text3); }

@media (max-width: 600px) {
  .my-rank-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .my-rank-card { padding: 14px 10px; }
  .my-rank-num  { font-size: 18px; }
}

.stats-grid {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  /* Grid defaults to align-items: stretch, which makes every card in a row
     match the tallest card's height — so expanding one list visibly
     stretches the neighbouring cards' backgrounds. Keep each card's height
     to its own content. */
  align-items: start;
  gap: 16px;
  position: relative;
  z-index: 1;
}
.stats-grid + .stats-grid { margin-top: 16px; }

.stats-card {
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}
.stats-card h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 12px;
  letter-spacing: .5px;
}

.stats-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(var(--blue-rgb), 0.06);
  font-size: 13px;
}
.stats-row:last-child { border-bottom: none; }

.stats-row .rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  font-size: 11px; font-weight: 600;
  color: var(--text3);
  flex-shrink: 0;
}
.stats-row .rank.rank-medal { font-size: 18px; }

.stats-row .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(var(--blue-rgb), 0.1);
}

/* Guard frame wrapper — layout rules are global; only size is context-specific */
.avatar-frame-wrap {
  position: relative;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.avatar-frame-wrap .avatar {
  width: 72%; height: 72%;
  position: relative;
  z-index: 0;
}
.avatar-guard-frame {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  pointer-events: none;
  z-index: 1;
}
.stats-row .avatar-frame-wrap { width: 32px; height: 32px; }

.stats-row .name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  color: var(--text);
}

.stats-row .value {
  font-size: 12px;
  color: var(--blue2);
  font-weight: 500;
  white-space: nowrap;
}

.stats-row .guard {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
}
.stats-row .guard-3 { background: linear-gradient(135deg, var(--guard-3), #60a5fa); } /* 舰长 — 蓝 */
.stats-row .guard-2 { background: linear-gradient(135deg, var(--guard-2), #a78bfa); } /* 提督 — 紫 */
.stats-row .guard-1 { background: linear-gradient(135deg, var(--guard-1), #ef4444); } /* 总督 — 金→红 */

/* Collapsible list: show top 5, expand button reveals the rest */
.stats-list.collapsible { position: relative; }
.stats-list.collapsible.collapsed .stats-row:nth-child(n+6) { display: none; }
/* Always show the user's own injected row even when the list is collapsed. */
.stats-list.collapsible.collapsed .stats-row.my-rank-inject { display: flex; }
.stats-list.collapsible.collapsed::before {
  content: '';
  position: absolute;
  /* Extend past the card's 20px horizontal padding so the fade hits the
     card edges instead of stopping at the list's content box. */
  left: -20px; right: -20px;
  bottom: 30px;
  height: 48px;
  /* Fade into the page floor color so it reads right on both themes. */
  background: linear-gradient(to bottom, transparent, var(--sky));
  pointer-events: none;
  z-index: 1;
}
.stats-list .stats-expand {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 8px 6px;
  background: transparent;
  border: none;
  border-top: 1px solid rgba(var(--blue-rgb), 0.08);
  color: var(--blue2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.stats-list .stats-expand:hover { color: var(--text); }

.stats-loading, .stats-empty {
  text-align: center;
  color: var(--text3);
  font-size: 12px;
  padding: 20px 0;
}

/* Lottery stats: overall totals grid inside a card */
.lottery-overall-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.lottery-overall-grid .overall-cell {
  background: rgba(var(--blue-rgb), 0.06);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: center;
}
.lottery-overall-grid .overall-label {
  font-size: 11px;
  color: var(--text3);
  margin-bottom: 4px;
}
.lottery-overall-grid .overall-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--blue2);
}

.lottery-gift-icon {
  height: 20px;
  vertical-align: -4px;
  margin: 0 2px;
}

/* Odds page: section wrapper with a subdued header */
.odds-section {
  max-width: 920px;
  margin: 0 auto 32px;
}
.odds-section + .odds-section { margin-top: 8px; }
.odds-section .section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0 4px 6px;
  letter-spacing: .5px;
}
.odds-section .section-desc {
  font-size: 13px;
  color: var(--text3);
  margin: 0 4px 14px;
  line-height: 1.6;
}
.odds-section .stats-grid + .stats-grid { margin-top: 16px; }

/* Per-pool tab strip above the lottery stats. Hidden when only one pool
   is active — the strip has an empty innerHTML in that case. */
.odds-pool-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 4px 10px; }
.odds-pool-tabs:empty { display: none; }
.odds-pool-tab {
  background: var(--card);
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.odds-pool-tab:hover { color: var(--text); border-color: var(--border2); }
.odds-pool-tab.active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

/* Inline battery cost after each trigger gift name in the lottery intro. */
.lottery-gift-cost { color: var(--text3); font-size: 12px; margin-left: 4px; }

/* Blind-box card: show box icon + name in card header */
.stats-card h2 .odds-gift-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
  vertical-align: -4px;
  margin-right: 6px;
}
.stats-card h2 span.odds-gift-icon.odds-gift-icon-empty {
  display: inline-block;
}
.stats-card h2 .odds-box-total {
  float: right;
  font-size: 11px;
  color: var(--text3);
  font-weight: 400;
}
.stats-row .odds-gift-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}
.stats-row .odds-gift-icon-empty {
  display: inline-block;
  background: rgba(var(--blue-rgb), 0.1);
  border-radius: 4px;
}

.odds-box-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text3);
  margin: -4px 0 10px;
  line-height: 1.5;
}
.odds-pnl {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  color: #fff;
  vertical-align: 1px;
}
.odds-pnl-up   { background: var(--ok); }
.odds-pnl-down { background: var(--danger); }

/* ── My rank banner (above each leaderboard card) ── */
.my-rank-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: linear-gradient(135deg, rgba(var(--blue-rgb), 0.12), rgba(var(--blue-rgb), 0.06));
  border: 1px solid rgba(var(--blue-rgb), 0.25);
  border-radius: 10px;
  font-size: 13px;
  position: relative;
}
.my-rank-row::before {
  content: '我';
  position: absolute;
  right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 9px; letter-spacing: 1px;
  color: var(--blue2); opacity: 0.7;
  font-weight: 600;
}
.my-rank-row .name { color: var(--blue2); }

/* Personal stats card rows (odds page) */
.my-stats-label {
  font-size: 12px; color: var(--text3); min-width: 48px; flex-shrink: 0;
}
.my-stats-rank {
  font-size: 13px; font-weight: 600; color: var(--blue2); min-width: 36px; flex-shrink: 0;
}

/* User's row in the list — highlighted when found at its natural position */
.stats-row.my-rank-item {
  background: rgba(var(--blue-rgb), 0.06);
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
  margin: 0 -6px;
  border-bottom: none;
}

/* User's injected row appended when not in top-N — subtle top border to integrate */
.stats-row.my-rank-inject {
  background: rgba(var(--blue-rgb), 0.06);
  border-radius: 6px;
  padding-left: 6px;
  padding-right: 6px;
  margin: 4px -6px 0;
  border-top: 1px solid rgba(var(--blue-rgb), 0.12);
  border-bottom: none;
}
