/* --- Universal Retro Console Hardware Styling --- */
#console-container {
    perspective: 1000px;
    z-index: 30;
}

#console-hardware {
    background: #2a2a2a;
    border-bottom: 10px solid #151515;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

/* Theme Adaptations for Console */
[data-theme='brick'] #console-hardware {
    background: #306230;
    border-bottom-color: #0f380f;
    border-radius: 0;
}
[data-theme='brick'] #active-cartridge {
    background: #8bac0f;
    border-radius: 0;
}

[data-theme='os'] #console-hardware {
    background: #c0c0c0;
    border: 2px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    border-bottom-width: 10px;
    border-radius: 0;
}

[data-theme='legacy'] #console-hardware {
    background: #000000;
    border: 1px solid #ffffff;
    border-bottom-width: 8px;
    border-radius: 0;
}

[data-theme='blueprint'] #console-hardware {
    background: #002b5c;
    border: 1px solid #ffffff;
    border-bottom-width: 10px;
    border-radius: 0;
}
[data-theme='blueprint'] #active-cartridge {
    background: transparent !important;
    border: 1px solid #ffffff !important;
    border-radius: 0;
}
[data-theme='blueprint'] #cart-label {
    filter: brightness(0.5) sepia(1) hue-rotate(180deg) saturate(2) !important;
}

[data-theme='woodgrain'] #console-hardware {
    background: linear-gradient(to right, #3d2b1f, #5c4033 10%, #5c4033 90%, #3d2b1f);
    border-bottom: 15px solid #1a0f00;
    border-radius: 4px;
}
[data-theme='woodgrain'] #console-hardware::before {
    content: "";
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 2px solid #ffbf00;
    opacity: 0.1;
    pointer-events: none;
}
[data-theme='woodgrain'] #active-cartridge {
    background-color: #1a0f00 !important;
    border: 2px solid #5c4033 !important;
}
[data-theme='woodgrain'] #cart-label {
    filter: sepia(0.5) contrast(1.1) brightness(0.8) !important;
}

[data-theme='papercraft'] #console-hardware {
    background-color: #cbbba0;
    background-image: url('https://www.transparenttextures.com/patterns/cardboard.png');
    border: 3px solid #a6937c;
    border-bottom: 12px solid #8c7861;
}
[data-theme='papercraft'] #active-cartridge {
    background-color: #f4eee1 !important;
    border: 2px solid #333 !important;
}
[data-theme='papercraft'] #cart-label {
    filter: grayscale(0.2) contrast(0.9) brightness(1.1) sepia(0.2) !important;
}

[data-theme='candy'] #console-hardware {
    background: radial-gradient(circle at top, rgba(0, 210, 255, 0.8), rgba(58, 123, 213, 0.9));
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-bottom: 12px solid rgba(58, 123, 213, 1);
    backdrop-filter: blur(10px);
}
[data-theme='candy'] #active-cartridge {
    background-color: rgba(255, 0, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.6) !important;
    border-radius: 1rem 1rem 0 0;
}
[data-theme='candy'] #cart-label {
    filter: saturate(1.5) brightness(1.1) !important;
}

[data-theme='arcade'] #console-hardware {
    background: #000;
    border: 2px solid #ff00ff;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.4), inset 0 0 20px rgba(255, 0, 255, 0.2);
}
[data-theme='arcade'] #active-cartridge {
    background-color: #000 !important;
    border: 2px solid #00f2ff !important;
    box-shadow: 0 0 15px #00f2ff !important;
}
[data-theme='arcade'] #cart-label {
    filter: none !important;
    position: relative;
}
[data-theme='arcade'] #cart-label::after {
    content: "";
    position: absolute;
    inset: 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, 255, 0, 0.06));
    background-size: 100% 4px, 3px 100%;
    pointer-events: none;
    z-index: 10;
}

[data-theme='obsidian'] #console-hardware {
    background: #050505;
    border: 1px solid #222;
    border-bottom: 10px solid #000;
}
[data-theme='obsidian'] #active-cartridge {
    background-color: #0f0f0f !important;
    border: 1px solid #ff6600 !important;
}
[data-theme='obsidian'] #cart-label {
    filter: contrast(1.2) brightness(0.7) grayscale(0.5) !important;
}

