/* =========================================================
   Mysscallitos Leaderboard — Estética Retro 70s Twilight
   Paleta extraída de leaderboard_canvas.py
   ========================================================= */

:root {
  --page-bg:    #1C1B1A;
  --card-bg:    #3A342A;   /* borde exterior */
  --card-inner: #302B23;   /* interior */
  --text-dark:  #EEE0C8;   /* crema luminosa */
  --text-mid:   #AA9B80;   /* arena media */
  --accent:     #DA9B3C;   /* ámbar cálido */
  --bar-bg:     #483D34;   /* barra vacía */
  --default-color: #80766450; /* tint sin rol */

  /* Rank badges */
  --rank1-bg: #69520C; --rank1-fg: #F8D250;
  --rank2-bg: #373A4E; --rank2-fg: #C3C6E4;
  --rank3-bg: #583712; --rank3-fg: #E19B50;
  --rankN-bg: #3E382D; --rankN-fg: #B6A891;

  /* Top-1 badges */
  --t1global-bg: #5F4808;  --t1global-fg: #FFDA50;
  --t1bumper-bg: #127878;  --t1bumper-fg: #B9FFFF;
  --t1monthly-bg: #703008; --t1monthly-fg: #FFA841;
  --t1weekly-bg:  #765808; --t1weekly-fg:  #FFCD32;
  --t1daily-bg:   #80260C; --t1daily-fg:   #FF8046;

  --radius: 14px;
  --radius-inner: 10px;
  --border-w: 5px;
  --font: 'Noto Sans', 'DejaVu Sans', Arial, sans-serif;
}

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

body {
  background: var(--page-bg);
  color: var(--text-dark);
  font-family: var(--font);
  min-height: 100vh;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* ── Header ─────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.site-title {
  font-size: 1.20rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(218,155,60,0.35);
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-title-box {
  display: inline-block;
  padding: 3px 10px;
  background: rgba(218,155,60,0.10);
  border: 1.5px solid rgba(218,155,60,0.30);
  border-radius: 6px;
}

.site-title-comfy-wrap {
  position: relative;
  cursor: pointer;
  transition: opacity 0.2s;
}

.site-title-comfy-wrap:hover {
  opacity: 0.85;
}

.site-title-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  border-radius: 6px;
}

.site-title-sub {
  font-weight: 700;
  color: var(--accent);
}

.search-wrap {
  flex: 1;
  min-width: 180px;
  max-width: 280px;
}

.search-input {
  width: 100%;
  background: var(--card-inner);
  border: 1.5px solid var(--card-bg);
  border-radius: 8px;
  color: var(--text-dark);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input::placeholder { color: var(--text-mid); }
.search-input:focus { border-color: var(--accent); }

/* ── Period tabs — segmented toggle pill ────────────────────── */

.period-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

/* Wrapper que agrupa los botones como un control segmentado */
.period-toggle-wrap {
  display: inline-flex;
  background: var(--card-inner);
  border: 1.5px solid var(--card-bg);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.tab {
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--text-mid);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 16px;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text-dark); }
.tab.active {
  background: var(--card-bg);
  color: var(--accent);
}

.btn-period-refresh {
  margin-left: auto;
  background: var(--card-inner);
  border: 1.5px solid var(--card-bg);
  border-radius: 7px;
  color: var(--text-mid);
  cursor: pointer;
  font-family: var(--font);
  font-size: 1.05rem;
  line-height: 1;
  padding: 5px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.btn-period-refresh:hover { color: var(--text-dark); border-color: var(--accent); }
.refresh-icon {
  display: inline-block;
  width: 1.15em;
  height: 1.15em;
  vertical-align: middle;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.btn-period-refresh:hover .refresh-icon { opacity: 0.9; }
@keyframes spin-refresh-ccw { from { transform: rotate(0deg); } to { transform: rotate(-360deg); } }
.refresh-icon.spinning { animation: spin-refresh-ccw 0.55s linear; }

/* ── Loading / empty ─────────────────────────────────────── */

.loading, .empty {
  text-align: center;
  color: var(--text-mid);
  padding: 48px 0;
  font-size: 0.9rem;
}

/* ── Leaderboard list ────────────────────────────────────── */

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* ── Card (replica 3-capa del canvas) ───────────────────────────── */

.card {
  border-radius: var(--radius);
  padding: var(--border-w);
  /* gradient border — se sobreescribe desde JS con role colors */
  background: linear-gradient(135deg, var(--card-bg), var(--card-bg));
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.12s, filter 0.12s;
}

/* Usuarios fuera del servidor — overlay oscuro sutil (replica not_in_server del canvas) */
.card.not-in-server .card-inner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(15, 12, 8, 0.35);
  border-radius: var(--radius-inner);
  pointer-events: none;
  z-index: 2;
}

/* Etiqueta "Fuera del servidor" */
.card-not-in-server-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  color: var(--text-mid);
  text-align: right;
  opacity: 0.70;
  margin-top: 2px;
  text-transform: uppercase;
}

.card-inner {
  background: var(--card-inner);
  background-size: cover;
  background-position: center;
  border-radius: var(--radius-inner);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px 9px 9px;
  position: relative;
  overflow: hidden;
  opacity: 1;
  /* Unhover: espera a que la tarjeta termine de encogerse (0.18s) para reaparecer suavemente */
  transition: opacity 0.15s ease 0.18s, background-color 0.18s, padding 0.18s ease;
}
.card.expanded .card-inner {
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  /* Hover: desaparece súper rápido para revelar el gradiente del borde */
  transition: opacity 0.1s ease 0s, padding 0.18s ease 0s;
}

/* Capa 3: tint sutil del color de rol */
.card-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius-inner);
  /* color se asigna desde JS */
}

