/* ==========================================================================
   FOR YOU — DESIGN SYSTEM (PINK & SLATE PRESENTATION WITH ADVANCED INTERACTION)
   ========================================================================== */

:root {
    /* Muted Pink & Slate Palette */
    --color-rose: #db7b8e;          /* Muted Dusty Rose */
    --color-rose-hover: #cb687b;
    --color-rose-light: #fdf6f7;
    --color-rose-subtle: #f9e2e5;

    --color-slate-dark: #334155;    /* Deep Charcoal Slate */
    --color-slate-medium: #475569;  /* Cool Steel Slate */
    --color-slate-light: #64748b;   /* Muted Slate */
    --color-slate-bg: #f8fafc;      /* Ice Slate */
    
    --color-bg-base: #fbf8f8;
    --color-card-bg: rgba(255, 255, 255, 0.85);
    --color-card-border: rgba(219, 123, 142, 0.2);

    /* Fonts */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    /* Layout Tokens */
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 8px;
    --transition-smooth: all 0.65s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-medium: all 0.45s cubic-bezier(0.25, 0.8, 0.25, 1);
    --transition-fast: all 0.2s ease;
}

/* ==========================================================================
   1. CORE RESETS & GLOBAL STYLES
   ========================================================================== */

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg-base);
    color: var(--color-slate-dark);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* Floating background glow spheres */
.bg-gradient-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -10;
    overflow: hidden;
    pointer-events: none;
}

.glow-sphere {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.55;
    mix-blend-mode: multiply;
    animation: floatAnimation 20s infinite alternate ease-in-out;
}

.glow-1 {
    width: 500px;
    height: 500px;
    background-color: #fcebeb;
    top: -100px;
    left: -150px;
}

.glow-2 {
    width: 600px;
    height: 600px;
    background-color: #eef2f7;
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
    animation-duration: 25s;
}

.glow-3 {
    width: 400px;
    height: 400px;
    background-color: #f7e9ec;
    top: 35%;
    left: 55%;
    animation-delay: -10s;
}

@keyframes floatAnimation {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 80px) scale(1.15); }
}

/* ==========================================================================
   2. PORTAL / INTRO SCREEN
   ========================================================================== */

.portal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-bg-base);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.8s;
}

.portal-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
}

.portal-card {
    background: white;
    border: 1px solid var(--color-card-border);
    border-radius: var(--border-radius-lg);
    padding: 3rem;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(71, 85, 105, 0.05);
    animation: portalScaleIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes portalScaleIn {
    from { opacity: 0; transform: scale(0.95) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.portal-logo {
    width: 64px;
    height: 64px;
    background: var(--color-rose-light);
    color: var(--color-rose);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.portal-card h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.portal-card p {
    font-size: 0.95rem;
    color: var(--color-slate-light);
    margin-bottom: 2rem;
    line-height: 1.6;
}

/* ==========================================================================
   3. APP WRAPPER & NAVIGATION
   ========================================================================== */

.main-wrapper {
    opacity: 1;
    transition: opacity 0.8s ease;
}

.main-wrapper.hide {
    opacity: 0;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.container-narrow {
    max-width: 750px;
}

/* Ambient Player Switcher */
.ambient-player {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 100;
}

.audio-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--color-rose-subtle);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-slate-medium);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    transition: var(--transition-fast);
}

.audio-btn:hover {
    color: var(--color-rose);
    border-color: var(--color-rose);
    transform: translateY(-1px);
}

/* ==========================================================================
   4. HERO SECTION
   ========================================================================== */

.hero-section {
    min-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
    padding: 2rem 1.5rem;
}

.hero-container {
    max-width: 800px;
}

.hero-subtitle {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--color-rose);
    margin-bottom: 1.25rem;
    display: inline-block;
}

.hero-title {
    font-family: var(--font-heading);
    font-size: 4rem;
    line-height: 1.15;
    font-weight: 400;
    color: var(--color-slate-dark);
    margin-bottom: 1.5rem;
}

.hero-lead {
    font-size: 1.25rem;
    color: var(--color-slate-light);
    max-width: 600px;
    margin: 0 auto 2.5rem auto;
    font-weight: 300;
}

/* Scroll prompt */
.scroll-indicator {
    position: absolute;
    bottom: 3rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.scroll-text {
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-slate-light);
}

.mouse-icon {
    width: 20px;
    height: 32px;
    border: 2px solid var(--color-slate-light);
    border-radius: 12px;
    position: relative;
}

.wheel {
    width: 3px;
    height: 6px;
    background-color: var(--color-slate-light);
    border-radius: 2px;
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    animation: scrollMouse 1.8s infinite ease-in-out;
}

@keyframes scrollMouse {
    0% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, 8px); }
}

