/* ═══════════════════════════════════════════════════════════════════
   VI 2026-07-05 · Widget flotante multi-personaje
   ═══════════════════════════════════════════════════════════════════ */

#vi-mascot-root {
  position: fixed;
  bottom: 2.5rem;
  right: 3rem;
  z-index: 99998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  pointer-events: none;
}
#vi-mascot-root * { box-sizing: border-box; }

/* Minimizado: el grupo desaparece y solo se ve el botón de reabrir */
#vi-mascot-root.is-minimized .vi-mascot-group,
#vi-mascot-root.is-minimized .vi-mascot-panel-wrap {
  display: none !important;
}
#vi-mascot-root:not(.is-minimized) .vi-mascot-reopen {
  display: none !important;
}

/* Animación de entrada — salto desde abajo con rebote overshoot */
@keyframes vi-mascot-jump-in {
  0%   { transform: translateY(140%) scale(0.55); opacity: 0; }
  55%  { transform: translateY(-12%) scale(1.06); opacity: 1; }
  75%  { transform: translateY(3%) scale(0.98); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
#vi-mascot-root.is-entering .vi-mascot-group {
  animation: vi-mascot-jump-in 0.75s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  transform-origin: 50% 100%;
}
/* El botón 🎭 de reabrir también entra con salto cuando aparece */
#vi-mascot-root.is-minimized .vi-mascot-reopen {
  animation: vi-mascot-jump-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both,
             vi-mascot-float 3.5s ease-in-out 0.6s infinite;
}
@media (prefers-reduced-motion: reduce) {
  #vi-mascot-root.is-entering .vi-mascot-group,
  #vi-mascot-root.is-minimized .vi-mascot-reopen { animation: none; }
}

/* Auto-oculta el bocadillo pasados unos segundos; la X mini queda visible
   sobre el grupo para poder minimizar. */
#vi-mascot-root.is-bubble-hidden .vi-mascot-group-bubble {
  opacity: 0;
  transform: translateY(-6px) scale(0.9);
  pointer-events: none;
  visibility: hidden;
}
.vi-mascot-mini-x {
  position: absolute;
  top: -4px;
  right: 0;
  width: 24px;
  height: 24px;
  border: 1px solid rgba(200,169,110,0.4);
  border-radius: 50%;
  background: rgba(15,15,20,0.92);
  color: #f4f2ed;
  font-size: 15px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: auto;
  box-shadow: 0 3px 8px rgba(0,0,0,0.55);
  z-index: 5;
  transition: background 0.18s, transform 0.15s;
  opacity: 0;
}
.vi-mascot-mini-x:hover { background: #cc1a1a; transform: scale(1.1); }
#vi-mascot-root.is-bubble-hidden .vi-mascot-mini-x {
  display: flex;
  opacity: 1;
  transition: opacity 0.35s ease 0.1s;
}

/* Botón de reabrir — círculo con emoji, misma esquina */
.vi-mascot-reopen {
  pointer-events: auto;
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #cc1a1a 0%, #7a0f0f 100%);
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow:
    0 0 18px rgba(204,26,26,0.45),
    0 6px 16px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: vi-mascot-float 3.5s ease-in-out infinite;
  transition: transform 0.15s ease;
}
.vi-mascot-reopen:hover {
  transform: scale(1.08);
  box-shadow:
    0 0 26px rgba(255,60,40,0.7),
    0 8px 22px rgba(0,0,0,0.55);
}
.vi-mascot-reopen-emoji { line-height: 1; }

/* ── Contenedor grupal ────────────────────────────────────────────── */
.vi-mascot-group {
  pointer-events: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.5));
}

/* Fila de 4 avatares con overlap horizontal ligero (solo lo justo para
   que queden "juntos" sin que sus nombres debajo se pisen). */
.vi-mascot-row {
  display: flex;
  align-items: flex-end;
  width: 340px;
  height: 118px;
  position: relative;
}
.vi-mascot-char-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
  margin-left: -12px;
  transition: opacity 0.4s ease, margin 0.4s ease;
}
/* Cada avatar recibe delay/duración según --i (0..N-1) para que la flotación
   quede desincronizada. Usamos --i (en el HTML) en vez de :nth-child porque
   el .vi-mascot-row lleva delante un botón X, y con nth-child el último
   avatar se quedaba fuera del selector (Lola sin animación 2026-07). */
