* {
    box-sizing: border-box;
}

body {
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(145deg, #080808, #141414, #0c0c0c);
    font-family: "Pixelify Sans", sans-serif;
    color: #d0d0d0;
    overflow: hidden;
}

/* ═══════════════ Envelope Screen ═══════════════ */

#envelope-container {
    text-align: center;
    cursor: pointer;
}

#envelope-container p {
    color: #999;
    font-size: 32px;
    text-shadow: 0 0 12px rgba(180, 180, 180, 0.15);
}

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

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

#envelope {
    width: 200px;
    animation: pulse 1.5s infinite;
    cursor: pointer;
    filter: brightness(0.8) contrast(1.1) saturate(0.6);
}

/* ═══════════════ Letter Screen ═══════════════ */

#letter-container {
    display: none;
    position: fixed;
    inset: 0;
    justify-content: center;
    align-items: center;
}

.letter-window {
    width: 90vw;
    max-width: 560px;
    display: flex;
    justify-content: center;
    align-items: center;

    transform: scale(1.2);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

.letter-window.open {
    transform: scale(1);
    opacity: 1;
}

/* ═══════════════ Pixel Window Frame ═══════════════ */

.pixel-window {
    width: 100%;
    border: 4px solid #444;
    border-radius: 4px;
    background: #1a1a1a;
    box-shadow:
        inset 0 0 0 2px #2a2a2a,
        0 8px 40px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    image-rendering: pixelated;
}

/* ── Title Bar ── */

.win-titlebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: linear-gradient(180deg, #2a2a2a, #1e1e1e);
    border-bottom: 3px solid #444;
}

.win-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 6px;
    color: #c0c0c0;
    text-shadow: 2px 2px 0 #000;
}

.win-controls {
    display: flex;
    gap: 6px;
}

.win-ctrl {
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    color: #888;
    background: #333;
    border: 2px solid #555;
    border-radius: 2px;
    line-height: 1;
}

.win-ctrl.close {
    color: #aa4444;
    border-color: #664444;
}

/* ── Hearts Health Bar ── */

.hearts-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 18px 12px;
    background: #1c1c1c;
    border-bottom: 3px solid #333;
}

.pixel-heart {
    display: inline-block;
    position: relative;
    width: 56px;
    /* 7 cols × 8px */
    height: 48px;
    /* 6 rows × 8px */
    font-size: 0;
    /* hide the ♥ text */
    color: transparent;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.pixel-heart::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    background: #cc3344;
    box-shadow:
        /* Row 0 */
        8px 0 #cc3344, 16px 0 #cc3344, 32px 0 #cc3344, 40px 0 #cc3344,
        /* Row 1 */
        0 8px #cc3344, 8px 8px #ee4455, 16px 8px #ee4455, 24px 8px #cc3344, 32px 8px #ee4455, 40px 8px #ee4455, 48px 8px #cc3344,
        /* Row 2 */
        0 16px #cc3344, 8px 16px #dd3344, 16px 16px #dd3344, 24px 16px #cc3344, 32px 16px #dd3344, 40px 16px #dd3344, 48px 16px #cc3344,
        /* Row 3 */
        8px 24px #bb2233, 16px 24px #cc3344, 24px 24px #cc3344, 32px 24px #cc3344, 40px 24px #bb2233,
        /* Row 4 */
        16px 32px #aa2233, 24px 32px #bb2233, 32px 32px #aa2233,
        /* Row 5 */
        24px 40px #992233;
    image-rendering: pixelated;
}

.pixel-heart.lost {
    transform: scale(0.5);
    opacity: 0.15;
}

.pixel-heart.lost::before {
    background: #333;
    box-shadow:
        /* Row 0 */
        8px 0 #333, 16px 0 #333, 32px 0 #333, 40px 0 #333,
        /* Row 1 */
        0 8px #3a3a3a, 8px 8px #3a3a3a, 16px 8px #3a3a3a, 24px 8px #333, 32px 8px #3a3a3a, 40px 8px #3a3a3a, 48px 8px #333,
        /* Row 2 */
        0 16px #333, 8px 16px #333, 16px 16px #333, 24px 16px #333, 32px 16px #333, 40px 16px #333, 48px 16px #333,
        /* Row 3 */
        8px 24px #2a2a2a, 16px 24px #333, 24px 24px #333, 32px 24px #333, 40px 24px #2a2a2a,
        /* Row 4 */
        16px 32px #2a2a2a, 24px 32px #2a2a2a, 32px 32px #2a2a2a,
        /* Row 5 */
        24px 40px #222;
}

/* Exploding animation */
@keyframes heart-explode {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    10% {
        transform: scale(1.5);
        filter: brightness(2.5);
    }

    25% {
        transform: scale(1.6) rotate(-5deg);
        filter: brightness(2);
    }

    45% {
        transform: scale(0.8) rotate(8deg);
        filter: brightness(1);
        opacity: 0.6;
    }

    70% {
        transform: scale(0.3) rotate(-3deg);
        opacity: 0.2;
    }

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

.pixel-heart.exploding {
    animation: heart-explode 0.7s ease forwards;
}

.heart-dot {
    font-size: 28px;
    color: #555;
}

/* ── Heart Particles ── */

.heart-particle {
    position: absolute;
    border-radius: 50%;
    background: #cc3344;
    pointer-events: none;
    z-index: 50;
    animation: particle-fly 0.9s ease-out forwards;
}

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

    60% {
        opacity: 0.8;
    }

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

/* ── Content Area ── */

.win-content {
    padding: 24px 20px 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 320px;

    /* Dark subtle checkered pattern */
    background-color: #181818;
    background-image:
        linear-gradient(45deg, #1e1e1e 25%, transparent 25%),
        linear-gradient(-45deg, #1e1e1e 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1e1e1e 75%),
        linear-gradient(-45deg, transparent 75%, #1e1e1e 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

/* ── Shake ── */

@keyframes shake {

    0%,
    100% {
        transform: scale(1) translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: scale(1) translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: scale(1) translateX(5px);
    }
}

.letter-window.open.shake {
    animation: shake 0.45s ease;
}

/* ═══════════════ Content Elements ═══════════════ */

h1 {
    font-size: 26px;
    margin: 0 0 8px 0;
    color: #d0d0d0;
}

p {
    font-size: 36px;
    color: #aaa;
}

.cat {
    width: 200px;
    margin: 10px 0;
    transition: width 0.4s ease;
}

.letter-window.final .cat {
    width: 160px;
}

/* Buttons */
.buttons {
    display: flex;
    justify-content: center;
    gap: 24px;
    position: relative;
    margin-top: 8px;
}

.no-wrapper {
    position: relative;
}

.btn {
    width: 110px;
    cursor: pointer;
    user-select: none;
}

.yes-btn,
.no-btn {
    width: 110px;
    height: auto;
    display: inline-block;
}

.yes-btn {
    position: relative;
    z-index: 2;
    transform-origin: center center;
    transition: transform 0.3s ease;
}

.yes-btn:hover {
    transform: scale(1.1);
}

.no-btn {
    z-index: 1;
    position: relative;
    cursor: pointer;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.final-text {
    font-size: 20px;
    line-height: 1.5;
    text-align: center;
    display: inline-block;
    padding: 12px 20px;
    background-color: rgba(40, 40, 40, 0.7);
    border-radius: 8px;
    color: #ccc;
    border: 1px solid rgba(80, 80, 80, 0.4);
}