:root {
  --bg: #0a0a0f;
  --bg-card: #14141f;
  --bg-card-hover: #1a1a2e;
  --bg-header: #0d0d15;
  --bg-input: #1a1a2e;
  --bg-modal: #12121e;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --text-muted: #55556a;
  --accent: #7c5cff;
  --accent-dim: #5a3fd4;
  --accent-glow: rgba(124,92,255,0.15);
  --success: #4ade80;
  --warning: #fbbf24;
  --border: #222235;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}
* { margin:0; padding:0; box-sizing:border-box; }
html { font-size:16px; }
body { background:var(--bg); color:var(--text); font-family:var(--font); min-height:100vh; overflow-x:hidden; }
::-webkit-scrollbar { width:8px; }
::-webkit-scrollbar-track { background:var(--bg); }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:4px; }
::-webkit-scrollbar-thumb:hover { background:var(--text-muted); }
a { color:var(--accent); text-decoration:none; }

/* Header */
#header { position:sticky; top:0; z-index:100; background:var(--bg-header); border-bottom:1px solid var(--border); backdrop-filter:blur(12px); }
.header-inner { max-width:1400px; margin:0 auto; padding:0.75rem 1.5rem; display:flex; align-items:center; justify-content:space-between; }
.logo { font-size:1.4rem; font-weight:700; cursor:pointer; display:flex; align-items:center; gap:0.5rem; user-select:none; }
.logo span { background:linear-gradient(135deg,var(--accent),#a78bfa); -webkit-background-clip:text; -webkit-text-fill-color:transparent; }
.header-nav { display:flex; gap:0.5rem; }
.nav-btn { background:none; border:1px solid var(--border); color:var(--text-dim); padding:0.4rem 1rem; border-radius:20px; cursor:pointer; font-size:0.85rem; transition:all 0.2s; }
.nav-btn:hover { border-color:var(--accent); color:var(--text); }
.nav-btn.active { background:var(--accent); border-color:var(--accent); color:#fff; }

/* Main */
#main { max-width:1400px; margin:0 auto; padding:1.5rem; min-height:calc(100vh - 60px); }

/* Console Grid */
.consoles-header { margin-bottom:1.5rem; }
.consoles-header h2 { font-size:1.6rem; margin-bottom:0.25rem; }
.consoles-header p { color:var(--text-dim); font-size:0.9rem; }
.console-actions { display:flex; gap:0.75rem; margin:1rem 0; flex-wrap:wrap; align-items:center; }
.console-actions .btn { font-size:0.8rem; padding:0.4rem 0.9rem; }
.console-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(180px, 1fr)); gap:1rem; }
.console-card { background:var(--bg-card); border:2px solid var(--border); border-radius:var(--radius); padding:1.2rem; cursor:pointer; transition:all 0.25s; text-align:center; position:relative; user-select:none; }
.console-card:hover { border-color:var(--accent); transform:translateY(-2px); box-shadow:0 6px 20px rgba(124,92,255,0.15); }
.console-card.selected { border-color:var(--accent); background:var(--accent-glow); }
.console-card.selected::after { content:'✓'; position:absolute; top:8px; right:10px; color:var(--accent); font-weight:700; font-size:1.1rem; }
.console-icon { font-size:2.2rem; margin-bottom:0.5rem; }
.console-name { font-weight:600; font-size:0.95rem; margin-bottom:0.25rem; }
.console-count { color:var(--text-dim); font-size:0.8rem; }

/* Browse bar */
.browse-bar { position:sticky; top:56px; z-index:90; background:var(--accent); color:#fff; padding:0.6rem 1.5rem; margin:-1.5rem -1.5rem 1rem; display:flex; align-items:center; justify-content:space-between; gap:1rem; flex-wrap:wrap; }
.browse-bar .info { font-weight:600; font-size:0.95rem; }
.browse-bar .btn { background:rgba(255,255,255,0.2); border:1px solid rgba(255,255,255,0.3); color:#fff; }
.browse-bar .btn:hover { background:rgba(255,255,255,0.3); }

/* Button */
.btn { background:var(--bg-card); border:1px solid var(--border); color:var(--text); padding:0.5rem 1rem; border-radius:20px; cursor:pointer; font-size:0.85rem; transition:all 0.2s; white-space:nowrap; }
.btn:hover { border-color:var(--accent); color:var(--accent); }
.btn-primary { background:var(--accent); border-color:var(--accent); color:#fff; }
.btn-primary:hover { background:var(--accent-dim); }
.btn-sm { padding:0.3rem 0.7rem; font-size:0.78rem; }

/* Games View */
.games-header { display:flex; align-items:center; gap:1rem; margin-bottom:1rem; flex-wrap:wrap; }
.games-header .back-btn { background:none; border:none; color:var(--accent); font-size:1rem; cursor:pointer; display:flex; align-items:center; gap:0.3rem; padding:0.3rem 0; }
.games-header .back-btn:hover { text-decoration:underline; }
.games-header h2 { font-size:1.3rem; flex:1; }

/* Filters */
.filters-bar { display:flex; gap:0.6rem; margin-bottom:1rem; flex-wrap:wrap; align-items:center; }
.filter-input { background:var(--bg-input); border:1px solid var(--border); color:var(--text); padding:0.5rem 0.8rem; border-radius:var(--radius-sm); font-size:0.85rem; outline:none; transition:border 0.2s; min-width:0; }
.filter-input:focus { border-color:var(--accent); }
.filter-input::placeholder { color:var(--text-muted); }
select.filter-input { cursor:pointer; appearance:auto; }
.search-wrap { position:relative; flex:1; min-width:200px; }
.search-wrap input { width:100%; padding-left:2rem; }
.search-wrap::before { content:'🔍'; position:absolute; left:0.6rem; top:50%; transform:translateY(-50%); font-size:0.8rem; }

/* Games Grid */
.games-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(160px, 1fr)); gap:1rem; }
.game-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; cursor:pointer; transition:all 0.25s; animation:fadeIn 0.4s ease; }
.game-card:hover { border-color:var(--accent); transform:translateY(-3px); box-shadow:var(--shadow); }
.game-cover { width:100%; aspect-ratio:3/4; background:var(--bg-input); position:relative; overflow:hidden; }
.game-cover img { width:100%; height:100%; object-fit:contain; background:var(--bg); }
.game-cover .placeholder { width:100%; height:100%; display:flex; align-items:center; justify-content:center; font-size:2.5rem; color:var(--text-muted); background:linear-gradient(135deg, var(--bg-card), var(--bg-input)); }
.game-cover .fav-btn { position:absolute; top:6px; right:6px; background:rgba(0,0,0,0.6); border:none; font-size:1.1rem; cursor:pointer; border-radius:50%; width:28px; height:28px; display:flex; align-items:center; justify-content:center; transition:transform 0.2s; z-index:5; }
.game-cover .fav-btn:hover { transform:scale(1.2); }
.game-info { padding:0.6rem 0.8rem; }
.game-title { font-size:0.82rem; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.game-meta { display:flex; justify-content:space-between; align-items:center; margin-top:0.3rem; }
.game-genre { font-size:0.7rem; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:70%; }
.game-rating { font-size:0.7rem; color:var(--warning); }
.game-console-badge { font-size:0.65rem; color:var(--accent); margin-top:0.2rem; opacity:0.8; }

/* Load More */
.load-more { text-align:center; padding:2rem; }
.load-more .btn { padding:0.6rem 2rem; font-size:0.9rem; }
.no-results { text-align:center; padding:3rem; color:var(--text-dim); }
.no-results .emoji { font-size:3rem; margin-bottom:1rem; }

/* Modal */
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,0.75); z-index:200; display:flex; align-items:center; justify-content:center; padding:1rem; backdrop-filter:blur(4px); }
.modal-overlay.hidden { display:none; }
.modal-content { background:var(--bg-modal); border:1px solid var(--border); border-radius:var(--radius); max-width:700px; width:100%; max-height:90vh; overflow-y:auto; position:relative; animation:modalIn 0.3s ease; }
.modal-close { position:absolute; top:0.8rem; right:1rem; background:none; border:none; color:var(--text-dim); font-size:1.8rem; cursor:pointer; z-index:5; line-height:1; }
.modal-close:hover { color:var(--text); }

