/* ==========================================================================
   style.css - Parallax Scroll Animation Navideña
   Studio Mix - Campaña Cartas a Santa
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800;900&family=Playfair+Display:ital,wght@1,600&display=swap');

:root {
    --primary-sky-top: #0077c8;
    --primary-sky-mid: #009de5;
    --primary-sky-cyan: #00c7ea;
    --primary-sky-light: #5de7de;
    --candy-red: #d32027;
    --candy-dark: #a1141a;
    --gold: #ffcf40;
    --white: #ffffff;
    --shadow-blue: rgba(0, 72, 130, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* IMPORTANTE: no usar height:100% ni overflow en <body>.
   Si el body se convierte en contenedor de scroll, la ventana (window) deja
   de desplazarse y ScrollTrigger no detecta el scroll. */
html {
    overflow-x: hidden;
}

body {
    width: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--primary-sky-top);
    font-family: 'Montserrat', sans-serif;
    color: var(--white);
}

/* Espaciador de scroll para el motor GSAP ScrollTrigger
   (en flujo normal: es lo que le da altura real al documento) */
.scroll-dist {
    position: relative;
    width: 100%;
    height: 5200px;
    pointer-events: none;
}

/* Viewport fijo que contiene todo el escenario */
#fixed-viewport {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 2;
    background: linear-gradient(180deg, var(--primary-sky-top) 0%, var(--primary-sky-mid) 38%, var(--primary-sky-cyan) 72%, var(--primary-sky-light) 100%);
}

/* Cielo dinámico con gradiente */
#sky-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, #0072c6 0%, #009be4 38%, #00c8eb 72%, #68e8e1 100%);
    z-index: 1;
    pointer-events: none;
}

/* Canvas para las partículas de nieve cayendo */
#snow-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 15;
    pointer-events: none;
}

/* Contenedor del escenario que conserva exactamente la proporción 3840 / 2336 */
.stage-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max(100vw, calc(100vh * (3840 / 2336)));
    height: max(100vh, calc(100vw * (2336 / 3840)));
    pointer-events: none;
    /* Debe quedar POR ENCIMA de #sky-bg (z-index:1). Sin esto, el degradado
       opaco del cielo tapaba todas las capas PNG. */
    z-index: 2;
}

/* Capas Parallax */
.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: transform, opacity;
    pointer-events: none;
}

.parallax-layer picture {
    width: 100%;
    height: 100%;
    display: block;
}

.parallax-layer img {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Profundidad Z-Index de cada capa */
#layer-cordillera { z-index: 2; }
#layer-colinas    { z-index: 3; }
#layer-bosque     { z-index: 4; }
#layer-pinos      { z-index: 6; }
#layer-suelo      { z-index: 8; }
#layer-buzon      { z-index: 9; }
#layer-marco      { z-index: 10; }
#layer-letrero    { 
    z-index: 12; 
    transform-origin: 50% 50%; 
}

/* --------------------------------------------------------------------------
   ESCENA 1: PANTALLA DE BIENVENIDA (HERO)
   -------------------------------------------------------------------------- */
#hero-welcome {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    pointer-events: none;
    text-align: center;
    padding: 2rem;
    will-change: transform, opacity;
}

.welcome-title {
    font-size: clamp(1.8rem, 4.6vw, 4.2rem);
    font-weight: 800;
    color: var(--white);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0 0 1rem 0;
    text-shadow: 0 6px 24px var(--shadow-blue);
    line-height: 1.15;
}

.welcome-logo-wrap {
    width: min(85vw, 680px);
    display: flex;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.welcome-logo-wrap picture {
    width: 100%;
    display: block;
}

.welcome-logo-wrap img {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 6px 20px rgba(0, 60, 110, 0.4));
}

.scroll-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: clamp(0.82rem, 1.35vw, 1.05rem);
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.98);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.75rem 1.6rem;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    animation: floatBounce 2s ease-in-out infinite;
    max-width: 92vw;
    text-align: center;
}

