:root {
    --bg-color: #050508;
    --brand-blue: #0096ee;
    --brand-blue-glow: rgba(0, 150, 238, 0.4);
    --panel-bg: rgba(16, 20, 30, 0.6);
    --panel-border: rgba(0, 150, 238, 0.2);
    --text-primary: #f0f4f8;
    --text-secondary: #8a9bb0;
    --alert-yellow: #f5a623;
    --alert-red: #ff3366;
    --success-green: #00e676;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --u-height: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background-color: var(--bg-color); color: var(--text-primary); font-family: var(--font-main);
    min-height: 100vh;
    background-image: radial-gradient(circle at 15% 50%, rgba(0, 150, 238, 0.05), transparent 25%), radial-gradient(circle at 85% 30%, rgba(0, 150, 238, 0.03), transparent 25%);
}
.hidden { display: none !important; }

/* --- Utility --- */
.glass-panel {
    background: var(--panel-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--panel-border); border-radius: 12px; box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.txt-red { color: var(--alert-red) !important; }
.txt-green { color: var(--success-green) !important; }
.txt-secondary { color: var(--text-secondary) !important; }

/* --- Auth & Alerts --- */
#password-screen, #alert-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: rgba(5, 5, 8, 0.9); z-index: 1000;
}
.auth-box, .critical-alert { padding: 40px; width: 100%; max-width: 450px; text-align: center; border-top: 3px solid var(--brand-blue); }
.critical-alert { border-top-color: var(--alert-red); }
.lock-icon { width: 48px; height: 48px; color: var(--brand-blue); margin-bottom: 20px; }
.auth-box h1, .critical-alert h1 { font-size: 24px; letter-spacing: 2px; margin-bottom: 10px; font-family: var(--font-mono); }
.critical-alert h1 { color: var(--alert-red); }
.auth-box p, .critical-alert p { color: var(--text-secondary); margin-bottom: 30px; }
.auth-box input { width: 100%; padding: 15px; background: rgba(0,0,0,0.5); border: 1px solid var(--panel-border); border-radius: 6px; color: white; font-family: var(--font-mono); margin-bottom: 20px; outline: none; }
.auth-box input:focus { border-color: var(--brand-blue); box-shadow: 0 0 10px var(--brand-blue-glow); }

