body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: linear-gradient(45deg, #0f0c29, #302b63, #24243e);
    background-attachment: fixed; /* Keep background fixed */
    font-family: 'Arial', sans-serif;
}

#container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent; /* Ensure container is transparent */
}

/* Cinematic intro overlay with film grain and effects */
#introOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 30% 20%, rgba(255, 107, 157, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(107, 157, 255, 0.1) 0%, transparent 50%),
        linear-gradient(135deg, #0a0a0a 0%, #1a0a1a 30%, #0a0a1a 70%, #0a0a0a 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
    overflow: hidden;
}

/* Film grain effect */
#introOverlay::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: 
        repeating-conic-gradient(from 0deg at 50% 50%, 
            transparent 0deg, 
            rgba(255, 255, 255, 0.03) 1deg, 
            transparent 2deg),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.1) 2px,
            rgba(0, 0, 0, 0.1) 4px
        );
    animation: filmGrain 0.2s steps(10) infinite;
    pointer-events: none;
}

/* Floating particles */
#introOverlay::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255, 107, 157, 0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(107, 157, 255, 0.3), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255, 107, 157, 0.2), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(107, 157, 255, 0.2), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: floatingParticles 20s linear infinite;
    pointer-events: none;
}

@keyframes filmGrain {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-1px, -1px) rotate(0.1deg); }
    20% { transform: translate(1px, 0px) rotate(-0.1deg); }
    30% { transform: translate(0px, 1px) rotate(0.1deg); }
    40% { transform: translate(-1px, 0px) rotate(-0.1deg); }
    50% { transform: translate(1px, 1px) rotate(0.1deg); }
    60% { transform: translate(0px, -1px) rotate(-0.1deg); }
    70% { transform: translate(-1px, 1px) rotate(0.1deg); }
    80% { transform: translate(1px, -1px) rotate(-0.1deg); }
    90% { transform: translate(0px, 0px) rotate(0.1deg); }
}

@keyframes floatingParticles {
    0% { transform: translateY(0px) translateX(0px); }
    100% { transform: translateY(-100px) translateX(50px); }
}

#introOverlay.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: scale(1.1);
}

/* Cinematic text with multiple layers */
#introText {
    font-size: 5rem;
    color: #ff6b9d;
    text-align: center;
    font-weight: 100;
    letter-spacing: 8px;
    margin-bottom: 40px;
    position: relative;
    text-transform: uppercase;
    font-family: 'Arial', sans-serif;
    
    /* Multiple text shadows for depth */
    text-shadow: 
        0 0 10px rgba(255, 107, 157, 0.8),
        0 0 20px rgba(255, 107, 157, 0.6),
        0 0 40px rgba(255, 107, 157, 0.4),
        0 0 80px rgba(255, 107, 157, 0.2),
        2px 2px 0px rgba(0, 0, 0, 0.8),
        4px 4px 0px rgba(0, 0, 0, 0.4);
    
    animation: cinematicGlow 4s ease-in-out infinite alternate;
    transform: perspective(500px) rotateX(10deg);
}

/* Cinematic text background effect */
#introText::before {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: rgba(255, 107, 157, 0.1);
    text-shadow: none;
    transform: translate(4px, 4px) scale(1.02);
    z-index: -1;
    animation: textShadowMove 6s ease-in-out infinite;
}

/* Glitch effect overlay */
#introText::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    color: #00ffff;
    text-shadow: none;
    opacity: 0;
    animation: glitchEffect 8s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
}

#introSubtext {
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.8);
    text-align: center;
    font-weight: 200;
    letter-spacing: 3px;
    text-transform: lowercase;
    position: relative;
    
    /* Subtle glow */
    text-shadow: 
        0 0 10px rgba(255, 255, 255, 0.3),
        0 0 20px rgba(255, 255, 255, 0.1);
    
    animation: subtextPulse 3s ease-in-out infinite;
}

/* Animated underline for subtitle */
#introSubtext::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    width: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, #ff6b9d, transparent);
    transform: translateX(-50%);
    animation: underlineGrow 4s ease-in-out infinite;
}

/* Enhanced animations */
@keyframes cinematicGlow {
    0% {
        text-shadow: 
            0 0 10px rgba(255, 107, 157, 0.8),
            0 0 20px rgba(255, 107, 157, 0.6),
            0 0 40px rgba(255, 107, 157, 0.4),
            2px 2px 0px rgba(0, 0, 0, 0.8);
        transform: perspective(500px) rotateX(10deg) translateY(0px);
    }
    100% {
        text-shadow: 
            0 0 20px rgba(255, 107, 157, 1),
            0 0 30px rgba(255, 107, 157, 0.8),
            0 0 60px rgba(255, 107, 157, 0.6),
            0 0 100px rgba(255, 107, 157, 0.3),
            2px 2px 0px rgba(0, 0, 0, 0.8);
        transform: perspective(500px) rotateX(10deg) translateY(-5px);
    }
}

