/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=VT323&family=Share+Tech+Mono&display=swap');

:root {
    /* Main Palette */
    --phosphor-primary: #3cff8f;
    /* Minty Green */
    --phosphor-secondary: #1fa85b;
    /* Dimmer Green */
    --phosphor-bright: #ccffcc;
    /* Brightest Glare */

    /* Accents */
    --accent-amber: #ffb000;
    --accent-red: #ff4c4c;
    --accent-blue: #4cc9ff;

    /* Backgrounds */
    --screen-bg: #0b0f0c;
    --screen-overlay: rgba(10, 20, 15, 0.85);

    /* Effects */
    --scanline-color: rgba(0, 0, 0, 0.6);
    --glass-reflection: rgba(60, 255, 143, 0.05);
    --terminal-shadow: 0 0 10px rgba(60, 255, 143, 0.4), 0 0 2px var(--phosphor-primary);
    --text-glow: 0 0 4px var(--phosphor-secondary);
}

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

body {
    background-color: #050505;
    color: var(--phosphor-primary);
    font-family: 'Share Tech Mono', 'VT323', monospace;
    /* More technical font */
    height: 100vh;
    overflow: hidden;
    position: relative;
    font-size: 1.1rem;
    cursor: default;
}

/* CRT Overlay Container - The "Physical" Screen */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(60, 255, 143, 0.08), transparent 80%);
    pointer-events: none;
    z-index: 15;
}

/* CRT Effects */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(0deg,
            var(--scanline-color) 0px,
            var(--scanline-color) 2px,
            transparent 2px,
            transparent 4px);
    pointer-events: none;
    z-index: 10;
    opacity: 0.3;
}

.screen-curvature {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.6) 100%);
    pointer-events: none;
    z-index: 11;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.9);
}

/* Animations */
@keyframes flicker {
    0% {
        opacity: 0.95;
    }

    5% {
        opacity: 0.8;
    }

    10% {
        opacity: 0.9;
    }

    15% {
        opacity: 0.85;
    }

    20% {
        opacity: 0.95;
    }

    50% {
        opacity: 0.9;
    }

    90% {
        opacity: 0.85;
    }

    100% {
        opacity: 0.95;
    }
}

body::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(18, 16, 16, 0.1);
    opacity: 0;
    z-index: 10;
    pointer-events: none;
    animation: flicker 0.15s infinite;
}

/* Terminal Layout */
.terminal-container {
    max-width: 1100px;
    height: 95vh;
    margin: 2.5vh auto;
    display: flex;
    /* Row layout */
    flex-direction: row;
    gap: 1.5rem;
    padding: 1.5rem;
    position: relative;
    z-index: 5;
    background: var(--screen-bg);
    border: 3px solid var(--phosphor-secondary);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(60, 255, 143, 0.1);
    border-radius: 20px;
}

/* Sidebar */
.sidebar-panel {
    width: 300px;
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-shrink: 0;
}

/* Main Panel */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
    /* Prevent flex overflow */
}

/* Header */
.terminal-header {
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--phosphor-secondary);
    padding-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-line {
    opacity: 0.7;
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--phosphor-secondary);
}

.terminal-header h1 {
    font-size: 2rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-shadow: 0 0 8px var(--phosphor-primary);
    margin: 0.5rem 0;
}

.system-status {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--accent-amber);
    font-weight: bold;
}

/* Main Content */
.terminal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: hidden;
    /* Manage scroll internally */
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #000500;
    border-left: 1px solid var(--phosphor-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--phosphor-secondary);
    border: 1px solid #000;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--phosphor-primary);
}