/* ── Podio top-3 ─────────────────────────────────────────── */

.podium-slots {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
  padding-top: 64px; /* espacio para la corona que flota sobre el top 1 */
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex: 1;
  max-width: 230px;
  cursor: pointer;
}


.podium-card {
  border-radius: var(--radius);
  padding: var(--border-w);
  transition: transform 0.12s, filter 0.12s;
  position: relative;
  z-index: 1;
}
.podium-slot:hover .podium-card {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.podium-card-inner {
  background: var(--card-inner);
  background-size: cover;
  background-position: center;
  border-radius: var(--radius-inner);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px 8px;
  position: relative;
  overflow: hidden;
  gap: 3px;
  text-align: center;
}

.podium-medal {
  font-size: 1.35rem;
  line-height: 1;
  z-index: 1;
}

/* Corona flotante sobre la tarjeta del #1 */
@keyframes crown-glow {
  0%, 100% {
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.55))
            drop-shadow(0 0 6px rgba(248,210,80,0.25));
  }
  50% {
    filter: drop-shadow(0 3px 8px rgba(0,0,0,0.55))
            drop-shadow(0 0 18px rgba(248,210,80,0.85))
            drop-shadow(0 0 32px rgba(218,155,60,0.5));
  }
}

.podium-crown-float {
  align-self: center;
  margin-bottom: 3px; /* más cerca de la tarjeta → corona más baja */
  position: relative;
  z-index: 3;
  pointer-events: none;
}
.podium-crown-float .podium-crown-img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  display: block;
  animation: crown-glow 2.4s ease-in-out infinite;
}

.podium-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card-bg);
  z-index: 1;
  flex-shrink: 0;
}

.podium-name {
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  z-index: 1;
}

.podium-level {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  z-index: 1;
}

.podium-streak {
  z-index: 1;
}
.podium-streak img {
  width: 10px;
  height: 12px;
}

