/* ============================================================
   Cleopatra — Capa del personaje animado
   - Escritorio / apaisado: a la izquierda del marco, de pie
     junto a la columna, sin tapar los rodillos ni los botones.
   - Móvil vertical: el marco del slot baja a la parte inferior
     y el personaje ocupa la zona superior de la pantalla,
     "de pie" sobre el rodillo.
   ============================================================ */

.cleo-character {
  position: fixed;
  z-index: 60;                 /* por encima del marco, por debajo de overlays (settings 9999) */
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity .6s ease, transform .35s ease;
  opacity: 1;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;
  background: transparent !important;
  /* IMPORTANTE: sin filter/drop-shadow/backdrop sobre el vídeo con alpha.
     En Chrome/Android el compositor puede pintar el <video> sobre una
     caja negra opaca cuando se le aplica un filter. La sombra va en
     un pseudo-elemento separado (::after). */
}

/* Sombra suave en el suelo, separada del vídeo */
.cleo-character::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 70%;
  height: 5%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, .45), rgba(0, 0, 0, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

.cleo-character.cleo-hidden {
  opacity: 0;
  pointer-events: none;
}

.cleo-character-media {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  background: transparent !important;
  background-color: transparent !important;
  border: 0;
  outline: 0;
  box-shadow: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
  position: relative;
  z-index: 1;
}

/* Doble búfer: los dos <video> ocupan el mismo sitio; solo el activo es
   visible. El inactivo queda con opacity 0 (NO display:none, para que
   siga decodificando y el cambio sea en el mismo fotograma). */
.cleo-video {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: none;
}
.cleo-video.is-active {
  opacity: 1;
  visibility: visible;
}
/* Ocultar controles / overlays nativos que algunos navegadores pintan */
.cleo-video::-webkit-media-controls,
.cleo-video::-webkit-media-controls-enclosure,
.cleo-video::-webkit-media-controls-panel,
.cleo-video::-webkit-media-controls-start-playback-button,
.cleo-video::-webkit-media-controls-overlay-play-button {
  display: none !important;
  -webkit-appearance: none;
  opacity: 0;
}

/* Reacciones de la capa según el estado (refuerzan la animación del clip) */
.cleo-state-spin   { transform: translateY(-1%) scale(1.02); }
.cleo-state-win    { transform: translateY(-2%) scale(1.04); }
.cleo-state-bigwin { transform: translateY(-3%) scale(1.07); }

/* Halos de color (sin filter): resplandor detrás del personaje */
.cleo-state-bigwin::after {
  width: 110%; height: 40%; bottom: 5%;
  background: radial-gradient(ellipse at center, rgba(255, 205, 86, .55), rgba(255, 205, 86, 0) 70%);
}
.cleo-state-bonus::after {
  width: 110%; height: 40%; bottom: 5%;
  background: radial-gradient(ellipse at center, rgba(0, 220, 240, .45), rgba(0, 220, 240, 0) 70%);
}

/* ---------- Burbuja de texto ---------- */
.cleo-bubble {
  position: absolute;
  top: 2%;
  left: 50%;
  transform: translate(-50%, 8px) scale(.9);
  max-width: 92%;
  padding: 6px 12px;
  border-radius: 14px;
  border: 2px solid #c9a227;
  background: linear-gradient(135deg, rgba(26, 10, 0, .95), rgba(13, 27, 42, .95));
  color: #ffd86b;
  font-family: 'Cinzel', serif;
  font-weight: 700;
  font-size: clamp(11px, 1.3vw, 16px);
  letter-spacing: .5px;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 0 16px rgba(201, 162, 39, .45);
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}
.cleo-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 12px;
  height: 12px;
  background: inherit;
  border-right: 2px solid #c9a227;
  border-bottom: 2px solid #c9a227;
  transform: translateX(-50%) rotate(45deg);
}
.cleo-bubble.visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ============================================================
   ESCRITORIO / APAISADO
   El marco ocupa todo el viewport; la reina se sitúa a la
   izquierda, de pie en la explanada junto a la columna.
   ============================================================ */
@media (orientation: landscape) {
  .cleo-character {
    left: 0.4vw;
    bottom: 3vh;
    height: min(58vh, 44vw);
    width: min(21vw, 39vh);        /* aspecto 576x860 ≈ 0.67 */
  }
  .cleo-bubble { top: -2%; }
}

