:root {
    --primary-grad: linear-gradient(135deg, #6366f1, #a855f7);
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --border-color: rgba(255, 255, 255, 0.1);
    --text-dim: #94a3b8;
    --accent: #38bdf8;
    --danger: #ff4757;
    --spring-easing: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- BASE & MOBILE RESET --- */
body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-dark);
    color: #f8fafc;
    padding-top: 10px;
    padding-bottom: calc(110px + env(safe-area-inset-bottom));
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body.modal-open { padding-right: 0 !important; overflow: hidden; }

/* --- SPA VIEW MANAGEMENT --- */
.view {
    display: none; 
    animation: viewFadeIn 0.4s var(--spring-easing); 
}
.view.active { display: block; }

@keyframes viewFadeIn { 
    from { opacity: 0; transform: translateY(15px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* --- STICKY APP BAR --- */
.app-bar {
    position: sticky; 
    top: 0; 
    z-index: 1020;
    padding-top: calc(1rem + env(safe-area-inset-top)) !important;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}
.logo { font-weight: 800; letter-spacing: -1px; font-size: 1.4rem; }
.logo span { color: var(--accent); }

/* --- SEARCH & CATEGORIES --- */
#searchContainer { display: none; flex-grow: 1; margin-right: 12px; position: relative; }
.search-input {
    background: rgba(255, 255, 255, 0.07) !important;
    border: 1px solid var(--border-color) !important;
    color: white !important; 
    border-radius: 16px; 
    height: 46px;
    padding-right: 35px;
    transition: all 0.3s ease;
}
.search-input:focus {
    background: rgba(255, 255, 255, 0.12) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.15);
}

.category-wrapper { 
    display: flex; 
    overflow-x: auto; 
    padding: 15px 0; 
    gap: 10px; 
    scrollbar-width: none; 
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
}
.category-wrapper::-webkit-scrollbar { display: none; }

.chip {
    padding: 10px 22px; 
    border-radius: 14px; 
    background: var(--card-bg);
    border: 1px solid var(--border-color); 
    color: var(--text-dim);
    font-size: 14px; 
    font-weight: 600; 
    white-space: nowrap; 
    cursor: pointer;
    transition: 0.25s var(--spring-easing);
    scroll-snap-align: start;
}
.chip.active { 
    background: var(--primary-grad); 
    color: white; 
    border-color: transparent; 
    transform: scale(1.05);
    box-shadow: 0 8px 20px -5px rgba(99, 102, 241, 0.5);
}

/* --- GAME CARDS --- */
.game-card {
    background: var(--card-bg); 
    border: 1px solid var(--border-color);
    border-radius: 24px; 
    padding: 10px; 
    position: relative;
    transition: 0.3s var(--spring-easing);
    will-change: transform;
}
.game-card:active { transform: scale(0.92); }

.thumb-wrapper { 
    width: 100%; 
    aspect-ratio: 1/1; 
    border-radius: 18px; 
    overflow: hidden; 
    margin-bottom: 10px; 
    background: #242f44;
    position: relative;
}

.thumb-wrapper::after {
    content: ""; 
    position: absolute; 
    top: 0; 
    left: -150%;
    width: 150%; 
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    animation: shimmer 1.8s infinite linear;
}
.thumb-wrapper.loaded::after { display: none; }

@keyframes shimmer { 100% { left: 150%; } }

.thumb-wrapper img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    opacity: 0; 
    transition: opacity 0.6s ease; 
}

.game-title { 
    font-size: 14px; 
    font-weight: 600; 
    text-align: center; 
    margin: 0; 
    color: #fff;
}

.fav-btn {
    position: absolute; 
    top: 18px; 
    right: 18px; 
    z-index: 5;
    background: rgba(15, 23, 42, 0.6); 
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1); 
    color: white; 
    width: 36px; 
    height: 36px; 
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center;
    transition: 0.3s var(--spring-easing);
}
.fav-btn.active { 
    color: var(--danger); 
    background: white; 
    border-color: white;
    transform: scale(1.1);
}

/* --- SETTINGS UI FIXES --- */
#settingsView h4 { font-size: 1.5rem; }
#settingsView h6 { 
    font-size: 0.75rem; 
    letter-spacing: 1px; 
    margin-top: 20px;
    color: var(--text-dim) !important;
}

.settings-group {
    background: var(--card-bg); 
    border-radius: 20px;
    margin-bottom: 20px; 
    overflow: hidden; 
    border: 1px solid var(--border-color);
}
.settings-item {
    display: flex; 
    align-items: center; 
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-color); 
    color: white; 
    text-decoration: none; 
    transition: background 0.2s;
    cursor: pointer;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:active { background: rgba(255,255,255,0.05); }

.settings-icon {
    width: 38px; 
    height: 38px; 
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    margin-right: 15px; 
    color: var(--accent);
    font-size: 1.1rem;
}

.settings-label { 
    flex-grow: 1; 
    font-weight: 600; 
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}

/* Red text for Clear Favorites specifically */
.settings-item .text-danger { color: var(--danger) !important; }

/* --- BOTTOM NAV --- */
.bottom-nav {
    position: fixed; 
    bottom: calc(20px + env(safe-area-inset-bottom)); 
    left: 20px; 
    right: 20px;
    height: 72px; 
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(25px); 
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.1); 
    border-radius: 26px;
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    z-index: 1050;
    transition: transform 0.4s var(--spring-easing), opacity 0.3s ease;
}
.nav-link { 
    color: var(--text-dim); 
    text-decoration: none; 
    padding: 12px; 
    position: relative; 
    font-size: 1.3rem; 
}
.nav-link.active { color: var(--accent); }
.nav-link.active::after {
    content: ''; 
    position: absolute; 
    bottom: 0; 
    left: 50%;
    transform: translateX(-50%); 
    width: 6px; 
    height: 6px;
    background: var(--accent); 
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent);
}
.nav-hidden { transform: translateY(150px); opacity: 0; }

/* --- MODAL & EMPTY STATES --- */
.modal-content {
    background: rgba(30, 41, 59, 0.98);
    backdrop-filter: blur(20px); 
    border: 1px solid var(--border-color);
    border-radius: 32px; 
    color: white;
}
.modal-backdrop { background-color: rgba(15, 23, 42, 0.85); }

.empty-state { text-align: center; padding: 60px 20px; opacity: 0.6; }
.empty-state i { font-size: 3.5rem; margin-bottom: 20px; color: var(--text-dim); }

.ad-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: white;
}

.ad-loading-content .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--accent) !important;
}