:root {
    --bg-color: #050510;
    --neon-green: #00ff41;
    --neon-cyan: #00e5ff;
    --neon-red: #ff003c;
    --neon-yellow: #ffee00;
    --glass-bg: rgba(5, 5, 16, 0.7);
    --glass-border: rgba(0, 255, 65, 0.3);
    --node-bg: rgba(0, 30, 10, 0.8);
    --node-border: #00ff41;
    --font-main: 'Share Tech Mono', monospace;
    --font-header: 'Orbitron', sans-serif;
}

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

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

#game-root {
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    color: var(--neon-green);
    font-family: var(--font-main);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.text-cyan { color: var(--neon-cyan); }
.text-green { color: var(--neon-green); }
.text-red { color: var(--neon-red); }
.text-yellow { color: var(--neon-yellow); }
.hidden { display: none !important; }
.mt-2 { margin-top: 2rem; }

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 10;
    background: radial-gradient(circle at center, #0a0a2a 0%, #000000 100%);
}
.screen.active {
    display: flex;
}

#game-screen.active {
    display: flex;
    flex-direction: column;
}

/* Grid Background */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 255, 65, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 255, 65, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
    z-index: 0;
    pointer-events: none;
    transform: perspective(500px) rotateX(60deg) translateY(100px) scale(3);
    animation: gridMove 10s linear infinite;
}

@keyframes gridMove {
    0% { background-position: 0 0; }
    100% { background-position: 0 30px; }
}

/* Menu Components */
.menu-container {
    position: relative;
    z-index: 2;
    margin: auto;
    text-align: center;
    background: rgba(0, 10, 5, 0.85);
    padding: 3rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.2), inset 0 0 20px rgba(0, 255, 65, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
}

.brand-logo {
    max-width: 120px;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px var(--neon-cyan));
}

h1 {
    font-family: var(--font-header);
    font-size: 2.5rem;
    color: var(--neon-green);
    text-shadow: 0 0 10px var(--neon-green);
    margin-bottom: 0.5rem;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 1rem;
    color: var(--neon-cyan);
    margin-bottom: 2rem;
    letter-spacing: 1px;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    background: transparent;
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    font-family: var(--font-header);
    font-size: 1.1rem;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 15px var(--neon-green);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.level-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Game HUD */
.hud {
    height: 70px;
    background: rgba(0, 0, 0, 0.9);
    border-bottom: 1px solid var(--neon-cyan);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    z-index: 20;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
}

.hud-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-header);
    color: var(--neon-cyan);
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.hud-logo {
    height: 40px;
    filter: drop-shadow(0 0 5px var(--neon-cyan));
}

.hud-stats {
    display: flex;
    gap: 2rem;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.stat-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 3px;
    letter-spacing: 1px;
}

.stat-value {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: bold;
}

.progress-bar {
    width: 100px;
    height: 10px;
    background: #222;
    border: 1px solid #444;
}

.fill {
    height: 100%;
    transition: width 0.3s ease, background 0.3s ease;
}

.integrity-high { background: var(--neon-green); box-shadow: 0 0 8px var(--neon-green); }
.integrity-med { background: var(--neon-yellow); box-shadow: 0 0 8px var(--neon-yellow); }
.integrity-low { background: var(--neon-red); box-shadow: 0 0 8px var(--neon-red); }

.threat-low { background: var(--neon-green); box-shadow: 0 0 8px var(--neon-green); }
.threat-med { background: var(--neon-yellow); box-shadow: 0 0 8px var(--neon-yellow); }
.threat-high { background: var(--neon-red); box-shadow: 0 0 8px var(--neon-red); }

