:root {
    --bg-dark: #0a0a0a;
    --primary: #ff4d6d;
    --primary-light: #ff758f;
    --primary-dark: #c9184a;
    --text: #ffffff;
    --text-muted: #e0e0e0;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text);
    min-height: 100dvh;
    overflow: hidden;
    position: relative;
}

/* Background Animation */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 50%, #590d22 0%, var(--bg-dark) 100%);
    z-index: -2;
}

.stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: transparent;
}

.stars::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #eee, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, #ddd, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #fff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, #fff, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: stars 100s linear infinite;
    opacity: 0.3;
}

@keyframes stars {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    transition: opacity 1s ease-in-out, visibility 1s ease-in-out;
    overflow-y: auto;
    overflow-x: hidden;
}

.screen::before, .screen::after {
    content: '';
    flex: auto;
}

.screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Glassmorphism Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3.5rem 2rem;
    width: 100%; 
    max-width: 550px; 
    margin: 2rem 0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transform: translateY(20px);
    opacity: 0;
    position: relative;
    animation: slideUp 0.8s ease-out forwards;
}

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

/* Intro Screen */
#intro-screen h1 {
    font-family: 'Dancing Script', cursive;
    font-size: 4rem;
    color: var(--primary-light);
    margin-bottom: 1rem;
}

#intro-screen p {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem; /* Réduction légère de l'espacement */
    align-items: center;
    width: 100%;
}

input, textarea {
    width: 100%;
    padding: 1rem 1.5rem;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.08);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
}

#passcode {
    border-radius: 50px;
    max-width: 300px;
}

textarea {
    resize: vertical;
    border-radius: 15px;
}

input:focus, textarea:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 15px rgba(255, 77, 109, 0.3);
}

button {
    padding: 1rem 2rem;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(201, 24, 74, 0.4);
    margin-top: 0.5rem; /* Léger ajustement pour l'équilibre */
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 77, 109, 0.6);
}

.error {
    color: var(--primary-light) !important;
    font-size: 1rem !important;
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    overflow: hidden;
    transition: all 0.3s ease-out;
}

.error:not(.hidden) {
    opacity: 1;
    max-height: 3rem;
    margin-bottom: 1rem;
}

/* Message Screen */
.message-card {
    max-width: 600px;
    padding: 4rem 3rem;
}

.title-name {
    font-family: 'Dancing Script', cursive;
    font-size: 3.5rem;
    color: var(--primary-light);
    margin-bottom: 2rem;
    text-align: left;
    width: 100%;
    opacity: 0;
    transform: translateY(10px);
}

.message-content {
    text-align: left; /* Justify crée des espaces trop grands sur mobile */
    font-size: 1.15rem;
    line-height: 1.8; /* Espacement restauré */
    color: var(--text-muted);
}

.message-content p {
    margin-bottom: 1.5rem; /* Espacement restauré */
    opacity: 0;
    transform: translateY(10px);
}

.date-proposal {
    margin-top: 2rem; 
    padding-top: 2rem;
    border-top: 1px dashed var(--glass-border);
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
}

.date-intro {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem; /* Ajout d'une marge entre le texte et le champ */
    text-align: center;
}

.action-btn {
    width: 100%;
    margin-top: 1rem;
}

.whatsapp-btn {
    background: linear-gradient(135deg, #25D366, #128C7E);
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.whatsapp-btn:hover {
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.6);
}

/* Envelope Animation - Ultra Réaliste */
/* Envelope Animation - Vector SVG */
.no-transition, .no-transition * {
    transition: none !important;
}

#envelope-screen {
    z-index: 50;
    align-items: center;
}

.envelope-wrapper {
    position: relative;
    width: 360px; /* Enveloppe agrandie */
    max-width: 95%; /* Sécurité pour très petits écrans */
    margin: auto;
    transition: all 1s ease;
    cursor: pointer;
    perspective: 1000px; 
}

#vector-envelope {
    width: 100%;
    height: auto;
    overflow: visible;
}

#svg-flap-closed {
    transform-origin: 150px 0px;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1), opacity 0s 0.3s;
}

#svg-flap-open {
    transition: opacity 0s 0.3s;
}

#svg-seal {
    transition: opacity 0.3s ease;
}

#svg-letter {
    transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) 0.5s;
}

/* Animations d'ouverture */
.envelope-wrapper.open #svg-flap-closed {
    transform: rotateX(180deg);
    opacity: 0;
}

.envelope-wrapper.open #svg-flap-open {
    opacity: 1;
}

.envelope-wrapper.open #svg-seal {
    opacity: 0;
}

.envelope-wrapper.open #svg-letter {
    transform: translateY(-130px);
}

.envelope-wrapper.open {
    transform: translateY(60px) scale(0.9);
}

/* Modif de la lettre finale */
.letter-style {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Animation fluide de l'enveloppe vers la lettre */
.message-card {
    animation: letterExpand 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes letterExpand {
    0% {
        opacity: 0;
        transform: translateY(100px) scale(0.3);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Bouton Retour Secondaire (en bas) */
.back-btn-secondary {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    margin-top: 1.5rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
    transition: color 0.3s ease;
}

.back-btn-secondary:hover {
    color: white;
}

/* Reveal Animations applied via JS */
.reveal {
    animation: fadeUp 0.8s ease forwards;
}

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

/* Floating Hearts */
.heart {
    position: absolute;
    color: var(--primary);
    font-size: 20px;
    opacity: 0;
    animation: floatUp 4s ease-in forwards;
    pointer-events: none;
    z-index: 10;
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(0.5);
        opacity: 0;
    }
    20% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(-200px) scale(1.5);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .glass-card {
        padding: 2rem 1.5rem;
    }
    
    #intro-screen h1 {
        font-size: 3rem;
    }
    
    .title-name {
        font-size: 2.8rem;
    }
    
    .message-content {
        font-size: 1.05rem;
    }
}