/* ==========================================================================
   5. SECTIONS GENERAL & SCROLL REVEAL
   ========================================================================== */

.section {
    padding: 8rem 0;
    position: relative;
}

.section-header {
    margin-bottom: 4.5rem;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 400;
    margin-top: 0.5rem;
    color: var(--color-slate-dark);
}

.section-header p {
    color: var(--color-slate-light);
    font-size: 1rem;
    margin-top: 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    background: var(--color-rose-light);
    border: 1px solid var(--color-rose-subtle);
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-rose);
}

.text-center { text-align: center; }

/* Scroll reveal system */
.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: opacity 1s cubic-bezier(0.16, 1, 0.3, 1), transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Button Classes */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1.6rem;
    border-radius: 30px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid transparent;
    text-decoration: none;
    outline: none;
    user-select: none;
}

.btn-primary {
    background: var(--color-rose);
    color: white;
}

.btn-primary:hover {
    background: var(--color-rose-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(219, 123, 142, 0.2);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-slate-light);
    color: var(--color-slate-dark);
}

.btn-outline:hover {
    background: var(--color-rose-light);
    border-color: var(--color-rose);
    color: var(--color-rose);
}

.btn-secondary {
    background: white;
    color: var(--color-rose);
    border: 1px solid var(--color-rose-subtle);
}

.btn-secondary:hover {
    background: var(--color-rose-light);
}

.btn-sm {
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
}

/* ==========================================================================
   6. SECTION 1: THE INTERACTIVE ENVELOPE
   ========================================================================== */

.envelope-wrapper {
    position: relative;
    height: 380px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    perspective: 1000px;
}

.envelope {
    position: relative;
    width: 320px;
    height: 200px;
    background-color: var(--color-rose-subtle);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: transform 0.3s ease;
}

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

/* Envelope Flaps (Built with clip-path for sharp lines and zero overlap gaps) */
.envelope-front {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-rose-subtle);
    clip-path: polygon(0 40%, 50% 70%, 100% 40%, 100% 100%, 0 100%);
    z-index: 3;
    border-radius: 0 0 12px 12px;
    pointer-events: none;
}

.envelope-back {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--color-rose-light);
    clip-path: polygon(0 100%, 50% 65%, 100% 100%);
    z-index: 1;
    border-radius: 0 0 12px 12px;
    pointer-events: none;
}

.envelope-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 120px;
    background-color: var(--color-rose-subtle);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    z-index: 4;
    transform-origin: top;
    transition: transform 0.4s ease-in-out 0.35s, z-index 0s 0.35s; /* Delays closing until letter retracts */
}

/* Letter inside the envelope */
.letter {
    position: absolute;
    bottom: 10px;
    left: 15px;
    width: 290px;
    height: 180px;
    background-color: white;
    border-radius: 8px;
    z-index: 2;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.02);
    overflow: hidden;
    transition: transform 0.4s ease-in-out, height 0.4s ease-in-out; /* Retracts immediately when closing */
}

.letter-inner {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: hidden;
}

.letter-date {
    font-size: 0.7rem;
    color: var(--color-slate-light);
    margin-bottom: 0.5rem;
    display: block;
}

.letter h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--color-slate-dark);
    margin-bottom: 0.5rem;
}

.letter p {
    font-size: 0.85rem;
    color: var(--color-slate-medium);
    margin-bottom: 0.8rem;
    line-height: 1.5;
}

.letter .signature {
    margin-top: auto;
    font-style: italic;
    color: var(--color-rose);
    font-size: 0.88rem;
}

/* Envelope Open State */
.envelope-wrapper.open .envelope-top {
    transform: rotateX(180deg);
    z-index: 1;
    transition: transform 0.4s ease-in-out, z-index 0s 0.4s; /* Opens immediately, changes z-index after rotation */
}

.envelope-wrapper.open .letter {
    transform: translateY(-200px);
    z-index: 5;
    height: 370px;
    box-shadow: 0 15px 40px rgba(219, 123, 142, 0.12);
    transition: transform 0.4s ease-in-out 0.4s, height 0.4s ease-in-out 0.4s; /* Delays letter slide until flap opens */
}

