:root {
    --primary-red: #ff4d6d;
    --soft-pink: #ffccd5;
    --dark-red: #800f2f;
    --white: #ffffff;
    --bg-gradient: linear-gradient(135deg, #fff0f3 0%, #ffccd5 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg-gradient);
    height: 100vh;
    overflow: hidden;
    color: var(--dark-red);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Background Hearts */
.hearts-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

.heart {
    position: absolute;
    color: var(--primary-red);
    opacity: 0.6;
    animation: floatUp 5s linear infinite;
    font-size: 20px;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) scale(0.5);
        opacity: 0;
    }

    10% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(-10vh) scale(1.2) rotate(360deg);
        opacity: 0;
    }
}

/* Screen Management */
.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 1s ease-in-out, transform 1s ease-in-out;
    z-index: 10;
}

.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.9);
}

/* Landing Screen */
.content-box {
    text-align: center;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    padding: 3rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 30px rgba(255, 77, 109, 0.2);
    animation: fadeIn 1.5s ease-out;
}

.main-title {
    font-family: 'Great Vibes', cursive;
    font-size: 4rem;
    margin-bottom: 2rem;
    color: var(--dark-red);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.countdown-box {
    margin: 2rem 0;
    padding: 2rem;
    background: rgba(255, 77, 109, 0.1);
    border-radius: 15px;
    border: 2px solid rgba(255, 77, 109, 0.3);
}

.countdown-text {
    font-size: 1.2rem;
    color: var(--dark-red);
    margin-bottom: 1rem;
    font-weight: 600;
}

.countdown-timer {
    font-family: 'Courier New', monospace;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-red);
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(255, 77, 109, 0.5);
}

.cta-button {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    box-shadow: 0 5px 15px rgba(255, 77, 109, 0.4);
}

.cta-button:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(255, 77, 109, 0.6);
}

.music-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.7);
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    cursor: pointer;
    font-family: 'Poppins', sans-serif;
    color: var(--dark-red);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.music-btn:hover {
    background: white;
    transform: scale(1.05);
}

/* Message Screen */
.letter-container {
    perspective: 1000px;
    width: 90%;
    max-width: 600px;
}

.paper {
    background: #fff;
    padding: 2.5rem;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    position: relative;
    transform-origin: top center;
    background-image: linear-gradient(#f0f0f0 1px, transparent 1px);
    background-size: 100% 1.4rem;
    line-height: 1.4rem;
}

.paper::before {
    content: '';
    position: absolute;
    left: 40px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: rgba(255, 0, 0, 0.2);
}

.dear-text {
    font-family: 'Great Vibes', cursive;
    font-size: 2.52rem;
    margin-bottom: 1rem;
    color: var(--dark-red);
}

.message-body {
    font-size: 0.77rem;
    color: #555;
    min-height: 100px;
    white-space: pre-wrap;
    line-height: 1.2rem;
}

.signature {
    font-family: 'Great Vibes', cursive;
    font-size: 1.82rem;
    text-align: right;
    margin-top: 1.2rem;
    color: var(--primary-red);
    opacity: 0;
    animation: fadeIn 2s ease-in forwards;
    animation-delay: 10s;
    /* Will adjust via JS based on typing duration */
}

.restart-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 0.98rem;
    color: #999;
    opacity: 0.5;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 5px 15px rgba(255, 77, 109, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 8px 25px rgba(255, 77, 109, 0.8);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 5px 15px rgba(255, 77, 109, 0.4);
    }
}

/* Flower Garden */
.garden-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15vh;
    /* Occupy bottom area */
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    pointer-events: none;
    z-index: 5;
    padding: 0 20px;
}

#garden-canvas {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15vh;
    pointer-events: none;
    z-index: 5;
}

.flower-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: bottom center;
    animation: growFlower 2s ease-out forwards, sway 3s ease-in-out infinite alternate;
}

