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

:root {
    --container-width: min(92vw, 800px);
    --container-padding: clamp(1.25rem, 4vw, 2.5rem);
    --container-bottom-padding: clamp(8.5rem, 24vw, 12rem);
    --message-size: clamp(2rem, 5vw, 2.9rem);
    --question-size: clamp(2rem, 4.5vw, 3.25rem);
    --body-padding-top: max(1rem, env(safe-area-inset-top));
    --body-padding-right: max(1rem, env(safe-area-inset-right));
    --body-padding-bottom: max(1rem, env(safe-area-inset-bottom));
    --body-padding-left: max(1rem, env(safe-area-inset-left));
}

html {
    height: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-overflow-scrolling: touch;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    padding:
        var(--body-padding-top)
        var(--body-padding-right)
        var(--body-padding-bottom)
        var(--body-padding-left);
    background:
        linear-gradient(45deg,
            #620080 25%,
            #8a2be2 75%);
    font-family: "Courier New", monospace;
    overflow: hidden;
    position: relative;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='52' height='52' viewBox='0 0 52 52' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M26 35.5C17.6 35.5 4 29.5 4 17.5 4 9.5 11.7 3 21.5 3c5.1 0 8.7 2.5 11.5 6 2.8-3.5 6.4-6 11.5-6C40.3 3 48 9.5 48 17.5c0 12-13.6 18-22 18z' fill='%23ffffff' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    z-index: -1;
    pointer-events: none;
    will-change: transform;
}

.love-particle {
    position: absolute;
    font-size: 24px;
    opacity: 0;
    animation: float 6s linear infinite;
    will-change: transform;
    -webkit-font-smoothing: subpixel-antialiased;
}

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

.message-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--container-width);
    min-height: min(72vh, 560px);
    padding:
        var(--container-padding)
        var(--container-padding)
        var(--container-bottom-padding);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    transform: translate(-50%, -50%);
    border-radius: 32px;
    background: rgba(10, 0, 25, 0.22);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 22px 70px rgba(10, 0, 30, 0.28);
}

.message {
    position: absolute;
    top: 50%;
    left: 50%;
    width: calc(100% - (2 * var(--container-padding)));
    opacity: 0;
    font-size: var(--message-size);
    line-height: 1.25;
    text-align: center;
    text-shadow: 0 0 15px rgba(255, 50, 150, 0.5);
    transform: translate(-50%, -50%) translateY(50px);
    transition: all 1.5s ease-in-out;
    will-change: transform, opacity;
}

.message.active {
    opacity: 1;
    transform: translate(-50%, -50%);
}

.message.exit {
    opacity: 0;
    transform: translate(-50%, calc(-50% - 50px)) scale(0.8);
}

.final-question {
    display: none;
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 640px;
    margin-inline: auto;
    opacity: 0;
    transform: scale(0.5);
    animation: reveal 1s forwards;
    text-align: center;
}

.final-question h2 {
    font-size: var(--question-size);
    line-height: 1.2;
    text-align: center;
    text-shadow: 0 0 18px rgba(255, 64, 129, 0.35);
}

.final-question p {
    margin-top: 1rem;
    font-size: clamp(1rem, 2.8vw, 1.2rem);
    line-height: 1.6;
    text-align: center;
}

.success-badges {
    margin-top: 2rem;
    font-size: clamp(2rem, 6vw, 3rem);
}

@keyframes reveal {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}

.valentine-btn {
    min-width: 220px;
    min-height: 56px;
    padding: 1rem 1.6rem;
    font-family: inherit;
    font-size: clamp(1rem, 3vw, 1.35rem);
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.yes-btn {
    background: #ff4081;
    color: #fff;
}

.no-btn {
    background: #616161;
    color: #fff;
}

.valentine-btn:hover,
.valentine-btn:focus-visible {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(255, 64, 129, 0.4);
    outline: none;
}

.valentine-btn:active {
    transform: translateY(0) scale(0.98);
}

.celebration {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
    display: none;
}

.music-toggle {
    position: fixed;
    top: max(0.9rem, env(safe-area-inset-top));
    right: max(0.9rem, env(safe-area-inset-right));
    z-index: 25;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.music-toggle:hover,
.music-toggle:focus-visible {
    background: rgba(255, 64, 129, 0.24);
    transform: translateY(-2px);
    outline: none;
}

.music-toggle__icon {
    font-size: 1.35rem;
    line-height: 1;
}

.music-toggle.is-muted {
    opacity: 0.72;
}

.music-toggle.is-muted::after {
    content: "";
    position: absolute;
    width: 26px;
    height: 2px;
    border-radius: 999px;
    background: #fff;
    transform: rotate(-45deg);
}

.scene-media {
    position: absolute;
    left: 50%;
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 3;
    width: min(72%, 280px);
    transform: translateX(-50%);
    pointer-events: none;
}

.scene-gif {
    display: block;
    width: 100%;
    height: clamp(88px, 20vw, 160px);
    object-fit: contain;
    opacity: 1;
    transform: translateY(0) scale(1);
    transition:
        opacity 0.28s ease,
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.45s ease;
    filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.22));
}

.scene-gif.is-switching-out {
    opacity: 0;
    transform: translateY(18px) scale(0.92);
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.16)) blur(1px);
}

.scene-gif.is-switching-in {
    opacity: 0;
    transform: translateY(-14px) scale(1.08);
}

.heart-burst {
    position: absolute;
    font-size: 2rem;
    animation: burst 1s ease-out forwards;
    will-change: transform;
}

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

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

@media (max-width: 768px) {
    .message-container {
        min-height: min(76vh, 520px);
        border-radius: 26px;
    }

    .scene-media {
        width: min(78%, 250px);
    }

    .valentine-btn {
        min-width: min(260px, 100%);
    }
}

@media (max-width: 540px) {
    .message-container {
        width: min(100%, 30rem);
        min-height: min(82vh, 560px);
        padding: 1.25rem 1rem clamp(8.75rem, 34vw, 11rem);
        border-radius: 22px;
    }

    .message {
        width: calc(100% - 2rem);
        font-size: clamp(1.65rem, 8vw, 2.3rem);
    }

    .final-question {
        padding-top: 0.25rem;
    }

    .btn-group {
        flex-direction: column;
        gap: 0.75rem;
    }

    .valentine-btn {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 52px;
        padding: 0.95rem 1.1rem;
        font-size: 1rem;
    }

    .love-particle {
        font-size: 20px;
    }

    .scene-media {
        width: min(86%, 230px);
        bottom: max(0.65rem, env(safe-area-inset-bottom));
    }

    .scene-gif {
        height: clamp(84px, 28vw, 132px);
    }

    .music-toggle {
        width: 44px;
        height: 44px;
        top: max(0.75rem, env(safe-area-inset-top));
        right: max(0.75rem, env(safe-area-inset-right));
    }

    .heart-burst {
        font-size: 1.5rem;
    }
}

@media (max-width: 380px) {
    .message-container {
        min-height: min(84vh, 580px);
        padding: 1rem 0.85rem clamp(8rem, 36vw, 10rem);
    }

    .message {
        width: calc(100% - 1.7rem);
        font-size: clamp(1.45rem, 8.5vw, 1.95rem);
    }

    .final-question h2 {
        font-size: clamp(1.7rem, 9vw, 2.2rem);
    }

    .final-question p {
        font-size: 0.95rem;
    }
}