.envelope-wrapper.open .letter-inner {
    overflow-y: auto; /* Allow scrolling inside the letter card */
    scrollbar-width: thin;
}

/* ==========================================================================
   7. SECTION 2: APPRECIATIONS GRID (3D FLIP CARDS)
   ========================================================================== */

.appreciations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
}

.flip-card {
    background: transparent;
    perspective: 1200px;
    height: 320px;
    cursor: pointer;
    overflow: visible; /* Required so 3D perspective works correctly */
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

/* Toggle rotation state */
.flip-card.flipped .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--color-card-border);
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(71, 85, 105, 0.02);
}

.flip-card-front {
    background: var(--color-card-bg);
    color: var(--color-slate-dark);
}

.flip-card-back {
    background: white;
    border-color: rgba(219, 123, 142, 0.45);
    color: var(--color-slate-dark);
    transform: rotateY(180deg);
}

.card-prompt-hint {
    margin-top: auto;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--color-rose);
    letter-spacing: 0.05em;
    padding-top: 1rem;
    display: inline-block;
}

.apprec-icon {
    width: 48px;
    height: 48px;
    background: var(--color-rose-light);
    border-radius: var(--border-radius-sm);
    color: var(--color-rose);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    transition: var(--transition-fast);
}

.flip-card:hover .apprec-icon {
    background: var(--color-rose);
    color: white;
}

.flip-card-front h3, .flip-card-back h3 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--color-slate-dark);
}

.flip-card-back h3 {
    color: var(--color-rose);
}

.flip-card-front p, .flip-card-back p {
    font-size: 0.92rem;
    color: var(--color-slate-light);
    line-height: 1.6;
}

.flip-card-back p {
    color: var(--color-slate-medium);
}

/* ==========================================================================
   8. SECTION 3: INTERACTIVE MEMORY BUBBLES
   ========================================================================== */

.bubbles-viewport-container {
    background: var(--color-card-bg);
    border: 1px solid var(--color-card-border);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(71, 85, 105, 0.05);
    margin-top: 2rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.reflection-box-card {
    background: white;
    border: 1px solid var(--color-card-border);
    border-top: none;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(71, 85, 105, 0.05);
    padding: 2rem;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.reflection-placeholder p {
    font-size: 0.9rem;
    color: var(--color-slate-light);
    font-weight: 500;
}

.bubbles-viewport {
    position: relative;
    width: 100%;
    height: 380px;
    background: linear-gradient(to bottom, #fef8f8, #f5f8fa);
    overflow: hidden;
    cursor: crosshair;
    border-bottom: 1px dashed var(--color-rose-subtle);
}

.bubbles-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-align: center;
    z-index: 10;
    transition: opacity 0.5s ease;
    background: white;
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    border: 1px solid var(--color-rose-subtle);
    box-shadow: 0 4px 12px rgba(219, 123, 142, 0.1);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-rose);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    animation: pulsePrompt 2s infinite ease-in-out;
    white-space: nowrap;
}

.bubbles-prompt-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    text-align: center;
    z-index: 10;
    transition: opacity 0.5s ease;
}

.tap-start-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-rose);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: white;
    padding: 0.6rem 1.2rem;
    border-radius: 30px;
    border: 1px solid var(--color-rose-subtle);
    box-shadow: 0 4px 12px rgba(219, 123, 142, 0.1);
    display: inline-block;
    animation: pulsePrompt 2s infinite ease-in-out;
}

@keyframes pulsePrompt {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.04); opacity: 1; }
}

/* Bubble Styling with realistic reflections */
.bubble-element {
    position: absolute;
    bottom: -60px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.1) 40%, rgba(219, 123, 142, 0.25) 70%, rgba(107, 132, 150, 0.3) 100%);
    box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.6), 0 4px 10px rgba(219, 123, 142, 0.08);
    cursor: pointer;
    transition: transform 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

/* Glossy highlights */
.bubble-element::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 15%;
    width: 25%;
    height: 25%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    transform: rotate(-30deg);
}

.bubble-element::after {
    content: '💭';
    font-size: 1.25rem;
    opacity: 0.65;
    transition: transform 0.3s ease;
}

.bubble-element:hover {
    transform: scale(1.1);
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.8), 0 6px 15px rgba(219, 123, 142, 0.15);
}

.bubble-element:hover::after {
    transform: scale(1.2);
}

