:root {
    --bg-color: #2c3e50;
    /* Dark Blue Gray */
    /* Soft Pink */
    --box-bg: #dcdcdc;
    /* Slightly darker gray box */
    /* Gray for Retro look */
    --box-border: #4a4a4a;
    --text-color: #2c2c2c;
    --accent-color: #ff6b81;
    --pixel-font: 'NeoDunggeunmo Pro', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--pixel-font);
}

body {
    background-color: #222;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* CRT Scanline Effect */
.scanline {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0) 50%,
            rgba(0, 0, 0, 0.1) 50%,
            rgba(0, 0, 0, 0.1));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 100;
}

.game-screen {
    width: 100%;
    max-width: 600px;
    /* Tablet size max */
    height: 100%;
    background: var(--bg-color);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Scene Area (Upper part) */
.scene-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    /* Dark Night Gradient */
    background: linear-gradient(to bottom, #0f2027 0%, #203a43 50%, #2c5364 100%);
}

/* Pixel Art Elements CSS-only */
.pixel-moon {
    position: absolute;
    top: 30px;
    right: 30px;
    width: 30px;
    height: 30px;
    background: transparent;
    border-radius: 50%;
    box-shadow: -8px 8px 0 0 #f6f6f6;
    /* Crescent Moon shape */
    animation: glow 3s infinite alternate;
}

@keyframes glow {
    from {
        filter: drop-shadow(0 0 2px #fff);
    }

    to {
        filter: drop-shadow(0 0 8px #fff);
    }
}

.pixel-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    box-shadow: 0 0 4px #fff;
    animation: twinkle 2s infinite ease-in-out;
}

.s1 {
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.s2 {
    top: 20%;
    left: 80%;
    animation-delay: 1s;
}

.s3 {
    top: 40%;
    left: 20%;
    animation-delay: 0.5s;
}

.s4 {
    top: 15%;
    left: 50%;
    animation-delay: 1.5s;
}

.s5 {
    top: 30%;
    left: 90%;
    animation-delay: 0.2s;
}

@keyframes twinkle {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
        transform: scale(1.5);
    }
}

/* Remove clouds or make them dark */
.pixel-cloud {
    background: #3c3c3c;
    opacity: 0.3;
}

.character-sprite {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    /* Increased size slightly */
    height: 140px;
    /* Square for profile pic */
    background: transparent;
    border: 4px solid #000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Crop if needed */
    background: #fff;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
}

.pixel-profile {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill the box */
    image-rendering: pixelated;
    /* Retain pixel look */
}

/* Sleep Button Removed (Auto Mode) */

/* Reset Button */
.reset-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.2rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid #fff;
    border-radius: 4px;
    cursor: pointer;
    z-index: 10;
    color: white;
    padding: 5px;
    transition: background 0.2s;
}

.reset-toggle:hover {
    background: rgba(255, 0, 0, 0.5);
    /* Red hint on hover */
}

/* Sleep Button */
.sleep-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10;
    filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.3));
    transition: transform 0.2s;
}

.sleep-toggle:hover {
    transform: scale(1.1);
}

/* Sleep Overlay */
#sleep-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    transition: opacity 1s;
}

#sleep-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.zzz-container {
    display: flex;
    gap: 5px;
}

.z {
    font-size: 2rem;
    animation: zFloat 2s infinite ease-in-out;
}

.z:nth-child(2) {
    animation-delay: 0.5s;
    font-size: 1.5rem;
}

.z:nth-child(3) {
    animation-delay: 1s;
    font-size: 1rem;
}

@keyframes zFloat {
    0% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: translateY(-20px) translateX(10px);
        opacity: 0;
    }
}

.sleep-text {
    margin-top: 20px;
    font-size: 0.9rem;
    opacity: 0.7;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 0.9;
    }
}


/* Dialogue Box (Lower part) */
.dialogue-box {
    height: 40%;
    /* 40% of screen */
    background: var(--box-bg);
    border-top: 4px solid var(--box-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.name-tag {
    position: absolute;
    top: -20px;
    left: 20px;
    background: #000;
    /* Black for Dark Theme */
    color: white;
    padding: 8px 16px;
    border: 2px solid var(--box-border);
    font-size: 1.1rem;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
}

.message-container {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
    margin-bottom: 10px;
    padding-right: 5px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Scrollbar styling */
.message-container::-webkit-scrollbar {
    width: 8px;
}

.message-container::-webkit-scrollbar-track {
    background: #eee;
}

.message-container::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border: 2px solid #fff;
}

.message {
    font-size: 1.1rem;
    line-height: 1.5;
    word-break: keep-all;
}

.message.user {
    color: #666;
    text-align: right;
    font-size: 0.9rem;
}

.message.ai {
    color: var(--text-color);
}

.typewriter-text {
    /* Animation handling in JS to prevent text jumping */
}

/* Input Area */
.input-area {
    display: flex;
    align-items: center;
    border-top: 2px dashed #ccc;
    padding-top: 10px;
    gap: 10px;
}

.prompt-cursor {
    font-weight: bold;
    color: var(--accent-color);
    animation: blink 1s infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 1rem;
    color: #333;
    outline: none;
    font-family: var(--pixel-font);
}

.pixel-btn {
    background: var(--box-border);
    color: white;
    border: none;
    padding: 8px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 2px 2px 0 #999;
}

.pixel-btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

/* Status HUD */
.status-hud {
    position: absolute;
    top: auto;
    /* Reset top */
    bottom: 30px;
    /* Align near bottom */
    left: 50%;
    /* Center reference */
    transform: translateX(80px);
    /* Move to right of character (70px + 10px) */
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(2px);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.5);
    /* Pixel shadow */
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-text {
    font-size: 0.9rem;
    width: 35px;
    text-align: right;
    text-shadow: 1px 1px 0 #000;
    margin-right: 4px;
}

.stat-text.love {
    color: #ff6b81;
}

.stat-text.lust {
    color: #ffa502;
}

.stat-text.depr {
    color: #1e90ff;
}



.stat-track {
    width: 80px;
    height: 10px;
    background: #333;
    border: 1px solid #fff;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.stat-fill {
    height: 100%;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-fill.love {
    background: linear-gradient(to right, #ff6b81, #ff4757);
}

.stat-fill.lust {
    background: linear-gradient(to right, #ffa502, #ff7f50);
}

.stat-fill.depr {
    background: linear-gradient(to right, #1e90ff, #3742fa);
}