button { width: 100%; padding: 15px; background: transparent; border: 1px solid var(--brand-blue); color: var(--brand-blue); font-family: var(--font-mono); font-weight: bold; text-transform: uppercase; border-radius: 6px; cursor: pointer; transition: all 0.3s; }
button:hover { background: var(--brand-blue); color: #fff; box-shadow: 0 0 15px var(--brand-blue-glow); }
#auth-error { color: var(--alert-red); margin-top: 15px; font-size: 14px; }

/* --- Game Container --- */
#game-container { display: flex; flex-direction: column; height: 100vh; padding: 15px; max-width: 1400px; margin: 0 auto; overflow: hidden; }

/* --- Header --- */
.top-nav { display: flex; justify-content: space-between; align-items: center; padding: 15px 30px; margin-bottom: 20px; flex-shrink: 0; }
.logo { font-family: var(--font-mono); font-size: 24px; font-weight: bold; color: var(--text-primary); width: 250px; display:flex; flex-direction:column; }
.logo span { color: var(--brand-blue); }
.uptime-box { font-size: 11px; margin-top:5px; color: var(--text-secondary); letter-spacing: 1px;}
.uptime-box span { color: var(--success-green); }

.financial-stats { display: flex; gap: 30px; }
.mining-box { display: flex; flex-direction: column; align-items: center; }
.mining-box.highlight .val { color: var(--alert-yellow); text-shadow: 0 0 10px rgba(245, 166, 35, 0.4); }
.mining-box .label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.mining-box .val { font-family: var(--font-mono); font-size: 18px; font-weight: bold; }

.time-warp-box { display: flex; flex-direction: column; align-items: flex-end; width: 250px; }
.time-warp-box .label, .time-warp-box .sim-speed { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; margin-bottom: 4px; }
.time-warp-box select { background: transparent; color: var(--brand-blue); border: 1px solid var(--panel-border); font-family: var(--font-mono); padding: 5px; outline: none; border-radius: 4px; margin-bottom: 4px; width: 100%; }
.time-warp-box select option { background: var(--bg-color); color: var(--text-primary); }

/* --- Dropdown Form --- */
.dropdown-input {
    width: 100%; padding: 10px; background: rgba(0,0,0,0.5); border: 1px solid var(--panel-border);
    border-radius: 4px; color: var(--brand-blue); font-family: var(--font-mono); font-size:12px; outline: none;
}
.dropdown-input option { background: var(--bg-color); color: var(--text-primary); font-size:14px; }

/* --- Layout --- */
.game-area { display: grid; grid-template-columns: 350px 1fr; gap: 20px; flex: 1; min-height: 0; }
@media (max-width: 1000px) { .game-area { grid-template-columns: 1fr; overflow-y: auto;} }

.metrics { display: flex; flex-direction: column; overflow-y: auto; padding: 25px; }
.stats-bar-vertical { display: flex; flex-direction: column; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid #333; }
.stat-box { display: flex; justify-content: space-between; align-items: center; }
.stat-box .label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }
.stat-box .val { font-family: var(--font-mono); font-size: 14px; font-weight: bold; transition: color 0.3s; }
.temp-warning .val { color: var(--alert-yellow); }
.temp-danger .val { color: var(--alert-red); animation: pulse 1s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

/* Controls */
.actions { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.action-btn { text-align: left; padding: 10px; position: relative; }
.btn-title { font-size: 14px; margin-bottom: 2px; }
.btn-desc { font-size: 10px; color: var(--text-secondary); text-transform: none; font-family: var(--font-main); }
.action-btn:active { transform: scale(0.98); }

.safe-btn { border-color: rgba(0, 150, 238, 0.5); }
.safe-btn:hover { background: rgba(0, 150, 238, 0.1); color: var(--brand-blue); box-shadow: inset 0 0 10px rgba(0, 150, 238, 0.2); }
.safe-btn.active-safe { background: var(--brand-blue); color: #fff; box-shadow: 0 0 15px var(--brand-blue-glow); }

.danger-btn { border-color: rgba(255, 51, 102, 0.5); color: var(--alert-red); margin-top:5px; }
.danger-btn:hover { background: rgba(255, 51, 102, 0.1); color: var(--alert-red); box-shadow: inset 0 0 10px rgba(255, 51, 102, 0.2); }

.terminal { margin-top: 20px; padding-top: 15px; font-family: var(--font-mono); font-size: 10px; color: var(--success-green); opacity: 0.8; min-height: 90px; display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;}
.terminal div { margin-bottom: 4px; }

/* --- Room Visuals --- */
.room { padding: 30px; display: flex; flex-direction: column; border-top: 3px solid var(--text-secondary); transition: border-color 0.5s; height: 100%; overflow: hidden;}
.room.hot { border-top-color: var(--alert-yellow); }
.room.critical { border-top-color: var(--alert-red); }
.room-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-shrink: 0;}
.status-indicator { font-family: var(--font-mono); font-size: 14px; color: var(--success-green); }

.room-visuals { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0;}

.duct-area { margin-bottom: 5px; width: 350px; display: flex; justify-content: center; z-index: 10;}
.duct-fan-slot { 
    width: 250px; height: 35px; background: #111; border: 2px solid #333; border-radius: 8px 8px 0 0;
    display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 10px; color: #555;
    position: relative; overflow: hidden; font-weight: bold; transition: all 0.3s;
}
.duct-fan-slot.installed {
    background: #1a2530; border-color: var(--brand-blue); color: var(--brand-blue);
    box-shadow: 0 -5px 15px rgba(0, 150, 238, 0.2);
}

.rack-container { flex: 1; display: flex; justify-content: center; width: 100%; overflow-y: auto; padding: 10px 0;}
.rack {
    width: 350px; height: calc(42 * var(--u-height)); background: #0c0c11; border: 4px solid #444; border-bottom-width: 8px;
    border-radius: 2px; position: relative; display: flex; flex-direction: column;
}

.u-space {
    width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column-reverse; /* Reverses the DOM loop physically */
}

.u-slot-bg {
    height: var(--u-height); width: 100%; border-bottom: 1px dotted #222;
    display: flex; align-items: center; padding-left: 5px; opacity: 0.5;
}
.u-label { font-family: var(--font-mono); font-size: 8px; color: #555; }

/* Item Blocks */
.rack-item {
    position: absolute; left: 5px; width: calc(100% - 10px); background: #1a1a24;
    border: 1px solid #334; border-radius: 2px; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-mono); font-size: 10px; color: #778; transition: bottom 0.2s, background 0.3s;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8); cursor: pointer; user-select: none; z-index: 5;
}
.rack-item:hover { filter: brightness(1.2); z-index: 20;}

/* Safely Shutdown Dimmer Effect */
.rack-item.powered-down { filter: grayscale(1) opacity(0.5); box-shadow: none; border-color:#333 !important;}
.rack-item.powered-down::before { display: none; }

/* Drag and Drop Ghosting */
.rack-item.dragging { opacity: 0.5; z-index: 50; border-style: dashed; border-color: var(--brand-blue); box-shadow: 0 0 20px var(--brand-blue-glow); }

.rack-item.miner { border-color: #556; color: var(--brand-blue); font-weight: bold; overflow: hidden;}
.rack-item.miner::before { content: ''; position: absolute; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--success-green); box-shadow: 0 0 5px var(--success-green); }
.rack-item.fan-intake { border-color: var(--brand-blue); color: var(--success-green); }
.rack-item.fan-exhaust { border-color: var(--alert-yellow); color: var(--alert-yellow); }

.item-name { flex: 1; text-align: left; padding-left: 10px; }
.item-status { font-size: 8px; margin-right: 25px; opacity: 0.7;}

.item-controls {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.rack-item:hover .item-controls { opacity: 1; pointer-events: auto; }

.icon-btn {
    width: 20px; height: 20px; padding: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.8) !important; border: 1px solid #666 !important; font-size: 10px !important;
    border-radius: 2px !important; margin: 0; line-height: 1; opacity: 0.8;
}
.icon-btn:hover { border-color: var(--brand-blue) !important; opacity: 1; }
.icon-btn.remove-btn:hover { border-color: var(--alert-red) !important; color: var(--alert-red) !important; }

/* SVG */
.svg-fan { width: 14px; height: 14px; margin-right: 5px; animation: spin 1s linear infinite; }
.duct-icon { width: 24px; height: 24px; animation: spin 0.5s linear infinite; }
.rack-item.powered-down .svg-fan, .duct-fan-slot.powered-down .duct-icon { animation: none; }

@keyframes spin { 100% { transform: rotate(360deg); } }
