/* BASIS SETUP */
body { margin: 0; padding: 0; background: #000; font-family: 'Courier New', monospace; overflow: hidden; color: #ff9d00; touch-action: none; }
#map { width: 100vw; height: 100vh; background: #000; z-index: 1; }

/* LEAFLET OVERRIDES */
.leaflet-div-icon { background: transparent !important; border: none !important; }

/* UI PANELS */
.stat-box, #info, #term, #node-details {
    background: rgba(10, 10, 10, 0.95) !important;
    border: 1px solid #222 !important;
    border-left: 3px solid #ff9d00 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    color: #ff9d00;
}

#game-overlay { position: absolute; top: 15px; left: 15px; z-index: 1000; display: flex; gap: 12px; }
.stat-box { padding: 8px 12px; min-width: 110px; }
.stat-lab { font-size: 9px; color: #666; letter-spacing: 1px; text-transform: uppercase; }
.stat-num { font-size: 18px; font-weight: bold; color: #fff; }

#det-bar { width: 100%; height: 4px; background: #1a1a1a; margin-top: 6px; }
#det-fill {
    height: 100%; width: 100%;
    background: #00ff88;
    transition: width 0.5s, background 0.5s, box-shadow 0.5s;
    box-shadow: 0 0 5px #00ff88;
}
/* Colour shifts handled in script.js via inline style */

#info {
    position: absolute; top: 15px; right: 15px; z-index: 1000;
    padding: 8px 12px; min-width: 110px;
}
#timer_disp { font-size: 18px; font-weight: bold; color: #fff; }

