:root {
  --stage-width: 100vw;
  --stage-height: 100vh;
}

body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #121214;
  user-select: none;
  font-family: sans-serif;
}

/* Stage / Canvas 16:9 Centralizado e Perfeitamente Proporcional (1920x1080) */
#stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100vw;
  height: 56.25vw; /* 1080 / 1920 = 56.25% */
  max-height: 100vh;
  max-width: 177.78vh; /* 1920 / 1080 = 1.7778 */
  aspect-ratio: 16 / 9;
  overflow: hidden;
  container-type: size;
  pointer-events: none;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
}

/* Background Oficial do Projeto (39.jpg) */
#background-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  background-image: url("./assets/images/elements/39.jpg");
  background-position: center center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

img {
  user-select: none;
  -webkit-user-drag: none;
}

/* ============================================================
   TELA DE INTRODUÇÃO & MENSAGEM ESCRITA À MÃO (QUADRO)
   ============================================================ */
#intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 60px);
  background: rgba(10, 12, 16, 0.45);
  backdrop-filter: blur(5px);
  opacity: 1;
  transition: opacity 0.75s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  cursor: pointer;
  box-sizing: border-box;
}

#intro-overlay.intro-fade-out {
  opacity: 0;
  pointer-events: none;
}

.intro-content {
  max-width: 900px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2.5vw, 30px);
}

/* Folha de Papel Rasgada (Elemento 23) */
.intro-paper-note {
  position: relative;
  width: min(520px, 86vw, 34vw);
  max-width: 530px;
  margin: 0 auto;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.5)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
  transform-origin: center center;
  animation: paperStopMotionEntrance 0.45s steps(1) 1 forwards;
}

#intro-overlay.intro-fade-out .intro-paper-note {
  animation: paperStopMotionExit 0.4s steps(1) 1 forwards;
}

.intro-paper-bg {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  user-select: none;
}

.intro-paper-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12% 14% 10% 14%;
  box-sizing: border-box;
}

.handwritten-text {
  font-family: 'Homemade Apple', 'Patrick Hand', cursive;
  font-size: clamp(18px, 1.9vw, 32px);
  font-weight: 700;
  line-height: 1.35;
  color: #1a1a1a;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  min-height: 2.6em;
  word-break: break-word;
  text-align: center;
  width: 100%;
  position: relative;
}

/* Caneta de Escrita Dinâmica em Tempo Real */
.writing-pen-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 100;
}

.writing-pen {
  position: absolute;
  width: clamp(110px, 11vw, 160px);
  height: auto;
  top: 0;
  left: 0;
  pointer-events: none;
  user-select: none;
  /* Ancoragem exata na ponta metálica da pena (9.1% X e 93.24% Y) */
  transform-origin: 9.1% 93.24%;
  filter: drop-shadow(-8px 12px 14px rgba(0, 0, 0, 0.45));
  opacity: 0;
  /* Animação Stop-Motion: sem interpolação contínua, saltos discretos por caractere */
  transition: opacity 0.15s steps(1);
  will-change: transform, opacity;
}

.writing-pen.active {
  opacity: 1 !important;
}

.writing-pen.lifting {
  transition: opacity 0.3s steps(1), transform 0.3s steps(1);
  opacity: 0 !important;
}

.chalk-cursor {
  display: inline-block;
  font-weight: 300;
  margin-left: 3px;
  color: #1a1a1a;
  animation: chalk-blink 0.8s infinite;
}

@keyframes chalk-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.intro-prompt {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);
  padding: 10px 26px;
  border-radius: 40px;
  color: #ffffff;
  font-family: 'Short Stack', 'Patrick Hand', cursive, sans-serif;
  font-size: clamp(14px, 1.4vw, 20px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: opacity 0.5s ease, transform 0.5s ease;
  animation: prompt-pulse 2s ease-in-out infinite alternate;
}

.intro-prompt.hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(15px);
}

.intro-prompt.fade-in {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.key-badge {
  background: #ffffff;
  color: #1a1a24;
  font-family: monospace, sans-serif;
  font-weight: 700;
  font-size: 0.9em;
  padding: 4px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  border-bottom: 2px solid #bbb;
}

@keyframes prompt-pulse {
  0% { transform: scale(0.97); opacity: 0.85; }
  100% { transform: scale(1.03); opacity: 1; }
}

/* Oculta os elementos durante a introdução */
body.intro-mode #elements-container {
  opacity: 0;
  pointer-events: none;
}

body.game-active #elements-container {
  opacity: 1;
}

/* ============================================================
   PAINEL SUPERIOR DE NAVEGAÇÃO E CALIBRAÇÃO DOS ELEMENTOS (OCULTO)
   ============================================================ */
