/* Estilos CSS del juego
  Mejoras de la paleta de colores, tipografía, y animaciones.
*/

:root {
  /* Paleta de colores más vibrante y pastel */
  --bg: #fcf8e8; /* Very light cream */
  --bg2: #f5e6cc; /* Light beige */
  --card: rgba(255, 255, 255, .95);
  --cardHi: rgba(255, 255, 255, .9);
  --ink: #5a5a5a; /* Slightly softer dark grey */
  --muted: #a0a0a0; /* Softer muted grey */
  --primary: #a890f0; /* Softer purple */
  --primary-light: #c0a8f8; /* Lighter, more pastel purple */
  --success: #8bc34a; /* Brighter, more cheerful green */
  --warning: #ffca28; /* Brighter yellow/orange */
  --danger: #ef5350; /* Keeping red for danger, but could be softened if needed */
  --highlight: #ffeb3b; /* Brighter yellow highlight */
  /* Espaciado y tipografía */
  --space-unit: 1rem;
  --font-heading: 'Fredoka', sans-serif;
  --font-body: 'Nunito', sans-serif;
  --font-size-base: clamp(0.8rem, 1vw + 0.5rem, 1rem);
  --font-size-large: clamp(1.2rem, 1.5vw + 0.5rem, 1.5rem);
  --font-size-xl: clamp(1.5rem, 2vw + 0.5rem, 2rem);
  --font-size-xxl: clamp(2rem, 3vw + 1rem, 3rem);
  /* Sombra y bordes */
  --shadow-small: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 10px 15px rgba(0, 0, 0, 0.15);
  --shadow-large: 0 20px 25px rgba(0, 0, 0, 0.2);
  --border-radius-large: 1.5rem;
  --border-radius-medium: 1rem;
}

* { box-sizing: border-box; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vw, 2.5rem);
  min-height: 100vh;
  padding: clamp(1rem, 3vw, 2.5rem);
  line-height: 1.6;
  font-size: var(--font-size-base);
  transition: background-color 0.5s ease-in-out;
}

body.has-custom-background {
  background: linear-gradient(160deg, var(--custom-bg-start, #fce4ec), var(--custom-bg-end, #f8bbd0));
  color: var(--custom-text-color, var(--ink));
}

body.has-custom-background #stageBottom {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

body.has-custom-background #stageTop span {
  background: rgba(255, 255, 255, 0.92);
}

body::after {
  content: '';
  position: fixed;
  inset: -40vh 0 0 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.25) 0, transparent 55%),
    radial-gradient(circle at 80% 30%, rgba(255, 255, 255, 0.18) 0, transparent 50%),
    radial-gradient(circle at 50% 80%, rgba(255, 255, 255, 0.22) 0, transparent 45%);
  background-size: 380px 380px, 420px 420px, 360px 360px;
  opacity: 0.28;
  animation: starSlide 32s linear infinite;
  z-index: 0;
}

@keyframes starSlide {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-80px, -120px, 0); }
}

#floatingDecor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floating-decor__icon {
  position: absolute;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  opacity: 0.4;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.25));
  animation: floatingIcon var(--duration, 12s) linear infinite;
  animation-delay: var(--delay, 0s);
  transform: translate3d(0, 100vh, 0);
}

@keyframes floatingIcon {
  0% {
    transform: translate3d(0, 110vh, 0) scale(0.85);
    opacity: 0;
  }
  10% {
    opacity: 0.45;
  }
  60% {
    opacity: 0.65;
  }
  100% {
    transform: translate3d(0, -120vh, 0) scale(1.05);
    opacity: 0;
  }
}

