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

body {
    font-family: 'Dancing Script', cursive;
    color: #fff;
    overflow-x: hidden;
    position: relative;
    min-height: 100vh;
    background-color: #000;
}

/* Background stars and twinkling effect */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
}

.stars {
    background: #000 url('https://i.imgur.com/YKY28eT.png') repeat;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
}

.twinkling {
    background: transparent url('https://i.imgur.com/XYMF4ca.png') repeat;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    animation: move-twink-back 200s linear infinite;
}

@keyframes move-twink-back {
    from {background-position: 0 0;}
    to {background-position: -10000px 5000px;}
}

/* Container and layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 2;
}

.birthday-heading {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeIn 2s ease-in-out;
}

.birthday-title {
    font-family: 'Pacifico', cursive;
    font-size: 3.5rem;
    margin-bottom: 15px;
    background: linear-gradient(45deg, #ff69b4, #ff8c00, #ffd700, #ff1493);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 0 10px rgba(255, 105, 180, 0.5);
}

.birthday-subtitle {
    font-size: 1.5rem;
    color: #f8f8f8;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

@media (min-width: 1024px) {
    .content {
        flex-direction: row;
    }
    
    .letter-section {
        flex: 1;
    }
    
    .photo-gallery {
        flex: 1;
    }
}

/* Handwritten letter */
.letter-section {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 30px;
    backdrop-filter: blur(5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-height: 70vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
    position: relative;
}

.letter-section::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('BemPhoto/photo-output.jpeg') no-repeat center center;
    background-size: contain;
    opacity: 0.12; /* Slightly more visible but still subtle */
    pointer-events: none;
    z-index: 0;
    border-radius: 15px;
}

.letter-section::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.05), rgba(0,0,0,0.1));
    pointer-events: none;
    z-index: 0;
    border-radius: 15px;
}

.letter-section::-webkit-scrollbar {
    width: 8px;
}

.letter-section::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.handwritten-letter {
    font-size: 1.5rem;
    line-height: 1.8;
    opacity: 0;
    position: relative;
    z-index: 1; /* Ensure text is above the background image */
}

.letter-paragraph {
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.15);
    padding: 5px 8px;
    border-radius: 5px;
}

.highlight {
    color: #ff69b4;
    font-weight: bold;
}

.extra-highlight {
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
}

/* Photo gallery */
.photo-gallery {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.featured-photo {
    position: relative;
    height: 400px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.special-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 15px;
    animation: glow 3s infinite alternate;
    transform: scale(1);
    transition: transform 0.3s ease;
    background-color: rgba(0, 0, 0, 0.2);
}

@keyframes glow {
    0% { box-shadow: 0 0 10px rgba(255, 105, 180, 0.5); }
    100% { box-shadow: 0 0 25px rgba(255, 105, 180, 0.8); }
}

.special-photo:hover {
    transform: scale(1.02);
}

.slideshow-container {
    width: 100%;
    height: 300px;
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

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

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide.active {
    opacity: 1;
}

.slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    background-color: rgba(0, 0, 0, 0.2);
}

.prev-btn, .next-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.3s ease;
}

.prev-btn:hover, .next-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

.prev-btn {
    left: 10px;
}

.next-btn {
    right: 10px;
}

/* Audio control */
.sound-control {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 100;
}

.sound-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 20px;
    box-shadow: 0 0 15px rgba(255, 105, 180, 0.5);
    transition: all 0.3s ease;
}

.sound-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Floating hearts */
.heart {
    position: absolute;
    width: 20px;
    height: 20px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23ff69b4"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>') no-repeat;
    opacity: 0;
    z-index: -1;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

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

@keyframes heartbeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(1); }
    75% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Special message outside the letter */
.special-message-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 40px 0;
    perspective: 1000px;
}

.special-message {
    font-family: 'Pacifico', cursive;
    font-size: 2rem;
    color: transparent;
    background: linear-gradient(45deg, #ff69b4, #ffd700, #ff1493, #ff8c00);
    background-size: 300% 300%;
    background-clip: text;
    -webkit-background-clip: text;
    text-align: center;
    padding: 20px;
    max-width: 80%;
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(255, 105, 180, 0.3);
    position: relative;
    animation: rainbow-text 8s ease-in-out infinite, float-message 6s ease-in-out infinite, glow-pulse 3s infinite;
    transform-style: preserve-3d;
}

.special-message::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: linear-gradient(45deg, rgba(255, 105, 180, 0.3), rgba(255, 215, 0, 0.3));
    border-radius: 20px;
    z-index: -1;
    filter: blur(15px);
    opacity: 0.7;
    animation: glow-message 3s infinite alternate;
}

