/* Black Desert Research Terminal styles. Edit color/font variables near the top. */
* { margin: 0; padding: 0; box-sizing: border-box; }

@font-face {
    font-family: "IBM DOS ISO8";
    src:
        local("IBM DOS ISO8"),
        local("Px437 IBM DOS ISO8"),
        local("Px437 IBM ISO8"),
        local("Px437_IBM_ISO8"),
        local("Ac437 IBM DOS ISO8"),
        local("Mx437 IBM DOS ISO8");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    color-scheme: dark;
    --phosphor: #20c20e;
    --phosphor-dim: #0a3d08;
    --phosphor-glow: #39ff14;
    --amber: #ffb000;
    --amber-dim: #8b6914;
    --red: #ff3333;
    --cyan: #00d4aa;
    --magenta: #ff00ff;
    --bg: #050805;
    --scanline-alpha: 0.08;
    --font-size-base: clamp(13px, 1.05vw, 16px);
    --font-size-title: clamp(15px, 1.35vw, 20px);
    --font-size-small: clamp(10px, 0.9vw, 13px);
    --font-size-tiny: clamp(10px, 1.2vw, 12px);
    --panel-bg: rgba(4, 14, 6, 0.94);
    --panel-bg-deep: rgba(1, 6, 3, 0.96);
    --panel-highlight: rgba(32, 194, 14, 0.08);
    --panel-edge: rgba(57, 255, 20, 0.18);
    --ui-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --viewport-height: 100vh;
    --crt-band-opacity: 1;
    --terminal-font: "IBM DOS ISO8", "Px437 IBM ISO8", "Ac437 IBM DOS ISO8", "Mx437 IBM DOS ISO8", "Courier New", monospace;
}

@supports (height: 100dvh) {
    :root {
        --viewport-height: 100dvh;
    }
}

html, body { height: 100%; overflow: hidden; }

body {
    background:
        radial-gradient(circle at 50% 20%, rgba(32, 194, 14, 0.08), transparent 34%),
        linear-gradient(180deg, #020402 0%, var(--bg) 42%, #010301 100%);
    font-family: var(--terminal-font);
    font-synthesis: none;
    text-rendering: optimizeSpeed;
    accent-color: var(--phosphor);
    color: var(--phosphor);
    font-size: var(--font-size-base);
}

.noscript-warning {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #020402;
    color: var(--amber);
    font-family: var(--terminal-font);
    text-align: center;
    letter-spacing: 1px;
}

/* ===== CRT EFFECTS ===== */
.crt-monitor {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
}

body.terminal-ready .crt-monitor {
    visibility: visible;
    opacity: 1;
}

.crt-monitor::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(0,0,0,var(--scanline-alpha)) 1px, rgba(0,0,0,var(--scanline-alpha)) 2px);
    pointer-events: none;
    z-index: 100;
}

.crt-monitor::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 0%, transparent 60%, rgba(0,0,0,0.15) 80%, rgba(0,0,0,0.4) 100%);
    pointer-events: none;
    z-index: 101;
}

@keyframes crtBand {
    0% { transform: translate3d(0, -100%, 0); }
    100% { transform: translate3d(0, var(--viewport-height), 0); }
}
.crt-band {
    position: absolute; top: 0; left: 0; right: 0; height: 100px;
    background: linear-gradient(180deg, transparent 0%, rgba(32,194,14,0.03) 50%, transparent 100%);
    animation: crtBand 8s linear infinite;
    opacity: var(--crt-band-opacity);
    pointer-events: none; z-index: 99;
    will-change: transform;
}

body.low-power {
    --scanline-alpha: 0.045;
    --crt-band-opacity: 0;
}

body.low-power .crt-band {
    display: none;
}

body.low-power .glow {
    text-shadow: 0 0 1px currentColor;
}

/* ===== MAIN LAYOUT ===== */
.screen-content {
    position: relative;
    z-index: 1;
    height: 100%;
    padding: 15px;
    display: flex;
    flex-direction: column;
    transform: translateZ(0);
    contain: layout paint style;
}

/* ===== HEADER ===== */
.header-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    height: 90px;
    flex-shrink: 0;
}

.header-panel {
    flex: 1;
    border: 1px solid var(--phosphor-dim);
    background:
        linear-gradient(90deg, rgba(32,194,14,0.08), transparent 22%),
        linear-gradient(180deg, rgba(255,255,255,0.025), transparent 36%),
        var(--panel-bg);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow:
        inset 0 0 30px rgba(32, 194, 14, 0.055),
        0 0 0 1px rgba(32, 194, 14, 0.02);
    min-width: 0;
    overflow: hidden;
    contain: layout paint style;
}