#element-nav-panel {
  display: none !important;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

#element-nav-panel select {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
}

#element-nav-panel select option {
  background: #222;
  color: #fff;
}

#element-nav-panel button {
  background: #e63946;
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  font-family: inherit;
  transition: all 0.2s ease;
}

#element-nav-panel button:hover {
  background: #ff4d5e;
  transform: translateY(-1px);
}

#btn-toggle-all {
  background: #457b9d !important;
}

#btn-toggle-all:hover {
  background: #5b92b6 !important;
}

.nav-rotation {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 14px;
}

.nav-rotation span {
  font-size: 12px;
  color: #e0e0e0;
}

#input-rotation {
  width: 52px;
  padding: 5px 4px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#input-rotation:focus {
  border-color: #e63946;
  background: rgba(255, 255, 255, 0.2);
}

#input-rotation::-webkit-inner-spin-button,
#input-rotation::-webkit-outer-spin-button {
  opacity: 1;
}

#btn-rot-left,
#btn-rot-right {
  background: #4a4e69 !important;
  padding: 5px 10px !important;
}

#btn-rot-left:hover,
#btn-rot-right:hover {
  background: #6c757d !important;
}

#btn-rot-reset {
  background: #5c677d !important;
  padding: 5px 10px !important;
}

#btn-rot-reset:hover {
  background: #7d8597 !important;
}

.nav-scale {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 14px;
}

.nav-scale span {
  font-size: 12px;
  color: #e0e0e0;
}

#input-scale {
  width: 52px;
  padding: 5px 4px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#input-scale:focus {
  border-color: #f4a261;
  background: rgba(255, 255, 255, 0.2);
}

#input-scale::-webkit-inner-spin-button,
#input-scale::-webkit-outer-spin-button {
  opacity: 1;
}

#btn-scale-down,
#btn-scale-up {
  background: #7b2cbf !important;
  padding: 5px 10px !important;
}

#btn-scale-down:hover,
#btn-scale-up:hover {
  background: #9d4edd !important;
}

#btn-scale-reset {
  background: #5a189a !important;
  padding: 5px 10px !important;
}

#btn-scale-reset:hover {
  background: #7b2cbf !important;
}

.nav-layer {
  display: flex;
  align-items: center;
  gap: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 14px;
}

.nav-layer span {
  font-size: 12px;
  color: #e0e0e0;
}

#input-layer {
  width: 48px;
  padding: 5px 4px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

#input-layer:focus {
  border-color: #2a9d8f;
  background: rgba(255, 255, 255, 0.2);
}

#input-layer::-webkit-inner-spin-button,
#input-layer::-webkit-outer-spin-button {
  opacity: 1;
}

#btn-layer-down,
#btn-layer-up {
  background: #264653 !important;
  padding: 5px 10px !important;
}

#btn-layer-down:hover,
#btn-layer-up:hover {
  background: #2a9d8f !important;
}

#btn-toggle-fixed {
  background: #343a40 !important;
  color: #adb5bd !important;
  padding: 5px 11px !important;
  font-size: 11px !important;
  margin-left: 2px;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  transition: all 0.2s ease !important;
}

#btn-toggle-fixed:hover {
  background: #495057 !important;
  color: #fff !important;
}

#btn-toggle-fixed.active-fixed {
  background: #2a9d8f !important;
  color: #ffffff !important;
  border-color: #2a9d8f !important;
  box-shadow: 0 0 8px rgba(42, 157, 143, 0.6);
}

.nav-info {
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 1px solid rgba(255, 255, 255, 0.2);
  padding-left: 14px;
  font-family: monospace;
}

#btn-copy-coords {
  background: #2a9d8f !important;
}

#btn-copy-coords:hover {
  background: #3bbcae !important;
}

/* ============================================================
   CONTAINER E ITENS ARRASTÁVEIS DO CENÁRIO
   ============================================================ */
#elements-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Permite arrastar os filhos */
}

.draggable-item {
  position: absolute;
  cursor: grab;
  user-select: none;
  touch-action: none;
  z-index: 10;
  display: block; /* Todos os elementos visíveis por padrão na simulação */
  transform-origin: center center;
  pointer-events: auto;
  transition: opacity 0.22s ease, filter 0.25s ease;
  line-height: 0;
  font-size: 0;
  padding: 0;
  margin: 0;
}

/* ============================================================
   FOCO VISUAL: DIMMING DOS ELEMENTOS RESTANTES DURANTE O ARRASTO
   ============================================================ */
body.is-dragging-mode .draggable-item:not(.is-dragging):not(.snap-target-silhouette) {
  opacity: 0.25;
  filter: grayscale(20%) brightness(0.8);
  pointer-events: none;
}