.scroll-indicator svg {
    width: 30px;
    height: 30px;
    fill: #ffffff;
    filter: drop-shadow(0 2px 6px rgba(0, 35, 75, 0.55));
    animation: arrowDown 1.35s ease-in-out infinite;
}

/* Texto vertical sutil lateral izquierdo al hacer scroll (sin burbuja ni sombra) */
.side-scroll-guide {
    position: fixed;
    left: 14px;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    z-index: 22;
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.6rem, 0.95vw, 0.74rem);
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.72);
    background: none;
    border: none;
    box-shadow: none;
    text-shadow: none;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    will-change: opacity;
}

@keyframes floatBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes arrowDown {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

/* --------------------------------------------------------------------------
   ESCENA FINAL: INTERACTIVIDAD Y LLAMADO A LA ACCIÓN
   -------------------------------------------------------------------------- */
#final-interactive {
    position: absolute;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    opacity: 0;
    visibility: hidden;
    will-change: opacity, transform;
}

.btn-cta-santa {
    background: linear-gradient(135deg, #e52d27 0%, #b31217 100%);
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50px;
    padding: 1rem 2.4rem;
    font-size: clamp(1rem, 1.5vw, 1.25rem);
    font-weight: 700;
    font-family: 'Montserrat', sans-serif;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(179, 18, 23, 0.6), 0 0 20px rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-transform: uppercase;
}

.btn-cta-santa:hover {
    transform: translateY(-4px) scale(1.04);
    box-shadow: 0 12px 36px rgba(179, 18, 23, 0.8), 0 0 30px rgba(255, 255, 255, 0.6);
    background: linear-gradient(135deg, #f0332d 0%, #c4151b 100%);
}

.btn-cta-santa:active {
    transform: translateY(0) scale(0.98);
}

.scroll-hint-restart {
    font-size: 0.88rem;
    font-weight: 700;
    color: #153B5F;
    text-shadow: none;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.scroll-hint-restart:hover {
    opacity: 0.85;
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   BOTÓN DE AUDIO / MÚSICA AMBIENTAL
   -------------------------------------------------------------------------- */
#audio-toggle-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 30;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

#audio-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

#audio-toggle-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
    transition: transform 0.2s;
}

#audio-toggle-btn.playing {
    background: rgba(211, 32, 39, 0.85);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(211, 32, 39, 0.6);
    animation: pulseRing 2s infinite;
}

@keyframes pulseRing {
    0% { box-shadow: 0 0 0 0 rgba(211, 32, 39, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(211, 32, 39, 0); }
    100% { box-shadow: 0 0 0 0 rgba(211, 32, 39, 0); }
}

/* --------------------------------------------------------------------------
   MODAL INTERACTIVO: SOBRE 3D + CARTA A SANTA DESPLEGABLE
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 18, 42, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease, background 0.5s ease, backdrop-filter 0.5s ease;
    perspective: 1600px;
    overflow-y: auto;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Cuando el sobre vuela hacia la ranura del buzón, quitamos el oscurecimiento
   para que el usuario vea el buzón 3D claramente en el fondo */
.modal-overlay.flying-to-mailbox {
    background: rgba(0, 18, 42, 0.08);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    overflow: hidden;
}

/* ==========================================================================
   ESCENA A: SOBRE NAVIDEÑO 3D
   ========================================================================== */
.envelope-stage {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 120;
    pointer-events: none;
    perspective: 1200px;
    will-change: transform, opacity, clip-path;
}

.christmas-envelope {
    position: relative;
    width: min(86vw, 420px);
    height: min(56vw, 270px);
    transform-style: preserve-3d;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    border-radius: 6px;
}

/* Pared trasera interior del sobre */
.env-back {
    position: absolute;
    inset: 0;
    background: #dfcfb6;
    border-radius: 6px;
    border: 3px solid #bd1622;
    z-index: 1;
}

/* Carta doblada que sale y entra del bolsillo del sobre */
.env-letter-insert {
    position: absolute;
    left: 6%;
    right: 6%;
    top: 8%;
    height: 82%;
    background: #f6ebda;
    border: 6px solid transparent;
    border-image: repeating-linear-gradient(-45deg, #bd1622 0 10px, #f6ebda 10px 20px) 6;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.18);
    z-index: 2;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    will-change: transform;
}

.env-mini-heading {
    font-family: 'Kalam', cursive;
    color: #bd1622;
    font-size: 1.35rem;
    font-weight: 700;
    display: block;
    margin-bottom: 8px;
}

.env-mini-lines {
    width: 100%;
    height: 75px;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 14px,
        rgba(0, 0, 0, 0.25) 14px,
        rgba(0, 0, 0, 0.25) 16px
    );
}

/* Bolsillo frontal del sobre */
.env-pocket {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, #f6ebda 0%, #ede0ca 100%);
    border-radius: 6px;
    z-index: 3;
    clip-path: polygon(0 0, 50% 42%, 100% 0, 100% 100%, 0 100%);
    border-bottom: 10px solid transparent;
    box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 16px 20px;
}

.env-pocket::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 12px;
    background: repeating-linear-gradient(-45deg, #bd1622 0 14px, #f6ebda 14px 28px);
}

.env-pocket-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    margin-bottom: 6px;
}

.env-to-label {
    font-size: 0.78rem;
    font-weight: 800;
    color: #bd1622;
    letter-spacing: 0.05em;
}

.env-brand-sub {
    font-size: 0.65rem;
    font-weight: 700;
    color: #333;
    letter-spacing: 0.08em;
}

.env-corner-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    margin-bottom: 6px;
    opacity: 0.85;
}

/* Solapa triangular superior 3D */
.env-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 56%;
    background: linear-gradient(180deg, #e8d8be 0%, #f6ebda 100%);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform-origin: top center;
    transform-style: preserve-3d;
    z-index: 4;
    border-top: 8px solid #bd1622;
    will-change: transform;
}

.env-wax-seal {
    position: absolute;
    top: 54%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(56px, 14vw, 72px);
    height: clamp(56px, 14vw, 72px);
    object-fit: contain;
    z-index: 6;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.38));
    pointer-events: none;
    user-select: none;
    will-change: transform, opacity;
}

