/* ============================================================
   THE GIBSON — Cyberspace Interface + CRT Monitor
   Inspired by Hackers (1995)
   ============================================================ */

:root {
    /* Neon palette */
    --green:    #00ff41;
    --green-dim:#00aa2a;
    --cyan:     #16f0ff;
    --magenta:  #ff2bd6;
    --amber:    #ffb000;
    --yellow:   #fff200;
    --red:      #ff2b4e;
    --white:    #d7fbff;

    /* Surfaces */
    --screen-bg:   #03070b;
    --screen-bg-2: #061015;
    --room-bg:     #050406;

    /* Monitor plastic */
    --case-light: #3a3d44;
    --case-mid:   #24262b;
    --case-dark:  #131418;
    --case-edge:  #0a0b0d;

    --glow: 0.85;
    --scanline-opacity: 0.14;

    /* Motion language */
    --ease:     cubic-bezier(.4, .14, .3, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --t-fast: 150ms;
    --t-med:  280ms;
    --t-slow: 440ms;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--room-bg);
}

body {
    font-family: 'Share Tech Mono', 'VT323', monospace;
    font-size: 18px;
    line-height: 1.2;
    color: var(--green);
    -webkit-font-smoothing: none;
}

/* ============================================================
   ROOM + DESK
   ============================================================ */
.room {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(ellipse 60% 50% at 50% 38%, rgba(0, 255, 120, 0.10), transparent 70%),
        radial-gradient(ellipse at 50% 120%, #0b0a10 0%, var(--room-bg) 60%);
    perspective: 1400px;
    overflow: hidden;
}

/* Ambient bloom thrown from the screen onto the room */
.room-glow {
    position: absolute;
    top: 18%;
    left: 50%;
    width: 70vw;
    height: 60vh;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(22, 240, 255, 0.12), rgba(255, 43, 214, 0.06) 40%, transparent 72%);
    filter: blur(40px);
    pointer-events: none;
    z-index: 0;
    animation: ambient-pulse 6s ease-in-out infinite;
}

@keyframes ambient-pulse {
    0%, 100% { opacity: 0.75; }
    50%      { opacity: 1; }
}