body.is-dragging-mode .draggable-item.is-dragging {
  opacity: 1 !important;
  filter: none !important;
}

/* Elementos sem mapeamento permanecem ocultos */
.draggable-item.unmapped {
  display: none !important;
}

/* Elementos fixos ou encaixados são estáticos e travados */
.draggable-item.is-fixed,
.draggable-item.snapped {
  display: block;
  cursor: default;
}

/* Elementos encaixados ou fixos que possuem eventos onSnap (interatividade ao toque) */
.draggable-item.is-fixed.has-interaction,
.draggable-item.snapped.has-interaction {
  cursor: pointer !important;
}

.draggable-item.interaction-pulse img,
.draggable-item.interaction-pulse .stickers-grid {
  animation: interactionPulse 0.35s ease-out;
}

@keyframes interactionPulse {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.2); }
  100% { filter: brightness(1); }
}

/* ============================================================
   ANIMAÇÃO DE GROOVE EM BAIXO FRAMERATE (STOP-MOTION)
   Simula movimento recortado artesanal em ~6 FPS sem interpolação
   ============================================================ */
.draggable-item.audio-grooving img,
.draggable-item.audio-grooving .stickers-grid {
  animation: stopMotionGroove 0.72s steps(1) infinite;
  transform-origin: 50% 90%;
}

@keyframes stopMotionGroove {
  0% {
    transform: translateY(0px) rotate(0deg) scale(1, 1);
  }
  16.66% {
    /* Frame 1 (~120ms): inclinada à esquerda com leve esticada */
    transform: translateY(-6px) rotate(-4deg) scale(0.97, 1.04);
  }
  33.33% {
    /* Frame 2: achatamento no ritmo */
    transform: translateY(3px) rotate(1.5deg) scale(1.05, 0.95);
  }
  50% {
    /* Frame 3: pulo inclinado à direita */
    transform: translateY(-5px) rotate(4deg) scale(0.96, 1.03);
  }
  66.66% {
    /* Frame 4: recuo e torção */
    transform: translateY(2px) rotate(-2deg) scale(1.03, 0.97);
  }
  83.33% {
    /* Frame 5: acento secundário */
    transform: translateY(-3px) rotate(2.5deg) scale(0.98, 1.02);
  }
  100% {
    transform: translateY(0px) rotate(0deg) scale(1, 1);
  }
}

/* ============================================================
   ANIMAÇÃO DE GUITARRA E CAMBALHOTA EM STOP-MOTION (elem_7)
   Coreografia de 16s sincronizada com o solo de guitarra
   ============================================================ */
.draggable-item.guitar-shredding img {
  animation: guitarSoloStopMotion 16s steps(1) 1 forwards;
  transform-origin: 50% 85%;
}

