:root {
    --bg-color: #050505;
    --primary-neon: #00f2ff;
    --secondary-neon: #bc00ff;
    --danger-neon: #ff003c;
    --success-neon: #39ff14;
    --terminal-bg: rgba(0, 0, 0, 0.85);
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

@keyframes flicker {
    0% {
        opacity: 0.8;
    }

    5% {
        opacity: 0.9;
    }

    10% {
        opacity: 0.8;
    }

    15% {
        opacity: 1;
    }

    25% {
        opacity: 0.8;
    }

    30% {
        opacity: 1;
    }

    100% {
        opacity: 1;
    }
}

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

    20% {
        transform: translate(-2px, 2px);
    }

    40% {
        transform: translate(-2px, -2px);
    }

    60% {
        transform: translate(2px, 2px);
    }

    80% {
        transform: translate(2px, -2px);
    }

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

@keyframes shake {
    0% {
        transform: translate(1px, 1px) rotate(0deg);
    }

    10% {
        transform: translate(-1px, -2px) rotate(-1deg);
    }

    20% {
        transform: translate(-3px, 0px) rotate(1deg);
    }

    30% {
        transform: translate(3px, 2px) rotate(0deg);
    }

    40% {
        transform: translate(1px, -1px) rotate(1deg);
    }

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

    60% {
        transform: translate(-3px, 1px) rotate(0deg);
    }

    70% {
        transform: translate(3px, 1px) rotate(-1deg);
    }

    80% {
        transform: translate(-1px, -1px) rotate(1deg);
    }

    90% {
        transform: translate(1px, 2px) rotate(0deg);
    }

    100% {
        transform: translate(1px, -2px) rotate(-1deg);
    }
}

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

body {
    background-color: var(--bg-color);
    color: var(--primary-neon);
    font-family: var(--font-mono);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
}

.frequency-meter {
    height: 10px;
    background: rgba(0, 242, 255, 0.1);
    position: relative;
    border: 1px solid var(--primary-neon);
}

.freq-bar {
    height: 100%;
    width: 2px;
    background: var(--danger-neon);
    position: absolute;
    left: 50%;
    transition: left 0.1s linear;
    box-shadow: 0 0 5px var(--danger-neon);
}

.freq-target {
    height: 100%;
    width: 4px;
    border-left: 1px dashed var(--primary-neon);
    border-right: 1px dashed var(--primary-neon);
    position: absolute;
    left: calc(50% - 2px);
}

.data-stream {
    font-size: 0.6rem;
    color: var(--primary-neon);
    opacity: 0.5;
    line-height: 1.2;
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Background Grid Overlay */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(0, 242, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 242, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
}

.dashboard {
    display: grid;
    grid-template-columns: 120px 1fr 300px;
    grid-template-rows: 1fr 200px;
    gap: 20px;
    padding: 20px;
    height: 100vh;
    z-index: 1;
}

/* Battery Section */
.battery-section {
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--primary-neon);
    padding: 10px;
    box-shadow: 0 0 10px var(--primary-neon);
}

.battery-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    margin-bottom: 20px;
    font-size: 1.2rem;
    letter-spacing: 5px;
}

.battery-container {
    flex-grow: 1;
    width: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary-neon);
    position: relative;
    overflow: hidden;
}

.battery-level {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--primary-neon);
    transition: height 0.5s ease-in-out, background 0.5s ease-in-out;
    box-shadow: 0 0 20px var(--primary-neon);
}

.battery-level.warning {
    background: #ffaa00;
    box-shadow: 0 0 20px #ffaa00;
}

.battery-level.critical {
    background: var(--danger-neon);
    box-shadow: 0 0 20px var(--danger-neon);
    animation: flicker 0.2s infinite;
}

/* Main Puzzle Section */
.puzzle-section {
    grid-column: 2 / 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--primary-neon);
    position: relative;
}

.puzzle-header {
    position: absolute;
    top: 20px;
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 10px;
}

.sliders-container {
    width: 80%;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.slider-group {
    display: flex;
    flex-direction: column;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    background: rgba(0, 242, 255, 0.2);
    border: 1px solid var(--primary-neon);
}

input[type=range]::-webkit-slider-thumb {
    height: 30px;
    width: 15px;
    background: var(--primary-neon);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -12px;
    box-shadow: 0 0 10px var(--primary-neon);
}

/* Gauge Display */
.gauge-container {
    margin-top: 50px;
    text-align: center;
}

.power-display {
    font-size: 5rem;
    font-weight: bold;
    text-shadow: 0 0 20px var(--primary-neon);
}

.power-unit {
    font-size: 1.5rem;
}

.stability-bar-container {
    width: 300px;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 10px;
    border: 1px solid var(--primary-neon);
    overflow: hidden;
}

.stability-progress {
    width: 0%;
    height: 100%;
    background: var(--success-neon);
    transition: width 0.1s linear;
}

/* Status Sidebar */
.status-sidebar {
    grid-column: 3 / 4;
    border: 1px solid var(--primary-neon);
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.status-module {
    margin-bottom: 20px;
    padding: 10px;
    border: 1px solid rgba(0, 242, 255, 0.3);
}

.module-title {
    font-size: 0.8rem;
    color: rgba(0, 242, 255, 0.6);
    margin-bottom: 5px;
}

.visual-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 40px;
}

.chart-bar {
    flex: 1;
    background: var(--primary-neon);
    animation: bar-dance 1s infinite alternate;
}

@keyframes bar-dance {
    from {
        height: 20%;
    }

    to {
        height: 100%;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 5px var(--primary-neon);
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
        box-shadow: 0 0 15px var(--primary-neon);
    }

    100% {
        transform: scale(1);
        opacity: 1;
        box-shadow: 0 0 5px var(--primary-neon);
    }
}

.monitor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    font-size: 0.7rem;
}

