:root {
  --bg: #0c0d14;
  --bg-2: #1a1b28;
  --bg-3: #2b2d42;
  --input: #373952;
  --text: #f9faff;
  --muted: #aaadbe;
  --accent: #6842ff;
  --accent-hover: #7c5cff;
  --icon: #a6a9ff;
  --radius: 10px;
  --top: 64px;
  --side: 64px;
  --gap: 10px;
  --card-w: clamp(150px, 19vw, 300px);
  --card-h: calc(var(--card-w) * 9 / 16);
}
body.side-open { --side: 240px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.ic { width: 22px; height: 22px; flex-shrink: 0; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--top);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px 0 12px;
  background: var(--bg-2);
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--text);
  transition: background .15s;
}
.icon-btn:hover { background: var(--bg-3); }
.top-actions .icon-btn { background: var(--bg-3); }
.top-actions .icon-btn:hover { background: var(--input); }

.logo { display: flex; align-items: center; gap: 6px; margin-right: 8px; }
.logo-badge {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #8b6cff, #5a2fff);
  font-weight: 900; font-size: 18px; letter-spacing: -1px;
  box-shadow: 0 3px 0 #3a1fb0;
}
.logo-text { font-weight: 900; font-size: 22px; letter-spacing: .5px; }

.search { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search input {
  width: 100%; height: 44px;
  padding: 0 48px 0 20px;
  border: 2px solid transparent; border-radius: 22px;
  background: var(--input); color: var(--text);
  font: inherit; font-weight: 700; font-size: 16px;
  outline: none; transition: border-color .15s;
}
.search input::placeholder { color: var(--muted); }
.search input:focus { border-color: var(--accent); }
.search input::-webkit-search-cancel-button { display: none; }
.search-btn { position: absolute; right: 6px; top: 2px; width: 40px; height: 40px; color: var(--muted); display: grid; place-items: center; }
.search-results {
  position: absolute; top: 52px; left: 0; right: 0;
  background: var(--bg-2); border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.sr-item { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: 8px; }
.sr-item:hover, .sr-item.active { background: var(--bg-3); }
.sr-item .thumb-mini { width: 64px; height: 36px; border-radius: 6px; position: relative; overflow: hidden; flex-shrink: 0; container-type: inline-size; }
.sr-item .thumb-mini .t-title { display: none; }
.sr-item .thumb-mini .emoji { font-size: 40cqw; }
.sr-all { display: block; text-align: center; padding: 10px; color: var(--icon); border-radius: 8px; }
.sr-all:hover { background: var(--bg-3); }
.sr-empty { padding: 14px; color: var(--muted); text-align: center; }

.top-actions { display: flex; align-items: center; gap: 10px; }
.btn-primary {
  height: 40px; padding: 0 20px; border-radius: 20px;
  background: var(--accent); color: #fff; font-weight: 800; font-size: 16px;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: var(--top); bottom: 0; left: 0; z-index: 40;
  width: var(--side);
  overflow-y: auto; overflow-x: hidden; scrollbar-width: none;
  padding: 12px 0 24px;
  background: var(--bg);
  transition: width .2s;
}
.sidebar::-webkit-scrollbar { display: none; }
.side-item {
  position: relative;
  display: flex; align-items: center; gap: 18px;
  height: 42px; padding: 0 21px;
  color: var(--text); white-space: nowrap;
}
.side-item .ic { color: var(--icon); }
.side-item:hover { background: var(--bg-2); }
.side-item.active { background: var(--bg-2); }
.side-item.active::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-label { opacity: 0; transition: opacity .15s; }
body.side-open .side-label { opacity: 1; }
.side-divider { height: 1px; margin: 10px 16px; background: var(--bg-3); }

.backdrop { display: none; }

/* ---------- Main ---------- */
.main {
  margin: var(--top) 0 0 var(--side);
  padding: 20px 20px 0;
  min-height: calc(100vh - var(--top));
  transition: margin-left .2s;
}
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; margin: 0 4px 12px; }
.section-head h2 { margin: 0; font-size: 24px; font-weight: 800; }
.section-head a { display: inline-flex; align-items: center; gap: 4px; }
.section-head a:hover { color: var(--icon); }
.section-head .ic { width: 20px; height: 20px; }

/* Horizontal scrolling rows */
.scroll-wrap { position: relative; }
.scroller {
  display: grid; grid-auto-flow: column; grid-auto-columns: var(--card-w);
  gap: var(--gap);
  overflow-x: auto; scroll-behavior: smooth; scroll-snap-type: x proximity;
  scrollbar-width: none;
  /* room for the hover zoom so scaled cards aren't clipped */
  padding: 24px 4px;
  margin: -24px -4px;
}
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; }
.scroll-btn {
  position: absolute; top: 50%; z-index: 2;
  width: 44px; height: 44px; margin-top: -22px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(26, 27, 40, .92); box-shadow: 0 4px 16px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none; transition: opacity .15s;
}
.scroll-btn.left { left: -8px; }
.scroll-btn.right { right: -8px; }
.scroll-wrap:hover .scroll-btn.show { opacity: 1; pointer-events: auto; }
.scroll-btn:hover { background: var(--accent); }