@keyframes guitarSoloStopMotion {
  /* 0s - 2s: Introdução do solo e primeiros acordes */
  0% { transform: translateY(0) rotate(0deg) scale(1, 1); }
  2% { transform: translateY(-4px) rotate(-8deg) scale(1, 1); }
  4% { transform: translateY(3px) rotate(6deg) scale(1, 1); }
  6% { transform: translateY(-6px) rotate(-12deg) scale(-1, 1); } /* Inversão esquerda */
  8% { transform: translateY(2px) rotate(8deg) scale(-1, 1); }
  10% { transform: translateY(-5px) rotate(-6deg) scale(1, 1); } /* Inversão direita */
  12% { transform: translateY(4px) rotate(14deg) scale(1, 1); }

  /* 2s - 5s: Aceleração do dedilhado e batida de cabeça */
  14% { transform: translateY(-8px) rotate(-16deg) scale(1.03, 0.98); }
  16% { transform: translateY(3px) rotate(10deg) scale(0.97, 1.04); }
  18% { transform: translateY(-10px) rotate(-14deg) scale(-1, 1); } /* Inverte */
  20% { transform: translateY(2px) rotate(12deg) scale(-1, 1); }
  22% { transform: translateY(-7px) rotate(-18deg) scale(-1, 1); }
  25% { transform: translateY(4px) rotate(6deg) scale(1, 1); } /* Inverte */
  28% { transform: translateY(-9px) rotate(-12deg) scale(1, 1); }
  31% { transform: translateY(2px) rotate(15deg) scale(1.05, 0.95); }

  /* 5s - 9s: Variações dinâmicas e pulos de palco */
  34% { transform: translateY(-14px) rotate(-10deg) scale(-1, 1); }
  37% { transform: translateY(3px) rotate(8deg) scale(-1, 1); }
  40% { transform: translateY(-12px) rotate(-20deg) scale(1, 1); }
  43% { transform: translateY(4px) rotate(14deg) scale(1, 1); }
  46% { transform: translateY(-8px) rotate(-6deg) scale(-1, 1); }
  49% { transform: translateY(3px) rotate(16deg) scale(-1, 1); }
  52% { transform: translateY(-11px) rotate(-15deg) scale(1, 1); }
  55% { transform: translateY(2px) rotate(10deg) scale(1, 1); }

  /* 9s - 12s: Clímax do solo rápido, agitação máxima */
  58% { transform: translateY(-15px) rotate(-22deg) scale(1.04, 0.96); }
  61% { transform: translateY(4px) rotate(18deg) scale(-1, 1); }
  64% { transform: translateY(-12px) rotate(-14deg) scale(-1, 1); }
  67% { transform: translateY(3px) rotate(20deg) scale(1, 1); }
  70% { transform: translateY(-10px) rotate(-18deg) scale(1, 1); }
  73% { transform: translateY(2px) rotate(12deg) scale(-1, 1); }

  /* 12s - 12.8s: Preparação para o salto acrobático (agachamento) */
  76% { transform: translateY(6px) rotate(-8deg) scale(1.12, 0.85); }
  79% { transform: translateY(8px) rotate(4deg) scale(1.15, 0.82); }

  /* 12.8s - 15.0s: A CAMBALHOTA COMPLETA (Full 360° Somersault no ar) */
  81% { transform: translateY(-28px) rotate(45deg) scale(1, 1); }
  83% { transform: translateY(-50px) rotate(110deg) scale(1.06, 1.06); }
  85% { transform: translateY(-68px) rotate(180deg) scale(-1, 1); } /* Totalmente de cabeça para baixo no topo */
  88% { transform: translateY(-52px) rotate(260deg) scale(-1, 1); }
  90% { transform: translateY(-24px) rotate(330deg) scale(1, 1); }
  92% { transform: translateY(5px) rotate(370deg) scale(1.12, 0.88); } /* Pouso firme e amortecido */

  /* 15.0s - 15.8s: Pose de sustentação final do solo com guitarra empinada */
  94% { transform: translateY(-10px) rotate(-16deg) scale(1.04, 1.02); }
  97% { transform: translateY(-4px) rotate(-8deg) scale(1.01, 1.01); }

  /* 16s: Retorno natural à pose de repouso */
  100% { transform: translateY(0) rotate(0deg) scale(1, 1); }
}

/* ============================================================
   EFEITO DE FLASH DE CÂMERA NA TELA (CAMERA FLASH EFFECT)
   ============================================================ */
#camera-flash-overlay {
  position: absolute;
  inset: 0;
  background: #ffffff;
  z-index: 999999;
  pointer-events: none;
  opacity: 0;
  will-change: opacity;
}

#camera-flash-overlay.flash-active {
  animation: cameraFlashBurst 0.65s cubic-bezier(0.1, 0.9, 0.2, 1) forwards;
}

@keyframes cameraFlashBurst {
  0% {
    opacity: 0.96;
  }
  12% {
    opacity: 0.88;
  }
  100% {
    opacity: 0;
  }
}

/* ============================================================
   OVERLAY TEMÁTICO DO DRÁCULA (elem_21)
   ============================================================ */
#dracula-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("./assets/images/dracula_background.jpg");
  background-size: 100% 100%;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  will-change: opacity;
}

#dracula-overlay.active {
  opacity: 0.42;
}

/* Elementos fixos que aguardam gatilho de encaixe para aparecer */
.draggable-item.hidden-trigger {
  display: none !important;
}

/* Quando revelados pelo gatilho (elementos fixos ativados por snap) */
.draggable-item.revealed {
  display: block;
}

.draggable-item.revealed:not(.victory-stopmotion-dance):not(.victory-exit-left):not(.exited) img,
.draggable-item.revealed:not(.victory-stopmotion-dance):not(.victory-exit-left):not(.exited) .stickers-grid img {
  animation: stopMotionTriggerConstantTilt 1.4s steps(1) infinite;
  transform-origin: 50% 50%;
}

@keyframes stopMotionTriggerConstantTilt {
  0% {
    transform: translateY(0px) rotate(0deg) scale(1);
  }
  16.66% {
    /* Frame 1 (~230ms): leve inclinação à esquerda */
    transform: translateY(-2px) rotate(-3.5deg) scale(1.02);
  }
  33.33% {
    /* Frame 2: retorno ao centro com sutil ajuste de pose */
    transform: translateY(1px) rotate(0.8deg) scale(0.99);
  }
  50% {
    /* Frame 3: inclinação à direita */
    transform: translateY(-2px) rotate(3.5deg) scale(1.02);
  }
  66.66% {
    /* Frame 4: leve rotação de apoio à esquerda */
    transform: translateY(1px) rotate(-2deg) scale(1);
  }
  83.33% {
    /* Frame 5: pose de transição à direita */
    transform: translateY(-1px) rotate(2deg) scale(0.99);
  }
  100% {
    transform: translateY(0px) rotate(0deg) scale(1);
  }
}

