/* Root Variables & Cyberpunk Palette */
:root {
    --bg-color: #020205;
    --panel-bg: rgba(10, 10, 20, 0.65);
    --panel-border: rgba(0, 255, 102, 0.2);
    --neon-green: #00ff66;
    --neon-cyan: #00f0ff;
    --neon-red: #ff3333;
    --neon-yellow: #ffcc00;
    --neon-blue: #0077ff;
    --text-color: #e2e8f0;
    --text-muted: #64748b;
    --font-primary: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --glow-shadow: 0 0 15px rgba(0, 255, 102, 0.35);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Fullscreen Canvas Container */
#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* CRT Scanlines and Noise Overlay */
.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.04),
        rgba(0, 255, 0, 0.02),
        rgba(0, 0, 255, 0.04)
    );
    background-size: 100% 4px, 6px 100%;
    z-index: 99;
    pointer-events: none;
}

.noise-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.8) 100%);
    opacity: 0.15;
    z-index: 98;
    pointer-events: none;
}

/* Overlay Screens (Boot & Story) */
.overlay-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2, 2, 5, 0.95);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.8s ease-in-out;
}

.overlay-screen.active {
    opacity: 1;
    pointer-events: all;
}

/* Terminal Styling */
.terminal-container {
    width: 90%;
    max-width: 650px;
    background: rgba(5, 5, 10, 0.9);
    border: 1px solid var(--panel-border);
    box-shadow: 0 0 30px rgba(0, 255, 102, 0.15);
    border-radius: 6px;
    overflow: hidden;
}

.terminal-header {
    background: rgba(15, 15, 25, 0.9);
    padding: 10px 15px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
}

.terminal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
}

.terminal-dot.red { background-color: var(--neon-red); }
.terminal-dot.yellow { background-color: var(--neon-yellow); }
.terminal-dot.green { background-color: var(--neon-green); }

.terminal-title {
    margin-left: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.terminal-body {
    padding: 25px;
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.6;
}

.text-alert {
    color: var(--neon-red);
    font-weight: 800;
    margin-bottom: 15px;
    animation: flash 1.5s infinite;
}

.text-log {
    color: var(--text-color);
    margin-bottom: 8px;
}

.text-math {
    color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.05);
    padding: 15px;
    margin: 15px 0;
    border-left: 3px solid var(--neon-cyan);
    white-space: pre-line;
}

.text-prompt {
    color: var(--neon-green);
    margin-top: 20px;
    margin-bottom: 25px;
}

/* Neon buttons */
.neon-btn {
    background: transparent;
    color: var(--neon-green);
    border: 1px solid var(--neon-green);
    padding: 12px 24px;
    font-family: var(--font-mono);
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(0, 255, 102, 0.1);
    transition: all 0.3s ease;
}

.neon-btn:hover {
    background: var(--neon-green);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 255, 102, 0.5);
}

/* 2. Story Screen */
.story-container {
    width: 90%;
    max-width: 700px;
    padding: 40px;
    background: rgba(5, 5, 12, 0.85);
    border: 1px solid rgba(0, 240, 255, 0.2);
    box-shadow: 0 0 35px rgba(0, 240, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(8px);
}

.story-title {
    color: var(--neon-cyan);
    font-family: var(--font-primary);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 4px;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(0, 240, 255, 0.2);
    padding-bottom: 10px;
}

.story-box {
    min-height: 120px;
    margin-bottom: 30px;
}

.story-paragraph {
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-color);
}

.story-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
}

.neon-btn-sec {
    background: transparent;
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
    padding: 10px 20px;
    font-family: var(--font-mono);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.neon-btn-sec:hover {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
}

.text-link-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.3s;
}

.text-link-btn:hover {
    color: var(--text-color);
}

.hud-status {
    display: flex;
    align-items: center;
    margin-top: 25px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.hud-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
}

.pulse-blue {
    background-color: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan);
    animation: pulse 1.5s infinite alternate;
}

/* Primary Game Interface Layout */
#game-interface {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: grid;
    grid-template-rows: 60px 1fr;
    pointer-events: none; /* Let clicks pass to canvas if needed, but sidebar is active */
}

#top-hud, #ui-sidebar, #subtitles-container, #hint-panel {
    pointer-events: all; /* Reactivate clicks on actual UI panels */
}

/* Top HUD styling */
#top-hud {
    background: linear-gradient(180deg, rgba(2, 2, 5, 0.8) 0%, rgba(2, 2, 5, 0) 100%);
    padding: 10px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.hud-left {
    display: flex;
    align-items: baseline;
    gap: 20px;
}

.hud-logo {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 2px;
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.3);
}

