:root {
    --bg-gradient: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    --envelope-color: #fcebeb;
    /* Soft pastel pink */
    --flap-color: #f5dada;
    /* Slightly darker for depth */
    --pocket-color: #f7e1e1;
    --letter-bg: rgba(255, 255, 255, 0.95);
    --text-dark: #2c3e50;
    --accent-yellow: #f1c40f;
    /* Mimosa yellow */
    --accent-gold: #9c4a5c;
    /* Deep elegant rose/berry tone */
}

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

body {
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-gradient);
    overflow-x: hidden;
    /* Allow vertical scrolling, hide horizontal */
    overflow-y: auto;
    position: relative;
    color: var(--text-dark);
}

/* Glassmorphism Background Animation */
.background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: -1;
    background: linear-gradient(-45deg, #f8f1f1, #e6ebf5, #f5e6eb, #fdfbfb);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.glass-circles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.glass-circles li {
    position: absolute;
    display: block;
    list-style: none;
    width: 20px;
    height: 20px;
    background: rgba(230, 200, 220, 0.2);
    /* Soft violet/pink tint instead of yellow */
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    animation: floatUp 25s linear infinite;
    bottom: -150px;
}

.glass-circles li:nth-child(1) {
    left: 25%;
    width: 80px;
    height: 80px;
    animation-delay: 0s;
}

.glass-circles li:nth-child(2) {
    left: 10%;
    width: 20px;
    height: 20px;
    animation-delay: 2s;
    animation-duration: 12s;
}

.glass-circles li:nth-child(3) {
    left: 70%;
    width: 20px;
    height: 20px;
    animation-delay: 4s;
}

.glass-circles li:nth-child(4) {
    left: 40%;
    width: 60px;
    height: 60px;
    animation-delay: 0s;
    animation-duration: 18s;
}

.glass-circles li:nth-child(5) {
    left: 65%;
    width: 20px;
    height: 20px;
    animation-delay: 0s;
}

.glass-circles li:nth-child(6) {
    left: 75%;
    width: 110px;
    height: 110px;
    animation-delay: 3s;
}

.glass-circles li:nth-child(7) {
    left: 35%;
    width: 150px;
    height: 150px;
    animation-delay: 7s;
}

.glass-circles li:nth-child(8) {
    left: 50%;
    width: 25px;
    height: 25px;
    animation-delay: 15s;
    animation-duration: 45s;
}

.glass-circles li:nth-child(9) {
    left: 20%;
    width: 15px;
    height: 15px;
    animation-delay: 2s;
    animation-duration: 35s;
}

.glass-circles li:nth-child(10) {
    left: 85%;
    width: 150px;
    height: 150px;
    animation-delay: 0s;
    animation-duration: 11s;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
        border-radius: 50%;
    }

    100% {
        transform: translateY(-1000px) rotate(720deg);
        opacity: 0;
        border-radius: 50%;
    }
}

/* Authentication Overlay */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.auth-overlay.hidden-overlay {
    opacity: 0;
    visibility: hidden;
}

.auth-card {
    background: rgba(255, 255, 255, 0.85);
    padding: 40px 30px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.6);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.auth-card h2 {
    font-family: 'Lora', serif;
    color: var(--accent-gold);
    margin-bottom: 10px;
    font-size: 1.6rem;
}

.auth-card p {
    margin-bottom: 20px;
    font-size: 0.95rem;
    color: #555;
    line-height: 1.5;
}

.auth-card .auth-question {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 25px;
    font-size: 1.05rem;
}

.auth-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-option {
    background: rgba(250, 240, 245, 0.8);
    border: 1px solid rgba(220, 200, 210, 0.5);
    padding: 12px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.2s ease;
}

.auth-option:hover {
    background: rgba(230, 210, 220, 0.9);
    transform: translateY(-2px);
}