.monitor-item {
    border: 1px solid rgba(0, 242, 255, 0.1);
    padding: 2px 5px;
    background: rgba(0, 242, 255, 0.05);
}

.topology-view {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 40px;
}

.topo-node {
    width: 10px;
    height: 10px;
    background: rgba(0, 242, 255, 0.2);
    border: 1px solid var(--primary-neon);
}

.topo-node.active {
    background: var(--primary-neon);
    box-shadow: 0 0 10px var(--primary-neon);
}

.topo-node.pulse {
    animation: pulse 1s infinite;
    background: var(--danger-neon);
    border-color: var(--danger-neon);
}

.topo-line {
    flex-grow: 1;
    height: 1px;
    background: rgba(0, 242, 255, 0.2);
    margin: 0 5px;
}

@keyframes noise-flicker {
    0% {
        opacity: 0.02;
    }

    50% {
        opacity: 0.05;
    }

    100% {
        opacity: 0.02;
    }
}

/* Noise effect */
.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAUVBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGV6Y0AAAABXRSTlMAM0RVZneImf6S8v0AAACZSURBVEjH7ZJBDsAgCATFYvD/P+0LomlrTWuTXDwmM6DAsMvYj5lHmXmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8Zp5mHmY8ZrxGv8A8u8C7573z1UAAAAASUVORK5CYII=');
    opacity: 0.04;
    pointer-events: none;
    z-index: 999;
    animation: noise-flicker 0.6s infinite;
}

/* Terminal */
.terminal-footer {
    grid-column: 1 / 4;
    background: var(--terminal-bg);
    border: 1px solid var(--primary-neon);
    padding: 10px;
    font-size: 0.8rem;
    overflow-y: auto;
    color: #00ff00;
}

.terminal-line {
    margin-bottom: 2px;
}

.terminal-line::before {
    content: "> ";
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.initialize-btn {
    padding: 20px 50px;
    font-size: 2rem;
    background: transparent;
    border: 2px solid var(--primary-neon);
    color: var(--primary-neon);
    font-family: var(--font-mono);
    cursor: pointer;
    box-shadow: 0 0 20px var(--primary-neon);
    transition: all 0.3s;
}

.initialize-btn:hover {
    background: var(--primary-neon);
    color: black;
    box-shadow: 0 0 50px var(--primary-neon);
}

/* Logic classes */
.shake-screen {
    animation: shake 0.5s infinite;
}

.glitch-text {
    animation: glitch 0.3s infinite;
}

.hidden {
    display: none !important;
}

.glitch-effect {
    animation: glitch 0.2s 3;
    border-color: var(--danger-neon) !important;
}

.warning-panel {
    position: absolute;
    top: 80px;
    width: 90%;
    background: rgba(0, 242, 255, 0.05);
    border: 1px solid var(--primary-neon);
    padding: 10px;
    text-align: center;
    z-index: 5;
    pointer-events: none;
    transition: all 0.2s;
}

.warning-panel.active {
    background: rgba(255, 0, 60, 0.2);
    border: 2px solid var(--danger-neon);
    animation: flicker 0.1s infinite, shake 0.2s infinite;
    box-shadow: 0 0 20px var(--danger-neon);
}

.warning-header {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-neon);
    letter-spacing: 3px;
    transition: color 0.2s;
}

.warning-panel.active .warning-header {
    color: var(--danger-neon);
    content: "!! CRITICAL OVERLOAD !!";
    /* Note: content doesnt work on divs, will handle in JS */
}

.warning-body {
    font-size: 0.7rem;
    color: rgba(0, 242, 255, 0.6);
    text-transform: uppercase;
}

.warning-panel.active .warning-body {
    color: white;
}

/* Decorative Scanlines */
body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    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));
    z-index: 1000;
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
}

.success-state {
    color: var(--success-neon) !important;
    border-color: var(--success-neon) !important;
    box-shadow: 0 0 20px var(--success-neon) !important;
}

.fail-state {
    color: var(--danger-neon) !important;
    border-color: var(--danger-neon) !important;
    box-shadow: 0 0 20px var(--danger-neon) !important;
}

@keyframes emergency-bg {
    0% {
        background-color: var(--bg-color);
    }

    50% {
        background-color: rgba(255, 0, 60, 0.08);
    }

    100% {
        background-color: var(--bg-color);
    }
}

.emergency-state {
    animation: emergency-bg 1.2s infinite;
}