/* --- DESIGN SYSTEM & VARIABLES --- */
:root {
    --primary-hsl: 345, 100%, 70%;
    --primary: hsl(var(--primary-hsl));
    --primary-dark: hsl(345, 90%, 62%);
    --primary-light: hsl(345, 100%, 94%);
    
    --secondary-hsl: 43, 100%, 65%;
    --secondary: hsl(var(--secondary-hsl)); /* Gold / Sparkle */
    
    --success-hsl: 145, 75%, 45%;
    --success: hsl(var(--success-hsl)); /* Soft Mint Green */
    
    --danger-hsl: 355, 80%, 60%;
    --danger: hsl(var(--danger-hsl)); /* Soft Coral/Crimson */
    
    --bg-start: #FFF0F5; /* Lavender Blush */
    --bg-middle: #FFE4E1; /* Misty Rose */
    --bg-end: #FFB6C1; /* Light Pink */
    
    --text-main: hsl(340, 60%, 22%); /* Dark Berry/Chocolate */
    --text-muted: hsl(340, 25%, 45%);
    --text-white: #ffffff;
    
    --glass-bg: rgba(255, 255, 255, 0.48);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 12px 40px 0 rgba(255, 105, 180, 0.15);
    
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Outfit', sans-serif;
    
    --transition-smooth: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    --transition-bounce: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- BASE STYLES --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none; /* Prevent selection highlight during intensive tapping */
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-middle) 40%, var(--bg-end) 100%);
    color: var(--text-main);
    min-height: 100dvh;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Background Canvas for Sparkles & Particles */
#particles-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* Ambient Floating Hearts Background */
.floating-hearts-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.ambient-heart {
    position: absolute;
    color: rgba(255, 107, 139, 0.22);
    font-size: 1.5rem;
    animation: floatUp 8s linear infinite;
    bottom: -50px;
}

/* --- APP LAYOUT --- */
.app-container {
    width: 100%;
    max-width: 440px; /* Perfect mobile width */
    height: 100dvh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 3;
}

/* Screen Transitions */
.screen {
    display: none;
    opacity: 0;
    transform: translateY(30px) scale(0.96);
    transition: var(--transition-smooth);
    width: 100%;
    height: auto;
    max-height: 90dvh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* --- GLASS CARD COMPONENT --- */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px) saturate(130%);
    -webkit-backdrop-filter: blur(20px) saturate(130%);
    border-radius: 30px;
    box-shadow: var(--glass-shadow);
    padding: 30px 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    animation: cardGlowPulse 6s ease-in-out infinite alternate;
}

@keyframes cardGlowPulse {
    0% { box-shadow: 0 12px 40px 0 rgba(255, 105, 180, 0.15); }
    100% { box-shadow: 0 12px 40px 6px rgba(255, 105, 180, 0.28); }
}

/* --- BUTTON SYSTEM --- */
.btn {
    border: none;
    outline: none;
    padding: 16px 36px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition-bounce);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    box-shadow: 0 8px 24px rgba(255, 107, 139, 0.35);
}

.btn-primary:hover {
    box-shadow: 0 10px 28px rgba(255, 107, 139, 0.5);
}

.btn-success {
    background: linear-gradient(135deg, hsl(145, 80%, 48%) 0%, hsl(145, 90%, 38%) 100%);
    color: var(--text-white);
    box-shadow: 0 8px 24px rgba(46, 204, 113, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, hsl(355, 70%, 50%) 100%);
    color: var(--text-white);
    box-shadow: 0 6px 18px rgba(231, 76, 60, 0.25);
}


/* --- SCREEN 1: SIMPLIFIED ELEGANT ENVELOPE CARD --- */
.envelope-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    color: var(--text-main);
    text-shadow: 0 2px 4px rgba(255, 255, 255, 0.5);
    animation: heartBeat 2s infinite;
}

.envelope-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.envelope-card {
    background: var(--glass-bg);
    border: 2px dashed rgba(255, 107, 139, 0.4);
    backdrop-filter: blur(20px) saturate(130%);
    -webkit-backdrop-filter: blur(20px) saturate(130%);
    border-radius: 24px;
    padding: 40px 24px;
    width: 290px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: var(--glass-shadow);
    cursor: pointer;
    transition: var(--transition-bounce);
    position: relative;
    animation: cardGlowPulse 6s ease-in-out infinite alternate;
}