#term { position: absolute; bottom: 15px; left: 15px; width: 420px; height: 190px; padding: 12px 15px; z-index: 1000; font-size: 11px; display: flex; flex-direction: column; }
.trace-headline { font-size: 9px; color: #ff9d00; letter-spacing: 2px; text-transform: uppercase; border-bottom: 1px solid #222; padding-bottom: 5px; margin-bottom: 6px; flex-shrink: 0; }
#trace_disp { flex: 1; overflow: hidden; color: #888; line-height: 1.6; display: flex; flex-direction: column; justify-content: flex-end; }
#trace_disp div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.summary-line { font-size: 10px; color: #ff9d00; font-weight: bold; border-top: 1px solid #222; padding-top: 5px; margin-top: 5px; flex-shrink: 0; min-height: 16px; letter-spacing: 0.5px; }

#node-details { position: absolute; z-index: 1001; padding: 10px 12px; width: 150px; display: none; pointer-events: none; }
.node-headline { display: block; border-bottom: 1px solid #333; padding-bottom: 5px; margin-bottom: 8px; font-size: 12px; color: #ff9d00; font-weight: bold; }
.node-info-row { display: flex; justify-content: space-between; font-size: 10px; margin-bottom: 4px; color: #bbb; }

/* CURSOR (class names match script.js) */
.cursor-container { position: relative; width: 40px; height: 40px; will-change: transform; }
.c-circle {
    position: absolute; width: 26px; height: 26px; top: 7px; left: 7px;
    border: 2px solid #ff9d00 !important; border-radius: 50% !important;
    box-shadow: 0 0 10px #ff9d00; box-sizing: border-box; z-index: 10;
}
.c-h { position: absolute; width: 40px; height: 2px; background: #ff9d00; top: 19px; left: 0; z-index: 5; }
.c-v { position: absolute; width: 2px; height: 40px; background: #ff9d00; left: 19px; top: 0; z-index: 5; }

/* NODE DOTS — base */
.node-dot {
    width: 10px; height: 10px; border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.2);
    box-sizing: border-box; position: relative;
}

/* Security level colours */
.node-dot.sec-LOW      { background: #00ff88; box-shadow: 0 0 6px #00ff88; }
.node-dot.sec-MEDIUM   { background: #ffee00; box-shadow: 0 0 6px #ffee00; }
.node-dot.sec-HIGH     { background: #ff9d00; box-shadow: 0 0 6px #ff9d00; }
.node-dot.sec-ULTRA    { background: #ff2a2a; box-shadow: 0 0 8px #ff2a2a; }
.node-dot.sec-CRITICAL { background: #ff0000; box-shadow: 0 0 12px #ff0000; animation: pulse-critical 1s ease-in-out infinite; }

/* Payload ring — rotating dashed ring with pulse for nodes with a hidden payload */
.node-dot.has-payload::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 8px rgba(255,255,255,0.3), 0 0 14px rgba(255,255,255,0.1);
    transform: translate(-50%, -50%) rotate(0deg);
    transform-origin: center;
    animation: payload-spin 3s linear infinite, payload-pulse 2s ease-in-out infinite;
}

@keyframes payload-spin {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes payload-pulse {
    0%, 100% { opacity: 0.5; box-shadow: 0 0 6px rgba(255,255,255,0.2); }
    50%       { opacity: 1.0; box-shadow: 0 0 12px rgba(255,255,255,0.6), 0 0 20px rgba(255,255,255,0.2); }
}

.node-label { margin-top: 8px; font-size: 10px; background: rgba(0,0,0,0.85); color: #eee; padding: 2px 6px; border: 1px solid #333; white-space: nowrap; }

@keyframes pulse-critical {
    0%, 100% { box-shadow: 0 0 8px #ff0000; }
    50%       { box-shadow: 0 0 18px #ff0000, 0 0 30px rgba(255,0,0,0.4); }
}
.connector-line { stroke: #ff9d00; stroke-width: 1; opacity: 0.4; }
#svg-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 999; }

/* MINI MANUAL */

/* --- Tunable manual typography variables --- */
:root {
    --manual-font-header:    10px;
    --manual-font-line:      11px;
    --manual-line-height:    1.8;
    --manual-letter-spacing: 1px;
    --manual-font-tab-icon:  11px;
}

/* Single box — same style as HUD stat boxes, orange border spans full height */
/* Tab — always visible amber strip with chevron */
#manual-tab {
    position: absolute; top: 105px; left: 15px;
    z-index: 1001;
    width: 16px;
    background: rgba(10,10,10,0.95);
    border-left: 3px solid #ff9d00;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    border-right: 1px solid #222;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 10px 0;
    user-select: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
}

#manual-tab:hover { background: rgba(255,157,0,0.08); }

#manual-tab-icon {
    color: #ff9d00;
    font-size: var(--manual-font-tab-icon, 11px);
    line-height: 1;
}

#manual {
    position: absolute; top: 105px; left: 32px;
    z-index: 1000; width: 210px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid #222;
    border-left: none;
    box-shadow: 4px 4px 15px rgba(0,0,0,0.8);
    font-family: 'Courier New', monospace;
    color: #ff9d00;
    display: none;
}

#manual.open { display: block; }

/* Header always visible — contains title and chevron toggle */
#manual-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 7px 10px;
    font-size: var(--manual-font-header);
    letter-spacing: var(--manual-letter-spacing);
    text-transform: uppercase;
    color: #ff9d00; cursor: pointer;
    user-select: none; white-space: nowrap;
}

#manual-header:hover { background: rgba(255,157,0,0.05); }
#manual-toggle { font-size: 11px; color: #ff9d00; }

/* Body hidden when collapsed — border-top separates from header */
#manual-body {
    padding: 10px 12px;
    border-top: 1px solid #222;
}



.manual-line {
    color: #888;
    line-height: var(--manual-line-height);
    font-size: var(--manual-font-line);
}

.manual-divider { border-top: 1px solid #1a1a1a; margin: 6px 0; }
.manual-hi { color: #ff9d00; font-weight: bold; }

/* LIVE PACKET CAPTURE BAR */
/* PCAP — TICKER MODE (horizontal scrolling bar) */
#pcap-bar {
    position: absolute; bottom: 15px; right: 15px;
    z-index: 1000;
    width: calc(100vw - 480px);
    height: 38px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid #222;
    border-left: 3px solid #ff9d00;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    display: flex; align-items: center;
    overflow: hidden;
    gap: 10px; padding: 0 10px;
    box-sizing: border-box;
}

#pcap-label {
    font-size: 9px; color: #ff9d00;
    letter-spacing: 1px; text-transform: uppercase;
    white-space: nowrap; flex-shrink: 0;
}

#pcap-scroll {
    font-size: 10px; color: #888;
    font-family: 'Courier New', monospace;
    white-space: nowrap;
    overflow: visible; flex: 1;
    min-width: 0; text-overflow: clip;
}

/* PCAP — TERMINAL MODE (vertical scrolling box, matches #term) */
#pcap-terminal {
    position: absolute; bottom: 15px; right: 15px;
    z-index: 1000; width: 420px; height: 190px;
    background: rgba(10, 10, 10, 0.95);
    border: 1px solid #222;
    border-left: 3px solid #ff9d00;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
    padding: 12px 15px; box-sizing: border-box;
    font-size: 11px; font-family: 'Courier New', monospace;
    display: flex; flex-direction: column;
}

#pcap-terminal-headline {
    font-size: 9px; color: #ff9d00;
    letter-spacing: 2px; text-transform: uppercase;
    border-bottom: 1px solid #222;
    padding-bottom: 5px; margin-bottom: 6px;
    flex-shrink: 0;
}

#pcap-terminal-lines {
    flex: 1; overflow: hidden; color: #888;
    line-height: 1.6;
    display: flex; flex-direction: column;
    justify-content: flex-end;
}

#pcap-terminal-lines div {
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; font-size: 10px;
}

/* SETTINGS PANEL */
#settings-tab {
    position: absolute; top: 105px; right: 0;
    z-index: 1001; width: 16px;
    background: rgba(10,10,10,0.95);
    border-right: 3px solid #ff9d00;
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    border-left: 1px solid #222;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 10px 0; user-select: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
}

#settings-tab:hover { background: rgba(255,157,0,0.08); }
#settings-tab-icon { color: #ff9d00; font-size: 11px; line-height: 1; }

#settings-panel {
    position: absolute; top: 105px; right: 17px;
    z-index: 1000; width: 220px;
    background: rgba(10,10,10,0.95);
    border: 1px solid #222;
    border-right: none;
    box-shadow: -4px 4px 15px rgba(0,0,0,0.8);
    font-family: 'Courier New', monospace;
    color: #ff9d00;
    display: none;
}

#settings-panel.open { display: block; }

#settings-header {
    padding: 7px 10px;
    font-size: 9px; letter-spacing: 1px; text-transform: uppercase;
    color: #ff9d00; border-bottom: 1px solid #222;
    user-select: none;
}

