:root {
    --zx-black: #000000;
    --zx-blue: #0000D7;
    --ind-grey: #333333;
    
    --hw-bg: #0b0c0d;
    --panel-bg: #111;
    --neon-green: #39ff14;
    --neon-red: #ff003c;
    --neon-amber: #ffaa00;
    --neon-cyan: #00f2ff;
    --border-color: #333;
    
    --font-main: 'VT323', monospace;
    --font-header: 'Press Start 2P', cursive;
    --font-files: 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-text-size-adjust: none; }

html { font-size: 16px; }

body, html {
    width: 100%; height: 100%;
    background-color: #000;
    font-family: var(--font-main);
    overflow: hidden;
    image-rendering: pixelated;
}

/* --- LOADING SCREEN --- */
#loading-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.spectrum-border-sim { position: absolute; top: -10%; left: 0; width: 100%; height: 120%; background: repeating-linear-gradient(0deg, #D7D700, #D7D700 1.5rem, #0000D7 1.5rem, #0000D7 3rem); animation: chaoticTapeLoad 0.04s steps(4) infinite; z-index: 1; }
@keyframes chaoticTapeLoad { 0% { transform: translateY(-2rem); } 100% { transform: translateY(0); } }
.spectrum-center-screen { position: relative; width: 80vw; height: 56vh; background: #fff; z-index: 2; padding: 1.5rem; display: flex; align-items: center; justify-content: center;}
#loading-text-new { font-family: var(--font-header); font-size: 1.2rem; color: #000; }

/* --- FULLSCREEN CAM --- */
#fullscreen-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 99999; display: none; align-items: center; justify-content: center; cursor: zoom-out; }
#fullscreen-img { max-width: 95%; max-height: 95%; border: 2px solid var(--neon-green); box-shadow: 0 0 30px var(--neon-green); }

/* --- HERNÍ HEADER --- */
header { 
    position: absolute; top: 0; left: 0; width: 100%; height: 28vh; 
    background: #000; z-index: 100; overflow: hidden;
    border-bottom: 4px solid var(--ind-grey);
}
canvas#arcadeCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }
.header-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; z-index: 20; pointer-events: none; }
h1#main-title { 
    font-family: var(--font-header); font-size: clamp(1rem, 5vw, 2.5rem); color: #fff; 
    text-shadow: 4px 4px 0 var(--zx-blue); margin-bottom: 3rem; 
}
.char { display: inline-block; position: relative; }
.falling-char, .debris, .score-popup { position: absolute; pointer-events: none; font-family: var(--font-header); z-index: 200; }
.debris { width: 2px; height: 2px; z-index: 205; }
.score-popup { font-size: 10px; color: #ff0; animation: scoreFloat 1s forwards; z-index: 500; }
@keyframes scoreFloat { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(-30px); } }

