/* style-room.css */
body {
    margin: 0;
    padding: 0;
    background-color: #222;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    font-family: monospace;
    color: white;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

canvas {
    display: block;
    image-rendering: pixelated;
}

/* --- DEBUG OVERLAY (Glass Style) --- */
#debug-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    border-radius: 99px;
    /* Pill shape */

    /* The Glass Effect */
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.01) 100%);
    backdrop-filter: blur(10px) saturate(100%);
    -webkit-backdrop-filter: blur(10px) saturate(100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);

    /* Text Styling */
    pointer-events: none;
    user-select: none;
    font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
    /* Clean UI font */
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);

    z-index: 10;
    text-align: center;
    white-space: nowrap;
    display: block;
}

#back-btn {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top));
    left: 12px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.12) 0%,
            rgba(255, 255, 255, 0.01) 40%,
            rgba(255, 255, 255, 0.0) 100%);
    backdrop-filter: blur(3px) saturate(100%);
    -webkit-backdrop-filter: blur(3px) saturate(100%);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 0 1px 1px rgba(255, 255, 255, 0.05);
    color: white;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

#back-btn:hover {
    transform: scale(1.05);
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.18) 0%,
            rgba(255, 255, 255, 0.05) 40%,
            rgba(255, 255, 255, 0.0) 100%);
}

#back-btn:active {
    transform: scale(0.98);
}

#tv-gif {
    position: absolute;
    display: none;
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 0 20px 5px rgba(0, 255, 255, 0.4);
    animation: tv-glow 2s infinite linear;
}

@keyframes tv-glow {
    50% {
        box-shadow: 0 0 20px 5px rgba(0, 255, 255, 0.4);
    }

    40% {
        box-shadow: 0 0 30px 10px rgba(0, 255, 255, 0.6);
    }

    40% {
        box-shadow: 0 0 15px 3px rgba(0, 255, 255, 0.2);
    }

    30% {
        box-shadow: 0 0 35px 12px rgba(0, 255, 255, 0.7);
    }

    40% {
        box-shadow: 0 0 25px 8px rgba(0, 255, 255, 0.5);
    }

    50% {
        box-shadow: 0 0 10px 2px rgba(0, 255, 255, 0.2);
    }

    60% {
        box-shadow: 0 0 40px 15px rgba(0, 255, 255, 0.8);
    }

    70% {
        box-shadow: 0 0 20px 6px rgba(0, 255, 255, 0.4);
    }

    75% {
        box-shadow: 0 0 30px 10px rgba(0, 255, 255, 0.6);
    }

    60% {
        box-shadow: 0 0 15px 4px rgba(0, 255, 255, 0.3);
    }

    50% {
        box-shadow: 0 0 20px 5px rgba(0, 255, 255, 0.4);
    }
}

.liquid-slider-wrapper {
    position: absolute;
    width: 520px;
    height: 300px;
    display: none;
    z-index: 20;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

input[type=range].liquid-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 300px;
    height: 16px;
    transform: rotate(-90deg);
    transform-origin: center center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    outline: none;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

input[type=range].liquid-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #00ffff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.8), 0 0 20px rgba(0, 255, 255, 0.4);
    transition: transform 0.1s;
}

input[type=range].liquid-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 255, 255, 1), 0 0 25px rgba(0, 255, 255, 0.6);
}

/* Full-screen viewport that CLIPS the zoomed content */
#terminal-viewport {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: none;
    /* JS toggles this */
    overflow: hidden;
    /* clips panning */
    touch-action: none;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}


#terminal-zoom-container {
    position: absolute;
    inset: 0;
    will-change: transform;
    transform-origin: 0 0;
    /* crucial for the math */
    transition: transform 0.15s ease-out;
}



#terminal-zoom-container,
#terminal-screen {
    overscroll-behavior: none;
}


#terminal-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    pointer-events: none;
}

#terminal-screen {
    position: absolute;
    left: 81px;
    top: 976px;
    width: 950px;
    height: 564px;
    overflow: hidden;
    pointer-events: auto;
    box-shadow:
        inset 0 0 60px rgba(89, 167, 188, 0.15),
        inset 0 0 30px rgba(89, 167, 188, 0.2),
        0 0 20px rgba(89, 167, 188, 0.3);
}