/* Fondos de pantalla por nivel */
.body-level-1 { background: linear-gradient(180deg, #fce4ec 0%, #f8bbd0 45%, #f48fb1 100%); }
.body-level-2 { background: linear-gradient(180deg, #e3f2fd 0%, #bbdefb 40%, #64b5f6 100%); }
.body-level-3 { background: linear-gradient(180deg, #e8f5e9 0%, #c8e6c9 45%, #81c784 100%); }
.body-level-4 { background: linear-gradient(180deg, #fff3e0 0%, #ffe0b2 42%, #ffb74d 100%); }
.body-level-5 { background: linear-gradient(180deg, #f3e5f5 0%, #e1bee7 42%, #ba68c8 100%); }
.body-level-6 { background: linear-gradient(180deg, #e0f2f1 0%, #b2dfdb 40%, #4db6ac 100%); }
.body-level-7 { background: linear-gradient(180deg, #f1f8e9 0%, #dcedc8 40%, #aed581 100%); }
.body-level-8 { background: linear-gradient(180deg, #e1f5fe 0%, #b3e5fc 40%, #4fc3f7 100%); }
.body-level-9 { background: linear-gradient(180deg, #fffde7 0%, #fff59d 42%, #fdd835 100%); }
.body-level-10 { background: linear-gradient(180deg, #efebe9 0%, #d7ccc8 40%, #a1887f 100%); }
.body-level-11 { background: linear-gradient(180deg, #fbe9e7 0%, #ffccbc 40%, #ff8a65 100%); }
.body-level-12 { background: linear-gradient(180deg, #ede7f6 0%, #d1c4e9 40%, #9575cd 100%); }


/* 🏆 Header */
#stageTop {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  max-width: 900px;
  width: 100%;
  padding: var(--space-unit);
  font-family: var(--font-heading);
  font-size: var(--font-size-large);
  color: var(--primary);
  position: relative;
  z-index: 1;
}

.scores-container {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 1vw, 0.75rem);
  align-items: center;
}

#stageTop span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  background: var(--card);
  box-shadow: var(--shadow-small);
}

#stageTop span#user-info {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  gap: clamp(0.45rem, 1vw, 0.75rem);
  padding: clamp(0.45rem, 1vw, 0.8rem) clamp(0.7rem, 1.4vw, 1.1rem);
  background: var(--user-info-bg, var(--card));
  color: var(--user-info-ink, var(--primary));
}
#stageTop span#user-info:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 18px rgba(148, 102, 255, 0.25);
}

.user-info__avatar {
  width: clamp(42px, 5vw, 56px);
  height: clamp(42px, 5vw, 56px);
  object-fit: contain;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 6px 14px rgba(148, 102, 255, 0.25);
}

.user-info__avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  color: #4a3c75;
}

.user-info__name {
  font-family: var(--font-heading);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  color: var(--user-info-name, var(--ink));
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.user-info__badge {
  font-size: clamp(1.3rem, 2.2vw, 1.6rem);
  animation: sparklePulse 4.5s ease-in-out infinite;
}

#stageTop span#scoreStars::before { content: '⭐️'; }
#stageTop span.coins::before { content: '💰'; }
#stageTop span.level::before { content: '🚀'; }

#stageTop span::before {
  display: inline-flex;
  animation: sparklePulse 4.5s ease-in-out infinite;
  transform-origin: center;
}

.top-buttons {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* Estilos mejorados para los botones de temas */
.topic-btn {
  font-family: var(--font-heading);
  padding: 1rem 1.5rem;
  border-radius: 1.5rem;
  border: none;
  background: var(--bg2);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.25s ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  font-size: var(--font-size-large);
  animation: bounceIn 0.5s ease-out;

  /* ✨ Relieve visible */
  box-shadow: 
    -6px -6px 12px rgba(255, 255, 255, 0.9),  /* luz fuerte arriba-izq */
    6px 6px 12px rgba(0, 0, 0, 0.25);         /* sombra marcada abajo-der */
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.topic-btn:hover {
  transform: translateY(-3px);
  box-shadow: 
    -2px -2px 6px rgba(255, 255, 255, 0.7),
    6px 6px 12px rgba(0, 0, 0, 0.25);
}

.topic-btn:active {
  transform: translateY(1px);
  box-shadow: 
    inset -2px -2px 6px rgba(255, 255, 255, 0.7),
    inset 6px 6px 12px rgba(0, 0, 0, 0.25);
}


#btnBack, #btnLogros, #btnLogout {
  background: var(--muted);
  color: white;
  box-shadow: var(--shadow-small);
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
#btnBack:hover, #btnLogros:hover, #btnLogout:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-medium);
}
#btnBack:active, #btnLogros:active, #btnLogout:active {
  transform: scale(0.95);
}

/* 📦 Contenedor principal */
#stageBottom {
  max-width: min(960px, 100%);
  width: 100%;
  background: var(--card);
  border-radius: var(--border-radius-large);
  padding: clamp(1.5rem, 4vw, 3rem);
  box-shadow: var(--shadow-large);
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2.2vw, 2rem);
  text-align: center;
  animation: fadeIn 1s ease-in-out;
  position: relative;
  overflow: hidden;
  min-height: clamp(420px, 65vh, 780px);
  z-index: 1;
}

.review-banner {
  width: 100%;
  background: linear-gradient(135deg, rgba(255, 217, 61, 0.95), rgba(255, 150, 199, 0.92));
  color: #3a2c00;
  border-radius: 1.5rem;
  padding: clamp(1rem, 2.5vw, 1.4rem);
  box-shadow: 0 14px 30px rgba(255, 190, 120, 0.35);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
  text-align: center;
  margin-bottom: clamp(0.8rem, 2vw, 1.2rem);
}

.review-banner strong {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
}

.review-banner p {
  margin: 0;
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
}

.review-banner__btn {
  margin-top: 0.4rem;
  padding: 0.55rem 1.4rem;
  border-radius: 999px;
  border: none;
  background: #4b2bb3;
  color: #fff;
  font-family: var(--font-heading);
  font-size: clamp(0.95rem, 1.5vw, 1.05rem);
  cursor: pointer;
  box-shadow: 0 10px 22px rgba(75, 43, 179, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.review-banner__btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(75, 43, 179, 0.4);
}

.pause-banner {
  position: fixed;
  bottom: clamp(1rem, 4vw, 2.5rem);
  right: clamp(1rem, 4vw, 2.5rem);
  z-index: 1100;
  max-width: 280px;
  background: linear-gradient(135deg, rgba(255, 238, 88, 0.95), rgba(255, 167, 216, 0.95));
  color: #3a2c00;
  border-radius: 1.5rem;
  box-shadow: 0 18px 40px rgba(255, 181, 72, 0.35);
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.pause-banner strong {
  font-family: var(--font-heading);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.pause-banner p {
  margin: 0;
  font-size: 0.95rem;
}

.pause-banner__actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pause-banner__btn {
  border: none;
  border-radius: 999px;
  background: rgba(75, 43, 179, 0.9);
  color: #fff;
  font-family: var(--font-heading);
  padding: 0.45rem 1.2rem;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(75, 43, 179, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pause-banner__btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(75, 43, 179, 0.35);
}

.pause-banner__link {
  background: transparent;
  border: none;
  font-family: var(--font-body);
  color: #3a2c00;
  cursor: pointer;
  text-decoration: underline;
  padding: 0.3rem 0.6rem;
}
#stageBottom::before {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--primary-light), transparent 70%);
  opacity: 0.1;
  animation: bg-pulse 10s infinite alternate;
}

@keyframes bg-pulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

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

@keyframes sparklePulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0)); }
  40% { transform: scale(1.12) rotate(6deg); filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.45)); }
  70% { transform: scale(0.96) rotate(-4deg); filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.25)); }
}

@keyframes gentleGlow {
  0% { box-shadow: 0 10px 25px rgba(102, 187, 106, 0.35); }
  50% { box-shadow: 0 15px 35px rgba(102, 187, 106, 0.5); }
  100% { box-shadow: 0 10px 25px rgba(102, 187, 106, 0.35); }
}

@keyframes softShake {
  0% { transform: scale(0.97) translateX(0); }
  25% { transform: scale(0.97) translateX(-4px); }
  50% { transform: scale(0.97) translateX(4px); }
  75% { transform: scale(0.97) translateX(-2px); }
  100% { transform: scale(0.97) translateX(0); }
}

@keyframes iconFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(6deg); }
}

@keyframes iconSparkle {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(255, 255, 255, 0)); }
  50% { filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.55)); }
}

#content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-unit);
}

.question-prompt {
  font-family: var(--font-heading);
  font-size: var(--font-size-xl);
  color: #FFD93D;
  margin-bottom: var(--space-unit);
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.35);
  animation: fadeIn 0.8s ease-in-out;
}


.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1.25rem;
  width: 100%;
  /* semi-transparent pastel background with subtle blur */
  background: rgba(250, 250, 255, 0.55);
  backdrop-filter: blur(6px) saturate(1.05);
  border-radius: 1.5rem;
  box-shadow: 0 8px 32px rgba(148, 102, 255, 0.10), 0 2px 8px rgba(0,0,0,0.04);
  padding: 1.2rem 0.5rem;
  justify-items: center;
  align-items: stretch;
  min-height: 180px;
  transition: background 0.4s, transform 160ms ease;
}

@media (max-width: 900px) {
  .options-grid {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 1rem;
    padding: 0.8rem 0.2rem;
  }
}

@media (max-width: 600px) {
  .options-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    padding: 0.5rem 0.1rem;
  }
}

.option {
  font-family: var(--font-body);
  font-size: clamp(1rem, 2vw, 1.2rem);
  padding: 0.7em 0.2em 0.6em 0.2em;
  border-radius: 1.2em;
  background: linear-gradient(135deg, #fffbe6 0%, #ffe0f7 100%);
  border: 3px solid transparent;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  position: relative;
  animation: bounceIn 0.5s ease-out;
  box-shadow: 0 6px 18px rgba(148, 102, 255, 0.13), 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.22s cubic-bezier(.2,.9,.2,1), box-shadow 0.22s, filter 0.22s;
  min-height: 90px;
  min-width: 0;
  max-width: 100%;
  appearance: none;
  -webkit-appearance: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
  color: var(--custom-text-color, #333333);
  outline: none;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .option {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    padding: 0.5em 0.1em 0.5em 0.1em;
    min-height: 70px;
    border-radius: 1em;
  }
}

@media (max-width: 600px) {
  .option {
    font-size: clamp(0.9rem, 2vw, 1rem);
    padding: 0.4em 0.05em 0.4em 0.05em;
    min-height: 56px;
    border-radius: 0.9em;
  }
}

.option-icon {
  display: block;
  margin: 0 auto;
  max-width: 120px;
  width: 100%;
  height: auto;
  font-size: 2.5rem;
  transition: transform 0.3s ease, filter 0.3s ease;
  filter: drop-shadow(0 2px 8px rgba(148, 102, 255, 0.10));
}

@media (max-width: 900px) {
  .option-icon {
    max-width: 100px;
    font-size: 2.1rem;
  }
}

@media (max-width: 600px) {
  .option-icon {
    max-width: 80px;
    font-size: 1.7rem;
  }
}

.option-text {
  flex: 1 1 auto;
  text-align: center;
}


.option:hover {
  transform: scale(1.07) translateY(-2px);
  box-shadow: 0 0 0 8px rgba(255, 220, 255, 0.18), 0 10px 32px rgba(148, 102, 255, 0.18);
  border-color: #a890f0;
  filter: brightness(1.08) drop-shadow(0 0 16px #ffe0f7cc);
  z-index: 2;
}
.option:active {
  transform: scale(0.97);
  filter: brightness(0.98);
}


.option:focus-visible {
  outline: 3px solid #ffd54f;
  outline-offset: 4px;
}

.option.selected {
  transform: scale(1.05);
  border-color: #a890f0;
  background: linear-gradient(135deg, #e0f7fa 0%, #f8e8ff 100%);
  color: #6a2bbf;
  box-shadow: 0 0 0 10px #e0f7fa44, 0 10px 32px rgba(148, 102, 255, 0.18);
}

.option.correct {
  transform: scale(1.05);
  background: linear-gradient(135deg, var(--success), #7dd87d);
  border-color: var(--success);
  color: white;
  box-shadow: 0 10px 25px rgba(102, 187, 106, 0.35);
  animation: gentleGlow 1.4s ease-in-out 2;
}

.option.correct::after {
  content: '✅';
  position: absolute;
  top: -12px;
  right: -12px;
  background: white;
  color: var(--success);
  border-radius: 999px;
  padding: 0.1rem 0.35rem;
  font-size: 1.2rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.option.wrong {
  transform: scale(0.97);
  background: #ff9b9b;
  border-color: var(--danger);
  color: white;
  box-shadow: 0 12px 18px rgba(239, 83, 80, 0.25);
  animation: softShake 0.4s ease-in-out;
}

.prompt {
  font-family: var(--font-heading);
  font-size: var(--font-size-large);
  margin-top: var(--space-unit);
  padding: 0.5rem 1rem;
  border-radius: 1rem;
  width: fit-content;
  align-self: center;
  animation: fadeIn 0.5s ease-in-out;
}

.prompt.ok {
  background-color: var(--success);
  color: white;
}

.prompt.bad {
  background-color: var(--danger);
  color: white;
}

#stageBtns {
  display: flex;
  justify-content: center;
  gap: var(--space-unit);
  margin-top: calc(var(--space-unit) * 2);
  width: 100%;
}

.btn {
  font-family: var(--font-heading);
  font-size: var(--font-size-large);
  padding: 0.75rem 2rem;
  border-radius: var(--border-radius-medium);
  background: linear-gradient(135deg, rgba(255,255,255,0.85) 0%, rgba(255,240,250,0.8) 100%);
  border: 2px solid rgba(255,255,255,0.6);
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 180ms cubic-bezier(.2,.9,.2,1), box-shadow 180ms ease, filter 180ms ease;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);

.option:hover, .option:focus {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 14px 32px rgba(20,30,40,0.12);
  filter: saturate(1.03);
}
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-medium);
}
.btn:active {
  transform: scale(0.95);
}

.prompt-with-audio {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 1vw, 1rem);
  width: 100%;
}

.prompt-with-audio .question-prompt {
  margin-bottom: 0;
}

.audio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(2.75rem, 4vw, 3.1rem);
  height: clamp(2.75rem, 4vw, 3.1rem);
  border-radius: 999px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(148, 102, 255, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.audio-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(148, 102, 255, 0.4);
}

.audio-btn:active {
  transform: scale(0.92);
}

.audio-btn:focus-visible {
  outline: 3px solid var(--highlight);
  outline-offset: 3px;
}

.story-toolbar {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.story-listen-btn {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 2vw, 1.25rem);
  padding: clamp(0.6rem, 1.8vw, 0.9rem) clamp(1rem, 2.5vw, 1.6rem);
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #ff80ab, #ffb74d);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(255, 128, 171, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.story-listen-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(255, 128, 171, 0.4);
}

.story-listen-btn:active {
  transform: scale(0.95);
}

.progress-tracker {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: clamp(0.75rem, 2vw, 1.5rem);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.progress-tracker.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.progress-tracker__label {
  font-family: var(--font-heading);
  font-size: clamp(0.95rem, 1.8vw, 1.15rem);
  color: var(--primary);
}

.progress-tracker__bar {
  width: 100%;
  height: clamp(0.6rem, 1.5vw, 0.85rem);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: inset 0 0 0 2px rgba(148, 102, 255, 0.12);
  overflow: hidden;
}

.progress-tracker__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(171, 71, 188, 0.9), rgba(48, 63, 159, 0.9));
  transition: width 0.35s ease;
}

body[data-bg-theme="theme-galaxy"] {
  background: radial-gradient(circle at 20% 20%, #433f9f 0%, #231942 45%, #140b29 100%);
  color: #f6f7ff;
}

body[data-bg-theme="theme-ocean"] {
  background: linear-gradient(160deg, #d0f4ff 0%, #6fb1ff 50%, #004e92 100%);
}

body[data-bg-theme] #stageBottom {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.shop-modal {
  position: fixed;
  inset: 0;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: rgba(19, 10, 35, 0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1000;
}

.shop-modal.is-open {
  opacity: 1;
  pointer-events: all;
}

.shop-modal__dialog {
  background: rgba(255, 255, 255, 0.96);
  border-radius: 1.75rem;
  width: min(900px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2.5vw, 1.75rem);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  box-shadow: 0 24px 60px rgba(28, 16, 58, 0.35);
  position: relative;
}

.shop-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.shop-modal__header h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 2.4vw, 1.9rem);
  color: var(--primary);
  margin: 0;
}

.shop-modal__subtitle {
  margin: 0;
  font-size: clamp(1rem, 1.8vw, 1.1rem);
  color: var(--muted);
  text-align: center;
}

.shop-modal__close {
  background: transparent;
  border: none;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  cursor: pointer;
  color: var(--muted);
  transition: transform 0.2s ease, color 0.2s ease;
}

.shop-modal__close:hover {
  transform: scale(1.1);
  color: var(--primary);
}

.shop-modal__content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: clamp(1rem, 2vw, 1.5rem);
  max-height: calc(80vh - 160px);
  overflow-y: auto;
  padding-right: clamp(0.4rem, 1vw, 0.75rem);
  scrollbar-color: rgba(148, 102, 255, 0.45) rgba(255, 255, 255, 0.4);
}

.shop-section h3 {
  font-family: var(--font-heading);
  margin-bottom: 0.5rem;
  color: var(--primary);
}


.shop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(0.75rem, 2vw, 1.1rem);
  align-content: start;
  max-height: clamp(220px, 40vh, 360px);
  overflow-y: auto;
  padding-right: clamp(0.25rem, 1vw, 0.5rem);
  scrollbar-color: rgba(148, 102, 255, 0.45) rgba(255, 255, 255, 0.4);
}