[data-theme='hydraulic'] #console-hardware {
    background-color: #1f2937;
    border: 4px solid #111827;
    border-bottom: 15px solid #000;
}
[data-theme='hydraulic'] #console-hardware::before {
    content: "";
    position: absolute;
    top: 5px; left: 5px; right: 5px; bottom: 5px;
    border: 1px solid rgba(251, 191, 36, 0.1);
    pointer-events: none;
}
[data-theme='hydraulic'] #active-cartridge {
    background-color: #111827 !important;
    border: 2px solid #fbbf24 !important;
}
[data-theme='hydraulic'] #cart-label {
    filter: contrast(1.2) brightness(0.8) sepia(0.3) !important;
}

[data-theme='overgrown'] #console-hardware { background-color: #1a2421; border: 3px solid #3d4a44; border-bottom: 12px solid #0f1412; }
[data-theme='overgrown'] #active-cartridge { background-color: #2d3a35 !important; border: 2px solid #4ade80 !important; }
[data-theme='overgrown'] #cart-label { filter: grayscale(0.2) sepia(0.5) hue-rotate(80deg) brightness(0.7) !important; }

[data-theme='inkwash'] #console-hardware { background-color: #e8e4d9; border: 2px solid #1a1a1a; border-bottom: 10px solid #1a1a1a; }
[data-theme='inkwash'] #active-cartridge { background-color: #f2f0e9 !important; border: 1px solid #1a1a1a !important; }
[data-theme='inkwash'] #cart-label { filter: grayscale(1) contrast(1.2) !important; mix-blend-mode: multiply; }

[data-theme='hero'] #console-hardware { background-color: #0000ff; border: 4px solid #000; border-bottom: 15px solid #000; }
[data-theme='hero'] #active-cartridge { background-color: #ff0000 !important; border: 3px solid #000 !important; }
[data-theme='hero'] #cart-label { filter: saturate(2) contrast(1.2) !important; }

[data-theme='navigator'] #console-hardware { background-color: #05070a; border: 1px solid #1e90ff; border-bottom: 10px solid #000; box-shadow: 0 0 20px rgba(30, 144, 255, 0.3); }
[data-theme='navigator'] #active-cartridge { background-color: #0b0e14 !important; border: 1px solid #00f2ff !important; box-shadow: 0 0 10px #00f2ff; }
[data-theme='navigator'] #cart-label { filter: hue-rotate(180deg) brightness(0.8) contrast(1.2) !important; }

[data-theme='glacier'] #console-hardware { background: rgba(255, 255, 255, 0.3); border: 1px solid rgba(255, 255, 255, 0.8); backdrop-filter: blur(20px); border-bottom: 10px solid #bae6fd; }
[data-theme='glacier'] #active-cartridge { background: rgba(255, 255, 255, 0.5) !important; border: 1px solid #ffffff !important; }
[data-theme='glacier'] #cart-label { filter: brightness(1.2) contrast(0.8) saturate(0.5) !important; }

[data-theme='nomad'] #console-hardware { background-color: #78350f; border: 4px solid #451a03; border-bottom: 15px solid #000; background-image: url('https://www.transparenttextures.com/patterns/asfalt-dark.png'); }
[data-theme='nomad'] #active-cartridge { background-color: #92400e !important; border: 2px solid #f59e0b !important; }
[data-theme='nomad'] #cart-label { filter: sepia(0.8) contrast(1.2) brightness(0.7) !important; }

[data-theme='prism'] #console-hardware { background: #ffffff; border: 1px solid rgba(0,0,0,0.1); border-bottom: 10px solid #000; box-shadow: 0 10px 30px rgba(0,0,0,0.05); }
[data-theme='prism'] #active-cartridge { background: #ffffff !important; border: 1px solid #000 !important; }
[data-theme='prism'] #cart-label { filter: contrast(1.1) saturate(1.2) !important; }

[data-theme='invader'] #console-hardware { background-color: #000; border: 1px solid #22c55e; border-bottom: 10px solid #22c55e; }
[data-theme='invader'] #active-cartridge { background-color: #000 !important; border: 1px solid #22c55e !important; box-shadow: 0 0 15px #22c55e; }
[data-theme='invader'] #cart-label { filter: grayscale(1) contrast(1.5) brightness(0.8) !important; mix-blend-mode: color-dodge; }

