/* Minijuegos: cada escenario cambia el fondo de la tarjeta, cómo se ven las respuestas y las animaciones */

.av-reto[data-escena] { position: relative; overflow: hidden; }
.av-reto[data-escena] > * { position: relative; z-index: 1; }
.escena-deco { position: relative; z-index: 1; }
.escena-nueva {
  display: inline-block; margin: 0 0 6px; padding: 3px 12px; border-radius: 20px;
  background: linear-gradient(90deg, #E85D4F, #E8762B); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .25); font-weight: 800; font-size: 14px;
  animation: latido 1.2s ease-in-out infinite;
}
@keyframes latido { 50% { transform: scale(1.08); } }

/* ---------- Globos ---------- */
.av-reto[data-escena="globos"] { background: linear-gradient(180deg, #CDEBFF 0%, #FFF6E5 100%); }
.av-reto[data-escena="globos"] .av-opciones { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; padding-top: 8px; }
.av-reto[data-escena="globos"] .av-opcion {
  --c: #FF6F59; position: relative; min-height: 104px; border: none; border-radius: 50% 50% 46% 46% / 55% 55% 45% 45%;
  background: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .75) 0 10%, transparent 11%), var(--c);
  color: #fff; text-shadow: 0 2px 2px rgba(0, 0, 0, .3); box-shadow: inset -8px -10px 0 rgba(0, 0, 0, .12), 0 6px 10px rgba(0, 0, 0, .15);
  animation: flotaGlobo 3s ease-in-out infinite; margin-bottom: 26px;
}
.av-reto[data-escena="globos"] .av-opcion::after { content: ""; position: absolute; left: 50%; bottom: -26px; width: 2px; height: 26px; background: rgba(0, 0, 0, .25); }
.av-reto[data-escena="globos"] .av-opcion:nth-child(2) { --c: #3B8FE0; animation-delay: -.8s; }
.av-reto[data-escena="globos"] .av-opcion:nth-child(3) { --c: #2E9A57; animation-delay: -1.6s; }
.av-reto[data-escena="globos"] .av-opcion:nth-child(4) { --c: #9B59B6; animation-delay: -2.2s; }
.av-reto[data-escena="globos"] .av-opcion.mal { animation: pinchado .5s forwards; opacity: 1; background: #ccc; }
.av-reto[data-escena="globos"] .av-opcion.bien.vuela { animation: vuelaGlobo 1.4s ease-in forwards; }
@keyframes flotaGlobo { 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes pinchado { 0% { transform: scale(1); } 40% { transform: scale(1.15); } 100% { transform: scale(.5); opacity: .25; } }
@keyframes vuelaGlobo { to { transform: translateY(-420px) rotate(-8deg); opacity: 0; } }

/* ---------- Cofres ---------- */
.av-reto[data-escena="cofres"] { background: linear-gradient(180deg, #3B2A1E 0%, #6B4423 100%); color: #FFF6E5; }
.av-reto[data-escena="cofres"] .av-pregunta { color: #FFE7A8; }
.av-reto[data-escena="cofres"] .av-asignatura { background: rgba(255, 255, 255, .15); color: #FFE7A8; }
.av-reto[data-escena="cofres"] .av-texto { color: var(--tinta); }
.av-reto[data-escena="cofres"] .av-opciones { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 14px; }
.av-reto[data-escena="cofres"] .av-opcion {
  position: relative; min-height: 110px; padding: 34px 8px 10px; border: 4px solid #3B2412; border-radius: 14px 14px 10px 10px;
  background: linear-gradient(180deg, #B87333 0 28%, #D4A017 28% 34%, #9C5B26 34%); color: #FFF6E5; text-shadow: 0 2px 2px rgba(0, 0, 0, .5);
  box-shadow: 0 6px 0 #2A190C;
}
.av-reto[data-escena="cofres"] .av-opcion::before { content: "🔒"; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font-size: 20px; }
.av-reto[data-escena="cofres"] .av-opcion.abierto::before { content: "✨"; }
.av-reto[data-escena="cofres"] .av-opcion.abierto { background: linear-gradient(180deg, #FFE7A8 0 30%, #9C5B26 30%); animation: salto .5s; }
.av-reto[data-escena="cofres"] .av-opcion.mal { filter: grayscale(.8); opacity: .55; }

/* ---------- Estrellas ---------- */
.av-reto[data-escena="estrellas"] { background: radial-gradient(ellipse at 50% 0%, #3B3F9E, #141836 75%); color: #fff; }
.av-reto[data-escena="estrellas"] .av-pregunta { color: #fff; }
.av-reto[data-escena="estrellas"] .av-asignatura { background: rgba(255, 255, 255, .15); color: #FFE7A8; }
.av-reto[data-escena="estrellas"] .av-texto { color: var(--tinta); }
.av-reto[data-escena="estrellas"]::before { content: ""; position: absolute; inset: 0; z-index: 0; background-image: radial-gradient(2px 2px at 20% 30%, #fff, transparent), radial-gradient(2px 2px at 70% 20%, #fff, transparent), radial-gradient(1.5px 1.5px at 40% 70%, #fff, transparent), radial-gradient(1.5px 1.5px at 85% 60%, #fff, transparent), radial-gradient(2px 2px at 10% 80%, #fff, transparent); animation: titila 3s ease-in-out infinite; }
@keyframes titila { 50% { opacity: .4; } }
.av-reto[data-escena="estrellas"] .av-opciones { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.av-reto[data-escena="estrellas"] .av-opcion {
  min-height: 116px; border: none; background: #FFC93C; color: #6B4400; padding: 26px 14px 14px; box-shadow: 0 0 18px rgba(255, 201, 60, .6);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  animation: brilla 2.2s ease-in-out infinite; font-size: 20px;
}
.av-reto[data-escena="estrellas"] .av-opcion:nth-child(2) { animation-delay: -.6s; }
.av-reto[data-escena="estrellas"] .av-opcion:nth-child(3) { animation-delay: -1.2s; }
.av-reto[data-escena="estrellas"] .av-opcion.mal { background: #6A6480; opacity: .5; }
.av-reto[data-escena="estrellas"] .av-opcion.fugaz { animation: fugaz 1.2s ease-in forwards; background: #fff; }
@keyframes brilla { 50% { filter: brightness(1.25); transform: scale(1.04); } }
@keyframes fugaz { to { transform: translate(300px, -300px) scale(.3); opacity: 0; } }

/* ---------- Piedras del río ---------- */
.av-reto[data-escena="piedras"] { background: linear-gradient(180deg, #E9F7FF 0%, #7EC8E3 45%, #3A8DC1 100%); }
.av-reto[data-escena="piedras"] .av-opciones { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 16px; padding: 10px 0 6px; }
.av-reto[data-escena="piedras"] .av-opcion {
  min-height: 84px; border: none; border-radius: 48% 52% 44% 56% / 60% 55% 45% 40%;
  background: radial-gradient(circle at 35% 30%, #C9C2B8, #8A8178); color: #2B2540; box-shadow: 0 8px 0 rgba(0, 40, 80, .35), 0 0 0 6px rgba(255, 255, 255, .25);
  animation: mecer 2.6s ease-in-out infinite;
}
.av-reto[data-escena="piedras"] .av-opcion:nth-child(2) { animation-delay: -1s; }
.av-reto[data-escena="piedras"] .av-opcion:nth-child(3) { animation-delay: -1.8s; }
.av-reto[data-escena="piedras"] .av-opcion.mal { animation: hunde .7s forwards; }
.av-reto[data-escena="piedras"] .av-opcion.salto { background: radial-gradient(circle at 35% 30%, #DDF5E5, #2E9A57); color: #fff; }
@keyframes mecer { 50% { transform: translateY(4px) rotate(-1.5deg); } }
@keyframes hunde { to { transform: translateY(30px) scale(.8); opacity: .2; } }

/* ---------- Burbujas ---------- */
.av-reto[data-escena="burbujas"] { background: linear-gradient(180deg, #2B8DB5 0%, #164E7E 100%); color: #fff; }
.av-reto[data-escena="burbujas"] .av-pregunta { color: #fff; text-shadow: 0 2px 3px rgba(0, 0, 0, .3); }
.av-reto[data-escena="burbujas"] .av-asignatura { background: rgba(255, 255, 255, .15); color: #FFE7A8; }
.av-reto[data-escena="burbujas"] .av-texto { color: var(--tinta); }
.av-reto[data-escena="burbujas"] .av-opciones { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 14px; }
.av-reto[data-escena="burbujas"] .av-opcion {
  aspect-ratio: 1; min-height: 0; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .85);
  background: radial-gradient(circle at 30% 28%, rgba(255, 255, 255, .9) 0 8%, rgba(255, 255, 255, .25) 9% 40%, rgba(255, 255, 255, .08) 70%);
  color: #fff; text-shadow: 0 2px 3px rgba(0, 40, 80, .6); box-shadow: inset 0 0 18px rgba(255, 255, 255, .5);
  animation: subeBurbuja 3.4s ease-in-out infinite;
}
.av-reto[data-escena="burbujas"] .av-opcion:nth-child(2) { animation-delay: -1.1s; }
.av-reto[data-escena="burbujas"] .av-opcion:nth-child(3) { animation-delay: -2.2s; }
.av-reto[data-escena="burbujas"] .av-opcion.mal { animation: pinchado .5s forwards; }
.av-reto[data-escena="burbujas"] .av-opcion.revienta { animation: pinchado .6s forwards; border-color: #FFC93C; }
@keyframes subeBurbuja { 50% { transform: translateY(-10px); } }

/* ---------- Pizarra ---------- */
.av-reto[data-escena="pizarra"] { background: #2F4A3A; border: 10px solid #8A5A1E; color: #F4F1EA; }
.av-reto[data-escena="pizarra"] .av-pregunta, .av-reto[data-escena="pizarra"] .av-cuenta { color: #F4F1EA; font-family: 'Comic Sans MS', 'Chalkboard SE', var(--letra-titulo); }
.av-reto[data-escena="pizarra"] .av-asignatura { background: rgba(255, 255, 255, .15); color: #FFE7A8; }
.av-reto[data-escena="pizarra"] .av-texto { color: var(--tinta); }
.av-reto[data-escena="pizarra"] .av-opcion { background: transparent; color: #F4F1EA; border: 3px dashed rgba(255, 255, 255, .6); box-shadow: none; font-family: 'Comic Sans MS', 'Chalkboard SE', var(--letra-titulo); }
.av-reto[data-escena="pizarra"] .av-opcion.bien { background: rgba(61, 190, 110, .35); border-style: solid; color: #fff; }
.av-reto[data-escena="pizarra"] .av-opcion.mal { background: rgba(255, 111, 89, .3); }
.av-reto[data-escena="pizarra"] .av-escrito { background: transparent; color: #F4F1EA; border-color: rgba(255, 255, 255, .6); }
.av-reto[data-escena="pizarra"] .av-escrito.bien { background: rgba(61, 190, 110, .35); border-color: #8FE0A8; }
.av-reto[data-escena="pizarra"] .av-escrito.mal { background: rgba(255, 111, 89, .3); border-color: var(--coral); }

/* ---------- Cohete (teclado de números) ---------- */
.av-reto[data-escena="cohete"] { background: linear-gradient(180deg, #141836 0%, #3B3F9E 70%, #E8762B 100%); color: #fff; }
.av-reto[data-escena="cohete"] .av-pregunta, .av-reto[data-escena="cohete"] .av-cuenta { color: #fff; }
.av-reto[data-escena="cohete"] .av-asignatura { background: rgba(255, 255, 255, .15); color: #FFE7A8; }
.av-reto[data-escena="cohete"] .escena-deco { height: 64px; }
.cohete-nave { font-size: 54px; position: absolute; right: 10px; top: 0; transition: transform 1.2s cubic-bezier(.6, 0, .9, .4); }
.cohete-nave.despega { transform: translateY(-500px) rotate(-10deg); }
.av-reto[data-escena="cohete"] .teclado button { background: #2A2F6B; color: #fff; box-shadow: 0 4px 0 #11143A; }
.av-reto[data-escena="cohete"] .teclado button.tecla-ok { background: #E8762B; box-shadow: 0 4px 0 #A64B12; }

/* ---------- Caja fuerte ---------- */
.av-reto[data-escena="cajafuerte"] { background: linear-gradient(180deg, #D9DEE6, #9AA3B2); }
.av-reto[data-escena="cajafuerte"] .escena-deco { display: flex; justify-content: center; margin-bottom: 6px; }
.caja-fuerte { position: relative; width: 84px; height: 72px; border-radius: 10px; background: #2B2540; box-shadow: 0 6px 0 #11101A; overflow: visible; }
.caja-premio { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.caja-puerta { position: absolute; inset: 4px; border-radius: 8px; background: linear-gradient(135deg, #8E9AAF, #5C677D); transform-origin: left center; transition: transform 1s; z-index: 1; display: flex; align-items: center; justify-content: center; }
.caja-puerta i { width: 30px; height: 30px; border-radius: 50%; border: 5px solid #D4A017; background: #2B2540; }
.caja-puerta.abre { transform: perspective(300px) rotateY(-100deg); }
.av-reto[data-escena="cajafuerte"] .teclado button { background: #EEF1F6; box-shadow: 0 4px 0 #7A8396; }
.av-reto[data-escena="cajafuerte"] .teclado button.tecla-ok { background: #2E9A57; box-shadow: 0 4px 0 #1E6B3A; }

/* ---------- Tren (ordenar) ---------- */
.av-reto[data-escena="tren"] { background: linear-gradient(180deg, #FFF1D6 0%, #FFF1D6 70%, #C9E7C0 70%); }
.av-reto[data-escena="tren"] .escena-deco { text-align: left; font-size: 46px; height: 52px; }
.av-reto[data-escena="tren"] .av-orden-respuesta { border-bottom: 6px solid #6B4423; border-radius: 0; background: repeating-linear-gradient(90deg, transparent 0 18px, rgba(107, 68, 35, .25) 18px 22px) bottom / 100% 10px no-repeat; }
.av-reto[data-escena="tren"] .av-pieza { background: #E8762B; color: #fff; border: none; border-radius: 10px 10px 4px 4px; box-shadow: 0 4px 0 #A64B12; position: relative; }
.av-reto[data-escena="tren"] .av-orden-respuesta .av-pieza::after { content: "● ●"; position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); color: #2B2540; font-size: 12px; letter-spacing: 6px; }
.av-orden-respuesta.arranca { animation: arranca 1.4s ease-in forwards; }
@keyframes arranca { 20% { transform: translateX(-6px); } to { transform: translateX(110%); opacity: 0; } }

/* ---------- Tienda (monedas) ---------- */
.av-reto[data-escena="tienda"] { background: linear-gradient(180deg, #FFF6E5, #FFE7A8); padding-top: 0; }
.tienda-toldo { height: 26px; margin: 0 -18px 8px; background: repeating-linear-gradient(90deg, #E85D4F 0 26px, #fff 26px 52px); border-radius: 0 0 14px 14px; box-shadow: 0 4px 0 rgba(0, 0, 0, .1); }
.tienda-producto { font-size: 54px; line-height: 1; animation: flotar 3s ease-in-out infinite; }

/* ---------- Pergamino (escribir) ---------- */
.av-reto[data-escena="pergamino"] { background: linear-gradient(180deg, #F6E7C1, #EAD3A0); border: 3px solid #C9A86A; }
.av-reto[data-escena="pergamino"] .pluma { position: absolute; right: 8px; top: -6px; font-size: 40px; transform: rotate(20deg); }
.av-reto[data-escena="pergamino"] .av-input { background: rgba(255, 255, 255, .6); border-color: #C9A86A; font-family: 'Segoe Print', 'Bradley Hand', var(--letra-titulo); }

/* ---------- Cartas (emparejar) ---------- */
.av-reto[data-escena="cartas"] { background: linear-gradient(180deg, #2E86C1, #1B4F72); }
.av-reto[data-escena="cartas"] .av-pregunta { color: #fff; }
.av-reto[data-escena="cartas"] .av-parejas .av-pieza { background: #fff; border: 3px solid #D4A017; border-radius: 12px; box-shadow: 0 5px 0 rgba(0, 0, 0, .25); }
.av-reto[data-escena="cartas"] .av-parejas .av-pieza.elegida { transform: translateY(-4px) rotate(-2deg); border-color: var(--coral); }

/* Ahorro de batería: sin animaciones continuas */
body.ahorro .av-reto[data-escena] .av-opcion, body.ahorro .av-reto[data-escena]::before, body.ahorro .tienda-producto { animation: none !important; }