/* Desk surface the monitor sits on */
.desk {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 26%;
    background:
        linear-gradient(180deg, transparent, rgba(0,0,0,0.4)),
        repeating-linear-gradient(90deg, #15110d 0 2px, #1b1610 2px 60px),
        linear-gradient(180deg, #221b14 0%, #0c0a08 100%);
    transform: perspective(600px) rotateX(60deg);
    transform-origin: bottom center;
    box-shadow: inset 0 8px 30px rgba(0,0,0,0.7);
    z-index: 0;
}

/* ============================================================
   CRT MONITOR — physical casing
   ============================================================ */
.crt-monitor {
    position: relative;
    z-index: 2;
    width: min(92vw, 1080px);
    max-height: 82vh;
    aspect-ratio: 4 / 3.15;
    padding: clamp(18px, 2.4vw, 34px);
    border-radius: 26px 26px 22px 22px;
    background:
        linear-gradient(180deg, var(--case-light) 0%, var(--case-mid) 16%, var(--case-mid) 78%, var(--case-dark) 100%);
    box-shadow:
        inset 0 2px 1px rgba(255,255,255,0.10),
        inset 0 -28px 40px rgba(0,0,0,0.55),
        inset 0 0 0 2px rgba(0,0,0,0.4),
        0 30px 60px rgba(0,0,0,0.75),
        0 6px 16px rgba(0,0,0,0.6);
}

/* Side venting texture */
.crt-monitor::before,
.crt-monitor::after {
    content: "";
    position: absolute;
    top: 22%;
    width: 10px;
    height: 46%;
    background: repeating-linear-gradient(180deg, rgba(0,0,0,0.45) 0 3px, transparent 3px 7px);
    border-radius: 4px;
    opacity: 0.6;
}
.crt-monitor::before { left: 7px; }
.crt-monitor::after  { right: 7px; }

/* Inner bezel framing the glass */
.crt-bezel {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 18px;
    padding: clamp(10px, 1.4vw, 20px);
    background: linear-gradient(160deg, #1a1c20, #0a0b0d 70%);
    box-shadow:
        inset 0 0 0 1px rgba(255,255,255,0.04),
        inset 0 3px 8px rgba(0,0,0,0.9),
        inset 0 -2px 6px rgba(255,255,255,0.03);
}

/* ============================================================
   THE GLASS / SCREEN
   ============================================================ */
.crt-screen {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50% / 6%;          /* subtle tube bulge top/bottom */
    border-radius: 14px;
    overflow: hidden;
    background:
        radial-gradient(ellipse 120% 130% at 50% 50%, var(--screen-bg-2) 0%, var(--screen-bg) 60%, #010304 100%);
    box-shadow:
        inset 0 0 70px rgba(0,0,0,0.85),
        inset 0 0 14px rgba(0, 255, 120, 0.10);
    transform: perspective(900px) rotateX(0.4deg);
}

.screen-content {
    position: absolute;
    inset: 0;
    z-index: 1;
    /* gentle barrel curvature on everything drawn to screen */
    transform: scale(1.012);
}

.screen-view {
    position: absolute;
    inset: 0;
    overflow: hidden;
    transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
/* crossfade states used by swapView() in cyberspace.js */
.screen-view.view-in  { opacity: 0; transform: scale(1.015); }
.screen-view.view-out { opacity: 0; transform: scale(0.99); pointer-events: none; }
/* NB: #terminal / #cyberspace set `display:flex` via an ID selector, which
   out-specifies a plain `.hidden` class — list them explicitly so hiding wins. */
#terminal.hidden,
#cyberspace.hidden,
.screen-view.hidden,
.hidden { display: none !important; }

/* ----- Screen effect overlays ----- */
.crt-scanlines, .crt-mask, .crt-vignette, .crt-glare, .crt-flicker {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.crt-scanlines {
    z-index: 20;
    background: repeating-linear-gradient(
        0deg,
        rgba(0,0,0,var(--scanline-opacity)) 0,
        rgba(0,0,0,var(--scanline-opacity)) 1px,
        transparent 1px,
        transparent 3px
    );
}
/* slow rolling brightness band */
.crt-scanlines::after {
    content: "";
    position: absolute;
    left: 0; right: 0;
    height: 30%;
    background: linear-gradient(180deg, transparent, rgba(120,255,200,0.045), transparent);
    animation: scan-roll 7s linear infinite;
}
@keyframes scan-roll {
    0%   { top: -30%; }
    100% { top: 100%; }
}

/* shadow-mask (RGB subpixel) + faint chromatic fringe */
.crt-mask {
    z-index: 21;
    background: repeating-linear-gradient(
        90deg,
        rgba(255,0,60,0.05) 0,
        rgba(0,255,90,0.04) 1px,
        rgba(40,120,255,0.05) 2px,
        transparent 3px
    );
    mix-blend-mode: screen;
    opacity: 0.5;
}

.crt-vignette {
    z-index: 22;
    background:
        radial-gradient(ellipse 100% 100% at 50% 50%, transparent 55%, rgba(0,0,0,0.55) 100%),
        radial-gradient(ellipse 130% 120% at 12% 8%, rgba(22,240,255,0.05), transparent 40%),
        radial-gradient(ellipse 130% 120% at 88% 92%, rgba(255,43,214,0.05), transparent 40%);
}

/* glass glare / reflection sheen */
.crt-glare {
    z-index: 23;
    background:
        linear-gradient(135deg, rgba(255,255,255,0.07) 0%, transparent 26%),
        radial-gradient(circle at 78% 14%, rgba(255,255,255,0.05), transparent 22%);
}

.crt-flicker {
    z-index: 24;
    background: rgba(180, 255, 220, 0.02);
    opacity: 0;
    animation: flicker 0.18s infinite;
}
@keyframes flicker {
    0%   { opacity: 0; }
    5%   { opacity: 0.03; }
    10%  { opacity: 0; }
    16%  { opacity: 0.05; }
    22%  { opacity: 0; }
    100% { opacity: 0; }
}

/* ===== Channel-change glitch wipe (fires on every mode switch) ===== */
#mode-wipe {
    position: absolute;
    inset: 0;
    z-index: 40;
    pointer-events: none;
    opacity: 0;
    mix-blend-mode: screen;
    background: linear-gradient(180deg,
        transparent 44%,
        rgba(180,255,240,0.55) 49%,
        rgba(255,255,255,0.9) 50%,
        rgba(180,255,240,0.55) 51%,
        transparent 56%);
    background-size: 100% 45%;
    background-repeat: no-repeat;
}
#mode-wipe.active { animation: mode-wipe 380ms ease-in-out; }
@keyframes mode-wipe {
    0%   { opacity: 0; background-position: 0 -45%; }
    12%  { opacity: 1; }
    88%  { opacity: 1; }
    100% { opacity: 0; background-position: 0 145%; }
}

/* brief chromatic jitter on the whole screen during a switch
   (base .screen-content transform is scale(1.012) — preserved in every frame) */
.screen-content.glitching { animation: content-glitch 360ms steps(3, end); }
@keyframes content-glitch {
    0%   { transform: scale(1.012) translateX(0);    filter: none; }
    20%  { transform: scale(1.012) translateX(-3px); filter: drop-shadow(3px 0 0 var(--magenta)) drop-shadow(-3px 0 0 var(--cyan)); }
    45%  { transform: scale(1.012) translateX(3px);  filter: drop-shadow(-2px 0 0 var(--magenta)) drop-shadow(2px 0 0 var(--cyan)); }
    70%  { transform: scale(1.012) translateX(-2px); filter: drop-shadow(2px 0 0 var(--cyan)) drop-shadow(-2px 0 0 var(--magenta)); }
    100% { transform: scale(1.012) translateX(0);    filter: none; }
}

/* power-on / access flashes (added by terminal.js to .crt-screen) */
.flash-green { animation: flash-green 0.5s ease-out; }
@keyframes flash-green {
    0%   { box-shadow: inset 0 0 120px rgba(0,255,120,0.55); }
    100% { box-shadow: inset 0 0 70px rgba(0,0,0,0.85); }
}
.flash-red { animation: flash-red 0.3s ease-out; }
@keyframes flash-red {
    0%   { box-shadow: inset 0 0 120px rgba(255,43,78,0.5); }
    100% { box-shadow: inset 0 0 70px rgba(0,0,0,0.85); }
}

/* ============================================================
   MONITOR FACEPLATE / CONTROLS / STAND
   ============================================================ */
.crt-faceplate {
    position: absolute;
    left: 0; right: 0; bottom: 4px;
    height: clamp(16px, 2vw, 26px);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}
.crt-brand {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    letter-spacing: 3px;
    font-size: clamp(9px, 1vw, 13px);
    color: #6a6f78;
    text-shadow: 0 1px 0 rgba(0,0,0,0.8), 0 -1px 0 rgba(255,255,255,0.05);
}
.crt-controls {
    position: absolute;
    right: clamp(20px, 3vw, 44px);
    display: flex;
    align-items: center;
    gap: 9px;
}
.crt-btn {
    width: 16px; height: 5px;
    border-radius: 3px;
    background: linear-gradient(180deg, #3a3d44, #15161a);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 1px 2px rgba(0,0,0,0.7);
}
.crt-led {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green), 0 0 12px var(--green), inset 0 0 2px #fff;
    animation: led-breathe 3.5s ease-in-out infinite;
}
@keyframes led-breathe {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.55; }
}

/* Volume control on the faceplate */
.crt-volume {
    position: absolute;
    left: clamp(18px, 3vw, 44px);
    display: flex;
    align-items: center;
    gap: 8px;
}
.crt-vol-ico {
    font-family: 'Chakra Petch', sans-serif;
    font-size: clamp(8px, 0.9vw, 11px);
    letter-spacing: 1px;
    color: #6a6f78;
    text-shadow: 0 1px 0 rgba(0,0,0,0.8);
}
#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: clamp(56px, 9vw, 110px);
    height: 4px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--green-dim), #15161a);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.7);
    cursor: pointer;
}
#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green), inset 0 0 2px #fff;
    cursor: pointer;
}
#volume-slider::-moz-range-thumb {
    width: 11px; height: 11px;
    border: none;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green), inset 0 0 2px #fff;
    cursor: pointer;
}