[data-theme='virtual'] #console-hardware { background-color: #000; border: 2px solid #ff0000; border-bottom: 8px solid #ff0000; }
[data-theme='virtual'] #active-cartridge { background-color: #000 !important; border: 1px solid #ff0000 !important; }
[data-theme='virtual'] #cart-label { filter: grayscale(1) brightness(0.5) contrast(2) sepia(1) hue-rotate(-50deg) saturate(5) !important; }

[data-theme='quest'] #console-hardware { background: linear-gradient(135deg, #0000ff, #000040); border: 2px solid #ffffff; border-bottom: 10px solid #000020; }
[data-theme='quest'] #active-cartridge { background-color: #0000ff !important; border: 2px solid #ffde00 !important; }
[data-theme='quest'] #cart-label { filter: brightness(1.1) contrast(1.1) saturate(1.2) !important; }

[data-theme='genesis'] #console-hardware { background-color: #1a1a1a; border: 2px solid #333; border-bottom: 12px solid #000; box-shadow: inset 0 0 20px #000; }
[data-theme='genesis'] #active-cartridge { background-color: #111 !important; border: 2px solid #00f2ff !important; }
[data-theme='genesis'] #cart-label { filter: contrast(1.3) saturate(1.5) !important; }

[data-theme='spectrum'] #console-hardware { background-color: #000; border: 2px solid #fff; border-bottom: 8px solid #fff; }
[data-theme='spectrum'] #console-hardware::after { content: ""; position: absolute; top: 0; right: 10px; width: 20px; height: 100%; background: linear-gradient(to bottom, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff); opacity: 0.5; }
[data-theme='spectrum'] #active-cartridge { background-color: #000 !important; border: 1px solid #fff !important; }
[data-theme='spectrum'] #cart-label { filter: contrast(2) saturate(2) brightness(0.8) !important; }

[data-theme='famicom'] #console-hardware { background-color: #f2f0e9; border: 2px solid #991b1b; border-bottom: 12px solid #991b1b; box-shadow: inset 0 0 0 2px #ffde00; }
[data-theme='famicom'] #active-cartridge { background-color: #f2f0e9 !important; border: 2px solid #991b1b !important; }
[data-theme='famicom'] #cart-label { filter: sepia(0.2) contrast(1.1) !important; }

[data-theme='web1'] #console-hardware { background-color: #c0c0c0; border: 2px solid !important; border-color: #fff #808080 #808080 #fff !important; }
[data-theme='web1'] #active-cartridge { background-color: #c0c0c0 !important; border: 2px solid !important; border-color: #808080 #fff #fff #808080 !important; }
[data-theme='web1'] #cart-label { filter: grayscale(1) contrast(1.2) !important; }

[data-theme='gamegear'] #console-hardware { background-color: #111827; border: 2px solid #3b82f6; border-bottom: 15px solid #000; border-radius: 2rem !important; }
[data-theme='gamegear'] #active-cartridge { background-color: #1f2937 !important; border: 2px solid #a855f7 !important; }
[data-theme='gamegear'] #cart-label { filter: contrast(1.2) brightness(0.9) saturate(1.5) !important; }

[data-theme='manga'] #console-hardware { background-color: #fff; border: 4px solid #000; border-bottom: 12px solid #000; }
[data-theme='manga'] #active-cartridge { background-color: #fff !important; border: 3px solid #000 !important; }
[data-theme='manga'] #cart-label { filter: grayscale(1) contrast(2) !important; }

[data-theme='museum'] #console-hardware { background-color: #fff; border: 1px solid #d4af37; border-bottom: 10px solid #d4af37; box-shadow: 0 10px 30px rgba(0,0,0,0.05); }
[data-theme='museum'] #active-cartridge { background-color: #fff !important; border: 1px solid #d4af37 !important; }
[data-theme='museum'] #cart-label { filter: sepia(0.5) contrast(0.9) brightness(1.1) !important; }

[data-theme='craft'] #console-hardware { background-color: #1d4ed8; border: 4px dashed #fff; border-bottom: 15px solid #1e3a8a; border-radius: 2rem !important; }
[data-theme='craft'] #active-cartridge { background-color: #3b82f6 !important; border: 2px dashed #fff !important; }
[data-theme='craft'] #cart-label { filter: saturate(0.8) brightness(1.1) !important; border-radius: 1rem; }

