/* El Bacá: todo es oscuro. Las pantallas (ui.js) y la partida (game.js) se dibujan dentro de #app. */
:root {
  --bg: #050304; --ink: #e9dccb; --dim: #8d7f74; --blood: #b3121b; --ember: #ff7a2b;
  --top: calc(env(safe-area-inset-top) + var(--tint, 0px) + 14px);
  --bottom: calc(env(safe-area-inset-bottom) + 14px);
  --serif: 'Abril Fatface', Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { color: var(--ink); font: 17px/1.4 system-ui, -apple-system, sans-serif; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input { font: inherit; user-select: text; -webkit-user-select: text; }

#app { position: fixed; inset: 0; overflow: hidden; background: var(--bg); }
.screen {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: var(--top) 20px var(--bottom); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  background: radial-gradient(circle 80vmax at 50% 30%, #1d0709 0%, var(--bg) 60%);
}
.screen > :first-child { margin-top: auto; }
.screen > :last-child { margin-bottom: auto; }

h1.title { font: 400 clamp(52px, 17vw, 96px)/1 var(--serif); margin: 0; letter-spacing: .04em; animation: flicker 6s infinite; text-shadow: 0 0 24px rgba(179, 18, 27, .55); }
h2 { font: 400 30px/1.15 var(--serif); margin: 0; letter-spacing: .02em; }
.tag { color: var(--dim); max-width: 340px; margin: 0; }
.warn { color: #9a6a5a; font-size: 13px; max-width: 360px; margin: 0; }
.version { color: #4a3b35; font-size: 12px; }

.btn {
  display: block; width: min(320px, 100%); padding: 15px 18px; border-radius: 14px; border: 1px solid #5a1a1d;
  background: linear-gradient(#3a0c10, #1c0507); font: 400 22px/1 var(--serif); letter-spacing: .05em; color: var(--ink);
  box-shadow: 0 0 18px rgba(179, 18, 27, .25);
}
.btn:active { transform: scale(.97); filter: brightness(1.3); }
.btn.ghost { background: transparent; border-color: #3a2a26; box-shadow: none; font: 600 16px/1 system-ui, sans-serif; color: var(--dim); }
.btn:disabled { opacity: .4; }
.row { display: flex; gap: 10px; width: min(320px, 100%); }
.row > * { flex: 1; }

.code-in {
  width: min(320px, 100%); padding: 14px; border-radius: 14px; border: 1px solid #5a1a1d; background: #120506;
  color: var(--ink); text-align: center; font: 400 30px/1 var(--serif); letter-spacing: .3em; text-transform: uppercase;
}
.code { font: 400 64px/1 var(--serif); letter-spacing: .18em; color: var(--ink); text-shadow: 0 0 30px rgba(179, 18, 27, .7); }
.souls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 340px; }
.souls span { width: 38px; height: 54px; border-radius: 50% 50% 46% 46%; background: radial-gradient(circle at 50% 40%, #ffd28a 0 8%, #ff7a2b 14%, rgba(255, 122, 43, 0) 46%); animation: flame 1.6s infinite alternate; }
.souls span.off { filter: grayscale(1) brightness(.4); animation: none; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(340px, 100%); padding: 12px 14px; border-radius: 12px; background: #120607; border: 1px solid #2a1414; text-align: left; }
.opt b { display: block; }
.opt small { color: var(--dim); }
.opt input { width: 26px; height: 26px; accent-color: var(--blood); flex: none; }
.howto { text-align: left; max-width: 380px; color: #cbbcae; }
.howto p { margin: 0 0 10px; }
.howto b { color: var(--ink); }
.err { color: #ff6b6b; min-height: 20px; margin: 0; }

/* ---------- la partida ---------- */
#stage { position: absolute; inset: 0; background: #000; overflow: hidden; }
#stage .grain { position: absolute; inset: -50%; opacity: .07; pointer-events: none; animation: grain .5s steps(4) infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E"); }
#candle { position: absolute; left: 50%; bottom: calc(var(--bottom) - 40px); width: 340px; height: 340px; transform: translateX(-50%);
  background: radial-gradient(circle at 50% 70%, rgba(255, 170, 80, .22) 0, rgba(255, 110, 40, .08) 30%, transparent 62%);
  animation: glow 2.2s infinite alternate; pointer-events: none; transition: opacity 1.2s; }
#candle::after { content: ''; position: absolute; left: 50%; top: 58%; width: 12px; height: 26px; margin-left: -6px; border-radius: 50% 50% 40% 40%;
  background: radial-gradient(circle at 50% 70%, #fff3c4, #ff9a3c 55%, rgba(255, 90, 20, 0) 75%); animation: flame .9s infinite alternate; }
#stage.dark #candle { opacity: 0; }
/* de noche hay luz de vela: así se nota cuando se va */
#stage.night { background: radial-gradient(circle 70vmax at 50% 95%, #3a1c0c 0, #140805 45%, #050202 100%); }
#stage.night #candle { width: 520px; height: 520px; }
#stage.night.dark { background: #000; }
/* luz por dentro: --dim oscurece todo lo de abajo (y un poco el texto); #glow prende la pantalla */
#dim { position: absolute; inset: 0; background: #000; opacity: var(--dim, 0); pointer-events: none; transition: opacity 2s; }
#stage.night #msg, #stage.night #who { opacity: calc(1 - var(--dim, 0) * .55); transition: opacity 2s; }
#glow { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 40%, #fffaf0 0, #ffe9bf 60%, #f0c98a 100%); }
#glow.lit { opacity: 1; transition: opacity .25s; }
#glow.surge { animation: surge 3.2s linear forwards; }
#stage.glowing #msg, #stage.glowing #who { color: #2a1208; opacity: 1; }
#stage.glowing #msg * { text-shadow: none; }
#stage.glowing .btn.ghost { color: #4a2a1a; border-color: #b08a6a; }
@keyframes surge { 0% { opacity: 0; } 4% { opacity: .8; } 7% { opacity: .1; } 11% { opacity: 1; } 14% { opacity: .3; } 18%, 70% { opacity: 1; }
  73% { opacity: .2; } 76% { opacity: .9; } 80% { opacity: .1; } 84% { opacity: .6; } 86%, 100% { opacity: 0; } }
#off { position: absolute; inset: 0; z-index: 4; background: #000; opacity: 0; pointer-events: none; }
#off.flick { animation: flicker2 .9s steps(9); }
#off.on { opacity: 1; pointer-events: auto; }
#who { position: absolute; top: var(--top); left: 0; right: 0; text-align: center; color: #3e3230; font: 400 15px/1 var(--serif); letter-spacing: .25em; text-transform: uppercase; }
#msg { position: absolute; left: 22px; right: 22px; top: 50%; transform: translateY(-55%); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; max-height: 78%; overflow-y: auto; }
#msg .big { font: 400 clamp(26px, 8vw, 40px)/1.15 var(--serif); margin: 0; text-shadow: 0 0 18px rgba(0, 0, 0, .9); }
#msg .big.red { color: #e0343b; text-shadow: 0 0 24px rgba(224, 52, 59, .6); }
#msg .sub { color: var(--dim); margin: 0; }
#msg .fade { animation: appear 1.6s ease both; }
#msg .choices { display: flex; flex-direction: column; gap: 10px; width: min(320px, 100%); }
#msg .choices .btn { font-size: 20px; padding: 13px; }
.meter { width: 180px; height: 6px; border-radius: 9px; background: #1d0d0d; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--blood); transition: width .08s; }
.count { font: 400 120px/1 var(--serif); color: #2a1a18; }
#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#flash.red { animation: flash .9s ease-out; background: #a00; }
#flash.white { animation: flash 1.6s ease-out; background: #fff; }
#flash.flicker { animation: flicker2 .6s steps(6); background: #400; }
#cam { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); filter: grayscale(1) brightness(.35) contrast(1.6); opacity: 0; transition: opacity 1s; }
#cam.on { opacity: 1; }
#shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse 22% 34% at 72% 46%, rgba(0, 0, 0, .95), transparent 70%); }
#shade.on { opacity: 1; transition: opacity 2.5s; }
#notif { position: absolute; left: 10px; right: 10px; top: var(--top); padding: 12px 14px; border-radius: 18px; background: rgba(40, 40, 44, .92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); color: #fff; text-align: left; transform: translateY(-160%); transition: transform .45s cubic-bezier(.2, .9, .3, 1.2); font-size: 15px; }
#notif.on { transform: none; }
#notif small { color: #aaa; display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
#vela { position: absolute; right: 14px; bottom: var(--bottom); width: 46px; height: 46px; border-radius: 50%; border: 1px solid #2a1a18; background: #0c0606; font-size: 22px; opacity: .55; }
#calm { position: absolute; inset: 0; z-index: 5; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 30px; text-align: center; background: #f4ead8; color: #2a1a12; }
#calm.on { display: flex; }
#calm h2 { color: #2a1a12; }
.ghostui { display: flex; flex-direction: column; gap: 10px; width: min(320px, 100%); }
.ghostui select { padding: 12px; border-radius: 12px; background: #120607; color: var(--ink); border: 1px solid #5a1a1d; font: inherit; }
.album { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; width: min(360px, 100%); }
.album figure { margin: 0; }
.album img { width: 100%; border-radius: 10px; display: block; }
.album figcaption { font-size: 13px; color: var(--dim); }
.reveals { text-align: left; max-width: 360px; color: #cbbcae; margin: 0; padding-left: 20px; }

@keyframes flicker { 0%, 100% { opacity: 1; } 4% { opacity: .3; } 6% { opacity: 1; } 48% { opacity: 1; } 50% { opacity: .5; } 51% { opacity: 1; } }
@keyframes flicker2 { 0%, 40%, 80% { opacity: .9; } 20%, 60%, 100% { opacity: 0; } }
@keyframes flame { from { transform: scale(1, 1); opacity: .85; } to { transform: scale(.92, 1.08) translateY(-2px); opacity: 1; } }
@keyframes glow { from { opacity: .75; } to { opacity: 1; } }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes appear { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: none; } }
@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-5%, 3%); } 50% { transform: translate(4%, -4%); } 75% { transform: translate(-3%, -5%); } }
@media (prefers-reduced-motion: reduce) { h1.title, #candle, #candle::after, .grain, .souls span { animation: none !important; } }

/* el altavoz del Bacá (speaker.js) */
#spk { position: fixed; inset: 0; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 30px; text-align: center; }
#spk .eyes { display: flex; gap: 70px; margin-bottom: 30px; }
#spk .eyes i { width: 90px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 50% 50%, #ffb07a 0, #e2501f 45%, #6a0f08 100%); box-shadow: 0 0 40px #e2501f; animation: blink 6s infinite; }
#spk .big { font: 400 clamp(26px, 5vw, 56px)/1.15 var(--serif); color: var(--ink); max-width: 1000px; margin: 0; }
#spk .sub { color: var(--dim); font-size: clamp(16px, 2.4vw, 26px); margin: 0; }
#spk .tag { position: fixed; bottom: 18px; font-size: 13px; opacity: .5; }
body.spkFlash #spk { background: #fff3d6; transition: background .2s; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

/* final: oír lo que dijo cada uno (▶) y la foto en grande con zoom */
.reveals .rv { margin-left: 6px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid #6a2a22; background: #2a0a0c; color: var(--ink); font-size: 14px; vertical-align: middle; }
.reveals .rv:disabled { opacity: .3; }
.album img { cursor: zoom-in; }
#lb { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: calc(var(--top, 0px) + 10px) 14px calc(var(--bottom, 0px) + 14px); }
#lb .lbScroll { max-width: 100%; max-height: 74vh; overflow: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; }
#lb img { display: block; width: min(92vw, 520px); cursor: zoom-in; }
#lb.zoom img { width: min(260vw, 1500px); cursor: zoom-out; }
#lb .lbName { margin: 0; font: 400 22px var(--serif); color: var(--ink); }
#lb .lbSave { max-width: 220px; }
#lb .lbClose { position: absolute; top: calc(var(--top, 0px) + 10px); right: 14px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid #3a2a26; background: #120808; color: var(--ink); font-size: 20px; }
/* el altavoz al final: las caras en grande y lo que dijeron */
#spk .album { width: min(1100px, 100%); grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
#spk .reveals { max-width: 900px; font-size: clamp(16px, 2vw, 22px); }
#spk.end { justify-content: flex-start; overflow-y: auto; }
#spk .reveals li.now { color: #fff; text-shadow: 0 0 16px #e2501f; }
.vrow { text-align: left; max-width: 420px; width: 100%; margin: 0 auto 12px; color: #cbbcae; }
.vrow p { margin: 0 0 4px; font-size: 15px; }
.vrow audio { width: 100%; height: 36px; }