.vi-mascot-char-wrap {
  animation: vi-mascot-float calc(3.6s + var(--i, 0) * 0.35s) ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * -0.7s);
  z-index: calc(10 - var(--i, 0));
}
@keyframes vi-mascot-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: reduce) {
  .vi-mascot-char-wrap { animation: none; }
}
.vi-mascot-char-wrap:first-child { margin-left: 0; }

.vi-mascot-char {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  transform-origin: 50% 100%;
  transition: transform 0.25s ease;
}
/* Tambaleo (rotate) también parametrizado por --i para que ninguno se quede
   estático si el orden del DOM cambia. */
.vi-mascot-char-wrap .vi-mascot-char {
  animation: vi-mascot-sway calc(3.6s + var(--i, 0) * 0.4s) ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * -0.5s);
}
.vi-mascot-char img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  filter:
    drop-shadow(0 0 12px rgba(204,26,26,0.45))
    drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}
.vi-mascot-char-wrap:hover { z-index: 10; }
.vi-mascot-char:hover { transform: translateY(-6px) scale(1.06); }
.vi-mascot-char:hover img {
  filter:
    drop-shadow(0 0 20px rgba(255,60,40,0.7))
    drop-shadow(0 6px 10px rgba(0,0,0,0.55));
}

@keyframes vi-mascot-sway {
  0%   { transform: rotate(-2deg); }
  100% { transform: rotate(2deg); }
}
@media (prefers-reduced-motion: reduce) {
  .vi-mascot-char { animation: none; }
}

/* Cartelito con el nombre debajo — reemplaza al bocadillo individual */
.vi-mascot-char-name {
  position: absolute;
  bottom: -18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15,15,20,0.9);
  color: #f4f2ed;
  border: 1px solid rgba(200,169,110,0.35);
  padding: 2px 8px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
}

