/* Modern & Premium Chat Design */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,600;1,600&family=Great+Vibes&display=swap');

:root {
    /* Color Palette */
    --bg-dark: #0f172a;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e1b4b;

    --primary-color: #fca5a5;
    --primary-dark: #e11d48;
    --accent-gold: #fbbf24;

    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;

    --msg-sent-bg: #e11d48;
    --msg-sent-text: #fff;
    --msg-received-bg: rgba(255, 255, 255, 0.1);
    --msg-received-text: #f1f5f9;
}

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

body {
    background: radial-gradient(circle at top right, var(--bg-gradient-end), var(--bg-dark));
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="%23fca5a5" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/></svg>') 12 12, auto;
    /* Custom Cursor optional */
}

/* Background Animation */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 10s ease-in-out infinite;
}

.orb-1 {
    top: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: var(--primary-dark);
}

.orb-2 {
    bottom: -10%;
    left: -10%;
    width: 400px;
    height: 400px;
    background: #4f46e5;
    animation-delay: -5s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, 50px);
    }
}

/* FIREFLIES */
#fireflies-container {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    overflow: hidden;
    pointer-events: none;
    /* Pass clicks through */
    z-index: 1;
    /* Above background, below text (if text is z-index'd) */
}

/* Ensure Chat Area is above fireflies */
#chat-area {
    position: relative;
    z-index: 5;
}

/* Ensure Header is above */
header {
    position: relative;
    z-index: 10;
}

.firefly {
    position: absolute;
    width: 6px;
    height: 6px;
    /* Increased size */
    background: #fbbf24;
    border-radius: 50%;
    box-shadow: 0 0 15px #fbbf24, 0 0 25px #f59e0b;
    /* Brighter glow */
    opacity: 0;
    animation: fly 12s infinite ease-in-out;
    mix-blend-mode: screen;
    /* Vivid blend */
}

@keyframes fly {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    /* Higher opacity */
    50% {
        transform: translate(150px, -80px) scale(1.5);
        opacity: 1;
    }

    90% {
        opacity: 0.6;
    }

    100% {
        transform: translate(300px, -200px) scale(0);
        opacity: 0;
    }
}

/* MAGIC CURSOR TRAIL */
.cursor-trail {
    position: fixed;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 0 10px #fff, 0 0 20px var(--primary-color);
    animation: fadeTrail 1s linear forwards;
}

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

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Main Container */
.app-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    max-height: 900px;
    position: relative;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    /* Increased Blur for premium feel */
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--glass-shadow);
}

@media (min-width: 768px) {
    .app-container {
        height: 85vh;
        border-radius: 24px;
    }
}

/* Header */
header {
    padding: 20px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(15, 23, 42, 0.4);
    z-index: 10;
}

.avatar-container {
    position: relative;
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 15px rgba(225, 29, 72, 0.4);
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border: 2px solid var(--bg-dark);
    border-radius: 50%;
}

.header-info h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.header-info p {
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Chat Area */
#chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#chat-area::-webkit-scrollbar {
    display: none;
}

/* Messages */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    opacity: 0;
    transform: translateY(20px);
}

.message-wrapper.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message-wrapper.received {
    align-self: flex-start;
    align-items: flex-start;
}

.message {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    backdrop-filter: blur(4px);
    /* Extra glass effect on bubbles */
}

