:root {
  --bg: #0b0d14;
  --bg-elevated: #10121b;
  --surface: #1a1d2b;
  --surface-hi: #232739;
  --border: rgba(255, 255, 255, 0.07);
  --text: #f2f3f8;
  --text-dim: #9aa0b4;
  --text-dimmer: #666c82;
  --accent: #6d5cf6;
  --accent-hi: #8477f8;
  --accent-strong: #5645dd;
  --badge-bg: rgba(109, 92, 246, 0.18);
  --badge-text: #b6acfd;
  --success: #22c55e;
  --danger: #ef4444;
  --radius: 12px;
  --sidebar-w: 220px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.only-mobile { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
  padding: 0 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.topbar__left { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.icon-btn {
  background: none; border: none; color: var(--text-dim);
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; letter-spacing: 0.3px; white-space: nowrap; }
.brand__mark { color: var(--accent); width: 24px; height: 24px; }

.searchbar {
  flex: 1 1 auto;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
  color: var(--text-dimmer);
  margin: 0 auto;
}
.searchbar svg { width: 16px; height: 16px; flex-shrink: 0; }
.searchbar input {
  background: none; border: none; outline: none; color: var(--text);
  font-size: 14px; width: 100%;
}
.searchbar input::placeholder { color: var(--text-dimmer); }

.topbar__right { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.trending-toggle {
  display: flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
  white-space: nowrap;
}
.trending-toggle:hover { color: var(--text); border-color: var(--accent); }
.trending-toggle svg { width: 16px; height: 16px; }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--text);
  padding: 4px 8px 4px 4px; border-radius: 999px;
}
.user-chip:hover { background: var(--surface); }
.user-chip svg { width: 14px; height: 14px; color: var(--text-dimmer); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
}

/* ---------- Shell / Sidebar ---------- */
.shell { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky;
  top: 64px;
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  height: calc(100vh - 64px);
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-dim); font-size: 14px; font-weight: 500;
}
.nav__item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav__item:hover { background: var(--surface); color: var(--text); }
.nav__item.is-active { background: var(--surface-hi); color: var(--text); font-weight: 700; }

.ad-slot {
  margin-top: auto;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12.5px;
  color: var(--text-dimmer);
  line-height: 1.4;
  position: relative;
}
.ad-slot__tag {
  display: inline-block;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  margin-bottom: 8px;
  color: var(--text-dim);
}

/* ---------- Content ---------- */
.content { flex: 1 1 auto; min-width: 0; padding: 22px 26px 60px; }

.hero {
  position: relative;
  border-radius: 18px;
  padding: 34px 38px;
  min-height: 190px;
  overflow: hidden;
  background: linear-gradient(120deg, #4a3ad0 0%, #6448e6 45%, #7c5cf5 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
}
.hero__art {
  position: absolute;
  right: 28px; top: 50%; transform: translateY(-50%);
  width: 140px; height: 140px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex; align-items: center; justify-content: center;
}
.hero__art svg { width: 56px; height: 56px; color: rgba(255, 255, 255, 0.85); stroke-width: 1.4; }
.hero__art .game-card__art {
  width: 100%; height: 100%; display: block;
  border-radius: 15px;
  fill: none; stroke: none;
}
.pill {
  display: inline-flex; align-items: center; width: fit-content;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.pill--featured { background: rgba(255, 255, 255, 0.18); color: #fff; }
.pill--rating { background: rgba(0, 0, 0, 0.25); color: #fff; }
.hero h1 { margin: 4px 0 0; font-size: 34px; color: #fff; max-width: 65%; }
.hero p { margin: 0; color: rgba(255, 255, 255, 0.85); font-size: 15px; max-width: 55%; }
.hero__actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 9px; font-weight: 700; font-size: 14px;
  border: none;
}
.btn--primary { background: #fff; color: var(--accent-strong); }
.btn--primary:hover { background: #ece9ff; }

.row { margin-top: 30px; }
.row__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; margin: 0 0 14px; color: var(--text);
}
.row__title svg { width: 18px; height: 18px; color: var(--accent-hi); }
.row__scroller {
  display: flex; gap: 14px; overflow-x: auto; padding-bottom: 6px;
  scrollbar-width: thin;
}
.row__scroller::-webkit-scrollbar { height: 6px; }
.row__scroller::-webkit-scrollbar-thumb { background: var(--surface-hi); border-radius: 999px; }
.row__scroller .game-card { flex: 0 0 190px; }

.grid-section { margin-top: 34px; }
.grid-section__title { font-size: 18px; margin: 0 0 14px; }
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.empty-state { color: var(--text-dimmer); text-align: center; padding: 40px 0; }

/* ---------- Game Card ---------- */
.game-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform .15s ease, border-color .15s ease;
  position: relative;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.game-card__thumb {
  aspect-ratio: 4 / 3;
  background: linear-gradient(160deg, #2a2f45, #1b1e2c 70%);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}
.game-card__thumb svg { width: 46px; height: 46px; color: rgba(255, 255, 255, 0.35); stroke-width: 1.5; }
/* Full-bleed illustrated art: overrides the icon sizing above and the global
   `svg { fill: none; stroke: currentColor }` reset — each shape paints itself. */
.game-card__thumb .game-card__art {
  position: absolute; inset: 0;
  width: 100%; height: 100%; display: block;
  fill: none; stroke: none;
  transition: transform .3s ease;
}
.game-card:hover .game-card__art { transform: scale(1.05); }
/* Scrim keeps the badges readable over bright artwork. */
.game-card__thumb::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(6, 8, 16, .2), rgba(6, 8, 16, 0) 30%);
  pointer-events: none;
}
.game-card__cat {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(12, 14, 24, .62); color: #e6e2ff;
  backdrop-filter: blur(3px);
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
}
.game-card__play-badge {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  background: var(--success); color: #06210f;
  font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 999px;
  letter-spacing: .3px;
}
.game-card__body { padding: 10px 12px 12px; }
.game-card__title {
  font-size: 14px; font-weight: 700; margin: 0 0 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.game-card__meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-dimmer); }
.game-card__rating { color: #f2c94c; display: flex; align-items: center; gap: 3px; }
.game-card__rating svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--surface-hi); border: 1px solid var(--border);
  color: var(--text); padding: 12px 20px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
  z-index: 100;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
  .only-desktop { display: none; }
  .only-mobile { display: flex; }
  .searchbar { max-width: none; }
  .sidebar {
    position: fixed;
    left: 0; top: 64px;
    z-index: 25;
    background: var(--bg-elevated);
    border-right: none;
    border-bottom: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .2s ease;
    width: 240px;
    height: calc(100vh - 64px);
  }
  .sidebar.is-open { transform: translateX(0); box-shadow: 20px 0 40px rgba(0,0,0,.4); }
  .content { padding: 16px 16px 50px; }
  .hero { padding: 24px; min-height: 160px; }
  .hero h1 { font-size: 24px; max-width: 100%; }
  .hero p { max-width: 100%; }
  .hero__art { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand span { display: none; }
}

@media (max-width: 520px) {
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); gap: 10px; }
  .row__scroller .game-card { flex-basis: 150px; }
}