.shop-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(244, 239, 255, 0.95));
  border-radius: 1.25rem;
  padding: clamp(0.9rem, 2vw, 1.2rem);
  box-shadow: 0 14px 28px rgba(61, 9, 121, 0.16);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  text-align: center;
}

.shop-item__artwork {
  width: clamp(56px, 8vw, 80px);
  height: clamp(56px, 8vw, 80px);
  object-fit: contain;
  border-radius: 20%;
  box-shadow: 0 10px 22px rgba(61, 9, 121, 0.18);
}

.shop-item__emoji {
  font-size: clamp(2.2rem, 6vw, 2.8rem);
}

.shop-item__name {
  font-family: var(--font-heading);
  font-size: clamp(1rem, 1.8vw, 1.15rem);
}

.shop-item__price {
  font-weight: 700;
  color: var(--warning);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.shop-item__price-icon {
  font-size: clamp(1.1rem, 2vw, 1.3rem);
}

.shop-item__action {
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-family: var(--font-heading);
  font-size: clamp(0.85rem, 1.4vw, 1rem);
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(148, 102, 255, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.shop-item__action:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(148, 102, 255, 0.35);
}

.shop-item__action:disabled,
.shop-item__action.is-disabled {
  background: #d0c7f7;
  cursor: not-allowed;
  box-shadow: none;
}

.shop-inventory {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(0.75rem, 2vw, 1.1rem);
  max-height: clamp(220px, 40vh, 360px);
  overflow-y: auto;
  padding-right: clamp(0.25rem, 1vw, 0.5rem);
  scrollbar-color: rgba(148, 102, 255, 0.45) rgba(255, 255, 255, 0.4);
}

.shop-inventory__item {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(244, 239, 255, 0.95));
  border-radius: 1.25rem;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  box-shadow: 0 15px 30px rgba(61, 9, 121, 0.15);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.85rem;
}

.shop-inventory__action {
  align-self: flex-start;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.4rem;
  font-family: var(--font-heading);
  font-size: clamp(0.9rem, 1.5vw, 1rem);
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 20px rgba(148, 102, 255, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.shop-inventory__action:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(148, 102, 255, 0.35);
}

.shop-inventory__preview {
  width: clamp(64px, 12vw, 86px);
  height: clamp(64px, 12vw, 86px);
  border-radius: 1rem;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(61, 9, 121, 0.18);
}

.shop-inventory__meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1 1 auto;
}

.shop-inventory__label {
  font-weight: 600;
}

.shop-inventory__tag {
  font-size: 0.8rem;
  color: var(--muted);
  background: rgba(148, 102, 255, 0.12);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  width: fit-content;
}

.shop-inventory__empty {
  background: rgba(236, 236, 255, 0.65);
  border-radius: 1rem;
  padding: clamp(0.75rem, 2vw, 1rem);
  text-align: center;
  color: var(--muted);
}

.shop-inventory__item.is-locked {
  opacity: 0.6;
}

@media (max-width: 600px) {
  .shop-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(150px, 80%);
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.6rem;
    margin-bottom: 0.3rem;
    scroll-snap-type: x proximity;
  }

  .shop-item {
    scroll-snap-align: center;
  }
}