@keyframes textShadowMove {
    0%, 100% { transform: translate(4px, 4px) scale(1.02); }
    50% { transform: translate(8px, 2px) scale(1.03); }
}

@keyframes glitchEffect {
    0%, 90%, 100% { opacity: 0; }
    91% { 
        opacity: 0.8; 
        transform: translate(2px, 0);
        clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    }
    92% { 
        opacity: 0.6; 
        transform: translate(-2px, 0);
        clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    }
    93% { 
        opacity: 0.9; 
        transform: translate(1px, 0);
        clip-path: polygon(0 20%, 100% 20%, 100% 80%, 0 80%);
    }
}

@keyframes subtextPulse {
    0%, 100% {
        opacity: 0.8;
        transform: translateY(0px);
    }
    50% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

@keyframes underlineGrow {
    0%, 100% { width: 0; }
    50% { width: 200px; }
}

/* Cinematic vignette effect */
#introOverlay .vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 30%, rgba(0, 0, 0, 0.8) 100%);
    pointer-events: none;
}

#info {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    color: white;
    font-size: 16px;
    opacity: 0.7;
    pointer-events: none;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

#controls {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 101;
    max-width: 90vw;
    padding: 0 10px;
}

#controls .control-group {
    display: flex;
    flex-direction: row;
    gap: 12px;
}

#controls.show {
    opacity: 1;
    transform: translateX(-50%);
}

/* Lyrics Container */
#lyrics-container {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 102;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    pointer-events: none;
    width: 90%;
    max-width: 800px;
    font-family: 'Inter', sans-serif;
    min-height: 80px;
    height: auto;
    overflow: visible;
}

#lyrics-container.show {
    opacity: 1;
}

#lyrics {
    position: relative;
    text-align: center;
    width: 100%;
    height: auto;
    min-height: 80px;
    overflow: visible;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px);
    border-radius: 20px;
    padding: 20px 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box; /* Add this to ensure proper sizing */
}

.lyric-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin: 0;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
    line-height: 1.4;
    gap: 12px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 40px); /* Account for padding */
}

.word {
    opacity: 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: #fff;
    display: inline-block;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Button styles */
button {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(10px);
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 11px;
    white-space: nowrap;
    min-width: fit-content;
}

/* Letter Modal Styles */
.letter-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 20px;
    box-sizing: border-box;
}

.letter-modal.show {
    opacity: 1;
    visibility: visible;
}

.letter-content {
    position: relative;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.7) translateY(50px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.letter-modal.show .letter-content {
    transform: scale(1) translateY(0);
}

.letter-paper {
    background: linear-gradient(145deg, #fefefe, #f8f8f8);
    border-radius: 15px;
    padding: 40px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.3),
        0 10px 30px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    font-family: 'Dancing Script', cursive;
    color: #2c3e50;
    border: 2px solid rgba(255, 182, 193, 0.3);
}

.letter-paper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            transparent,
            transparent 24px,
            rgba(255, 182, 193, 0.1) 25px
        );
    border-radius: 15px;
    pointer-events: none;
}

.close-letter {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 107, 157, 0.1);
    border: 2px solid rgba(255, 107, 157, 0.3);
    color: #ff6b9d;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.close-letter:hover {
    background: rgba(255, 107, 157, 0.2);
    transform: scale(1.1);
    border-color: rgba(255, 107, 157, 0.5);
}

.letter-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid rgba(255, 182, 193, 0.3);
    padding-bottom: 20px;
}

.letter-header h2 {
    font-size: 2.2rem;
    color: #ff6b9d;
    margin: 0 0 10px 0;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(255, 107, 157, 0.2);
}

.letter-date {
    font-size: 1.1rem;
    color: #8e44ad;
    font-style: italic;
    font-weight: 400;
}

.letter-body {
    line-height: 1.8;
    font-size: 1.2rem;
    position: relative;
    z-index: 2;
}

.greeting {
    font-size: 1.4rem;
    color: #e74c3c;
    font-weight: 600;
    margin-bottom: 20px;
}

.letter-body p {
    margin-bottom: 20px;
    text-align: justify;
    font-weight: 500;
}

.closing {
    text-align: right;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 182, 193, 0.3);
    font-size: 1.3rem;
    font-weight: 600;
}

.signature {
    color: #ff6b9d;
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(255, 107, 157, 0.3);
}