.draggable-item:active:not(.is-fixed):not(.snapped) {
  cursor: grabbing;
}

.draggable-item img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(25 * var(--stage-width, 100vw) / 100);
  max-height: calc(45 * var(--stage-height, 100vh) / 100);
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none; /* Deixa o clique e arrasto irem diretamente para o container pai .draggable-item */
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.45));
}

/* Dimensões proporcionais extraídas do Photoshop (Base 1920x1080) */
.draggable-item[data-id="elem_1"] img { width: calc(267 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_3"] img { width: calc(298 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_4"] img { width: calc(376 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_6"] img { width: calc(344 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_7"] img { width: calc(267 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_8"] img { width: calc(322 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_9"] img { width: calc(121 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_10"] img { width: calc(372 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_11"] img { width: calc(496 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_13"] img { width: calc(369 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_17"] img { width: calc(317 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_18"] img { width: calc(351 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_19"] img { width: calc(344 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_20"] img { width: calc(334 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_21"] img { width: calc(220 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_22"] img { width: calc(85 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_37"] img { width: calc(244 / 1920 * var(--stage-width, 100vw)); max-width: none; }
.draggable-item[data-id="elem_38"] img { width: calc(220 / 1920 * var(--stage-width, 100vw)); max-width: none; }

/* Grid dos Stickers (Elementos 24 a 33 em 4 colunas x 2 linhas) */
.draggable-item[data-id="grid_stickers"] .stickers-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  column-gap: calc(21 / 1920 * var(--stage-width, 100vw));
  row-gap: calc(30 / 1920 * var(--stage-width, 100vw));
  width: calc(567 / 1920 * var(--stage-width, 100vw));
  height: auto;
}

.draggable-item[data-id="grid_stickers"] .stickers-grid img {
  width: 100%;
  height: auto;
  max-width: none;
  max-height: none;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.45));
}

/* Fotos quadradas menores (galeria) */
.draggable-item[data-id="elem_34"] img,
.draggable-item[data-id="elem_35"] img,
.draggable-item[data-id="elem_36"] img {
  width: calc(126 / 1920 * var(--stage-width, 100vw));
  max-width: none;
}

/* ============================================================
   ESTADO DE ENCAIXE COM SUCESSO (SNAP)
   ============================================================ */
.draggable-item.snapping {
  transition: transform 0.22s ease-out;
}

.draggable-item.snapped:not(.is-fixed) {
  /* Contorno dourado anterior removido conforme solicitado */
  transition: transform 0.22s ease-out;
}

/* ============================================================
   SILHUETA E CONTORNO DA ÁREA DE MAPEAMENTO (TARGET PLACEHOLDER)
   ============================================================ */
.snap-target-silhouette {
  display: block !important;
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none !important;
  user-select: none !important;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  transform-origin: center center;
  line-height: 0;
  font-size: 0;
  padding: 0;
  margin: 0;
}

.snap-target-silhouette.visible {
  opacity: 1;
  visibility: visible;
}

.snap-target-silhouette img,
.snap-target-silhouette .stickers-grid img {
  pointer-events: none !important;
  user-select: none !important;
  /* Cria contorno desenhado da silhueta do elemento com brilho e pulso */
  filter: 
    brightness(0) invert(1)
    drop-shadow(1.5px 0 0 rgba(255, 255, 255, 0.95))
    drop-shadow(-1.5px 0 0 rgba(255, 255, 255, 0.95))
    drop-shadow(0 1.5px 0 rgba(255, 255, 255, 0.95))
    drop-shadow(0 -1.5px 0 rgba(255, 255, 255, 0.95))
    drop-shadow(1px 1px 0 rgba(255, 255, 255, 0.95))
    drop-shadow(-1px -1px 0 rgba(255, 255, 255, 0.95))
    drop-shadow(1px -1px 0 rgba(255, 255, 255, 0.95))
    drop-shadow(-1px 1px 0 rgba(255, 255, 255, 0.95))
    drop-shadow(0 0 10px rgba(255, 255, 255, 0.65)) !important;
  opacity: 0.38;
  animation: silhouette-pulse 1.8s ease-in-out infinite alternate;
}

@keyframes silhouette-pulse {
  0% {
    opacity: 0.28;
    transform: scale(0.995);
  }
  100% {
    opacity: 0.55;
    transform: scale(1.005);
  }
}

/* ============================================================
   CONTAINER DE MENSAGEM NO PAPEL FLUTUANTE (elem_17)
   ============================================================ */
.paper-note-popup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 800;
  pointer-events: auto;
  background: rgba(10, 12, 16, 0.45);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.paper-note-popup.visible {
  opacity: 1;
}

.paper-note-popup.hiding {
  opacity: 0;
  pointer-events: none;
}

.paper-note-card {
  position: relative;
  width: min(520px, 86vw, 34vw);
  max-width: 530px;
  margin: 0 auto;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.5)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
  transform-origin: center center;
  pointer-events: auto;
}

.paper-note-bg {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  user-select: none;
}

.paper-note-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12% 14% 10% 14%;
  box-sizing: border-box;
}

/* Animação Stop-Motion de Entrada com Leves Inclinações (elem_17) */
.paper-note-card.entrance-anim {
  animation: paperStopMotionEntrance 0.45s steps(1) 1 forwards;
}

@keyframes paperStopMotionEntrance {
  0% {
    opacity: 0;
    transform: scale(0.65) rotate(-6deg);
  }
  20% {
    opacity: 1;
    transform: scale(0.8) rotate(4deg);
  }
  40% {
    opacity: 1;
    transform: scale(0.92) rotate(-3deg);
  }
  60% {
    opacity: 1;
    transform: scale(1.05) rotate(2deg);
  }
  80% {
    opacity: 1;
    transform: scale(0.98) rotate(-1.5deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(-0.5deg);
  }
}

/* Animação Stop-Motion de Saída (após ~3 segundos do término do texto) */
.paper-note-card.exit-anim {
  animation: paperStopMotionExit 0.4s steps(1) 1 forwards;
}

@keyframes paperStopMotionExit {
  0% {
    opacity: 1;
    transform: scale(1) rotate(-0.5deg);
  }
  25% {
    opacity: 0.9;
    transform: scale(0.95) rotate(3deg);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.8) rotate(-4deg);
  }
  75% {
    opacity: 0.3;
    transform: scale(0.6) rotate(6deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.4) rotate(0deg);
  }
}

/* ============================================================
   MODAL DE VÍDEO DO YOUTUBE NO PAPEL FLUTUANTE (elem_43)
   ============================================================ */
.paper-video-popup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 850;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
  transition: opacity 0.3s ease;
}

.paper-video-popup.hiding {
  pointer-events: none;
}

.paper-video-card {
  position: relative;
  width: min(640px, 92vw, 42vw);
  max-width: 660px;
  margin: 0 auto;
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.6)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
  transform-origin: center center;
  pointer-events: auto;
}

.paper-video-bg {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  user-select: none;
}

.paper-video-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10% 12% 8.5% 12%;
  box-sizing: border-box;
}