/* ==========================================================================
   ESCENA B: CARTA A SANTA DESDOBLADA (Réplica de Carta-a-Santa.png)
   ========================================================================== */
.carta-wrapper {
    position: relative;
    width: min(94vw, 650px);
    max-width: calc(100vw - 20px);
    min-width: 0;
    max-height: 92vh;
    overflow-x: hidden;
    overflow-y: auto;
    z-index: 110;
    transform-origin: center center;
    transform-style: preserve-3d;
    border-radius: 4px;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.55);
    will-change: transform, opacity;
    scrollbar-width: thin;
    scrollbar-color: #bd1622 #f6ebda;
}

/* Líneas sutiles de pliegue del papel desdoblado */
.paper-crease {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.08), rgba(255,255,255,0.4));
    z-index: 15;
    pointer-events: none;
}
.crease-1 { top: 33.3%; }
.crease-2 { top: 66.6%; }

/* Marco exterior con franjas diagonales rojas y crema (Airmail / Caramelo) */
.carta-airmail-frame {
    background: repeating-linear-gradient(
        -45deg,
        #bd1622 0px,
        #bd1622 24px,
        #f6ebda 24px,
        #f6ebda 50px
    );
    padding: 16px;
}

/* Hoja interior color pergamino crema (#F6EBDA) */
.carta-parchment {
    position: relative;
    background-color: #f6ebda;
    color: #111111;
    padding: 1.8rem 2.3rem 1.8rem;
    overflow: hidden;
}

