/* ── Pantalla en vivo (/directo y /android) ───────────────────────────────
 * Estilos compartidos por la pantalla que se emite. /android añade encima
 * solo la capa de pantalla completa (css/android-fullscreen.css).
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #e2e8f0;
  font-family: 'JetBrains Mono', monospace;
}

/* ── Escenario fijo 9:16 ────────────────────────────────────────────────
   El video (y todo lo que va encima) vive en un lienzo vertical 9:16
   centrado. En el teléfono llena la pantalla; en pantallas más anchas
   o más altas se letterboxea con barras negras. Así el ENCUADRE no
   cambia al redimensionar la ventana: lo que ves en el PC es lo que
   verá el teléfono. */
.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
  overflow: hidden;
}
.frame {
  position: relative;
  width: min(100vw, calc(100vh * 9 / 16));
  height: min(100vh, calc(100vw * 16 / 9));
  overflow: hidden;
  background: #0d0d13;
  container-type: inline-size;
}
@supports (height: 100dvh) {
  .frame {
    width: min(100vw, calc(100dvh * 9 / 16));
    height: min(100dvh, calc(100vw * 16 / 9));
  }
}

/* Video de fondo dentro del lienzo: capa 0. */
.bg-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background: #0d0d13;
  pointer-events: none;
}

/* Contenido por encima del video */
.scene {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

/* ── Stack: pill + frases (anclado arriba-centro) ─────────────────────── */
.welcome-stack {
  position: absolute;
  top: calc(6% + var(--welcome-safe-offset, 0%));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--phrase-gap, 12px) * var(--ui, 1));
  width: max-content;
  max-width: 92%;
  pointer-events: none;
}
/* Reserva el alto del último pill para que la tarjeta no salte al ocultarse. */
.pill-slot {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: var(--pill-slot-h, 0px);
}

/* ── Welcome Pill ─────────────────────────────────────────────────────── */
#welcome-pill {
  position: relative;
  z-index: 100;
  display: none;
  align-items: center;
  gap: calc(12px * var(--ui, 1));
  /* max-content: el pill se ajusta a su contenido, no al 92% del marco. */
  width: max-content;
  max-width: 100%;
  padding: calc(12px * var(--ui, 1)) calc(20px * var(--ui, 1));
  /* Menos "pastilla": esquinas redondeadas pero de radio fijo. */
  border-radius: calc(18px * var(--ui, 1));
  font-family: 'Inter', system-ui, sans-serif;
  /* Proporcional al ancho del lienzo (mínimo legible en ventanas pequeñas). */
  font-size: max(10px, 4cqw);
  font-weight: 700;
  line-height: 1.2;
  /* Estilos de color/opacidad/blur los aplica JS (applyStyle) */
  box-shadow: 0 calc(8px * var(--ui, 1)) calc(32px * var(--ui, 1)) rgba(0, 0, 0, 0.45);
  transition: box-shadow 240ms ease, opacity 240ms ease;
  pointer-events: none;
}
/* SOLO se anima la entrada. La salida es quitar `.show`. */
#welcome-pill.show {
  display: flex;
  animation: pillIn var(--pill-anim-ms, 280ms) ease-out;
}

/* `scale` (propiedad individual) no pisa el `transform: translateX(-50%)`
   de las posiciones centradas. */
@keyframes pillIn {
  from { opacity: 0; scale: 0.94; }
  to   { opacity: 1; scale: 1; }
}

.welcome-avatar {
  width: calc(36px * var(--ui, 1));
  height: calc(36px * var(--ui, 1));
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  overflow: hidden;
}
.welcome-text {
  white-space: normal;
  word-break: break-word;
}