.system-title {
    font-size: var(--font-size-title);
    letter-spacing: 2px;
    color: var(--phosphor-glow);
    text-shadow: 0 0 10px var(--phosphor), 0 0 20px var(--phosphor-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-info {
    text-align: right;
    font-size: var(--font-size-small);
    opacity: 0.7;
    flex-shrink: 0;
    margin-left: 15px;
}
.header-info .hl { color: var(--amber); }

.status-bar {
    display: flex;
    gap: 15px;
    font-size: var(--font-size-tiny);
    opacity: 0.6;
}
.status-item { display: flex; align-items: center; gap: 4px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--phosphor); box-shadow: 0 0 4px var(--phosphor); }
.status-dot.warn { background: var(--amber); box-shadow: 0 0 4px var(--amber); }
.status-dot.err { background: var(--red); box-shadow: 0 0 4px var(--red); }

/* ===== HOLOGRAM PANEL ===== */
.hologram-panel {
    width: 140px;
    border: 1px solid var(--phosphor-dim);
    background:
        radial-gradient(circle at 50% 35%, rgba(0,212,170,0.08), transparent 58%),
        var(--panel-bg-deep);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    contain: layout paint style;
}
.hologram-title {
    font-size: var(--font-size-tiny);
    text-align: center;
    padding: 3px;
    border-bottom: 1px solid var(--phosphor-dim);
    letter-spacing: 1px;
    opacity: 0.6;
}
.hologram-container {
    flex: 1;
    position: relative;
    min-height: 0;
}
#hologramCanvas {
    width: 100%;
    height: 100%;
}
@media (max-width: 1000px) {
    .hologram-panel { display: none; }
}
@media (max-width: 800px) {
    .header-info { display: none; }
}

/* ===== MAIN CONTAINER ===== */
.main-container {
    flex: 1;
    display: flex;
    gap: 15px;
    min-height: 0;
}

/* ===== LEFT MENU ===== */
.menu-panel {
    width: 280px;
    border: 1px solid var(--phosphor-dim);
    background:
        linear-gradient(180deg, rgba(255,176,0,0.025), transparent 22%),
        var(--panel-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    box-shadow:
        inset 0 0 30px rgba(32, 194, 14, 0.035),
        0 0 18px rgba(0, 0, 0, 0.28);
    contain: layout paint style;
}

.menu-title {
    padding: 10px 15px;
    border-bottom: 1px solid var(--phosphor-dim);
    font-size: var(--font-size-small);
    color: var(--amber);
    letter-spacing: 2px;
    text-align: center;
    background: rgba(0, 20, 0, 0.3);
}

.menu-list {
    flex: 1;
    padding: clamp(2px, 0.8vh, 8px) 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.menu-item {
    appearance: none;
    width: 100%;
    height: clamp(28px, calc((var(--viewport-height) - 260px) / 13), 42px);
    min-height: clamp(28px, calc((var(--viewport-height) - 260px) / 13), 42px);
    padding: 0 clamp(12px, 1.4vw, 20px);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    font-size: clamp(11px, 1.55vh, var(--font-size-base));
    transition:
        background-color 0.14s var(--ui-ease),
        color 0.14s var(--ui-ease),
        border-color 0.14s var(--ui-ease);
    background: transparent;
    color: inherit;
    font-family: inherit;
    text-align: left;
    outline: none;
    border: 0;
    border-left: 3px solid transparent;
    touch-action: manipulation;
}

.menu-item::after {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    right: 10px;
    width: 1px;
    background: var(--panel-edge);
    opacity: 0;
    transform: scaleY(0.4);
    transition: opacity 0.14s var(--ui-ease), transform 0.14s var(--ui-ease);
}

.menu-item:hover {
    background: rgba(32, 194, 14, 0.1);
}

.menu-item:focus-visible {
    background: rgba(0, 212, 170, 0.12);
    box-shadow: inset 0 0 0 1px var(--cyan);
}

.menu-item.selected {
    background: rgba(32, 194, 14, 0.2);
    border-left-color: var(--phosphor);
    color: var(--phosphor-glow);
    text-shadow: 0 0 5px var(--phosphor);
}

.menu-item.selected::after {
    opacity: 1;
    transform: scaleY(1);
}

.menu-item .icon {
    width: 20px;
    text-align: center;
    color: var(--cyan);
    flex-shrink: 0;
}

.menu-item span:not(.icon) {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-item.admin-cmd {
    color: var(--red);
}
.menu-item.admin-cmd .icon {
    color: var(--red);
}
.menu-item.admin-cmd.locked {
    opacity: 0.4;
    color: #444;
}
.menu-item.admin-cmd.locked .icon {
    color: #444;
}

.menu-separator {
    height: 1px;
    background: var(--phosphor-dim);
    margin: clamp(2px, 0.8vh, 8px) 15px;
    flex-shrink: 0;
}

.menu-footer {
    padding: clamp(6px, 0.9vh, 10px) 15px;
    border-top: 1px solid var(--phosphor-dim);
    font-size: var(--font-size-tiny);
    color: #555;
    text-align: center;
    flex-shrink: 0;
}

.admin-badge {
    display: none;
    color: var(--red);
    text-shadow: 0 0 6px var(--red);
    animation: pulse 2s ease-in-out infinite;
    font-size: var(--font-size-tiny);
    text-align: center;
    padding: clamp(5px, 0.75vh, 8px);
    border-top: 1px solid var(--phosphor-dim);
    flex-shrink: 0;
}
.admin-badge.active { display: block; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== RIGHT CONTENT ===== */
.content-panel {
    flex: 1;
    border: 1px solid var(--phosphor-dim);
    background:
        linear-gradient(180deg, rgba(32,194,14,0.04), transparent 18%),
        var(--panel-bg-deep);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        inset 0 0 50px rgba(32, 194, 14, 0.035),
        0 0 22px rgba(0, 0, 0, 0.35);
    contain: layout paint style;
}

.content-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 15px;
    border-bottom: 1px solid var(--phosphor-dim);
    font-size: var(--font-size-tiny);
    background: rgba(0, 15, 0, 0.4);
    flex-shrink: 0;
}

.toolbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    min-width: 0;
}

.page-indicator { color: var(--amber); text-shadow: 0 0 5px var(--amber-dim); }

.database-slot-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.database-slot-button {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    border: 1px solid currentColor;
    background: rgba(0, 0, 0, 0.52);
    color: var(--red);
    display: grid;
    place-items: center;
    font-family: var(--terminal-font);
    font-size: 19px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    text-shadow: 0 0 6px currentColor;
    touch-action: manipulation;
}

.database-slot-button.loaded {
    color: var(--phosphor);
}

.database-slot-button:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
}

.database-slot-button:hover {
    background: rgba(32, 194, 14, 0.09);
}

.content-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
    contain: layout paint style;
}