/* Botón cerrar esquina superior derecha */
.btn-close-carta {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1.5px solid rgba(189, 22, 34, 0.35);
    background: rgba(246, 235, 218, 0.9);
    color: #bd1622;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.btn-close-carta:hover {
    background: #bd1622;
    color: #fff;
    transform: scale(1.08);
}

/* Marca de agua central "S" de Studio Mix */
.carta-watermark-s {
    position: absolute;
    top: 48%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1.22);
    width: 84%;
    max-width: 500px;
    opacity: 0.055;
    pointer-events: none;
    user-select: none;
    z-index: 1;
}

/* Encabezado superior: Querido Santa : + Estampilla Postal */
.carta-top-header {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 1.1rem;
}

.querido-santa-title {
    font-family: 'Kalam', 'Caveat', cursive;
    font-size: clamp(2rem, 4.5vw, 3.2rem);
    font-weight: 700;
    color: #bd1622;
    margin: 0;
    line-height: 1.05;
    letter-spacing: 0.01em;
}

.carta-stamp-box {
    width: clamp(120px, 26%, 185px);
    flex-shrink: 0;
    margin-right: 14px;
}

.carta-stamp-box img {
    width: 100%;
    height: auto;
    display: block;
}

/* Formulario general */
.carta-form {
    position: relative;
    z-index: 5;
    width: 100%;
}

/* Renglones de texto con línea negra inferior */
.carta-line-field {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 0.85rem;
    width: 100%;
}

.carta-line-field label {
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.72rem, 1.5vw, 0.92rem);
    font-weight: 800;
    color: #0d0d0d;
    white-space: nowrap;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}

.carta-line-field input {
    flex: 1 1 0%;
    width: 0;
    min-width: 50px;
    border: none;
    border-bottom: 1.8px solid #1a1a1a;
    background: transparent;
    font-family: 'Kalam', cursive;
    font-size: 1.08rem;
    font-weight: 700;
    color: #162b4d;
    padding: 0 6px 1px;
    outline: none;
    border-radius: 0;
}

.carta-line-field input:focus {
    border-bottom-color: #bd1622;
}

.carta-ig-block {
    margin-bottom: 0.85rem;
}

.carta-ig-block .carta-line-field {
    margin-bottom: 0.55rem;
}

.carta-extra-underline {
    width: 52%;
    margin-left: auto;
    border-bottom: 1.8px solid #1a1a1a;
    height: 12px;
}

/* Renglón de Edad y Marca Brasileña Favorita */
.carta-age-brand-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.72rem, 1.5vw, 0.92rem);
    font-weight: 800;
    color: #0d0d0d;
    margin: 0.95rem 0 0.75rem;
}

.carta-inline-age {
    width: 62px;
    border: none;
    border-bottom: 1.8px solid #1a1a1a;
    background: transparent;
    font-family: 'Kalam', cursive;
    font-size: 1.1rem;
    font-weight: 700;
    color: #bd1622;
    text-align: center;
    padding: 0 2px;
    outline: none;
    -moz-appearance: textfield;
}

.carta-inline-age::-webkit-outer-spin-button,
.carta-inline-age::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Fila de 5 Opciones de Marcas Brasileñas (MOLECA, MODARE, VIZZANO, BEIRA RIO, TODAS) */
.carta-brands-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 10px;
    margin: 0.6rem 0 1.15rem;
    padding: 0 2px;
}

.carta-brand-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.carta-brand-option input[type="radio"],
.carta-brand-option input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.brand-checkbox-box {
    width: 20px;
    height: 20px;
    border: 2px solid #bd1622;
    background: rgba(255, 255, 255, 0.35);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
    position: relative;
    flex-shrink: 0;
}

.carta-brand-option input[type="radio"]:checked + .brand-checkbox-box,
.carta-brand-option input[type="checkbox"]:checked + .brand-checkbox-box {
    background: #bd1622;
    box-shadow: 0 0 0 3px rgba(189, 22, 34, 0.2);
}

