@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Press+Start+2P&display=swap');

:root {
    --bg-main: #0c0e14;
    --bg-card: rgba(22, 26, 36, 0.75);
    --bg-card-hover: rgba(30, 36, 50, 0.9);
    --bg-header: rgba(12, 14, 20, 0.9);
    
    --primary: #e2e8f0;
    --primary-glow: rgba(255, 255, 255, 0.15);
    --accent-gray: #94a3b8;
    
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --text-dim: #8492a6;
    
    --border-glass: rgba(255, 255, 255, 0.12);
    --border-hover: rgba(255, 255, 255, 0.35);
    
    --radius-lg: 14px;
    --radius-md: 8px;
    --radius-sm: 6px;
    
    --font-main: 'Outfit', sans-serif;
    --font-pixel: 'Press Start 2P', monospace;
}

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

body {
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Utility */
.hidden {
    display: none !important;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-header);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-glass);
    padding: 0.9rem 2rem;
}

.header-container {
    max-width: 1300px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--text-main);
}

.logo-title {
    font-family: var(--font-pixel);
    font-size: 0.95rem;
    letter-spacing: -0.5px;
    color: #ffffff;
}

.header-badges {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.badge-wasm {
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.badge-save {
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.16);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero-section {
    max-width: 1300px;
    margin: 2.2rem auto 1.4rem;
    padding: 0 1.5rem;
    text-align: center;
}

.hero-title {
    font-size: 2.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0.6rem;
    color: #ffffff;
}

.hero-title span {
    color: #cbd5e1;
}

.hero-subtitle {
    color: var(--text-dim);
    font-size: 1rem;
    max-width: 660px;
    margin: 0 auto 1.6rem;
}

/* ==========================================================================
   Filter & Search Toolbar
   ========================================================================== */
.toolbar-section {
    max-width: 1300px;
    margin: 0 auto 1.8rem;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-tabs {
    display: flex;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
}

.filter-tab {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.45rem 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-tab:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.06);
}

.filter-tab.active {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.search-box {
    position: relative;
    width: 260px;
}

.search-box input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    padding: 0.55rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.88rem;
    outline: none;
    transition: all 0.15s ease;
}

.search-box input:focus {
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Games Grid
   ========================================================================== */
.games-section {
    max-width: 1300px;
    margin: 0 auto 4rem;
    padding: 0 1.5rem;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.4rem;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-hover);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    background: var(--bg-card-hover);
}

.game-card-banner {
    height: 100px;
    padding: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    position: relative;
    overflow: hidden;
}

.gba-banner {
    background: linear-gradient(135deg, #1e2433 0%, #2b3346 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dos-banner {
    background: linear-gradient(135deg, #1b202c 0%, #262c3d 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.win95-banner {
    background: linear-gradient(135deg, #0f4c5c 0%, #1e293b 100%);
    border-bottom: 1px solid rgba(56, 189, 248, 0.3);
}

.nes-banner, .snes-banner, .genesis-banner, .gb-banner, .gbc-banner, .other-banner {
    background: linear-gradient(135deg, #191d28 0%, #252c3c 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.system-badge {
    font-family: var(--font-pixel);
    font-size: 0.7rem;
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.18);
    letter-spacing: 0.5px;
}

.save-badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(16, 185, 129, 0.25);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.4);
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.device-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.28rem 0.65rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.badge-mobile {
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.22);
}

.game-card-body {
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.game-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
    color: #ffffff;
}

.game-meta {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-weight: 500;
    margin-bottom: 0.75rem;
}

.game-desc {
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
    margin-bottom: 1.1rem;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.game-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.8rem;
    border-top: 1px solid var(--border-glass);
}

.author-tag {
    font-size: 0.76rem;
    color: var(--text-dim);
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-play {
    background: rgba(255, 255, 255, 0.88);
    color: #0c0e14;
    border: none;
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 0.86rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.15s ease;
}

.btn-play:hover {
    background: #ffffff;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* ==========================================================================
   Player View & Monotone Light-Gray Top HUD
   ========================================================================== */
#player-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    background: #000000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.player-hud {
    height: 44px;
    background: rgba(16, 20, 30, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    z-index: 100;
    width: 100%;
}

.btn-hud {
    flex: 1;
    max-width: 110px;
    height: 32px;
    padding: 0 8px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    
    /* GBA-style light gray translucent monotone */
    background: rgba(255, 255, 255, 0.12);
    color: #f1f5f9;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-hud:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.45);
    color: #ffffff;
}

.btn-hud:active {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0.97);
}

.hud-label {
    letter-spacing: 0.5px;
    font-size: 0.8rem;
}

.win95-hud-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.win95-hud-controls.hidden {
    display: none !important;
}

.hud-select-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    height: 32px;
    box-sizing: border-box;
}

.hud-ctrl-icon {
    font-size: 12px;
    user-select: none;
}

.hud-select {
    background: transparent;
    color: #f1f5f9;
    border: none;
    font-family: var(--font-main);
    font-size: 0.78rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    padding: 0;
}

.hud-select option {
    background: #0f172a;
    color: #f1f5f9;
}

#emulator-wrapper {
    flex: 1;
    width: 100%;
    height: calc(100% - 44px);
    position: relative;
    overflow: hidden;
    background: #000000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#emulator-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ==========================================================================
   Controls Modal (Monotone Theme)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.modal-card {
    background: #141822;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    padding: 1.6rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #ffffff;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.btn-close-modal:hover {
    color: #ffffff;
}

.controls-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.8rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
}

.key-badge {
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    font-family: var(--font-main);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 0.3rem 0.65rem;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    letter-spacing: 0.2px;
}

.control-desc {
    font-size: 0.86rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Toast Notifications (Monotone Theme)
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 3000;
    padding: 0.75rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    background: #181d2a;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast-info {
    border-color: rgba(255, 255, 255, 0.3);
}

.toast-success {
    border-color: rgba(255, 255, 255, 0.4);
    background: #1c2433;
}

.toast-warning {
    border-color: rgba(255, 255, 255, 0.3);
}

.toast-error {
    border-color: rgba(248, 113, 113, 0.5);
    background: #281519;
    color: #fca5a5;
}

/* ==========================================================================
   Mobile & Responsive Tweaks
   ========================================================================== */
@media (max-width: 768px) {
    .header-container {
        padding: 0.3rem 0;
    }
    .header-badges {
        display: none;
    }
    .hero-title {
        font-size: 1.7rem;
    }
    .toolbar-section {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box {
        width: 100%;
    }
    .games-grid {
        grid-template-columns: 1fr;
    }
    
    .player-hud {
        padding: 4px 6px;
        gap: 5px;
        height: 40px;
    }
    .btn-hud {
        height: 30px;
        padding: 0 4px;
        font-size: 0.75rem;
    }
    .hud-label {
        font-size: 0.75rem;
    }
}