@keyframes rainbow-text {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes float-message {
    0% { transform: translateY(0) rotateX(0deg); }
    50% { transform: translateY(-15px) rotateX(5deg); }
    100% { transform: translateY(0) rotateX(0deg); }
}

@keyframes glow-message {
    0% { opacity: 0.5; filter: blur(15px); }
    100% { opacity: 0.9; filter: blur(20px); }
}

@keyframes glow-pulse {
    0% { box-shadow: 0 0 20px rgba(255, 105, 180, 0.5); }
    50% { box-shadow: 0 0 40px rgba(255, 105, 180, 0.7), 0 0 80px rgba(255, 215, 0, 0.4); }
    100% { box-shadow: 0 0 20px rgba(255, 105, 180, 0.5); }
}

/* Sparkle effect for special message */
.sparkle {
    position: fixed;
    background: radial-gradient(ellipse at center, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 0 20px rgba(255, 105, 180, 0.6);
}

/* Responsive adjustments for special message */
@media (max-width: 768px) {
    .special-message {
        font-size: 1.6rem;
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .special-message {
        font-size: 1.3rem;
        padding: 15px;
    }
    
    .special-message-container {
        margin: 30px 0;
    }
}

/* Save options */
.save-options {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.save-btn {
    padding: 12px 25px;
    font-size: 1rem;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.save-btn i {
    font-size: 1.2rem;
}

.pdf-btn {
    background: linear-gradient(45deg, #ff5e62, #ff9966);
    box-shadow: 0 4px 15px rgba(255, 94, 98, 0.4);
}

.letter-btn {
    background: linear-gradient(45deg, #654ea3, #ea68a2);
    box-shadow: 0 4px 15px rgba(101, 78, 163, 0.4);
}

.record-btn {
    background: linear-gradient(45deg, #614385, #516395);
    box-shadow: 0 4px 15px rgba(97, 67, 133, 0.4);
}

.download-btn {
    background: linear-gradient(45deg, #11998e, #38ef7d);
    box-shadow: 0 4px 15px rgba(17, 153, 142, 0.4);
}

.save-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.3);
}

.save-btn:active {
    transform: translateY(1px);
}

.recording-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background-color: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 50px;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    animation: pulse 1.5s infinite;
}

.recording-indicator i {
    color: red;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Music prompt */
.music-prompt {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 105, 180, 0.7);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.2rem;
    z-index: 1000;
    animation: pulse 1.5s infinite;
    box-shadow: 0 0 20px rgba(255, 105, 180, 0.5);
    text-align: center;
}

/* Special ending signature styling */
.letter-paragraph:nth-last-child(1),
.letter-paragraph:nth-last-child(2),
.letter-paragraph:nth-last-child(3) {
    font-family: 'Pacifico', cursive;
    text-align: right;
    padding-right: 10%;
    margin-top: 20px;
}

.letter-paragraph:nth-last-child(1) {
    font-size: 1.2em;
    margin-top: 5px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }
    
    .birthday-title {
        font-size: 2.2rem;
    }

    .birthday-subtitle {
        font-size: 1.1rem;
    }

    .handwritten-letter {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    
    .letter-section {
        padding: 20px;
        max-height: 50vh;
    }
    
    .featured-photo {
        height: 350px;
    }
    
    .slideshow-container {
        height: 250px;
    }
    
    .prev-btn, .next-btn {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    
    /* Better spacing on mobile */
    .content {
        gap: 15px;
    }
}

/* Even smaller screens */
@media (max-width: 480px) {
    .birthday-title {
        font-size: 1.8rem;
    }

    .birthday-subtitle {
        font-size: 1rem;
    }
    
    .handwritten-letter {
        font-size: 1rem;
    }
    
    .featured-photo {
        height: 300px;
    }
    
    .slideshow-container {
        height: 200px;
    }
    
    .letter-section {
        padding: 15px;
    }
    
    .sound-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}