#terminal-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    background: #59A7BC;
    mix-blend-mode: color;
    opacity: 0.6;
    pointer-events: none;
    z-index: 3;
}

#terminal-screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg,
            rgba(0, 0, 0, 0.15) 0px,
            rgba(0, 0, 0, 0.15) 1px,
            transparent 1px,
            transparent 2px);
    pointer-events: none;
    z-index: 4;
    animation: scanline-flicker 0.1s infinite;
}

@keyframes scanline-flicker {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.95;
    }
}

#terminal-image {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: 95%;
    max-height: 90%;
    object-fit: contain;
    filter: brightness(1.1) contrast(1.05);
    z-index: 2;
}

.terminal-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center,
            transparent 0%,
            transparent 60%,
            rgba(0, 0, 0, 0.3) 80%,
            rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
    z-index: 5;
}

.terminal-nav {
    position: absolute;
    bottom: 20px;
    padding: 8px 20px;
    background: rgba(89, 167, 188, 0.3);
    border: 2px solid rgba(89, 167, 188, 0.6);
    border-radius: 4px;
    color: #59A7BC;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    z-index: 6;
    transition: all 0.15s ease;
    text-shadow: 0 0 5px rgba(89, 167, 188, 0.8);
    box-shadow: 0 0 10px rgba(89, 167, 188, 0.4);
    touch-action: manipulation;
}

.terminal-nav:hover {
    background: rgba(89, 167, 188, 0.5);
    border-color: rgba(89, 167, 188, 1);
    box-shadow: 0 0 15px rgba(89, 167, 188, 0.8);
    transform: scale(1.05);
}

.terminal-nav:active {
    transform: scale(0.98);
}

#terminal-prev {
    left: 30px;
}

#terminal-next {
    right: 30px;
}

#terminal-counter {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #59A7BC;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(89, 167, 188, 0.9);
    z-index: 6;
}

#mobile-controls {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 100 !important;
}

.glass-control {
    pointer-events: auto;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.12) 0%,
            rgba(255, 255, 255, 0.01) 40%,
            rgba(255, 255, 255, 0.0) 100%);
    border: 0.5px solid rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(3px) saturate(100%);
    -webkit-backdrop-filter: blur(3px) saturate(100%);
    box-shadow:
        0 4px 15px rgba(0, 0, 0, 0.4),
        inset 0 0 1px 1px rgba(255, 255, 255, 0.05);
}

#joystick-wrapper {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
}

#joystick-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#joystick-inner {
    position: absolute;
    width: 50px;
    height: 50px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transition: transform 0.05s ease-out;
    touch-action: none;
}

#interact-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#interact-btn:active {
    transform: scale(0.92);
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.2) 0%,
            rgba(255, 255, 255, 0.05) 40%,
            rgba(255, 255, 255, 0.0) 100%);
}

@media (max-width: 768px) {
    .terminal-nav {
        padding: 6px 12px;
        font-size: 14px;
        bottom: 15px;
        box-shadow: 0 0 5px rgba(89, 167, 188, 0.4);
    }

    #terminal-prev {
        left: 15px;
    }

    #terminal-next {
        right: 15px;
    }
}

#terminal-image {
    transform-origin: center center;
    will-change: transform;
}

/* --- Remote Player Snoring --- */
.snore-container {
    position: absolute;
    z-index: 20;
    /* Above players */
    pointer-events: none;
    /* Initial pos doesn't matter, set by JS */
}

.z {
    position: absolute;
    font-family: 'VT323', monospace;
    font-size: 60px;
    /* Increased from 25px */
    color: #c1c1c1;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.5);
    /* Thicker shadow for readability */
    font-weight: bold;
    opacity: 0;
    animation: snore 4s infinite linear;
    white-space: nowrap;
    /* Prevents wrapping */
}

.z:nth-child(2) {
    animation-delay: 1.3s;
}

.z:nth-child(3) {
    animation-delay: 2.6s;
}

@keyframes snore {
    0% {
        transform: translate(0, 0) scale(0.5);
        opacity: 0;
    }

    20% {
        opacity: 1;
    }

    100% {
        transform: translate(15px, -40px) scale(1.5);
        opacity: 0;
    }
}