.shop-modal__content::-webkit-scrollbar,
.shop-list::-webkit-scrollbar,
.shop-inventory::-webkit-scrollbar {
  width: 8px;
}

.shop-modal__content::-webkit-scrollbar-thumb,
.shop-list::-webkit-scrollbar-thumb,
.shop-inventory::-webkit-scrollbar-thumb {
  background: rgba(148, 102, 255, 0.45);
  border-radius: 999px;
}

.shop-modal__content::-webkit-scrollbar-track,
.shop-list::-webkit-scrollbar-track,
.shop-inventory::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.4);
  border-radius: 999px;
}

#btnPrev {
  background: var(--muted);
  color: white;
}

#btnSkip {
  background: var(--muted);
  color: white;
}

/* Animaciones y efectos */
.fx-shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
.fx-pop { animation: pop 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55) both; }
.fx-glow { animation: glow 1.5s infinite alternate; }
.fx-pop-out { animation: pop-out 0.5s forwards; }
.fx-bounce-menu { animation: bounceIn 0.5s ease-out; }

/* NUEVAS ANIMACIONES */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes bounceInDown {
  from,
  60%,
  75%,
  90%,
  to {
    animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
  }
  0% {
    opacity: 0;
    transform: translate3d(0, -3000px, 0) scale(0.5);
  }
  60% {
    opacity: 1;
    transform: translate3d(0, 25px, 0) scale(1);
  }
  75% {
    transform: translate3d(0, -10px, 0);
  }
  90% {
    transform: translate3d(0, 5px, 0);
  }
  to {
    transform: translate3d(0, 0, 0);
  }
}