.letter-decorations {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.heart-decoration {
    position: absolute;
    font-size: 2rem;
    opacity: 0.1;
    animation: floatHeart 6s ease-in-out infinite;
}

.heart-decoration:nth-child(1) {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
}

.heart-decoration:nth-child(2) {
    top: 60%;
    right: 15%;
    animation-delay: 2s;
}

.heart-decoration:nth-child(3) {
    bottom: 30%;
    left: 20%;
    animation-delay: 4s;
}

@keyframes floatHeart {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.1;
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
        opacity: 0.2;
    }
}

.letter-btn {
    background: linear-gradient(145deg, rgba(255, 107, 157, 0.2), rgba(255, 107, 157, 0.1)) !important;
    border-color: rgba(255, 107, 157, 0.4) !important;
    color: #ff6b9d !important;
}

.letter-btn:hover {
    background: linear-gradient(145deg, rgba(255, 107, 157, 0.3), rgba(255, 107, 157, 0.2)) !important;
    border-color: rgba(255, 107, 157, 0.6) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.3);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    #controls {
        top: 15px;
        gap: 8px;
        max-width: 95vw;
    }
    
    #controls .control-group {
        gap: 8px;
    }
    
    button {
        padding: 10px 16px;
        font-size: 10px;
        letter-spacing: 0.5px;
    }
    
    #lyrics-container {
        bottom: 15% !important; /* Better positioning */
        left: 50%;
        transform: translateX(-50%);
        width: 92%;
        max-width: 92%;
        margin: 0;
        padding: 0;
    }
    
    #lyrics {
        padding: 12px 16px; /* Smaller padding */
        border-radius: 12px;
        margin: 0 auto;
        width: 100%;
        box-sizing: border-box;
        background: rgba(0, 0, 0, 0.4) !important; /* More transparent */
        backdrop-filter: blur(3px);
        min-height: 60px; /* Smaller minimum height */
    }
    
    .word {
        font-size: 1.2rem !important; /* Smaller text */
        gap: 6px;
    }
    
    .lyric-line {
        gap: 6px;
        width: calc(100% - 25px);
        font-size: 1.2rem !important; /* Consistent smaller size */
        padding: 6px !important;
        line-height: 1.3;
    }
    
    /* Better letter modal for mobile */
    .letter-modal {
        padding: 8px;
    }
    
    .letter-paper {
        padding: 30px 25px; /* Better mobile padding */
        margin: 0;
        max-height: 85vh; /* More space for content */
    }
    
    .letter-header h2 {
        font-size: 2.0rem; /* Bigger header */
    }
    
    .letter-body {
        font-size: 1.3rem; /* Bigger body text */
        line-height: 1.7; /* Better line spacing */
    }
    
    .greeting {
        font-size: 1.4rem; /* Bigger greeting */
    }
    
    .closing {
        font-size: 1.2rem; /* Bigger closing */
    }
    
    .signature {
        font-size: 1.4rem; /* Bigger signature */
    }
}

@media (max-width: 480px) {
    #lyrics-container {
        bottom: 12% !important;
        width: 95%;
        max-width: 95%;
    }
    
    #lyrics {
        padding: 10px 12px;
        border-radius: 10px;
        min-height: 50px;
    }
    
    .word {
        font-size: 1.0rem !important; /* Even smaller for very small screens */
    }
    
    .lyric-line {
        gap: 4px;
        width: calc(100% - 20px);
        font-size: 1.0rem !important;
        padding: 4px !important;
    }
    
    /* Enhanced letter for small mobile */
    .letter-paper {
        padding: 25px 20px;
        max-height: 80vh;
    }
    
    .letter-header h2 {
        font-size: 1.8rem;
    }
    
    .letter-body {
        font-size: 1.2rem;
        line-height: 1.6;
    }
    
    .greeting {
        font-size: 1.3rem;
    }
    
    .close-letter {
        width: 38px;
        height: 38px;
        font-size: 22px;
    }
}

/* Extra small screens optimization */
@media (max-width: 360px) {
    #lyrics-container {
        bottom: 10% !important;
        width: 98%;
        max-width: 98%;
    }
    
    #lyrics {
        padding: 8px 10px;
        border-radius: 8px;
        min-height: 45px;
    }
    
    .word {
        font-size: 0.9rem !important;
    }
    
    .lyric-line {
        gap: 3px;
        width: calc(100% - 16px);
        font-size: 0.9rem !important;
        padding: 3px !important;
    }
    
    /* Letter optimization for very small screens */
    .letter-paper {
        padding: 20px 15px;
        max-height: 75vh;
    }
    
    .letter-header h2 {
        font-size: 1.6rem;
    }
    
    .letter-body {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    
    .letter-body p {
        margin-bottom: 15px; /* Tighter spacing */
    }
    
    .greeting {
        font-size: 1.2rem;
    }
    
    .closing {
        font-size: 1.0rem;
    }
    
    .signature {
        font-size: 1.2rem;
    }
}
