body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #fce4ec;
    font-family: 'Times New Roman', serif;
}

.container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center; /* Add this to center children */
    width: 100%;         /* Add this to ensure full width */
    max-width: 1200px;   /* Add this to control maximum width */
    margin: 0 auto;      /* Add this to center the container */
    padding: 2rem;       /* Add this for some breathing room */
}

/* Remove letter-container and letter-wrapper styles as they're no longer needed */

.letter {
    max-width: 90%; /* Added to constrain width */
    margin: 0 auto; /* Center the letter */
    border: 1px solid #dec3c3;
    padding: 2rem;
    background: #fff9f9;
    font-size: 1.1rem; /* Slightly reduced for better fit */
}

.letter h1 {
    color: #8b4513;
    text-align: center;
    font-style: italic;
    font-size: 2.2rem;  /* Slightly reduced */
    margin-bottom: 1.5rem; /* Reduced margin */
}

.letter-content {
    line-height: 1.5;
    color: #5d4037;
    margin-bottom: 1.5rem;
}

.signature {
    text-align: right;
    font-style: italic;
    margin-top: 2rem;
}

.music-player {
    background: white;
    padding: 1rem;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    width: 300px;
    margin: 0 auto;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin: 1rem 0;
}

.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    padding: 0.8rem;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: 0.3s;
}

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

