/* Sorpify Dash: pantallas encima del lienzo 3D. Colores y letra de Sorpify (Poppins, verde bosque, amarillo sorpresa). */
:root { --bosque: #166534; --rescate: #22c55e; --rescate-osc: #16a34a; --sorpresa: #facc15; --sorpresa-osc: #ca9a04; --noche: #0c1a33; --tinta: #1f2937; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--noche); font-family: 'Poppins', system-ui, sans-serif; color: #fff; touch-action: none; -webkit-user-select: none; user-select: none; }
#escena { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
:focus-visible { outline: 3px solid var(--sorpresa); outline-offset: 3px; }
[hidden] { display: none !important; }

/* Pantallas (inicio, tutorial, pausa, resultado) */
.pantalla { position: fixed; inset: 0; z-index: 20; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 16px; background: radial-gradient(120% 90% at 50% 0%, rgba(23, 48, 92, .82), rgba(12, 26, 51, .92)); overflow-y: auto; touch-action: pan-y; }
/* En pantallas anchas el menú va a la izquierda y la mascota se ve a la derecha */
@media (min-width: 900px) and (min-aspect-ratio: 6/5) {
    #inicio, #tienda { justify-items: start; padding-left: 6vw; background: linear-gradient(90deg, rgba(12, 26, 51, .92) 0%, rgba(12, 26, 51, .6) 45%, rgba(12, 26, 51, 0) 70%); }
}
.tarjeta { width: min(100%, 560px); background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); border-radius: 26px; padding: 22px; backdrop-filter: blur(6px); display: flex; flex-direction: column; gap: 12px; }
.tarjeta h1 { margin: 0; font-size: clamp(2.2rem, 9vw, 3.4rem); font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.tarjeta h1 span { color: var(--rescate); }
.tarjeta h2 { margin: 6px 0 0; font-size: 1.05rem; font-weight: 700; color: #bfdbfe; }
.lema { margin: 0; color: #dbeafe; }
.volver { color: #d1fae5; text-decoration: none; font-weight: 600; font-size: .88rem; }
.volver:hover { color: var(--sorpresa); }

.boton { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 12px 22px; border-radius: 16px; border: 0; font: 800 1.05rem 'Poppins', sans-serif; cursor: pointer; text-decoration: none; transition: transform .12s ease; }
.boton:active { transform: translateY(3px); }
.boton-amarillo { background: var(--sorpresa); color: var(--tinta); box-shadow: 0 5px 0 var(--sorpresa-osc); }
.boton-verde { background: var(--rescate); color: #fff; box-shadow: 0 5px 0 var(--rescate-osc); }
.boton-claro { background: rgba(255, 255, 255, .1); color: #fff; border: 1.5px solid rgba(255, 255, 255, .3); }
.boton:disabled { opacity: .5; cursor: not-allowed; }

#cuenta { font-size: .9rem; color: #dbeafe; background: rgba(0, 0, 0, .2); border-radius: 14px; padding: 10px 14px; }
#cuenta a { color: var(--sorpresa); font-weight: 700; }
#cuenta .malo { color: #fca5a5; font-weight: 700; }

.mascotas { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.mascota { flex: 0 0 auto; min-width: 92px; padding: 10px; border-radius: 16px; border: 2px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06); color: #fff; font: 600 .82rem 'Poppins', sans-serif; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mascota i { font-size: 1.5rem; color: var(--sorpresa); }
.mascota[aria-checked="true"] { border-color: var(--sorpresa); background: rgba(250, 204, 21, .14); }
.mascota small { color: #bfdbfe; font-weight: 500; }

.niveles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.nivel { aspect-ratio: 1; border-radius: 14px; border: 2px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .06); color: #fff; font: 800 1.15rem 'Poppins', sans-serif; cursor: pointer; display: grid; place-items: center; }
.nivel[aria-checked="true"] { background: var(--rescate); border-color: #bbf7d0; }
.nivel:disabled { opacity: .35; cursor: not-allowed; }
.premio { margin: 0; font-size: .9rem; color: #fde68a; }
.enlaces { margin: 0; font-size: .85rem; text-align: center; }
.enlaces a { color: #d1fae5; }

.controles { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.controles li { display: flex; gap: 12px; align-items: center; background: rgba(0, 0, 0, .2); border-radius: 14px; padding: 10px 12px; font-size: .9rem; }
.controles i { width: 28px; text-align: center; font-size: 1.2rem; color: var(--sorpresa); }

.resumen-partida { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.resumen-partida div { background: rgba(0, 0, 0, .25); border-radius: 14px; padding: 10px; text-align: center; display: flex; flex-direction: column; }
.resumen-partida span { font-size: .75rem; color: #bfdbfe; text-transform: uppercase; letter-spacing: .05em; }
.resumen-partida b { font-size: 1.4rem; }
#resultado-titulo { font-size: 1.8rem; color: #fff; text-align: center; }

/* HUD */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.hud-arriba { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; align-items: center; gap: 10px; }
.hud-nivel { flex: 1; min-width: 0; font-weight: 800; font-size: .9rem; text-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
#hud-nivel { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra { height: 10px; border-radius: 6px; background: rgba(0, 0, 0, .35); overflow: hidden; margin-top: 4px; }
#hud-progreso { height: 100%; width: 0; background: linear-gradient(90deg, var(--rescate), var(--sorpresa)); }
.hud-datos { display: flex; gap: 12px; align-items: center; font-weight: 800; background: rgba(0, 0, 0, .3); border-radius: 999px; padding: 6px 14px; }
.hud-datos i { color: #67e8f9; }
#hud-vidas { color: #f87171; letter-spacing: 2px; }
.redondo { pointer-events: auto; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .4); color: #fff; font-size: 1rem; cursor: pointer; }
#hud-salvaje { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); left: 10px; display: flex; gap: 5px; align-items: center; background: rgba(0, 0, 0, .3); border-radius: 999px; padding: 5px 10px; color: #fca5a5; }
#hud-salvaje span { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #f87171; }
#hud-salvaje span.lleno { background: #ef4444; }
#hud-salvaje.activo { background: #b91c1c; color: #fff; }
#hud-x2 { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 54px); right: 10px; background: var(--sorpresa); color: var(--tinta); font-weight: 800; border-radius: 999px; padding: 4px 14px; }
#aviso { position: absolute; top: 34%; left: 0; right: 0; text-align: center; font-size: clamp(1.4rem, 6vw, 2.6rem); font-weight: 800; text-shadow: 0 3px 10px rgba(0, 0, 0, .6); opacity: 0; transition: opacity .2s; }
#aviso.visible { opacity: 1; }

/* Turbo: en todos los dispositivos; en táctil, encima de las flechas */
#boton-turbo { pointer-events: auto; position: absolute; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); width: 104px; height: 104px; border-radius: 50%;
    border: 3px solid var(--sorpresa); background: rgba(12, 26, 51, .55); color: #fff; font-family: 'Poppins', sans-serif; cursor: pointer; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; touch-action: none; }
#boton-turbo i { font-size: 1.5rem; color: var(--sorpresa); position: relative; }
#boton-turbo b { font-size: .85rem; letter-spacing: .08em; position: relative; }
#boton-turbo small { font-size: .62rem; color: #bfdbfe; position: relative; }
#turbo-energia { position: absolute; left: 0; bottom: 0; height: 100%; width: 100%; background: linear-gradient(0deg, rgba(250, 204, 21, .45), rgba(250, 204, 21, .15)); transition: width .1s linear; }
#boton-turbo.activo { transform: scale(1.08); box-shadow: 0 0 24px rgba(250, 204, 21, .8); }
@media (pointer: coarse) { #boton-turbo { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 74px); width: 92px; height: 92px; } #boton-turbo small { display: none; } }

/* Tienda */
.volver-boton { align-self: flex-start; background: none; border: 0; color: #d1fae5; font: 600 .88rem 'Poppins', sans-serif; cursor: pointer; padding: 4px 0; }
.volver-boton:hover { color: var(--sorpresa); }
.titulo-tienda { font-size: 1.6rem !important; color: #fff !important; }
.titulo-tienda i { color: var(--sorpresa); }
.tienda-saldo { margin: 0; font-weight: 700; color: #fde68a; }
.tienda-lista { display: grid; gap: 12px; }
.pestanas-tienda { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: rgba(0, 0, 0, .25); border-radius: 16px; padding: 5px; }
.pestanas-tienda button { min-height: 44px; border: 0; border-radius: 12px; background: transparent; color: #cbd5e1; font: 700 .95rem 'Poppins', sans-serif; cursor: pointer; }
.pestanas-tienda button[aria-selected="true"] { background: var(--sorpresa); color: var(--tinta); }
.articulo.con-imagen { grid-template-columns: 96px 1fr; }
.miniatura { grid-row: span 2; width: 96px; height: 96px; border-radius: 16px; background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, .22), rgba(255, 255, 255, .04)); object-fit: contain; }
.miniatura:not([src]) { animation: parpadeo 1s infinite alternate; }
@keyframes parpadeo { to { opacity: .4; } }
.etiqueta-falta { color: #cbd5e1; font-size: .85rem; font-weight: 600; }
.subtitulo-tienda { margin: 8px 0 0 !important; font-size: 1rem !important; color: #fde68a !important; text-transform: uppercase; letter-spacing: .06em; }
/* 50 niveles: cuadrícula compacta con desplazamiento */
.niveles { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)) !important; max-height: 230px; overflow-y: auto; padding-right: 4px; }
.articulo { display: grid; grid-template-columns: 56px 1fr; gap: 6px 14px; align-items: center; background: rgba(0, 0, 0, .25); border: 1.5px solid rgba(255, 255, 255, .15); border-radius: 18px; padding: 14px; }
.articulo.tuyo { border-color: var(--rescate); }
.articulo > i { grid-row: span 2; width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; font-size: 1.6rem; background: rgba(250, 204, 21, .15); color: var(--sorpresa); }
.articulo h3 { margin: 0; font-size: 1.05rem; }
.articulo p { margin: 0; font-size: .82rem; color: #cbd5e1; }
.articulo .acciones { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.articulo .boton { min-height: 44px; padding: 8px 16px; font-size: .9rem; }
.etiqueta-tuyo { display: inline-flex; align-items: center; gap: 6px; color: #86efac; font-weight: 800; }

/* Cohete (accesorio): encima del turbo; el borde se llena mientras se recarga */
#boton-cohete { pointer-events: auto; position: absolute; right: 30px; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 116px); width: 80px; height: 80px;
    border-radius: 50%; border: 0; color: #fff; font-family: 'Poppins', sans-serif; cursor: pointer; touch-action: none;
    background: radial-gradient(circle, rgba(12, 26, 51, .9) 62%, transparent 63%), conic-gradient(#fb923c var(--carga, 360deg), rgba(255, 255, 255, .2) 0);
    display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: .55; }
#boton-cohete.listo { opacity: 1; box-shadow: 0 0 18px rgba(251, 146, 60, .8); }
#boton-cohete i { font-size: 1.3rem; color: #fb923c; }
#boton-cohete b { font-size: .7rem; letter-spacing: .06em; }
#boton-cohete small { font-size: .6rem; color: #bfdbfe; }
@media (pointer: coarse) { #boton-cohete { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 178px); right: 24px; width: 72px; height: 72px; } #boton-cohete small { display: none; } }

/* Multijugador: amigos, sala, posiciones en vivo y resultado */
.mi-codigo { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.mi-codigo b, .codigo-grande { font-size: 1.3rem; letter-spacing: .12em; color: var(--sorpresa); }
.mi-codigo .boton { min-height: 38px; padding: 6px 14px; font-size: .85rem; }
.fila-form { display: flex; gap: 8px; }
.fila-form input { flex: 1; min-width: 0; min-height: 48px; border-radius: 14px; border: 1.5px solid rgba(255, 255, 255, .3); background: rgba(0, 0, 0, .25);
    color: #fff; font: 600 1rem 'Poppins', sans-serif; padding: 0 14px; text-transform: uppercase; letter-spacing: .08em; }
.fila-form .boton { min-height: 48px; }
.amigo { display: flex; align-items: center; gap: 12px; background: rgba(0, 0, 0, .25); border: 1.5px solid rgba(255, 255, 255, .15); border-radius: 16px; padding: 10px 14px; }
.amigo .avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: none; background: radial-gradient(circle at 50% 35%, #fff, #bbf7d0); }
.amigo .punto { width: 10px; height: 10px; border-radius: 50%; background: #64748b; flex: none; }
.amigo .punto.en-linea { background: var(--rescate); box-shadow: 0 0 8px var(--rescate); }
.amigo div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.amigo small { color: #cbd5e1; }
.amigo .boton { min-height: 40px; padding: 6px 14px; font-size: .85rem; }
.invitacion { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: linear-gradient(90deg, rgba(34, 197, 94, .3), rgba(250, 204, 21, .2));
    border: 1.5px solid var(--rescate); border-radius: 16px; padding: 10px 14px; font-weight: 600; }
.invitacion .boton { min-height: 40px; padding: 6px 16px; font-size: .9rem; }
#ranking { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 90px); right: 10px; margin: 0; padding: 8px 10px 8px 30px; list-style: decimal;
    background: rgba(0, 0, 0, .4); border-radius: 14px; font-weight: 700; font-size: .85rem; min-width: 140px; }
#ranking li.yo { color: var(--sorpresa); }
#ranking li.fuera { opacity: .5; }
.resultado-carrera { margin: 0; padding-left: 28px; display: grid; gap: 6px; font-weight: 700; }
.resultado-carrera li.yo { color: var(--sorpresa); }

/* Disparo (niveles con enemigos): abajo a la izquierda, para el otro pulgar */
#boton-disparo { pointer-events: auto; position: absolute; left: 18px; bottom: max(18px, env(safe-area-inset-bottom)); width: 104px; height: 104px; border-radius: 50%;
    border: 3px solid #f97316; background: rgba(12, 26, 51, .55); color: #fff; font-family: 'Poppins', sans-serif; cursor: pointer; touch-action: none;
    display: flex; flex-direction: column; align-items: center; justify-content: center; }
#boton-disparo:active { transform: scale(.94); box-shadow: 0 0 24px rgba(249, 115, 22, .8); }
#boton-disparo i { font-size: 1.5rem; color: #fb923c; }
#boton-disparo b { font-size: .8rem; letter-spacing: .06em; }
#boton-disparo small { font-size: .62rem; color: #bfdbfe; }
@media (pointer: coarse) { #boton-disparo { bottom: calc(max(14px, env(safe-area-inset-bottom)) + 74px); width: 92px; height: 92px; } #boton-disparo small { display: none; } }

/* Bordes de pantalla: amarillo con turbo, rojo en forma salvaje */
body.modo-turbo #hud::before, body.modo-salvaje #hud::after { content: ''; position: absolute; inset: 0; pointer-events: none; }
body.modo-turbo #hud::before { box-shadow: inset 0 0 90px 10px rgba(250, 204, 21, .35); }
body.modo-salvaje #hud::after { box-shadow: inset 0 0 140px 30px rgba(239, 68, 68, .55); animation: pulso .5s infinite alternate; }
@keyframes pulso { to { opacity: .6; } }

/* Botones táctiles (además de deslizar): solo en pantallas táctiles */
.botones-tactiles { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 0; right: 0; display: none; justify-content: center; gap: 12px; }
.botones-tactiles button { pointer-events: auto; width: 58px; height: 58px; border-radius: 18px; border: 1.5px solid rgba(255, 255, 255, .35); background: rgba(0, 0, 0, .3); color: #fff; font-size: 1.2rem; }
@media (pointer: coarse) { .botones-tactiles { display: flex; } }

#cargando { z-index: 30; gap: 12px; align-content: center; }
.girando { width: 48px; height: 48px; border-radius: 50%; border: 5px solid rgba(255, 255, 255, .2); border-top-color: var(--sorpresa); animation: girar 1s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .girando { animation-duration: 3s; } .boton { transition: none; } }

/* Móvil tumbado (pantalla baja): el menú empieza arriba (centrado se cortaba) y «Jugar» queda siempre a la vista */
@media (orientation: landscape) and (max-height: 560px) {
    .pantalla { place-items: start center; align-content: start; padding: 10px 16px; }
    .tarjeta { padding: 16px 18px; gap: 9px; }
    #boton-jugar { position: sticky; bottom: 0; z-index: 2; }
    .botones-tactiles button { width: 50px; height: 50px; }
}
