/* Color Variables - Pastel Pink Theme */
:root {
    --soft-green: #9DB4A0;
    --brown: #A08679;
    --tan: #E8D4D4;
    --denim-blue: #8BA4B4;
    --cream: #FFF0F3;
    --dark-cream: #FFE4E9;
    --outline: #5D4954;
    --pink: #E8A4B8;
    --light-pink: #FFD1DC;
    --orange: #E89A8A;
    --pastel-pink: #F5C6D6;
    --deep-pink: #D4869A;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--cream);
    min-height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    background-image:
        radial-gradient(circle at 20% 80%, var(--dark-cream) 1px, transparent 1px),
        radial-gradient(circle at 80% 20%, var(--dark-cream) 1px, transparent 1px),
        radial-gradient(circle at 40% 40%, var(--dark-cream) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* Game Container */
.game-container {
    max-width: 900px;
    width: 100%;
    position: relative;
}

/* Stage Styles */
.stage {
    display: none;
    animation: fadeIn 0.5s ease-out;
}

.stage.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.stage-content {
    background-color: var(--cream);
    border: 3px solid var(--outline);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 6px 6px 0 var(--outline);
}

.stage-content.centered {
    text-align: center;
}

/* Image Container */
.image-container {
    text-align: center;
    margin-bottom: 10px;
}

.nn-image {
    max-width: 180px;
    width: 100%;
    border: 3px solid var(--outline);
    border-radius: 15px;
    box-shadow: 4px 4px 0 var(--outline);
}

.image-caption {
    margin-top: 5px;
    color: var(--brown);
    font-size: 0.95em;
    font-weight: 600;
}

/* Game Area */
.game-area {
    margin-top: 10px;
}

.game-header {
    text-align: center;
    margin-bottom: 8px;
}

.game-header h2 {
    color: var(--deep-pink);
    font-size: 1.6em;
    text-shadow: 2px 2px 0 var(--outline);
    -webkit-text-stroke: 1px var(--outline);
}

.instructions {
    color: var(--brown);
    margin-top: 3px;
    font-size: 0.9em;
}

/* Timer */
.timer-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background-color: var(--tan);
    padding: 5px 15px;
    border: 3px solid var(--outline);
    border-radius: 10px;
    margin-top: 5px;
}

.timer-label {
    font-weight: 600;
    color: var(--outline);
}

.timer {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--deep-pink);
    min-width: 40px;
}

.timer.warning {
    color: var(--orange);
    animation: pulse 0.5s ease-in-out infinite;
}

.timer.danger {
    color: #C44536;
    animation: pulse 0.3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Game Canvas */
#gameCanvas {
    display: block;
    margin: 0 auto;
    border: 3px solid var(--outline);
    border-radius: 10px;
    background-color: var(--dark-cream);
    box-shadow: 4px 4px 0 var(--outline);
}

.controls-hint {
    text-align: center;
    margin-top: 5px;
    color: var(--denim-blue);
    font-size: 0.85em;
}

/* Overlay Screens */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(45, 45, 45, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.active {
    display: flex;
}

.overlay-content {
    background-color: var(--cream);
    border: 3px solid var(--outline);
    border-radius: 20px;
    padding: 40px 60px;
    text-align: center;
    box-shadow: 8px 8px 0 var(--outline);
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.overlay-content h2 {
    color: var(--orange);
    font-size: 2.5em;
    margin-bottom: 10px;
}

.overlay-content p {
    color: var(--brown);
    font-size: 1.2em;
    margin-bottom: 10px;
}

.small-text {
    font-size: 1em !important;
    color: var(--denim-blue) !important;
}

/* Buttons */
.game-btn {
    font-family: inherit;
    font-size: 1.2em;
    font-weight: 600;
    padding: 12px 30px;
    border: 3px solid var(--outline);
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
    box-shadow: 4px 4px 0 var(--outline);
    margin-top: 20px;
}

.game-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--outline);
}

.game-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--outline);
}

#retryBtn {
    background-color: var(--deep-pink);
    color: white;
}

.reset-btn {
    background-color: var(--denim-blue);
    color: white;
    margin-top: 15px;
    font-size: 1em;
    padding: 10px 25px;
}

/* Stage 2 Styles */
.message-container {
    margin-top: 30px;
}

.freed-message {
    color: var(--deep-pink);
    font-size: 2.5em;
    animation: bounce 0.6s ease-out;
}

@keyframes bounce {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

.package-question {
    color: var(--brown);
    font-size: 1.3em;
    margin-top: 20px;
    min-height: 1.5em;
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 30px;
    opacity: 0;
    transition: opacity 0.5s;
    /* Fixed height prevents layout shift when buttons change to position: fixed */
    height: 80px;
    align-items: flex-start;
}

.button-container.visible {
    opacity: 1;
}

/* Remove margin-top from buttons in this container to prevent layout shift */
.button-container .game-btn {
    margin-top: 0;
}

.yes-btn {
    background-color: var(--pink);
    color: white;
}

.no-btn {
    background-color: var(--pastel-pink);
    color: var(--outline);
    position: relative;
    transition: left 0.3s ease-out, top 0.3s ease-out, transform 0.1s, box-shadow 0.1s;
}

/* Placeholder to maintain layout when No button escapes */
.no-btn-placeholder {
    width: 100px;
    height: 1px;
    visibility: hidden;
}

/* Love Note Styles */
.love-note-content {
    animation: fadeIn 0.5s ease-out;
}

.envelope {
    position: relative;
    width: 350px;
    height: 250px;
}

.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    border-left: 175px solid transparent;
    border-right: 175px solid transparent;
    border-top: 100px solid var(--tan);
    z-index: 1;
    animation: openFlap 0.8s ease-out forwards;
    transform-origin: top center;
}

@keyframes openFlap {
    from { transform: rotateX(0deg); }
    to { transform: rotateX(180deg); }
}

.letter {
    position: absolute;
    top: 20px;
    left: 25px;
    width: 300px;
    background-color: var(--cream);
    border: 3px solid var(--outline);
    border-radius: 10px;
    padding: 30px;
    box-shadow: 4px 4px 0 var(--outline);
    animation: riseLetter 0.8s ease-out 0.3s forwards;
    opacity: 0;
    transform: translateY(50px);
}

@keyframes riseLetter {
    to {
        opacity: 1;
        transform: translateY(-30px);
    }
}

.letter-content {
    text-align: center;
}

.hearts {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.bottom-hearts {
    margin-top: 15px;
    margin-bottom: 0;
}

.heart {
    color: var(--pink);
    font-size: 1.5em;
    animation: floatHeart 2s ease-in-out infinite;
}

.heart:nth-child(2) {
    animation-delay: 0.3s;
}

.heart:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes floatHeart {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.love-message {
    color: var(--brown);
    font-size: 1.5em;
    font-weight: 600;
    line-height: 1.4;
}

.signature {
    color: var(--denim-blue);
    font-size: 1.3em;
    font-style: italic;
    margin-top: 15px;
}

/* Responsive Adjustments */
@media (max-width: 700px) {
    .stage-content {
        padding: 20px;
    }

    #gameCanvas {
        width: 100%;
        height: auto;
        max-width: 400px;
    }

    .nn-image {
        max-width: 200px;
    }

    .freed-message {
        font-size: 2em;
    }

    .envelope {
        width: 280px;
        height: 200px;
    }

    .envelope-flap {
        border-left: 140px solid transparent;
        border-right: 140px solid transparent;
        border-top: 80px solid var(--tan);
    }

    .letter {
        width: 240px;
        left: 20px;
        padding: 20px;
    }
}