.message.sent {
    background: linear-gradient(135deg, rgba(225, 29, 72, 0.9), rgba(190, 18, 60, 0.9));
    color: var(--msg-sent-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(225, 29, 72, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message.received {
    background: rgba(255, 255, 255, 0.08);
    color: var(--msg-received-text);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--glass-border);
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    margin-left: 4px;
}

.sent .message-time {
    text-align: right;
    margin-right: 4px;
}

/* Typing Indicator */
.typing-indicator {
    padding: 12px 16px;
    background: var(--msg-received-bg);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: fit-content;
    margin-bottom: 10px;
    display: none;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Photo Gallery */
.gallery-container {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    opacity: 0;
    transition: opacity 1s ease;
}

.gallery-photo {
    width: 100%;
    aspect-ratio: 1/1;
    border-radius: 12px;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.gallery-photo:hover {
    transform: scale(1.05) rotate(2deg);
    z-index: 5;
    border-color: var(--primary-color);
}

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

/* Special Message */
.special-message {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    text-align: center;
    width: 100%;
    max-width: 100% !important;
    background: transparent !important;
    border: none !important;
    padding: 20px 0;
}

.special-message .highlight {
    background: linear-gradient(120deg, var(--white) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: bold;
}

/* START OVERLAY */
.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease;
}

.start-content {
    text-align: center;
    color: #fff;
    animation: fadeIn 1s ease;
}

.start-content h1 {
    font-family: 'Great Vibes', cursive;
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(225, 29, 72, 0.5);
}

.start-content p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    opacity: 0.8;
}

.start-content button {
    padding: 12px 40px;
    background: var(--primary-dark);
    border: none;
    border-radius: 30px;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(225, 29, 72, 0.4);
    transition: transform 0.2s, background 0.2s;
}

.start-content button:hover {
    transform: scale(1.05);
    background: #be123c;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* --- 3D GIFT BOX --- */
.gift-container {
    perspective: 1000px;
    width: 150px;
    height: 150px;
    margin: 0 auto;
    position: relative;
    cursor: pointer;
}

.gift-box {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    transform: rotateX(-20deg) rotateY(45deg);
}

.gift-container:hover .gift-box {
    transform: rotateX(-20deg) rotateY(45deg) scale(1.05);
}

.gift-body {
    width: 100px;
    height: 100px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform-style: preserve-3d;
    transform: translate(-50%, -50%);
}

.gift-cube-face {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.face-front {
    background: linear-gradient(135deg, #e11d48, #be123c);
    transform: translateZ(50px);
}

.face-back {
    background: linear-gradient(135deg, #e11d48, #be123c);
    transform: rotateY(180deg) translateZ(50px);
}

.face-right {
    background: linear-gradient(135deg, #9f1239, #881337);
    transform: rotateY(90deg) translateZ(50px);
}

.face-left {
    background: linear-gradient(135deg, #9f1239, #881337);
    transform: rotateY(-90deg) translateZ(50px);
}

.face-top {
    background: #fb7185;
    transform: rotateX(90deg) translateZ(50px);
}

.face-bottom {
    background: #881337;
    transform: rotateX(-90deg) translateZ(50px);
}

/* Ribbon vertical */
.face-front::after,
.face-back::after,
.face-top::after,
.face-bottom::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 100%;
    background: var(--accent-gold);
    left: 40px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

.face-right::after,
.face-left::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 20px;
    background: var(--accent-gold);
    top: 40px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
}

/* LID */
.gift-lid {
    position: absolute;
    width: 104px;
    height: 25px;
    top: calc(50% - 65px);
    left: calc(50% - 52px);
    transform-style: preserve-3d;
    transform: translateZ(0);
    z-index: 10;
    transition: transform 0.8s ease-in-out;
}

.lid-face {
    position: absolute;
    background: #f43f5e;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.lid-top {
    width: 104px;
    height: 104px;
    transform: rotateX(90deg) translateZ(12.5px);
    background: #fb7185;
}

.lid-front {
    width: 104px;
    height: 25px;
    transform: translateZ(52px);
}

.lid-back {
    width: 104px;
    height: 25px;
    transform: rotateY(180deg) translateZ(52px);
}

.lid-right {
    width: 104px;
    height: 25px;
    transform: rotateY(90deg) translateZ(52px);
}

.lid-left {
    width: 104px;
    height: 25px;
    transform: rotateY(-90deg) translateZ(52px);
}

.lid-top::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 100%;
    left: 42px;
    background: var(--accent-gold);
}

.lid-top::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 20px;
    top: 42px;
    background: var(--accent-gold);
}

.gift-bow {
    position: absolute;
    top: -35px;
    left: 32px;
    width: 40px;
    height: 40px;
    transform-style: preserve-3d;
    transform: rotateX(90deg) translateZ(15px);
}

.gift-bow::before,
.gift-bow::after {
    content: '';
    position: absolute;
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 0 50%;
    background: var(--accent-gold);
    transform: rotate(45deg);
    top: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.gift-bow::after {
    left: 20px;
    transform: rotate(-45deg);
}

.shake-box {
    animation: shake 0.5s ease-in-out infinite;
}

.lid-open {
    transform: translateY(-80px) rotateX(-110deg) !important;
}

@keyframes shake {
    0% {
        transform: rotateX(-20deg) rotateY(45deg) translateX(0);
    }

    25% {
        transform: rotateX(-20deg) rotateY(45deg) translateX(5px);
    }

    50% {
        transform: rotateX(-20deg) rotateY(45deg) translateX(-5px);
    }

    75% {
        transform: rotateX(-20deg) rotateY(45deg) translateX(5px);
    }

    100% {
        transform: rotateX(-20deg) rotateY(45deg) translateX(0);
    }
}

/* MUSIC CONTROL */
.music-control {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--primary-color);
}

.music-control:hover {
    background: rgba(225, 29, 72, 0.2);
    transform: scale(1.1);
}

.music-icon {
    font-size: 1.2rem;
}

.music-playing {
    animation: spin 3s linear infinite;
    background: rgba(225, 29, 72, 0.2);
    box-shadow: 0 0 15px rgba(225, 29, 72, 0.4);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* FLOWERS & FINALE */
.finale-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    overflow: hidden;
}

.flowers-wrapper {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 60%;
    display: flex;
    justify-content: center;
    perspective: 1000px;
}

.stem {
    position: absolute;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to top, #0f220f, #2e7d32);
    border-radius: 4px;
    transform-origin: bottom center;
    opacity: 0;
}

.leaf {
    position: absolute;
    width: 20px;
    height: 10px;
    background: #1b5e20;
    border-radius: 0 80% 80% 80%;
    opacity: 0;
    transform-origin: left center;
}

.berry {
    position: absolute;
    width: 12px;
    height: 12px;
    background: radial-gradient(circle at 30% 30%, #ff5e5e, #c40000);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
    transform: scale(0);
}

.final-note {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    width: 80%;
    max-width: 350px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: all 1s ease;
    z-index: 600;
    pointer-events: auto;
}

.final-note.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.final-note h2 {
    font-family: 'Great Vibes', cursive;
    font-size: 2.5rem;
    color: #c40000;
    margin-bottom: 10px;
}

.final-note p {
    font-family: 'Inter', sans-serif;
    color: #333;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ENVELOPE */
.envelope-container {
    position: absolute;
    bottom: 0px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    z-index: 700;
    transition: all 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: auto;
}

.envelope-container.show {
    bottom: 250px;
    transform: translateX(-50%) scale(1);
}

.envelope {
    width: 150px;
    height: 100px;
    background: #fdf2f8;
    position: relative;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s;
}

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

.front {
    position: absolute;
    width: 0;
    height: 0;
    z-index: 3;
    border-left: 75px solid #fecdd3;
    border-right: 75px solid #fecdd3;
    border-top: 50px solid transparent;
    border-bottom: 50px solid #f43f5e;
    top: 0;
    left: 0;
}

.back {
    position: absolute;
    width: 0;
    height: 0;
    z-index: 1;
    border-left: 75px solid #fbcfe8;
    border-right: 75px solid #fbcfe8;
    border-top: 50px solid #db2777;
    border-bottom: 50px solid transparent;
    top: 0;
    left: 0;
    transform-origin: top;
    transition: transform 0.4s 0.2s;
}

.envelope.open .back {
    transform: rotateX(180deg);
    z-index: 0;
}

.card {
    position: absolute;
    top: 5px;
    left: 10px;
    width: 130px;
    height: 90px;
    background: #fff;
    z-index: 2;
    transition: transform 0.4s 0.6s;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.envelope.open .card {
    transform: translateY(-50px);
    z-index: 4;
}

.letter-text {
    font-family: 'Great Vibes', cursive;
    font-size: 1.2rem;
    color: #be123c;
    line-height: 1.2;
}

/* Click Heart */
.click-heart {
    position: fixed;
    pointer-events: none;
    animation: floatHeart 1s ease-out forwards;
    z-index: 9999;
}

@keyframes floatHeart {
    0% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }

    100% {
        transform: scale(1.5) translateY(-50px);
        opacity: 0;
    }
}