/* DEAD SWITCH — lo-fi cyberpunk CRT */

:root {
    --bg: #070a09;
    --panel: #0c1311;
    --panel-2: #101a17;
    --line: #1d332b;
    --ink: #c8ffe0;
    --dim: #4d6f60;
    --neon: #3dffa0;
    --cyan: #41e8ff;
    --mag: #ff4bd8;
    --amber: #ffc857;
    --alarm: #f07727;
    --red: #ff5052;
    --font-term: 'VT323', monospace;
    --font-mono: 'Share Tech Mono', monospace;
}

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

html,
body {
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 14px;
    overflow: hidden;
}

/* CRT overlay on everything */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    background:
        repeating-linear-gradient(
            0deg,
            rgba(0, 0, 0, 0.14) 0px,
            rgba(0, 0, 0, 0.14) 1px,
            transparent 1px,
            transparent 3px
        ),
        radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9001;
    background: rgba(61, 255, 160, 0.02);
    animation: flicker 4s infinite;
}

@keyframes flicker {
    0%,
    100% {
        opacity: 1;
    }
    92% {
        opacity: 1;
    }
    93% {
        opacity: 0.6;
    }
    94% {
        opacity: 1;
    }
    97% {
        opacity: 0.8;
    }
    98% {
        opacity: 1;
    }
}

.hidden {
    display: none !important;
}

.kbd {
    font-family: var(--font-term);
    font-size: 1.1em;
    color: var(--neon);
    border: 1px solid var(--line);
    padding: 0 6px;
    border-radius: 3px;
    background: var(--panel-2);
}

/* ---------- boot screen ---------- */
.boot-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    background: var(--bg);
    z-index: 100;
}

.boot-logo {
    font-family: var(--font-mono);
    font-size: clamp(6px, 1.4vw, 13px);
    line-height: 1.15;
    color: var(--neon);
    text-shadow:
        0 0 8px rgba(61, 255, 160, 0.7),
        0 0 30px rgba(61, 255, 160, 0.3);
    animation: glitch-in 0.9s steps(12) both;
    white-space: pre;
}

@keyframes glitch-in {
    0% {
        opacity: 0;
        transform: translateX(-6px) skewX(6deg);
        filter: blur(2px);
    }
    40% {
        opacity: 1;
        transform: translateX(4px);
    }
    60% {
        transform: translateX(-2px) skewX(-3deg);
    }
    100% {
        transform: none;
        filter: none;
    }
}

.boot-sub {
    font-family: var(--font-term);
    font-size: 20px;
    letter-spacing: 5px;
    color: var(--mag);
    text-shadow: 0 0 10px rgba(255, 75, 216, 0.6);
}

.boot-lines {
    font-family: var(--font-term);
    font-size: 17px;
    color: var(--dim);
    min-height: 110px;
    width: min(560px, 90vw);
    text-align: left;
    white-space: pre-wrap;
}

.boot-hint {
    color: var(--dim);
    font-size: 13px;
}

/* ---------- buttons ---------- */
.btn {
    font-family: var(--font-term);
    font-size: 18px;
    letter-spacing: 2px;
    color: var(--neon);
    background: transparent;
    border: 1px solid var(--neon);
    padding: 6px 18px;
    cursor: pointer;
    text-transform: uppercase;
    transition:
        background 0.12s,
        color 0.12s,
        box-shadow 0.12s;
}

.btn:hover {
    background: var(--neon);
    color: #04130b;
    box-shadow: 0 0 18px rgba(61, 255, 160, 0.5);
}

.btn:disabled {
    color: var(--dim);
    border-color: var(--line);
    cursor: not-allowed;
    background: transparent;
    box-shadow: none;
}

.btn-big {
    font-size: 26px;
    padding: 10px 34px;
}

.btn-dim {
    color: var(--dim);
    border-color: var(--line);
}

.btn-tiny {
    font-size: 13px;
    padding: 2px 10px;
    letter-spacing: 1px;
}

.icon-btn {
    font-family: var(--font-mono);
    background: transparent;
    color: var(--dim);
    border: 1px solid var(--line);
    padding: 3px 9px;
    cursor: pointer;
    font-size: 14px;
}

.icon-btn:hover {
    color: var(--neon);
    border-color: var(--neon);
}

.howto-btn {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--neon);
    letter-spacing: 1px;
}

.ai-badge {
    color: var(--cyan);
}

/* ---------- layout ---------- */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--panel);
}

.brand {
    font-family: var(--font-term);
    font-size: 26px;
    letter-spacing: 3px;
    color: var(--neon);
    text-shadow: 0 0 10px rgba(61, 255, 160, 0.5);
}

.brand-x {
    color: var(--mag);
}

.ver {
    font-size: 13px;
    color: var(--dim);
    letter-spacing: 1px;
}

.topstats {
    flex: 1;
    display: flex;
    gap: 22px;
    font-family: var(--font-term);
    font-size: 19px;
}