/* ── Tarjeta de frases (debajo del pill) ──────────────────────────────── */
.phrase-card {
  position: relative;
  overflow: hidden;
  max-width: 100%;
  padding: calc(14px * var(--ui, 1)) calc(24px * var(--ui, 1));
  border-radius: calc(18px * var(--ui, 1));
  background: var(--phrase-bg, #101014);
  color: var(--phrase-color, #ffffff);
  font-family: 'Quicksand', 'Inter', system-ui, sans-serif;
  font-size: calc(var(--phrase-size, 24px) * var(--ui, 1));
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1.25;
  text-align: center;
  border: 1px solid var(--phrase-aura, rgba(255, 197, 61, 0.5));
  box-shadow:
    0 calc(10px * var(--ui, 1)) calc(30px * var(--ui, 1)) rgba(0, 0, 0, 0.5),
    0 0 calc(18px * var(--ui, 1)) calc(3px * var(--ui, 1)) var(--phrase-aura, rgba(255, 197, 61, 0.35));
  backdrop-filter: blur(10px);
  transition:
    opacity 240ms ease,
    transform 420ms cubic-bezier(0.16, 1, 0.3, 1),
    filter 280ms ease;
  /* La opacidad configurada se multiplica por el fade de la rotación. */
  opacity: calc(var(--phrase-opacity, 1) * var(--phrase-fade, 1));
}
.phrase-card[hidden] { display: none !important; }
.phrase-text {
  position: relative;
  z-index: 1;
  display: block;
  white-space: normal;
  word-break: break-word;
}

/* Salida: se hunde, encoge y desenfoca. */
.phrase-card.is-exit {
  --phrase-fade: 0;
  transform: translateY(14px) scale(0.92);
  filter: blur(6px);
}
/* Entrada: "pop" con rebote. */
.phrase-card.is-enter {
  animation: phrasePop 640ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes phrasePop {
  0%   { transform: translateY(calc(16px * var(--ui, 1))) scale(0.9); filter: blur(calc(6px * var(--ui, 1))); }
  55%  { transform: translateY(calc(-3px * var(--ui, 1))) scale(1.04); filter: blur(0); }
  100% { transform: translateY(0) scale(1); }
}

/* Barrido de brillo al entrar. */
.phrase-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.18) 50%, transparent 68%);
  transform: translateX(-130%);
}
.phrase-card.is-enter::before {
  animation: phraseShine 760ms ease;
}
@keyframes phraseShine {
  from { transform: translateX(-130%); }
  to   { transform: translateX(130%); }
}

/* ── Capa central de agradecimientos (regalos y shares), debajo de la frase ──
   Se muestra al llegar un evento `gift:thankyou` / `share:thankyou`. Invisible
   en reposo. El tamaño del avatar lo fija `--center-avatar-size` (lo pone JS
   desde `config:center-layer.avatarSize`); todo escala con `--ui`. */
.center-thankyou {
  position: relative;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(10px * var(--ui, 1));
  width: max-content;
  max-width: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 300ms ease;
}
.center-thankyou[hidden] {
  display: none;
}
.center-thankyou.is-visible {
  opacity: 1;
}

/* Marco del avatar: el halo y las ondas se anclan a él. */
.center-avatar-wrap {
  position: relative;
  width: calc(var(--center-avatar-size, 140px) * var(--ui, 1));
  height: calc(var(--center-avatar-size, 140px) * var(--ui, 1));
}
.center-avatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  z-index: 3;
  background: #141414;
}

/* Halo cálido difuminado: 4 tonos (dorado, ámbar, verde esmeralda, rojo suave). */
.center-halo {
  position: absolute;
  inset: -22%;
  z-index: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 215, 0, 0.55), transparent 55%),
    radial-gradient(circle at 72% 34%, rgba(255, 166, 35, 0.50), transparent 55%),
    radial-gradient(circle at 42% 72%, rgba(120, 220, 160, 0.45), transparent 55%),
    radial-gradient(circle at 66% 70%, rgba(255, 138, 138, 0.40), transparent 55%);
  filter: blur(12px);
  /* Glow ESTÁTICO: un regalo simple no debe «latir». El único pulso es el del
     combo, y va sobre la imagen del regalo (.center-gift), no aquí. */
  opacity: 0.7;
}
@keyframes centerHaloGlow {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 0.85; }
}

/* Brillo dorado más amplio para regalos ≥10 diamantes. */
.center-thankyou.large-halo .center-halo {
  inset: -40%;
  filter: blur(14px) drop-shadow(0 0 24px rgba(255, 215, 0, 0.6));
}