.carta-brand-option input[type="radio"]:checked + .brand-checkbox-box::after,
.carta-brand-option input[type="checkbox"]:checked + .brand-checkbox-box::after {
    content: '✓';
    color: #fff;
    font-size: 0.9rem;
    font-weight: 900;
    line-height: 1;
}

.brand-label-text {
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.72rem, 1.35vw, 0.85rem);
    font-weight: 800;
    color: #0d0d0d;
    white-space: nowrap;
}

/* Sección ME GUSTARÍA PEDIRTE: con 5 líneas rayadas */
.carta-wish-section {
    margin-bottom: 1rem;
}

.carta-section-label {
    display: block;
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.75rem, 1.5vw, 0.92rem);
    font-weight: 800;
    color: #0d0d0d;
    margin-bottom: 0.35rem;
}

.carta-ruled-wrap {
    width: 100%;
}

.carta-ruled-wrap textarea {
    width: 100%;
    height: 160px;
    border: none;
    background-color: transparent;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 30px,
        #1a1a1a 30px,
        #1a1a1a 32px
    );
    font-family: 'Kalam', cursive;
    font-size: 1.08rem;
    font-weight: 700;
    color: #162b4d;
    line-height: 32px;
    padding: 0 4px;
    resize: none;
    outline: none;
}

.carta-ruled-wrap textarea::placeholder {
    color: rgba(0, 0, 0, 0.32);
    font-family: 'Kalam', cursive;
}

/* POSDATA: NUM. TICKET + SUCURSAL en la misma fila horizontal */
.carta-posdata-section {
    margin-bottom: 1.05rem;
}

.carta-ticket-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 20px;
    margin-top: 0.55rem;
    width: 100%;
}

.carta-ticket-col {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1 1 0%;
    min-width: 0;
}

.carta-ticket-col label {
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.72rem, 1.45vw, 0.9rem);
    font-weight: 800;
    color: #0d0d0d;
    white-space: nowrap;
    flex-shrink: 0;
}

.carta-ticket-col input {
    flex: 1 1 0%;
    width: 0;
    min-width: 40px;
    border: none;
    border-bottom: 1.8px solid #1a1a1a;
    background: transparent;
    font-family: 'Kalam', cursive;
    font-size: 1.05rem;
    font-weight: 700;
    color: #162b4d;
    padding: 0 4px 1px;
    outline: none;
    border-radius: 0;
}

/* Botón SUBE LA FOTO DE TU TICKET y panel OCR */
.carta-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin: 1.1rem 0 0.8rem;
}

.btn-upload-ticket {
    background-color: #bd1622;
    color: #ffffff;
    border: none;
    padding: 0.72rem 1.6rem;
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.75rem, 1.4vw, 0.86rem);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(189, 22, 34, 0.35);
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.btn-upload-ticket:hover {
    background-color: #9e111b;
    transform: translateY(-2px);
}

/* ==========================================================================
   MINI-MODAL PARA ELEGIR CÁMARA O SUBIR ARCHIVO DE TICKET
   ========================================================================== */
.ticket-source-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 14, 34, 0.68);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 160;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeInSourceModal 0.2s ease;
}

.ticket-source-overlay[hidden] {
    display: none !important;
}

@keyframes fadeInSourceModal {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.ticket-source-card {
    position: relative;
    width: min(92vw, 390px);
    background: #f6ebda;
    border: 4px solid #bd1622;
    border-radius: 16px;
    padding: 1.6rem 1.4rem 1.4rem;
    text-align: center;
    box-shadow: 0 22px 55px rgba(0, 0, 0, 0.55);
    color: #162b4d;
}

.ticket-source-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid rgba(189, 22, 34, 0.35);
    background: rgba(255, 255, 255, 0.7);
    color: #bd1622;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ticket-source-close:hover {
    background: #bd1622;
    color: #fff;
}

.ticket-source-icon {
    font-size: 2.3rem;
    margin-bottom: 0.35rem;
}

