:root {
    --bg-blue: #D6E4F0;
    --accent-blue: #D2DCE6;
    --text-dark: #333333;
    --white: #FFFFFF;
    --green-wedding: #385A40;
    --font-body: 'Outfit', sans-serif;
    --bg-paper: #F2F0E6;
}

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

html {
    scroll-behavior: smooth;
    background-color: var(--bg-paper);
    overscroll-behavior: none;
    /* ELIMINADO: scroll-padding-top (Usaremos tu código específico abajo) */
}

body {
    font-family: var(--font-body);
    font-weight: 300;
    background-color: var(--bg-paper);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    scrollbar-gutter: stable;
    overscroll-behavior: none;
}

.hidden {
    display: none !important;
}

/* --- TU CÓDIGO RECUPERADO (Maneja el Scroll perfectamente) --- */
#historia,
#regalos,
#rsvp,
#final,
#dresscode,
#evento,
#faq {
    scroll-margin-top: 130px;
}

#inicio {
    scroll-margin-top: 180px;
}

/* --- PANTALLA DE INICIO --- */
#envelope-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-paper);
    background-image: url('/assets/images/Fondo-Inicio.webp');
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;

    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    transition: opacity 0.8s;
}

.desktop-bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* CONTENEDOR MAESTRO */
.ratio-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 10;
    overflow: hidden;
}

/* ILUSTRACIÓN */
.bg-illustration {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    z-index: 1;
}

/* LOGIN */
.login-container {
    position: absolute;
    z-index: 20;
    background-color: transparent;
    bottom: 7%;
    left: 50%;
    transform: translateX(-50%);
    width: 75%;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* === NUBE SVG EMBEBIDA === */
.login-box-container {
    width: 100%;
    height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 65' preserveAspectRatio='none'%3E%3Cpath d='M10,5 Q25,-2 40,5 T70,5 T100,5 T130,5 T160,5 T190,5 T220,5 T250,5 T280,5 Q295,-2 300,15 Q305,32 295,50 Q285,67 270,60 T240,60 T210,60 T180,60 T150,60 T120,60 T90,60 T60,60 T30,60 Q15,67 5,50 Q-5,32 5,15 Q0,10 10,5 Z' fill='%23ffffff' stroke='%23333333' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 100% 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: transparent;
    padding: 0 20px;
    transform: rotate(-1.5deg);
    filter: drop-shadow(4px 4px 0px rgba(0, 0, 0, 0.8));
}

#access-code {
    width: 100%;
    height: 100%;
    padding: 5px;
    background: transparent;
    border: none;
    text-align: center;
    text-transform: uppercase;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px;
    letter-spacing: 1px;
    color: #333;
    outline: none;
    padding-top: 5px;
}

#access-code::placeholder {
    color: #666;
    opacity: 0.6;
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 1px;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-2px);
    }

    75% {
        transform: translateX(2px);
    }

    100% {
        transform: translateX(0);
    }
}

.login-box-container:focus-within {
    animation: shake 0.3s ease-in-out;
}

/* BOTÓN ENTRAR */
.btn-enter {
    background: var(--green-wedding);
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-body);
    font-size: 0.85rem;
    letter-spacing: 1px;
    box-shadow: 0 4px 10px rgba(56, 90, 64, 0.3);
    transition: transform 0.2s;
    z-index: 2;
    margin-top: 35px;
}

.btn-enter:active {
    transform: scale(0.95);
}

/* MENSAJE DE ERROR */
.error-msg-start {
    position: absolute;
    bottom: 2%;
    width: 90%;
    max-width: 300px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    color: #D32F2F;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: opacity 0.3s;
    z-index: 25;
    pointer-events: none;
}

.error-msg-start:empty {
    display: none;
}

/* === REGLA ESPECIAL PARA ESCRITORIO === */
@media (min-width: 768px) {
    .ratio-wrapper {
        width: 430px;
        height: 90vh;
        margin: 0 auto;
        border-radius: 20px;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
        background-color: var(--bg-paper);
    }

    .bg-illustration {
        object-fit: cover;
        border-radius: 20px;
    }

    .desktop-bg {
        background-image: url('/assets/images/Fondo-Inicio.webp');
        background-size: cover;
        filter: blur(8px);
    }
}