/* Reflection card display box */
.bubble-reflection-box {
    padding: 2rem;
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: white;
}

.bubble-reflection-placeholder {
    color: var(--color-slate-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.bubble-reflection-placeholder p {
    font-size: 0.9rem;
    font-weight: 500;
}

.bubble-reflection-content {
    animation: bubbleContentReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.bubble-reflection-content span {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-rose);
    display: block;
    margin-bottom: 0.5rem;
}

.bubble-reflection-content h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 500;
    color: var(--color-slate-dark);
    margin-bottom: 0.5rem;
}

.bubble-reflection-content p {
    font-size: 0.95rem;
    color: var(--color-slate-medium);
    line-height: 1.6;
    max-width: 550px;
    margin: 0 auto;
}

@keyframes bubbleContentReveal {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   9. SECTION 4: INTERACTIVE FLOWER BLOOM & SOUNDS
   ========================================================================== */

#bloom-section {
    position: relative;
    overflow: hidden;
}

#sparkle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9;          /* Above page content, below portal overlay (1000) */
    pointer-events: none;
}

.flower-box {
    position: relative;
    width: 200px;
    height: 250px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    cursor: pointer;
    user-select: none;
}

.flower-stem {
    position: absolute;
    bottom: 0;
    width: 4px;
    height: 150px;
    background: var(--color-slate-light);
    border-radius: 2px;
}

.flower-bloom {
    position: absolute;
    bottom: 130px;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Petal Base Styles */
.petal {
    position: absolute;
    width: 32px;
    height: 50px;
    background: var(--color-rose-subtle);
    border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
    transform-origin: bottom center;
    transition: transform 1.2s cubic-bezier(0.19, 1, 0.22, 1), background 1.2s;
    opacity: 0.85;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

/* Radial placement of closed bud petals */
.petal-1 { transform: rotate(0deg) scale(0.65) translateY(10px); }
.petal-2 { transform: rotate(60deg) scale(0.65) translateY(10px); }
.petal-3 { transform: rotate(120deg) scale(0.65) translateY(10px); }
.petal-4 { transform: rotate(180deg) scale(0.65) translateY(10px); }
.petal-5 { transform: rotate(240deg) scale(0.65) translateY(10px); }
.petal-6 { transform: rotate(300deg) scale(0.65) translateY(10px); }

.flower-center {
    position: absolute;
    width: 24px;
    height: 24px;
    background: #eed2ac; /* Warm soft yellow pollen color */
    border-radius: 50%;
    z-index: 10;
    transform: scale(0.4);
    opacity: 0.5;
    transition: transform 1.2s cubic-bezier(0.19, 1, 0.22, 1), opacity 0.8s;
}

/* Flower Bloom State */
.flower-box.bloomed .petal {
    background: var(--color-rose);
    opacity: 0.95;
}

.flower-box.bloomed .petal-1 { transform: rotate(0deg) scale(1) translateY(-25px); }
.flower-box.bloomed .petal-2 { transform: rotate(60deg) scale(1) translateY(-25px); }
.flower-box.bloomed .petal-3 { transform: rotate(120deg) scale(1) translateY(-25px); }
.flower-box.bloomed .petal-4 { transform: rotate(180deg) scale(1) translateY(-25px); }
.flower-box.bloomed .petal-5 { transform: rotate(240deg) scale(1) translateY(-25px); }
.flower-box.bloomed .petal-6 { transform: rotate(300deg) scale(1) translateY(-25px); }

.flower-box.bloomed .flower-center {
    transform: scale(1.1);
    opacity: 1;
    box-shadow: 0 0 10px rgba(238, 210, 172, 0.4);
}

.bloom-status {
    margin-top: 1rem;
    min-height: 2rem;
}

.bloom-status p {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    color: var(--color-slate-light);
}

/* Interactive Card below flower */
.interactive-card {
    background: white;
    border: 1px solid var(--color-card-border);
    border-radius: var(--border-radius-md);
    padding: 2.25rem 2rem;
    margin-top: 3rem;
    box-shadow: 0 10px 40px rgba(71, 85, 105, 0.03);
}

.interactive-card h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--color-slate-dark);
}

