/* ============================================================
   TopChess.org – Leaderboard page styles (redesigned)
   ============================================================ */

.leaderboard-page .main {
  min-height: 100vh;
}

/* ---- Layout ------------------------------------------------ */
.leaderboard-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
}

/* ---- Header ------------------------------------------------ */
.leaderboard-header {
  text-align: center;
  padding: 2.5rem 1.5rem 1.75rem;
}

.leaderboard-title {
  font-size: 2.25rem;
  font-weight: 900;
  color: var(--text-white);
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  letter-spacing: -0.5px;
}

.leaderboard-subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,.7);
  margin-bottom: 0;
}

/* ---- My Position Card -------------------------------------- */
.my-position-card {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  border-left: 4px solid var(--primary);
}

.my-position-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(0,76,153,.15);
}

.my-position-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #fff;
  flex-shrink: 0;
  font-weight: 700;
}

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

.my-position-name {
  font-weight: 700;
  color: var(--text-dark);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.my-position-rank {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.1rem;
}

.my-position-stats {
  text-align: right;
  flex-shrink: 0;
}

.my-position-number {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}

.my-position-percentile {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.15rem;
}

/* ---- Streak Widget ----------------------------------------- */
.streak-widget {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}

.streak-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}

.streak-widget-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dark);
}

.streak-widget-best {
  font-size: 0.78rem;
  color: var(--text-light);
  background: #f1f5f9;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
}

.streak-dots {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
}

.streak-dot-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
}

.streak-dot {
  width: 100%;
  aspect-ratio: 1;
  max-width: 40px;
  border-radius: var(--radius-sm);
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: #f8fafc;
  transition: var(--transition-fast);
}

.streak-dot.active {
  border-color: #22c55e;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
}

.streak-dot.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245,158,11,.2);
  animation: streak-pulse 2s ease-in-out infinite;
}

.streak-dot.today.active {
  border-color: #22c55e;
  box-shadow: none;
  animation: none;
}

.streak-dot-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

@keyframes streak-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(245,158,11,.3); }
  50% { box-shadow: 0 0 0 6px rgba(245,158,11,.05); }
}

/* ---- Login Prompt ------------------------------------------ */
.login-prompt {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  margin-bottom: 0.75rem;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
}

.login-prompt h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 0.35rem;
}

.login-prompt p {
  color: var(--text-light);
  margin-bottom: 1.1rem;
  font-size: 0.88rem;
}

.login-prompt .btn-login {
  display: inline-block;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  padding: 0.6rem 1.75rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  text-decoration: none;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(0,76,153,.35);
  transition: var(--transition-fast);
}

.login-prompt .btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,76,153,.45);
}

/* ---- Category Tabs ----------------------------------------- */
.leaderboard-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0 0 1rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.leaderboard-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.75);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  font-family: var(--font-family);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  scroll-snap-align: start;
  flex-shrink: 0;
}

.tab-btn:hover {
  background: rgba(255,255,255,.18);
  border-color: rgba(255,255,255,.3);
  color: #fff;
}

.tab-btn.active {
  background: #fff;
  color: var(--primary);
  border-color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.tab-icon {
  font-size: 1rem;
  line-height: 1;
}

/* Divider between tab groups */
.tab-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,.2);
  flex-shrink: 0;
  align-self: center;
  margin: 0 0.15rem;
}

/* ---- Podium ------------------------------------------------ */
.lb-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0 1rem;
  min-height: 180px;
}

.podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  flex: 1;
  max-width: 140px;
  cursor: default;
}

.podium-spot .podium-avatar-wrap {
  position: relative;
}

.podium-avatar {
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.podium-avatar-placeholder {
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  border: 3px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.podium-medal {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 1.3rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.25));
}

/* 1st place */
.podium-spot.p1 .podium-avatar,
.podium-spot.p1 .podium-avatar-placeholder {
  width: 72px;
  height: 72px;
  border-color: #f59e0b;
  font-size: 1.5rem;
}
.podium-spot.p1 .podium-medal { font-size: 1.5rem; }

/* 2nd place */
.podium-spot.p2 .podium-avatar,
.podium-spot.p2 .podium-avatar-placeholder {
  width: 58px;
  height: 58px;
  border-color: #94a3b8;
  font-size: 1.2rem;
}

/* 3rd place */
.podium-spot.p3 .podium-avatar,
.podium-spot.p3 .podium-avatar-placeholder {
  width: 54px;
  height: 54px;
  border-color: #cd7f32;
  font-size: 1.1rem;
}

.podium-name {
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  text-align: center;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,.4);
}

