:root {
    --os-bg: #008080;
    --os-ui: #c0c0c0;
    --os-border-light: #ffffff;
    --os-border-dark: #000000;
}

.theme-outrun {
    --win-bg: #050014;
    --win-border-light: #ff00ff;
    --win-border-dark: #00ffff;
    --title-bg: #2d004d;
    --title-color: #00ffff;
    --text-main: #ff00ff;
    --text-alt: #00ffff;
    --inset-bg: #000000;
    --btn-bg: #110922;
    --shadow: 4px 4px 0px rgba(0, 255, 255, 0.3);
}

.theme-nft {
    --win-bg: #ffd700; 
    --win-border-light: #ffff66; 
    --win-border-dark: #ccaa00; 
    --title-bg: #000000;
    --title-color: #ffd700;
    --text-main: #000000;
    --text-alt: #ffd700;
    --inset-bg: #e6c200;
    --btn-bg: #000000;
    --shadow: 6px 6px 0px rgba(0, 0, 0, 0.8);
}
.theme-nft .close-btn { color: var(--text-alt); }

.theme-vaporwave {
    --win-bg: #ffffff;
    --win-border-light: #00f0ff;
    --win-border-dark: #ff007f;
    --title-bg: #ff9ce6;
    --title-color: #000000;
    --text-main: #2b2b2b;
    --text-alt: #ff007f;
    --inset-bg: #f0f0f0;
    --btn-bg: #ffffff;
    --shadow: 4px 4px 0px rgba(255, 0, 127, 0.3);
}

.theme-vapor-teal {
    --win-bg: #015958; 
    --win-border-light: #00ffff; 
    --win-border-dark: #003333;
    --title-bg: #00ffff;
    --title-color: #000000;
    --text-main: #ffffff;
    --text-alt: #ff00ff; 
    --inset-bg: #002b2b;
    --btn-bg: #001111;
    --shadow: 4px 4px 0px rgba(255, 0, 255, 0.4);
}

.theme-mainframe {
    --win-bg: #000000;
    --win-border-light: #ffb000;
    --win-border-dark: #996900;
    --title-bg: #ffb000;
    --title-color: #000000;
    --text-main: #ffb000;
    --text-alt: #ffb000;
    --inset-bg: #0a0a0a;
    --btn-bg: #000000;
    --shadow: 6px 6px 0px rgba(0, 0, 0, 0.8);
}

.theme-reader {
    --win-bg: #000000;
    --win-border-light: #ffd166;
    --win-border-dark: #b38500;
    --title-bg: #ffd166;
    --title-color: #000000;
    --text-main: #ffd166;
    --text-alt: #ffd166;
    --inset-bg: #110d00;
    --btn-bg: #000000;
    --shadow: 6px 6px 0px rgba(0, 0, 0, 0.8);
}

.theme-terminal {
    --win-bg: #000000;
    --win-border-light: #00ff00;
    --win-border-dark: #008000;
    --title-bg: #008000;
    --title-color: #000000;
    --text-main: #00ff00;
    --text-alt: #00ff00;
    --inset-bg: #000000;
    --btn-bg: #000000;
    --shadow: 6px 6px 0px rgba(0, 0, 0, 0.8);
}

.theme-newspaper {
    --win-bg: #cccccc;
    --win-border-light: #ffffff;
    --win-border-dark: #808080;
    --title-bg: #808080;
    --title-color: #ffffff;
    --text-main: #000000;
    --text-alt: #000000;
    --inset-bg: #a9a9a9; 
    --btn-bg: #e0e0e0;
    --shadow: 6px 6px 0px rgba(0, 0, 0, 0.5);
}

.theme-nasa {
    --win-bg: #050c1a;
    --win-border-light: #3a7bd5;
    --win-border-dark: #1b4999; 
    --title-bg: #0b3d91;
    --title-color: #ffffff;
    --text-main: #e2eeff;
    --text-alt: #fc3d21;
    --inset-bg: #020712;
    --btn-bg: #0d1e3d;
    --shadow: 6px 6px 0px rgba(0, 0, 0, 0.8);
}