.content-area {
    position: absolute;
    inset: 0;
    padding: 10px 15px;
    font-size: var(--font-size-base);
    line-height: 1.22;
    overflow: hidden;
    transform: translateZ(0);
    contain: layout paint style;
}

.output {
    white-space: pre-wrap;
    word-wrap: break-word;
    contain: content;
}

.output-line {
    min-height: 1.22em;
}
.glow { text-shadow: 0 0 1px var(--phosphor), 0 0 3px var(--phosphor-dim); }

/* ===== INPUT AREA ===== */
.input-area {
    border-top: 1px solid var(--phosphor-dim);
    padding: 10px 15px;
    display: flex;
    align-items: center;
    background: rgba(0, 12, 0, 0.4);
    flex-shrink: 0;
}

.prompt {
    color: var(--amber);
    margin-right: 10px;
    text-shadow: 0 0 4px var(--amber-dim);
}

#commandInput {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-base);
    outline: none;
    text-shadow: 0 0 1px var(--phosphor);
    caret-color: var(--phosphor);
}

#commandInput:focus-visible {
    outline: 1px solid var(--cyan);
    outline-offset: 4px;
}

.cursor-block {
    width: 10px;
    height: 1.2em;
    background: var(--phosphor);
    animation: cursorBlink 1s step-end infinite;
    box-shadow: 0 0 4px var(--phosphor);
}
@keyframes cursorBlink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* ===== TEXT STYLES ===== */
.t-amber { color: var(--amber); text-shadow: 0 0 4px var(--amber-dim); }
.t-red { color: var(--red); text-shadow: 0 0 4px rgba(255,51,51,0.4); }
.t-cyan { color: var(--cyan); text-shadow: 0 0 4px rgba(0,212,170,0.4); }
.t-magenta { color: var(--magenta); text-shadow: 0 0 4px rgba(255,0,255,0.4); }
.t-dim { opacity: 0.5; }
.t-bright { color: var(--phosphor-glow); text-shadow: 0 0 6px var(--phosphor); }

/* ===== PASSWORD DIALOG ===== */
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    justify-content: center;
    align-items: center;
}
.dialog-overlay.active { display: flex; }

.dialog-box {
    border: 2px solid var(--amber);
    background: rgba(5, 15, 5, 0.98);
    padding: 30px 40px;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 0 50px rgba(255, 176, 0, 0.2);
    contain: layout paint style;
}

.dialog-box h2 {
    color: var(--amber);
    font-size: var(--font-size-title);
    margin-bottom: 20px;
    letter-spacing: 2px;
}

.dialog-box p {
    margin-bottom: 20px;
    color: #888;
}

.dialog-box input {
    width: 100%;
    background: rgba(0, 20, 0, 0.8);
    border: 1px solid var(--phosphor-dim);
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-base);
    padding: 12px 15px;
    text-align: center;
    outline: none;
    margin-bottom: 10px;
}

.dialog-box input:focus {
    border-color: var(--phosphor);
    box-shadow: 0 0 10px var(--phosphor-dim);
}

.dialog-error {
    color: var(--red);
    font-size: var(--font-size-small);
    margin-bottom: 15px;
    display: none;
}
.dialog-error.visible { display: block; }

.dialog-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

.dialog-btn {
    padding: 10px 25px;
    border: 1px solid var(--phosphor-dim);
    background: rgba(0, 30, 0, 0.8);
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-base);
    cursor: pointer;
    touch-action: manipulation;
    transition:
        background-color 0.18s var(--ui-ease),
        border-color 0.18s var(--ui-ease),
        color 0.18s var(--ui-ease),
        box-shadow 0.18s var(--ui-ease);
}

.dialog-btn:hover {
    background: rgba(0, 50, 0, 0.8);
    border-color: var(--phosphor);
    box-shadow: 0 0 10px var(--phosphor-dim);
}

.dialog-btn.primary {
    background: var(--phosphor-dim);
    color: var(--phosphor-glow);
}

.dialog-btn.cancel {
    border-color: #444;
    color: #666;
}