.video-responsive-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-responsive-wrapper iframe,
.video-responsive-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain;
  background: #000;
}

.paper-video-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 50;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e76f51;
  color: #ffffff;
  border: 2px solid #ffffff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, background 0.15s ease;
  line-height: 1;
}

.paper-video-close:hover {
  background: #d94e28;
  transform: scale(1.12);
}

.paper-video-card.entrance-anim {
  animation: paperStopMotionEntrance 0.45s steps(1) 1 forwards;
}

.paper-video-card.exit-anim {
  animation: paperStopMotionExit 0.4s steps(1) 1 forwards;
}

/* ============================================================
   MODAL DE LETRA SINCRONIZADA / MÚSICA NO PAPEL (elem_1)
   ============================================================ */
.paper-lyrics-popup {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 850;
  pointer-events: auto;
  background: rgba(10, 12, 16, 0.45);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.paper-lyrics-popup.visible {
  opacity: 1;
}

.paper-lyrics-popup.hiding {
  opacity: 0;
  pointer-events: none;
}

.paper-lyrics-card {
  position: relative;
  width: min(560px, 88vw, 36vw);
  max-width: 580px;
  margin: 0 auto;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.5)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
  transform-origin: center center;
  pointer-events: auto;
}

.paper-lyrics-bg {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  user-select: none;
}

.paper-lyrics-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12% 14% 10% 14%;
  box-sizing: border-box;
}

.lyrics-container {
  width: 100%;
  min-height: 3.2em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Homemade Apple', 'Patrick Hand', cursive;
  font-size: clamp(20px, 2.1vw, 34px);
  font-weight: 700;
  line-height: 1.4;
  color: #1a1a1a;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  word-break: break-word;
}

.lyrics-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.28em;
  transition: opacity 0.25s steps(1);
}

.lyrics-word {
  opacity: 0;
  transform: translateY(2px);
  transition: opacity 0.08s ease-out, transform 0.08s ease-out;
  display: inline-block;
  will-change: opacity, transform;
}