/* ── Bocadillo compartido arriba ──────────────────────────────────── */
.vi-mascot-group-bubble {
  align-self: center;
  position: relative;
  background: #fff;
  color: #0a0a0a;
  padding: 0.5rem 2.2rem 0.55rem 0.9rem;
  border-radius: 14px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.15;
  box-shadow: 0 6px 22px rgba(0,0,0,0.35);
  white-space: nowrap;
  margin-bottom: 2px;
  margin-right: 20px;
  animation: vi-bubble-in 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s linear 0.4s;
}
.vi-mascot-group-bubble::after {
  content: '';
  position: absolute;
  right: 30px;
  bottom: -7px;
  width: 0; height: 0;
  border: 7px solid transparent;
  border-top-color: #fff;
  border-bottom: 0;
}
@keyframes vi-bubble-in {
  from { opacity: 0; transform: translateY(6px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Al elegir un personaje: los otros 3 se ocultan y el bocadillo del grupo
   desaparece (display:none, no solo opacity — evita dejar hueco). */
.vi-mascot-group[data-stage="CHAR_MENU"] .vi-mascot-group-bubble,
.vi-mascot-group[data-stage="PLAN"] .vi-mascot-group-bubble,
.vi-mascot-group[data-stage="STORY"] .vi-mascot-group-bubble {
  display: none !important;
}
.vi-mascot-group[data-stage="CHAR_MENU"] .vi-mascot-char-wrap:not(.is-active),
.vi-mascot-group[data-stage="PLAN"] .vi-mascot-char-wrap:not(.is-active),
.vi-mascot-group[data-stage="STORY"] .vi-mascot-char-wrap:not(.is-active) {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6) translateY(20px);
}
.vi-mascot-group[data-stage="CHAR_MENU"] .vi-mascot-char-wrap.is-active,
.vi-mascot-group[data-stage="PLAN"] .vi-mascot-char-wrap.is-active,
.vi-mascot-group[data-stage="STORY"] .vi-mascot-char-wrap.is-active {
  margin-left: 0;
  z-index: 10;
}
.vi-mascot-group[data-stage="CHAR_MENU"] .vi-mascot-char-wrap.is-active,
.vi-mascot-group[data-stage="PLAN"] .vi-mascot-char-wrap.is-active,
.vi-mascot-group[data-stage="STORY"] .vi-mascot-char-wrap.is-active {
  animation-play-state: paused;
}
.vi-mascot-group[data-stage="CHAR_MENU"] .vi-mascot-char-wrap.is-active .vi-mascot-char,
.vi-mascot-group[data-stage="PLAN"] .vi-mascot-char-wrap.is-active .vi-mascot-char,
.vi-mascot-group[data-stage="STORY"] .vi-mascot-char-wrap.is-active .vi-mascot-char {
  animation-play-state: paused;
}

/* ── Panel (menú, plan, resultado) ───────────────────────────────── */
.vi-mascot-panel-wrap {
  pointer-events: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 10px;
}
.vi-mascot-panel {
  pointer-events: auto;
  width: 360px;
  max-width: calc(100vw - 2rem);
  background: #40404a;
  color: #f4f2ed;
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.75);
  overflow: hidden;
  animation: vi-panel-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
  font-size: 0.9rem;
}
/* Modo historia — panel más ancho para que no haya scroll */
.vi-mascot-panel.is-story {
  width: 460px;
  max-width: calc(100vw - 1.5rem);
}
@keyframes vi-panel-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.vi-mascot-panel-header {
  padding: 0.85rem 1rem 0.7rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
}
.vi-mascot-panel-title {
  font-size: 0.86rem;
  font-weight: 600;
  color: #fff;
  flex: 1;
  text-align: center;
}
.vi-mascot-panel-charlabel {
  font-size: 0.72rem;
  color: #f0d495;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
}
.vi-mascot-panel-back {
  background: none; border: none; color: #e6e4de; cursor: pointer;
  font-size: 0.82rem; font-weight: 500;
  padding: 0.2rem 0.45rem; border-radius: 6px;
}
.vi-mascot-panel-back:hover { background: rgba(255,255,255,0.14); color: #fff; }
.vi-mascot-panel-close {
  background: none; border: none; color: #e6e4de; cursor: pointer;
  font-size: 20px; line-height: 1; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 6px;
}
.vi-mascot-panel-close:hover { background: rgba(255,255,255,0.14); color: #fff; }

.vi-mascot-panel-body {
  padding: 0.9rem 1rem 1rem;
  display: flex; flex-direction: column; gap: 0.55rem;
}
.vi-mascot-panel-body p {
  margin: 0 0 0.15rem;
  color: #e0ded6;
  font-size: 0.85rem;
  line-height: 1.4;
}

.vi-mascot-option {
  display: flex; align-items: center; gap: 0.75rem;
  width: 100%; text-align: left;
  background: #16161c;
  border: 1px solid rgba(255,255,255,0.12);
  color: #f4f2ed;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  font-family: inherit; font-size: 0.9rem; font-weight: 500;
  cursor: pointer; text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}
.vi-mascot-option:hover {
  background: #2a1010;
  border-color: rgba(204,26,26,0.55);
}
.vi-mascot-option:active { transform: scale(0.98); }
.vi-mascot-option-emoji { font-size: 1.15rem; line-height: 1; }
.vi-mascot-option-text { flex: 1; }
.vi-mascot-option-primary {
  background: linear-gradient(135deg, #cc1a1a 0%, #a01515 100%);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 600;
}
.vi-mascot-option-primary:hover {
  background: linear-gradient(135deg, #d92626 0%, #b81919 100%);
}
.vi-mascot-option-wa {
  background: linear-gradient(135deg, #25d366 0%, #128c7e 100%);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
  font-weight: 600;
}
.vi-mascot-option-wa:hover {
  background: linear-gradient(135deg, #2ee973 0%, #159686 100%);
}

.vi-mascot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.vi-mascot-grid .vi-mascot-option {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
}
.vi-mascot-grid .vi-mascot-option .vi-mascot-option-emoji {
  font-size: 1rem;
}
/* "Dame ofertas" (primary) ocupa toda la fila cuando comparte grid con
   otras 2 opciones — evita la casilla huérfana en la fila 2. */
.vi-mascot-grid .vi-mascot-option-primary {
  grid-column: 1 / -1;
  justify-content: center;
}

/* Resultado — card del juego */
.vi-mascot-result-game {
  position: relative;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  background: #16161c;
  text-decoration: none; color: inherit;
  transition: background 0.2s, border-color 0.2s;
}
.vi-mascot-result-game:hover {
  background: #22222a;
  border-color: rgba(255,255,255,0.28);
}
.vi-mascot-result-game.is-disabled {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
  border-style: dashed;
}
.vi-mascot-result-game.is-disabled .vi-mascot-result-meta {
  color: #c8a96e;
  font-style: italic;
}
.vi-mascot-result-game.with-offer {
  border-color: rgba(204,26,26,0.55);
  background: #16161c;
  padding-top: 1.7rem;
}
.vi-mascot-result-game.with-offer:hover {
  border-color: rgba(204,26,26,0.85);
  background: #22161a;
}
.vi-mascot-result-offer-strip {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: #cc1a1a;
  color: #fff;
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.11em;
  text-align: center;
  padding: 0.28rem 0;
  border-radius: 9px 9px 0 0;
  box-shadow: 0 2px 6px rgba(204,26,26,0.35);
  text-transform: uppercase;
}
.vi-mascot-result-thumb {
  width: 44px; height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.vi-mascot-result-info { flex: 1; min-width: 0; }
.vi-mascot-result-name {
  font-weight: 600; font-size: 0.88rem;
  color: #fff; line-height: 1.15; margin-bottom: 0.15rem;
}
.vi-mascot-result-meta {
  font-size: 0.76rem; color: #a3a19a; line-height: 1.2;
}
.vi-mascot-empty {
  color: #a3a19a; font-size: 0.85rem;
  padding: 0.75rem 0; text-align: center; line-height: 1.4;
}

/* ── Historia (avatar grande + bocadillos secuenciales) ──────────── */
.vi-mascot-story {
  display: flex;
  gap: 0.8rem;
  padding: 1rem 1.1rem 1.2rem;
}
.vi-mascot-story-avatar {
  flex: 0 0 120px;
  height: 170px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.vi-mascot-story-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  animation: vi-mascot-sway 3s ease-in-out infinite alternate;
  filter:
    drop-shadow(0 0 15px rgba(204,26,26,0.5))
    drop-shadow(0 6px 8px rgba(0,0,0,0.5));
}
.vi-mascot-story-bubbles {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.15rem;
}
.vi-mascot-story-bubble {
  background: #fff;
  color: #0a0a0a;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  font-size: 0.87rem;
  line-height: 1.4;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  animation: vi-story-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  position: relative;
}
.vi-mascot-story-bubble::before {
  content: '';
  position: absolute;
  left: -6px; top: 12px;
  width: 0; height: 0;
  border: 7px solid transparent;
  border-right-color: #fff;
  border-left: 0;
}
@keyframes vi-story-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.vi-mascot-story-cta {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(255,255,255,0.15);
  display: flex; flex-direction: column; gap: 0.4rem;
  animation: vi-story-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.vi-mascot-story-cta-q {
  color: #f4f2ed;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  line-height: 1.4;
}

/* ── Móvil ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #vi-mascot-root { bottom: 1.5rem; right: 0.6rem; }
  .vi-mascot-row {
    width: 290px;
    height: 100px;
  }
  .vi-mascot-char-wrap {
    width: 78px;
    height: 78px;
    margin-left: -10px;
  }
  .vi-mascot-char-name { font-size: 0.6rem; padding: 2px 6px; bottom: -16px; }
  .vi-mascot-panel { width: calc(100vw - 1.5rem); }
  .vi-mascot-panel.is-story { width: calc(100vw - 1rem); }
  .vi-mascot-group-bubble {
    font-size: 0.78rem;
    padding: 0.4rem 1.9rem 0.45rem 0.7rem;
    margin-right: 12px;
  }
  .vi-mascot-story-avatar { flex: 0 0 90px; height: 130px; }
  .vi-mascot-story-bubble { font-size: 0.82rem; }
}
