:root {
  --bg: #0d0716;
  --bg-2: #1a0b2e;
  --purple: #6b2fa3;
  --purple-soft: #3a1a5c;
  --orange: #ff8a2b;
  --gold: #d4a64a;
  --parchment: #f4e9d8;
  --ink: #2a1a10;
  --potion: #7cff8a;
  --text: #ede4f5;
  --muted: #b9a8cc;
  --radius: 16px;
  --font-title: 'Cinzel Decorative', Georgia, serif;
  --font-body: 'Cormorant Garamond', Georgia, serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; overflow-x: clip; }

body {
  background: radial-gradient(ellipse at top, var(--bg-2), var(--bg) 70%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

.hidden { display: none !important; }

/* ---------- fondo: estrellas, luna y murciélagos ---------- */
.sky {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #fff8 50%, transparent),
    radial-gradient(1px 1px at 30% 70%, #fff6 50%, transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, #fff9 50%, transparent),
    radial-gradient(1px 1px at 75% 45%, #fff7 50%, transparent),
    radial-gradient(1px 1px at 90% 80%, #fff6 50%, transparent),
    radial-gradient(1.5px 1.5px at 20% 90%, #fff5 50%, transparent),
    radial-gradient(1px 1px at 65% 85%, #fff7 50%, transparent),
    radial-gradient(circle at 85% 8%, #ffe9b8 0 28px, #ffcf7a33 30px, transparent 90px);
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .7; } to { opacity: 1; } }

.bats { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: -1; }
.bats span {
  position: absolute; top: 12%; left: -40px; font-size: 22px; opacity: .55; z-index: -1;
  animation: fly 18s linear infinite;
}
.bats span:nth-child(2) { top: 30%; animation-delay: -7s; animation-duration: 23s; font-size: 16px; }
.bats span:nth-child(3) { top: 55%; animation-delay: -13s; animation-duration: 27s; font-size: 14px; }
@keyframes fly {
  0% { transform: translate(0, 0); }
  25% { transform: translate(30vw, -20px); }
  50% { transform: translate(60vw, 15px); }
  100% { transform: translate(115vw, -10px); }
}

.sound-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 50;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--purple); background: #0d0716cc; color: var(--text);
  font-size: 20px; cursor: pointer;
}

/* ---------- layout de pantallas ---------- */
main {
  max-width: 480px; margin: 0 auto;
  padding: 68px 16px calc(32px + env(safe-area-inset-bottom));
}

.screen { display: none; flex-direction: column; align-items: center; gap: 18px; text-align: center; }
.screen.active { display: flex; animation: appear .6s ease both; }
@keyframes appear { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.title {
  font-family: var(--font-title); font-size: 28px; line-height: 1.15; margin: -44px 40px 0;
  color: var(--orange); text-shadow: 0 0 18px #ff8a2b66;
}

.hint { color: var(--muted); font-style: italic; margin: 0; }
.footer-note { color: var(--muted); font-style: italic; font-size: 16px; }

.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; }

/* ---------- botones e inputs ---------- */
.btn {
  display: block; width: 100%; padding: 15px 20px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--purple), #8e44c9); color: #fff;
  font-family: var(--font-body); font-size: 20px; font-weight: 700; text-decoration: none;
  box-shadow: 0 6px 24px #6b2fa355; cursor: pointer; transition: transform .15s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--purple); box-shadow: none; }
.btn-small { padding: 10px 14px; font-size: 16px; }

.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; cursor: pointer; }

.input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--purple);
  background: #1a0b2ecc; color: var(--text); font-family: var(--font-body); font-size: 19px;
  resize: vertical;
}
.input:focus { outline: 2px solid var(--orange); border-color: transparent; }

/* ---------- la bruja ---------- */
.witch-says {
  position: relative; width: 100%; padding: 16px 18px;
  background: #1a0b2ee6; border: 1px solid var(--purple); border-radius: var(--radius);
  font-size: 20px; font-style: italic; min-height: 1em;
  box-shadow: 0 0 30px #6b2fa333;
}
.witch-says::before { content: '🧙‍♀️'; position: absolute; top: -16px; left: 14px; font-size: 26px; font-style: normal; }

/* Espacio delimitado para el arte de la bruja (foto o video, editable desde el panel). */
.witch-stage {
  position: relative; width: min(100%, 320px); aspect-ratio: 4 / 5;
  border-radius: 160px 160px 18px 18px; overflow: hidden;
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 6px #0d0716, 0 0 0 8px var(--purple), 0 0 50px #ff8a2b44;
  background: radial-gradient(circle at 50% 35%, #3a1a5c, #0d0716 75%);
}
.witch-stage.small { width: min(70%, 220px); }
.witch-media, .witch-media img, .witch-media video, .witch-media svg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
}
.fog { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; transition: opacity 1.2s; cursor: grab; }
.fog.cleared { opacity: 0; pointer-events: none; }

/* ---------- cartas del tarot ---------- */
.deck {
  position: relative; width: 100%; height: 230px; display: flex; justify-content: center; align-items: flex-end;
}
.tarot {
  position: absolute; bottom: 0; width: 92px; height: 148px; perspective: 800px;
  transform-origin: 50% 130%; cursor: pointer; transition: transform .5s, opacity .5s;
  border: 0; padding: 0; background: none;
}
.tarot .inner {
  position: absolute; inset: 0; transition: transform .8s cubic-bezier(.2,.8,.2,1); transform-style: preserve-3d;
}
.tarot.flipped .inner { transform: rotateY(180deg); }
.tarot .face {
  position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border: 2px solid var(--gold); box-shadow: 0 8px 20px #0008;
}
.tarot .back {
  background:
    radial-gradient(circle, transparent 28%, #0d0716 29% 31%, transparent 32%),
    repeating-linear-gradient(45deg, #3a1a5c 0 8px, #2a1047 8px 16px);
  color: var(--gold); font-size: 30px;
}
.tarot .front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, var(--parchment), #e2cfae); color: var(--ink);
  font-family: var(--font-title); font-size: 11px; padding: 6px;
}
.tarot .front .num { font-size: 18px; color: var(--purple); }
.tarot .front .big { font-size: 34px; }
.tarot:not(.flipped):hover .inner { transform: translateY(-10px); }
.tarot.gone { opacity: 0; pointer-events: none; }

/* ---------- modal de carta ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: #0d0716dd; backdrop-filter: blur(4px);
}
.modal-card {
  width: min(100%, 440px); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(170deg, var(--parchment), #e8d6b5); color: var(--ink);
  border-radius: var(--radius); padding: 22px 18px; border: 3px solid var(--gold);
  animation: appear .5s ease both; text-align: center;
}
.modal-card h2 { font-family: var(--font-title); color: var(--purple); margin: 0 0 8px; font-size: 22px; }
.modal-card > .btn { margin-top: 16px; }
.modal-card .btn-ghost { color: var(--purple); border-color: var(--purple); }
.modal-card .hint { color: #7a5a3a; }

/* ---------- elecciones (hechizos y ofrendas) ---------- */
.choices { display: grid; gap: 12px; width: 100%; }
.choice {
  position: relative; display: flex; gap: 14px; align-items: center; text-align: left;
  padding: 14px 16px; border-radius: var(--radius); cursor: pointer;
  background: #1a0b2ecc; border: 1px solid var(--purple-soft); color: var(--text);
  font-family: var(--font-body); font-size: 18px; transition: border-color .2s, transform .15s, box-shadow .2s;
}
.choice:active { transform: scale(.98); }
.choice.selected { border-color: var(--orange); box-shadow: 0 0 20px #ff8a2b55; }
.choice .icon { font-size: 34px; flex: none; }
.choice strong { display: block; font-size: 20px; color: var(--orange); }
.choice small { color: var(--muted); font-size: 16px; }
.choice .badge {
  position: absolute; top: -10px; right: 10px; padding: 2px 10px; border-radius: 999px;
  background: var(--orange); color: #1a0b2e; font-size: 13px; font-weight: 700;
}

/* ---------- estado del caldero ---------- */
.cauldron-status { width: 100%; display: grid; gap: 8px; padding: 14px; border-radius: var(--radius); background: #0d0716aa; border: 1px dashed var(--purple); }
.cauldron-status h3 { margin: 0 0 4px; font-family: var(--font-title); font-size: 15px; color: var(--gold); }
.bar { display: grid; grid-template-columns: 30px 1fr 52px; align-items: center; gap: 8px; font-size: 15px; text-align: left; }
.bar .track { height: 10px; border-radius: 999px; background: #3a1a5c; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--potion), #3fd86a); transition: width 1s; }
.bar.low .fill { background: linear-gradient(90deg, var(--orange), #ff5e2b); }

.yape-box { width: 100%; padding: 16px; border-radius: var(--radius); background: #742284; border: 1px solid #c14fd8; }
.yape-box img { width: 180px; max-width: 70%; border-radius: 12px; background: #fff; padding: 6px; }
.yape-box .btn-ghost { border-color: #e7b3f2; }
.yape-box .phone { font-size: 26px; font-weight: 700; letter-spacing: 1px; margin: 6px 0; }
.check { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 10px; font-size: 18px; }
.check input { width: 22px; height: 22px; accent-color: var(--orange); }

/* ---------- caldero animado ---------- */
.cauldron-scene { position: relative; width: 240px; height: 280px; margin-top: 30px; }
.cauldron {
  position: absolute; bottom: 0; left: 20px; width: 200px; height: 150px;
  background: radial-gradient(ellipse at 40% 30%, #444, #111 70%);
  border-radius: 40% 40% 50% 50% / 30% 30% 70% 70%;
  box-shadow: inset 0 -10px 30px #000, 0 0 60px #7cff8a55;
}
.cauldron::before {
  content: ''; position: absolute; top: -8px; left: -10px; right: -10px; height: 30px;
  border-radius: 50%; background: radial-gradient(ellipse, var(--potion), #2a9c45 60%, #222 62%);
  box-shadow: 0 0 40px var(--potion); animation: glow 1s ease-in-out infinite alternate;
}
@keyframes glow { from { filter: brightness(.9); } to { filter: brightness(1.4); } }
.bubbles i {
  position: absolute; bottom: 140px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--potion); opacity: 0; animation: bubble 1.6s ease-in infinite;
}
.bubbles i:nth-child(1) { left: 60px; }
.bubbles i:nth-child(2) { left: 100px; animation-delay: .3s; width: 22px; height: 22px; }
.bubbles i:nth-child(3) { left: 140px; animation-delay: .7s; }
.bubbles i:nth-child(4) { left: 80px; animation-delay: 1s; width: 10px; height: 10px; }
.bubbles i:nth-child(5) { left: 165px; animation-delay: 1.2s; width: 12px; height: 12px; }
@keyframes bubble {
  0% { transform: translateY(0) scale(.5); opacity: .9; }
  100% { transform: translateY(-120px) scale(1.2); opacity: 0; }
}
.ingredient { position: absolute; top: 0; left: 50%; font-size: 48px; transform: translateX(-50%); animation: drop 1.4s ease-in .2s both; }
@keyframes drop {
  0% { transform: translate(-50%, -40px) rotate(0); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, 140px) rotate(360deg) scale(.4); opacity: 0; }
}

/* ---------- resultado ---------- */
.scroll {
  width: 100%; padding: 26px 20px; color: var(--ink); border-radius: 6px;
  background: linear-gradient(170deg, var(--parchment), #e2cfae);
  box-shadow: 0 10px 40px #0009, inset 0 0 40px #b8955a66;
  animation: unroll 1s ease both; transform-origin: top;
}
@keyframes unroll { from { transform: scaleY(.1); opacity: 0; } to { transform: none; opacity: 1; } }
.scroll h2 { font-family: var(--font-title); color: var(--purple); margin: 0 0 6px; font-size: 22px; }
.scroll .icon { font-size: 44px; }
.scroll p { font-size: 20px; font-style: italic; }
.scroll .signed { font-family: var(--font-title); font-size: 13px; color: #7a5a3a; }

.seal {
  width: 100%; padding: 18px; border-radius: var(--radius); background: #1a0b2ee6;
  border: 2px solid var(--gold); display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.seal img { width: 190px; height: 190px; border-radius: 10px; }
.seal .game-id { font-family: var(--font-title); font-size: 22px; color: var(--gold); letter-spacing: 1px; }
.seal small { color: var(--muted); font-size: 16px; }

/* ---------- invitación completa ---------- */
.card-block {
  width: 100%; text-align: left; padding: 18px; border-radius: var(--radius);
  background: #1a0b2ecc; border: 1px solid var(--purple-soft);
}
.card-block h2 { font-family: var(--font-title); font-size: 17px; color: var(--gold); margin: 0 0 10px; }
.card-block p { margin: 6px 0; }
.spell-text, .pre { white-space: pre-line; font-style: italic; }
.map {
  width: 100%; height: 220px; border: 0; border-radius: 12px; margin: 10px 0; filter: saturate(.8);
}
.nav-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.nav-buttons .btn { font-size: 16px; padding: 12px 10px; text-align: center; }
.nav-buttons .full { grid-column: 1 / -1; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  padding: 10px 18px; border-radius: 999px; background: var(--orange); color: #1a0b2e; font-weight: 700;
}

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