:root {
    --bg: #0f1115;
    --bg-secondary: #1a1d24;
    --bg-tertiary: #252830;
    --border: #2e323d;
    --text: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-muted: #5f6368;
    --accent: #7c4dff;
    --accent-light: rgba(124, 77, 255, 0.15);
    --success: #00c853;
    --warning: #ffab00;
    --danger: #ff5252;
    --info: #448aff;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 20px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    z-index: 10;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 24px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
}
.brand:hover { opacity: 0.8; }
.nav { flex: 1; padding: 8px 12px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
    margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
}
.nav-item svg { flex-shrink: 0; }
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: center;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}
.mobile-home-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5;
}
.sidebar-overlay.active { display: block; }

/* Main */
.main {
    flex: 1;
    margin-left: 220px;
    display: flex;
    flex-direction: column;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar h1 { font-size: 1.4rem; font-weight: 600; flex: 1; margin: 0 12px; }
.content { padding: 24px 28px; flex: 1; overflow-y: auto; }

/* Buttons */
.btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn:hover { background: var(--border); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-small { padding: 5px 10px; font-size: 0.8rem; }

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--accent); margin-top: 4px; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.clickable, .section-title.clickable { cursor: pointer; transition: background 0.15s, color 0.15s; }
.stat-card.clickable:hover { background: var(--bg-tertiary); border-color: var(--accent); }
.section-title.clickable:hover { color: var(--accent); }

.section-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 24px 0 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Cards */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}
.game-list { display: flex; flex-direction: column; gap: 6px; }
.game-list .list-item {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 14px; display: flex; align-items: center; gap: 12px; cursor: pointer;
    transition: var(--transition); position: relative;
}
.game-list .list-item:hover { border-color: var(--accent); }
.game-list .list-item.selected { outline: 2px solid var(--accent); box-shadow: 0 0 0 2px var(--accent-light); }
.game-list .list-item .status-badge { position: static; margin-right: 4px; }
.game-list .list-info { flex: 1; min-width: 0; }
.game-list .list-title { font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-list .list-meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.game-list .list-rating { color: var(--warning); font-size: 0.85rem; white-space: nowrap; }
.game-list .list-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.game-list .list-item:hover .list-actions { opacity: 1; }
.game-list .list-actions .icon-btn { width: 26px; height: 26px; font-size: 0.85rem; }
.game-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}
.game-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent); }
.game-card .cover {
    aspect-ratio: 3/4;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.game-card .cover img { width: 100%; height: 100%; object-fit: cover; }
.game-card .cover .no-cover {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    padding: 12px;
}
.game-card .info { padding: 10px 12px; }
.game-card .title { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-card .meta { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.game-card .rating { color: var(--warning); font-size: 0.8rem; }
.game-card .genre-tag { background: var(--bg-tertiary); padding: 1px 6px; border-radius: 4px; font-size: 0.7rem; border: 1px solid var(--border); }
.game-card.selected { outline: 2px solid var(--accent); box-shadow: 0 0 0 4px var(--accent-light); }
.card-edit-btn {
    position: absolute; top: 8px; left: 8px; z-index: 2;
    background: rgba(0,0,0,0.6); border: none; color: #fff;
    width: 28px; height: 28px; border-radius: 50%;
    cursor: pointer; font-size: 0.9rem; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.2s;
}
.game-card:hover .card-edit-btn { opacity: 1; }
.card-upload-btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2;
    background: rgba(0,0,0,0.6); border: none; color: #fff;
    width: 40px; height: 40px; border-radius: 50%;
    cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    opacity: 0.7; transition: opacity 0.2s;
}
.card-upload-btn:hover { opacity: 1; }
.no-cover { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.8rem; }

/* Mass Edit */
.mass-edit-panel {
    background: var(--bg-secondary); border: 1px solid var(--accent); border-radius: var(--radius-sm);
    padding: 12px 16px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.mass-edit-panel .mass-count { font-weight: 600; color: var(--accent); min-width: 80px; }

/* Detail actions */
.detail-actions { display: flex; gap: 6px; margin-bottom: 6px; }
.icon-btn {
    background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text);
    width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
    transition: var(--transition);
}
.icon-btn:hover { background: var(--border); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: var(--danger); color: #fff; }

/* Upload icon button */
.upload-icon-btn { font-size: 0.9rem; gap: 6px; }

.status-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
}
.status-notstarted { background: var(--info); color: #fff; }
.status-started { background: #7c4dff; color: #fff; }
.status-playing { background: var(--accent); color: #fff; }
.status-done { background: var(--success); color: #fff; }
.status-endless { background: var(--warning); color: #000; }
.status-abandoned { background: var(--danger); color: #fff; }
.status-wishlist { background: #ff80ab; color: #000; }

/* Filters */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}
.filter-bar input, .filter-bar select {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    min-width: 140px;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--accent); }
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filter-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-light); color: var(--accent); padding: 4px 10px; border-radius: var(--radius-sm); font-size: 0.8rem; cursor: pointer; transition: background 0.15s; }
.filter-chip:hover { background: var(--accent); color: #fff; }
.chip-x { font-weight: 700; }
.global-search {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    color: var(--text);
    font-size: 0.85rem;
    width: 200px;
    max-width: 100%;
    outline: none;
    transition: border-color 0.15s;
}
.global-search:focus { border-color: var(--accent); }

/* Tables */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background: var(--bg-secondary); }

select[multiple] { min-height: 80px; background: var(--bg-tertiary); }
select[multiple] option { padding: 4px 8px; }
select[multiple] option:checked { background: var(--accent-light); color: var(--accent); }
input[type="file"].form-control { padding: 8px; cursor: pointer; }
#coverPreview img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-sm); }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
}
.modal-overlay.active { display: block; }
.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 101;
    box-shadow: var(--shadow);
}
.modal.active { display: block; }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.4rem;
    cursor: pointer;
}
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.9rem;
}
.form-control:focus { outline: none; border-color: var(--accent); }
textarea.form-control { resize: vertical; min-height: 60px; }
select.form-control { cursor: pointer; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* Stars */
.star-rating {
    display: flex;
    gap: 4px;
    font-size: 1.3rem;
    cursor: pointer;
}
.star-rating .star { color: var(--text-muted); transition: var(--transition); }
.star-rating .star.active, .star-rating .star:hover { color: var(--warning); }

/* Status pills */
.status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.status-pill {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: var(--transition);
}
.status-pill:hover { border-color: var(--accent); color: var(--accent); }
.status-pill.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Detail view */
.detail-header {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}
.detail-cover {
    width: 160px;
    height: 220px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--border);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-info { flex: 1; position: relative; }
.detail-info h2 { font-size: 1.4rem; margin-bottom: 6px; }
.detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 10px 0;
}
.detail-meta span strong { color: var(--text); }
.detail-desc {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 12px;
    line-height: 1.6;
}
.detail-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.detail-nav .btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Recommendations */
.recommendation-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 14px;
}
.recommendation-card:hover { border-color: var(--accent); }
.rec-thumb { width: 50px; height: 66px; background: var(--bg-tertiary); border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.rec-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rec-info { flex: 1; min-width: 0; }
.rec-info .rec-title { font-weight: 600; font-size: 0.9rem; }
.rec-info .rec-reason { font-size: 0.8rem; color: var(--text-secondary); margin-top: 2px; }

/* Recommendations view */
.rec-intro { color: var(--text-secondary); margin-bottom: 16px; }
.rec-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.rec-tab {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: var(--transition);
}
.rec-tab:hover { border-color: var(--accent); color: var(--accent); }
.rec-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.rec-blurb { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 16px; }
.rec-feature { align-items: flex-start; }
.rec-feature .rec-thumb { width: 70px; height: 93px; }
.rec-feature .rec-title { font-size: 1.05rem; margin-bottom: 2px; }
.rec-sub { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 6px; }
.rec-feature .rec-reason { font-size: 0.85rem; line-height: 1.5; }
.rec-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* Would You Rather */
.wyr-progress { text-align: center; color: var(--text-secondary); font-size: 0.95rem; margin-bottom: 20px; }
.wyr-duel { display: flex; align-items: stretch; gap: 16px; }
.wyr-or {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.wyr-card {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}
.wyr-card:hover { border-color: var(--accent); background: var(--bg-tertiary); transform: translateY(-2px); }
.wyr-cover { width: 120px; height: 160px; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-tertiary); flex-shrink: 0; }
.wyr-cover img { width: 100%; height: 100%; object-fit: cover; }
.wyr-nocover { display: flex; align-items: center; justify-content: center; height: 100%; padding: 8px; font-size: 0.8rem; color: var(--text-muted); text-align: center; }
.wyr-title { font-weight: 600; font-size: 1rem; }
.wyr-meta { font-size: 0.8rem; color: var(--text-secondary); }

/* Sessions */
.session-list { margin-top: 12px; }
.session-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.85rem;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}
.toast.info { background: var(--info); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.5; }

