* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #050505;
    color: #eaeaea;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
}

#three-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#petal-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    pointer-events: none;
    opacity: 0;
    transition: opacity 2s ease;
}
#petal-canvas.active {
    opacity: 1;
}

/* ─── صحنه‌ها ─── */
.scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.5s ease;
}
.scene.active {
    opacity: 1;
    pointer-events: auto;
}

/* ─── Scene 1 ─── */
#scene-1 {
    background: #050505;
    z-index: 10;
    flex-direction: column;
    text-align: center;
    cursor: pointer;
}
#scene-1 .main-title {
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    font-size: clamp(2.2rem, 6vw, 4.5rem);
    letter-spacing: 0.15em;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 0 30px rgba(255, 200, 200, 0.1);
    animation: breathe 2.5s ease-in-out infinite;
}
#scene-1 .sub-title {
    margin-top: 1.5rem;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    font-weight: 300;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.1em;
    opacity: 0.8;
}
@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.03); opacity: 1; }
}

/* ─── Scene 2 ─── */
#scene-2 {
    background: transparent;
    z-index: 5;
    flex-direction: column;
    text-align: center;
    opacity: 0;
    transition: opacity 2s ease;
}
#scene-2.active {
    opacity: 1;
    pointer-events: none;
}
#scene-2 .text-container {
    max-width: 90%;
    padding: 1.5rem;
}
#scene-2 #typed-text {
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    font-size: clamp(1.8rem, 5vw, 4rem);
    color: #f0e6d6;
    text-shadow: 0 0 40px rgba(255, 200, 200, 0.15);
    line-height: 1.6;
    letter-spacing: 0.05em;
    direction: ltr;
    min-height: 2em;
}
#scene-2 #typed-text .typed-cursor {
    font-size: clamp(1.8rem, 5vw, 4rem);
    color: #ffb3b3;
    opacity: 0.7;
}

/* ─── Scene 3: Envelope & Letter ─── */
#scene-3 {
    background: transparent;
    z-index: 6;
    flex-direction: column;
    text-align: center;
    opacity: 0;
    transition: opacity 2s ease;
}
#scene-3.active {
    opacity: 1;
    pointer-events: auto;
}
.envelope-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    position: relative;
}
.envelope-wrapper {
    position: relative;
    width: clamp(200px, 30vw, 320px);
    height: clamp(140px, 20vw, 210px);
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
    perspective: 800px;
    opacity: 0;
    transform: scale(0.8) translateY(30px);
}
.envelope-wrapper.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    transition: opacity 1.2s ease, transform 1.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.envelope-wrapper:hover {
    transform: scale(1.04) translateY(-6px);
}
.envelope-wrapper:active {
    transform: scale(0.96);
}
.envelope {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(145deg, #f5e6d3, #e8d5c4);
    border-radius: 6px 6px 14px 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 80px rgba(255, 150, 150, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.envelope::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent);
    border-radius: 6px 6px 0 0;
    pointer-events: none;
}
.envelope-flap {
    position: absolute;
    top: -2px;
    left: 0;
    width: 100%;
    height: 55%;
    background: linear-gradient(160deg, #f5e6d3, #dccbbc);
    clip-path: polygon(0 0, 50% 60%, 100% 0);
    border-radius: 6px 6px 0 0;
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: top center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    border-bottom: 2px solid rgba(180, 140, 110, 0.15);
}
.envelope.open .envelope-flap {
    transform: rotateX(180deg) translateY(-4px);
}
.envelope .heart-seal {
    position: absolute;
    top: 28%;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    color: #c0392b;
    text-shadow: 0 2px 12px rgba(192, 57, 43, 0.3);
    z-index: 2;
    transition: all 0.5s ease;
}
.envelope.open .heart-seal {
    opacity: 0;
    transform: translateX(-50%) scale(0.5) translateY(-20px);
}
.envelope .envelope-text {
    font-size: clamp(0.7rem, 1.2vw, 1rem);
    color: #8a6e5a;
    letter-spacing: 0.15em;
    font-family: 'Georgia', serif;
    opacity: 0.5;
    margin-top: 12%;
    z-index: 1;
}

.letter-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 7;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 1.2s ease 0.3s;
}
.letter-container.visible {
    opacity: 1;
    pointer-events: auto;
}
.letter-paper {
    width: min(90%, 560px);
    max-height: 80vh;
    background: linear-gradient(160deg, #fcf6ef, #f5ede4);
    border-radius: 12px;
    padding: clamp(1.8rem, 4vw, 3.5rem) clamp(1.5rem, 3.5vw, 3rem);
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 0 120px rgba(255, 150, 150, 0.05);
    position: relative;
    overflow-y: auto;
    transform: scale(0.92) translateY(30px);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.8s ease;
    opacity: 0;
    color: #2c1810;
    font-family: 'Georgia', 'Times New Roman', serif;
    direction: ltr;
    text-align: left;
}
.letter-container.visible .letter-paper {
    transform: scale(1) translateY(0);
    opacity: 1;
}
.letter-paper .letter-date {
    font-size: clamp(0.7rem, 1.2vw, 0.95rem);
    color: #a08070;
    letter-spacing: 0.1em;
    text-align: left;
    margin-bottom: 1.2rem;
    font-style: italic;
}
.letter-paper .letter-greeting {
    font-size: clamp(1rem, 1.8vw, 1.4rem);
    font-weight: 600;
    color: #3d241a;
    margin-bottom: 0.8rem;
    font-family: 'Great Vibes', cursive;
}
.letter-paper .letter-body {
    font-size: clamp(0.9rem, 1.5vw, 1.15rem);
    line-height: 1.9;
    color: #3d2a1e;
    white-space: pre-wrap;
    font-family: 'Georgia', serif;
    min-height: 3em;
}
.letter-paper .letter-body .cursor-blink {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #c0392b;
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink 0.8s step-end infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.letter-paper .letter-close {
    margin-top: 1.2rem;
    font-size: clamp(0.9rem, 1.4vw, 1.1rem);
    color: #8a6e5a;
    text-align: left;
    font-style: italic;
}
.letter-close-btn {
    margin-top: 1.5rem;
    padding: 0.6rem 2rem;
    border: 1px solid rgba(60, 30, 20, 0.2);
    border-radius: 30px;
    background: transparent;
    color: #3d241a;
    font-family: 'Georgia', serif;
    font-size: clamp(0.8rem, 1.2vw, 1rem);
    cursor: pointer;
    pointer-events: auto;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
}
.letter-close-btn:hover {
    background: #3d241a;
    color: #f5ede4;
    border-color: #3d241a;
    box-shadow: 0 8px 30px rgba(60, 30, 20, 0.2);
}

/* ─── Scene 4: Rose + Meow Text ─── */
#scene-4 {
    background: transparent;
    z-index: 5;
    flex-direction: column;
    text-align: center;
    opacity: 0;
    transition: opacity 2.5s ease;
}
#scene-4.active {
    opacity: 1;
    pointer-events: none;
}
#rose-container {
    width: 100%;
    height: 70vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}