.topstats .stat-dc {
    color: var(--amber);
}

.topstats .stat-runs {
    color: var(--dim);
}

.top-actions {
    display: flex;
    gap: 8px;
}

.main {
    flex: 1;
    display: flex;
    min-height: 0;
}

.stage {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* the game scales to fit — never scrolls */
}

/* ---------- hub ---------- */
.hub {
    display: flex;
    gap: 14px;
    padding: 14px;
    align-items: flex-start;
}

.hub-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.panel {
    border: 1px solid var(--line);
    background: var(--panel);
    padding: 12px;
}

.panel-title {
    font-family: var(--font-term);
    font-size: 21px;
    letter-spacing: 3px;
    color: var(--cyan);
    margin-bottom: 10px;
    text-shadow: 0 0 8px rgba(65, 232, 255, 0.4);
}

.job-card {
    border: 1px solid var(--line);
    background: var(--panel-2);
    padding: 10px 12px;
    margin-bottom: 8px;
}

.job-card .job-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-family: var(--font-term);
    font-size: 19px;
}

.job-card .job-corp {
    color: var(--ink);
}

.job-card .job-pay {
    color: var(--amber);
}

.job-card .job-desc {
    color: var(--dim);
    margin: 4px 0 8px;
    font-size: 13px;
}

.job-tier {
    color: var(--mag);
    letter-spacing: 2px;
}

.shop-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.shop-tab {
    font-family: var(--font-term);
    font-size: 16px;
    letter-spacing: 2px;
    padding: 3px 14px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--dim);
    cursor: pointer;
}

.shop-tab:hover {
    color: var(--ink);
    border-color: var(--dim);
}

.shop-tab.active {
    color: var(--neon);
    border-color: var(--neon);
    box-shadow: 0 0 10px rgba(61, 255, 160, 0.35);
}

/* each shop scrolls on its own, with a neon scrollbar */
.shop-list,
.fence-list {
    max-height: 238px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-width: thin;
    scrollbar-color: var(--neon) var(--panel-2);
}

.fence-list {
    max-height: 150px;
}

.shop-list::-webkit-scrollbar,
.fence-list::-webkit-scrollbar {
    width: 8px;
}

.shop-list::-webkit-scrollbar-track,
.fence-list::-webkit-scrollbar-track {
    background: var(--panel-2);
    border: 1px solid var(--line);
}

.shop-list::-webkit-scrollbar-thumb,
.fence-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--neon), #1d8f5c);
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(61, 255, 160, 0.6);
}

.shop-list::-webkit-scrollbar-thumb:hover,
.fence-list::-webkit-scrollbar-thumb:hover {
    background: var(--neon);
}

.icon-btn.off {
    color: #4a4f55;
    text-decoration: line-through;
}

.slot-row {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--dim);
    font-family: var(--font-term);
    font-size: 14px;
    letter-spacing: 1px;
}

.slot-row-header {
    margin-right: 10px;
}

.slot-btn {
    letter-spacing: 0;
    padding: 2px 8px;
}

.slot-btn.slot-active {
    background: var(--neon);
    color: #04130b;
    box-shadow: 0 0 10px rgba(61, 255, 160, 0.4);
}

.tt-tree-locked {
    opacity: 0.45;
}

.tt-up-head {
    font-family: var(--font-term);
    font-size: 15px;
    letter-spacing: 2px;
    margin: 8px 0 2px 6px;
}

.tt-up-row {
    margin-left: 22px;
}

.tt-pips {
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--neon);
}

.shop-item,
.fence-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 8px;
    border-bottom: 1px dashed var(--line);
}

.shop-item:last-child,
.fence-item:last-child {
    border-bottom: none;
}

.shop-name {
    color: var(--ink);
}

.shop-owned {
    color: var(--neon);
    font-family: var(--font-term);
    font-size: 17px;
}

.shop-desc {
    color: var(--dim);
    font-size: 12px;
    flex: 1;
    margin-left: 10px;
}

.shop-price {
    color: var(--amber);
    white-space: nowrap;
}

.rig-info {
    color: var(--dim);
    line-height: 1.7;
    margin-bottom: 10px;
}

.rig-info b {
    color: var(--ink);
    font-weight: normal;
}

/* ---------- the den scene ---------- */
.hub {
    flex: 1;
    min-height: 0;
    padding: 10px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.den-scene {
    position: relative;
    width: 100%;
    max-width: 1100px;
    max-height: 100%;
    aspect-ratio: 1024 / 559;
    margin: 0 auto;
    border: 1px solid var(--line);
    overflow: hidden;
    user-select: none;
}

.den-base,
#denDecorCv,
#denFxCv,
#denHotspots {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.den-base {
    object-fit: fill;
    image-rendering: pixelated;
}

#denDecorCv,
#denFxCv {
    image-rendering: pixelated;
    pointer-events: none;
}

.den-hot {
    position: absolute;
    pointer-events: none;
}

