:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 27, 34, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f2f5;
    --text-secondary: #9ca3af;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --success-color: #10b981;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --border-radius: 16px;
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Glassmorphism utility */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

header {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 3rem;
    width: 100%;
}

@media (min-width: 1024px) {
    main {
        grid-template-columns: 280px 1fr 300px;
    }
}

/* Sidebar / Filters */
.filters-section, .favorites-section {
    height: fit-content;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.75rem;
    font-weight: 600;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.filter-group {
    margin-bottom: 1.25rem;
}

.filter-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

select {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-speed);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%239ca3af%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem top 50%;
    background-size: 0.65rem auto;
}

select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

select option {
    background-color: #1a1d24;
}

/* Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: var(--text-secondary);
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Featured Game */
.featured-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 2rem;
    position: relative;
}

@media (min-width: 768px) {
    .featured-card {
        flex-direction: row;
    }
}

#featured-img {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

@media (min-width: 768px) {
    #featured-img {
        width: 45%;
        height: auto;
        min-height: 300px;
    }
}

.featured-content {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

#featured-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

#featured-desc {
    color: var(--text-secondary);
    margin: 1rem 0;
    flex: 1;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.genre-tag {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.stat {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Games Grid */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
}

.game-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -10px rgba(0, 0, 0, 0.5), 0 0 15px var(--accent-glow);
}

.game-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-bottom: 1px solid var(--glass-border);
    transition: transform 0.5s ease;
}

.game-card:hover img {
    transform: scale(1.05);
}

.game-card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    z-index: 1;
    background: inherit;
}

.game-card h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-card-meta {
    margin-bottom: 1rem;
    flex: 1;
}

.game-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.small-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 0 15px var(--accent-glow);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.btn-secondary.active {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.5);
    background-color: rgba(251, 191, 36, 0.1);
}

.game-card-actions .btn-primary {
    flex: 1;
}

.fav-grid-btn {
    width: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* Favorites Sidebar */
.favorites-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fav-mini-card {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.5rem;
    gap: 0.75rem;
    transition: background var(--transition-speed);
}

.fav-mini-card:hover {
    background: rgba(255, 255, 255, 0.05);
}

.fav-mini-card img {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
}

.fav-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fav-info h5 {
    font-size: 0.85rem;
    font-weight: 500;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.remove-fav-btn {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--transition-speed);
}

.remove-fav-btn:hover {
    opacity: 1;
}

.empty-state, .empty-fav {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 2rem;
}

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

.fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Search Input */
.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-speed);
}

.search-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Library Tabs */
.library-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.lib-tab {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.lib-tab:hover {
    background: rgba(255,255,255,0.05);
}

.lib-tab.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* Library Select Dropdown in Cards */
.lib-select {
    padding: 0.4rem;
    background-color: rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    text-align: center;
    background-image: none; /* Hide default arrow to save space */
}
.lib-select option {
    background-color: #1a1d24;
}

.library-section {
    max-height: 85vh;
    overflow-y: auto;
}

/* Custom Scrollbar for library */
.library-section::-webkit-scrollbar {
    width: 6px;
}
.library-section::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1); 
}
.library-section::-webkit-scrollbar-thumb {
    background: var(--glass-border); 
    border-radius: 4px;
}
.library-section::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary); 
}
