@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Boogaloo&display=swap');

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

:root {
  --bg: #f0f4ff;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --shadow: 0 8px 32px rgba(80,80,160,0.10);
  --radius: 20px;
  --transition: 0.3s cubic-bezier(.4,0,.2,1);
}

body {
  font-family: 'Nunito', sans-serif;
  background: url('images/fondo.png') no-repeat center center;
  background-size: cover; 
  color: var(--text);
  min-height: 100vh;
  padding: 0;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #667eea 0%, #FF327D 100%);
  padding: 32px 24px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}
header h1 {
  font-family: 'Boogaloo', cursive;
  font-size: clamp(2rem, 6vw, 3.4rem);
  color: #fff;
  letter-spacing: 2px;
  position: relative;
  text-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
header p {
  color: rgba(255,255,255,0.8);
  font-size: 1rem;
  margin-top: 6px;
  position: relative;
}

/* ── Tabs ── */
.tabs-wrapper {
  display: flex;
  justify-content: center;
  margin-top: -28px;
  position: relative;
  z-index: 10;
  padding: 0 16px;
}
.tabs {
  display: inline-flex;
  background: #fff;
  border-radius: 50px;
  padding: 6px;
  gap: 4px;
  box-shadow: 0 8px 32px rgba(80,80,160,0.18);
}
.tab-btn {
  border: none;
  background: transparent;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-muted);
  padding: 8px 22px;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.tab-btn.active, .tab-btn:hover {
  background: linear-gradient(135deg, #FF327D, #FF327D);
  color: #fff;
  box-shadow: 0 4px 16px rgba(102,126,234,0.35);
}

/* ── Main Container ── */
main {
  max-width: 780px;
  margin: 0 auto;
  padding: 32px 16px 60px;
}

/* ── Ranking List ── */
#ranking-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-top: 10px;
}

/* ── Card ── */
.rank-card {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: var(--radius);
  /* overflow: hidden; */ /* <--- ELIMINA O COMENTA ESTA LÍNEA */
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
  animation: slideIn 0.5s ease both;
  cursor: default;
  position: relative;
  z-index: 1; /* Para controlar capas */
}
.rank-card.first {
  height: auto;
  min-height: 150px; /* Un poco más alto que antes */
  border-radius: 28px;
  position: relative;
  overflow: visible;
  transform: scale(1.03);
  z-index: 5;
}
.rank-card.first > *:first-child {
  border-radius: 24px 0 0 24px;
}
.rank-card.first > *:last-child {
  border-radius: 0 24px 24px 0;
}
.rank-card:hover {
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 18px 48px rgba(80,80,160,0.18);
}

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

/* Rank badge */
.rank-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 66px;
  min-width: 66px;
  height: 80px;
  font-family: 'Boogaloo', cursive;
  font-size: 2rem;
  color: #fff;
  flex-shrink: 0;
}

/* Card body */
.card-body {
  flex: 1;
  padding: 14px 16px;
  color: #fff;
  min-width: 0;
}
.card-name {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stars */
.stars {
  display: flex;
  gap: 3px;
  align-items: center;
}
.star {
  font-size: 1.4rem;
  /* El secreto de la estrella gruesa: un pequeño borde de sombra */
  text-shadow: 0 0 1px rgba(0,0,0,0.1); 
  color: rgba(255, 255, 255, 0.3); /* Color para estrellas vacías */
  transition: transform 0.2s ease;
}
.star.filled {
  color: #FFD700;
  filter: drop-shadow(0 0 2px rgba(255, 215, 0, 0.5));
}
.star.half {
  position: relative;
  color: rgba(255, 255, 255, 0.3);
}

.star.half::after {
  content: '★';
  position: absolute;
  left: 0;
  top: 0;
  width: 50%;
  overflow: hidden;
  color: #FFD700;
}


.score-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center; /* Centra horizontalmente el botón con el score */
  justify-content: center;
  gap: 2px;            /* Espacio entre el 5.0/5 y el botón Ver */
  padding: 0 15px;     /* Espacio lateral */
  flex-shrink: 0;      /* Evita que se aplaste */
}

/* Score */
.card-score {
  font-family: 'Boogaloo', cursive;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  color: #fff;
  padding: 0 12px;
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 1px;
}

.card-avatar {
  width: 100px;
  min-width: 100px;
  height: 80px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  overflow: visible;
  background: transparent; 
  flex-shrink: 0;
}

.card-avatar img {
  width: 100%; 
  height: auto;
  position: absolute;
  bottom: -2px;
  right: 10px;
  transform-origin: bottom center;
  z-index: 100;
  filter: drop-shadow(0 8px 15px rgba(0,0,0,0.3));
}

.rank-card.first .card-avatar {
  font-size: 3.8rem;
  width: 170px;
  min-width: 170px;
  height: 150px;
  bottom: 2px;
}

