:root {
  --miel: #f6b73c;
  --miel-osc: #e39424;
  --rojo: #d7262f;
  --crema: #fff6e0;
  --cafe: #5b3714;
  --verde: #8cbf5a;
  --cielo-1: #bfe6ff;
  --cielo-2: #fff3d6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Fredoka", system-ui, sans-serif;
  color: var(--cafe);
  background: linear-gradient(180deg, var(--cielo-1) 0%, var(--cielo-2) 70%, #ffe7b0 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.oculto { opacity: 0; pointer-events: none; }

#cielo { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.flotante { position: absolute; bottom: -40px; font-size: 22px; animation: subir linear forwards; opacity: .85; }
.abeja { position: absolute; font-size: 22px; animation: volar linear forwards; }

@keyframes subir {
  to { transform: translateY(-115vh) rotate(25deg); opacity: 0; }
}
@keyframes volar {
  0%   { transform: translate(-10vw, 0); }
  25%  { transform: translate(25vw, -30px); }
  50%  { transform: translate(55vw, 20px); }
  75%  { transform: translate(85vw, -25px); }
  100% { transform: translate(115vw, 0); }
}

#app {
  position: relative;
  z-index: 1;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.pantalla {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: calc(100dvh - 48px);
}
.pantalla.activa { display: flex; animation: entrar .6s cubic-bezier(.2,.9,.3,1.2); }
@keyframes entrar { from { opacity: 0; transform: translateY(24px) scale(.97); } }

/* ---------- Osito ---------- */
.escena { display: flex; flex-direction: column; align-items: center; }
.slot-oso { width: 210px; }
.oso { width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 10px 12px rgba(91,55,20,.18)); }
.oso-cabeza { transform-box: view-box; transform-origin: 100px 140px; animation: cabecear 3s ease-in-out infinite; }
.brazo-der { transform-box: view-box; transform-origin: 146px 158px; animation: saludar 1s ease-in-out infinite; }
.ojos { transform-box: view-box; transform-origin: 100px 88px; animation: parpadear 4s infinite; }
@keyframes saludar { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(22deg); } }
@keyframes cabecear { 0%,100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
@keyframes parpadear { 0%,92%,100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

.triste .boca { d: path("M88 120 Q100 110 112 120"); }
.triste .brazo-der { animation: none; transform: rotate(60deg); }

.burbuja {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 16px 20px;
  font-size: 1.2rem;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 8px 20px rgba(91,55,20,.12);
  max-width: 320px;
  min-height: 3.2em;
  margin-bottom: 14px;
}
.burbuja::after {
  content: ""; position: absolute; bottom: -12px; left: 50%; transform: translateX(-50%);
  border: 12px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.cursor::after { content: "|"; animation: titilar .8s steps(1) infinite; margin-left: 2px; }
@keyframes titilar { 50% { opacity: 0; } }

/* ---------- Tarjetas y botones ---------- */
.tarjeta {
  width: 100%;
  background: var(--crema);
  border: 3px solid var(--miel);
  border-radius: 28px;
  padding: 22px 18px;
  box-shadow: 0 12px 0 var(--miel-osc), 0 18px 30px rgba(91,55,20,.15);
  display: flex; flex-direction: column; gap: 14px;
}

input[type=password] {
  font: inherit; font-size: 1.15rem;
  padding: 14px 16px; border-radius: 16px;
  border: 2px solid #f0d49a; background: #fff; color: var(--cafe);
  text-align: center; outline: none;
}
input[type=password]:focus { border-color: var(--miel-osc); box-shadow: 0 0 0 4px rgba(246,183,60,.3); }

.boton {
  font: inherit; font-weight: 600; font-size: 1.15rem;
  border: 0; border-radius: 999px; cursor: pointer;
  padding: 14px 28px;
  color: #fff; background: var(--rojo);
  box-shadow: 0 6px 0 #a3171f;
  transition: transform .1s, box-shadow .1s, opacity .4s;
}
.boton:active { transform: translateY(4px); box-shadow: 0 2px 0 #a3171f; }
.boton:disabled { opacity: .45; cursor: default; }

.aviso-camara { margin: 0; font-size: .85rem; text-align: center; opacity: .75; }

.temblar { animation: temblar .45s; }
@keyframes temblar {
  20% { transform: translateX(-10px); } 40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); } 80% { transform: translateX(6px); }
}

/* ---------- Pregunta ---------- */
.marcador { width: 100%; display: flex; align-items: center; gap: 12px; }
.progreso {
  flex: 1; position: relative; height: 26px; border-radius: 999px;
  background: #fff; border: 3px solid var(--miel); overflow: hidden;
}
.miel {
  height: 100%; width: 0;
  background: repeating-linear-gradient(45deg, var(--miel) 0 12px, #f9c75a 12px 24px);
  transition: width .8s cubic-bezier(.3,1.3,.5,1);
}
.progreso span { position: absolute; inset: 0; display: grid; place-items: center; font-size: .8rem; font-weight: 600; }
.vidas { font-size: 1.4rem; letter-spacing: 2px; }
.vidas .perdido { filter: grayscale(1); opacity: .35; }
.vidas .rompiendo { display: inline-block; animation: romper .7s; }
@keyframes romper { 50% { transform: scale(1.6) rotate(-15deg); } }

.pregunta h2 { margin: 0; font-size: 1.4rem; text-align: center; line-height: 1.3; }
.pista { margin: 0; font-size: .85rem; text-align: center; opacity: .7; }
.opciones { display: flex; flex-direction: column; gap: 10px; }
.opcion {
  font: inherit; font-size: 1.05rem; text-align: left;
  padding: 14px 16px; border-radius: 18px; cursor: pointer;
  background: #fff; color: var(--cafe); border: 2px solid #f0d49a;
  display: flex; align-items: center; gap: 12px;
  transition: transform .15s, background .2s, border-color .2s;
}
.opcion .marca { width: 26px; height: 26px; flex: none; display: grid; place-items: center; border: 2px solid var(--miel); border-radius: 50%; font-size: .9rem; }
.opcion.multiple .marca { border-radius: 8px; }
.opcion.elegida { background: #fff1c7; border-color: var(--miel-osc); transform: scale(1.02); }
.opcion.elegida .marca { background: var(--miel); color: #fff; }
.mensaje-pooh { margin: 0; min-height: 1.4em; text-align: center; font-weight: 500; color: var(--rojo); }

/* ---------- Cartas ---------- */
.carta {
  position: relative; width: 100%;
  background: #fffdf6 repeating-linear-gradient(transparent 0 33px, #f3e2bd 33px 34px);
  border-radius: 6px 6px 22px 22px;
  padding: 40px 22px 26px;
  box-shadow: 0 16px 40px rgba(91,55,20,.2);
  animation: desplegar 1s cubic-bezier(.2,.9,.3,1.1);
  transform-origin: top center;
}
@keyframes desplegar { from { transform: perspective(600px) rotateX(-80deg); opacity: 0; } }
.sello {
  position: absolute; top: -22px; left: 50%; transform: translateX(-50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--rojo); display: grid; place-items: center; font-size: 1.3rem;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
}
.manuscrito {
  margin: 0; white-space: pre-line;
  font-family: "Caveat", cursive; font-size: 1.65rem; line-height: 34px;
  color: #4a2a0e;
}

/* ---------- Final ---------- */
#p-final { justify-content: flex-start; padding-top: 10px; }
body.modo-final {
  background: linear-gradient(180deg, #2b2161 0%, #b05b8c 45%, #ffb36b 80%, #ffe2a8 100%);
  background-attachment: fixed;
}
body.modo-final .flotante { opacity: 1; }
.final-oso { position: relative; animation: flotar 4s ease-in-out infinite; margin-top: 70px; }
.final-oso .slot-oso { width: 160px; }
.final-oso .brazo-der { animation: none; transform: rotate(-30deg); }
.globo-rojo {
  position: absolute; left: 132px; top: -96px; width: 70px; height: 84px;
  background: radial-gradient(circle at 35% 30%, #ff7a80, var(--rojo) 60%, #9e1119);
  border-radius: 50% 50% 48% 48%;
  box-shadow: inset -6px -8px 0 rgba(0,0,0,.08);
}
.globo-rojo::after {
  content: ""; position: absolute; left: 34px; top: 84px; width: 2px; height: 90px;
  background: rgba(255,255,255,.8); transform: rotate(-14deg); transform-origin: top;
}
@keyframes flotar { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-16px); } }
.carta.final { background-color: rgba(255,253,246,.96); }
.para-siempre {
  margin: 0; font-family: "Caveat", cursive; font-size: 2.2rem; color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,.25);
  transition: opacity 2s;
}
#globos { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.globo { position: absolute; bottom: -90px; font-size: 44px; animation: subir linear forwards; }
.estrella { position: absolute; width: 3px; height: 3px; background: #fff; border-radius: 50%; animation: brillar 2s ease-in-out infinite; }
@keyframes brillar { 50% { opacity: .2; transform: scale(.5); } }

/* ---------- Cámara ---------- */
#video { position: fixed; width: 2px; height: 2px; opacity: 0; pointer-events: none; bottom: 0; right: 0; }
.camara-indicador {
  position: fixed; top: 12px; right: 12px; z-index: 5;
  background: rgba(255,255,255,.85); border-radius: 999px; padding: 4px 8px; font-size: .9rem;
  transition: opacity .4s;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ---------- Venom ---------- */
.venom, .venom-pecho { opacity: 0; transform-box: view-box; transform-origin: 100px 100px; transform: scale(.2); }
.es-venom .venom, .es-venom .venom-pecho { animation: simbionte 1.6s cubic-bezier(.3,1.4,.5,1) .4s forwards; }
.es-venom .camisa { fill: #0d0d12; transition: fill .8s .6s; }
.es-venom .manga { stroke: #0d0d12; transition: stroke .8s .6s; }
.es-venom .oso { filter: drop-shadow(0 0 18px rgba(120,0,160,.45)); }
@keyframes simbionte {
  0%   { opacity: 0; transform: scale(.2) rotate(-20deg); }
  60%  { opacity: 1; transform: scale(1.12) rotate(4deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.oso-escrito { display: none; width: 150px; }
.oso-escrito.visible { display: block; }
.libro .slot-oso { width: 120px; margin: 4px auto 18px; }

/* ---------- El libro ---------- */
.libro {
  width: 100%;
  background: #fbf3e2;
  border-radius: 4px 14px 14px 4px;
  border-left: 10px solid #7a4a1c;
  padding: 30px 22px;
  box-shadow: 0 18px 40px rgba(91,55,20,.25), inset 8px 0 14px -10px rgba(0,0,0,.3);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem; line-height: 1.7; color: #3d2a17;
}
.libro h1 { font-family: "Caveat", cursive; font-size: 2.4rem; line-height: 1.1; margin: 0 0 6px; text-align: center; color: var(--rojo); }
.libro .subtitulo { text-align: center; margin-top: 0; opacity: .75; }
.libro p { margin: 0 0 1em; opacity: 0; transform: translateY(12px); transition: opacity 1.2s, transform 1.2s; }
.libro p.leido, .libro h1 { opacity: 1; transform: none; }
.libro p:last-child { font-size: 1.1rem; }

/* ---------- Mensaje de ella ---------- */
textarea {
  font: inherit; font-family: "Caveat", cursive; font-size: 1.5rem; line-height: 1.3;
  padding: 14px; border-radius: 16px; border: 2px solid #f0d49a; background: #fffdf6;
  color: #4a2a0e; resize: vertical; outline: none;
}
textarea:focus { border-color: var(--miel-osc); box-shadow: 0 0 0 4px rgba(246,183,60,.3); }

/* ---------- Disculpa ---------- */
.titulo-perdon { margin: 10px 0 0; font-family: "Caveat", cursive; font-size: 2.6rem; color: var(--cafe); }
.carta.disculpa { background-color: #fdfaf4; }

/* ---------- Cuenta regresiva y destrucción ---------- */
.cuenta {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 12vh; pointer-events: none;
  background: linear-gradient(180deg, transparent 40%, rgba(10,4,20,.75));
  color: #fff; text-align: center; transition: opacity .6s;
}
.cuenta p { margin: 0 16px; font-family: "Caveat", cursive; font-size: 1.7rem; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.cuenta .numero { font-size: 6rem; font-weight: 600; line-height: 1; text-shadow: 0 0 30px rgba(255,140,60,.9); }
.cuenta .numero.latido { animation: latido .9s ease-out; }
.cuenta.urgente .numero { color: #ff5a5a; text-shadow: 0 0 40px rgba(255,0,0,.9); }
@keyframes latido { from { transform: scale(1.6); opacity: .3; } }
body.temblando #app { animation: temblar .35s infinite; }

body.desintegrando #app > *, body.desintegrando #globos, body.desintegrando #cielo, body.desintegrando .cuenta {
  animation: ceniza 2.8s ease-in forwards;
}
@keyframes ceniza {
  30%  { filter: sepia(1) brightness(.6) blur(1px); }
  100% { filter: grayscale(1) brightness(0) blur(14px); opacity: 0; transform: translateY(-60px) scale(1.08) skewX(8deg); }
}
body.cenizas { background: #050307 !important; }
.destruido {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: #050307; color: #b9a99a; text-align: center; padding: 16px;
  transition: opacity 3s;
}
.destruido.oculto { display: none; }
.destruido p { margin: 0; font-size: 2.4rem; }
.destruido .frase { font-family: "Caveat", cursive; font-size: 1.7rem; opacity: .7; }