.fx-pulse { animation: pulse 2s infinite ease-in-out; }
.fx-bounce-in-down { animation: bounceInDown 1s both; }

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

@keyframes pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

@keyframes pop-out {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.2); }
}

@keyframes glow {
  from { box-shadow: 0 0 5px var(--success); }
  to { box-shadow: 0 0 20px var(--success), 0 0 30px var(--success); }
}

@keyframes sparkle {
  0% { opacity: 0; transform: scale(0.5); }
  50% { opacity: 0.4; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(0.5); }
}

@keyframes bounceIn {
  0%, 20%, 40%, 60%, 80%, 100% {
    transition-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
  }
  0% {
    opacity: 0;
    transform: scale3d(0.3, 0.3, 0.3);
  }
  20% {
    transform: scale3d(1.1, 1.1, 1.1);
  }
  40% {
    transform: scale3d(0.9, 0.9, 0.9);
  }
  60% {
    opacity: 1;
    transform: scale3d(1.03, 1.03, 1.03);
  }
  80% {
    transform: scale3d(0.97, 0.97, 0.97);
  }
  100% {
    opacity: 1;
    transform: scale3d(1, 1, 1);
  }
}

/* 📱 Media queries mejorados */
@media (max-width: 900px) {
  #stageBottom {
    padding: clamp(1.2rem, 4vw, 1.9rem);
    min-height: clamp(360px, 70vh, 640px);
  }
  #stageTop {
    flex-direction: column;
    align-items: stretch;
  }
  .scores-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
  }
  .top-buttons {
    flex-wrap: wrap;
    width: 100%;
  }
  .top-buttons .btn {
    flex: 1 1 calc(50% - 0.5rem);
    max-width: none;
  }
}

@media (max-width: 600px) {
  body {
    padding: clamp(0.75rem, 4vw, 1rem);
    justify-content: flex-start;
    gap: 1.25rem;
  }
  #stageBottom {
    padding: clamp(1rem, 6vw, 1.3rem);
    border-radius: 1.35rem;
    min-height: auto;
  }
  .question-prompt {
    font-size: clamp(1.1rem, 5vw, 1.35rem);
  }
  .options-grid {
    grid-template-columns: 1fr;
  }
  .btn {
    font-size: clamp(0.95rem, 4vw, 1.05rem);
    padding: clamp(0.55rem, 3vw, 0.8rem);
  }
  .audio-btn {
    width: 2.6rem;
    height: 2.6rem;
    font-size: 1.5rem;
  }
  .shop-modal__dialog {
    max-height: 92vh;
    padding: clamp(1.2rem, 5vw, 1.8rem);
  }
  .shop-modal__content {
    grid-template-columns: 1fr;
    max-height: 65vh;
  }
}
.option:hover .option-icon,
.color-option-button:hover .option-icon {
  animation: iconFloat 1.8s ease-in-out infinite, iconSparkle 1.8s ease-in-out infinite;
}