/* Game Area */
.network-area {
    flex-grow: 1;
    position: relative;
    background: radial-gradient(circle at center, #0a1215 0%, #000000 100%);
    background-image: 
        linear-gradient(rgba(0, 229, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 229, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
}

#network-lines {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.conn-line {
    stroke: rgba(0, 229, 255, 0.3);
    stroke-width: 2;
    stroke-dasharray: 5, 5;
    animation: dash 20s linear infinite;
}

.conn-active {
    stroke: var(--neon-cyan);
    stroke-dasharray: none;
    animation: none;
}

.conn-danger {
    stroke: var(--neon-red);
    stroke-dasharray: 10, 5;
    animation: dashDanger 1s linear infinite;
}

@keyframes dash {
    to { stroke-dashoffset: -1000; }
}
@keyframes dashDanger {
    to { stroke-dashoffset: -20; }
}

#nodes-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

/* Nodes */
.node {
    position: absolute;
    width: 70px;
    height: 70px;
    background: var(--node-bg);
    border: 2px solid var(--node-border);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.4);
    transform: translate(-50%, -50%);
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.node:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 25px rgba(0, 255, 65, 0.8);
}

.node.selected {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 25px var(--neon-cyan);
}

.node.compromised {
    border-color: var(--neon-red);
    box-shadow: 0 0 25px var(--neon-red);
    animation: pulseRed 1.5s infinite;
}

.node.warning {
    border-color: var(--neon-yellow);
    box-shadow: 0 0 25px var(--neon-yellow);
}

.node.offline {
    border-color: #555;
    background: #222;
    box-shadow: none;
    opacity: 0.6;
}

.node-icon {
    font-size: 24px;
    pointer-events: none;
}

.node-label {
    position: absolute;
    bottom: -25px;
    white-space: nowrap;
    font-size: 0.8rem;
    color: #fff;
    background: rgba(0,0,0,0.8);
    padding: 2px 5px;
    border: 1px solid var(--neon-cyan);
    border-radius: 3px;
    pointer-events: none;
}

/* Attack Indicator */
.attack-indicator {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 24px;
    height: 24px;
    background: var(--neon-red);
    color: #fff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    animation: popIn 0.3s ease, pulseRed 1s infinite;
    pointer-events: none;
}

@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(255, 0, 60, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(255, 0, 60, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 0, 60, 0); }
}
@keyframes popIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

/* Side Panel */
.side-panel {
    position: absolute;
    right: 0;
    top: 70px;
    bottom: 0;
    width: 350px;
    background: rgba(0, 5, 10, 0.95);
    border-left: 1px solid var(--neon-cyan);
    display: flex;
    flex-direction: column;
    z-index: 10;
    backdrop-filter: blur(5px);
}

.panel-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    border-bottom: 1px solid rgba(0, 229, 255, 0.3);
}

.panel-section h3 {
    font-family: var(--font-header);
    color: var(--neon-cyan);
    font-size: 1rem;
    margin-bottom: 1rem;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(0, 229, 255, 0.5);
    padding-bottom: 5px;
}

.node-details {
    flex: 0 0 45%;
}

.event-log {
    flex: 1;
    overflow: hidden;
}

#log-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
    padding-right: 5px;
}

#log-container::-webkit-scrollbar {
    width: 5px;
}
#log-container::-webkit-scrollbar-thumb {
    background: var(--neon-cyan);
}

.log-entry { margin-bottom: 3px; word-wrap: break-word; }
.log-entry.system { color: var(--neon-cyan); }
.log-entry.alert { color: var(--neon-red); }
.log-entry.success { color: var(--neon-green); }
.log-entry.warning { color: var(--neon-yellow); }

/* Actions */
.action-btn {
    display: block;
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    background: rgba(0, 255, 65, 0.1);
    border: 1px solid var(--neon-green);
    color: var(--neon-green);
    font-family: var(--font-main);
    font-size: 0.9rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.action-btn:hover {
    background: var(--neon-green);
    color: #000;
}
.action-btn.disabled {
    border-color: #555;
    color: #555;
    background: transparent;
    cursor: not-allowed;
}

.node-meta {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 15px;
}
.node-meta span.label {
    color: rgba(255,255,255,0.5);
    display: inline-block;
    width: 80px;
}

/* Glitch Effect */
.glitch {
    position: relative;
}
.glitch::before, .glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
}
.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--neon-red);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim 3s infinite linear alternate-reverse;
}
.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--neon-cyan);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-anim {
    0% { clip: rect(10px, 9999px, 83px, 0); }
    20% { clip: rect(62px, 9999px, 20px, 0); }
    40% { clip: rect(89px, 9999px, 53px, 0); }
    60% { clip: rect(12px, 9999px, 93px, 0); }
    80% { clip: rect(44px, 9999px, 11px, 0); }
    100% { clip: rect(78px, 9999px, 34px, 0); }
}

/* Stats Summary Game Over */
.stats-summary {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: left;
    font-size: 1.1rem;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    border-bottom: 1px dashed rgba(255,255,255,0.1);
    padding-bottom: 5px;
}
.summary-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    font-weight: bold;
    font-size: 1.3rem;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
}

/* CRT Scanlines */
.scanlines {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    background-size: 100% 4px, 3px 100%;
    z-index: 100;
    pointer-events: none;
    opacity: 0.6;
}