.dialog-btn:focus-visible,
.diagnostic-close:focus-visible,
.facility-close:focus-visible,
.boot-skip:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
}

/* ===== DATABASE SELECTOR ===== */
.database-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 235;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background:
        radial-gradient(circle at 50% 20%, rgba(255, 176, 0, 0.08), transparent 34%),
        rgba(0, 0, 0, 0.88);
}

.database-modal-panel {
    width: min(720px, 100%);
    max-height: calc(var(--viewport-height) - 36px);
    border: 1px solid var(--amber);
    background:
        linear-gradient(90deg, rgba(255, 176, 0, 0.04), transparent 28%),
        rgba(3, 12, 5, 0.98);
    box-shadow:
        inset 0 0 40px rgba(32, 194, 14, 0.06),
        0 0 42px rgba(255, 176, 0, 0.13);
    overflow: hidden;
}

.database-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 176, 0, 0.35);
    background: rgba(0, 16, 0, 0.48);
}

.database-modal-title {
    color: var(--amber);
    font-size: var(--font-size-title);
    letter-spacing: 2px;
}

.database-modal-close,
.database-modal-action {
    border: 1px solid rgba(255, 176, 0, 0.5);
    background: rgba(20, 12, 0, 0.78);
    color: var(--amber);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    padding: 8px 11px;
    min-height: 38px;
    cursor: pointer;
    touch-action: manipulation;
}

.database-modal-close:focus-visible,
.database-modal-action:focus-visible,
.database-choice:focus-visible,
.database-password-input:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
}

.database-modal-body {
    padding: 14px;
    overflow: auto;
    max-height: calc(var(--viewport-height) - 120px);
}

.database-modal-copy {
    color: var(--phosphor);
    font-size: var(--font-size-small);
    margin-bottom: 12px;
}

.database-list {
    display: grid;
    gap: 8px;
}

.database-choice {
    appearance: none;
    width: 100%;
    border: 1px solid rgba(32, 194, 14, 0.28);
    background:
        linear-gradient(90deg, rgba(32, 194, 14, 0.08), transparent),
        rgba(0, 10, 0, 0.66);
    color: var(--phosphor);
    font-family: var(--terminal-font);
    text-align: left;
    padding: 10px 12px;
    cursor: pointer;
}

.database-choice:hover {
    border-color: var(--cyan);
    background-color: rgba(0, 30, 20, 0.72);
}

.database-choice.disabled,
.database-choice:disabled {
    border-color: rgba(120, 120, 120, 0.28);
    background:
        linear-gradient(90deg, rgba(120, 120, 120, 0.08), transparent),
        rgba(10, 12, 10, 0.66);
    color: #666;
    cursor: not-allowed;
    opacity: 0.58;
}

.database-choice.disabled:hover,
.database-choice:disabled:hover {
    border-color: rgba(120, 120, 120, 0.28);
    background-color: rgba(10, 12, 10, 0.66);
}

.database-choice.disabled .database-choice-name,
.database-choice:disabled .database-choice-name,
.database-choice.disabled .database-choice-description,
.database-choice:disabled .database-choice-description {
    color: #666;
}

.database-choice-external {
    margin-top: 10px;
    border-color: rgba(255, 176, 0, 0.48);
    background:
        linear-gradient(90deg, rgba(255, 176, 0, 0.1), transparent),
        rgba(20, 12, 0, 0.66);
}

.database-choice-external .database-choice-name {
    color: var(--amber);
}

.database-choice-name,
.database-choice-description {
    display: block;
}

.database-choice-name {
    color: var(--cyan);
    font-size: var(--font-size-base);
    margin-bottom: 4px;
}

.database-choice-description {
    color: #777;
    font-size: var(--font-size-small);
}

.database-password-input {
    width: 100%;
    border: 1px solid var(--phosphor-dim);
    background: rgba(0, 20, 0, 0.8);
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-base);
    padding: 11px 12px;
    margin-bottom: 10px;
}

.database-password-error {
    color: var(--red);
    min-height: 1.3em;
    font-size: var(--font-size-small);
    margin-bottom: 10px;
}

.database-decrypt-box {
    border: 1px solid rgba(32, 194, 14, 0.35);
    background:
        linear-gradient(90deg, rgba(32, 194, 14, 0.08), transparent 38%),
        rgba(0, 14, 4, 0.78);
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    line-height: 1.45;
    min-height: 186px;
    margin-bottom: 12px;
    padding: 12px;
    white-space: pre-wrap;
    overflow: hidden;
}

.database-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.database-modal-action.secondary {
    border-color: rgba(32, 194, 14, 0.35);
    color: var(--phosphor);
    background: rgba(0, 24, 0, 0.72);
}

.database-modal-action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.database-slot-details {
    border: 1px solid rgba(32, 194, 14, 0.3);
    background: rgba(0, 14, 4, 0.72);
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    line-height: 1.5;
    padding: 12px;
    margin-bottom: 12px;
    white-space: pre-wrap;
}

/* ===== DIAGNOSTIC DASHBOARD ===== */
.diagnostic-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 220;
    background:
        radial-gradient(circle at 50% 18%, rgba(32, 194, 14, 0.08), transparent 34%),
        rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.diagnostic-overlay.active { display: flex; }