.lyrics-word.visible {
  opacity: 1;
  transform: translateY(0);
}

.paper-lyrics-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 50;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e76f51;
  color: #ffffff;
  border: 2px solid #ffffff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s ease, background 0.15s ease;
  line-height: 1;
}

.paper-lyrics-close:hover {
  background: #d94e28;
  transform: scale(1.12);
}

.paper-lyrics-card.entrance-anim {
  animation: paperStopMotionEntrance 0.45s steps(1) 1 forwards;
}

.paper-lyrics-card.exit-anim {
  animation: paperStopMotionExit 0.4s steps(1) 1 forwards;
}

/* ============================================================
   ANIMAÇÕES DE COMEMORAÇÃO E SAÍDA FINAL DOS ELEMENTOS (STOP-MOTION)
   ============================================================ */

/* 1. Dança Comemorativa Stop-Motion de 5 segundos */
.draggable-item.victory-stopmotion-dance img,
.draggable-item.victory-stopmotion-dance .stickers-grid img {
  animation: victoryStopMotionDance 0.9s steps(1) infinite !important;
  transform-origin: 50% 50%;
}

@keyframes victoryStopMotionDance {
  0% {
    transform: translateY(0px) rotate(0deg) scale(1);
  }
  16.66% {
    /* Frame 1: Salto e inclinação à esquerda */
    transform: translateY(-8px) rotate(-6deg) scale(1.06);
  }
  33.33% {
    /* Frame 2: Leve descida e inclinação à direita */
    transform: translateY(3px) rotate(4deg) scale(0.98);
  }
  50% {
    /* Frame 3: Salto maior com inclinação acentuada */
    transform: translateY(-11px) rotate(7deg) scale(1.08);
  }
  66.66% {
    /* Frame 4: Amortecimento com leve balanço à esquerda */
    transform: translateY(2px) rotate(-4deg) scale(1);
  }
  83.33% {
    /* Frame 5: Pose empolgada intermediária */
    transform: translateY(-6px) rotate(3deg) scale(1.04);
  }
  100% {
    transform: translateY(0px) rotate(0deg) scale(1);
  }
}

/* 2. Retirada dos Elementos pelo Lado Esquerdo em Stop-Motion */
.draggable-item.victory-exit-left {
  animation: victoryExitLeftStopMotion 0.85s steps(1) 1 forwards !important;
  pointer-events: none !important;
}

@keyframes victoryExitLeftStopMotion {
  0% {
    transform: translate(var(--current-x, 0px), var(--current-y, 0px)) rotate(var(--current-rot, 0deg)) scale(var(--current-scale, 1));
    opacity: 1;
  }
  20% {
    transform: translate(calc(var(--current-x, 0px) - 25vw), calc(var(--current-y, 0px) - 15px)) rotate(calc(var(--current-rot, 0deg) - 8deg)) scale(var(--current-scale, 1));
    opacity: 1;
  }
  40% {
    transform: translate(calc(var(--current-x, 0px) - 55vw), calc(var(--current-y, 0px) + 20px)) rotate(calc(var(--current-rot, 0deg) + 12deg)) scale(var(--current-scale, 1));
    opacity: 1;
  }
  60% {
    transform: translate(calc(var(--current-x, 0px) - 90vw), calc(var(--current-y, 0px) - 20px)) rotate(calc(var(--current-rot, 0deg) - 14deg)) scale(var(--current-scale, 1));
    opacity: 1;
  }
  80% {
    transform: translate(calc(var(--current-x, 0px) - 130vw), calc(var(--current-y, 0px) + 10px)) rotate(calc(var(--current-rot, 0deg) + 8deg)) scale(var(--current-scale, 1));
    opacity: 1;
  }
  100% {
    transform: translate(calc(var(--current-x, 0px) - 180vw), var(--current-y, 0px)) rotate(var(--current-rot, 0deg)) scale(var(--current-scale, 1));
    opacity: 0;
  }
}

/* Oculta todos os elementos do cenário permanentemente após a saída final */
.draggable-item.exited,
body.final-sequence-mode #elements-container {
  display: none !important;
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* ============================================================
   MODAL DA SEQUÊNCIA FINAL (FUNDO ESVANECIDO E CARDS NO PAPEL)
   ============================================================ */
#final-overlay {
  position: absolute;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 60px);
  background: rgba(10, 12, 16, 0.45);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.75s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  box-sizing: border-box;
}

#final-overlay.visible {
  opacity: 1;
}

.final-content {
  max-width: 900px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2.5vw, 30px);
}

.final-paper-card {
  position: relative;
  width: min(520px, 86vw, 34vw);
  max-width: 530px;
  margin: 0 auto;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.5)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.35));
  transform-origin: center center;
}

