@import url('https://fonts.googleapis.com/css2?family=Kalam:wght@300;400;700&display=swap');

:root {
    --paper-color: #fffef9;
    --vintage-gold: #b8a589;
    --ink-color: #3d3d3d;
    --accent-red: #7f1d1d;
}

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

body {
    font-family: 'Kalam', cursive;
    background: radial-gradient(circle, #d4c4a8 0%, #b8a589 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.viewport-wrapper {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.envelope-wrapper {
    width: 100%;
    cursor: pointer;
    transition: all 0.6s ease;
}

.envelope {
    position: relative;
    width: 100%;
    aspect-ratio: 3/2;
    background: linear-gradient(135deg, #c9a97a 0%, #a88d5f 100%);
    border-radius: 4px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.envelope-flap {
    position: absolute;
    top: 0;
    width: 100%;
    height: 100%;
    clip-path: polygon(0 0, 50% 50%, 100% 0);
    background: #d4b68a;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.envelope-seal {
    width: 50px;
    height: 50px;
    background: var(--accent-red);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    z-index: 11;
}

.letter-section {
    display: none;
    opacity: 0;
    width: 100%;
    transform: scale(0.9);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.letter-paper {
    background: var(--paper-color);
    padding: 60px 30px 40px 30px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2),
        inset 0 0 100px rgba(0, 0, 0, 0.05);
    border-radius: 2px;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(150, 150, 150, 0.15) 31px, rgba(150, 150, 150, 0.15) 32px),
        radial-gradient(ellipse at 10% 20%, rgba(139, 115, 85, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 80%, rgba(139, 115, 85, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 30% 60%, rgba(160, 130, 90, 0.03) 0%, transparent 30%),
        radial-gradient(circle at 70% 30%, rgba(160, 130, 90, 0.03) 0%, transparent 30%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='3.5' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.08'/%3E%3C/svg%3E");
    background-blend-mode: normal, multiply, multiply, overlay, overlay, overlay;
}

.polaroid {
    position: absolute;
    top: 0;
    right: 0;
    width: 120px;
    background: white;
    padding: 8px 8px 10px 8px;
    box-shadow: -5px 5px 15px rgba(0, 0, 0, 0.1);
    transform: translate(15%, -15%) rotate(10deg);
    z-index: 20;
}

.polaroid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.polaroid-frame {
    width: 100%;
    aspect-ratio: 1/1;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 35px;
}

.polaroid-caption {
    text-align: center;
    font-family: 'Brush Script MT', cursive;
    font-size: 8px;
    margin-top: 5px;
    color: #777;
}

.letter-header {
    margin-bottom: 25px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.letter-title {
    font-size: 24px;
    font-style: italic;
}

.letter-content {
    font-size: 16px;
    line-height: 1.7;
    color: var(--ink-color);
}

.message {
    text-align: justify;
}

.footer-flex {
    margin-top: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mini-player {
    display: flex;
    align-items: center;
    gap: 12px;
}

.vinyl-record {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle, #333 30%, #000 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.vinyl-label {
    width: 20px;
    height: 20px;
    background: var(--accent-red);
    border-radius: 50%;
    color: white;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinning {
    animation: rotate 3s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.song-info {
    font-size: 11px;
    color: #8b7355;
    line-height: 1.2;
}

.song-title {
    font-weight: bold;
    display: block;
    color: #4a3f35;
}

.letter-signature {
    text-align: right;
    font-style: italic;
    font-size: 18px;
    color: #444;
}

.close-btn {
    margin-top: 25px;
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--vintage-gold);
    padding: 6px 15px;
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: 0.3s;
}

.close-btn:hover {
    background: var(--vintage-gold);
    color: white;
}

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

.fade-in {
    display: block !important;
    animation: letterIn 0.8s forwards;
}

@keyframes letterIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

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

@media (max-width: 480px) {
    .polaroid {
        width: 90px;
    }

    .letter-paper {
        padding: 50px 20px 30px 20px;
    }
}