.ticket-source-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.08rem;
    font-weight: 800;
    color: #bd1622;
    margin: 0 0 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.ticket-source-desc {
    font-size: 0.84rem;
    color: #334155;
    margin: 0 0 1.1rem;
    line-height: 1.35;
    font-weight: 600;
}

.ticket-source-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-source-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    border: 2px solid rgba(189, 22, 34, 0.25);
    background: #ffffff;
    color: #153B5F;
    font-family: 'Montserrat', sans-serif;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.btn-source-option:hover {
    border-color: #bd1622;
    background: #fff9f5;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(189, 22, 34, 0.18);
}

.btn-source-option.camera {
    background: linear-gradient(135deg, #bd1622 0%, #96101a 100%);
    color: #ffffff;
    border-color: #bd1622;
}

.btn-source-option.camera:hover {
    background: linear-gradient(135deg, #d11926 0%, #a8121d 100%);
}

.source-opt-emoji {
    font-size: 1.65rem;
    flex-shrink: 0;
}

.source-opt-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.source-opt-text strong {
    font-size: 0.88rem;
    font-weight: 800;
}

.source-opt-text small {
    font-size: 0.74rem;
    opacity: 0.85;
    font-weight: 600;
}

.ticket-ocr-panel {
    width: 100%;
    max-width: 440px;
    background: rgba(255, 255, 255, 0.75);
    border: 1.5px solid rgba(189, 22, 34, 0.35);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ticket-ocr-panel[hidden] {
    display: none !important;
}

.ticket-preview-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ccc;
    flex-shrink: 0;
    background: #eee;
}

.ticket-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ticket-ocr-info {
    flex: 1;
    min-width: 0;
    text-align: left;
}

.ocr-status-text {
    font-size: 0.78rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 5px;
    line-height: 1.3;
}

.ocr-status-text.valid {
    color: #116622;
}

.ocr-status-text.warning {
    color: #995500;
}

.ocr-status-text.error {
    color: #bd1622;
}

.ocr-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    overflow: hidden;
}

.ocr-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #bd1622, #ffcf40);
    transition: width 0.25s ease;
}

/* Mensajes de validación del formulario */
.carta-form-feedback {
    margin: 0.5rem auto;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    text-align: center;
    max-width: 95%;
}

.carta-form-feedback.error {
    background: rgba(189, 22, 34, 0.12);
    border: 1.5px solid #bd1622;
    color: #9e111b;
}

.carta-form-feedback.success {
    background: rgba(20, 130, 50, 0.12);
    border: 1.5px solid #148232;
    color: #0f6326;
}

/* Botón final para doblar la carta y enviarla al buzón */
.carta-submit-row {
    display: flex;
    justify-content: center;
    margin-top: 0.9rem;
    padding-right: 48px;
}

.btn-submit-carta {
    background: linear-gradient(135deg, #1b6b3a 0%, #0f4724 100%);
    color: #ffffff;
    border: 2px solid #ffcf40;
    border-radius: 50px;
    padding: 0.78rem 1.8rem;
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.74rem, 1.5vw, 0.92rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(15, 71, 36, 0.4);
    transition: all 0.25s ease;
    max-width: 100%;
}

.btn-submit-carta:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(15, 71, 36, 0.6);
}

.btn-submit-carta:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Logotipo circular "S" en la esquina inferior derecha */
.carta-bottom-logo {
    position: absolute;
    bottom: 2px;
    right: 0px;
    width: 52px;
    height: 52px;
    object-fit: contain;
    pointer-events: none;
}

/* ==========================================================================
   ESCENA C: TOAST DE ÉXITO TRAS ENTRAR AL BUZÓN
   ========================================================================== */
.letter-success-toast {
    position: fixed;
    bottom: 35px;
    left: 50%;
    transform: translateX(-50%);
    width: min(92vw, 440px);
    background: rgba(255, 253, 248, 0.97);
    color: #222;
    border-radius: 20px;
    padding: 1.6rem 1.8rem;
    text-align: center;
    box-shadow: 0 20px 55px rgba(0, 0, 0, 0.5), 0 0 0 6px rgba(189, 22, 34, 0.25);
    border: 3px solid #bd1622;
    z-index: 140;
}

