:root {
    --bg-color: #0b0914;
    --primary-color: #9d4edd;
    --primary-hover: #c77dff;
    --text-color: #f8f9fa;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(157, 78, 221, 0.2), transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(199, 125, 255, 0.15), transparent 40%);
    background-size: 200% 200%;
    min-height: 100vh;
    animation: fadeIn 0.6s ease-out, bgAnimation 15s ease infinite alternate;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bgAnimation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 100%; }
    100% { background-position: 50% 0%; }
}

/* Glassmorphism */
.glass-nav, .glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.glass-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 5%;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-hover);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

.user-badge {
    background: rgba(157, 78, 221, 0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--primary-hover);
}

/* Buttons */
.btn-primary, .btn-outline {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 15px rgba(157, 78, 221, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(157, 78, 221, 0.6);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-hover);
}

.btn-outline:hover {
    background: rgba(157, 78, 221, 0.1);
    transform: translateY(-2px);
}

.large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.full-width {
    width: 100%;
    box-sizing: border-box;
}

.btn-primary:focus-visible, .btn-outline:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
}

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 10rem 1rem;
}

.hero h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.highlight {
    background: linear-gradient(to right, var(--primary-color), var(--primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero p {
    font-size: 1.2rem;
    color: #adb5bd;
    margin-bottom: 2.5rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
}

.auth-card {
    padding: 3rem;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    margin-top: 0;
    margin-bottom: 2rem;
    text-align: center;
    font-size: 2rem;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.input-group input {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-family: inherit;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

.input-group input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(157, 78, 221, 0.3);
    background: rgba(0, 0, 0, 0.4);
}

.input-group input:focus-visible, .form-select:focus-visible {
    outline: none;
}

.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-toggle {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-color);
    opacity: 0.6;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s;
}

.password-toggle:hover {
    opacity: 1;
}

.password-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    border-radius: 4px;
}

.form-select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-family: inherit;
    box-sizing: border-box;
    transition: all 0.3s ease;
    appearance: none;
}
.form-select option {
    background: var(--bg-color);
    color: var(--text-color);
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease-out;
}

.alert-error {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid rgba(255, 77, 77, 0.3);
    color: #ff8080;
}

.alert-success {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid rgba(0, 255, 136, 0.3);
    color: #00ff88;
}

.auth-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.auth-switch a {
    color: var(--primary-hover);
    text-decoration: none;
}

/* Library */
.library-container {
    padding: 2rem 5%;
}

.library-layout {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
}

.sidebar {
    width: 250px;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-nav a {
    color: var(--text-color);
    text-decoration: none;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    transition: all 0.3s;
    background: rgba(255,255,255,0.02);
}

.sidebar-nav a:hover {
    background: rgba(157, 78, 221, 0.2);
}

.sidebar-nav a.active {
    background: var(--primary-color);
    font-weight: 600;
}

.main-content {
    flex-grow: 1;
}

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

.game-card {
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 30px rgba(157, 78, 221, 0.2);
}

.game-info {
    padding: 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex-grow: 1;
}

.action-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: auto;
}

.game-info h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.3s;
    color: rgba(255,255,255,0.3);
    z-index: 10;
}

.favorite-btn:hover {
    transform: scale(1.15);
}

.favorite-btn.active {
    color: #f1c40f;
    text-shadow: 0 0 10px rgba(241, 196, 15, 0.5);
}

/* Emulator */
.emulator-container {
    padding: 2rem 5%;
    max-width: 1200px;
    margin: 0 auto;
}

.emulator-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
}

#game {
    width: 100%;
    height: 600px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    background: #000;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(11, 9, 20, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--glass-border);
    padding: 0.5rem 1rem;
    padding-bottom: env(safe-area-inset-bottom, 0.5rem);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-color);
    text-decoration: none;
    opacity: 0.7;
    transition: all 0.3s ease;
    flex: 1;
}

.nav-item.active {
    opacity: 1;
    color: var(--primary-color);
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
}

.nav-icon {
    font-size: 1.4rem;
    margin-bottom: 4px;
    transition: transform 0.3s ease;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Mobile Horizontal Filter Strip */
.mobile-filter-strip {
    display: none;
    overflow-x: auto;
    white-space: nowrap;
    padding: 0.5rem 5%;
    gap: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.mobile-filter-strip::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.mobile-filter-strip a {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
    transition: all 0.3s;
}

.mobile-filter-strip a.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    font-weight: 600;
}

/* System Card */
.system-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 2rem 1.5rem;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease, background 0.3s;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.system-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(157, 78, 221, 0.4);
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    body {
        padding-bottom: 80px; /* Space for bottom nav */
    }

    .glass-nav .nav-links {
        display: none; /* Hide top nav links */
    }

    .mobile-bottom-nav {
        display: flex; /* Show bottom nav */
        justify-content: space-between;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .hero p {
        font-size: 1rem;
    }

    .auth-card {
        padding: 1.5rem;
    }

    .library-layout {
        flex-direction: column;
        gap: 1rem;
        margin-top: 1rem;
    }

    .sidebar {
        display: none; /* Hide desktop sidebar */
    }

    .mobile-filter-strip {
        display: flex; /* Show mobile filter strip */
    }

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

    .action-buttons {
        flex-direction: column;
        gap: 8px;
    }

    .library-container {
        padding: 1rem 5%;
    }

    .game-info {
        padding: 1rem;
    }

    .game-info h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .game-card:hover {
        transform: translateY(-4px) scale(1.01);
    }
    
    .emulator-container {
        padding: 1rem 5%;
    }
    
    .emulator-container > div {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    #game {
        height: 300px;
    }
    
    /* Make emulator orientation horizontal natively or via CSS if possible, but mostly it's canvas responsive */
}