.progress-bar {
    background: rgba(255, 255, 255, 0.2);
    height: 4px;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.progress {
    background: white;
    height: 100%;
    width: 0%;
    transition: width 0.1s linear;
}

.click-heart {
    margin-top: -3.125rem;
    text-align: center;
    margin-bottom: 1rem;
}

.click-heart h2 {
    font-family: 'Dancing Script', cursive;
    color: #ff4081;
    font-size: 3.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.envelope {
    position: relative;
    width: 600px;  /* increased from 500px */
    height: 450px; /* increased from 350px */
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    cursor: pointer;
    overflow: hidden;
    margin-bottom: 30px;
    /* Remove any margin-left/right if present */
    margin-left: auto;
    margin-right: auto;
    border-radius: 30px;
    transition: transform 0.3s ease;
}

.envelope:hover {
    transform: scale(1.02);
}

.front {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #fff;
    border: 2px solid #ffcdd2;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.5s;
    transform-origin: top;
}

.flap {
    position: absolute;
    background: #fff;
    border: 2px solid #ffcdd2;
    transition: transform 0.5s ease-in-out;
}

.top-flap {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    transform-origin: top;
    z-index: 3;
    transition: transform 0.4s ease-in-out;
}

.right-flap {
    width: 100%;
    height: 100%;
    top: 0;
    right: 0;
    transform-origin: right;
    z-index: 2;
    transition: transform 0.4s ease-in-out;
}

.heart-seal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;  /* increased from 3rem */
    color: #ff4081;
    z-index: 4;
    transition: opacity 0.3s;
}

.envelope.open .front {
    transform: rotateX(180deg);
}

.envelope.open .top-flap {
    transform: rotateX(180deg);
}

.envelope.open .right-flap {
    transform: rotateY(-180deg);
    transition-delay: 0.25s;
}

.envelope.open .heart-seal {
    opacity: 0;
}

.envelope:not(.open) .top-flap {
    transform: rotateX(0);
}

.envelope:not(.open) .right-flap {
    transform: rotateY(0);
}

.music-card {
    background: linear-gradient(45deg, #ff4081, #f50057);
    padding: 1.5rem;
    border-radius: 15px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
    color: white;
    width: 300px;
    margin: 0.5rem auto;
}

.song-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.album-cover {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    object-fit: cover;
}

.song-details h3 {
    margin: 0;
    font-size: 1.2rem;
}

.song-details p {
    margin: 5px 0 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.memories-section {
    width: 100%;
    max-width: 900px;
    margin: 3rem auto;
    padding: 0 1rem;
}

.memories-section h2 {
    font-family: 'Dancing Script', cursive;
    color: #ff4081;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin-bottom: 2rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Changed to exactly 4 columns */
    gap: 1.5rem;
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.gallery-item {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    width: 100%;
}

/* Add media query for responsive design */
@media (max-width: 1024px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.1);
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .envelope {
        width: 90vw;
        height: calc(90vw * 0.75); /* Maintain aspect ratio */
        margin-bottom: 20px;
    }

    .letter {
        padding: 1rem;
        font-size: 1rem;
    }

    .letter h1 {
        font-size: 1.8rem;
    }

    .heart-seal {
        font-size: 3rem;
    }

    .music-card {
        width: 90%;
        padding: 1rem;
    }

    .click-heart h2 {
        font-size: 2rem;
    }

    .memories-section {
        padding: 0 0.5rem;
    }

    .memories-section h2 {
        font-size: 2rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.5rem;
    }

    .modal-letter {
        padding: 2rem;
        width: 90%;
    }
}

@media screen and (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(1, 1fr);
    }

    .song-info {
        flex-direction: column;
        text-align: center;
    }

    .album-cover {
        margin-bottom: 0.5rem;
    }

    .controls {
        gap: 1rem;
    }

    .control-btn {
        padding: 0.6rem;
    }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
    .envelope {
        width: 500px;
        height: 375px;
    }

    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Add smooth scrolling for mobile */
@media (hover: none) {
    html {
        scroll-behavior: smooth;
    }
}

.timer {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-letter {
    background: #fff9f9;
    padding: 3rem;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-width: 80%;
    width: 600px;
    position: relative;
    border: 2px solid #ffcdd2;
    animation: modalAppear 0.5s ease;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-letter .letter {
    border: 1px solid #dec3c3;
    padding: 2rem;
    margin: 0;
    max-width: 100%;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #ff4081;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.3s ease;
}

.close-modal:hover {
    transform: scale(1.1);
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-overlay.active {
    display: flex;
}

/* Update mobile responsiveness */
@media screen and (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    .click-heart {
        margin-top: -2rem; /* Reduced negative margin for mobile */
    }
    .click-heart h2 {
        font-size: 2.5rem;
    }

    .envelope {
        width: 85vw;
        height: calc(85vw * 0.75);
        margin-bottom: 1.5rem;
    }

    .heart-seal {
        font-size: 3.5rem;
    }

    .modal-letter {
        width: 90%;
        padding: 1.5rem;
        max-height: 85vh;
    }

    .modal-letter .letter {
        padding: 1rem;
    }

    .modal-letter .letter h1 {
        font-size: 1.8rem;
        margin-bottom: 1rem;
    }

    .modal-letter .letter-content {
        font-size: 1rem;
    }

    .music-card {
        width: 85vw;
        max-width: 350px;
        padding: 1rem;
    }

    .control-btn {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    .memories-section {
        padding: 0;
        margin-top: 2rem;
    }

    .memories-section h2 {
        font-size: 2rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        padding: 0.5rem;
    }
}

@media screen and (max-width: 480px) {
    .click-heart h2 {
        font-size: 2rem;
    }

    .envelope {
        width: 90vw;
        height: calc(90vw * 0.8);
    }

    .heart-seal {
        font-size: 3rem;
    }

    .modal-letter {
        padding: 1rem;
    }

    .modal-letter .letter h1 {
        font-size: 1.5rem;
    }

    .music-card {
        padding: 1rem;
    }

    .song-info {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .album-cover {
        width: 50px;
        height: 50px;
    }

    .controls {
        gap: 0.75rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(1, 1fr);
    }

    .close-modal {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 1.2rem;
    }
}

/* Add orientation-specific styles */
@media screen and (max-height: 600px) and (orientation: landscape) {
    .modal-letter {
        max-height: 90vh;
        width: 85%;
        padding: 1rem;
    }

    .envelope {
        height: 40vh;
        width: calc(40vh * 1.33);
    }
}