.envelope-card:active {
    transform: scale(0.96) rotate(-2deg);
}

.envelope-seal {
    position: relative;
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, var(--primary-light) 0%, #fff 100%);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 20px rgba(255, 107, 139, 0.2);
    margin-bottom: 25px;
    border: 2px solid rgba(255, 107, 139, 0.3);
}

.envelope-icon {
    font-size: 2.8rem;
    color: var(--primary);
}

.heart-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    font-size: 1.8rem;
    animation: heartBeat 1.5s infinite;
}

.envelope-text {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
}

.open-button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 6px 18px rgba(255, 107, 139, 0.3);
    transition: var(--transition-bounce);
}

.envelope-card:hover .open-button {
    box-shadow: 0 8px 22px rgba(255, 107, 139, 0.45);
    transform: translateY(-2px);
}



/* --- SCREEN 2: HEARTFELT LETTER & CARDS --- */
.letter-card {
    padding: 35px 20px 25px;
}

.letter-header {
    margin-bottom: 18px;
}

.rose-icon {
    font-size: 2.2rem;
    display: inline-block;
    animation: sway 3s ease-in-out infinite alternate;
}

.letter-header h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--text-main);
    margin-top: 8px;
}

.letter-body {
    text-align: left;
    margin-bottom: 25px;
}

.letter-body p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 12px;
    color: var(--text-main);
}

.font-italic {
    font-style: italic;
    font-weight: 500;
    text-align: center;
    color: var(--primary-dark) !important;
}

/* Dividers */
.divider {
    width: 100%;
    display: flex;
    align-items: center;
    margin: 20px 0;
}

.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 107, 139, 0.4), transparent);
}

.divider span {
    padding: 0 12px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary-dark);
}

/* 3D memory cards */
.memory-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    margin-bottom: 25px;
}

.flip-card {
    background-color: transparent;
    height: 100px;
    perspective: 1000px;
}

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

/* Flipped class toggle by JS */
.flip-card-inner.flipped {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 6px;
}

.flip-card-front {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 107, 139, 0.25);
    color: var(--text-main);
}

.flip-card-back {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    transform: rotateY(180deg);
    font-size: 0.72rem;
    line-height: 1.3;
    font-weight: 500;
}

.card-icon {
    font-size: 1.3rem;
    color: var(--primary-dark);
    margin-bottom: 4px;
}

.flip-card-front h3 {
    font-size: 0.82rem;
    font-weight: 700;
}

.tap-hint {
    font-size: 0.58rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 4px;
    opacity: 0.8;
}


/* --- SCREEN 3: INTERACTIVE QUESTION --- */
.cute-character-area {
    margin-bottom: 25px;
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Custom CSS Heart Animation */
.cute-heart-container {
    position: relative;
    width: 80px;
    height: 80px;
}

.pulse-heart {
    position: absolute;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    top: 10px;
    left: 10px;
    transform: rotate(-45deg);
    border-radius: 4px;
    animation: heartThrob 1s infinite alternate cubic-bezier(0.215, 0.610, 0.355, 1);
    box-shadow: 0 10px 30px rgba(255, 107, 139, 0.4);
}

.pulse-heart::before, .pulse-heart::after {
    content: "";
    position: absolute;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    border-radius: 50%;
}

.pulse-heart::before {
    top: -30px;
    left: 0;
}

.pulse-heart::after {
    top: 0;
    left: 30px;
}

/* Pulsing Outer Rings */
.pulse-heart-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 100px;
    height: 100px;
    border: 2px solid rgba(255, 107, 139, 0.35);
    border-radius: 50%;
    animation: heartRingPulse 2s infinite ease-out;
    pointer-events: none;
}

@keyframes heartThrob {
    0% { transform: rotate(-45deg) scale(0.9); }
    100% { transform: rotate(-45deg) scale(1.1); }
}