#settings-body { padding: 10px 12px; }

.settings-row {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 10px;
}

.settings-row label {
    font-size: 9px; color: #666;
    letter-spacing: 1px; text-transform: uppercase;
    flex-shrink: 0; margin-right: 8px;
}

.settings-row input, .settings-row select {
    background: #000; border: 1px solid #333;
    border-bottom: 1px solid #ff9d00;
    color: #fff; font-family: 'Courier New', monospace;
    font-size: 11px; padding: 3px 6px;
    text-transform: uppercase; outline: none;
    width: 110px; text-align: right;
}

.settings-row select option { background: #111; }

#settings-apply {
    width: 100%; background: transparent;
    border: 1px solid #ff9d00; color: #ff9d00;
    font-family: 'Courier New', monospace;
    font-size: 10px; letter-spacing: 2px;
    padding: 8px; cursor: pointer;
    text-transform: uppercase; margin-top: 4px;
    transition: background 0.2s, color 0.2s;
}

#settings-apply:hover { background: #ff9d00; color: #000; }
#settings-panel.locked { opacity: 0.4; pointer-events: none; }

#settings-reset {
    width: 100%; background: transparent;
    border: 1px solid #ff2a2a; color: #ff2a2a;
    font-family: 'Courier New', monospace;
    font-size: 10px; letter-spacing: 2px;
    padding: 8px; cursor: pointer;
    text-transform: uppercase; margin-top: 6px;
    transition: background 0.2s, color 0.2s;
}
#settings-reset:hover { background: #ff2a2a; color: #000; }
#settings-panel.locked { opacity: 0.4; pointer-events: none; }
#settings-panel.locked #settings-reset { opacity: 1; pointer-events: auto; }