/* En apaisado de móvil (poca altura) la hacemos algo más pequeña */
@media (orientation: landscape) and (max-height: 480px) {
  .cleo-character {
    height: 52vh;
    width: min(20vw, 35vh);
    bottom: 2vh;
  }
}

/* ============================================================
   MÓVIL VERTICAL
   El slot baja a la parte inferior (62% de la pantalla) y el
   personaje ocupa la franja superior, de pie sobre el rodillo.
   ============================================================ */
@media (orientation: portrait) {
  /* Franja superior: cielo del Nilo a juego con el marco, con el
     suelo de piedra justo bajo los pies del personaje */
  .app-container {
    background: linear-gradient(180deg, #0d1b2a, #050510) !important;
  }
  /* El bundle pinta el ambiente con pseudo-elementos fijos y blur;
     en vertical los reemplazamos por el cielo del Nilo nítido */
  .app-container::before {
    inset: 0 !important;
    transform: none !important;
    filter: none !important;
    opacity: 1 !important;
    background: url("sky_bg.jpg") center 72% / cover no-repeat !important;
  }
  .app-container::after {
    background:
      linear-gradient(180deg, rgba(5, 12, 28, .25) 0%, rgba(5, 12, 28, 0) 12dvh, rgba(5, 12, 28, 0) 30dvh, rgba(40, 24, 8, .45) 38dvh) !important;
    opacity: 1 !important;
  }
  /* Línea dorada de separación entre la escena y el marco */
  .slot-frame-container::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: -2px;
    height: 3px;
    background: linear-gradient(90deg, rgba(201,162,39,0), #ffd86b 30%, #ffd86b 70%, rgba(201,162,39,0));
    box-shadow: 0 0 12px rgba(255, 205, 86, .6);
    z-index: 5;
    pointer-events: none;
  }

  .slot-frame-container {
    position: absolute !important;
    left: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    height: 62dvh !important;
    width: 100vw !important;
  }

  .cleo-character {
    left: 50%;
    transform: translateX(-50%);
    top: 1.5dvh;
    height: 37.5dvh;
    width: min(92vw, 28dvh);       /* mantiene la proporción del clip */
  }

  /* Variantes de estado mantienen el centrado horizontal */
  .cleo-state-spin   { transform: translateX(-50%) translateY(-1%) scale(1.02); }
  .cleo-state-win    { transform: translateX(-50%) translateY(-2%) scale(1.04); }
  .cleo-state-bigwin { transform: translateX(-50%) translateY(-3%) scale(1.07); }
  .cleo-state-bonus  { transform: translateX(-50%); }

  /* Burbuja a la derecha de la reina, a la altura de su cabeza */
  .cleo-bubble {
    top: 9%;
    left: 78%;
    right: auto;
    max-width: 48vw;
    transform: translate(0, 6px) scale(.9);
    font-size: clamp(12px, 3.4vw, 16px);
    white-space: normal;
    text-align: left;
  }
  .cleo-bubble.visible { transform: translate(0, 0) scale(1); }
  .cleo-bubble::after {
    left: -8px;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%) rotate(135deg);
  }

  /* Suelo dorado sutil bajo los pies, encima del marco */
  .cleo-character::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -1%;
    width: 120%;
    height: 6%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(255, 205, 86, .45), rgba(255, 205, 86, 0) 70%);
    pointer-events: none;
  }
}

/* Teléfonos muy altos (p.ej. 20:9): un poco más de personaje */
@media (orientation: portrait) and (min-aspect-ratio: 9/19.5) and (max-aspect-ratio: 9/16) {
  .slot-frame-container { height: 60dvh !important; }
  .cleo-character { height: 39dvh; width: min(92vw, 29dvh); }
}

/* Tablets en vertical: el slot puede ser más alto */
@media (orientation: portrait) and (min-width: 700px) {
  .slot-frame-container { height: 66dvh !important; }
  .cleo-character { height: 33dvh; width: min(60vw, 24.5dvh); top: 1dvh; }
}

/* Accesibilidad: sin movimiento extra si el usuario lo pide */
@media (prefers-reduced-motion: reduce) {
  .cleo-character { transition: none; }
  .cleo-state-spin, .cleo-state-win, .cleo-state-bigwin { transform: none; }
}