.crt-stand {
    position: relative;
    z-index: 1;
    margin-top: -2px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.crt-neck {
    width: clamp(90px, 12vw, 150px);
    height: clamp(14px, 2vh, 26px);
    background: linear-gradient(180deg, var(--case-mid), var(--case-dark));
    box-shadow: inset 0 2px 3px rgba(255,255,255,0.05), 0 6px 10px rgba(0,0,0,0.6);
    border-radius: 0 0 8px 8px;
}
.crt-base {
    width: clamp(180px, 26vw, 340px);
    height: clamp(10px, 1.6vh, 20px);
    background: linear-gradient(180deg, var(--case-mid) 0%, var(--case-dark) 100%);
    border-radius: 10px / 40px;
    box-shadow: 0 14px 24px rgba(0,0,0,0.7), inset 0 2px 2px rgba(255,255,255,0.05);
}

/* ============================================================
   TERMINAL VIEW
   ============================================================ */
#terminal {
    display: flex;
    flex-direction: column;
    overflow: hidden;            /* the inner scroll region scrolls, not this */
    color: var(--green);
    font-family: 'VT323', monospace;
    font-size: 20px;
    line-height: 1.15;
}

/* Opaque header bar — content scrolls cleanly beneath it */
#terminal-toolbar {
    flex-shrink: 0;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, #08160e, #050f0a);
    border-bottom: 1px solid rgba(0,255,90,0.28);
    box-shadow: 0 2px 8px rgba(0,0,0,0.6);
    font-family: 'Chakra Petch', sans-serif;
    font-size: 11px;
    letter-spacing: 2px;
    z-index: 5;
}

/* Scrollable buffer */
#terminal-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 30px 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--green-dim) transparent;
}
#terminal-scroll::-webkit-scrollbar { width: 8px; }
#terminal-scroll::-webkit-scrollbar-track { background: transparent; }
#terminal-scroll::-webkit-scrollbar-thumb { background: var(--green-dim); border-radius: 4px; }

/* Boot skip hint — pinned to the bottom of the glass during connection */
#boot-skip-hint {
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 30;
    padding: 4px 14px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    letter-spacing: 2px;
    white-space: nowrap;
    color: var(--amber);
    text-shadow: 0 0 8px var(--amber);
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,176,0,0.3);
    border-radius: 4px;
    pointer-events: none;
    animation: text-blink 1.1s step-end infinite;
}
#boot-skip-hint.hidden { display: none !important; }
.tb-label { color: var(--green-dim); text-shadow: 0 0 6px rgba(0,255,90,0.4); }
#to-cyberspace {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    color: var(--cyan);
    background: transparent;
    border: 1px solid rgba(22,240,255,0.4);
    border-radius: 4px;
    padding: 3px 9px;
    cursor: pointer;
    text-shadow: 0 0 6px var(--cyan);
    transition: all 0.15s ease;
}
#to-cyberspace:hover {
    background: rgba(22,240,255,0.12);
    box-shadow: 0 0 12px rgba(22,240,255,0.4);
}

#output { white-space: pre-wrap; word-wrap: break-word; line-height: 1.1; }
#output .line { text-shadow: 0 0 5px var(--green), 0 0 10px rgba(0,255,65,0.5); }
#output .command-line { margin-top: 10px; }