.podium-base {
  border-radius: 0 0 10px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  width: 100%;
  margin-top: -20px;
  padding-top: 20px;
}
.podium-base-1st {
  height: 140px;
  background: linear-gradient(180deg, #69520C, #2A1800);
  color: #F8D250;
}
.podium-base-2nd {
  height: 95px;
  background: linear-gradient(180deg, #373A4E, #1A1C2E);
  color: #C3C6E4;
}
.podium-base-3rd {
  height: 62px;
  background: linear-gradient(180deg, #583712, #2A1200);
  color: #E19B50;
}

/* ── Card transform — compact se desvanece, perfil flota encima ── */

/*
 * Al hacer clic o hover, .card.expanded / .card:hover:
 *   1. .card-compact-wrap colapsa (max-height: 0) y se desvanece.
 *   2. .card-profile-expand crece (max-height: 500px) y aparece.
 *   La tarjeta CAMBIA de tamaño físico en el DOM, empujando a las demás hacia abajo.
 */

.card.expanded {
  z-index: 2;
}

/* 
 * FIX FLICKER: Opción 1 (Puente de Pointer Events).
 * Durante la fase de contracción, la tarjeta se vuelve físicamente muy pequeña.
 * Este pseudo-elemento invisible ancla y mantiene el tamaño original de la tarjeta
 * para que el ratón no se "escape" y triggeree un mouseleave falso.
 */
.card.expanded::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 150px; /* Mantiene un área de hover constante durante el aplastamiento */
  z-index: 0;
}

/* Wrapper compacto: colapsa al expandir */
.card-compact-wrap {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  opacity: 1;
  min-height: 0;
  /* Unhover: crece inmediatamente en altura, PERO permanece invisible (opacity delay 0.18s) para dejar ver el gradiente */
  transition: grid-template-rows 0.18s ease 0s, opacity 0.1s ease 0.18s;
}
.card.expanded .card-compact-wrap {
  opacity: 0;
  pointer-events: none;
  grid-template-rows: 0fr;
  /* Hover: se encoge al mismo tiempo que el perfil crece, para no perder altura física */
  transition: grid-template-rows 0.18s ease 0s, opacity 0.1s ease 0s;
}
.card-compact-wrap > .card-inner {
  min-height: 0;
}

/* Sección expandida: en el flujo normal, invisible por defecto */
.card-profile-expand {
  display: grid;
  grid-template-rows: 0fr;
  z-index: 10;
  border-radius: var(--radius-inner);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  min-height: 0;
  /* Unhover: se colapsa inmediatamente (0.18s de duración) ocultando el perfil expandido */
  transition: grid-template-rows 0.18s ease 0s, opacity 0.12s ease 0s;
}
.card.expanded .card-profile-expand {
  opacity: 1;
  pointer-events: auto;
  grid-template-rows: 1fr;
  /* Hover: crece inmediatamente y a la par para garantizar que siempre aumente de tamaño */
  transition: grid-template-rows 0.18s ease 0s, opacity 0.12s ease 0.06s;
}

/* profile-inner: aparece dentro del contenedor al expandirse */
.card-profile-expand .profile-inner {
  min-height: 0;
  opacity: 0;
  margin-top: 0;
  /* Unhover: desaparece rápido convirtiendo la tarjeta en un bloque de gradiente */
  transition: opacity 0.08s ease 0s;
}
.card.expanded .card-profile-expand .profile-inner {
  opacity: 1;
  /* Hover: aparece suavemente mientras el bloque ya está creciendo */
  transition: opacity 0.15s ease 0.09s;
}

/* Botón cerrar dentro del perfil expandido */
.card-expand-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: none;
  border-radius: 50%;
  color: var(--text-mid);
  cursor: pointer;
  font-size: 0.85rem;
  height: 26px;
  width: 26px;
  display: none; /* oculto por defecto; solo visible en dispositivos sin hover */
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: color 0.15s;
}
.card-expand-close:hover { color: var(--text-dark); }

/* El botón ✕ en móvil solo se muestra en Mi Nivel (no en las tarjetas del ranking) */


/* ── Sección Mi Nivel ────────────────────────────────────── */

.my-level-section {
  margin-bottom: 20px;
  background: var(--card-inner);
  border: 1.5px solid var(--card-bg);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
}

.my-level-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.my-level-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-mid);
  white-space: nowrap;
}

.my-level-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}

.my-level-clear-btn {
  background: none;
  border: none;
  color: var(--text-mid);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  transition: color 0.15s;
}
.my-level-clear-btn:hover { color: var(--text-dark); }

.search-history-drop {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--card-inner);
  border: 1.5px solid var(--card-bg);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.search-history-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-mid);
  border-bottom: 1px solid var(--card-bg);
}

.search-history-clear-btn {
  background: none;
  border: none;
  color: var(--text-mid);
  cursor: pointer;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s;
  font-family: var(--font);
}
.search-history-clear-btn:hover { color: var(--text-dark); }

.search-history-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
}

.search-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-dark);
  transition: background 0.1s;
}
.search-history-item:hover { background: rgba(255,255,255,0.04); }
.search-history-item .hist-icon { color: var(--text-mid); font-size: 0.72rem; flex-shrink: 0; }


/* ── Separador de sección ─────────────────────────────────── */

.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
  font-size: 0.70rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--text-mid);
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--card-bg);
}
.section-divider span {
  color: var(--accent);
  padding: 0 2px;
}

#streak-roles-section {
  margin-block-start: 28px;
}

/* ── Badge de ranking (#1, #2, #3, …) ───────────────────── */

.rank-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 800;
  min-width: 44px;
  padding: 5px 8px;
  flex-shrink: 0;
  z-index: 1;
  letter-spacing: 0.05em;
}

/* Badge más grande en tarjeta expandida (perfil) */
.profile-row1 .rank-badge {
  font-size: 1.1rem;
  min-width: 54px;
  padding: 7px 11px;
  border-radius: 8px;
}

/* ── Avatar ──────────────────────────────────────────────────────── */