.den-toast {
    position: absolute;
    left: 50%;
    top: 12%;
    transform: translateX(-50%);
    font-family: var(--font-term);
    font-size: 19px;
    letter-spacing: 2px;
    color: var(--neon);
    text-shadow: 0 0 14px rgba(61, 255, 160, 0.8);
    background: rgba(7, 10, 9, 0.9);
    border: 1px solid var(--neon);
    padding: 8px 20px;
    white-space: nowrap;
    pointer-events: none;
    animation: den-toast-in 3.6s ease forwards;
    z-index: 5;
}

@keyframes den-toast-in {
    0% {
        opacity: 0;
        transform: translateX(-50%) translateY(-14px);
    }
    8% {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

.bm-empty {
    padding: 14px;
    color: #8a938d;
    font-style: italic;
    line-height: 1.6;
}

.bm-kind {
    color: #b98bff;
    font-style: normal;
}

.shop-item.bm-blocked {
    opacity: 0.45;
}

.hot-item.hot-bm .hot-key {
    color: #b98bff;
}

/* ---------- story archive + fence extras ---------- */
.job-sector {
    color: #b98bff;
    font-size: 14px;
    letter-spacing: 1px;
}

.fence-hot {
    color: #ff5052;
    font-size: 13px;
    letter-spacing: 1px;
    border: 1px solid #ff5052;
    padding: 0 5px;
}

.fence-hw {
    color: #ffc857;
    font-size: 13px;
    letter-spacing: 1px;
    border: 1px solid #ffc857;
    padding: 0 5px;
}

.fence-report {
    color: #ff5052;
}

.fence-read {
    margin: 2px 0 10px;
    padding: 8px 12px;
    border-left: 2px solid var(--line);
    color: #a8b3ac;
    font-size: 16px;
    line-height: 1.55;
    white-space: pre-wrap;
}

.arch-blurb {
    color: #8a938d;
    font-style: italic;
    margin-bottom: 12px;
    line-height: 1.5;
}

.arch-corp {
    border: 1px solid var(--line);
    margin-bottom: 8px;
    padding: 6px 10px;
}

.arch-corp > summary {
    cursor: pointer;
    color: var(--neon);
    letter-spacing: 1px;
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.arch-sector {
    color: #b98bff;
    font-size: 14px;
}

.arch-prog {
    margin-left: auto;
    color: #8a938d;
    font-size: 14px;
}

.arch-frag {
    margin: 5px 0 5px 14px;
}

.arch-frag > summary {
    cursor: pointer;
    color: var(--ink);
}

.arch-text {
    padding: 6px 12px;
    border-left: 2px solid var(--line);
    color: #a8b3ac;
    line-height: 1.55;
    font-size: 16px;
    white-space: pre-wrap;
}

.arch-missing {
    margin: 5px 0 5px 14px;
    color: #3d444a;
    letter-spacing: 2px;
}

.arch-notes-head {
    margin: 12px 0 4px 14px;
    color: #8a938d;
    font-size: 14px;
    letter-spacing: 2px;
}

.arch-note {
    margin: 4px 0 4px 14px;
    padding-left: 12px;
    border-left: 2px solid var(--line);
    color: #97a39b;
    font-size: 15px;
    line-height: 1.5;
}

/* ---------- battle rig: chassis schematic ---------- */
#denRig .modal-box {
    width: min(900px, 94vw);
}

.rig-frames {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.rig-frame-card {
    flex: 1;
    background: rgba(10, 14, 12, 0.6);
    border: 1px solid var(--line);
    color: #8a938d;
    font-family: var(--font-term);
    font-size: 15px;
    letter-spacing: 1px;
    padding: 6px 4px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.rig-frame-card svg {
    width: 58px;
    height: 42px;
}

.rig-frame-card svg polygon {
    fill: rgba(61, 255, 160, 0.06);
    stroke: #3dffa0;
    stroke-width: 9;
}

.rig-frame-card.rig-on {
    border-color: var(--neon);
    color: var(--neon);
    box-shadow: 0 0 14px rgba(61, 255, 160, 0.3);
}

.rig-frame-card.rig-locked {
    opacity: 0.4;
    cursor: pointer; /* locked = click to see it in the shop */
}

.rig-frame-card.rig-locked svg polygon {
    stroke: #5a625d;
    fill: none;
}

.rig-wrap {
    display: flex;
    gap: 14px;
    align-items: stretch;
}

.rig-schem {
    flex: 1.3;
    min-width: 0;
    border: 1px solid var(--line);
    background: radial-gradient(circle at 50% 45%, rgba(61, 255, 160, 0.06), rgba(7, 10, 9, 0.2));
}

.rig-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.rig-hull {
    fill: rgba(61, 255, 160, 0.05);
    stroke: #3dffa0;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 7px rgba(61, 255, 160, 0.55));
}

.rig-core-ring {
    fill: none;
    stroke: rgba(61, 255, 160, 0.25);
    stroke-dasharray: 4 4;
}

.rig-strut {
    stroke: rgba(61, 255, 160, 0.18);
    stroke-width: 1;
}

.rig-hp {
    cursor: pointer;
}

.rig-hp circle {
    fill: #0a0f0c;
    stroke: #5a625d;
    stroke-width: 2;
    stroke-dasharray: 3 3;
}

.rig-hp-armed circle {
    stroke: #41e8ff;
    stroke-dasharray: none;
    filter: drop-shadow(0 0 6px rgba(65, 232, 255, 0.7));
}

.rig-hp-ult.rig-hp-armed circle {
    stroke: #ff4bd8;
    filter: drop-shadow(0 0 8px rgba(255, 75, 216, 0.7));
}

@keyframes hp-glow {
    from {
        filter: drop-shadow(0 0 3px rgba(253, 251, 247, 0.6));
    }

    to {
        filter: drop-shadow(0 0 13px rgba(253, 251, 247, 1));
    }
}

.rig-hp-sel circle {
    stroke: #fdfbf7 !important;
    stroke-width: 3;
    animation: hp-glow 0.9s ease-in-out infinite alternate;
}

.rig-hp-key {
    fill: #fdfbf7;
    font-family: var(--font-term);
    font-size: 16px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.rig-hp-name {
    fill: #8a938d;
    font-family: var(--font-term);
    font-size: 12px;
    letter-spacing: 1px;
    text-anchor: middle;
    pointer-events: none;
    paint-order: stroke;
    stroke: #070a09;
    stroke-width: 3px;
}

.rig-hp-armed .rig-hp-name {
    fill: #41e8ff;
}

.rig-gun-tag {
    fill: #8a938d;
    font-family: var(--font-term);
    font-size: 13px;
    letter-spacing: 2px;
    text-anchor: middle;
}

.rig-rack {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rack-head {
    color: #b98bff;
    letter-spacing: 2px;
    font-size: 14px;
    margin-bottom: 4px;
}

.rig-chip {
    text-align: left;
    background: rgba(10, 14, 12, 0.6);
    border: 1px solid var(--line);
    color: var(--ink);
    font-family: var(--font-term);
    font-size: 16px;
    letter-spacing: 1px;
    padding: 5px 10px;
    cursor: pointer;
}

.rig-chip:hover:not(:disabled) {
    border-color: var(--neon);
}

.rig-chip.rig-on {
    border-color: var(--neon);
    color: var(--neon);
    box-shadow: 0 0 10px rgba(61, 255, 160, 0.3);
}

.rig-chip.rig-locked {
    opacity: 0.45;
    cursor: default;
}

/* ---------- corpo heat monitor + endgame ---------- */
#denHeat .modal-box {
    width: min(760px, 94vw);
}

.heat-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid rgba(61, 255, 160, 0.08);
}

.heat-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex: none;
}

.heat-name {
    flex: 1;
    letter-spacing: 1px;
    font-size: 16px;
}

.heat-row.heat-owned .heat-name {
    text-decoration: line-through;
    color: #5a625d;
}

.heat-ctl {
    color: var(--neon);
    letter-spacing: 2px;
    font-size: 14px;
    text-shadow: 0 0 10px rgba(61, 255, 160, 0.6);
}

.heat-pips {
    display: inline-flex;
    gap: 3px;
}

.heat-pips i {
    width: 9px;
    height: 13px;
    background: rgba(61, 255, 160, 0.12);
    border: 1px solid rgba(61, 255, 160, 0.25);
}

.heat-pips i.hp-on {
    background: #ff5052;
    border-color: #ff5052;
    box-shadow: 0 0 8px rgba(255, 80, 82, 0.7);
}

.heat-tier {
    width: 150px;
    text-align: right;
    color: #8a938d;
    font-size: 14px;
}

.cbi-box {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 14px;
    padding: 10px;
    border: 1px solid rgba(65, 232, 255, 0.35);
    background: rgba(10, 16, 20, 0.5);
}

.cbi-logo {
    width: 84px;
    height: 64px;
    object-fit: contain;
    flex: none;
}

.cbi-text {
    font-size: 15px;
    line-height: 1.55;
    color: #a8b3ac;
}

.cbi-pips {
    margin-left: 10px;
    vertical-align: middle;
}

.job-logo {
    width: 34px;
    height: 34px;
    object-fit: contain;
    margin-right: 8px;
    vertical-align: middle;
    flex: none;
}

.job-card .job-top {
    display: flex;
    align-items: center;
}

.job-card.job-boss {
    border-color: #ff4bd8;
    box-shadow: 0 0 18px rgba(255, 75, 216, 0.25);
}

.job-card.job-cbi {
    border-color: #41e8ff;
    box-shadow: 0 0 14px rgba(65, 232, 255, 0.2);
}

.ending {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(4, 6, 5, 0.96);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px;
    text-align: center;
}

.ending.hidden {
    display: none;
}

.ending-stage {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ending-art {
    max-width: min(900px, 92vw);
    max-height: 48vh;
    border: 1px solid var(--line);
    box-shadow: 0 0 60px rgba(61, 255, 160, 0.15);
}

.ending-logo {
    max-height: 30vh;
    filter: drop-shadow(0 0 30px rgba(255, 80, 82, 0.4));
}

/* the corp/CBI badge that caught you — pinned to the corner of the art */
.ending-badge {
    position: absolute;
    right: -14px;
    bottom: -14px;
    max-height: 108px;
    max-width: 160px;
    border: 1px solid var(--red, #ff5052);
    background: rgba(4, 6, 5, 0.85);
    padding: 4px;
    filter: drop-shadow(0 0 16px rgba(255, 80, 82, 0.55));
}

.ending-badge.hidden {
    display: none;
}

/* fake movie credits that crawl after a loss */
.ending-credits {
    width: min(520px, 92vw);
    height: 168px;
    overflow: hidden;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
    mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent);
}

.ending-credits.hidden {
    display: none;
}

.credits-crawl {
    font-family: var(--font-term);
    font-size: 14px;
    line-height: 1.9;
    color: var(--dim);
    white-space: pre;
    text-align: center;
    animation: credits-roll 22s linear forwards;
}

.credits-crawl b {
    color: var(--ink);
    font-weight: normal;
}

@keyframes credits-roll {
    from {
        transform: translateY(168px);
    }
    to {
        transform: translateY(-100%);
    }
}

.ending-text {
    font-family: var(--font-term);
    font-size: 19px;
    line-height: 1.6;
    color: var(--ink);
    max-width: 680px;
}

.ending-text h2 {
    color: var(--red, #ff5052);
    letter-spacing: 4px;
    margin-bottom: 10px;
    font-weight: normal;
}

/* ---------- den label eyeball + first-play arrow ---------- */
.den-eye {
    position: absolute;
    left: 10px;
    bottom: 10px;
    z-index: 5;
    width: 38px;
    height: 34px;
    background: rgba(7, 10, 9, 0.75);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 18px;
    cursor: pointer;
}

.den-eye.off {
    opacity: 0.45;
    filter: grayscale(1);
}

.labels-on .den-hot-label {
    opacity: 1;
    pointer-events: auto;
    cursor: pointer;
}

.den-eye-arrow {
    position: absolute;
    left: 56px;
    bottom: 16px;
    z-index: 5;
    color: var(--neon);
    font-family: var(--font-term);
    font-size: 17px;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(61, 255, 160, 0.8);
    pointer-events: none;
    animation: eye-bounce 0.8s ease-in-out infinite alternate;
}

@keyframes eye-bounce {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(9px);
    }
}

/* ---------- boot logo glitch ---------- */
.boot-logo.glitching {
    animation: logo-glitch 0.15s steps(2) infinite;
    text-shadow:
        2px 0 #ff2bd6,
        -2px 0 #41e8ff;
}

@keyframes logo-glitch {
    0% {
        transform: translate(0) skewX(0);
    }

    25% {
        transform: translate(-3px, 1px) skewX(-4deg);
    }

    50% {
        transform: translate(2px, -1px) skewX(3deg);
    }

    75% {
        transform: translate(-1px, 2px) skewX(-2deg);
    }

    100% {
        transform: translate(0) skewX(0);
    }
}

/* jump-to-shop landing flash */
.shop-flash {
    animation: shop-flash 0.5s ease-in-out 3;
}

@keyframes shop-flash {
    0%,
    100% {
        box-shadow: none;
    }

    50% {
        box-shadow: 0 0 18px rgba(61, 255, 160, 0.8);
        background: rgba(61, 255, 160, 0.1);
    }
}

/* heat monitor column header */
.heat-row.heat-head {
    border-bottom: 1px solid rgba(61, 255, 160, 0.3);
    padding-bottom: 2px;
}

.heat-head .heat-logo {
    height: 10px;
}

.heat-col {
    width: 118px;
    color: #b98bff;
    font-size: 13px;
    letter-spacing: 2px;
}

.heat-head .heat-tier {
    color: #b98bff;
    font-size: 13px;
    letter-spacing: 2px;
}

.rig-summary {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    color: #97a39b;
    line-height: 1.7;
}

/* ---------- battle-rig tabs (SERVER ASSAULT / PIN DEFENSE / THE MAP) ---------- */
.rig-tabs {
    display: flex;
    gap: 6px;
    /* stay pinned to the top of the scrolling modal body, covering the
       body's 14px padding so content slides cleanly underneath */
    position: sticky;
    top: -14px;
    z-index: 3;
    background: var(--panel);
    padding: 14px 0 10px;
    margin-bottom: 8px;
}

.rig-tab {
    flex: 1;
    background: rgba(10, 14, 12, 0.6);
    border: 1px solid var(--line);
    color: var(--dim);
    font-family: var(--font-term);
    font-size: 16px;
    letter-spacing: 2px;
    padding: 6px 4px;
    cursor: pointer;
}

.rig-tab.active {
    color: #04130b;
    background: var(--neon);
    box-shadow: 0 0 12px rgba(61, 255, 160, 0.4);
}

.rig-explain {
    color: var(--dim);
    line-height: 1.6;
    font-size: 13px;
    margin-bottom: 12px;
}

.rig-explain b {
    color: var(--cyan);
    font-weight: normal;
}

.rig-dim {
    color: #6c756f;
}

/* ---------- NULLHEAD command cheat-sheet ---------- */
.nh-cmd-group {
    margin-bottom: 12px;
    border-left: 2px solid var(--line);
    padding-left: 10px;
}

.nh-cmd-title {
    font-family: var(--font-term);
    font-size: 15px;
    letter-spacing: 1px;
    color: var(--alarm);
    margin-bottom: 5px;
}

.nh-cmd-row {
    display: flex;
    gap: 10px;
    align-items: baseline;
    padding: 2px 0;
    font-size: 13px;
}

.nh-cmd {
    flex: 0 0 auto;
    min-width: 190px;
    color: var(--neon);
    font-family: var(--font-mono);
    font-size: 12px;
    white-space: nowrap;
}

.nh-cmd-desc {
    color: var(--dim);
    line-height: 1.45;
}

.rig-explain code,
.rig-summary code {
    color: var(--neon);
    font-family: var(--font-mono);
    font-size: 12px;
}

@media (max-width: 640px) {
    .nh-cmd-row {
        flex-direction: column;
        gap: 1px;
    }
    .nh-cmd {
        min-width: 0;
    }
}

/* ---------- TEST YOUR RIG training-range panel ---------- */
.rig-test {
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid var(--cyan);
    background: rgba(65, 232, 255, 0.05);
}

.rig-test-head {
    color: var(--cyan);
    letter-spacing: 2px;
    font-family: var(--font-term);
    font-size: 17px;
}

.rig-test-sub {
    color: var(--dim);
    font-size: 12px;
    line-height: 1.5;
    margin: 4px 0 10px;
}

.rig-test-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.rig-test-boss {
    border-color: var(--red, #ff5052);
    color: var(--red, #ff5052);
}

.rig-shop-head {
    margin: 14px 0 6px;
    color: #b98bff;
    letter-spacing: 2px;
    font-size: 15px;
}

.den-hot-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-term);
    font-size: 17px;
    letter-spacing: 2px;
    color: var(--neon);
    text-shadow: 0 0 10px rgba(61, 255, 160, 0.7);
    background: rgba(7, 10, 9, 0.85);
    border: 1px solid var(--line);
    padding: 1px 10px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}

.den-hot.hot-on .den-hot-label {
    opacity: 1;
}

/* FENCE flags itself when there are shards waiting — label stays lit + a badge */
.den-hot.has-new .den-hot-label {
    opacity: 1;
    color: var(--alarm);
    border-color: var(--alarm);
    text-shadow: 0 0 10px rgba(240, 119, 39, 0.85);
}

.den-hot-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--alarm);
    color: #1a0f08;
    font-weight: 700;
    animation: fencePulse 1.2s ease-in-out infinite;
}

@keyframes fencePulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

.fence-appraise-note {
    font-family: var(--font-term);
    font-size: 15px;
    color: var(--alarm);
    border: 1px solid var(--alarm);
    background: rgba(240, 119, 39, 0.08);
    padding: 6px 9px;
    margin-bottom: 8px;
    line-height: 1.35;
}

/* ---------- mission ---------- */
.mission {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    overflow: hidden;
}

/* the map fills the space left between the bars and the hotbar, and
   scales down to fit — canvas is a replaced element, so max-width/height
   preserve its aspect like an image (mouse mapping reads the scale) */
.mission-canvas {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
}

.mission-bars {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 880px;
    font-family: var(--font-term);
    font-size: 18px;
}

.bar-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bar-label {
    color: var(--dim);
    letter-spacing: 1px;
}

.bar-num {
    color: var(--cyan);
}

#hpPips {
    color: var(--red);
    letter-spacing: 2px;
    font-size: 20px;
}

.meter {
    width: 110px;
    height: 10px;
    border: 1px solid var(--line);
    background: var(--panel-2);
}

.meter > div {
    height: 100%;
    width: 0%;
    transition: width 0.25s;
}

.alarm-meter > div {
    background: var(--alarm);
    box-shadow: 0 0 8px rgba(240, 119, 39, 0.7);
}

.ram-meter > div {
    background: var(--cyan);
    box-shadow: 0 0 8px rgba(65, 232, 255, 0.6);
}

.objective {
    margin-left: auto;
    color: var(--amber);
    letter-spacing: 1px;
}

.nh-cmds {
    width: 100%;
    max-width: 880px;
    font-family: var(--font-term);
    font-size: 15px;
    letter-spacing: 1px;
    color: var(--dim);
    padding: 2px 4px 4px;
}

.nh-cmds .nhc-label {
    color: var(--mag);
}

.nh-cmds .nhc {
    color: var(--cyan);
}

.nh-cmds .nhc-off {
    color: #4a4f55;
}

.nh-cmds .nhc-on {
    color: var(--neon);
}

#gameCanvas {
    border: 1px solid var(--line);
    background: #050807;
    image-rendering: pixelated;
    max-width: 100%;
}

.hotbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    font-family: var(--font-term);
    font-size: 16px;
}

.hot-item {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--dim);
    padding: 3px 10px;
    letter-spacing: 1px;
}

.hot-item .hot-key {
    color: var(--neon);
}

.hot-item .hot-count {
    color: var(--amber);
}

.hot-item.hot-danger .hot-key {
    color: var(--red);
}

/* ---------- comms ---------- */
.comms {
    width: 360px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--line);
    background: var(--panel);
    min-height: 0;
}

.comms-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
}

.comms-title {
    font-family: var(--font-term);
    font-size: 19px;
    letter-spacing: 3px;
    color: var(--mag);
}

.nh-status {
    font-size: 11px;
    color: var(--dim);
}

.feed {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    line-height: 1.45;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.feed-line {
    white-space: pre-wrap;
    word-break: break-word;
}

.feed-line.sys {
    color: var(--dim);
}

.feed-line.warn {
    color: var(--alarm);
}

.feed-line.bad {
    color: var(--red);
}

.feed-line.good {
    color: var(--neon);
}

.feed-line.nh {
    color: var(--cyan);
    text-shadow: 0 0 6px rgba(65, 232, 255, 0.35);
}

.feed-line.nh::before {
    content: 'NULLHEAD AI ▸ ';
    color: var(--mag);
}

.feed-line.you {
    color: var(--ink);
}

.feed-line.you::before {
    content: 'YOU ▸ ';
    color: var(--dim);
}

/* ---------- modals ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(4, 8, 6, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-box {
    width: min(620px, 92vw);
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--neon);
    box-shadow: 0 0 40px rgba(61, 255, 160, 0.15);
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-term);
    font-size: 20px;
    letter-spacing: 2px;
    color: var(--neon);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--dim);
    font-size: 16px;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--red);
}

.modal-body {
    padding: 14px;
    overflow-y: auto;
    line-height: 1.6;
    scrollbar-width: thin;
    scrollbar-color: var(--line) transparent;
}

.modal-body p {
    margin-bottom: 10px;
}

.modal-body .ai-steps {
    color: var(--neon);
    line-height: 2;
}

.dim-note {
    color: var(--dim);
}

.dontshow {
    display: block;
    margin-top: 8px;
    color: var(--dim);
    cursor: pointer;
}

.journal-entry {
    border: 1px solid var(--line);
    background: var(--panel-2);
    padding: 10px;
    margin-bottom: 10px;
}

.journal-entry h4 {
    font-family: var(--font-term);
    font-size: 17px;
    color: var(--amber);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.journal-entry pre {
    white-space: pre-wrap;
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--ink);
    line-height: 1.5;
}

.hack-row {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
}

#hackInput {
    flex: 1;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--neon);
    font-family: var(--font-term);
    font-size: 20px;
    letter-spacing: 2px;
    padding: 4px 10px;
    outline: none;
}

.hack-puzzle {
    font-family: var(--font-term);
    font-size: 19px;
    color: var(--cyan);
    letter-spacing: 1px;
}

.hack-history {
    margin-top: 10px;
    color: var(--dim);
    font-size: 13px;
    white-space: pre-wrap;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--neon) var(--panel-2);
}

.kp-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.kp-d {
    width: 28px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--cyan);
    background: var(--panel-2);
    font-family: var(--font-term);
    font-size: 22px;
    color: var(--ink);
    box-shadow: 0 0 6px rgba(65, 232, 255, 0.25);
}

.kp-fb {
    font-family: var(--font-term);
    font-size: 17px;
    color: var(--amber);
    margin-left: 8px;
    letter-spacing: 2px;
}

.kp-note {
    color: var(--dim);
    margin-bottom: 8px;
    font-size: 12px;
}

/* ---------- breach fight ---------- */
.fight-box {
    width: min(640px, 94vw);
    border-color: var(--red);
    box-shadow: 0 0 50px rgba(255, 80, 82, 0.2);
}

/* assault mode: the arena swallows the whole stage */
.fight-box.fight-wide {
    width: min(1640px, 96vw);
    max-height: 96vh;
}

.fight-box .modal-head {
    color: var(--red);
}

.fight-head {
    font-family: var(--font-term);
    font-size: 19px;
    letter-spacing: 2px;
    color: var(--ink);
    padding: 8px 18px 4px;
}

.fight-stage {
    position: relative;
    padding: 8px 18px 12px;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fightCanvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    background: #04070a;
    border: 1px solid var(--line);
    cursor: crosshair;
}

.fight-start {
    position: absolute;
    inset: 8px 18px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(4, 7, 10, 0.82);
}

.fight-start-callout {
    font-family: var(--font-term);
    font-size: 24px;
    letter-spacing: 2px;
    color: var(--amber);
    text-shadow: 0 0 12px rgba(255, 200, 87, 0.6);
    text-align: center;
    animation: callout-blink 1.2s steps(2) infinite;
}

@keyframes callout-blink {
    50% {
        opacity: 0.55;
    }
}

.fight-howto {
    border: 1px solid var(--line);
    background: rgba(12, 19, 17, 0.92);
    padding: 10px 18px;
    width: max-content; /* grow to the longest line... */
    max-width: 96%; /* ...but never past the card */
    font-size: 12px;
    line-height: 1.7;
    color: var(--ink);
    white-space: normal;
}

.fight-howto .howto-title {
    font-family: var(--font-term);
    font-size: 19px;
    letter-spacing: 3px;
    color: var(--cyan);
}

.fight-howto .howto-key {
    color: var(--neon);
    font-family: var(--font-term);
    font-size: 14px;
}

.fight-start-hint {
    color: var(--dim);
    font-size: 12px;
    text-align: center;
    line-height: 1.6;
}

.fight-foot {
    padding: 10px 18px;
    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 13px;
    line-height: 1.6;
}

.howto-link {
    color: var(--magenta);
    text-decoration: none;
    letter-spacing: 2px;
}

.howto-link:hover {
    text-shadow: 0 0 10px rgba(255, 43, 214, 0.8);
}

.fight-foot .nh-guess {
    color: var(--cyan);
}

.tt-btn {
    letter-spacing: 0;
    font-size: 14px;
    padding: 1px 8px;
}

.tt-btn.tt-sel {
    background: var(--neon);
    color: #04130b;
    box-shadow: 0 0 12px rgba(61, 255, 160, 0.5);
}

.tt-hint {
    color: var(--dim);
    font-size: 11px;
}

/* the speed control — a slower/faster pair around the current speed */
.ff-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    vertical-align: middle;
}