.diagnostic-panel {
    width: min(1080px, 100%);
    height: min(760px, calc(var(--viewport-height) - 36px));
    max-height: calc(var(--viewport-height) - 36px);
    border: 1px solid var(--amber);
    background:
        linear-gradient(90deg, rgba(255, 176, 0, 0.045), transparent 26%),
        linear-gradient(180deg, rgba(32, 194, 14, 0.055), rgba(0, 0, 0, 0.08)),
        rgba(3, 12, 5, 0.98);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        inset 0 0 44px rgba(32, 194, 14, 0.07),
        0 0 44px rgba(255, 176, 0, 0.12);
    contain: layout paint style;
}

.diagnostic-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255, 176, 0, 0.38);
    background: rgba(0, 18, 0, 0.48);
}

.diagnostic-title {
    color: var(--amber);
    letter-spacing: 2px;
    font-size: var(--font-size-title);
    min-width: 0;
}

.diagnostic-meta {
    color: var(--cyan);
    font-size: var(--font-size-tiny);
    opacity: 0.82;
    white-space: nowrap;
}

.diagnostic-close {
    border: 1px solid rgba(255, 176, 0, 0.5);
    background: rgba(20, 12, 0, 0.8);
    color: var(--amber);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    padding: 7px 10px;
    min-height: 36px;
    cursor: pointer;
    touch-action: manipulation;
}

.diagnostic-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(126px, 1fr)) minmax(158px, 1.18fr);
    gap: 8px;
    padding: 10px;
    min-height: 0;
    overflow: auto;
}

.diagnostic-card {
    border: 1px solid rgba(32, 194, 14, 0.26);
    background:
        linear-gradient(180deg, rgba(32, 194, 14, 0.055), transparent 55%),
        rgba(0, 10, 0, 0.68);
    padding: 9px 10px;
    min-height: 0;
    overflow: hidden;
    contain: layout paint style;
}

.diagnostic-card.wide {
    grid-column: 1 / -1;
}

.diagnostic-card.warn {
    border-color: rgba(255, 176, 0, 0.42);
}

.diagnostic-card.alert {
    border-color: rgba(255, 51, 51, 0.42);
}

.diagnostic-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--amber);
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(32, 194, 14, 0.16);
    padding-bottom: 4px;
    margin-bottom: 6px;
    font-size: var(--font-size-small);
}

.diagnostic-label span:last-child {
    color: var(--cyan);
    opacity: 0.85;
    white-space: nowrap;
}

.diagnostic-readout {
    margin: 0;
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    line-height: 1.22;
    white-space: pre;
    overflow: hidden;
    min-height: 6.1em;
}

.diagnostic-card.wide .diagnostic-readout {
    min-height: 8.55em;
}

.diagnostic-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid rgba(32, 194, 14, 0.2);
    padding: 9px 12px;
    color: var(--amber);
    font-size: var(--font-size-small);
    background: rgba(0, 14, 0, 0.42);
    min-height: 40px;
}

@media (max-width: 760px) {
    .diagnostic-overlay { padding: 10px; }
    .diagnostic-panel {
        height: calc(var(--viewport-height) - 20px);
        max-height: calc(var(--viewport-height) - 20px);
    }
    .diagnostic-header { align-items: flex-start; flex-wrap: wrap; }
    .diagnostic-grid {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        align-content: start;
    }
    .diagnostic-card.wide { grid-column: auto; }
    .diagnostic-card { min-height: 118px; }
    .diagnostic-readout { font-size: 10px; min-height: 6.1em; }
    .diagnostic-card.wide .diagnostic-readout { min-height: 8.55em; }
}

/* ===== FACILITY STATUS ===== */
.facility-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 225;
    background:
        radial-gradient(circle at 46% 28%, rgba(0, 212, 170, 0.075), transparent 34%),
        rgba(0, 0, 0, 0.91);
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.facility-overlay.active { display: flex; }

.facility-panel {
    width: min(1120px, 100%);
    height: min(760px, calc(var(--viewport-height) - 36px));
    border: 1px solid rgba(0, 212, 170, 0.68);
    background:
        linear-gradient(90deg, rgba(0, 212, 170, 0.04), transparent 30%),
        linear-gradient(180deg, rgba(32, 194, 14, 0.055), rgba(0, 0, 0, 0.12)),
        rgba(2, 10, 6, 0.98);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        inset 0 0 46px rgba(0, 212, 170, 0.07),
        0 0 46px rgba(0, 212, 170, 0.11);
    contain: layout paint style;
}

.facility-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 212, 170, 0.38);
    background: rgba(0, 18, 10, 0.5);
}

.facility-title {
    color: var(--cyan);
    letter-spacing: 2px;
    font-size: var(--font-size-title);
}

.facility-meta {
    color: var(--amber);
    font-size: var(--font-size-tiny);
    opacity: 0.86;
    white-space: nowrap;
}

.facility-close {
    border: 1px solid rgba(0, 212, 170, 0.5);
    background: rgba(0, 20, 14, 0.78);
    color: var(--cyan);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    padding: 7px 10px;
    min-height: 36px;
    cursor: pointer;
    touch-action: manipulation;
}

