/* =========================================
   RESET & BASE
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body,
html {
    width: 100%;
    height: 100%;
    font-family: 'Montserrat', sans-serif;
    background-color: #050012;
    color: #fff;
    overflow: hidden;
}

/* =========================================
   FONDO
   ========================================= */
.background-container {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* Chibi wrapper — rebote suave */
.chibi-wrapper {
    display: flex;
    justify-content: center;
    margin-bottom: 0.8rem;
}

.chibi-tanjiro {
    width: 120px;
    height: auto;
    animation: chibi-bounce 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(180, 80, 255, 0.4));
}

@keyframes chibi-bounce {
    0% {
        transform: translateY(0) rotate(-1deg);
    }

    30% {
        transform: translateY(-8px) rotate(0deg);
    }

    60% {
        transform: translateY(-4px) rotate(1deg);
    }

    100% {
        transform: translateY(0) rotate(-1deg);
    }
}

/* Corazón flotante pulsante */
.heart-float {
    transform-origin: 80px 28px;
    animation: heart-pulse 1.4s ease-in-out infinite;
}

@keyframes heart-pulse {
    0% {
        transform: scale(1) translateY(0);
    }

    25% {
        transform: scale(1.18) translateY(-3px);
    }

    50% {
        transform: scale(1) translateY(-5px);
    }

    75% {
        transform: scale(1.12) translateY(-2px);
    }

    100% {
        transform: scale(1) translateY(0);
    }
}


/* Estrellas */
.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle var(--dur, 3s) ease-in-out infinite alternate;
    animation-delay: var(--del, 0s);
}

@keyframes twinkle {
    0% {
        opacity: 0.1;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Neblinas de color */
.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    animation: drift 12s ease-in-out infinite alternate;
}

.glow-purple {
    width: 65vw;
    height: 65vw;
    bottom: -15%;
    left: 15%;
    background: radial-gradient(circle, rgba(123, 31, 162, 0.55) 0%, transparent 70%);
    animation-duration: 10s;
}

.glow-pink {
    width: 50vw;
    height: 50vw;
    bottom: -10%;
    right: 5%;
    background: radial-gradient(circle, rgba(216, 27, 96, 0.45) 0%, transparent 70%);
    animation-duration: 14s;
    animation-direction: alternate-reverse;
}

.glow-blue {
    width: 40vw;
    height: 40vw;
    top: 5%;
    left: -5%;
    background: radial-gradient(circle, rgba(26, 35, 126, 0.4) 0%, transparent 70%);
    animation-duration: 18s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, -30px) scale(1.1);
    }
}

/* Partículas / luciérnagas */
.firefly {
    position: absolute;
    border-radius: 50%;
    width: var(--sz, 4px);
    height: var(--sz, 4px);
    background: white;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.9),
        0 0 20px 4px rgba(236, 72, 153, 0.6);
    animation: rise var(--d, 20s) linear infinite;
    animation-delay: var(--del, 0s);
}

@keyframes rise {
    0% {
        transform: translateY(105vh) translateX(0) scale(0);
        opacity: 0;
    }

    8% {
        opacity: 1;
        transform: translateY(85vh) scale(1);
    }

    92% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(-5vh) translateX(var(--x, 0px)) scale(0);
        opacity: 0;
    }
}

/* =========================================
   JARDÍN SVG
   ========================================= */
.garden-svg {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
    max-width: 1400px;
    height: 100vh;
    min-height: 500px;
    z-index: 1;
    pointer-events: none;
}

/* Oscilación individual de cada tulipán */
.tulip-group {
    transform-origin: center bottom;
}

.sway-1 {
    animation: sway-a 5.5s ease-in-out infinite alternate;
}

.sway-2 {
    animation: sway-b 6.8s ease-in-out infinite alternate;
}

.sway-3 {
    animation: sway-c 7.2s ease-in-out infinite alternate;
}

.sway-4 {
    animation: sway-a 8.0s ease-in-out infinite alternate-reverse;
}

.sway-5 {
    animation: sway-b 9.0s ease-in-out infinite alternate;
}

.sway-6 {
    animation: sway-c 6.2s ease-in-out infinite alternate-reverse;
}

@keyframes sway-a {
    0% {
        transform: rotate(-2deg) translateX(-3px);
    }

    100% {
        transform: rotate(2deg) translateX(3px);
    }
}

@keyframes sway-b {
    0% {
        transform: rotate(-1.5deg) translateX(-2px);
    }

    100% {
        transform: rotate(2.5deg) translateX(4px);
    }
}

@keyframes sway-c {
    0% {
        transform: rotate(2deg) translateX(2px);
    }

    100% {
        transform: rotate(-1.5deg) translateX(-3px);
    }
}

/* =========================================
   PANTALLA INICIAL
   ========================================= */
.landing-page {
    position: relative;
    z-index: 10;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 1.4s ease, transform 1.4s ease;
}

.landing-page.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.04) translateY(-10px);
}