.ff-btn {
    letter-spacing: 0;
    font-size: 14px;
    padding: 1px 8px;
    border-color: var(--cyan);
    color: var(--cyan);
}

.ff-label {
    font-family: var(--font-term);
    font-size: 15px;
    letter-spacing: 1px;
    color: var(--dim);
    min-width: 74px;
    text-align: center;
}

.ff-label.ff-on {
    color: var(--cyan);
    text-shadow: 0 0 10px rgba(65, 232, 255, 0.6);
}

.tt-locked {
    opacity: 0.45;
    cursor: not-allowed;
}

.end-stats {
    font-family: var(--font-term);
    font-size: 19px;
    line-height: 2;
}

.end-stats .amt {
    color: var(--amber);
}

#endTitle.good {
    color: var(--neon);
}

#endTitle.bad {
    color: var(--red);
}

/* ---------- feedback popups ---------- */
.hud-float {
    position: fixed;
    transform: translate(-50%, -100%);
    font-family: var(--font-term);
    font-size: 19px;
    letter-spacing: 1px;
    pointer-events: none;
    z-index: 9500;
    animation: hudfloat 1.1s ease-out forwards;
}

.hud-float.alarm {
    color: var(--alarm);
    text-shadow: 0 0 8px rgba(240, 119, 39, 0.8);
}