.final-paper-card.entrance-anim {
  animation: paperStopMotionEntrance 0.45s steps(1) 1 forwards;
}

.final-paper-card.exit-anim {
  animation: paperStopMotionExit 0.4s steps(1) 1 forwards;
}

.final-paper-bg {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  user-select: none;
}

.final-paper-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12% 14% 10% 14%;
  box-sizing: border-box;
}

/* ============================================================
   CARD DA CÂMERA FOTOGRÁFICA PARA O VÍDEO FINAL
   ============================================================ */
.final-camera-card {
  position: absolute;
  left: 54.09%;
  top: 41.85%;
  transform: translate(-50%, -50%) rotate(0deg);
  width: 91.99%;
  max-width: none;
  aspect-ratio: 736 / 876;
  filter: drop-shadow(0 20px 48px rgba(0, 0, 0, 0.75)) drop-shadow(0 6px 16px rgba(0, 0, 0, 0.5));
  transform-origin: center center;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.final-camera-card.entrance-anim {
  animation: cameraStopMotionEntrance 0.45s steps(1) 1 forwards;
}

.final-camera-card.entrance-right-anim {
  animation: cameraStopMotionEntranceFromRight 0.5s steps(1) 1 forwards;
}

.final-camera-card.exit-anim {
  animation: cameraStopMotionExit 0.4s steps(1) 1 forwards;
}

@keyframes cameraStopMotionEntrance {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.65) rotate(-6deg);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.8) rotate(4deg);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.92) rotate(-3deg);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05) rotate(2deg);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.98) rotate(-1.5deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

@keyframes cameraStopMotionEntranceFromRight {
  0% {
    opacity: 0;
    transform: translate(60%, -50%) scale(0.65) rotate(14deg);
  }
  20% {
    opacity: 1;
    transform: translate(30%, -50%) scale(0.78) rotate(-8deg);
  }
  40% {
    opacity: 1;
    transform: translate(5%, -50%) scale(0.9) rotate(5deg);
  }
  60% {
    opacity: 1;
    transform: translate(-55%, -50%) scale(1.05) rotate(-3deg);
  }
  80% {
    opacity: 1;
    transform: translate(-48%, -50%) scale(0.98) rotate(1.5deg);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
}

@keyframes cameraStopMotionExit {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
  }
  25% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.95) rotate(3deg);
  }
  50% {
    opacity: 0.6;
    transform: translate(-50%, -50%) scale(0.8) rotate(-4deg);
  }
  75% {
    opacity: 0.3;
    transform: translate(-50%, -50%) scale(0.6) rotate(6deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }
}

/* Visor / Tela Interna da Câmera (Encaixe Calibrado da Máscara) */
.camera-screen-viewport {
  position: absolute;
  top: 40.09%;
  left: 11.95%;
  width: 51.48%;
  height: 24.00%;
  background: #000;
  overflow: hidden;
  border-radius: 4px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-video-container {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.camera-video-container video,
.camera-video-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  object-fit: cover;
  background: #000;
  display: block;
}

/* Frame da Câmera em PNG sobreposto como máscara */
.camera-frame-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  z-index: 5;
}

/* Botão de Fechar da Câmera */
.camera-video-close {
  position: absolute;
  top: -12px;
  right: -12px;
  z-index: 50;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e76f51;
  color: #ffffff;
  border: 2px solid #ffffff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s ease, background 0.15s ease;
  line-height: 1;
}

.camera-video-close:hover {
  background: #d94e28;
  transform: scale(1.14);
}

/* ============================================================
   TELA FINAL DE ENCERRAMENTO (GRAND FINALE)
   ============================================================ */
.final-overlay.grand-finale-mode {
  background: rgba(8, 10, 14, 0.98);
  backdrop-filter: blur(14px);
  transition: background 1.4s ease, backdrop-filter 1.4s ease;
}

.final-grand-screen {
  position: relative;
  width: min(880px, 92vw);
  max-width: 920px;
  margin: 0 auto;
  text-align: center;
  z-index: 20;
  pointer-events: auto;
}

.final-grand-screen.entrance-anim {
  animation: paperStopMotionEntrance 0.5s steps(1) 1 forwards;
}

.final-grand-inner {
  padding: 40px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.grand-handwritten-text {
  font-family: 'Homemade Apple', cursive, sans-serif;
  font-size: clamp(22px, 2.4vw, 36px);
  color: #ffffff;
  line-height: 1.85;
  letter-spacing: 0.5px;
  text-shadow: 0 4px 20px rgba(255, 255, 255, 0.35), 0 2px 8px rgba(0, 0, 0, 0.8);
  word-break: break-word;
  user-select: none;
  min-height: 2em;
}