/* --- MAIN DESIGN (3+1 Grid) --- */
main {
    position: absolute; top: 28vh; left: 0; width: 100%; height: 72vh;
    overflow-y: auto; padding: 20px;
    background-color: var(--hw-bg);
    background-image: 
        linear-gradient(rgba(57, 255, 20, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(57, 255, 20, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex; flex-wrap: wrap; gap: 15px;
    justify-content: flex-start; align-content: flex-start;
}

main::-webkit-scrollbar, .scroll-box::-webkit-scrollbar, .terminal-box::-webkit-scrollbar { width: 8px; }
main::-webkit-scrollbar-track, .scroll-box::-webkit-scrollbar-track, .terminal-box::-webkit-scrollbar-track { background: #000; }
main::-webkit-scrollbar-thumb, .scroll-box::-webkit-scrollbar-thumb, .terminal-box::-webkit-scrollbar-thumb { background: #333; border: 1px solid var(--neon-green); }

/* HARDWARE JEDNOTKA */
.hw-unit {
    background: var(--panel-bg);
    border: 2px solid var(--border-color); border-top: 3px solid #555;
    box-shadow: 0 5px 15px rgba(0,0,0,0.8);
    padding: 15px; display: flex; flex-direction: column;
    /* GRID LOGIKA PRO 3 OKNA */
    flex: 1 1 30%; 
    min-width: 320px; 
    max-width: 33%;
    height: 420px; 
    position: relative;
}

/* Zarovnání posledního okna doprava */
.unit-bottom-right {
    margin-left: auto;
}

.unit-wide { 
    flex: 0 0 100%; max-width: 100%; height: auto; 
    border-color: var(--neon-amber); margin-bottom: 5px; 
}

/* Panel Header */
.front-panel {
    display: flex; align-items: center; justify-content: space-between;
    background: #000; padding: 8px 12px; margin-bottom: 12px;
    border: 1px solid #333; box-shadow: inset 0 0 5px #000;
}
.panel-title { font-family: var(--font-header); font-size: 0.7rem; color: var(--neon-green); letter-spacing: 1px; }
.led-group { display: flex; gap: 6px; }
.led { width: 8px; height: 8px; border-radius: 50%; background-color: #222; }
.led.green { background-color: var(--neon-green); box-shadow: 0 0 5px var(--neon-green); }
.led.red { background-color: var(--neon-red); box-shadow: 0 0 5px var(--neon-red); }
.led.amber { background-color: var(--neon-amber); box-shadow: 0 0 5px var(--neon-amber); }
.led.blink { animation: blink 1s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* STATUS BAR */
#status-line { 
    width: 100%; text-align: right; padding-right: 20px;
    color: var(--neon-amber); font-size: 1.1rem; 
    text-shadow: 0 0 2px var(--neon-amber); 
}

/* Unit 1 Layout */
.sys-layout { display: flex; gap: 15px; height: 100%; }
.sys-left { flex: 1; display: flex; flex-direction: column; }
.sys-right { flex: 0.8; border-left: 1px dashed #333; padding-left: 15px; display: flex; flex-direction: column; justify-content: space-between; }

.boot-screen { font-family: var(--font-main); color: var(--neon-green); font-size: 1.1rem; line-height: 1.4; }
.boot-row span { color: #fff; opacity: 0.7; }
.password-box { margin-top: auto; border-top: 1px dashed #333; padding-top: 10px; }
#pass-field { background: #333; color: var(--neon-green); height: 2rem; border: 1px solid #444; width: 100%; font-family: var(--font-main); padding: 5px; }

.mem-block { font-family: 'VT323'; font-size: 0.8rem; color: #555; line-height: 1; overflow: hidden; height: 80px; }
.cpu-graph { display: flex; gap: 2px; align-items: flex-end; height: 40px; margin-top: 10px; }
.cpu-bar { flex: 1; background: var(--neon-green); opacity: 0.5; animation: barFluctuate 1s infinite alternate; }
@keyframes barFluctuate { 0% { height: 20%; } 100% { height: 80%; } }

/* Unit 2 Storage */
.scroll-box { overflow-y: auto; flex-grow: 1; border: 1px solid #222; padding: 8px; background: #050505; }
ul.file-list { list-style: none; padding: 0; }
ul.file-list li { margin-bottom: 8px; font-size: 0.8rem; border-bottom: 1px solid #222; padding-bottom: 5px; }
ul.file-list a { color: var(--neon-amber); font-family: var(--font-files); font-weight: 500; text-decoration: none; display: block; letter-spacing: 0.5px;}
ul.file-list a:hover { color: #fff; text-shadow: 0 0 5px var(--neon-amber); padding-left: 5px; transition: 0.2s; }
.meta { float: right; color: #666; font-size: 0.8rem; font-family: var(--font-main); margin-top: 2px; }
.disk-space { margin-top: 10px; font-size: 0.8rem; color: #666; }

/* Unit 3 Camera */
.cam-container { position: relative; border: 2px solid #333; flex-grow: 1; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 10px;}
.webcam-img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; }
.cam-overlay { position: absolute; top: 5px; left: 5px; color: var(--neon-red); font-size: 0.8rem; animation: blink 2s infinite; background: rgba(0,0,0,0.5); padding: 2px; }
.cam-selector { background: #111; color: var(--neon-green); border: 1px solid var(--neon-green); width: 100%; padding: 5px; font-family: var(--font-main); font-size: 1rem; }

/* Unit 4 Comms */
.terminal-split { display: flex; flex-direction: column; height: 100%; gap: 5px; }
.terminal-box { flex: 1; border: 1px solid #333; background: #000; padding: 5px; overflow-y: auto; font-size: 0.9rem; }
.system-log { color: #0f0; }
.messenger-display { color: var(--neon-cyan); }
.msg-input-wrap { display: flex; gap: 5px; align-items: center; }
.msg-prompt { color: var(--neon-green); }
#messenger-input { background: #333; color: #fff; border: none; height: 2rem; width: 100%; font-family: var(--font-main); padding-left: 5px; outline: none; }

@media (max-width: 1100px) {
    .hw-unit { flex: 1 1 45%; max-width: 48%; }
    .unit-bottom-right { margin-left: 0; }
}

@media (max-width: 800px) {
    .hw-unit { max-width: 100%; flex: 1 1 100%; height: auto; min-height: 350px; }
}