:root {
  --bg: #0b0f1a;
  --surface: #121a2b;
  --surface-2: #182238;
  --line: #232f47;
  --text: #e8ecf5;
  --muted: #8b93ab;
  --cyan: #5eead4;
  --amber: #fbbf24;
  --magenta: #f472b6;
  --navbar-h: 64px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% 0%, rgba(94, 234, 212, .08), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(244, 114, 182, .07), transparent 40%),
    var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-top: var(--navbar-h);
}

a { color: inherit; }

/* ---------- Topbar ---------- */
.topbar {
  height: var(--navbar-h);
  background: rgba(11, 15, 26, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  font-family: 'Press Start 2P', monospace;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(94, 234, 212, .5);
  white-space: nowrap;
}
.brand-mark .amber { color: var(--amber); text-shadow: 0 0 6px rgba(251, 191, 36, .5); }

.navbar-toggler {
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
}
.navbar-toggler:focus { box-shadow: 0 0 0 .2rem rgba(94, 234, 212, .25); }

.search-wrap { max-width: 360px; width: 100%; }
.search-wrap .form-control {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}
.search-wrap .form-control::placeholder { color: var(--muted); }
.search-wrap .form-control:focus {
  background: var(--surface);
  color: var(--text);
  border-color: var(--cyan);
  box-shadow: 0 0 0 .2rem rgba(94, 234, 212, .15);
}
.search-wrap .input-group-text {
  background: var(--surface);
  border: 1px solid var(--line);
  border-right: none;
  color: var(--muted);
}
.search-icon-btn {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  font-size: 14px;
}
.search-close-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: none;
  color: var(--muted);
}
.search-close-btn:hover { color: var(--text); }

/* Mobile: search collapses to an icon; tapping it expands into a full-width bar
   that overlays the rest of the topbar row. */
@media (max-width: 991.98px) {
  .search-wrap {
    max-width: none;
    width: auto;
    flex: 0 0 auto;
  }
  .search-wrap .input-group { width: 40px; transition: width .18s ease; }
  .search-wrap .input-group-text {
    border-radius: 8px;
    border-right: 1px solid var(--line);
  }
  .search-wrap .form-control,
  .search-close-btn { display: none; }

  .search-wrap.expanded {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    background: var(--bg);
    padding: 0 12px;
    max-width: none;
  }
  .search-wrap.expanded .input-group { width: 100%; }
  .search-wrap.expanded .form-control,
  .search-wrap.expanded .search-close-btn { display: block; }
  .search-wrap.expanded .input-group-text { border-radius: 8px 0 0 8px; border-right: none; }

  #topbar.search-open .navbar-toggler,
  #topbar.search-open .brand-mark,
  #topbar.search-open .game-count-pill { visibility: hidden; }
}

@media (min-width: 992px) {
  .search-wrap .input-group { width: 100%; }
  .search-close-btn { display: none !important; }
}

.game-count-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.game-count-pill b { color: var(--text); }

/* ---------- Layout ---------- */
.app-layout { min-height: calc(100vh - var(--navbar-h)); }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
@media (min-width: 992px) {
  .sidebar {
    position: sticky;
    top: var(--navbar-h);
    height: calc(100vh - var(--navbar-h));
    overflow-y: auto;
  }
}
.sidebar .offcanvas-header { border-bottom: 1px solid var(--line); }

.sidebar-title {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 18px 18px 8px;
}

.category-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--muted);
  padding: 10px 18px;
  font-size: 14px;
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.category-link:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
.category-link.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: rgba(94, 234, 212, .06);
}
.cat-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
.category-link.active .cat-count { color: var(--cyan); border-color: rgba(94, 234, 212, .35); }

main.content { padding: 32px 24px 80px; flex: 1 1 auto; min-width: 0; }

/* ---------- Hero ---------- */
.hero {
  padding: 28px 4px 8px;
}
.hero .marquee {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(18px, 3vw, 28px);
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 6px rgba(94, 234, 212, .6), 0 0 22px rgba(94, 234, 212, .35);
}
.hero .marquee .amber { color: var(--amber); text-shadow: 0 0 6px rgba(251, 191, 36, .6); }
.hero .tagline { color: var(--muted); font-size: 15px; max-width: 640px; margin-top: 10px; }

/* ---------- Game grid ---------- */
@media (min-width: 1200px) {
  .col-xl-2dot4 { flex: 0 0 auto; width: 20%; }
}

.cabinet {
  position: relative;
  height: 100%;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.cabinet:hover, .cabinet:focus-visible {
  transform: translateY(-4px);
  border-color: var(--cyan);
  box-shadow: 0 14px 30px -12px rgba(94, 234, 212, .25);
  outline: none;
}
.screen {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  overflow: hidden;
  background: #05070c;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.screen img { width: 100%; height: 100%; object-fit: cover; filter: saturate(1.05); }
.screen::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.18) 3px);
  pointer-events: none;
}
.play-pill {
  position: absolute; right: 8px; bottom: 8px;
  background: rgba(11, 15, 26, .85);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: .5px;
  padding: 4px 9px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .15s ease, transform .15s ease;
}
.cabinet:hover .play-pill, .cabinet:focus-visible .play-pill { opacity: 1; transform: translateY(0); }
.cabinet h3 { margin: 0; font-size: 15px; font-weight: 700; }
.cabinet p {
  margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.5; flex-grow: 1;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.cab-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); letter-spacing: .4px; }
.pwa-tag {
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, .35);
  background: rgba(251, 191, 36, .08);
  padding: 2px 7px;
  border-radius: 6px;
}

#empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--line);
  text-align: center;
  padding: 28px 24px 44px;
  color: var(--muted);
  font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {
  .cabinet { transition: none; }
}