/* Game Detail */
.game-detail { padding:1.5rem; }
.game-detail-top { display:flex; gap:1.5rem; margin-bottom:1.5rem; }
.game-detail-cover { width:200px; min-width:200px; }
.game-detail-cover img, .game-detail-cover video { width:100%; border-radius:var(--radius-sm); background:var(--bg); }
.game-detail-cover .placeholder { width:200px; height:266px; display:flex; align-items:center; justify-content:center; font-size:4rem; color:var(--text-muted); background:var(--bg-card); border-radius:var(--radius-sm); }
.game-detail-info h2 { font-size:1.3rem; margin-bottom:0.3rem; }
.game-detail-info .console-tag { display:inline-block; background:var(--accent-glow); color:var(--accent); padding:0.2rem 0.6rem; border-radius:12px; font-size:0.75rem; margin-bottom:0.8rem; }
.detail-fields { display:grid; grid-template-columns:1fr 1fr; gap:0.4rem 1.5rem; margin-bottom:1rem; }
.detail-field { font-size:0.85rem; }
.detail-field .label { color:var(--text-dim); font-size:0.75rem; text-transform:uppercase; letter-spacing:0.05em; }
.detail-field .value { margin-top:0.1rem; }
.game-description { color:var(--text-dim); font-size:0.85rem; line-height:1.6; margin-top:1rem; border-top:1px solid var(--border); padding-top:1rem; }
.game-description h3 { color:var(--text); font-size:0.9rem; margin-bottom:0.5rem; }
.related-games { margin-top:1.5rem; border-top:1px solid var(--border); padding-top:1rem; }
.related-games h3 { font-size:0.9rem; margin-bottom:0.75rem; }
.related-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(100px, 1fr)); gap:0.75rem; }
.related-card { cursor:pointer; text-align:center; transition:transform 0.2s; }
.related-card:hover { transform:translateY(-2px); }
.related-card img { width:100%; aspect-ratio:3/4; object-fit:contain; border-radius:var(--radius-sm); background:var(--bg); }
.related-card .rname { font-size:0.7rem; margin-top:0.3rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Stats */
.stats-page { max-width:900px; margin:0 auto; }
.stats-page h2 { font-size:1.5rem; margin-bottom:1.5rem; }
.stats-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(200px, 1fr)); gap:1rem; margin-bottom:2rem; }
.stat-card { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); padding:1.2rem; text-align:center; }
.stat-number { font-size:2rem; font-weight:700; color:var(--accent); }
.stat-label { color:var(--text-dim); font-size:0.85rem; margin-top:0.25rem; }
.chart-section { background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); padding:1.5rem; margin-bottom:1.5rem; }
.chart-section h3 { font-size:1rem; margin-bottom:1rem; }
.bar-chart .bar-row { display:flex; align-items:center; gap:0.75rem; margin-bottom:0.5rem; }
.bar-row .bar-label { min-width:120px; font-size:0.8rem; text-align:right; color:var(--text-dim); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.bar-row .bar-track { flex:1; height:22px; background:var(--bg-input); border-radius:4px; overflow:hidden; }
.bar-row .bar-fill { height:100%; background:linear-gradient(90deg, var(--accent), #a78bfa); border-radius:4px; transition:width 0.6s ease; display:flex; align-items:center; justify-content:flex-end; padding-right:0.5rem; }
.bar-row .bar-value { font-size:0.7rem; color:#fff; font-weight:600; min-width:30px; text-align:right; }

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

/* Mobile */
@media (max-width:768px) {
  .header-inner { padding:0.6rem 1rem; }
  .logo { font-size:1.1rem; }
  #main { padding:1rem; }
  .console-grid { grid-template-columns:repeat(auto-fill, minmax(140px, 1fr)); gap:0.75rem; }
  .games-grid { grid-template-columns:repeat(auto-fill, minmax(130px, 1fr)); gap:0.75rem; }
  .filters-bar { gap:0.4rem; }
  .filter-input { font-size:0.8rem; padding:0.4rem 0.6rem; }
  .game-detail-top { flex-direction:column; align-items:center; }
  .game-detail-cover { width:160px; min-width:auto; }
  .detail-fields { grid-template-columns:1fr; }
  .browse-bar { margin:-1rem -1rem 1rem; padding:0.5rem 1rem; font-size:0.85rem; }
  .stats-grid { grid-template-columns:repeat(2, 1fr); }
}
@media (max-width:480px) {
  .console-grid { grid-template-columns:repeat(auto-fill, minmax(110px, 1fr)); }
  .games-grid { grid-template-columns:repeat(auto-fill, minmax(110px, 1fr)); }
  .console-actions { gap:0.4rem; }
}

/* Highlight */
mark { background:var(--accent-glow); color:var(--accent); padding:0 2px; border-radius:2px; }