#input-line { display: flex; align-items: center; margin-top: 10px; }
#input-line.hidden { display: none; }

.prompt {
    color: var(--green);
    text-shadow: 0 0 5px var(--green), 0 0 10px var(--green);
    white-space: pre;
    flex-shrink: 0;
}
/* Real input is kept invisible but ON-SCREEN (1px) so focusing it never
   scrolls the buffer sideways. The visible text is mirrored by the spans below. */
#command-input {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}
#input-display, #input-after {
    color: var(--green);
    font-family: 'VT323', monospace;
    font-size: 20px;
    text-shadow: 0 0 5px var(--green), 0 0 10px var(--green);
    white-space: pre;
}
.cursor {
    text-shadow: 0 0 5px var(--green), 0 0 10px var(--green);
    text-decoration: underline;
    text-decoration-color: var(--green);
    animation: blink-underline 0.7s step-end infinite;
}
@keyframes blink-underline {
    0%, 100% { text-decoration: underline; }
    50%      { text-decoration: none; }
}

/* ----- Terminal text colors ----- */
.green   { color: var(--green); }
.amber   { color: var(--amber);   text-shadow: 0 0 5px var(--amber), 0 0 10px var(--amber); }
.cyan    { color: var(--cyan);    text-shadow: 0 0 5px var(--cyan), 0 0 10px var(--cyan); }
.magenta { color: var(--magenta); text-shadow: 0 0 5px var(--magenta), 0 0 10px var(--magenta); }
.yellow  { color: var(--yellow);  text-shadow: 0 0 5px var(--yellow), 0 0 10px var(--yellow); }
.dim     { color: var(--green-dim); text-shadow: 0 0 3px var(--green-dim); }
.blink   { animation: text-blink 1s step-end infinite; }
@keyframes text-blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

.boot-text    { color: var(--green-dim); }
.boot-ok      { color: var(--green); text-shadow: 0 0 5px var(--green); }
.boot-warning { color: var(--amber); }
.boot-error   { color: var(--red); text-shadow: 0 0 5px var(--red); }

.ascii, .ascii-art {
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.0;
    white-space: pre;
    color: var(--cyan);
    text-shadow: 0 0 5px var(--cyan);
}

.skill-bar {
    display: inline-block;
    width: 200px; height: 12px;
    background: var(--screen-bg-2);
    border: 1px solid var(--green-dim);
    margin-left: 10px;
    vertical-align: middle;
}
.skill-bar-fill { height: 100%; background: var(--green); box-shadow: 0 0 5px var(--green); }

/* ============================================================
   CYBERSPACE VIEW
   ============================================================ */
#cyberspace {
    display: flex;
    flex-direction: column;
    color: var(--cyan);
    font-family: 'Share Tech Mono', monospace;
    background: radial-gradient(ellipse at 50% 30%, #061018 0%, #03060a 55%, #010204 100%);
}

/* Tron perspective grid floor */
.cyber-grid {
    position: absolute;
    left: -25%;
    bottom: -10%;
    width: 150%;
    height: 70%;
    background-image:
        linear-gradient(rgba(22,240,255,0.35) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22,240,255,0.25) 1px, transparent 1px);
    background-size: 46px 46px;
    transform: perspective(420px) rotateX(70deg);
    transform-origin: 50% 100%;
    animation: grid-flow 2.4s linear infinite;
    -webkit-mask-image: linear-gradient(transparent, #000 40%);
    mask-image: linear-gradient(transparent, #000 40%);
    opacity: 0.55;
    pointer-events: none;
}
@keyframes grid-flow {
    0%   { background-position: 0 0; }
    100% { background-position: 0 46px; }
}

/* drifting data motes */
.cyber-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(22,240,255,0.7), transparent),
        radial-gradient(1px 1px at 70% 20%, rgba(255,43,214,0.6), transparent),
        radial-gradient(1px 1px at 40% 70%, rgba(0,255,90,0.6), transparent),
        radial-gradient(1px 1px at 85% 60%, rgba(255,176,0,0.6), transparent),
        radial-gradient(1px 1px at 60% 45%, rgba(22,240,255,0.5), transparent),
        radial-gradient(1px 1px at 10% 80%, rgba(255,43,214,0.5), transparent);
    animation: star-drift 9s ease-in-out infinite alternate;
    opacity: 0.7;
}
@keyframes star-drift {
    0%   { transform: translateY(0); }
    100% { transform: translateY(-14px); }
}

.cyber-hud {
    position: relative;
    z-index: 4;
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--cyan);
    text-shadow: 0 0 6px var(--cyan);
}
.cyber-hud .dim { color: rgba(22,240,255,0.4); text-shadow: none; }
.cyber-hud .ok  { color: var(--green); text-shadow: 0 0 6px var(--green); }

.cyber-title {
    position: relative;
    z-index: 4;
    text-align: center;
    margin-top: 4px;
    font-family: 'Monoton', 'Chakra Petch', cursive;
    font-weight: 400;
    font-size: clamp(24px, 4.8vw, 58px);
    letter-spacing: clamp(2px, 0.6vw, 7px);
    background: linear-gradient(90deg, var(--cyan), var(--magenta), var(--green), var(--cyan));
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 14px rgba(22,240,255,0.5));
    animation: title-hue 6s linear infinite;
}
@keyframes title-hue { 0% { background-position: 0% 0; } 100% { background-position: 300% 0; } }

