:root {
    --bg-color: #000;
    --pixel-font: 'Press Start 2P', cursive;
    --snes-blue: #2a2a72;
    --snes-gold: #ffcc00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    image-rendering: pixelated;
    /* Crisp pixel art */
}

body {
    background-color: var(--bg-color);
    color: white;
    font-family: var(--pixel-font);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 640px;
    height: 480px;
    background: #111;
    border: 4px solid #333;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

#game-canvas {
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px;
}

#dialogue-box {
    width: 90%;
    margin: 0 auto;
    height: 120px;
    background: rgba(10, 10, 30, 0.92);
    border: 3px solid var(--snes-gold);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.5);
    position: relative;
    padding: 20px 30px;
    color: #fff;
    font-size: 10px;
    line-height: 1.8;
    pointer-events: auto;
    overflow: hidden;
    text-shadow: 0 0 4px rgba(255, 204, 0, 0.4);
    transition: opacity 0.3s ease;
}

.dialogue-content {
    max-height: 80px;
    overflow-y: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#dialogue-box.hidden {
    display: none;
}

.next-indicator {
    position: absolute;
    bottom: 10px;
    right: 20px;
    animation: bounce 0.6s infinite alternate;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }

    to {
        transform: translateY(5px);
    }
}

/* CRT Effect */
.crt-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.1) 50%), linear-gradient(90deg,
            rgba(255, 0, 0, 0.03),
            rgba(0, 255, 0, 0.01),
            rgba(0, 0, 255, 0.03));
    background-size: 100% 3px, 3px 100%;
    pointer-events: none;
    z-index: 10;
}

.crt-overlay::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 10;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

@keyframes flicker {
    0% {
        opacity: 0.27861;
    }

    5% {
        opacity: 0.34769;
    }

    10% {
        opacity: 0.23604;
    }

    /* ... shortened flicker ... */
    100% {
        opacity: 0.24387;
    }
}

@media (max-width: 640px) {
    #game-container {
        width: 100vw;
        height: 75vw;
    }
}