.auth-error {
    color: #e74c3c !important;
    font-size: 0.85rem !important;
    margin-top: 15px !important;
    margin-bottom: 0 !important;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.auth-error.show {
    opacity: 1;
}

.hidden {
    display: none !important;
}

/* Container */
.container {
    position: relative;
    perspective: 1000px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 120px 20px 80px 20px;
    /* Increased top padding */
    margin: auto;
}

/* Envelope Structure */
.envelope-wrapper {
    position: relative;
    width: 420px;
    height: 320px;
    cursor: pointer;
    transition: transform 0.4s ease;
    filter: drop-shadow(0 20px 30px rgba(0, 0, 0, 0.15));
}

.envelope-wrapper:hover {
    transform: translateY(-5px);
}

.envelope {
    position: absolute;
    width: 100%;
    height: 100%;
}

.front {
    position: absolute;
    width: 0;
    height: 0;
    z-index: 3;
}

.flap {
    border-left: 210px solid transparent;
    border-right: 210px solid transparent;
    border-top: 170px solid var(--flap-color);
    transform-origin: top;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 5;
    /* Initially on top */
}

.pocket {
    border-left: 210px solid var(--pocket-color);
    border-right: 210px solid var(--pocket-color);
    border-bottom: 180px solid var(--envelope-color);
    border-top: 170px solid transparent;
    z-index: 4;
}

/* The Letter inside */
.letter {
    position: absolute;
    top: 5px;
    left: 10px;
    width: 400px;
    height: 310px;
    background: var(--letter-bg);
    border-radius: 8px;
    z-index: 2;
    transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1), z-index 0.4s;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.letter-content {
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease 0.5s;
    /* Fade in after letter rises */
}

.letter h1 {
    font-family: 'Lora', serif;
    font-size: 1.6rem;
    color: var(--accent-gold);
    margin-top: 10px;
    margin-bottom: 15px;
    line-height: 1.2;
}

.letter .message {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 15px;
    color: #444;
}

.letter .signature {
    margin-top: 15px;
    margin-bottom: 10px;
    font-family: 'Lora', serif;
    font-style: italic;
    font-weight: 500;
    color: var(--accent-gold);
}

/* Open Animation States */
.envelope-wrapper.open .flap {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope-wrapper.open .letter {
    transform: translateY(-220px);
    /* Move higher up to avoid clipping */
    z-index: 4;
    /* Comes above the pocket when pulled out */
}

/* Hint Text */
.tap-hint {
    position: absolute;
    bottom: -40px;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(90, 90, 90, 0.7);
    letter-spacing: 1px;
    animation: pulse 2s infinite;
    pointer-events: none;
    transition: opacity 0.3s;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
    }

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

/* Flight Status Button and Message */
.flight-status-container {
    margin-top: 60px;
    /* Pushes the button manually down to clear envelope bounds */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 15;
}

.flight-btn {
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 12px 24px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-dark);
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUpIn 0.8s ease forwards 1.2s;
    /* Delays appearance */
}

@keyframes fadeUpIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flight-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.flight-btn:active {
    transform: translateY(0);
}

.flight-message {
    margin-top: 15px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-dark);
    background: rgba(252, 235, 235, 0.85);
    /* Soft pink to match theme */
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(8px);
    max-width: 320px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.flight-message.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Mimosa Particle System */
#mimosa-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}

.mimosa-particle {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    user-select: none;
    font-size: 20px;
    /* Base for emojis */
}

@keyframes fallAndSway {
    0% {
        transform: translateY(-5vh) translateX(0) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 1;
        transform: translateY(10vh) translateX(20px) scale(1);
    }

    50% {
        transform: translateY(50vh) translateX(-20px) scale(1.1);
    }

    90% {
        opacity: 0.8;
        transform: translateY(90vh) translateX(15px) scale(1);
    }

    100% {
        transform: translateY(105vh) translateX(0) scale(0.5);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 140px 10px 120px 10px;
        /* Force it way down so the 190px pop up has room */
        justify-content: center;
    }

    .flight-status-container {
        margin-top: 50px;
    }

    .envelope-wrapper {
        width: 360px;
        height: 280px;
    }

    .flap {
        border-left-width: 180px;
        border-right-width: 180px;
        border-top-width: 140px;
    }

    .pocket {
        border-left-width: 180px;
        border-right-width: 180px;
        border-bottom-width: 160px;
        border-top-width: 140px;
    }

    .letter {
        width: 340px;
        height: 270px;
    }

    .envelope-wrapper.open .letter {
        transform: translateY(-190px);
    }

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

    .letter .message {
        font-size: 0.85rem;
    }
}