/* Quick actions */
.quick-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 180px; }
    .main { margin-left: 180px; }
    .game-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .detail-header { flex-direction: column; }
    .detail-cover { width: 100%; height: 200px; }
    .form-row { grid-template-columns: 1fr; }
    .game-list .list-actions { opacity: 1; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { gap: 6px; }
    .filter-bar input, .filter-bar select { min-width: 120px; flex: 1; }
}
@media (max-width: 600px) {
    .sidebar {
        display: flex;
        left: -220px;
        transition: left 0.25s ease;
    }
    .sidebar.open { left: 0; }
    .mobile-menu-toggle { display: block; }
    .mobile-home-btn { display: block; }
    .main { margin-left: 0; }
    .topbar { padding: 12px 16px; flex-wrap: wrap; }
    .topbar h1 { font-size: 1.15rem; flex: 1; }
    .content { padding: 16px; }
    .game-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .game-list .list-actions .icon-btn { width: 28px; height: 28px; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .modal { width: 95vw; }
    .recommendation-card { gap: 10px; padding: 12px; }
    .wyr-duel { flex-direction: column; }
    .wyr-or { padding: 4px 0; }
    .wyr-cover { width: 100px; height: 133px; }
    .rec-tabs { gap: 6px; }
    .rec-tab { padding: 6px 12px; font-size: 0.8rem; }
    .mass-edit-panel { gap: 6px; padding: 10px 12px; }
    .status-pills { gap: 4px; }
    .status-pill { padding: 4px 10px; font-size: 0.75rem; }
}
@media (max-width: 420px) {
    .game-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .filter-bar input, .filter-bar select { min-width: 100px; }
    .topbar .btn-primary { padding: 6px 10px; font-size: 0.8rem; }
    .topbar .btn-ghost { display: none; }
    .global-search { display: none; }
}
