:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-2: #18212c;
  --border: #263241;
  --text: #f4f7fb;
  --muted: #8e9aaa;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: radial-gradient(circle at top right, #14233b 0, var(--bg) 36%);
  color: var(--text);
  min-height: 100vh;
}
button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(8,12,18,.78);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; background: #1d4ed8; font-size: 20px;
}
.brand strong { display: block; font-size: 14px; letter-spacing: .08em; }
.brand span { color: var(--muted); font-size: 11px; }
.icon-btn {
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); border-radius: 10px; width: 40px; height: 40px;
}

.container { width: min(1250px, calc(100% - 40px)); margin: 0 auto; }
.hero {
  display: grid; grid-template-columns: 1fr minmax(360px, 520px);
  gap: 40px; align-items: end; padding: 55px 0 28px;
}
.eyebrow { color: var(--accent-2); font-weight: 700; font-size: 11px; letter-spacing: .14em; }
h1 { font-size: clamp(32px, 5vw, 52px); margin: 5px 0 8px; }
.subtitle { color: var(--muted); margin: 0; }

.search-wrap { position: relative; display: flex; gap: 8px; }
.search-wrap input {
  width: 100%; background: var(--panel); color: var(--text);
  border: 1px solid var(--border); border-radius: 13px; padding: 15px 16px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.primary {
  background: var(--accent); color: white; border: 0; border-radius: 13px;
  padding: 0 18px; font-weight: 700;
}
.primary:hover { background: #2563eb; }

.search-results {
  position: absolute; top: calc(100% + 9px); left: 0; right: 86px;
  background: #111923; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 30;
}
.result {
  width: 100%; border: 0; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text); display: flex; gap: 12px;
  padding: 10px; text-align: left;
}
.result:last-child { border-bottom: 0; }
.result:hover { background: var(--panel-2); }
.result img { width: 46px; height: 62px; object-fit: cover; border-radius: 7px; background: #202938; }
.result-title { font-weight: 700; margin: 4px 0; }
.result-meta { color: var(--muted); font-size: 12px; line-height: 1.5; }

.stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 10px 0 25px;
}
.stat { background: var(--panel); border: 1px solid var(--border); padding: 17px; border-radius: 15px; }
.stat-value { font-size: 25px; font-weight: 800; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 3px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.filter {
  border: 1px solid var(--border); background: var(--panel); color: var(--muted);
  border-radius: 999px; padding: 9px 14px; font-size: 13px;
}
.filter.active { color: white; background: #1d4ed8; border-color: #2563eb; }

.games-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; padding-bottom: 50px;
}
.game-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 15px;
  overflow: hidden; transition: transform .18s, border-color .18s; cursor: pointer;
}
.game-card:hover { transform: translateY(-4px); border-color: #3b82f6; }
.cover { aspect-ratio: 3 / 4; width: 100%; object-fit: cover; background: #1c2530; }
.card-body { padding: 12px; }
.card-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-meta { color: var(--muted); font-size: 11px; margin-top: 6px; min-height: 31px; }
.badge {
  display: inline-block; margin-top: 9px; padding: 5px 8px; border-radius: 7px;
  font-size: 10px; font-weight: 700;
}
.badge.backlog { background: #1e3a8a; color: #bfdbfe; }
.badge.playing { background: #713f12; color: #fde68a; }
.badge.completed { background: #14532d; color: #bbf7d0; }
.badge.abandoned { background: #450a0a; color: #fecaca; }

.empty {
  grid-column: 1/-1; padding: 70px 20px; text-align: center;
  border: 1px dashed var(--border); border-radius: 16px; color: var(--muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 8px; }

.modal.hidden, .hidden { display: none !important; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(8px); }
.modal-card {
  position: relative; width: min(850px, 100%); max-height: 90vh; overflow: auto;
  background: #111923; border: 1px solid var(--border); border-radius: 20px;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 36px; height: 36px;
  border: 0; border-radius: 50%; background: rgba(0,0,0,.55); color: white; font-size: 24px;
}
.modal-hero { display: grid; grid-template-columns: 230px 1fr; gap: 24px; padding: 28px; }
.modal-hero img { width: 100%; border-radius: 12px; }
.modal-info h2 { font-size: 30px; margin: 10px 0; }
.modal-info p { color: #b6c0cd; line-height: 1.65; }
.info-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 18px 0; }
.info-box { background: var(--panel); border: 1px solid var(--border); padding: 12px; border-radius: 10px; }
.info-box small { display:block; color:var(--muted); margin-bottom:4px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
select, .number-input {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px;
}
.danger { background: transparent; color: #fca5a5; border: 1px solid #7f1d1d; border-radius: 9px; padding: 9px 12px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; background: #17212c;
  border: 1px solid var(--border); color: white; padding: 13px 16px;
  border-radius: 10px; opacity: 0; transform: translateY(10px);
  pointer-events: none; transition: .2s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateY(0); }

footer { color: #667386; border-top: 1px solid var(--border); padding: 25px 0 35px; font-size: 11px; }
footer a { color: #93c5fd; }

@media (max-width: 1050px) {
  .games-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 800px) {
  .hero { grid-template-columns: 1fr; gap: 20px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .games-grid { grid-template-columns: repeat(3, 1fr); }
  .topbar { padding: 0 18px; }
}
@media (max-width: 560px) {
  .container { width: min(100% - 24px, 1250px); }
  .games-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .modal-hero { grid-template-columns: 120px 1fr; gap: 15px; padding: 20px; }
  .modal-info h2 { font-size: 22px; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .search-wrap { display: block; }
  .search-wrap .primary { width: 100%; height: 46px; margin-top: 8px; }
  .search-results { right: 0; }
}