.facility-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
    gap: 10px;
    padding: 10px;
}

.facility-map-wrap {
    position: relative;
    min-height: 0;
    border: 1px solid rgba(32, 194, 14, 0.28);
    background:
        radial-gradient(circle at 50% 50%, rgba(32, 194, 14, 0.075), transparent 58%),
        repeating-linear-gradient(0deg, rgba(32, 194, 14, 0.04), rgba(32, 194, 14, 0.04) 1px, transparent 1px, transparent 18px),
        repeating-linear-gradient(90deg, rgba(32, 194, 14, 0.03), rgba(32, 194, 14, 0.03) 1px, transparent 1px, transparent 18px),
        rgba(0, 7, 3, 0.78);
    overflow: hidden;
    contain: layout paint style;
}

#facilityCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

.facility-map-hud {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 8px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--amber);
    font-size: var(--font-size-tiny);
    pointer-events: none;
    opacity: 0.82;
}

.facility-sidebar {
    min-height: 0;
    display: grid;
    grid-template-rows: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.facility-card {
    border: 1px solid rgba(0, 212, 170, 0.26);
    background:
        linear-gradient(180deg, rgba(0, 212, 170, 0.055), transparent 55%),
        rgba(0, 10, 7, 0.72);
    padding: 9px 10px;
    overflow: hidden;
    contain: layout paint style;
}

.facility-card-title {
    color: var(--amber);
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(0, 212, 170, 0.16);
    padding-bottom: 4px;
    margin-bottom: 6px;
    font-size: var(--font-size-small);
}

.facility-readout {
    margin: 0;
    color: var(--phosphor);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    line-height: 1.22;
    white-space: pre;
    overflow: hidden;
}

.facility-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid rgba(0, 212, 170, 0.2);
    padding: 9px 12px;
    color: var(--cyan);
    font-size: var(--font-size-small);
    background: rgba(0, 14, 9, 0.44);
    min-height: 40px;
}

@media (max-width: 820px) {
    .facility-overlay { padding: 10px; }
    .facility-panel {
        height: calc(var(--viewport-height) - 20px);
    }
    .facility-header { align-items: flex-start; flex-wrap: wrap; }
    .facility-layout {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(310px, 1fr) auto;
        overflow: auto;
    }
    .facility-sidebar {
        grid-template-rows: none;
    }
    .facility-readout {
        font-size: 10px;
    }
}

/* ===== BOOT SCREEN ===== */
.boot-screen {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 78% 42%, rgba(0, 212, 170, 0.075), transparent 30%),
        radial-gradient(circle at 18% 18%, rgba(255, 176, 0, 0.055), transparent 28%),
        var(--bg);
    z-index: 300;
    padding: 20px;
    display: block;
    overflow: hidden;
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.24s var(--ui-ease), transform 0.24s var(--ui-ease);
}
.boot-screen.boot-fading {
    opacity: 0;
    transform: scale(1.008);
    pointer-events: none;
}
.boot-screen.boot-blackout {
    background: #000;
}
.boot-screen.boot-blackout .boot-left,
.boot-screen.boot-blackout .boot-right,
.boot-screen.boot-blackout .boot-skip {
    opacity: 0;
}
.boot-screen.hidden { display: none; }

.boot-left {
    height: 100%;
    max-width: min(88ch, 100%);
    margin: 0 auto;
    padding-inline: clamp(0px, 2vw, 20px);
    overflow-y: auto;
    overflow-x: hidden;
    contain: layout paint style;
    scrollbar-width: none;
    transition: opacity 0.32s var(--ui-ease), transform 0.32s var(--ui-ease);
}

.boot-screen.boot-log-mode .boot-left {
    display: flex;
    flex-direction: column;
}

.boot-left::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.boot-right {
    display: none;
}

.boot-output { 
    font-size: var(--font-size-small); 
    line-height: 1.35;
    font-family: var(--terminal-font);
    white-space: normal;
    overflow-wrap: anywhere;
    transition: opacity 0.32s var(--ui-ease), transform 0.32s var(--ui-ease);
    width: 100%;
}

.boot-screen.boot-log-mode .boot-output {
    margin-top: auto;
    flex: 0 0 auto;
}

.boot-output.fading {
    opacity: 0;
    transform: translateY(-8px);
}

.boot-line {
    display: block;
    min-height: 1.35em;
    width: 100%;
    max-width: 100%;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    animation: bootLineRise 0.16s var(--ui-ease) both;
}