@keyframes heartRingPulse {
    0% { transform: scale(0.6); opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

.question-title {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.3;
}

.dynamic-prompt {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 30px;
    min-height: 24px;
    transition: var(--transition-smooth);
}

/* Interactive button layout */
.btn-group {
    display: flex;
    flex-direction: row;
    gap: 15px;
    width: 100%;
    margin-top: 10px;
    position: relative;
    min-height: 60px;
    align-items: center;
    justify-content: center;
}

#btn-yes {
    margin-top: 0;
    flex: 1.2;
    z-index: 100; /* Must stay on top of other elements when growing */
    white-space: nowrap;
}

#btn-no {
    margin-top: 0;
    flex: 0.8;
    z-index: 10;
}


/* --- SCREEN 4: CELEBRATION --- */
.celebration-card {
    padding: 40px 24px;
}

.celebration-badge {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary) 0%, #ffc300 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 20px rgba(254, 215, 98, 0.4);
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.gold-crown {
    font-size: 2rem;
    color: var(--text-white);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.celebration-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 15px;
    color: var(--primary-dark);
}

.celebration-subtitle {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-main);
    margin-bottom: 25px;
}

.heart-pulse-large {
    font-size: 5rem;
    color: var(--primary);
    animation: heartBeat 1.2s infinite;
    text-shadow: 0 10px 25px rgba(255, 107, 139, 0.25);
    margin-bottom: 20px;
}

.promise-tag {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-dark);
    letter-spacing: 0.5px;
    opacity: 0.9;
}


/* --- GENERAL ANIMATIONS --- */
@keyframes floatUp {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.8);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-110vh) rotate(360deg) scale(1.2);
        opacity: 0;
    }
}

@keyframes float {
    0% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
    100% { transform: translateY(0px) rotate(0deg); }
}

@keyframes sway {
    0% { transform: rotate(-8deg); }
    100% { transform: rotate(8deg); }
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.12); }
    28% { transform: scale(1); }
    42% { transform: scale(1.12); }
    70% { transform: scale(1); }
}

@keyframes bounceText {
    0% { transform: translateY(0); opacity: 0.6; }
    100% { transform: translateY(-5px); opacity: 0.9; }
}

@keyframes letterPopup {
    0% { transform: translateY(100%) scale(0.8); opacity: 0; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}


/* --- RESPONSIVENESS AND TIGHT FIXES --- */
@media (max-height: 700px) {
    .glass-card {
        padding: 20px 16px;
    }
    .letter-header h2 {
        font-size: 1.5rem;
    }
    .letter-body p {
        font-size: 0.9rem;
        margin-bottom: 8px;
    }
    .memory-cards-grid {
        margin-bottom: 15px;
        gap: 6px;
    }
    .flip-card {
        height: 85px;
    }
    .flip-card-back {
        font-size: 0.65rem;
    }
    .cute-character-area {
        margin-bottom: 15px;
        width: 100px;
        height: 100px;
    }
    .cute-heart-container {
        width: 50px;
        height: 50px;
    }
    .pulse-heart {
        width: 40px;
        height: 40px;
    }
    .pulse-heart::before, .pulse-heart::after {
        width: 40px;
        height: 40px;
    }
    .pulse-heart::before { top: -20px; }
    .pulse-heart::after { left: 20px; }
    .pulse-heart-ring {
        width: 70px;
        height: 70px;
    }
}

/* Fullscreen Yes Button class triggered on 4th No click */
.btn-yes-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    font-size: 2.2rem !important;
    z-index: 99999 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin: 0 !important;
    transform: none !important;
    box-shadow: none !important;
    background: linear-gradient(135deg, hsl(145, 80%, 48%) 0%, hsl(145, 90%, 38%) 100%) !important;
    transition: var(--transition-bounce) !important;
}

/* Perfect square buttons for the question card (centered glass card container) */
.question-card .btn {
    width: 130px !important;
    height: 130px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 16px !important; /* Premium rounded square */
    display: inline-flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    padding: 12px !important;
    font-size: 1.05rem !important;
    white-space: normal !important; /* Let text wrap nicely inside the square */
    line-height: 1.4 !important;
    margin: 0 !important;
}

/* Allow buttons to overflow outside the card boundaries during growing and dodging */
#screen-question,
.question-card,
.question-card .btn-group {
    overflow: visible !important;
}