/* LOADING DIM OVERLAY */
/* LOADING OVERLAY — dims entire screen during node generation */
#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1500;
    background: rgba(0, 0, 0, 0.55);
    pointer-events: none;
    transition: opacity 0.8s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* NODE GENERATION PROGRESS BAR — slim, bottom center between boxes */
#node-progress-bar {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: 320px;
    height: 28px;
    background: rgba(10,10,10,0.98);
    border: 1px solid #333;
    border-top: 2px solid #ff9d00;
    box-shadow: 0 4px 20px rgba(0,0,0,0.9);
    display: flex; align-items: center;
    gap: 10px; padding: 0 12px;
    box-sizing: border-box;
    font-family: 'Courier New', monospace;
    transition: opacity 0.5s ease;
}

#node-progress-label {
    font-size: 9px; color: #ff9d00;
    letter-spacing: 1px; text-transform: uppercase;
    white-space: nowrap; flex-shrink: 0;
}

#node-progress-track {
    flex: 1; height: 3px;
    background: #1a1a1a; border-radius: 2px;
    overflow: hidden;
}

#node-progress-fill {
    height: 100%; width: 0%;
    background: #ff9d00;
    box-shadow: 0 0 4px #ff9d00;
    transition: width 0.2s ease;
    border-radius: 2px;
}

#node-progress-count {
    font-size: 9px; color: #666;
    letter-spacing: 1px; white-space: nowrap;
    flex-shrink: 0;
}

/* HOME MARKER TOOLTIP */
.home-tooltip {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #ff00aa !important;
    font-family: 'Courier New', monospace !important;
    font-size: 9px !important;
    letter-spacing: 2px !important;
    font-weight: bold !important;
}
.home-tooltip::before { display: none !important; }

/* HOP LINE ANIMATION */
.hop-line {
    stroke-dasharray: 8 6;
    stroke-dashoffset: 100;
}

/* Directional flow — dashes move from origin toward target */
@keyframes hop-flow {
    from { stroke-dashoffset: 100; }
    to   { stroke-dashoffset: 0; }
}

@keyframes hop-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* NODE VALIDATED GLOW */
.node-dot.validated {
    box-shadow: 0 0 12px rgba(255,255,255,0.4) !important;
}

/* NAME ENTRY OVERLAY */
#name-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 3000; display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.95);
}

#name-box {
    background: rgba(10, 10, 10, 0.98);
    border: 1px solid #333;
    border-left: 3px solid #ff9d00;
    padding: 50px 60px;
    text-align: center;
    min-width: 340px;
    box-shadow: 0 0 60px rgba(0,0,0,0.9);
    font-family: 'Courier New', monospace;
}

#name-title {
    font-size: 28px; font-weight: bold;
    letter-spacing: 6px; color: #ff9d00;
    text-shadow: 0 0 20px rgba(255,157,0,0.4);
}

#name-subtitle {
    font-size: 10px; color: #444;
    letter-spacing: 3px; margin-top: 6px;
    text-transform: uppercase;
}

#name-divider {
    border-top: 1px solid #222; margin: 24px 0;
}

