@import url('https://fonts.googleapis.com/css2?family=Antonio:wght@400;700&display=swap');

:root {
    --purple: #C492D4; 
    --blue: #87B3D6; 
    --tan: #E8BA87; 
    --orange: #F2A93B;
    --amber: #ffbf00;
    --red: #D9453E; 
    --cyan: #00f2ff; 
    --black: #000000; 
    --bg-dark: #050505;
    --radius: 6vmin; 
    --gap: 1.5vmin;
    --scanline: repeating-linear-gradient(to bottom, transparent, transparent 0.2vmin, rgba(0,0,0,0.3) 0.2vmin, rgba(0,0,0,0.3) 0.4vmin);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Antonio', sans-serif; 
    text-transform: uppercase; 
    user-select: none; 
}

body { 
    background: var(--black); 
    color: var(--orange); 
    height: 100vh; 
    width: 100vw; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    overflow: hidden; 
}

.crt-overlay { 
    position: fixed; 
    inset: 0; 
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%); 
    background-size: 100% 0.5vmin; 
    pointer-events: none; 
    z-index: 2000; 
}

.touch-target { cursor: pointer; }
.touch-target:focus, .touch-target:active { 
    outline: 0.3vmin solid var(--tan); 
    box-shadow: 0 0 2vmin var(--tan); 
}

/* LCARS LAYOUT ELEMENTS */
.lcars-layout { 
    display: flex; 
    flex-direction: column; 
    width: 100vw; 
    height: 100vh; 
    padding: 2vmin; 
    gap: var(--gap); 
}

.lcars-header { display: flex; height: 8vmin; gap: var(--gap); }

.lcars-elbow-tl { 
    width: 30vmin; 
    background: var(--purple); 
    border-top-left-radius: var(--radius); 
    display: flex; 
    align-items: flex-end; 
    justify-content: flex-end; 
    padding: 1.5vmin 2.5vmin; 
    background-image: var(--scanline); 
}

.lcars-title { font-size: 4.5vmin; font-weight: bold; letter-spacing: 0.2vmin;}

.lcars-top-bar { 
    display: flex; 
    flex: 1; 
    gap: var(--gap); 
    height: 5.5vmin; 
    align-self: flex-start;
}

.bar-seg { 
    flex: 1; 
    padding: 0 2.5vmin; 
    font-size: 3vmin; 
    display: flex; 
    align-items: center; 
    font-weight: bold; 
    background-image: var(--scanline); 
}

.text-right { justify-content: flex-end; }
.flex-2 { flex: 2; }
.flex-3 { flex: 3; }
.flex-1 { flex: 1; }

.lcars-body { 
    display: flex; 
    flex: 1; 
    gap: var(--gap); 
    min-height: 0;
}

.lcars-sidebar { 
    width: 30vmin; 
    display: flex; 
    flex-direction: column; 
    gap: var(--gap); 
}

.side-status { 
    height: 8vmin; 
    padding: 1.5vmin; 
    font-size: 3.5vmin; 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    font-weight: bold; 
    background-image: var(--scanline);
}

.lcars-block-fill { flex: 1; background-image: var(--scanline); }

.lcars-block { 
    height: 6.5vmin; 
    padding-right: 2.5vmin; 
    font-size: 3.5vmin; 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    font-weight: bold; 
    background-image: var(--scanline); 
}

/* NEW: BUTTON OVERRIDE FOR SIDEBAR NAVIGATION */
.nav-btn {
    border: none;
    width: 100%;
    cursor: pointer;
    text-align: right;
    transition: filter 0.2s;
    font-family: inherit;
}
.nav-btn:hover { filter: brightness(1.2); }

.lcars-elbow-bl { 
    height: 12vmin; 
    border-bottom-left-radius: var(--radius); 
    background-image: var(--scanline); 
    background-color: var(--orange); 
}

.lcars-content-wrapper { 
    flex: 1; 
    border-left: 0.4vmin solid #223; 
    border-bottom: 0.4vmin solid #223; 
    background: var(--bg-dark); 
    position: relative;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
}

/* STRICT CENTERING CONTAINER */
.lcars-content-centerer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4vmin;
    position: relative;
}

.lcars-bottom-row { 
    display: flex; 
    gap: var(--gap); 
    padding-left: calc(30vmin + var(--gap)); 
    height: 5.5vmin; 
}

#initView { 
    position: fixed; 
    inset: 0; 
    background: var(--black); 
    z-index: 2000; 
    display: none; 
    align-items: center; 
    justify-content: center; 
}

#initView.active { display: flex; }

.init-wrapper { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    width: 100%; 
    height: 100%; 
}

.lcars-btn { 
    background: var(--scanline), var(--bg-dark); 
    border: 0.3vmin solid var(--orange); 
    color: var(--orange); 
    padding: 2vmin 6vmin; 
    font-size: 4vmin; 
    border-radius: 5vmin; 
    transition: 0.3s; 
    margin-top: 4vmin; 
    font-weight: bold;
}