.letter-success-toast[hidden] {
    display: none !important;
}

.letter-success-toast .icon-sparkle {
    font-size: 2.6rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    animation: floatBounce 2s infinite;
}

.letter-success-toast h3 {
    color: #bd1622;
    font-size: 1.35rem;
    margin-bottom: 0.45rem;
    font-weight: 800;
}

.letter-success-toast p {
    color: #444;
    font-size: 0.92rem;
    line-height: 1.45;
    margin-bottom: 1rem;
}

.btn-close-success {
    background: linear-gradient(135deg, #bd1622 0%, #8e0e00 100%);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 0.65rem 1.6rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ==========================================================================
   MEDIA QUERIES: RESPONSIVE MOBILE & TABLET (< 768px)
   ========================================================================== */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0.5rem;
    }

    .carta-wrapper {
        width: 96vw;
        max-width: calc(100vw - 12px);
        max-height: 94vh;
    }

    .welcome-title {
        font-size: clamp(1.4rem, 6.2vw, 2.4rem);
        letter-spacing: 0.02em;
        line-height: 1.2;
        padding: 0 10px;
        margin-bottom: 0.8rem;
    }

    .welcome-logo-wrap {
        width: min(85vw, 420px);
        margin-bottom: 2rem;
    }

    .scroll-indicator {
        font-size: 0.72rem;
        padding: 0.6rem 1.1rem;
        gap: 6px;
        letter-spacing: 0.06em;
    }

    .scroll-indicator svg {
        width: 26px;
        height: 26px;
    }

    .side-scroll-guide {
        left: 7px;
        font-size: 0.56rem;
        letter-spacing: 0.13em;
        color: rgba(255, 255, 255, 0.75);
    }

    #final-interactive {
        bottom: 18px;
        width: 90%;
        max-width: 330px;
    }

    .btn-cta-santa {
        padding: 0.75rem 1.2rem;
        font-size: clamp(0.78rem, 3.8vw, 0.95rem);
        width: 100%;
        max-width: 320px;
        justify-content: center;
        gap: 8px;
        white-space: nowrap;
        letter-spacing: 0.03em;
    }

    #audio-toggle-btn {
        top: 16px;
        right: 16px;
        width: 42px;
        height: 42px;
    }

    #audio-toggle-btn svg {
        width: 18px;
        height: 18px;
    }

    .carta-airmail-frame {
        padding: 10px;
    }

    .carta-parchment {
        padding: 1.15rem 1rem 1.35rem;
    }

    .querido-santa-title {
        font-size: clamp(1.65rem, 6.2vw, 2.2rem);
    }

    .carta-stamp-box {
        width: 102px;
        margin-right: 26px;
    }

    .carta-line-field label,
    .carta-age-brand-line,
    .carta-section-label,
    .carta-ticket-col label {
        font-size: 0.7rem;
    }

    .carta-brands-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 10px;
    }

    .carta-ticket-row {
        flex-wrap: wrap;
        gap: 10px 14px;
    }

    .carta-ticket-col {
        flex: 1 1 135px;
    }

    .carta-submit-row {
        padding-right: 36px;
        margin-bottom: 0.4rem;
    }

    .btn-submit-carta {
        padding: 0.68rem 1rem;
        font-size: 0.72rem;
        line-height: 1.25;
    }

    .carta-bottom-logo {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 380px) {
    .btn-cta-santa {
        font-size: 0.76rem;
        padding: 0.65rem 0.9rem;
        gap: 6px;
    }

    .welcome-title {
        font-size: 1.35rem;
    }

    .carta-parchment {
        padding: 0.95rem 0.75rem 1.15rem;
    }

    .carta-stamp-box {
        width: 88px;
        margin-right: 24px;
    }
}