.name-label {
    font-size: 9px; color: #666;
    letter-spacing: 2px; text-transform: uppercase;
    margin-bottom: 10px;
}

#name-input {
    width: 100%; box-sizing: border-box;
    background: #000; border: 1px solid #333;
    border-bottom: 2px solid #ff9d00;
    color: #fff; font-family: 'Courier New', monospace;
    font-size: 16px; letter-spacing: 3px;
    padding: 10px; text-align: center;
    text-transform: uppercase; outline: none;
    margin-bottom: 24px;
}

#name-input::placeholder { color: #333; }
#name-input:focus { border-bottom-color: #fff; }

#name-btn {
    width: 100%; background: transparent;
    border: 1px solid #ff9d00; color: #ff9d00;
    font-family: 'Courier New', monospace;
    font-size: 12px; letter-spacing: 2px;
    padding: 12px; cursor: pointer;
    text-transform: uppercase;
    transition: background 0.2s, color 0.2s;
}

#name-btn:hover { background: #ff9d00; color: #000; }

/* END GAME OVERLAY */
#end-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 2000;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.85);
    animation: fadeIn 0.6s ease;
}

#end-box {
    background: rgba(10, 10, 10, 0.98);
    border: 1px solid #333;
    padding: 50px 60px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
}

#end-title {
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin-bottom: 20px;
}

#end-message {
    font-size: 13px;
    color: #888;
    line-height: 1.8;
    margin-bottom: 30px;
    letter-spacing: 1px;
}

#end-score {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #fff;
}

#end-subtitle {
    font-size: 11px; color: #666; letter-spacing: 2px;
    text-transform: uppercase; margin-top: 6px;
}

#end-divider, #end-divider2 {
    border-top: 1px solid #222; margin: 20px 0;
}

#end-stats {
    display: flex; flex-direction: column; gap: 8px;
}

.end-stat-row {
    display: flex; justify-content: space-between;
    font-size: 12px; letter-spacing: 1px;
    color: #888; text-transform: uppercase;
}

.end-stat-row span:last-child { color: #fff; font-weight: bold; }

/* Win variant — amber glow */
#end-overlay.end-won #end-box  { border-left: 3px solid #ff9d00; box-shadow: 0 0 40px rgba(255, 157, 0, 0.15); }
#end-overlay.end-won #end-title { color: #ff9d00; text-shadow: 0 0 20px rgba(255, 157, 0, 0.5); }

/* Lost variant — red glow */
#end-overlay.end-lost #end-box  { border-left: 3px solid #ff2a2a; box-shadow: 0 0 40px rgba(255, 42, 42, 0.15); }
#end-overlay.end-lost #end-title { color: #ff2a2a; text-shadow: 0 0 20px rgba(255, 42, 42, 0.5); }
/* energy bar is already empty on game over */

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* HUD — ALWAYS VISIBLE NEW MISSION BUTTON */
#hud-reset-btn {
    position: absolute; top: 75px; right: 15px;
    z-index: 1000;
    background: transparent;
    border: 1px solid #ff2a2a; color: #ff2a2a;
    font-family: 'Courier New', monospace;
    font-size: 9px; letter-spacing: 2px;
    padding: 5px 10px; cursor: pointer;
    text-transform: uppercase;
    transition: background 0.2s, color 0.2s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8);
}
#hud-reset-btn:hover { background: #ff2a2a; color: #000; }

/* END SCREEN — NEW MISSION BUTTON */
#end-reset-btn {
    width: 100%; background: transparent;
    border: 1px solid #ff9d00; color: #ff9d00;
    font-family: 'Courier New', monospace;
    font-size: 12px; letter-spacing: 2px;
    padding: 12px; cursor: pointer;
    text-transform: uppercase; margin-top: 20px;
    transition: background 0.2s, color 0.2s;
}
#end-reset-btn:hover { background: #ff9d00; color: #000; }