/* Capa de sombra que oscurece el BG cuando hay imagen */
.card-bg-shadow {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-inner);
  background: rgba(20, 17, 12, 0.55);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 0;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  z-index: 1;
  background: var(--card-bg);
}

/* ── Card body (columna principal derecha del avatar) ─────────────── */

.card-body {
  flex: 1;
  min-width: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Fila 1: [badge] [@usuario] ··· [streak] [Nivel X] */
.card-row1 {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Derecha de la fila 1 — streak + nivel, margen auto hacia la derecha */
.card-row1-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.card-username {
  font-size: 0.90rem;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  z-index: 1;
}

.card-level {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Fila 2: XP total alineado a la derecha */
.card-xp-row {
  display: flex;
  justify-content: flex-end;
}

.card-xp {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-mid);
  white-space: nowrap;
}

/* ── Top-1 badges inline ─────────────────────────────────── */

.top1-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 5px;
}

.top1-badge {
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
}

/* ── Progress bar ──────────────────────────────────────────────── */

.bar-wrap {
  position: relative;
  background: var(--bar-bg);
  border-radius: 99px;
  height: 14px;
  overflow: hidden;
  margin-top: 2px;
}

.bar-fill {
  height: 100%;
  border-radius: 99px;
  /* background se asigna desde JS con role color gradient */
  background: var(--accent);
  transition: width 0.4s ease;
}

/* Texto debajo de la barra (estilo canvas compacto) — color asignado desde JS */
.bar-subtext {
  font-size: 0.65rem;
  color: var(--text-mid); /* fallback; JS sobrescribe con lvlColor */
  font-weight: 600;
  margin-top: 1px;
}

.streak-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #FDA234;
  font-weight: 700;
  font-size: 0.80rem;
  flex-shrink: 0;
}

.streak-wrap img {
  width: 11px;
  height: 14px;
  object-fit: contain;
}

/* ── Search result wrap ──────────────────────────────────── */

.search-result-wrap {
  margin-bottom: 18px;
}
.search-result-wrap.hidden { display: none; }

.profile-inner {
  background: var(--card-inner);
  background-size: cover;
  background-position: center;
  border-radius: var(--radius-inner);
  position: relative;
  overflow: hidden;
  transition: background-color 0.3s;
}

.profile-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: var(--radius-inner);
}

.profile-body {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  position: relative;
  z-index: 1;
  padding: 18px 20px;
}

/* Columna izquierda: avatar + badges de top1 */
.profile-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.profile-avatar {
  width: 95px;
  height: 95px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--card-bg);
  display: block;
}

/* Top1 badges verticales bajo el avatar */
.profile-left .top1-badges {
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 3px;
}
.profile-left .top1-badge {
  display: block;
  text-align: center;
  width: 100%;
  font-size: 0.58rem;
}

/* Columna derecha: datos del perfil */
.profile-details { flex: 1; min-width: 0; }

/* Fila 1: badge + @nombre ··· streak + nivel */
.profile-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.profile-row1-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}


.profile-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.profile-level {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
}

.profile-stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.60rem;
  font-weight: 700;
  color: var(--text-mid);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
}

.stat-value-sm {
  font-size: 0.82rem;
}

/* Barra del perfil — alta (26px) con texto inside como el bot */
.profile-bar-wrap {
  background: var(--bar-bg);
  border-radius: 99px;
  height: 26px;
  overflow: hidden;
  position: relative;
}

.profile-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.5s ease;
}

/* Textos superpuestos dentro de la barra — color asignado desde JS con lvlColor */
.profile-bar-side {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dark); /* fallback; JS sobrescribe con lvlColor */
  pointer-events: none;
}
.profile-bar-left   { left: 10px; }
.profile-bar-right  { right: 10px; }
.profile-bar-center {
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ── Última actividad en card ────────────────────────────── */

.card-last-active {
  font-size: 0.60rem;
  color: var(--text-mid);
  font-weight: 600;
  text-align: right;
  opacity: 0.75;
  margin-top: 1px;
}

/* ── Título dinámico de leaderboard ─────────────────────── */

.lb-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(218,155,60,0.45);
  margin: 12px 0 14px;
  text-transform: uppercase;
}

/* ── Cargar más ──────────────────────────────────────────── */

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

.load-more-btn {
  background: var(--card-inner);
  border: 1.5px solid var(--card-bg);
  border-radius: 8px;
  color: var(--text-mid);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 9px 36px;
  transition: color 0.15s, border-color 0.15s;
}
.load-more-btn:not(:disabled):hover { color: var(--text-dark); border-color: var(--accent); }
.load-more-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Modal de podio ──────────────────────────────────────── */