/* Frames */
.frame-box {
    border: 1px solid var(--phosphor-secondary);
    padding: 1rem;
    position: relative;
    background: rgba(0, 15, 5, 0.4);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.frame-title {
    position: absolute;
    top: -0.8rem;
    left: 1rem;
    background: var(--screen-bg);
    padding: 0 0.8rem;
    font-weight: bold;
    color: var(--phosphor-primary);
    border: 1px solid var(--screen-bg);
    /* Mask line behind */
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* Visualizer */
.visualizer-section {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    /* Deep black for contrast */
    border-top: 1px solid var(--phosphor-secondary);
    border-bottom: 1px solid var(--phosphor-secondary);
    box-shadow: inset 0 0 20px #000;
    margin-bottom: 1rem;
}

canvas {
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

/* Status Info */
.info-section {
    display: flex;
    gap: 1rem;
}

.now-playing {
    width: 100%;
}

.status-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.blink {
    animation: blinker 1s linear infinite;
}

@keyframes blinker {
    50% {
        opacity: 0;
    }
}

/* Controls */
.controls-section {
    display: flex;
    justify-content: flex-start;
    /* Align left */
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
    padding: 1.5rem;
    border: 1px solid var(--phosphor-secondary);
}

.terminal-btn {
    background: rgba(60, 255, 143, 0.1);
    border: 1px solid var(--phosphor-primary);
    color: var(--phosphor-primary);
    font-family: 'Share Tech Mono', monospace;
    font-size: 1rem;
    padding: 0.8rem 2rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.15s ease;
    text-shadow: none;
    flex-shrink: 0;
    letter-spacing: 2px;
    box-shadow: 0 0 5px rgba(60, 255, 143, 0.2);
    font-weight: bold;
}

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

.terminal-btn:active {
    transform: translateY(2px);
    box-shadow: 0 0 5px var(--phosphor-primary);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-group label {
    font-size: 0.9rem;
    color: var(--phosphor-secondary);
    letter-spacing: 1px;
}

/* Range Input Styling */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 200px;
    background: transparent;
    max-width: 100%;
}

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

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 12px;
    background: var(--phosphor-primary);
    border: none;
    cursor: pointer;
    margin-top: -6px;
    box-shadow: 0 0 8px var(--phosphor-primary);
    border-radius: 1px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(31, 168, 91, 0.3);
    border: 1px solid var(--phosphor-secondary);
}

/* Station List */
.stations-section {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 250px;
}

.search-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem;
    /* border-bottom: 1px solid var(--phosphor-secondary); Removed for cleaner look */
    background: rgba(0, 0, 0, 0.3);
    margin-bottom: 0.5rem;
}

.search-prompt {
    font-size: 0.9rem;
    color: var(--accent-amber);
    font-weight: bold;
}

#search-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--phosphor-secondary);
    color: var(--phosphor-primary);
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.1rem;
    flex: 1;
    outline: none;
    caret-color: var(--accent-amber);
    /* Amber caret block */
    text-transform: uppercase;
    text-shadow: 0 0 5px var(--phosphor-primary);
    /* Specific request: 10px bottom padding */
    transition: all 0.2s;
}

#search-input:focus {
    border-bottom-color: var(--phosphor-primary);
    background: rgba(60, 255, 143, 0.05);
}

#search-input::placeholder {
    color: var(--phosphor-secondary);
    opacity: 0.5;
}

.station-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem 0;
    padding-right: 5px;
}

.station-item {
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    color: var(--phosphor-secondary);
    margin-bottom: 2px;
}

.station-item:hover {
    background: rgba(60, 255, 143, 0.1);
    border-left-color: var(--phosphor-secondary);
    color: var(--phosphor-primary);
}

.station-item.active {
    background: var(--phosphor-primary);
    color: #000;
    text-shadow: none;
    font-weight: bold;
    border-left-color: var(--accent-amber);
}

.station-item.active::before {
    content: "►";
    /* Solid arrow */
    margin-right: 10px;
}

/* Footer & Scrolling Text */
.terminal-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    flex-shrink: 0;
    color: var(--phosphor-secondary);
    border-top: 1px solid rgba(60, 255, 143, 0.2);
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    /* Add bottom padding for balance */
}

.scrolling-text {
    white-space: nowrap;
    overflow: hidden;
    box-sizing: border-box;
}