.hud-float.hp-bad {
    color: var(--red);
    text-shadow: 0 0 8px rgba(255, 80, 82, 0.8);
}

.hud-float.hp-good {
    color: var(--neon);
    text-shadow: 0 0 8px rgba(61, 255, 160, 0.8);
}

@keyframes hudfloat {
    0% {
        opacity: 0;
        transform: translate(-50%, -100%) scale(0.6);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -110%) scale(1.25);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -240%) scale(1);
    }
}

#hpPips {
    display: inline-block;
}

.hp-pop {
    animation: hppop 0.45s ease-out;
}

@keyframes hppop {
    30% {
        transform: scale(1.55);
    }
}

.map-tip {
    position: fixed;
    z-index: 9600;
    background: rgba(7, 10, 9, 0.94);
    border: 1px solid var(--cyan);
    color: var(--ink);
    font-size: 12px;
    padding: 3px 9px;
    pointer-events: none;
    white-space: nowrap;
}

.map-tip.wide {
    white-space: pre-line;
    max-width: 320px;
    line-height: 1.55;
    padding: 8px 12px;
}

.bar-group,
.hub-tip {
    cursor: help;
}

.bar-group.objective {
    cursor: default;
}

/* narrow screens: stack comms under stage */
@media (max-width: 900px) {
    .main {
        flex-direction: column;
        overflow-y: auto;
    }
    .comms {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--line);
        max-height: 40vh;
    }
    .hub {
        flex-direction: column;
    }
}