/* === AJUSTE PARA PANTALLAS PEQUEÑAS === */
@media (max-height: 700px) {
    .login-container {
        bottom: 4%;
    }

    .login-box-container {
        height: 55px;
    }

    #access-code {
        font-size: 14px;
    }

    .btn-enter {
        padding: 10px 30px;
        margin-top: 25px;
    }

    .error-msg-start {
        bottom: 1%;
    }
}

#invitation {
    display: none;
    width: 100%;

    /* CAMBIO 1: Usar dvh para que no baile con la barra de direcciones del celular */
    height: 100dvh;

    overflow-y: auto;
    background: #f9f9f9;

    /* CAMBIO 2: Esto BLOQUEA el rebote al final de la página */
    overscroll-behavior-y: none;

    /* CAMBIO 3: Scroll suave */
    -webkit-overflow-scrolling: touch;
}

#invitation.active {
    display: block;
    animation: fadeIn 1s forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.sticky-menu-wrapper {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.sticky-menu-wrapper img {
    width: 100%;
    display: block;
}

.seamless-scroll {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    line-height: 0;
    font-size: 0;
    margin-top: -1px;
    contain: content;
}

.seamless-scroll img {
    display: block;
    width: 100%;
    height: auto;
    border: none;
    margin: 0;
    padding: 0;
    min-height: 200px;
    background-color: #fafafa;
}

#separador {
    min-height: auto !important;
    height: auto !important;
    width: 100%;
    object-fit: contain;
}

.portada-wrapper {
    position: relative;
    width: 100%;
}

.portada-bg {
    display: block;
    width: 100%;
    height: auto;
}

.countdown-overlay {
    position: absolute;
    bottom: 8%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 20;
    justify-content: center;
}

.countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #222222;
}

.countdown-item span:first-child {
    font-family: "Courier New", monospace !important;
    font-size: 60px;
    line-height: 1;
    letter-spacing: -2px;
}

.separator {
    font-family: "Courier New", monospace !important;
    font-size: 60px;
    line-height: 0.9;
    color: #222222;
    margin-top: -5px;
}

.countdown-item .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-family: var(--font-body);
    font-weight: 500;
    letter-spacing: 1px;
    opacity: 0.7;
    margin-top: -5px;
}

.hotspot {
    position: absolute;
    top: 0;
    height: 100%;
    cursor: pointer;
    z-index: 50;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.map-hotspot {
    position: absolute;
    z-index: 20;
    cursor: pointer;
    left: 50%;
    transform: translateX(-50%);
    width: 275px;
    height: 30px;
}

.spot-iglesia {
    top: 55%;
}

.spot-sala {
    top: 87%;
}

.rsvp-wrapper {
    position: relative;
    width: 100%;
    min-height: 800px;
    overflow: hidden;
}

.rsvp-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rsvp-content-container {
    position: relative;
    z-index: 1;
    width: 100%;
    padding-top: 160px;
    display: flex;
    justify-content: center;
}

.iframe-box {
    width: 100%;
    max-width: 500px;
    height: 600px;
    border-radius: 12px;
    overflow: hidden;
}

#rsvp-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

@media (max-width: 768px) {
    .countdown-overlay {
        bottom: 7%;
        gap: 4px;
    }

    .countdown-item span:first-child {
        font-size: 45px !important;
        line-height: 1;
        color: #060606;
    }

    .separator {
        font-size: 45px;
        line-height: 0.9;
    }

    .countdown-item .label {
        font-size: 0.5rem;
        margin-top: 2px;
    }

    .rsvp-wrapper {
        min-height: 500px;
    }

    .rsvp-content-container {
        padding-top: 80px;
        padding-left: 20px;
        padding-right: 20px;
        padding-bottom: 30px;
        overflow: hidden;
    }

    .iframe-box {
        width: 100%;
        height: 450px;
        margin: 0 auto;
        display: block;
        overflow: hidden;
        border-radius: 12px;
    }

    #rsvp-iframe {
        transform: scale(0.75);
        transform-origin: top left;
        width: 134%;
        height: 160%;
    }
}