#scene-4 .meow-text {
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    color: #f0e6d6;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    text-shadow: 0 0 40px rgba(255, 200, 200, 0.15);
    opacity: 0;
    margin-top: 0.5rem;
    min-height: 4rem;
    letter-spacing: 0.05em;
    transition: opacity 0.5s ease;
}
#scene-4 .meow-text .typed-cursor {
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    color: #ffb3b3;
    opacity: 0.7;
}

/* ─── Scene 5: Finale ─── */
#scene-5 {
    background: transparent;
    z-index: 4;
    flex-direction: column;
    text-align: center;
    opacity: 0;
    transition: opacity 3s ease;
}
#scene-5.active {
    opacity: 1;
    pointer-events: none;
}
.finale-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.heart-icon {
    font-size: clamp(4rem, 10vw, 8rem);
    color: #ff4d6d;
    animation: pulseHeart 1.5s ease-in-out infinite;
    text-shadow: 0 0 80px rgba(255, 77, 109, 0.4);
    margin-bottom: 0.5rem;
}
@keyframes pulseHeart {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}
.finale-title {
    font-family: 'Great Vibes', cursive;
    font-size: clamp(3rem, 8vw, 6rem);
    color: #ffb3b3;
    text-shadow: 0 0 60px rgba(255, 150, 150, 0.3), 0 0 120px rgba(255, 100, 100, 0.1);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: scale(0.8);
    animation: fadeInScale 2s ease forwards 0.5s;
}
.finale-sub {
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    font-size: clamp(1.2rem, 2.5vw, 2rem);
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 0 30px rgba(255, 200, 200, 0.1);
    letter-spacing: 0.1em;
    opacity: 0;
    animation: fadeInUp 2s ease forwards 1.5s;
}
@keyframes fadeInScale {
    0% { opacity: 0; transform: scale(0.8); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes fadeInUp {
    0% { opacity: 0; transform: translateY(20px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ─── Music Toggle Button ─── */
.music-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.4rem;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.music-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: scale(1.08);
    border-color: rgba(255, 255, 255, 0.25);
}
.music-toggle:active {
    transform: scale(0.92);
}
.music-toggle.muted {
    opacity: 0.5;
    color: rgba(255, 200, 200, 0.3);
    border-color: rgba(255, 200, 200, 0.05);
}
.music-toggle .fa-spin {
    animation: fa-spin 1s linear infinite;
}
@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
    #scene-1 .sub-title { font-size: 0.9rem; margin-top: 1rem; }
    #scene-2 #typed-text { font-size: clamp(1.4rem, 6vw, 2.5rem); }
    .envelope-wrapper { width: 160px; height: 110px; }
    .letter-paper { padding: 1.5rem 1.2rem; max-height: 70vh; }
    .letter-paper .letter-body { font-size: 0.9rem; line-height: 1.7; }
    #scene-4 .meow-text { font-size: clamp(1.4rem, 5vw, 2.5rem); }
    .finale-title { font-size: clamp(2.5rem, 10vw, 4rem); }
    .heart-icon { font-size: clamp(3rem, 12vw, 5rem); }
    .music-toggle { width: 42px; height: 42px; font-size: 1.1rem; bottom: 16px; right: 16px; }
}
@media (max-width: 400px) {
    .envelope-wrapper { width: 130px; height: 90px; }
    .letter-paper { padding: 1rem 0.8rem; }
    .letter-paper .letter-body { font-size: 0.8rem; }
}