.hud-coord {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

.hud-control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    padding: 6px 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.hud-control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--neon-cyan);
}

.hud-status-text {
    margin-left: 20px;
    font-family: var(--font-mono);
    font-size: 12px;
}

.status-alert {
    color: var(--neon-red);
    animation: flash 1s infinite alternate;
}

.status-locked {
    color: var(--neon-green);
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.5);
    animation: none !important;
}

/* Glassmorphic Sidebar (Right Panel) */
#ui-sidebar {
    grid-column: 2;
    position: absolute;
    top: 80px;
    right: 30px;
    width: 380px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    box-shadow: 0 0 20px rgba(0, 255, 102, 0.1);
    border-radius: 8px;
    padding: 25px;
    z-index: 20;
    transition: border-color 0.8s, box-shadow 0.8s;
}

#ui-sidebar.locked {
    border-color: rgba(0, 240, 255, 0.4);
    box-shadow: 0 0 25px rgba(0, 240, 255, 0.2);
}

.sidebar-header {
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
}

.sidebar-header h3 {
    font-size: 16px;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.sidebar-header p {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Controls and Sliders */
.control-group {
    margin-bottom: 22px;
}

.control-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.slider-value {
    color: var(--neon-cyan);
}

.slider-container {
    position: relative;
    height: 24px;
    display: flex;
    align-items: center;
}

/* Custom glow range slider styling */
.glow-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    transition: all 0.3s;
}

.glow-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--text-color);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
}

.glow-slider::-webkit-slider-thumb:hover {
    background: var(--neon-green);
    box-shadow: 0 0 12px var(--neon-green);
    transform: scale(1.15);
}

/* Target vertical indicators on sliders */
.target-indicator {
    position: absolute;
    top: 4px;
    width: 2px;
    height: 16px;
    background: rgba(0, 240, 255, 0.4);
    box-shadow: 0 0 8px var(--neon-cyan);
    pointer-events: none;
}

.slider-helper {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Lock Lights indicator panel */
.lock-status-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 25px 0;
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.lock-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: var(--font-mono);
    font-size: 9px;
    color: var(--text-muted);
    gap: 6px;
}

.led-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #222;
    transition: all 0.4s ease;
}

.lock-indicator.connected {
    color: var(--neon-cyan);
}

.lock-indicator.connected .led-light {
    background-color: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan), 0 0 15px rgba(0, 240, 255, 0.5);
}

/* Catalyst Ingestion Box */
#catalyst-box {
    border-top: 1px dashed var(--panel-border);
    margin-top: 10px;
    padding-top: 25px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(15px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

#catalyst-box.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.catalyst-header h4 {
    color: var(--neon-cyan);
    font-size: 13px;
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.catalyst-header p {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 15px;
}

.catalyst-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#catalystInput {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    border-radius: 4px;
    outline: none;
    text-transform: uppercase;
    transition: all 0.3s;
}

#catalystInput:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}

.neon-btn-pulse {
    background: transparent;
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
    padding: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
}

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

.catalyst-status {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: 10px;
}

/* Subtitles/Log Display (Bottom Centered) */
#subtitles-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 800px;
    background: rgba(5, 5, 8, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    padding: 18px 25px;
    z-index: 20;
    display: grid;
    grid-template-columns: 80px 1fr;
    align-items: center;
    gap: 20px;
}

.subtitles-box {
    display: flex;
    flex-direction: column;
}

.subtitles-sender {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--neon-green);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

#subtitles {
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-color);
    min-height: 40px;
}

/* Oscilloscope representation */
.oscilloscope-container {
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 5px;
}

.osc-bar {
    width: 3px;
    height: 10%;
    background-color: var(--neon-green);
    border-radius: 1px;
    transition: height 0.1s ease;
}

/* Float Hint Panel */
#hint-panel {
    position: absolute;
    bottom: 30px;
    left: 30px;
    background: rgba(10, 10, 15, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 20;
}

.hint-icon {
    color: var(--neon-yellow);
}

/* Keyframes & Animations */
@keyframes flash {
    0% { opacity: 0.2; }
    50% { opacity: 1; }
    100% { opacity: 0.2; }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 5px var(--neon-cyan);
        opacity: 0.7;
    }
    100% {
        box-shadow: 0 0 15px var(--neon-cyan), 0 0 20px rgba(0, 240, 255, 0.4);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 900px) {
    #game-interface {
        grid-template-rows: auto auto 1fr;
    }
    #ui-sidebar {
        position: static;
        width: calc(100vw - 40px);
        margin: 20px;
        max-height: none;
    }
    #subtitles-container {
        position: static;
        transform: none;
        width: calc(100vw - 40px);
        margin: 20px;
    }
}