.podium-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.podium-modal.open { display: flex; }

.podium-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 12, 8, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: modal-overlay-in 0.22s ease both;
}
.podium-modal.closing .podium-modal-overlay {
  animation: modal-overlay-out 0.15s ease both;
}

.podium-modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  border-radius: var(--radius);
  padding: var(--border-w);
  background: linear-gradient(135deg, var(--card-bg), var(--card-bg));
  overflow: hidden;
  animation: modal-in 0.22s ease both;
}
.podium-modal.closing .podium-modal-card {
  animation: modal-out 0.15s ease both;
}

@keyframes modal-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-overlay-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.93) translateY(14px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}
@keyframes modal-out {
  from { opacity: 1; transform: scale(1)    translateY(0); }
  to   { opacity: 0; transform: scale(0.93) translateY(14px); }
}


/* ── Navegación entre páginas ────────────────────────────── */

.page-nav {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--card-bg);
}

.page-nav-btn {
  background: transparent;
  border: none;
  color: var(--text-mid);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 8px 4px 10px;
  text-decoration: none;
  display: inline-block;
  position: relative;
  transition: color 0.15s;
}

.page-nav-btn::after {
  content: '';
  position: absolute;
  bottom: -2px; /* Superpone sobre el border-bottom de .page-nav */
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform 0.2s ease;
}

.page-nav-btn:hover {
  color: var(--text-dark);
}

.page-nav-btn.active {
  color: var(--accent);
}

.page-nav-btn.active::after {
  transform: scaleX(1);
}

/* ── Roles de nivel / racha ──────────────────────────────── */

.level-roles-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}

.level-role-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  background: var(--card-inner);
  border: 1.5px solid var(--card-bg);
  border-radius: var(--radius-inner);
  padding: 9px 14px 8px;
  transition: border-color 0.15s;
}
.level-role-item.unlocked { border-color: rgba(218,155,60,0.30); }
.level-role-item.active   { border-color: var(--accent); box-shadow: 0 0 10px rgba(218,155,60,0.15); }
.level-role-item.locked   { opacity: 0.55; }

/* Icono: círculo de color con gradiente del rol */
.role-icon-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.level-role-badge {
  border-radius: 5px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 9px;
  white-space: nowrap;
}

.level-role-threshold {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-mid);
  white-space: nowrap;
}

.level-role-status {
  margin-left: auto;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-mid);
  white-space: nowrap;
  text-align: right;
}
.level-role-status.active-status { color: var(--accent); }

/* Barra de progreso (segunda fila, ancho completo) */
.role-progress-row {
  flex: 0 0 100%;
  display: flex;
  align-items: center;
  gap: 7px;
}

.role-progress-bar {
  flex: 1;
  height: 5px;
  background: var(--bar-bg);
  border-radius: 3px;
  overflow: hidden;
}

.role-progress-fill {
  height: 100%;
  border-radius: 3px;
  min-width: 3px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.role-progress-pct {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--text-mid);
  white-space: nowrap;
  min-width: 2.8em;
  text-align: right;
}

/* Ítem de rol difuminado (segundo bloqueado — clipped) */
.level-role-item.role-item-faded {
  max-height: 40px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 30%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 30%, transparent 100%);
  pointer-events: none;
}

/* Botón "Mostrar más" */
.role-show-more-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 0;
  background: none;
  border: 1.5px solid var(--card-bg);
  border-radius: var(--radius-inner);
  color: var(--text-mid);
  font-family: inherit;
  font-size: 0.70rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  cursor: pointer;
  text-transform: uppercase;
  transition: border-color 0.15s, color 0.15s;
}
.role-show-more-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 520px) {
  .card-username { max-width: 120px; }
  .card-row1-right { gap: 5px; }
  .profile-body { flex-direction: column; align-items: center; }
  .profile-left { flex-direction: row; align-items: flex-start; gap: 12px; }
  .profile-left .top1-badges { flex-direction: column; }
  .profile-details { width: 100%; }
  .profile-row1 { flex-wrap: wrap; }
  .profile-stats { justify-content: flex-start; }

  .podium-avatar { width: 44px; height: 44px; }
  .podium-name   { font-size: 0.66rem; }
  .podium-level  { font-size: 0.72rem; }
  .podium-medal  { font-size: 1.1rem; }
  .podium-base-1st { height: 100px; font-size: 1.3rem; }
  .podium-base-2nd { height: 70px; font-size: 1.3rem; }
  .podium-base-3rd { height: 46px; font-size: 1.1rem; }
}