/* glitch slices */
.glitch { position: relative; }
.glitch::before, .glitch::after {
    content: attr(data-text);
    position: absolute;
    left: 0; right: 0;
    top: 0;
    -webkit-background-clip: text;
    background-clip: text;
}
.glitch::before { color: var(--magenta); -webkit-text-fill-color: var(--magenta); mix-blend-mode: screen; animation: glitch-x 3.2s infinite steps(2); opacity: 0.35; }
.glitch::after  { color: var(--cyan);    -webkit-text-fill-color: var(--cyan);    mix-blend-mode: screen; animation: glitch-y 2.6s infinite steps(2); opacity: 0.35; }
@keyframes glitch-x { 0%,92%,100% { transform: translate(0); } 94% { transform: translate(-3px,1px);} 96% { transform: translate(2px,-1px);} }
@keyframes glitch-y { 0%,90%,100% { transform: translate(0); } 93% { transform: translate(2px,1px);} 97% { transform: translate(-2px,0);} }

.cyber-stage {
    position: relative;
    z-index: 3;
    flex: 1;
    margin: 4px 0;
    /* when .zooming is removed on panel close, ease back from the held end-state */
    transition: transform var(--t-med) var(--ease-out), opacity var(--t-med) var(--ease-out), filter var(--t-med) var(--ease-out);
}
.cyber-links {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}
.cyber-links line {
    stroke: rgba(22,240,255,0.5);
    stroke-width: 1.5;
    stroke-dasharray: 5 8;
    filter: drop-shadow(0 0 4px rgba(22,240,255,0.6));
    animation: dash-flow 1.2s linear infinite;
}
@keyframes dash-flow { to { stroke-dashoffset: -26; } }

/* core + nodes (absolutely positioned by JS via left/top %) */
.cyber-core, .cyber-node {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.cyber-core {
    width: clamp(86px, 11vw, 130px);
    height: clamp(86px, 11vw, 130px);
    border-radius: 50%;
    color: var(--white);
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(11px, 1.3vw, 15px);
    letter-spacing: 2px;
    background: radial-gradient(circle at 50% 40%, rgba(22,240,255,0.25), rgba(0,0,0,0.6) 70%);
    border: 2px solid var(--cyan);
    box-shadow: 0 0 24px rgba(22,240,255,0.7), inset 0 0 24px rgba(22,240,255,0.35);
    animation: core-pulse 3s ease-in-out infinite;
}
.cyber-core::before, .cyber-core::after {
    content: "";
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    border: 1px solid rgba(22,240,255,0.4);
    animation: ring-expand 3s ease-out infinite;
}
.cyber-core::after { animation-delay: 1.5s; }
@keyframes core-pulse {
    0%,100% { box-shadow: 0 0 24px rgba(22,240,255,0.7), inset 0 0 24px rgba(22,240,255,0.35); }
    50%     { box-shadow: 0 0 40px rgba(22,240,255,1), inset 0 0 30px rgba(22,240,255,0.55); }
}
@keyframes ring-expand {
    0%   { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}
/* core hover (core-pulse only animates box-shadow, so transform is free) */
.cyber-core { transition: transform var(--t-fast) var(--ease-out); }
.cyber-core:hover { transform: translate(-50%, -50%) scale(1.06); }
.cyber-core:active { transform: translate(-50%, -50%) scale(0.99); }

/* .cyber-node = positioning only (centered). Visuals + motion live on the
   nested .node-float (idle drift) and .node-inner (hover), so the float and
   hover transforms never fight and both run on the GPU. */
.cyber-node {
    width: clamp(74px, 9vw, 108px);
    height: clamp(74px, 9vw, 108px);
    --c: var(--cyan);
}
.node-float {
    width: 100%;
    height: 100%;
    animation: node-float 5.5s ease-in-out infinite;
    animation-delay: var(--fd, 0s);
}
.node-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px;
    color: var(--c);
    border: 1.5px solid var(--c);
    border-radius: 16px;
    background: rgba(0,0,0,0.45);
    box-shadow: 0 0 16px color-mix(in srgb, var(--c) 55%, transparent), inset 0 0 14px color-mix(in srgb, var(--c) 22%, transparent);
    text-shadow: 0 0 8px var(--c);
    transition: transform var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
    will-change: transform;
}
.cyber-node .node-label {
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: clamp(10px, 1.15vw, 14px);
    letter-spacing: 1.5px;
}
.cyber-node .node-sub {
    font-size: clamp(8px, 0.85vw, 11px);
    opacity: 0.7;
    margin-top: 3px;
}
.cyber-node .node-ico {
    font-size: clamp(14px, 1.7vw, 22px);
    line-height: 1;
    margin-bottom: 3px;
}
.cyber-node:hover { z-index: 6; }
.cyber-node:hover .node-inner {
    transform: scale(1.14);
    box-shadow: 0 0 34px var(--c), inset 0 0 22px color-mix(in srgb, var(--c) 35%, transparent);
}
.cyber-node:active .node-inner { transform: scale(1.05); }
.cyber-node.locked { opacity: 0.5; filter: saturate(0.55); }
.cyber-node.locked .node-sub { color: var(--red); opacity: 0.9; }

@keyframes node-float {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-9px); }
}

