:root {
    --bg-deep: #0f0c29;
    --bg-mid: #302b63;
    --bg-light: #24243e;
    --envelope-color: #f75c7e;
    --envelope-flap: #ff7a9e;
    --pocket-color: #f75c7e;
    --pocket-dark: #d64566;
    --accent-gold: #ffd700;
    --text-color: #333;
    --card-bg: #fff;
}

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

body {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, var(--bg-mid), var(--bg-deep));
    font-family: 'Outfit', sans-serif;
    overflow: hidden;
    color: white;
}

#starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.container {
    perspective: 1000px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.envelope-wrapper {
    position: relative;
    width: 300px;
    height: 200px;
    transform-style: preserve-3d;
    cursor: pointer;
    animation: float 3s ease-in-out infinite;
}

.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

/* Back of envelope */
.envelope::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--pocket-dark);
    border-radius: 5px;
    transform: translateZ(-1px); /* Slight depth */
}

.pocket {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--pocket-color);
    clip-path: polygon(0 0, 50% 50%, 100% 0, 100% 100%, 0 100%);
    border-radius: 0 0 5px 5px;
    z-index: 3;
    transition: all 0.5s ease;
}

.flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--envelope-flap);
    clip-path: polygon(0 0, 50% 50%, 100% 0);
    transform-origin: top;
    z-index: 4;
    transition: transform 0.6s ease 0.2s, z-index 0.2s;
    border-radius: 5px 5px 0 0;
}

.letter {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 90%;
    height: 90%;
    background: var(--card-bg);
    transform: translateX(-50%) translateY(0);
    z-index: 2;
    transition: transform 0.6s ease 0.4s;
    border-radius: 5px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.letter-content {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease 0.8s, transform 0.4s ease 0.8s;
}

.letter h1 {
    font-family: 'Pacifico', cursive;
    font-size: 1.8rem;
    color: #ff4d6d;
    margin-bottom: 10px;
}

.letter p {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 20px;
}

.actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn {
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.yes-btn {
    background-color: #ff4d6d;
    color: white;
}

.yes-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 77, 109, 0.5);
}

.no-btn {
    background-color: #ddd;
    color: #666;
    position: relative; /* For moving it around */
}

.shadow {
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    height: 20px;
    background: rgba(0,0,0,0.3);
    border-radius: 50%;
    filter: blur(5px);
    animation: shadow-pulse 3s ease-in-out infinite;
    z-index: 0;
}

.click-instruction {
    font-size: 1rem;
    opacity: 0.7;
    animation: pulse-text 2s infinite;
    letter-spacing: 1px;
}

/* Open State */
.envelope-wrapper.open {
    cursor: default;
    animation: none;
}

.envelope-wrapper.open .flap {
    transform: rotateX(180deg);
    z-index: 1;
}

.envelope-wrapper.open .letter {
    transform: translateX(-50%) translateY(-60px);
    z-index: 5; /* Card comes on top of pocket */
    height: 250px; /* Expand card slightly */
}

.envelope-wrapper.open .letter-content {
    opacity: 1;
    transform: translateY(0);
}

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.celebration-overlay.active {
    display: flex;
    opacity: 1;
}

.celebration-content h1 {
    font-family: 'Pacifico', cursive;
    font-size: 4rem;
    color: white;
    text-shadow: 0 0 20px #ff4d6d;
    animation: heartbeat 1.5s infinite;
}

/* Animations */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes shadow-pulse {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.3; }
    50% { transform: translateX(-50%) scale(0.8); opacity: 0.1; }
}

@keyframes pulse-text {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.1); }
    30% { transform: scale(1); }
    45% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 480px) {
    .envelope-wrapper {
        transform: scale(0.8);
    }
}