/* Responsive */
@media (max-width: 768px) {
    .terminal-container {
        flex-direction: column-reverse;
        /* Stack sidebar below main content */
        height: 100dvh;
        margin: 0;
        border: none;
        border-radius: 0;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .sidebar-panel {
        width: 100%;
        height: 40%;
        /* Take up bottom portion */
        border-top: 2px solid var(--phosphor-secondary);
    }

    .main-panel {
        height: 60%;
    }

    .terminal-header h1 {
        font-size: 1.2rem;
    }

    .visualizer-section {
        height: 120px;
    }

    .controls-section {
        padding: 1rem;
        gap: 1rem;
    }

    /* Stack elements naturally on mobile */
    .terminal-content {
        gap: 1rem;
    }

    .info-section {
        flex-direction: column;
        gap: 0.5rem;
    }

    /*
    .controls-section {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    */

    .control-group {
        width: 100%;
        justify-content: space-between;
    }

    /*
    .visualizer-section {
        min-height: 100px;
        height: 15vh;
    }
    */

    /* Make station list take remaining space but have a minimum */
    .stations-section {
        flex: 1;
        min-height: 0;
        /* Important for flex-grow to work properly in nested flex */
    }

    #search-input {
        width: 100%;
    }

    /* Hide decorative lines on very small screens to save space */
    .header-line,
    .footer-line {
        display: none;
    }
}

/* --- FALLOUT GIMMICKS STYLES --- */

/* CRT Overdrive Mode */
.crt-overdrive .terminal-container {
    box-shadow: 0 0 50px var(--accent-red), inset 0 0 50px var(--accent-red) !important;
    border-color: var(--accent-red) !important;
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both infinite;
}

.crt-overdrive,
.crt-overdrive h1,
.crt-overdrive .frame-title {
    color: var(--accent-red) !important;
    text-shadow: 0 0 10px var(--accent-red), 0 0 20px var(--accent-red) !important;
}

.crt-overdrive .crt-overlay {
    opacity: 0.6;
    background: repeating-linear-gradient(0deg,
            rgba(255, 0, 0, 0.5) 0px,
            rgba(255, 0, 0, 0.5) 2px,
            transparent 2px,
            transparent 4px);
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-2px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(2px, 0, 0);
    }
}

/* Fake Signal Interference */
.signal-interference canvas {
    filter: invert(1) hue-rotate(180deg) blur(2px);
    opacity: 0.5 !important;
    transform: scaleY(1.2) skewX(10deg);
}

/* Interaction Flash */
.interaction-flash {
    background-color: var(--accent-amber) !important;
    color: #000 !important;
    box-shadow: 0 0 15px var(--accent-amber);
    transition: background-color 0s, box-shadow 0s !important;
    /* Instant on */
}

/* Signal Drift (Jitter) */
.signal-drift {
    animation: drift-jitter 0.15s infinite;
    text-shadow: 2px 0 var(--accent-red), -2px 0 var(--accent-blue) !important;
}

@keyframes drift-jitter {
    0% {
        transform: skewX(0deg);
        opacity: 1;
    }

    20% {
        transform: skewX(-5deg) translateX(-2px);
        opacity: 0.9;
    }

    40% {
        transform: skewX(5deg) translateX(2px);
        opacity: 0.95;
    }

    60% {
        transform: skewX(-2deg);
        opacity: 0.9;
    }

    80% {
        transform: skewX(2deg);
        opacity: 1;
    }

    100% {
        transform: skewX(0deg);
        opacity: 1;
    }
}

/* Emergency Alert */
.emergency-alert {
    color: var(--accent-red) !important;
    text-shadow: 0 0 5px var(--accent-red) !important;
    font-weight: bold;
    animation: alert-blink 1s infinite alternate;
}

@keyframes alert-blink {
    from {
        opacity: 0.8;
    }

    to {
        opacity: 1;
        letter-spacing: 1px;
    }
}

/* Terminal Wear Overlay */
.terminal-wear {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    pointer-events: none;
    background: radial-gradient(circle, transparent 60%, rgba(0, 0, 0, 0.6) 100%),
        url('data:image/svg+xml;utf8,<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"><filter id="noiseFilter"><feTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23noiseFilter)" opacity="0.1"/></svg>');
    opacity: 0.5;
    mix-blend-mode: overlay;
}