.lcars-btn:hover { 
    background: var(--scanline), var(--orange); 
    color: var(--black); 
    box-shadow: 0 0 4vmin var(--orange); 
}

/* AUTH VIEW & KEYPAD */
.auth-layout { display: flex; width: 100%; height: 100%; justify-content: center; align-items: center; gap: 8vmin;}
.auth-left { display: flex; flex-direction: column; width: 45%; justify-content: center;}
.boot-scanner { width: 100%; margin-bottom: 4vmin; display: flex; flex-direction: column; justify-content: center; padding-left: 2vmin; position: relative;}
.scanner-text { font-family: monospace; font-size: 3vmin; letter-spacing: 1.5vmin; line-height: 1.5; opacity: 0.8; }
.scanner-beam { position: absolute; top: 0; left: 0; width: 100%; height: 6vmin; background: linear-gradient(to bottom, rgba(135,179,214,0), rgba(135,179,214,0.6), rgba(135,179,214,0)); animation: scanBeam 2s linear infinite alternate; pointer-events: none;}
@keyframes scanBeam { 0% { transform: translateY(-2vmin); } 100% { transform: translateY(12vmin); } }
.keypad-display { font-size: 8vmin; letter-spacing: 2.5vmin; text-align: right; border-bottom: 0.5vmin dashed var(--orange); margin-bottom: 3vmin; padding-right: 2vmin; width: 100%; max-width: 60vmin;}
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5vmin; width: 100%; max-width: 60vmin; }
.lcars-pill { height: 7vmin; border: none; border-radius: 3.5vmin; font-size: 3.5vmin; font-weight: bold; cursor: pointer; text-align: right; padding-right: 3vmin; color: #000; background-image: var(--scanline); transition: 0.2s;}
.lcars-pill:hover { filter: brightness(1.2); }
.auth-msg { font-size: 4vmin; margin-top: 2vmin; text-align: right; max-width: 60vmin;}
.auth-right { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border-left: 0.4vmin solid #223; padding-left: 5vmin; height: 100%; }
.starfleet-emblem { width: 45vmin; height: 45vmin; filter: drop-shadow(0 0 3vmin var(--orange)); position: relative; }
.emblem-layer-solid { transform-origin: center; animation: spinY 8s linear infinite; }
.emblem-layer-wire { transform-origin: center; animation: spinYRev 12s linear infinite; }
@keyframes spinY { 0% { transform: rotateY(0deg); } 100% { transform: rotateY(360deg); } }
@keyframes spinYRev { 0% { transform: rotateY(360deg); } 100% { transform: rotateY(0deg); } }
.hologram-text { margin-top: 6vmin; font-size: 3vmin; letter-spacing: 0.8vmin; text-align: center; opacity: 0.9; }

/* COMMAND MAIN VIEW */
.command-grid { display: flex; flex-direction: column; gap: 2.5vmin; margin-top: 4vmin; align-items: center; width: 100%;}
.cmd-row { display: flex; align-items: center; gap: 1.5vmin; }
.label-pill { width: 22vmin; height: 8vmin; border-radius: 4vmin 0 0 4vmin; display: flex; align-items: center; justify-content: flex-end; padding-right: 2.5vmin; font-size: 3.5vmin; color: #000; font-weight: bold; background-image: var(--scanline); }
.lcars-btn-rect { background: rgba(0,0,0,0.4); border: 0.4vmin solid; height: 8vmin; padding: 0 3.5vmin; font-size: 3.5vmin; border-radius: 4vmin; display: flex; align-items: center; justify-content: flex-end; background-image: var(--scanline); cursor: pointer; min-width: 45vmin; transition: 0.2s;}
.lcars-btn-rect:hover { background: rgba(255,255,255,0.1); }
.lcars-btn-rect:active { filter: brightness(1.5); }
.maint-clock { font-size: 16vmin; margin: 4vmin 0; }
.progress-bar-container { height: 5vmin; border: 0.4vmin solid var(--orange); border-radius: 2.5vmin; overflow: hidden; width: 100%; margin-top: 4vmin;}
.progress-bar-fill { height: 100%; width: 0%; background-image: var(--scanline);}
.auth-center-layout { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.5vmin; width: 100%;}
.destruct-clock { font-size: 22vmin; text-align: center; font-weight: bold; letter-spacing: 1vmin; }
.destruct-msg { font-size: 5vmin; text-align: center; margin-bottom: 5vmin; }
.action-buttons { display: flex; gap: 3vmin; }

/* UPLINK GRIDS & SPINNERS */
.spinner { width: 10vmin; height: 10vmin; border: 1vmin solid transparent; border-top-color: currentColor; border-bottom-color: currentColor; border-radius: 50%; animation: spinY 2s linear infinite; }
.uplink-source-stream { width: 20vmin; height: 100%; border-right: 0.3vmin solid var(--cyan); padding-right: 2vmin; overflow: hidden; }
#keygenStream { font-family: monospace; font-size: 2vmin; line-height: 1.5; word-break: break-all; opacity: 0.7; height: 40vmin; overflow: hidden;}
.bit-grid { display: grid; grid-template-columns: repeat(16, 1fr); gap: 0.6vmin; font-family: monospace; font-size: 1.5vmin; color: var(--cyan); width: 100%; }
.bit-cell { background: rgba(0, 242, 255, 0.05); padding: 0.4vmin; text-align: center; border: 0.1vmin solid rgba(0, 242, 255, 0.2); transition: 0.1s; }
.bit-cell.locked { background: var(--cyan); color: var(--black); font-weight: bold; box-shadow: 0 0 1vmin var(--cyan); }

/* HIGH-FIDELITY DIAGNOSTIC VIEW */
.diag-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2vmin; padding-bottom: 2vmin; border-bottom: 0.3vmin solid var(--purple); width: 100%;}
.diag-container { display: flex; width: 100%; flex: 1; gap: 4vmin; overflow: hidden;}
.diag-visual { flex: 1; border: 0.2vmin solid var(--purple); position: relative; background: rgba(196, 146, 212, 0.05); display: flex; align-items: center; justify-content: center; overflow: hidden;}
.diag-svg { width: 80%; height: 80%; }
.radar-sweep { position: absolute; width: 200%; height: 200%; top: -50%; left: -50%; background: conic-gradient(from 0deg, transparent 70%, rgba(196, 146, 212, 0.4) 100%); border-radius: 50%; animation: radarSpin 4s linear infinite; pointer-events: none;}
@keyframes radarSpin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.diag-grid-container { flex: 2; border: 0.2vmin solid var(--purple); padding: 2vmin; background: rgba(196, 146, 212, 0.02);}
.diag-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5vmin; height: 100%; overflow-y: hidden; align-content: start;}
.diag-item { font-family: monospace; font-size: 2vmin; color: var(--purple); opacity: 0.3; transition: 0.2s; display: flex; justify-content: space-between; padding: 0.5vmin; border-bottom: 0.1vmin solid rgba(196, 146, 212, 0.2);}
.diag-item.scanned { opacity: 1; font-weight: bold; background: rgba(196,146,212,0.15); border-color: var(--purple); box-shadow: inset 0 0 1vmin rgba(196,146,212,0.5);}

/* COMM VIEW EQ & LOG */
.eq-container { display: flex; align-items: flex-end; gap: 0.5vmin; height: 20vmin; border-bottom: 0.3vmin solid var(--tan); padding-bottom: 1vmin; width: 100%; margin-top: 2vmin; }
.eq-bar { flex: 1; background-color: var(--tan); min-height: 5%; transition: height 0.15s ease-out; box-shadow: 0 0 1vmin var(--tan);}
.comm-log { flex: 1; border: 0.3vmin solid var(--tan); padding: 2vmin; overflow: hidden; background: rgba(232, 186, 135, 0.05); display: flex; flex-direction: column; gap: 1vmin;}
.comm-log-item { font-family: monospace; font-size: 2.2vmin; color: var(--tan); border-left: 0.5vmin solid var(--tan); padding-left: 1.5vmin; opacity: 0.8; animation: fadeIn 0.2s ease-out; background: rgba(232, 186, 135, 0.1);}

/* UTILITIES */
.bg-purple { background-color: var(--purple); } .bg-blue { background-color: var(--blue); } .bg-tan { background-color: var(--tan); } .bg-orange { background-color: var(--orange); } .bg-red { background-color: var(--red); } .bg-cyan { background-color: var(--cyan); }
.text-orange { color: var(--orange); } .text-cyan { color: var(--cyan); } .text-red { color: var(--red); } .text-blue { color: var(--blue); } .text-purple { color: var(--purple); } .text-tan { color: var(--tan); } .text-black { color: #000; } .text-amber { color: var(--amber); }
.border-blue { border-color: var(--blue); } .border-purple { border-color: var(--purple); } .border-orange { border-color: var(--orange); } .border-red { border-color: var(--red); } .border-tan { border-color: var(--tan); } .border-cyan { border-color: var(--cyan); }

.glow-text { text-shadow: 0 0 2vmin var(--orange); }
.glow-text-cyan { text-shadow: 0 0 2vmin var(--cyan); }
.blink { animation: bl 1s steps(2) infinite; }
@keyframes bl { 50% { opacity: 0; } }

.view { display: none; width: 100%; height: 100%; flex-direction: column; align-items: center; justify-content: center;}
.view.active { display: flex; animation: fadeIn 0.4s ease-out forwards;}
@keyframes fadeIn { from { opacity: 0; transform: translateY(1vmin);} to { opacity: 1; transform: translateY(0); } }
.hidden { display: none !important; }

/* RED ALERT MODE */
body.red-alert-mode .bg-orange, body.red-alert-mode .bg-purple, body.red-alert-mode .bg-tan, body.red-alert-mode .bg-blue { background-color: var(--red) !important; color: var(--black) !important;}
body.red-alert-mode .delta-outer, body.red-alert-mode .delta-inner, body.red-alert-mode .emblem-layer-outer, body.red-alert-mode .emblem-layer-solid, body.red-alert-mode .emblem-layer-wire { stroke: var(--red) !important; fill: var(--red) !important; }
body.red-alert-mode .starfleet-emblem { filter: drop-shadow(0 0 3vmin var(--red)); }

.static-error { text-shadow: 0 0 2vmin var(--red); }
.glitch-local { animation: textGlitch 0.2s infinite; text-shadow: 0.3vmin 0 0 blue, -0.3vmin 0 0 yellow; }
@keyframes textGlitch { 0% { transform: translate(0); } 25% { transform: translate(-0.2vmin, 0.2vmin); } 50% { transform: translate(0.2vmin, -0.2vmin); } 75% { transform: translate(-0.2vmin, -0.2vmin); } 100% { transform: translate(0.2vmin, 0.2vmin); } }
.omega-mask { font-family: 'Antonio', sans-serif; letter-spacing: 2vmin; }
.input-box { text-align: center; width: 35vmin; justify-content: center; }

/* --- REALISTIC S31 LAYOUT --- */
.s31-realistic-layout { display: flex; width: 100%; height: 100%; justify-content: space-between; align-items: stretch; gap: 4vmin; }
.s31-panel { flex: 1; display: flex; flex-direction: column; border: 0.3vmin solid var(--cyan); background: rgba(0, 242, 255, 0.03); overflow: hidden; }
.s31-header { padding: 1vmin; text-align: center; font-weight: bold; font-size: 2.5vmin; letter-spacing: 0.5vmin; }
.s31-terminal { flex: 1; padding: 2vmin; display: flex; flex-direction: column; overflow: hidden; gap: 1vmin; }
.s31-log-line { font-family: monospace; font-size: 2vmin; opacity: 0.8; }
.s31-hex-line { font-family: monospace; font-size: 2vmin; opacity: 0.6; }
.s31-main-center { flex: 1.5; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.s31-radar { width: 35vmin; height: 35vmin; margin-bottom: 2vmin; }
.s31-sweep { transform-origin: center; animation: radarSpin 2s linear infinite; }
.glitch-effect { animation: cyberGlitch 3s infinite; }
@keyframes cyberGlitch { 0% { filter: drop-shadow(0 0 3vmin var(--cyan)); opacity:1; } 2% { opacity:0.6; filter: drop-shadow(0 0 4vmin red); } 4% { filter: drop-shadow(0 0 3vmin var(--cyan)); opacity:1; } }
.s31-code-box { font-family: monospace; font-size: 9vmin; letter-spacing: 2.5vmin; text-shadow: 0 0 3vmin var(--cyan); margin-bottom: 4vmin; text-align: center;}
.s31-progress-bg { width: 80%; height: 3vmin; border: 0.3vmin solid var(--cyan); border-radius: 1.5vmin; overflow: hidden; background: rgba(0, 242, 255, 0.05); }
.s31-progress-fill { height: 100%; width: 0%; box-shadow: 0 0 3vmin var(--cyan); transition: width 0.3s linear; }
.s31-locks { display: flex; gap: 2vmin; margin-bottom: 4vmin; }
.s31-lock { width: 5vmin; height: 2.5vmin; border: 0.3vmin solid var(--red); background: rgba(255,0,0,0.1); border-radius: 0.5vmin; transition: 0.3s;}
.s31-lock.unlocked { border-color: #0F0; background: #0F0; box-shadow: 0 0 3vmin #0F0; }

/* --- SPLIT DESTRUCT LAYOUT --- */
.destruct-split-layout { display: flex; width: 100%; height: 100%; justify-content: center; align-items: center; gap: 8vmin; }
.destruct-split-left { display: flex; flex-direction: column; align-items: center; width: 45vmin; }
.destruct-split-right { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 45vmin; height: 60vmin; border: 0.4vmin solid var(--red); background: rgba(217, 69, 62, 0.05); padding: 4vmin; box-shadow: inset 0 0 5vmin rgba(217, 69, 62, 0.2); border-radius: 4vmin;}
.warning-graphic { width: 20vmin; height: 20vmin; margin-bottom: 4vmin; filter: drop-shadow(0 0 2vmin var(--red)); }