/* One-time staggered entrance — gated by .intro on #cyberspace (per-node --ed delay).
   `backwards` fill hides each node until its turn, then releases so hover works. */
#cyberspace.intro .node-inner {
    animation: node-in var(--t-slow) var(--ease-out) var(--ed, 0s) backwards;
}
@keyframes node-in {
    0%   { opacity: 0; transform: scale(0.2); }
    70%  { opacity: 1; }
    100% { opacity: 1; transform: scale(1); }
}

/* Data packets travelling core -> node along each link */
.cyber-packet {
    fill: var(--cyan);
    filter: drop-shadow(0 0 3px currentColor);
}

.cyber-hint {
    position: relative;
    z-index: 4;
    text-align: center;
    padding: 10px 0 16px;
    font-size: 12px;
    letter-spacing: 1px;
    color: rgba(22,240,255,0.7);
    text-shadow: 0 0 6px rgba(22,240,255,0.4);
}
.cyber-hint b { color: var(--green); }

/* zoom transition when entering a node */
#cyberspace.zooming .cyber-stage { animation: stage-zoom var(--t-slow) var(--ease) forwards; }
@keyframes stage-zoom {
    to { transform: scale(1.22); opacity: 0; filter: blur(4px); }
}

/* ============================================================
   CONTENT PANELS
   ============================================================ */
