/* ==========================================================================
   Retro Win32 Arcade Web Portal - Master Stylesheet
   ========================================================================== */

:root {
    --bg-dark: #090a10;
    --bg-surface: #121422;
    --bg-card: #1a1d30;
    --bg-card-hover: #232742;
    --neon-cyan: #00f0ff;
    --neon-pink: #ff0077;
    --neon-yellow: #ffea00;
    --neon-green: #00ff88;
    --text-main: #f0f2fa;
    --text-muted: #8b92b3;
    --border-glow: rgba(0, 240, 255, 0.25);
    --radius-md: 10px;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* CRT Scanlines Filter Overlay */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    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% 3px, 3px 100%;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.crt-overlay.disabled {
    display: none;
}

/* Header */
.portal-header {
    background: rgba(18, 20, 34, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glow);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px var(--neon-cyan));
}

.brand-title {
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1px;
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    background: rgba(0, 240, 255, 0.15);
    color: var(--neon-cyan);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid var(--border-glow);
    font-weight: 700;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-tool-btn {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.nav-tool-btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.nav-tool-btn.active {
    background: rgba(0, 240, 255, 0.2);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

/* Layout Grid */
.portal-layout {
    display: grid;
    grid-template-columns: 310px 1fr;
    flex: 1;
    min-height: calc(100vh - 65px);
}

/* Sidebar Navigation */
.arcade-sidebar {
    background: var(--bg-surface);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    padding: 18px 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-left: 6px;
    font-weight: 700;
}

.game-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.game-nav-item {
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.game-nav-item:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateX(3px);
}

.game-nav-item.active {
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.12), rgba(255, 0, 119, 0.12));
    border-color: var(--neon-cyan);
    box-shadow: 0 0 14px rgba(0, 240, 255, 0.2);
}

.game-nav-icon {
    font-size: 24px;
    min-width: 32px;
    text-align: center;
}

.game-nav-info {
    flex: 1;
    overflow: hidden;
}

.game-nav-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-nav-item.active .game-nav-title {
    color: var(--neon-cyan);
}

.game-nav-tag {
    font-size: 11px;
    color: var(--text-muted);
}

.badge-featured {
    background: var(--neon-pink);
    color: #fff;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.badge-win32 {
    background: #000080;
    color: #fff;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
}

/* Main Display Area */
.arcade-viewport {
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: radial-gradient(circle at top center, #181b30 0%, #090a10 70%);
    overflow-y: auto;
}

.viewport-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.current-game-title-group h2 {
    font-family: 'Orbitron', monospace, sans-serif;
    font-size: 22px;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.current-game-desc {
    font-size: 13px;
    color: var(--text-muted);
}

.viewport-actions {
    display: flex;
    gap: 8px;
}

/* Stage Frame */
.game-stage-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 16px;
    flex: 1;
}

.game-stage {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 240, 255, 0.15);
    background: #000;
    max-width: 100%;
}

.game-canvas {
    display: block;
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* On-Screen Mobile Virtual Controls */
.mobile-controls-overlay {
    display: none; /* Auto-shown on touch devices or small screens */
    margin-top: 14px;
    padding: 12px;
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    justify-content: space-between;
    align-items: center;
    user-select: none;
    touch-action: manipulation;
}

.mobile-dpad {
    display: flex;
    gap: 10px;
}

.v-btn {
    background: var(--bg-card);
    border: 2px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    width: 68px;
    height: 60px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.1s ease;
}

.v-btn:active, .v-btn.active {
    background: var(--neon-cyan);
    color: #000;
    box-shadow: 0 0 15px var(--neon-cyan);
    transform: scale(0.96);
}

.v-btn-action {
    background: linear-gradient(135deg, rgba(255, 0, 119, 0.3), rgba(0, 240, 255, 0.3));
    border-color: var(--neon-pink);
    width: 76px;
}

.v-btn-action:active, .v-btn-action.active {
    background: var(--neon-pink);
    color: #fff;
    box-shadow: 0 0 15px var(--neon-pink);
}

.v-label {
    font-size: 10px;
    opacity: 0.8;
}

/* Desktop Controls Helper */
.controls-hint-bar {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.hint-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.key-badge {
    background: #232742;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-family: monospace;
    font-weight: bold;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
}

/* Modal for Code Inspection */
.code-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.code-modal.hidden {
    display: none;
}

.code-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
}

.code-modal-window {
    position: relative;
    background: #111422;
    border: 1px solid var(--neon-cyan);
    border-radius: var(--radius-md);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
    z-index: 10;
}

.code-modal-header {
    background: #1a1e35;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-modal-title {
    font-family: 'Orbitron', monospace;
    font-size: 16px;
    color: var(--neon-cyan);
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-modal-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.action-btn:hover {
    background: var(--neon-cyan);
    color: #000;
}

.close-btn {
    background: transparent;
    border: none;
    color: #ff5555;
    font-size: 18px;
    cursor: pointer;
    padding: 0 6px;
}

.code-modal-desc {
    padding: 8px 18px;
    font-size: 12px;
    color: var(--text-muted);
    background: #16192c;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #0a0b12;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    color: #00ffcc;
    line-height: 1.45;
}

/* Responsive Media Queries */
@media (max-width: 900px) {
    .portal-layout {
        grid-template-columns: 1fr;
    }

    .arcade-sidebar {
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        max-height: 240px;
    }

    .mobile-controls-overlay {
        display: flex;
    }

    .controls-hint-bar {
        display: none;
    }
}