.stem {
    width: 4px;
    height: 60px;
    /* Base height, JS will randomize */
    background: linear-gradient(to top, #1a9c34, #52c234);
    border-radius: 2px;
}

.leaf {
    position: absolute;
    width: 20px;
    height: 10px;
    background-color: #52c234;
    border-radius: 0 10px 0 10px;
    top: 40%;
}

.leaf.left {
    left: -15px;
    transform: rotate(-15deg);
}

.leaf.right {
    right: -15px;
    transform: rotate(15deg) scaleX(-1);
}

.rose-head {
    width: 30px;
    height: 30px;
    position: relative;
    bottom: -2px;
    /* Connect to stem */
}

/* CSS Only Rose Petals */
.petal {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #d00000;
    border-radius: 50% 50% 0 50%;
    transform: rotate(45deg);
    box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.2);
}

.petal::before,
.petal::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: #e00000;
    border-radius: 50% 50% 0 50%;
    top: -15%;
    left: -15%;
    transform: rotate(-20deg);
    z-index: -1;
}

.petal::after {
    background: #9d0208;
    top: 15%;
    left: 15%;
    transform: rotate(20deg);
    z-index: 1;
    opacity: 0.7;
}

.center-bud {
    position: absolute;
    width: 60%;
    height: 60%;
    background: #6a040f;
    border-radius: 50%;
    top: 20%;
    left: 20%;
    z-index: 2;
    opacity: 0.8;
}

@keyframes growFlower {
    from {
        transform: scaleY(0);
        opacity: 0;
    }

    to {
        transform: scaleY(1);
        opacity: 1;
    }
}

@keyframes sway {
    from {
        transform: rotate(-5deg);
    }

    to {
        transform: rotate(5deg);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .content-box {
        padding: 2.5rem;
    }

    .main-title {
        font-size: 3.5rem;
    }

    .cta-button {
        padding: 0.9rem 2rem;
        font-size: 1.1rem;
    }
}

@media (max-width: 768px) {
    body {
        min-height: 100vh;
        overflow-y: auto;
    }

    .content-box {
        padding: 2rem;
        margin: 1rem;
    }

    .main-title {
        font-size: 2.5rem;
        margin-bottom: 1.5rem;
    }

    .cta-button {
        padding: 0.8rem 1.8rem;
        font-size: 1rem;
    }

    .letter-container {
        max-width: 90%;
        width: 90%;
    }

    .paper {
        padding: 1.8rem;
        background-size: 100% 1rem;
        line-height: 1rem;
    }

    .dear-text {
        font-size: 2rem;
        margin-bottom: 0.8rem;
    }

    .message-body {
        font-size: 0.7rem;
        line-height: 1rem;
    }

    .signature {
        font-size: 1.4rem;
        margin-top: 1rem;
    }

    .music-btn {
        top: 10px;
        right: 10px;
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .garden-container {
        height: 12vh;
    }

    .stem {
        height: 50px;
    }
}

@media (max-width: 480px) {
    .content-box {
        padding: 1.5rem;
        margin: 0.5rem;
    }

    .main-title {
        font-size: 2rem;
        margin-bottom: 1.2rem;
    }

    .cta-button {
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
    }

    .letter-container {
        max-width: 95%;
        width: 95%;
    }

    .paper {
        padding: 1.3rem;
        background-size: 100% 0.95rem;
        line-height: 0.95rem;
    }

    .dear-text {
        font-size: 1.68rem;
        margin-bottom: 0.7rem;
    }

    .message-body {
        font-size: 0.67rem;
        line-height: 0.95rem;
    }

    .signature {
        font-size: 1.26rem;
        margin-top: 0.8rem;
    }

    .restart-hint {
        font-size: 0.84rem;
        margin-top: 15px;
    }

    .music-btn {
        top: 8px;
        right: 8px;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .garden-container {
        height: 10vh;
        padding: 0 10px;
    }

    .stem {
        height: 40px;
    }
}