#panel-overlay { position: absolute; inset: 0; z-index: 60; }
.panel-backdrop {
    position: absolute; inset: 0;
    background: rgba(2, 6, 10, 0.62);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: backdrop-in var(--t-med) var(--ease) both;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.cyber-panel {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: min(86%, 680px);
    max-height: 82%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(160deg, rgba(8,16,22,0.96), rgba(4,8,12,0.98));
    border: 1px solid var(--pc, var(--cyan));
    border-radius: 10px;
    box-shadow: 0 0 30px color-mix(in srgb, var(--pc, var(--cyan)) 55%, transparent), inset 0 0 30px rgba(0,0,0,0.6);
    overflow: hidden;
    animation: panel-in var(--t-med) var(--ease-out) both;
}
@keyframes panel-in {
    0%   { opacity: 0; transform: translate(-50%, -46%) scale(0.92); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
/* symmetric exit, driven by the .closing class from closePanel() */
#panel-overlay.closing .panel-backdrop { animation: backdrop-out var(--t-fast) var(--ease) both; }
#panel-overlay.closing .cyber-panel    { animation: panel-out var(--t-fast) var(--ease) both; }
@keyframes backdrop-out { to { opacity: 0; } }
@keyframes panel-out {
    to { opacity: 0; transform: translate(-50%, -53%) scale(0.95); }
}
.panel-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--pc, var(--cyan)) 22%, transparent), transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--pc, var(--cyan)) 45%, transparent);
}
.panel-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--pc, var(--cyan));
    box-shadow: 0 0 8px var(--pc, var(--cyan));
}
.panel-title {
    flex: 1;
    font-family: 'Chakra Petch', sans-serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 2px;
    color: var(--pc, var(--cyan));
    text-shadow: 0 0 8px var(--pc, var(--cyan));
}
.panel-close {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 12px;
    color: var(--pc, var(--cyan));
    background: transparent;
    border: 1px solid color-mix(in srgb, var(--pc, var(--cyan)) 50%, transparent);
    border-radius: 4px;
    padding: 2px 7px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.panel-close:hover { background: var(--magenta); color: #000; border-color: var(--magenta); }
.panel-body {
    padding: 18px 20px;
    overflow-y: auto;
    color: var(--white);
    font-size: 15px;
    line-height: 1.5;
    scrollbar-width: thin;
    scrollbar-color: var(--pc, var(--cyan)) transparent;
}
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: var(--pc, var(--cyan)); border-radius: 4px; }

/* --- panel content helpers --- */
.p-ascii {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    line-height: 1;
    white-space: pre;
    color: var(--cyan);
    text-shadow: 0 0 5px var(--cyan);
    margin-bottom: 12px;
    overflow-x: auto;
}
.p-kv { margin: 2px 0; }
.p-kv .k { color: var(--amber); text-shadow: 0 0 6px var(--amber); margin-right: 8px; }
.p-rule { height: 1px; background: linear-gradient(90deg, var(--cyan), transparent); margin: 14px 0; border: 0; }
.p-text { color: #cfeff5; white-space: pre-wrap; }

/* neon skill bars */
.nbar-row { margin: 9px 0; }
.nbar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.nbar-head .nm { color: var(--white); }
.nbar-head .pc { color: var(--green); text-shadow: 0 0 6px var(--green); }
.nbar-track { height: 9px; background: rgba(255,255,255,0.06); border-radius: 5px; overflow: hidden; border: 1px solid rgba(255,255,255,0.08); }
.nbar-fill {
    height: 100%; width: 0;
    background: linear-gradient(90deg, var(--green), var(--cyan));
    box-shadow: 0 0 10px var(--green);
    border-radius: 5px;
    animation: nbar-grow 1.1s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes nbar-grow { from { width: 0; } }
.skill-group { margin-top: 14px; font-family: 'Chakra Petch',sans-serif; font-size: 11px; letter-spacing: 2px; color: var(--magenta); text-shadow: 0 0 6px var(--magenta); }

/* project cards */
.proj-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.proj-card {
    border: 1px solid rgba(0,255,90,0.35);
    border-radius: 8px;
    padding: 12px 14px;
    background: rgba(0,255,90,0.04);
    cursor: pointer;
    transition: all 0.16s ease;
}
.proj-card:hover { background: rgba(0,255,90,0.10); box-shadow: 0 0 16px rgba(0,255,90,0.35); transform: translateY(-2px); }
.proj-card .pc-name { font-family: 'Chakra Petch',sans-serif; font-weight: 700; color: var(--green); text-shadow: 0 0 6px var(--green); letter-spacing: 1px; }
.proj-card .pc-desc { font-size: 13px; color: #bfe6cf; margin-top: 4px; }
.proj-card .pc-go { float: right; color: var(--cyan); font-size: 12px; }

/* contact links */
.contact-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; margin: 9px 0;
    border: 1px solid rgba(255,176,0,0.35);
    border-radius: 8px;
    color: var(--white);
    text-decoration: none;
    background: rgba(255,176,0,0.04);
    transition: all 0.16s ease;
}
.contact-link:hover { background: rgba(255,176,0,0.12); box-shadow: 0 0 16px rgba(255,176,0,0.4); transform: translateX(4px); }
.contact-link .cl-ico { font-size: 18px; }
.contact-link .cl-k { color: var(--amber); text-shadow: 0 0 6px var(--amber); width: 92px; font-size: 13px; letter-spacing: 1px; }
.contact-link .cl-v { color: var(--white); }

.vault-locked { text-align: center; color: var(--red); text-shadow: 0 0 8px var(--red); }
.vault-locked .big { font-family: 'Chakra Petch',sans-serif; font-size: 20px; letter-spacing: 3px; margin: 10px 0; }
.vault-term-btn {
    display: inline-block;
    margin-top: 4px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--red);
    background: rgba(255, 43, 78, 0.10);
    border: 1px solid var(--red);
    border-radius: 5px;
    padding: 7px 16px;
    cursor: pointer;
    text-shadow: 0 0 6px rgba(255, 43, 78, 0.5);
    transition: background var(--t-fast) var(--ease-out), color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.vault-term-btn:hover {
    background: var(--red);
    color: #120206;            /* dark text on solid red — high contrast */
    text-shadow: none;
    box-shadow: 0 0 16px rgba(255, 43, 78, 0.6);
}

/* ============================================================
   PROJECT MODAL (run command)
   ============================================================ */
.modal { position: absolute; inset: 0; background: rgba(2,6,10,0.78); display: flex; justify-content: center; align-items: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-content {
    background: linear-gradient(160deg, rgba(8,16,22,0.97), rgba(4,8,12,0.99));
    border: 1px solid var(--green);
    box-shadow: 0 0 24px var(--green), inset 0 0 24px rgba(0,255,90,0.08);
    width: 80%; max-width: 600px; max-height: 80%;
    display: flex; flex-direction: column; overflow: hidden;
    border-radius: 8px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; background: var(--green); color: #021; }
.modal-title { font-family: 'Chakra Petch',sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 1px; }
.modal-close { cursor: pointer; font-weight: bold; }
.modal-close:hover { color: var(--magenta); }
.modal-body {
    padding: 20px; overflow-y: auto; white-space: pre-wrap;
    color: var(--green);
    font-family: 'VT323', monospace; font-size: 18px;
    text-shadow: 0 0 5px var(--green);
}

/* ============================================================
   HACK THE PLANET ANIMATION
   ============================================================ */
#hack-animation {
    position: fixed; inset: 0; width: 100vw; height: 100vh;
    background: #000; z-index: 9999;
    display: flex; justify-content: center; align-items: center; overflow: hidden;
}
#hack-animation.hidden { display: none; }
#matrix-canvas { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }
.hack-text {
    position: relative; z-index: 10;
    font-family: 'Courier New', monospace; font-size: 14px; line-height: 1.0;
    color: var(--green);
    text-shadow: 0 0 10px var(--green), 0 0 20px var(--green), 0 0 40px var(--green);
    animation: pulse-glow-green 0.5s ease-in-out infinite alternate;
}
@keyframes pulse-glow-green {
    0%   { text-shadow: 0 0 10px var(--green), 0 0 20px var(--green); }
    100% { text-shadow: 0 0 20px var(--green), 0 0 40px var(--green), 0 0 60px var(--green); }
}

/* ============================================================
   START OVERLAY
   ============================================================ */
/* Landing lives INSIDE the glass now (above the views, under the CRT overlays),
   so the monitor + room are visible around it and scanlines/glare sit on top. */
#start-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    background: radial-gradient(ellipse 120% 130% at 50% 50%, var(--screen-bg-2) 0%, var(--screen-bg) 60%, #010304 100%);
    animation: power-on 0.9s var(--ease-out) both;
}
#start-overlay.hidden { display: none; }
@keyframes power-on {
    0%   { opacity: 0; transform: scale(1.04); filter: brightness(2.4) blur(1px); }
    55%  { opacity: 1; }
    100% { opacity: 1; transform: scale(1); filter: brightness(1) blur(0); }
}
.start-content { text-align: center; }
.start-ascii {
    font-family: 'Courier New', monospace;
    color: var(--green);
    text-shadow: 0 0 10px var(--green), 0 0 20px var(--green);
    font-size: 14px; line-height: 1.0; margin-bottom: 18px;
}
.start-sub {
    color: var(--cyan);
    text-shadow: 0 0 8px var(--cyan);
    font-family: 'Chakra Petch', sans-serif;
    letter-spacing: 2px;
    font-size: 12px;
    margin-bottom: 26px;
}
.start-content p.blink {
    color: var(--amber);
    text-shadow: 0 0 10px var(--amber);
    font-size: 20px;
    font-family: 'VT323', monospace;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* Tablets / small laptops — keep the desktop layout, just tighten it */
@media (max-width: 900px) {
    .crt-monitor { width: 95vw; padding: clamp(12px, 2vw, 22px); aspect-ratio: 4 / 3.3; }
    .cyber-node { width: clamp(70px, 13vw, 100px); height: clamp(70px, 13vw, 100px); }
    .ascii, .ascii-art { font-size: 10px; }
    .hack-text { font-size: 10px; }
}

/* ---------- PHONES: full-screen CRT + vertical node menu ---------- */
@media (max-width: 640px) {
    .room { perspective: none; }

    /* monitor fills the viewport; drop desk/stand that eat vertical space */
    .desk, .crt-stand { display: none; }
    .crt-monitor {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        aspect-ratio: auto;
        padding: 7px 7px 34px;          /* bottom band reserved for the faceplate */
        border-radius: 0;
        box-shadow: inset 0 0 0 2px rgba(0,0,0,0.5);
    }
    .crt-monitor::before, .crt-monitor::after { display: none; }   /* side vents */
    .crt-bezel { border-radius: 12px; padding: 7px; }
    .crt-screen { border-radius: 9px; transform: none; }

    /* faceplate: keep the volume slider + LED, drop decorative chrome */
    .crt-brand, .crt-btn { display: none; }
    .crt-faceplate { height: 28px; justify-content: flex-start; padding: 0 14px; }
    .crt-volume { position: static; }
    .crt-controls { position: absolute; right: 14px; }
    #volume-slider { width: clamp(110px, 46vw, 190px); }

    /* terminal */
    body { font-size: 15px; }
    #terminal { font-size: 16px; }
    #terminal-scroll { padding: 12px 14px 20px; }
    #terminal-toolbar { padding: 7px 12px; }

    /* ----- cyberspace: radial graph -> vertical tappable menu ----- */
    .cyber-links { display: none; }        /* hide links + travelling packets */
    .cyber-core { display: none; }          /* the title is the header on mobile */
    .cyber-grid { opacity: 0.3; }
    .cyber-hud { padding: 9px 14px; font-size: 10px; }
    .cyber-title { margin-top: 8px; font-size: clamp(26px, 9vw, 40px); }

    .cyber-stage {
        flex: 1;
        min-height: 0;
        margin: 8px 0;
        padding: 0 14px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: 11px;
        overflow-y: auto;
    }

    /* radial absolute positioning -> full-width stacked rows */
    .cyber-node {
        position: static !important;
        transform: none !important;
        width: 100% !important;
        height: auto !important;
    }
    .node-float { width: 100%; height: auto; animation: none; }   /* no idle bob in a list */
    .node-inner {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 14px;
        height: auto;
        padding: 15px 16px;
        border-radius: 11px;
    }
    .cyber-node:active .node-inner { transform: scale(0.98); }
    .node-ico { margin: 0; width: 26px; text-align: center; font-size: 22px; }
    .node-label { font-size: 15px; letter-spacing: 1px; }
    .node-sub { display: block; margin: 0 0 0 auto; font-size: 11px; opacity: 0.6; }

    .cyber-hint { padding: 8px 10px 12px; font-size: 11px; }

    /* panels / modal go near-fullscreen */
    .cyber-panel { width: 94%; max-height: 88%; }
    .panel-body { font-size: 14px; padding: 14px 16px; }
    .modal-content { width: 94%; max-height: 86%; }
    .p-ascii { font-size: 7px; }      /* shrink name/box ASCII to fit panel width */

    /* landing */
    .start-ascii { font-size: 9px; margin-bottom: 14px; }
    .start-sub { font-size: 10px; }
    .start-content p.blink { font-size: 16px; }

    .ascii, .ascii-art { font-size: 8px; }
    .hack-text { font-size: 8px; }
}

/* very narrow phones */
@media (max-width: 380px) {
    .cyber-title { font-size: 24px; letter-spacing: 2px; }
    .node-label { font-size: 14px; }
    .node-sub { display: none; }            /* avoid wrapping on tiny screens */
    .p-ascii { font-size: 6px; }
    .start-ascii { font-size: 7px; }
    .ascii, .ascii-art { font-size: 7px; }
    .hack-text { font-size: 7px; }
}

@media (prefers-reduced-motion: reduce) {
    .crt-flicker, .cyber-grid, .cyber-stars, .node-float, .cyber-core,
    .room-glow, .cyber-title, .crt-scanlines::after, #mode-wipe, #start-overlay,
    #cyberspace.intro .node-inner, .screen-content.glitching,
    .glitch::before, .glitch::after { animation: none !important; }
    .screen-view, .node-inner, .cyber-core { transition: none !important; }
}