.glass-panel {
    max-width: 580px;
    width: 90%;
    padding: 3rem 2.8rem;
    background: rgba(10, 5, 30, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 28px;
    border: 1px solid rgba(200, 150, 255, 0.18);
    box-shadow:
        0 25px 60px rgba(0, 0, 0, 0.55),
        inset 0 0 30px rgba(147, 51, 234, 0.18),
        0 0 0 1px rgba(255, 255, 255, 0.04);
    text-align: center;
    animation: panelIn 2s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.small-tulip-icon {
    font-size: 2.4rem;
    margin-bottom: 1.2rem;
    display: block;
    animation: float-icon 4s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 12px rgba(200, 100, 255, 0.8));
}

@keyframes float-icon {
    0% {
        transform: translateY(0);
    }

    100% {
        transform: translateY(-8px);
    }
}

.message {
    font-size: 1.25rem;
    line-height: 1.75;
    margin-bottom: 2.5rem;
    font-weight: 300;
    letter-spacing: 0.3px;
    color: #f0e8ff;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
}

/* Botón */
.glow-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: rgba(147, 51, 234, 0.12);
    color: white;
    border: 1px solid rgba(200, 100, 255, 0.45);
    padding: 15px 42px;
    font-size: 1.05rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    letter-spacing: 1.5px;
    overflow: hidden;
    transition: all 0.35s ease;
    text-transform: uppercase;
}

.btn-icon {
    font-size: 1.2rem;
    position: relative;
    z-index: 2;
}

.btn-text {
    position: relative;
    z-index: 2;
}

.btn-shine {
    position: absolute;
    top: 0;
    left: -120%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(200, 130, 255, 0.35), transparent);
    transition: left 0.55s ease;
    z-index: 1;
}

.glow-btn:hover {
    border-color: rgba(200, 100, 255, 0.9);
    box-shadow: 0 0 30px rgba(180, 80, 255, 0.5), 0 0 60px rgba(180, 80, 255, 0.2);
    transform: translateY(-3px);
    background: rgba(147, 51, 234, 0.25);
}

.glow-btn:hover .btn-shine {
    left: 120%;
}

/* =========================================
   VISTA DE LA CARTA
   ========================================= */
.letter-overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(3, 1, 12, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: opacity 1s ease;
    padding: 20px;
}

.letter-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.letter-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
}

/* Sello de lacre */
.wax-seal {
    font-size: 2.2rem;
    background: radial-gradient(circle, #9c27b0, #4a0072);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(180, 60, 255, 0.7), 0 4px 12px rgba(0, 0, 0, 0.5);
    transition: transform 0.5s ease, opacity 0.5s ease;
    opacity: 0;
    transform: translateY(-20px) scale(0.6) rotate(-20deg);
    flex-shrink: 0;
}

.letter-overlay:not(.hidden) .wax-seal {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
    transition-delay: 0.2s;
}

/* Papel */
.paper-card {
    position: relative;
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #f5ead8;
    border-radius: 3px;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.7),
        inset 0 0 80px rgba(120, 70, 20, 0.08),
        0 0 0 1px rgba(180, 140, 80, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(40px) scale(0.97);
    transition: opacity 0.9s ease 0.35s, transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) 0.35s;
}

.letter-overlay:not(.hidden) .paper-card {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Líneas de cuaderno */
.paper-lines {
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(transparent, transparent 39px,
            rgba(150, 110, 70, 0.18) 39px,
            rgba(150, 110, 70, 0.18) 40px);
    background-position: 0 14px;
    pointer-events: none;
    z-index: 0;
}

/* Línea roja de margen */
.paper-lines::before {
    content: '';
    position: absolute;
    top: 0;
    left: 55px;
    width: 1px;
    height: 100%;
    background: rgba(220, 100, 100, 0.25);
}

/* Textura de papel */
.paper-lines::after {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.06' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.04'/></svg>");
    pointer-events: none;
}

.paper-inner {
    position: relative;
    z-index: 1;
    padding: 40px 50px 40px 65px;
    overflow-y: auto;
    flex: 1;
}

/* Scrollbar */
.paper-inner::-webkit-scrollbar {
    width: 6px;
}

.paper-inner::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
}

.paper-inner::-webkit-scrollbar-thumb {
    background: rgba(130, 80, 30, 0.28);
    border-radius: 3px;
}

.letter-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 22px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(150, 100, 60, 0.2);
}

.letter-date {
    font-family: 'Dancing Script', cursive;
    color: #5a3520;
    font-size: 1.5rem;
    font-weight: 600;
}

.letter-body p {
    font-family: 'Lora', serif;
    font-style: italic;
    color: #2a150a;
    font-size: 1.08rem;
    line-height: 40px;
    margin-bottom: 10px;
}

.poem-block {
    border-left: 3px solid rgba(147, 51, 234, 0.5);
    padding-left: 18px;
    margin-top: 8px;
    color: #3d1a6e !important;
    font-style: italic;
}

.letter-signature {
    font-family: 'Dancing Script', cursive;
    color: #3d1a6e;
    font-size: 1.75rem;
    text-align: right;
    margin-top: 30px;
    padding-top: 16px;
    border-top: 1px solid rgba(150, 100, 60, 0.15);
}

/* Botón cerrar */
.close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.75);
    padding: 11px 28px;
    border-radius: 30px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.5s ease 0.9s, background 0.3s ease, transform 0.3s ease;
}

.letter-overlay:not(.hidden) .close-btn {
    opacity: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    transform: translateY(-2px);
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 600px) {
    .glass-panel {
        padding: 2.2rem 1.8rem;
    }

    .message {
        font-size: 1.08rem;
    }

    .glow-btn {
        padding: 13px 30px;
        font-size: 0.95rem;
    }

    .paper-inner {
        padding: 28px 24px 28px 36px;
    }

    .paper-lines::before {
        left: 32px;
    }

    .letter-body p {
        font-size: 1.2rem;
    }

    .letter-signature {
        font-size: 1.5rem;
    }

    .small-tulip-icon {
        font-size: 2rem;
    }
}

@media (max-height: 600px) {
    .letter-scene {
        max-height: 95vh;
    }
}