/* Bento "Top picks" layout: big tile, then 2x2 small tiles, repeating */
.bento { grid-template-rows: repeat(2, var(--card-h)); grid-auto-flow: column dense; }
.bento .card { aspect-ratio: auto; height: 100%; }
.bento .card.big { grid-row: span 2; grid-column: span 2; }

/* ---------- Cards / thumbnails ---------- */
.card {
  --card-radius: 16px;
  position: relative; display: block;
  aspect-ratio: 16 / 9;
  border: 2px solid transparent; border-radius: var(--card-radius);
  background: rgba(255, 255, 255, .07); background-clip: padding-box;
  container-type: inline-size;
  z-index: 0;
}
.card-media {
  position: absolute; inset: 0; z-index: 1;
  border-radius: var(--card-radius); overflow: hidden; isolation: isolate;
  transform-origin: var(--origin, center) center;
  transition: transform .2s ease-out;
}
.thumb {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2cqw;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,255,255,.28), transparent 45%),
    radial-gradient(circle at 80% 90%, rgba(0,0,0,.35), transparent 50%),
    linear-gradient(135deg, var(--c1), var(--c2));
  overflow: hidden;
}
.thumb::after {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 12px, transparent 12px 24px);
}
.thumb .emoji { font-size: 26cqw; line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); transform: rotate(-6deg); }
.thumb .t-title {
  position: relative; z-index: 1;
  max-width: 92%;
  font-weight: 900; font-size: 8.5cqw; line-height: 1; text-align: center; text-transform: uppercase;
  color: #fff;
  text-shadow: 0 .6cqw 0 rgba(0,0,0,.45), 0 0 1.5cqw rgba(0,0,0,.4);
  -webkit-text-stroke: .35cqw rgba(0,0,0,.35);
  paint-order: stroke fill;
}
.badge, .thumb .t-title { transition: opacity .2s ease-out; }
.card.big .thumb .emoji { font-size: 22cqw; }
.card.big .thumb .t-title { font-size: 7.5cqw; }
.badge {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  padding: 3px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 900; letter-spacing: .5px; text-transform: uppercase;
  background: var(--accent); color: #fff;
}
.badge.hot { background: #ff4d4d; }
.badge.updated { background: #1fa971; }
.badge.original { background: #ffb020; color: #1a1300; }

/* Hover overlay: purple frame, preview, title + stats bar */
.card-hover {
  position: absolute; inset: 0; z-index: 3;
  border-radius: inherit; overflow: hidden;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease-out;
}
.card-hover::after {
  content: ""; position: absolute; inset: 0; z-index: 4;
  border: 2px solid var(--accent); border-radius: inherit;
  pointer-events: none;
}
.card-hover video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card-info {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  padding: 12px;
  background: linear-gradient(rgba(104, 66, 255, 0), rgba(104, 66, 255, .6) 40%, rgb(104, 66, 255) 79.81%);
  color: #fff;
}
.ci-title { font-size: 14px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-sub { display: flex; align-items: center; gap: 12px; margin-top: 4px; font-size: 10px; font-weight: 700; }
.ci-cat {
  padding: 2px 6px; border-radius: 8px; background: rgba(0, 0, 0, .4);
  max-width: 100px; min-width: 0; flex-shrink: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-stat { display: flex; align-items: center; gap: 4px; }
.ci-stat .ic { width: 13px; height: 13px; fill: currentColor; stroke-width: 1.5; }
@container (max-width: 220px) { .card-info { padding: 8px; } .ci-year { display: none; } }
@container (max-width: 180px) { .card-info { padding: 4px 6px; } .ci-sub { display: none; } }
@container (max-width: 130px) { .ci-title { font-size: 11px; } }

@keyframes preview-bob {
  0%, 100% { transform: rotate(-6deg) translateY(0) scale(1); }
  50% { transform: rotate(4deg) translateY(-6%) scale(1.08); }
}
@media (hover: hover) {
  .card:not(.static):hover { box-shadow: rgba(0, 0, 0, .57) 0 0 7px 1px; z-index: 10; }
  .card:not(.static):hover .card-media { transform: scale(1.2); box-shadow: rgb(29, 0, 104) 0 10px 40px 0; }
  .card.big:not(.static):hover .card-media { transform: scale(1.1); }
  .card:not(.static):hover .card-hover { opacity: 1; }
  .card:not(.static):hover .badge,
  .card:not(.static):hover .thumb .t-title { opacity: 0; }
  /* No video? Animate the artwork as a stand-in preview */
  .card:not(.static):hover .thumb .emoji { animation: preview-bob 1.4s ease-in-out infinite; }
}
.card.static .card-hover { display: none; }

/* Square tiles ("Continue playing") */
.scroller.squares { grid-auto-columns: 110px; }
.card.square { aspect-ratio: 1; }
.card.square .t-title { display: none; }
.card.square .thumb .emoji { font-size: 48cqw; }

/* Grid listing */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.page-head { margin: 4px 4px 20px; }
.page-head h1 { margin: 0 0 6px; font-size: 32px; font-weight: 900; display: flex; align-items: center; gap: 12px; }
.page-head h1 .ic { width: 32px; height: 32px; color: var(--icon); }
.page-head p { margin: 0; color: var(--muted); max-width: 760px; line-height: 1.5; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 48px; height: 48px; margin-bottom: 8px; }

/* ---------- Game page ---------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.player {
  position: relative; aspect-ratio: 16 / 9; max-height: calc(100vh - var(--top) - 110px); width: 100%;
  border-radius: 12px 12px 0 0; overflow: hidden; background: #000;
}
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.player:fullscreen { border-radius: 0; max-height: none; }
.player-bg { position: absolute; inset: -40px; filter: blur(36px) brightness(.55); }
.player-bg .thumb .t-title, .player-bg .thumb .emoji { display: none; }
.player-start {
  position: absolute; inset: 0; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  text-align: center; padding: 16px;
}
.player-start .card { width: clamp(110px, 18%, 170px); aspect-ratio: 1; pointer-events: none; border: 0; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.player-start .card .t-title { display: none; }
.player-start .card .emoji { font-size: 50cqw; }
.player-start h2 { margin: 0; font-size: clamp(20px, 3vw, 32px); font-weight: 900; }
.btn-play {
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 36px; border-radius: 28px;
  background: var(--accent); color: #fff; font-size: 20px; font-weight: 900;
  box-shadow: 0 6px 0 #3a1fb0; transition: transform .1s, background .15s;
}
.btn-play:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-play:active { transform: translateY(3px); box-shadow: 0 3px 0 #3a1fb0; }
.btn-play .ic { fill: currentColor; }
.player-note { color: var(--muted); max-width: 420px; font-size: 14px; line-height: 1.5; }

.game-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 0 0 12px 12px; background: var(--bg-2);
}
.game-bar .card { --card-radius: 8px; width: 44px; aspect-ratio: 1; border: 0; flex-shrink: 0; }
.game-bar .card .t-title { display: none; }
.game-bar .card .emoji { font-size: 60cqw; }
.game-bar-title { flex: 1; min-width: 0; }
.game-bar-title strong { display: block; font-size: 18px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-bar-title span { color: var(--muted); font-size: 13px; }
.bar-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  color: var(--text); background: var(--bg-3); transition: background .15s;
}
.bar-btn:hover { background: var(--input); }
.bar-btn.on { color: #ff5c8a; }
.bar-btn.on .ic { fill: currentColor; }

.game-side { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-info {
  margin: 20px 0 28px; padding: 20px 24px; border-radius: 12px; background: var(--bg-2);
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px;
}
.game-info h1 { margin: 0 0 10px; font-size: 28px; font-weight: 900; }
.game-info p { margin: 0 0 12px; color: var(--muted); line-height: 1.6; font-weight: 600; }
.game-info h3 { margin: 0 0 8px; font-size: 16px; }
.meta-list { margin: 0; align-content: start; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip { padding: 6px 14px; border-radius: 16px; background: var(--bg-3); font-size: 14px; }
.chip:hover { background: var(--accent); }

/* ---------- Static pages ---------- */
.prose { max-width: 760px; margin: 0 4px 40px; line-height: 1.7; font-weight: 600; color: #dcdeea; }
.prose h1 { color: var(--text); font-size: 32px; font-weight: 900; margin: 4px 0 16px; }
.prose h2 { color: var(--text); font-size: 20px; margin: 28px 0 8px; }
.prose a { color: var(--icon); text-decoration: underline; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 24px; padding: 28px 4px 36px; border-top: 1px solid var(--bg-3);
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; color: var(--muted); font-size: 14px;
}
.footer .logo { transform: scale(.85); transform-origin: left center; color: var(--text); }
.footer nav { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.footer a:hover { color: var(--text); }
.footer .copy { margin-left: auto; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100;
  padding: 12px 20px; border-radius: 12px;
  background: var(--bg-3); box-shadow: 0 10px 30px rgba(0,0,0,.5);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .game-side { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .game-info { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  :root { --side: 0px; --card-w: clamp(140px, 42vw, 240px); }
  body.side-open { --side: 0px; }
  .sidebar { width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar .side-label { opacity: 1; }
  body.mobile-open .sidebar { transform: none; }
  body.mobile-open .backdrop { display: block; position: fixed; inset: var(--top) 0 0 0; z-index: 30; background: rgba(0,0,0,.6); }
  .main { padding: 16px 12px 0; }
  .logo-text { display: none; }
  .section-head h2 { font-size: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .player { aspect-ratio: 4 / 3; border-radius: 10px 10px 0 0; }
  .game-info { padding: 16px; }
  .footer .copy { margin-left: 0; }
  .game-bar { gap: 8px; padding: 8px 10px; }
  .bar-btn { width: 36px; height: 36px; }
  .bar-btn .ic { width: 18px; height: 18px; }
  .game-bar-title strong { font-size: 16px; }
}
@media (max-width: 520px) {
  .topbar { gap: 8px; padding: 0 10px 0 6px; }
  .btn-primary { padding: 0 14px; font-size: 14px; height: 36px; }
  .top-actions .icon-btn { display: none; }
  .search input { height: 40px; font-size: 15px; padding-left: 14px; }
  .search-btn { top: 0; }
  .search-results { top: 48px; }
}
@media (hover: none) {
  .scroll-btn { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