.theme-classic {
    --win-bg: #c0c0c0;
    --win-border-light: #ffffff;
    --win-border-dark: #808080;
    --title-bg: #000080;
    --title-color: #ffffff;
    --text-main: #000000;
    --text-alt: #000000;
    --inset-bg: #ffffff;
    --btn-bg: #c0c0c0;
    --shadow: 4px 4px 0px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; user-select: none; }
body {
    margin: 0; overflow: hidden; font-family: 'VT323', monospace; font-size: 20px;
    background-color: var(--os-bg);
    background-image: radial-gradient(#00000022 1px, transparent 0);
    background-size: 4px 4px;
}

.scanlines {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.2) 50%);
    background-size: 100% 4px; z-index: 9999; pointer-events: none;
}

.menu-bar {
    width: 100%; background: var(--os-ui); border-bottom: 2px solid var(--os-border-dark);
    padding: 2px 10px; display: flex; gap: 15px; position: fixed; top: 0;
    z-index: 1000; color: #000; box-shadow: 0 2px 0 var(--os-border-light) inset;
}
.menu-item { position: relative; cursor: pointer; padding: 2px 8px; display: flex; align-items: center; }
.menu-item:hover { background: #000080; color: #fff; }

.dropdown {
    display: none; position: absolute; top: 100%; left: 0; background: var(--os-ui);
    border: 2px solid var(--os-border-light); border-right-color: var(--os-border-dark);
    border-bottom-color: var(--os-border-dark); box-shadow: 2px 2px 0px rgba(0,0,0,0.5);
    min-width: 200px; z-index: 1001; color: #000; margin-top: 2px;
}
.dropdown.show { display: block; }
.dropdown-item { padding: 6px 12px; white-space: nowrap; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.dropdown-item:hover { background: #000080; color: #fff; }
.dropdown-icon { width: 20px; display: flex; justify-content: center; align-items: center; flex-shrink: 0; }

.window {
    position: absolute; background: var(--win-bg); border: 2px solid var(--win-border-light);
    border-right-color: var(--win-border-dark); border-bottom-color: var(--win-border-dark);
    box-shadow: var(--shadow); display: none; flex-direction: column; z-index: 10;
    color: var(--text-main);
}
.window-header {
    background: var(--title-bg); color: var(--title-color); padding: 4px 8px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: grab; font-weight: bold; border-bottom: 2px solid var(--win-border-light);
}
.window-header:active { cursor: grabbing; }

.close-btn {
    background: var(--btn-bg); border: 2px solid var(--win-border-light);
    border-right-color: var(--win-border-dark); border-bottom-color: var(--win-border-dark);
    width: 20px; height: 20px; display: flex; justify-content: center; align-items: center;
    cursor: pointer; color: var(--text-main); font-size: 16px;
}
.close-btn:active {
    border-color: var(--win-border-dark); border-right-color: var(--win-border-light);
    border-bottom-color: var(--win-border-light);
}

.window-content { padding: 15px; display: flex; flex-direction: column; gap: 12px; height: 100%; overflow: hidden; }
.inset-box {
    background: var(--inset-bg); border: 2px solid var(--win-border-dark);
    border-right-color: var(--win-border-light); border-bottom-color: var(--win-border-light);
    padding: 8px; overflow-y: auto;
}

.window button {
    font-family: inherit; font-size: 18px; font-weight: bold; padding: 4px 15px;
    background: var(--btn-bg); border: 2px solid var(--win-border-light);
    border-right-color: var(--win-border-dark); border-bottom-color: var(--win-border-dark);
    cursor: pointer; color: var(--text-alt);
}
.window button:active {
    border-color: var(--win-border-dark); border-right-color: var(--win-border-light);
    border-bottom-color: var(--win-border-light);
}
.window button:disabled { opacity: 0.5; cursor: not-allowed; }

::-webkit-scrollbar { width: 12px; }
::-webkit-scrollbar-track { background: var(--win-bg); border-left: 1px solid var(--win-border-dark); }
::-webkit-scrollbar-thumb { background: var(--win-border-light); }

/* 📈 Wall Street Mainframe Specific Styles */
.index-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.index-block {
    background: #000; border: 2px solid var(--win-border-light); padding: 10px;
    text-align: center; font-family: 'VT323', monospace; display: flex; flex-direction: column; justify-content: space-between;
}
.index-name { font-size: 16px; color: var(--text-main); }
.index-value { font-size: 28px; font-weight: bold; margin: 4px 0; color: #fff; }
.index-change { font-size: 14px; color: #aaa; }
.up-market { color: #00ff00 !important; }
.down-market { color: #ff0000 !important; }

.mf-action-btn {
    font-family: 'VT323', monospace; font-size: 24px; color: var(--text-main);
    padding: 10px 15px; cursor: pointer; transition: background-color 0.1s, color 0.1s;
    border: 2px solid transparent; text-align: center; width: 80%;
}
.mf-action-btn:hover { background-color: var(--win-border-light); color: #000000; }

.ticker-price { font-size: 36px; text-align: center; margin: 5px 0; background: #000; padding: 10px; }
.search-row { display: flex; gap: 5px; }
.search-input {
    flex: 1; background: #000; border: 2px solid var(--win-border-dark); color: var(--text-alt); 
    font-family: inherit; font-size: 18px; padding: 4px 8px; text-transform: uppercase; outline: none; width: 100%;
}
.search-input:focus { border-color: var(--win-border-light); }
.target-info { font-size: 18px; color: var(--text-main); border-bottom: 1px dashed var(--win-border-dark); padding-bottom: 10px; }
.related-news-container { font-size: 16px; display: none; }
.related-news-link { color: var(--text-alt); text-decoration: underline; cursor: pointer; display: block; margin-top: 5px; }
.related-news-link:hover { color: #fff; }
.news-item { cursor: pointer; padding: 10px; border-bottom: 1px dashed var(--win-border-dark); transition: background 0.1s; }
.news-item:hover { background: #332300; color: #fff; }
.news-date { color: #aaaaaa; margin-right: 15px; }

.reader-text p { margin-bottom: 15px; line-height: 1.4; user-select: text; }
.reader-header-flex { display: flex; gap: 20px; align-items: flex-start; margin-bottom: 5px; padding-bottom: 15px; border-bottom: 1px dashed var(--win-border-light); }
.reader-title-group { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.reader-image { width: 360px; height: 150px; flex-shrink: 0; object-fit: cover; border: 2px solid var(--win-border-light); display: none; image-rendering: pixelated; }

.video-container { width: 100%; background: #000; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 2px solid var(--win-border-dark); border-right-color: var(--win-border-light); border-bottom-color: var(--win-border-light); pointer-events: none; }
.retro-video { position: absolute; top: -25%; left: -25%; width: 150%; height: 150%; display: none; opacity: 0.85; filter: contrast(1.2) saturate(1.3); border: none; }
.api-stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 16px; }

.np-container { flex: 1; background: var(--inset-bg); border: 2px solid var(--win-border-dark); border-right-color: var(--win-border-light); border-bottom-color: var(--win-border-light); display: flex; justify-content: center; align-items: center; padding: 15px; overflow: hidden; perspective: 3000px; }
.book { position: relative; width: 840px; height: 100%; display: flex; transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1); transform-style: preserve-3d; transform: translateX(-210px); }
.book::after { content: ''; position: absolute; top: 0; left: 50%; bottom: 0; width: 4px; background: rgba(0,0,0,0.15); box-shadow: -2px 0 15px rgba(0,0,0,0.4); z-index: 0; transform: translateX(-50%); }
.leaf { position: absolute; top: 0; right: 0; width: 50%; height: 100%; transform-origin: left center; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.4, 0.0, 0.2, 1); }
#leaf-1 { z-index: 2; }
#leaf-2 { z-index: 1; }
#leaf-1.flipped { transform: rotateY(-180deg); z-index: 1; }
#leaf-2.flipped { transform: rotateY(-180deg); z-index: 2; }
.page { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; background: #fdfbf7; padding: 20px; display: flex; flex-direction: column; overflow: hidden; }
.page.front { transform: rotateY(0deg); border-left: 1px solid rgba(0,0,0,0.1); box-shadow: inset 15px 0 20px -15px rgba(0,0,0,0.2); }
.page.back { transform: rotateY(180deg); border-right: 1px solid rgba(0,0,0,0.1); box-shadow: inset -15px 0 20px -15px rgba(0,0,0,0.2); }
.np-masthead-container { text-align: center; margin-bottom: 5px; flex-shrink: 0; }
.np-masthead { font-family: 'Georgia', serif; font-size: 42px; font-weight: normal; letter-spacing: -1px; border-top: 2px solid #111; border-bottom: 4px double #111; padding: 5px 0; margin-bottom: 5px; }
.np-date-line { font-family: Arial, sans-serif; font-size: 10px; text-transform: uppercase; border-bottom: 1px solid #111; padding-bottom: 4px; margin-bottom: 10px; display: flex; justify-content: space-between; font-weight: bold; }
.np-story { cursor: pointer; border-bottom: 1px solid #ccc; padding-bottom: 10px; margin-bottom: 5px; flex-shrink: 0; }
.np-story:hover h1, .np-story:hover h2 { text-decoration: underline; }
.np-story h1 { font-size: 24px; line-height: 1.1; margin: 0 0 8px 0; font-family: 'Georgia', serif; }
.np-story h2 { font-size: 18px; line-height: 1.1; margin: 0 0 8px 0; font-family: 'Georgia', serif; }
.np-img { width: 45%; max-height: 100px; object-fit: cover; border: 1px solid #111; margin: 0 10px 5px 0; float: left; display: none; filter: grayscale(100%) contrast(1.2); }
.np-story::after { content: ""; display: table; clear: both; }
.np-fake-text { width: 100%; background-image: repeating-linear-gradient(to bottom, transparent, transparent 3px, #aaa 3px, #aaa 5px); margin-bottom: 5px; }
.np-filler { display: flex; flex-direction: column; flex-grow: 1; border-top: 1px dashed #ccc; padding-top: 10px; margin-top: 5px; }
.np-filler .np-fake-text { flex-grow: 1; }
.np-filler-head { width: 70%; height: 6px; background: #666; margin-bottom: 5px; flex-shrink: 0; }
.np-filler-head.short { width: 40%; }
.np-ad { border: 2px solid #111; padding: 8px; text-align: center; font-family: sans-serif; flex-shrink: 0; }
.np-ad-title { font-size: 18px; font-weight: bold; margin: 0 0 4px 0; letter-spacing: 1px; }
.np-chart-box { border-bottom: 1px solid #111; border-left: 1px solid #111; height: 60px; width: 90%; margin: 5px auto; display: flex; align-items: flex-end; gap: 6px; padding-left: 6px; flex-shrink: 0; }
.np-bar { background: #333; width: 20%; }

.nasa-body { display: flex; gap: 15px; height: 100%; }
.nasa-sidebar { width: 190px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.nasa-logo-box { text-align: center; padding: 10px 5px; border: 2px solid var(--win-border-light); background: #020712; }
.nasa-btn-list { display: flex; flex-direction: column; gap: 8px; }
.nasa-btn-list button { text-align: left; padding: 8px 10px; font-size: 18px; border-color: #3a7bd5; color: #ffffff; background: #0b2246; }
.nasa-btn-list button.active { background: #fc3d21; color: #ffffff; border-color: #ffffff; }
.nasa-viewport { flex: 1; display: flex; flex-direction: column; gap: 10px; height: 100%; overflow: hidden; }
.nasa-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; position: relative; overflow: hidden; background: #00040a; border: 2px solid #3a7bd5; }
.nasa-pixel-art { image-rendering: pixelated; filter: contrast(1.3) saturate(1.2); max-width: 220px; max-height: 220px; object-fit: contain; }
.nasa-telemetry { font-size: 15px; font-family: 'Courier New', Courier, monospace; line-height: 1.3; color: #70d6ff; max-height: 140px; overflow-y: auto; border-top: 2px solid #3a7bd5; padding-top: 6px; width: 100%; margin-top: auto; }
.moon-display { width: 160px; height: 160px; border-radius: 50%; background: #111; position: relative; box-shadow: 0 0 25px rgba(255, 255, 255, 0.2); overflow: hidden; border: 2px solid #555; image-rendering: pixelated; }
.moon-illum { position: absolute; top: 0; bottom: 0; left: 0; right: 0; background: radial-gradient(circle at 30% 30%, #f4f4f4, #cfcfcf); }

@keyframes sunSpin { 100% { transform: rotate(360deg); } }
@keyframes shadesDrop { 0%, 15%, 85%, 100% { transform: translateY(-30px); opacity: 0; } 25%, 75% { transform: translateY(0px); opacity: 1; } }
@keyframes cloudDrift { 0%, 100% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }
@keyframes rainFall { 0% { transform: translateY(-8px); opacity: 0; } 50% { opacity: 1; } 100% { transform: translateY(12px); opacity: 0; } }
@keyframes lightningFlash { 0%, 88%, 93%, 97%, 100% { opacity: 0; } 90%, 95% { opacity: 1; filter: drop-shadow(0 0 8px #ffff00); } }

.wx-anim-sun { animation: sunSpin 10s infinite linear; transform-origin: 16px 16px; }
.wx-anim-shades { animation: shadesDrop 10s infinite ease-in-out; transform-origin: 16px 16px; }
.wx-anim-cloud { animation: cloudDrift 3.5s infinite ease-in-out; }
.wx-anim-rain-drop { animation: rainFall 1s infinite linear; }
.wx-anim-bolt { animation: lightningFlash 3s infinite; }

.wx-layout-flex { display: flex; gap: 15px; width: 100%; height: 100%; }
.wx-primary-col { width: 310px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.wx-calendar-col { flex: 1; display: none; flex-direction: column; gap: 8px; overflow-y: auto; border-left: 1px dashed var(--win-border-light); padding-left: 12px; }
.wx-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.wx-day-card { background: #001f1f; border: 1px solid var(--win-border-light); padding: 6px; text-align: center; font-size: 14px; display: flex; flex-direction: column; align-items: center; gap: 3px; }

.classic-tab-btn { flex: 1; text-align: center; cursor: pointer; padding: 6px 0; border-bottom: 2px solid transparent; color: #555; font-weight: normal; }
.classic-tab-btn.active { color: #000; border-bottom: 2px solid #000; font-weight: bold; }
.graph-container { width: 100%; height: 260px; position: relative; margin: 10px 0; background: #151515; border: 2px solid var(--win-border-dark); cursor: crosshair; }
#gr-mass-slider { -webkit-appearance: none; width: 100%; height: 8px; background: #808080; outline: none; border: 1px solid #000; }
#gr-mass-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 24px; background: #c0c0c0; border: 2px solid #fff; border-right-color: #000; border-bottom-color: #000; cursor: pointer; }

/* HARD OVERRIDE: Ad Server must always remain on top and anchored */
#sponsor-window { z-index: 999999 !important; }

/* 🎵 Audio Player Visualizer Animations */
@keyframes eq-bounce {
    0%, 100% { height: 5px; }
    50% { height: 25px; }
}
@keyframes eq-bounce-lg {
    0%, 100% { height: 10px; }
    50% { height: 60px; }
}
.eq-bar {
    width: 6px;
    animation: eq-bounce 1s infinite ease-in-out;
    transform-origin: bottom;
}
/* Colorize the EQ bars to match the Outrun/Neon aesthetic */
.eq-bar:nth-child(5n+1) { background-color: #ff00ff; }
.eq-bar:nth-child(5n+2) { background-color: #00ffff; }
.eq-bar:nth-child(5n+3) { background-color: #ffb000; }
.eq-bar:nth-child(5n+4) { background-color: #00ff00; }
.eq-bar:nth-child(5n+5) { background-color: #ff007f; }

.lg-bar { width: 12px; animation-name: eq-bounce-lg; }
.eq-container.paused .eq-bar { animation-play-state: paused; height: 5px !important; }
.vol-slider { -webkit-appearance: none; width: 100%; height: 8px; background: #002b2b; outline: none; border: 1px solid var(--win-border-light); }
.vol-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 20px; background: var(--btn-bg); border: 2px solid var(--win-border-light); cursor: pointer; }

/* 💼 PORTFOLIO TABLE STYLES */
.portfolio-table { width: 100%; border-collapse: collapse; font-family: inherit; font-size: 16px; }
.portfolio-table th, .portfolio-table td { padding: 4px 8px; text-align: left; border-bottom: 1px dashed var(--win-border-dark); }
.portfolio-table th { color: #ffffff; border-bottom: 2px solid var(--win-border-light); }

/* 📱 MOBILE RESPONSIVENESS */
@media (max-width: 768px) {
    .window {
        /* Restrict all windows to screen bounds minus ad server height */
        max-width: 96vw !important;
        left: 2vw !important;
        right: auto !important;
    }
    
    #mainframe-window, #reader-window, #newspaper-window, #nasa-window, #weather-window, #time-window, #dilation-window, #ether-link-window, #nft-window, #intel-window, #research-window, #portfolio-window {
        width: 96vw !important;
        top: 40px !important;
        height: calc(100vh - 310px) !important;
    }

    #mainframe-window .window-content {
        flex-direction: column !important;
        overflow-y: auto !important;
    }
    
    #mainframe-window .window-content > div:first-child {
        display: none !important;
    }
    
    #mainframe-window .window-content > div:last-child {
        width: 100% !important;
        border-left: none !important;
    }

    #player-window, #music-player-window, #music-ext-window {
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 304px !important;
    }

    #sponsor-window {
        top: auto !important;
        bottom: 5px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }

    .book { width: 100% !important; transform: none !important; display: block !important; height: auto !important; }
    .leaf { width: 100% !important; position: relative !important; display: block !important; transform: none !important; margin-bottom: 15px; }
    .page { position: relative !important; height: auto !important; border: 2px solid var(--win-border-dark) !important; box-shadow: none !important; }
    .page.back { transform: none !important; margin-top: 15px; }
    .np-container { overflow-y: auto !important; align-items: flex-start !important; }
    #np-btn-prev, #np-btn-next, #np-page-num { display: none !important; }

    .nasa-body { flex-direction: column !important; }
    .nasa-sidebar { width: 100% !important; flex-direction: row !important; flex-wrap: wrap; }
    .nasa-btn-list { flex-direction: row !important; flex-wrap: wrap; }
    .nasa-btn-list button { flex: 1; font-size: 14px !important; padding: 4px !important; }
    .nasa-logo-box { display: none; }

    .wx-layout-flex { flex-direction: column !important; }
    .wx-primary-col { width: 100% !important; }

    .menu-item span { font-size: 16px; }
    .menu-bar { padding: 2px 4px; gap: 8px; }
}