[data-theme='street'] #console-hardware { background-color: #111827; border: 3px solid #22c55e; border-bottom: 12px solid #000; background-image: url('https://www.transparenttextures.com/patterns/asphalt-dark.png'); }
[data-theme='street'] #active-cartridge { background-color: #374151 !important; border: 2px solid #22c55e !important; }
[data-theme='street'] #cart-label { filter: contrast(1.2) brightness(0.8) !important; }

[data-theme='noir'] #console-hardware { background-color: #000; border: 1px solid #404040; border-bottom: 10px solid #000; }
[data-theme='noir'] #active-cartridge { background-color: #111 !important; border: 1px solid #e5e5e5 !important; }
[data-theme='noir'] #cart-label { filter: grayscale(1) contrast(1.5) brightness(0.6) !important; }

[data-theme='tokyo'] #console-hardware { background-color: #000; border: 2px solid #d946ef; border-bottom: 12px solid #000; box-shadow: 0 0 20px rgba(217, 70, 239, 0.3); }
[data-theme='tokyo'] #active-cartridge { background-color: #2e1065 !important; border: 2px solid #f0abfc !important; box-shadow: 0 0 10px #d946ef; }
[data-theme='tokyo'] #cart-label { filter: hue-rotate(280deg) saturate(1.5) !important; }

/* Cartridge Animation */
#active-cartridge {
    will-change: transform;
    opacity: 1 !important;
    background-color: #444 !important;
    z-index: 100;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#active-cartridge:hover {
    box-shadow: 0 0 15px var(--accent), 0 0 30px var(--accent) !important;
    filter: brightness(1.1);
}

/* --- Theme-Specific Cartridges --- */

/* Future: Holographic/Digital Cartridge */
[data-theme='future'] #active-cartridge {
    background-color: var(--bg-card) !important;
    border: 1px solid rgba(255,255,255,0.1) !important;
}
[data-theme='future'] #active-cartridge .flex-grow {
    background-color: var(--bg-card) !important;
}

/* Brick: Game Boy Grey */
[data-theme='brick'] #active-cartridge {
    background-color: var(--bg-card) !important;
    border: 2px solid var(--accent) !important;
}
[data-theme='brick'] #active-cartridge .flex-grow {
    background-color: var(--bg-card) !important;
}
[data-theme='brick'] #cart-title {
    color: var(--text-primary) !important;
}

/* Cube: Vibrant/Rounded */
[data-theme='cube'] #active-cartridge {
    background-color: var(--bg-card) !important;
    border: 2px solid #ffffff !important;
    border-radius: 1rem 1rem 0 0;
}
[data-theme='cube'] #active-cartridge .flex-grow {
    background-color: var(--bg-card) !important;
}

/* OS: Classic Win95 Beige/Grey */
[data-theme='os'] #active-cartridge {
    background-color: var(--bg-card) !important;
    border: 2px solid;
    border-color: #ffffff #808080 #808080 #ffffff !important;
}
[data-theme='os'] #active-cartridge .flex-grow {
    background-color: var(--bg-card) !important;
}
[data-theme='os'] #cart-title {
    color: #000000 !important;
}

/* Legacy: Stark Monochrome */
[data-theme='legacy'] #active-cartridge {
    background-color: var(--bg-card) !important;
    border: 1px solid #ffffff !important;
}
[data-theme='legacy'] #active-cartridge .flex-grow {
    background-color: var(--bg-card) !important;
}
[data-theme='legacy'] #cart-title {
    color: #ffffff !important;
}
[data-theme='legacy'] #cart-label {
    filter: grayscale(1) contrast(1.2) brightness(0.9) !important;
}

/* CRT Overlay for Cartridge label */
[data-theme='brick'] #cart-label {
    filter: sepia(1) hue-rotate(40deg) saturate(2) brightness(0.9) contrast(1.2) !important;
}
[data-theme='brick'] #cart-label::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 20;
    background-image: radial-gradient(rgba(15, 56, 15, 0.6) 1px, transparent 1px);
    background-size: 3px 3px;
    pointer-events: none;
}