.interactive-card p {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-style: italic;
    color: var(--color-slate-medium);
    margin-bottom: 1.5rem;
    line-height: 1.6;
    min-height: 3.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* ==========================================================================
   10. FOOTER
   ========================================================================== */

.app-footer {
    text-align: center;
    padding: 5rem 0 3rem 0;
    border-top: 1px solid rgba(219, 123, 142, 0.15);
    margin-top: 4rem;
    font-size: 0.85rem;
    color: var(--color-slate-light);
}

.app-footer p {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.app-footer span {
    font-size: 0.75rem;
    color: var(--color-slate-light);
}

/* ==========================================================================
   11. RESPONSIVE MEDIA QUERIES — MOBILE FIRST
   ========================================================================== */

/* ---- Tablet (768px and below) ---- */
@media (max-width: 768px) {
    .hero-section {
        min-height: 90vh;
        padding: 5rem 1.5rem 4rem;
    }

    .hero-title {
        font-size: 2.6rem;
        line-height: 1.2;
    }

    .hero-lead {
        font-size: 1.05rem;
    }

    .section {
        padding: 5rem 0;
    }

    .section-header {
        margin-bottom: 3rem;
    }

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

    /* Envelope */
    .envelope-wrapper {
        height: 340px;
    }

    .envelope {
        width: 280px;
        height: 175px;
    }

    .envelope-top {
        height: 105px;
    }

    .letter {
        width: 250px;
        height: 155px;
        left: 15px;
        bottom: 10px;
    }

    .envelope-wrapper.open .letter {
        height: 300px;
        transform: translateY(-170px);
        transition: transform 0.4s ease-in-out 0.4s, height 0.4s ease-in-out 0.4s;
    }

    /* Cards grid */
    .appreciations-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .flip-card {
        height: 280px;
    }

    /* Bubbles */
    .bubbles-viewport {
        height: 320px;
    }

    /* Flower */
    .flower-box {
        width: 160px;
        height: 220px;
    }

    .flower-stem {
        height: 120px;
    }

    .flower-bloom {
        bottom: 105px;
        width: 90px;
        height: 90px;
    }

    .interactive-card {
        padding: 1.75rem 1.5rem;
        margin-top: 2rem;
    }

    .interactive-card p {
        font-size: 1.1rem;
    }
}

/* ---- iPhone 12 Pro & Small Phones (max 430px) ---- */
@media (max-width: 430px) {
    /* Typography */
    .portal-card h1 {
        font-size: 1.7rem;
    }

    .portal-card p {
        font-size: 0.9rem;
    }

    .portal-card {
        padding: 2rem 1.25rem;
        border-radius: var(--border-radius-md);
    }

    .hero-section {
        min-height: 85vh;
        padding: 4rem 1.25rem 3rem;
    }

    .hero-title {
        font-size: 2rem;
        line-height: 1.2;
    }

    .hero-lead {
        font-size: 0.95rem;
        margin-bottom: 2rem;
    }

    .section {
        padding: 4rem 0;
    }

    .section-header {
        margin-bottom: 2.5rem;
    }

    .section-header h2 {
        font-size: 1.75rem;
    }

    .section-header p {
        font-size: 0.92rem;
    }

    .container {
        padding: 0 1.1rem;
    }

    /* Audio Toggle — smaller & repositioned */
    .ambient-player {
        top: 0.85rem;
        right: 0.85rem;
    }

    .audio-btn {
        padding: 0.45rem 0.85rem;
        font-size: 0.78rem;
        gap: 0.4rem;
    }

    .audio-btn span {
        display: none; /* Icon only on tiny screens */
    }

    /* Envelope — sized for 390px screens */
    .envelope-wrapper {
        height: 310px;
    }

    .envelope {
        width: 260px;
        height: 160px;
    }

    .envelope-top {
        height: 95px;
    }

    .letter {
        width: 232px;
        height: 140px;
        left: 14px;
        bottom: 10px;
    }

    .letter-inner {
        padding: 1rem 1.1rem;
    }

    .letter h3 {
        font-size: 1.05rem;
    }

    .letter p {
        font-size: 0.78rem;
        margin-bottom: 0.55rem;
    }

    .letter-date {
        font-size: 0.65rem;
        margin-bottom: 0.4rem;
    }

    .letter .signature {
        font-size: 0.8rem;
    }

    .envelope-wrapper.open .letter {
        height: 280px;
        transform: translateY(-155px);
        transition: transform 0.4s ease-in-out 0.4s, height 0.4s ease-in-out 0.4s;
    }

    /* Toggle button */
    .btn {
        padding: 0.72rem 1.35rem;
        font-size: 0.88rem;
    }

    /* Flip Cards — keep 3D flip intact, only adjust sizing */
    .flip-card {
        height: 340px;           /* Fixed height required for 3D flip context */
    }

    .flip-card-inner {
        height: 100%;            /* Must fill parent for backface-visibility to work */
    }

    /* Keep front/back as position:absolute — NEVER change this or the flip breaks */
    .flip-card-front,
    .flip-card-back {
        padding: 1.75rem 1.5rem; /* Reduce padding on mobile only */
        overflow-y: auto;        /* Scroll if text overflows at small heights */
        justify-content: flex-start; /* Align to top so text doesn't clip */
    }

    .flip-card-front {
        justify-content: center; /* Front face stays centered */
    }

    .flip-card-front h3,
    .flip-card-back h3 {
        font-size: 1.15rem;
    }

    .flip-card-front p,
    .flip-card-back p {
        font-size: 0.85rem;
    }

    .apprec-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 1rem;
    }

    .appreciations-grid {
        gap: 1.5rem;
    }

    /* Memory Bubbles — taller for phone aspect ratio */
    .bubbles-viewport {
        height: 300px;
        cursor: default; /* No crosshair on touch */
    }

    .bubble-element {
        /* Larger tap targets on mobile */
        min-width: 58px;
        min-height: 58px;
    }

    .bubble-reflection-box {
        padding: 1.5rem 1.1rem;
        min-height: 120px;
    }

    .bubble-reflection-content h3 {
        font-size: 1.15rem;
    }

    .bubble-reflection-content p {
        font-size: 0.85rem;
    }

    /* Flower */
    .flower-box {
        width: 140px;
        height: 200px;
    }

    .flower-stem {
        height: 110px;
    }

    .flower-bloom {
        bottom: 95px;
        width: 80px;
        height: 80px;
    }

    .petal {
        width: 26px;
        height: 40px;
    }

    .bloom-status p {
        font-size: 0.72rem;
    }

    /* Final note card */
    .interactive-card {
        padding: 1.5rem 1.25rem;
        margin-top: 1.5rem;
    }

    .interactive-card h3 {
        font-size: 1.2rem;
    }

    .interactive-card p {
        font-size: 1rem;
        min-height: auto;
    }

    /* Footer */
    .app-footer {
        padding: 3rem 0 2rem;
        font-size: 0.8rem;
    }
}

/* ---- Tiny phones (375px and below e.g. iPhone SE) ---- */
@media (max-width: 375px) {
    .hero-title {
        font-size: 1.8rem;
    }

    .envelope {
        width: 240px;
    }

    .letter {
        width: 214px;
    }

    .envelope-wrapper.open .letter {
        height: 260px;
        transform: translateY(-140px);
    }
}

/* ---- Touch-device specific enhancements ---- */
@media (hover: none) and (pointer: coarse) {
    /* Increase all tap targets to 44×44px minimum (Apple HIG) */
    .btn {
        min-height: 44px;
    }

    .audio-btn {
        min-height: 40px;
        padding: 0.55rem 1rem;
    }

    .bubble-element {
        min-width: 60px;
        min-height: 60px;
    }

    /* Disable hover-only tilt effects on touch — prevent stuck states */
    .flip-card-inner {
        transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    }

    /* Disable hover icon color change — no hover on touch */
    .flip-card:hover .apprec-icon {
        background: var(--color-rose-light);
        color: var(--color-rose);
    }

    /* Tap highlight for interactive elements */
    .flip-card,
    .bubble-element,
    .flower-box,
    .envelope {
        -webkit-tap-highlight-color: rgba(219, 123, 142, 0.12);
    }

    /* Prevent text selection during swipe/tap */
    .flip-card,
    .bubble-element,
    .flower-box {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Scroll momentum on letter */
    .envelope-wrapper.open .letter-inner {
        -webkit-overflow-scrolling: touch;
    }

    /* Glow spheres less intense on mobile (performance) */
    .glow-sphere {
        filter: blur(80px);
        opacity: 0.4;
    }
}

/* ---- Safe areas for iPhone notch/home bar ---- */
@supports (padding: max(0px)) {
    .ambient-player {
        top: max(0.85rem, env(safe-area-inset-top));
        right: max(0.85rem, env(safe-area-inset-right));
    }

    .app-footer {
        padding-bottom: max(2rem, env(safe-area-inset-bottom));
    }
}