/* View button */
.btn-view {
  background: rgba(255, 255, 255, 0);
  border: 1.5px solid rgba(255,255,255,0.55);
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 0.72rem;
  padding: 1px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.rank-card.first .score-wrapper {
  gap: 12px;           /* Un poco más de espacio en el ganador */
}

.btn-view:hover {
  background: rgba(255,255,255,0.45);
  transform: scale(1.05);
}

/* ── First place special style ── */
.star-icon {
  width: 1.4rem;  /* Tamaño base */
  height: auto;
  margin-right: 2px;
  filter: drop-shadow(0 0 1px rgba(54, 54, 54, 0.219));
  transition: transform 0.2s ease;
}

/* Estrella llena */
.star-icon.filled {
  fill: #FFD700;
}

/* Estrella media (usando el gradiente definido en el HTML) */
.star-icon.half {
  fill: url(#half-grad);
}

/* Estrella vacía */
.star-icon.empty {
  fill: rgba(65, 65, 65, 0.185);
}

/* Estrellas más grandes para el primer puesto */
.rank-card.first .star-icon {
  width: 1.8rem;
  filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.6));
}
.star-icon.partial {
  filter: drop-shadow(0 0 1px rgba(54,54,54,0.2));
}

/* Animación al pasar el mouse */
.rank-card:hover .star-icon.filled {
  transform: scale(1.1) rotate(5deg);
}

/* Gold crown ribbon */
.rank-card.first::before {
  content: '👑'; /* Añadimos la corona */
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.2rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.399));
  z-index: 10;
  pointer-events: none;
  animation: bounce 2s infinite; /* Un pequeño efecto de rebote */
}

@keyframes bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-10px); }
}

.rank-card.first .rank-badge {
  font-size: 4.5rem; /* Número más grande */
  width: 100px;
  min-width: 100px;
  height: 150px;
}

.rank-card.first .card-name {
  font-size: clamp(1.3rem, 4vw, 1.7rem); /* Nombre más grande */
  font-weight: 900;
  margin-bottom: 5px;
}

.rank-card.first .star {
  font-size: 2.2rem; /* Estrellas más grandes */
}

.rank-card.first .card-score {
  font-size: clamp(2.2rem, 6vw, 3rem);
  padding: 0 20px;
}


.rank-card.first .card-body {
  padding: 18px 18px;
}

.rank-card.first .card-genre {
  font-size: 0.82rem;
}

.rank-card.first .btn-view {
  font-size: 0.78rem;
  padding: 1px 12px;
  margin-right: 14px;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 10, 40, 0.6);
  backdrop-filter: blur(6px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.open {
  display: flex;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: #fff;
  border-radius: 24px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 32px 80px rgba(0,0,0,0.3);
  animation: popIn 0.3s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.85) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 24px;
  color: #fff;
  position: relative;
}
.modal-emoji {
  font-size: 2.4rem;
}
.modal-title-block h2 {
  font-size: 1.15rem;
  font-weight: 900;
}
.modal-title-block p {
  font-size: 0.8rem;
  opacity: 0.8;
}
.modal-close {
  margin-left: auto;
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.modal-close:hover { background: rgba(255,255,255,0.45); }

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-body::-webkit-scrollbar { width: 5px; }
.modal-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }

.modal-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.modal-avg {
  font-family: 'Boogaloo', cursive;
  font-size: 2.4rem;
  line-height: 1;
}
.modal-total {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.review-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg);
  margin-bottom: 10px;
  border-left: 4px solid transparent;
  transition: transform 0.2s;
}

.review-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.review-user {
  font-weight: 900;
  font-size: 0.9rem;
  color: var(--text);
}
.review-stars { display: flex; gap: 2px; }
.review-stars span { font-size: 0.78rem; }
.review-comment {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.user-info {
  display: flex;
  flex-direction: column; /* Pone la fecha debajo del nombre */
}

.review-date {
  font-size: 0.7rem;
  color: #666;
  margin-top: 2px;
  font-weight: 400;
}

.review-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Alinea arriba para que el nombre y estrellas cuadren */
  margin-bottom: 8px;
}

/* No results */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.no-results span { font-size: 3rem; display: block; margin-bottom: 12px; }

/* ── Responsive ── */
@media (max-width: 520px) {
  .rank-badge { width: 50px; min-width: 50px; font-size: 1.6rem; }
  .card-avatar { width: 70px; min-width: 70px; font-size: 2rem; }
  .btn-view { font-size: 0.5rem; padding: 4px 9px; margin-right: 8px; }
  .rank-card.first { min-height: 110px; }
  .rank-card.first .rank-badge { width: 50px; min-width: 40px; height: 110px; font-size: 2.2rem; }
  .rank-card.first .card-avatar { width: 80px; min-width: 80px; height: 110px; font-size: 3rem; }
  .rank-card.first .card-avatar img { width: 170%;  right: -10px; bottom: -1px;}
  .rank-card.first .card-score { font-size: 1.6rem; padding: 0 8px; }
  .rank-card.first .card-name {
    font-size: clamp(1rem, 3vw, 1.3rem);
  }
  .card-score { font-size: 1.3rem; padding: 0 8px; }
  .modal-avg { font-size: 1.9rem; }
  .rank-card.first .btn-view {
    font-size: 0.6rem;
    padding: 5px 10px;
    margin-right: 14px;
  }
  .rank-card.first .star {
    font-size: 1.5rem; /* Estrellas más grandes */
  }
  .rank-card.first .card-body {
    padding: 0;
  }
  .card-body {
    padding: 0;
  }

  .card-avatar img {
    width: 140%;
    right: -3px;
    bottom: 0;
  }

}