.podium-value {
  font-weight: 800;
  font-size: 0.9rem;
  color: rgba(255,255,255,.9);
  text-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.podium-spot.p1 .podium-name { font-size: 0.9rem; }
.podium-spot.p1 .podium-value { font-size: 1.05rem; color: #fbbf24; }
.podium-spot.p2 .podium-value { color: #cbd5e1; }
.podium-spot.p3 .podium-value { color: #d4956b; }

.podium-base {
  width: 100%;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: rgba(255,255,255,.5);
  font-size: 1.1rem;
}

.podium-spot.p1 .podium-base {
  height: 64px;
  background: linear-gradient(180deg, rgba(245,158,11,.35), rgba(245,158,11,.15));
}
.podium-spot.p2 .podium-base {
  height: 44px;
  background: linear-gradient(180deg, rgba(148,163,184,.3), rgba(148,163,184,.12));
}
.podium-spot.p3 .podium-base {
  height: 32px;
  background: linear-gradient(180deg, rgba(205,127,50,.3), rgba(205,127,50,.12));
}

/* ---- Leaderboard List -------------------------------------- */
.leaderboard-list {
  background: rgba(255,255,255,0.97);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.15);
}

/* Animate rows appearing */
.lb-row {
  display: grid;
  grid-template-columns: 2.25rem 2.5rem 1fr auto;
  align-items: center;
  padding: 0.8rem 1.1rem;
  gap: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s ease, transform 0.15s ease;
  animation: lb-row-in 0.3s ease both;
}

@keyframes lb-row-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.lb-row:last-child { border-bottom: none; }

.lb-row:hover {
  background: #f8fafc;
}

.lb-row.me {
  background: #eff6ff !important;
  border-left: 3px solid var(--primary);
  padding-left: calc(1.1rem - 3px);
}

/* Position column */
.lb-position {
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Avatar */
.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid #e2e8f0;
}

.lb-avatar-placeholder {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid transparent;
}

/* Name + rank */
.lb-info {
  min-width: 0;
}

.lb-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.lb-rank {
  font-size: 0.72rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 0.2rem;
  margin-top: 0.1rem;
}

/* Value column */
.lb-value-col {
  text-align: right;
  flex-shrink: 0;
}

.lb-value {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary);
  display: block;
  line-height: 1.2;
}

.lb-value-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  display: block;
  text-align: right;
  margin-top: 0.05rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Load More / Empty / Loading --------------------------- */
.lb-load-more {
  display: block;
  width: 100%;
  padding: 0.8rem;
  background: none;
  border: none;
  border-top: 1px solid #f1f5f9;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  font-family: var(--font-family);
  transition: var(--transition-fast);
}

.lb-load-more:hover {
  background: #f8fafc;
  color: var(--primary-dark);
}

.lb-empty {
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.95rem;
}

.lb-loading {
  padding: 3.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Skeleton loading -------------------------------------- */
.lb-skeleton {
  padding: 0.8rem 1.1rem;
  display: grid;
  grid-template-columns: 2.25rem 2.5rem 1fr 4rem;
  gap: 0.75rem;
  align-items: center;
  border-bottom: 1px solid #f1f5f9;
}

.skel-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s ease infinite;
}

.skel-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.2s ease infinite;
}

.skel-line.short { width: 60%; }
.skel-line.xs { width: 40px; height: 10px; }

@keyframes skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---- Responsive -------------------------------------------- */
@media (max-width: 600px) {
  .leaderboard-header { padding: 1.75rem 1rem 1.25rem; }
  .leaderboard-title { font-size: 1.75rem; }
  .leaderboard-container { padding: 0 0.75rem 3rem; }

  .leaderboard-tabs { gap: 0.3rem; padding-bottom: 0.75rem; }
  .tab-btn { padding: 0.4rem 0.7rem; font-size: 0.74rem; }
  .tab-icon { font-size: 0.85rem; }

  .lb-podium { gap: 0.35rem; min-height: 150px; padding: 0.25rem 0 0.75rem; }
  .podium-spot.p1 .podium-avatar,
  .podium-spot.p1 .podium-avatar-placeholder { width: 58px; height: 58px; }
  .podium-spot.p2 .podium-avatar,
  .podium-spot.p2 .podium-avatar-placeholder { width: 48px; height: 48px; }
  .podium-spot.p3 .podium-avatar,
  .podium-spot.p3 .podium-avatar-placeholder { width: 44px; height: 44px; }
  .podium-name { font-size: 0.75rem; }
  .podium-value { font-size: 0.8rem; }
  .podium-spot.p1 .podium-base { height: 50px; }
  .podium-spot.p2 .podium-base { height: 34px; }
  .podium-spot.p3 .podium-base { height: 24px; }

  .lb-row {
    grid-template-columns: 1.75rem 2rem 1fr auto;
    padding: 0.65rem 0.9rem;
    gap: 0.55rem;
  }

  .lb-avatar, .lb-avatar-placeholder { width: 30px; height: 30px; font-size: 0.8rem; }
  .lb-name { font-size: 0.82rem; }
  .lb-rank { font-size: 0.67rem; }
  .lb-value { font-size: 0.95rem; }
  .lb-position { font-size: 0.8rem; }

  .my-position-card,
  .streak-widget { padding: 0.85rem 1rem; }
  .my-position-avatar,
  .my-position-avatar-placeholder { width: 38px; height: 38px; }
  .my-position-number { font-size: 1.4rem; }

  .streak-dots { gap: 0.3rem; }
  .streak-dot { border-radius: 6px; }
  .streak-dot-label { font-size: 0.55rem; }
}

@media (max-width: 380px) {
  .tab-btn { padding: 0.35rem 0.55rem; font-size: 0.7rem; }
  .leaderboard-title { font-size: 1.5rem; }
}