/* Ondas de agua concéntricas. */
.center-ripples {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.center-ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: calc(2px * var(--ui, 1)) solid rgba(255, 255, 255, 0.55);
  opacity: 0;
  animation: centerRipple 2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes centerRipple {
  0%   { transform: scale(0.95); opacity: 0.75; }
  100% { transform: scale(2.2);  opacity: 0; }
}

/* Texto de agradecimiento. */
.center-text {
  z-index: 3;
  margin: 0;
  font-family: 'Quicksand', 'Inter', system-ui, sans-serif;
  font-size: calc(16px * var(--ui, 1));
  font-weight: 700;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  max-width: 90%;
}

/* Imagen del regalo (solo en regalos; oculta en shares o sin imagen). */
.center-gift {
  z-index: 3;
  width: calc(var(--center-gift-size, 72px) * var(--ui, 1));
  height: calc(var(--center-gift-size, 72px) * var(--ui, 1));
  object-fit: contain;
  border-radius: calc(14px * var(--ui, 1));
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}
.center-gift[hidden] { display: none; }

/* Pulso de combo en la imagen del regalo. */
@keyframes giftPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.18); }
}
.center-gift.pulsing {
  animation: giftPulse var(--combo-pulse-ms, 300ms) ease-in-out;
  animation-fill-mode: both;
}

/* ── Burbujas de Share ───────────────────────────────────────────────────
   Aparecen desde abajo, suben y se desvanecen. Tamaño configurable via
   --share-bubble-size (lo setea JS desde config). Max 8 simultáneas.     */

.share-bubbles-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 80; /* Debajo de center-thankyou (z-index: 100) */
  overflow: hidden;
}

.share-bubble {
  position: absolute;
  top: 100%;
  left: var(--bubble-x, 50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(2px * var(--ui, 1));
  width: calc(var(--share-bubble-size, 60px) * var(--ui, 1));
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  animation: shareBubbleFloat var(--share-bubble-duration, 12000ms)
    cubic-bezier(0.33, 0, 0.67, 1) forwards;
  will-change: transform, opacity;
  z-index: 1;
}

.share-bubble__avatar-wrap {
  position: relative;
  width: calc(var(--share-bubble-avatar-size, 36px) * var(--ui, 1));
  height: calc(var(--share-bubble-avatar-size, 36px) * var(--ui, 1));
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.6),
    0 0 calc(8px * var(--ui, 1)) rgba(255, 255, 255, 0.5);
}

.share-bubble__avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #141414;
}

.share-bubble__icon {
  font-size: calc(9px * var(--ui, 1));
  line-height: 1;
  opacity: 1;
  color: #fff;
  filter: drop-shadow(0 0 2px rgba(255,255,255,0.4));
  animation: shareIconFade var(--share-bubble-duration, 12000ms)
    ease-out forwards;
}

/* Sube desde fuera de la pantalla (abajo) flotando con vaivén y respiración. */
@keyframes shareBubbleFloat {
  0% {
    transform: translate(-50%, calc(var(--share-bubble-start-offset, 50px) * var(--ui, 1))) scale(0.7);
    opacity: 0;
  }
  8% {
    opacity: 0.9;
  }
  25% {
    transform: translate(calc(-50% + var(--sway-a, 0vw)), -12vh) scale(1);
    opacity: 0.95;
  }
  45% {
    transform: translate(calc(-50% + var(--sway-b, 0vw)), -38vh) scale(1.05);
  }
  65% {
    transform: translate(calc(-50% + var(--sway-a, 0vw)), -64vh) scale(0.99);
    opacity: 0.9;
  }
  85% {
    transform: translate(calc(-50% + var(--sway-b, 0vw)), -92vh) scale(0.92);
    opacity: 0.5;
  }
  100% {
    transform: translate(calc(-50% + var(--sway-a, 0vw)), -112vh) scale(0.85);
    opacity: 0;
  }
}

@keyframes shareIconFade {
  0%, 65% { opacity: 1; }
  100% { opacity: 0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .share-bubble {
    animation: none !important;
    opacity: 0;
    display: none;
  }
}