@keyframes bootLineRise {
    from {
        opacity: 0;
        transform: translateY(0.45em);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.boot-line.boot-check {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
}

.boot-line.boot-check .boot-label {
    white-space: pre;
}

.boot-label {
    color: var(--phosphor);
    white-space: pre-wrap;
}

.boot-status {
    display: inline-block;
    margin-left: 0.8ch;
    letter-spacing: 1px;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.14s var(--ui-ease), transform 0.14s var(--ui-ease);
    white-space: nowrap;
}

.boot-status.visible {
    opacity: 1;
    transform: translateX(0);
}

.boot-section {
    margin-top: 0.45em;
    color: var(--amber);
    letter-spacing: 1px;
}

.boot-loader {
    color: var(--amber);
    margin-top: 0.45em;
}

.boot-caret::after {
    content: "█";
    display: inline-block;
    margin-left: 2px;
    color: var(--phosphor-glow);
    animation: cursorBlink 0.65s step-end infinite;
}

.boot-logo {
    text-align: center;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.45s var(--ui-ease), transform 0.45s var(--ui-ease);
}

.boot-logo-inline {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    white-space: pre;
    font-family: var(--terminal-font);
    font-size: clamp(7px, 1.45vw, 14px);
    line-height: 1.14;
    text-align: center;
    padding-top: min(8vh, 64px);
}
.boot-logo.visible {
    opacity: 1;
    transform: translateY(0);
}

.boot-skip {
    position: fixed;
    right: 20px;
    bottom: 18px;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 305;
    border: 1px solid rgba(255, 176, 0, 0.45);
    background: rgba(10, 18, 6, 0.82);
    color: var(--amber);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    letter-spacing: 1px;
    padding: 9px 14px;
    min-height: 44px;
    cursor: pointer;
    text-shadow: 0 0 6px var(--amber-dim);
    box-shadow: inset 0 0 18px rgba(255, 176, 0, 0.06);
    touch-action: manipulation;
}

.boot-skip:active {
    transform: translateY(1px);
    border-color: var(--amber);
}

html.has-gsap .boot-screen,
html.has-gsap .boot-logo {
    transition: none;
}

html.has-gsap .boot-left,
html.has-gsap .boot-output {
    transition: none;
}

@media (max-width: 900px) {
    .boot-left {
        height: 100%;
    }
}

/* ===== HIDDEN RAYCAST MINI-GAME ===== */
.liebi-overlay {
    position: fixed;
    inset: 0;
    z-index: 540;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    background:
        radial-gradient(circle at 50% 20%, rgba(0, 212, 170, 0.12), transparent 34%),
        linear-gradient(180deg, rgba(0, 0, 0, 0.94), rgba(1, 7, 5, 0.98));
    color: var(--phosphor);
    font-family: var(--terminal-font);
}

.liebi-shell {
    width: min(1080px, 100%);
    max-height: calc(var(--viewport-height) - 28px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 10px;
    border: 1px solid rgba(0, 212, 170, 0.62);
    background:
        linear-gradient(90deg, rgba(0, 212, 170, 0.05), transparent 28%),
        rgba(1, 9, 7, 0.96);
    box-shadow:
        inset 0 0 46px rgba(0, 212, 170, 0.08),
        0 0 48px rgba(0, 0, 0, 0.7);
    padding: 10px;
    overflow: hidden;
}

.liebi-topbar,
.liebi-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.liebi-title {
    color: var(--amber);
    letter-spacing: 2px;
    font-size: var(--font-size-title);
    white-space: nowrap;
}

.liebi-objective,
.liebi-controls {
    color: var(--cyan);
    font-size: var(--font-size-small);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.liebi-close {
    flex-shrink: 0;
    border: 1px solid rgba(255, 176, 0, 0.58);
    background: rgba(20, 12, 0, 0.82);
    color: var(--amber);
    font-family: var(--terminal-font);
    font-size: var(--font-size-small);
    padding: 8px 11px;
    min-height: 38px;
    cursor: pointer;
    touch-action: manipulation;
}

.liebi-close:focus-visible,
.liebi-action:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 3px;
}

.liebi-stage {
    position: relative;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
    gap: 10px;
}

.liebi-canvas-wrap {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(32, 194, 14, 0.28);
    background:
        repeating-linear-gradient(0deg, rgba(32, 194, 14, 0.035), rgba(32, 194, 14, 0.035) 1px, transparent 1px, transparent 4px),
        #000;
    overflow: hidden;
}

#liebiCanvas {
    width: min(100%, calc((var(--viewport-height) - 180px) * 1.64));
    max-height: calc(var(--viewport-height) - 180px);
    aspect-ratio: 18 / 11;
    display: block;
    background: #000;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.liebi-hud {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-content: start;
}

.liebi-panel {
    border: 1px solid rgba(32, 194, 14, 0.24);
    background: rgba(0, 12, 6, 0.72);
    padding: 8px;
    min-width: 0;
}

.liebi-panel.wide {
    grid-column: 1 / -1;
}

.liebi-label {
    color: var(--amber);
    font-size: var(--font-size-tiny);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.liebi-value {
    color: var(--phosphor);
    font-size: var(--font-size-small);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.liebi-bar {
    height: 8px;
    border: 1px solid rgba(32, 194, 14, 0.35);
    background: rgba(0, 0, 0, 0.55);
    overflow: hidden;
}

.liebi-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--red), var(--amber), var(--phosphor));
    transform-origin: left center;
}

.liebi-modal {
    position: absolute;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(0, 0, 0, 0.72);
    text-align: center;
    padding: 18px;
}

.liebi-modal.active {
    display: grid;
}

.liebi-modal-card {
    width: min(420px, 100%);
    border: 1px solid var(--amber);
    background: rgba(2, 9, 5, 0.96);
    padding: 20px;
    box-shadow: 0 0 30px rgba(255, 176, 0, 0.16);
}

.liebi-modal-title {
    color: var(--amber);
    font-size: var(--font-size-title);
    margin-bottom: 10px;
}

.liebi-modal-text {
    color: var(--phosphor);
    font-size: var(--font-size-small);
    margin-bottom: 16px;
}

.liebi-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.liebi-action {
    border: 1px solid rgba(32, 194, 14, 0.5);
    background: rgba(0, 28, 0, 0.86);
    color: var(--phosphor);
    font-family: var(--terminal-font);
    padding: 9px 14px;
    min-height: 38px;
    cursor: pointer;
}

.liebi-action.secondary {
    border-color: rgba(255, 176, 0, 0.48);
    color: var(--amber);
    background: rgba(20, 12, 0, 0.78);
}

@media (max-width: 760px) {
    .liebi-shell {
        max-height: calc(var(--viewport-height) - 20px);
    }

    .liebi-topbar,
    .liebi-footer {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .liebi-stage {
        grid-template-columns: 1fr;
        overflow: auto;
    }

    #liebiCanvas {
        width: 100%;
        max-height: 52vh;
    }

    .liebi-hud {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* ===== NAV HINT ===== */
.nav-hint {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-tiny);
    opacity: 0;
    z-index: 150;
    transition: opacity 0.3s;
}
.nav-hint.visible { opacity: 0.4; }

/* ===== HIDDEN ===== */
#fileInput,
#statusFileInput { display: none; }

/* ===== RESPONSIVE ===== */
@media (max-width: 800px) {
    .menu-panel { width: 200px; }
    .header-info { display: none; }
}
@media (max-width: 600px) {
    .menu-panel { width: 160px; }
    .menu-item { padding: 0 10px; font-size: var(--font-size-small); }
}
@media (max-width: 700px) {
    :root { --scanline-alpha: 0.055; }
    .screen-content { padding: 8px; }
    .header-bar { height: 72px; margin-bottom: 8px; }
    .main-container { flex-direction: column; gap: 8px; }
    .menu-panel { width: 100%; max-height: min(240px, 38vh); }
    .menu-title { padding: 6px 10px; }
    .menu-list {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 2px;
        padding: 4px;
        overflow: hidden;
    }
    .menu-separator { display: none; }
    .menu-item {
        height: clamp(32px, 7.2vh, 40px);
        min-height: clamp(32px, 7.2vh, 40px);
        padding: 0 8px;
        gap: 7px;
        font-size: clamp(10px, 2.6vw, 12px);
    }
    .menu-item .icon { width: 14px; }
    .menu-footer { display: none; }
    .admin-badge { padding: 5px; }
    .admin-badge.active { display: none; }
    .content-toolbar, .input-area { padding: 8px 10px; }
    .content-area { padding: 8px 10px; }
    .boot-screen { padding: 12px; gap: 10px; }
    .boot-output { font-size: 12px; line-height: 1.22; }
    .boot-left { min-height: 0; padding-inline: 0; }
    .boot-status { margin-left: 0.45ch; }
    .boot-logo-inline { font-size: clamp(6px, 1.9vw, 11px); padding-top: 5vh; }
    .boot-skip {
        right: 12px;
        bottom: 12px;
        right: max(12px, env(safe-area-inset-right));
        bottom: max(12px, env(safe-area-inset-bottom));
    }
}

@media (update: slow), (pointer: coarse) {
    :root {
        --scanline-alpha: 0.045;
        --crt-band-opacity: 0.45;
    }

    .glow {
        text-shadow: 0 0 1px currentColor;
    }
}

@media (min-width: 1400px) {
    :root {
        --font-size-base: 15px;
        --font-size-title: 19px;
        --font-size-small: 12px;
        --font-size-tiny: 11px;
    }
}
@media (min-width: 1900px) {
    :root {
        --font-size-base: 16px;
        --font-size-title: 20px;
        --font-size-small: 13px;
        --font-size-tiny: 12px;
    }
}

@media (prefers-contrast: more) {
    :root {
        --phosphor: #39ff14;
        --phosphor-dim: #176d12;
        --amber: #ffd15c;
        --cyan: #40f7d0;
        --scanline-alpha: 0.035;
    }

    .glow,
    .system-title,
    .page-indicator,
    .prompt,
    .t-amber,
    .t-red,
    .t-cyan,
    .t-magenta,
    .t-bright {
        text-shadow: none;
    }
}

@media (forced-colors: active) {
    *,
    *::before,
    *::after {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    .crt-monitor::before,
    .crt-monitor::after,
    .crt-band {
        display: none;
    }

    .menu-item.selected,
    .menu-item:focus-visible,
    .dialog-btn:focus-visible,
    .diagnostic-close:focus-visible,
    .facility-close:focus-visible,
    .boot-skip:focus-visible,
    #commandInput:focus-visible {
        outline: 2px solid Highlight;
        outline-offset: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .screen-content,
    .admin-badge,
    .cursor-block,
    .boot-caret::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }

    .crt-band {
        display: none;
    }

    .boot-logo,
    .boot-screen,
    .boot-line,
    .menu-item,
    .menu-item::after,
    .dialog-btn,
    .nav-hint {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
