/* tokens.css */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eff1f5;
  --surface-3: #e5e8ee;
  --border: #dde1e8;
  --border-strong: #c3c9d3;
  --text: #151922;
  --text-2: #4f5767;
  --text-3: #6b7383;
  --accent: #3451d1;
  --accent-hover: #2940b4;
  --accent-contrast: #ffffff;
  --accent-soft: #e9edff;
  --accent-text: #2d46bd;
  --free: #11704a;
  --free-soft: #e1f5ec;
  --paid: #5b4a1c;
  --paid-soft: #f6efdc;
  --here: #6d2fb8;
  --here-soft: #f1e8fd;
  --danger: #b42318;
  --focus: #3451d1;
  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 16px rgb(16 24 40 / 6%);
  --shadow-lg: 0 12px 40px rgb(16 24 40 / 18%);
  --scrim: rgb(10 13 20 / 45%);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --header-h: 60px;
  --sidebar-w: 264px;
  --wrap: 1320px;
  --gutter: 24px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --t-fast: 120ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1217;
    --surface: #171b22;
    --surface-2: #1e232c;
    --surface-3: #272d38;
    --border: #2a303b;
    --border-strong: #3b4350;
    --text: #e9ecf1;
    --text-2: #b2b9c6;
    --text-3: #939bab;
    --accent: #8298ff;
    --accent-hover: #9dafff;
    --accent-contrast: #0f1217;
    --accent-soft: #1f2748;
    --accent-text: #a5b4ff;
    --free: #6ad6a3;
    --free-soft: #133126;
    --paid: #e7cf8f;
    --paid-soft: #2d2715;
    --here: #c9a3ff;
    --here-soft: #2b1f40;
    --danger: #ff8a80;
    --focus: #a5b4ff;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
    --shadow-lg: 0 16px 48px rgb(0 0 0 / 50%);
    --scrim: rgb(0 0 0 / 60%);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1217;
  --surface: #171b22;
  --surface-2: #1e232c;
  --surface-3: #272d38;
  --border: #2a303b;
  --border-strong: #3b4350;
  --text: #e9ecf1;
  --text-2: #b2b9c6;
  --text-3: #939bab;
  --accent: #8298ff;
  --accent-hover: #9dafff;
  --accent-contrast: #0f1217;
  --accent-soft: #1f2748;
  --accent-text: #a5b4ff;
  --free: #6ad6a3;
  --free-soft: #133126;
  --paid: #e7cf8f;
  --paid-soft: #2d2715;
  --here: #c9a3ff;
  --here-soft: #2b1f40;
  --danger: #ff8a80;
  --focus: #a5b4ff;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 6px 20px rgb(0 0 0 / 25%);
  --shadow-lg: 0 16px 48px rgb(0 0 0 / 50%);
  --scrim: rgb(0 0 0 / 60%);
  color-scheme: dark;
}

@media (max-width: 640px) {
  :root { --gutter: 16px; --header-h: 56px; }
}

/* base.css */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main { flex: 1 0 auto; outline: none; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 2.6vw, 2.3rem); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--accent-text); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font: 600 .75em/1 var(--font-mono);
  padding: .2em .45em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--text-2);
}
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; margin: 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.i { width: 20px; height: 20px; flex: none; }

.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.narrow-page { max-width: 880px; padding-top: 32px; padding-bottom: 56px; }
.muted { color: var(--text-2); }
.small { font-size: .875rem; }
.intro { color: var(--text-2); font-size: 1.05rem; max-width: 68ch; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; font-weight: 700; color: var(--text-3); margin-bottom: .4rem; }
.h-small { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-contrast);
  padding: 10px 16px; border-radius: var(--radius); font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 10px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .ad-slot, .sidebar, .toolbar, .save-btn { display: none !important; }
}

/* components.css */
/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 20px; height: var(--header-h); }
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.15rem; letter-spacing: -0.02em; flex: none; }
.logo:hover { color: var(--text); }
.logo-mark { width: 30px; height: 30px; }
.main-nav ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.main-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.main-nav a:hover { background: var(--surface-2); color: var(--text); }
.main-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.nav-search .i { width: 17px; height: 17px; }
.nav-search kbd { margin-left: 4px; }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.login-link { font-size: .875rem; color: var(--text-2); text-decoration: none; padding: 6px 8px; border-radius: var(--radius-sm); margin-left: 4px; }
.login-link:hover { color: var(--text); background: var(--surface-2); }
.saved-link { position: relative; }
.count-dot {
  position: absolute; top: 3px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--accent); color: var(--accent-contrast);
  font-size: .68rem; font-weight: 800; line-height: 17px; text-align: center;
}
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}
.mobile-nav { border-top: 1px solid var(--border); background: var(--surface); }
.mobile-nav ul { list-style: none; margin: 0; padding: 8px var(--gutter) 14px; display: grid; gap: 2px; }
.mobile-nav a { display: block; padding: 12px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text); font-weight: 600; }
.mobile-nav a:hover, .mobile-nav a[aria-current="page"] { background: var(--surface-2); }

.only-narrow { display: none !important; }
@media (max-width: 899px) {
  .main-nav, .login-link { display: none; }
  .only-narrow { display: inline-flex !important; }
  .only-wide { display: none !important; }
  .header-inner { gap: 10px; }
}
@media (min-width: 900px) { .mobile-nav { display: none !important; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 16px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  font-weight: 700; font-size: .95rem; line-height: 1.1; text-decoration: none; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover { background: var(--surface-3); color: var(--text); }
.btn .i { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-hover); color: var(--accent-contrast); }
.btn-outline { background: var(--surface); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-2); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-play { background: var(--accent-soft); color: var(--accent-text); }
.btn-play:hover { background: var(--accent); color: var(--accent-contrast); }
.btn-danger { color: var(--danger); }
.btn-sm { min-height: 34px; padding: 6px 11px; font-size: .85rem; border-radius: var(--radius-sm); gap: 6px; }
.btn-sm .i { width: 16px; height: 16px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn-sub { font-weight: 500; opacity: .85; margin-left: -2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.i-ext { width: 14px !important; height: 14px !important; opacity: .8; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius); border: 0; background: transparent;
  color: var(--text-2); text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.link-btn { background: none; border: 0; padding: 2px 0; color: var(--accent-text); font-weight: 600; font-size: .9rem; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-hover); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.file-btn { cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* save (heart) toggle */
.save-btn .i-on { display: none; color: #e0475b; }
.save-btn[aria-pressed="true"] .i-on { display: block; }
.save-btn[aria-pressed="true"] .i-off { display: none; }
.save-btn.icon-btn { width: 34px; height: 34px; }

/* ---------- badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; font-size: .74rem; font-weight: 700; line-height: 1.3; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.badge .i { width: 12px; height: 12px; }
.badge-free { background: var(--free-soft); color: var(--free); }
.badge-paid { background: var(--paid-soft); color: var(--paid); }
.badge-here { background: var(--here-soft); color: var(--here); }
.badge-lg { font-size: .85rem; padding: 6px 12px; }
.badge-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; background: var(--accent); color: var(--accent-contrast); font-size: .72rem; font-weight: 800;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 600;
}
.chip:hover { border-color: var(--accent); color: var(--accent-text); }
.chip .count, .count { color: var(--text-3); font-weight: 600; font-size: .85em; font-variant-numeric: tabular-nums; }
.chip-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tag { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); text-decoration: none; font-size: .85rem; font-weight: 600; }
.tag:hover { background: var(--accent-soft); color: var(--accent-text); }
.tag-list { list-style: none; padding: 0; margin: 0 0 24px; display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- search fields & suggestions ---------- */
.search-field {
  position: relative; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 0 6px 0 14px; min-height: 46px;
}
.search-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.search-field > .i { color: var(--text-3); }
.search-field input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none; padding: 10px 0; font-size: 1rem;
}
.search-field input::-webkit-search-cancel-button { cursor: pointer; }
.search-field-lg { min-height: 56px; font-size: 1.1rem; }
.search-field-lg input { font-size: 1.1rem; }
.search-field-xl { min-height: 62px; border-radius: var(--radius-lg); padding-left: 18px; box-shadow: var(--shadow); }
.search-field-xl input { font-size: 1.15rem; }
.search-field-xl .btn { min-height: 48px; }
.interpret { margin: 10px 2px 0; font-size: .9rem; color: var(--text-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.interpret .chip { padding: 3px 4px 3px 10px; font-size: .82rem; background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.interpret .chip button { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.interpret .chip button:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.interpret .chip .i { width: 14px; height: 14px; }
.suggest { list-style: none; margin: 8px 0 0; padding: 0; }
.suggest li[role="option"] { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius); cursor: pointer; }
.suggest li[role="option"][aria-selected="true"], .suggest li[role="option"]:hover { background: var(--surface-2); }
.suggest img { width: 64px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; }
.suggest .s-title { font-weight: 700; display: block; }
.suggest .s-meta { color: var(--text-2); font-size: .82rem; display: block; }
.suggest .s-all { color: var(--accent-text); font-weight: 700; padding-left: 4px; }
.suggest-pop {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 6px; max-height: min(60vh, 460px); overflow: auto;
}

.search-dialog {
  width: min(680px, calc(100vw - 24px)); max-height: min(80vh, 640px); margin: 10vh auto auto;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.search-dialog::backdrop { background: var(--scrim); }
.search-dialog .search-field { border-color: transparent; box-shadow: none; background: var(--surface-2); }
.search-hint { color: var(--text-3); font-size: .85rem; margin: 10px 4px 2px; }
@media (max-width: 640px) {
  .search-dialog { margin: 8px auto auto; max-height: calc(100vh - 16px); }
}

/* ---------- cards & grids ---------- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr));
}
.card-item { display: flex; }
.card {
  position: relative; display: flex; flex-direction: column; width: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.card:focus-within { border-color: var(--accent); }
.card-media { aspect-ratio: 16 / 9; background: var(--surface-3); overflow: hidden; }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 4px; flex: 1; display: flex; flex-direction: column; }
.card-title { font-size: 1.02rem; margin: 0 0 4px; }
.card-title a { color: var(--text); text-decoration: none; }
.card-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.card-title a:focus-visible { outline: none; }
.card-title a:focus-visible::after { outline: 3px solid var(--focus); outline-offset: -3px; }
.card-summary {
  color: var(--text-2); font-size: .875rem; line-height: 1.4; margin: 0 0 10px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-meta { list-style: none; padding: 0; margin: auto 0 0; display: grid; gap: 4px; font-size: .82rem; color: var(--text-2); }
.card-meta li { display: flex; align-items: center; gap: 7px; min-width: 0; }
.card-meta li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta .i { width: 15px; height: 15px; color: var(--text-3); }
.card-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px 12px 14px; flex-wrap: wrap; }
.card-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; position: relative; z-index: 2; }
.card-foot .badge { position: relative; z-index: 2; }

/* horizontal strips */
.strip {
  list-style: none; margin: 0; padding: 2px 2px 12px; display: grid; grid-auto-flow: column;
  grid-auto-columns: minmax(236px, 260px); gap: 16px; overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: thin; overscroll-behavior-x: contain;
}
.strip > li { scroll-snap-align: start; }

/* phones: list-style cards */
@media (max-width: 559px) {
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .grid .card { display: grid; grid-template-columns: 136px 1fr; grid-template-rows: auto auto; }
  .grid .card-media { grid-row: 1 / span 2; aspect-ratio: 16 / 9; align-self: start; margin: 12px 0 0 12px; border-radius: 8px; }
  .grid .card-body { padding: 10px 12px 0; }
  .grid .card-title { font-size: .98rem; }
  .grid .card-summary { -webkit-line-clamp: 2; font-size: .82rem; margin-bottom: 6px; }
  .grid .card-meta-genre, .grid .card-meta-platform { display: none; }
  .grid .card-foot { padding: 6px 10px 10px 12px; }
  .strip { grid-auto-columns: 78%; }
}

/* ---------- sections ---------- */
.section { margin: 40px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-note { color: var(--text-2); margin: -6px 0 14px; font-size: .95rem; }
.see-all { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: .9rem; text-decoration: none; white-space: nowrap; }
.see-all .i { width: 16px; height: 16px; }

.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 10px; font-size: .85rem; color: var(--text-3); }
.breadcrumbs li + li::before { content: "/"; margin-right: 6px; color: var(--border-strong); }
.breadcrumbs a { color: var(--text-2); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ---------- ads: one small banner near the bottom of a page (see src/js/ui/ads.js) ---------- */
.ad-slot { margin: 28px auto 0; width: 468px; max-width: 100%; }
.ad-label { display: block; font-size: .62rem; line-height: 1; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 0 0 3px 2px; }
.ad-box { position: relative; height: 60px; border-radius: var(--radius-sm); overflow: hidden; }
.house-ad {
  display: flex; align-items: center; gap: 10px; height: 100%; padding: 3px 10px 3px 3px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text-2); text-decoration: none; font-size: .8rem;
}
.house-ad:hover { border-color: var(--border-strong); }
.house-ad img { width: 96px; height: 54px; flex: none; object-fit: cover; border-radius: calc(var(--radius-sm) - 2px); }
.house-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.house-text strong { color: var(--text); font-weight: 600; }
.house-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.house-cta { flex: none; font-weight: 600; color: var(--accent-text); }
.ad-box iframe { position: absolute; inset: 0; border: 0; opacity: 0; pointer-events: none; }
.ad-slot.is-filled .ad-box iframe { opacity: 1; pointer-events: auto; }
.ad-slot.is-filled .house-ad { visibility: hidden; }
.ad-consent { margin: 4px 2px 0; font-size: .72rem; color: var(--text-3); }
.ad-consent .link-btn { font-size: inherit; }
@media (max-width: 559px) {
  .ad-slot { width: 320px; }
  .ad-box { height: 50px; }
  .house-ad img { width: 78px; height: 44px; }
  .house-text span { display: none; }
}

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); margin-top: 48px; }
.footer-inner { display: grid; grid-template-columns: 1.2fr 2fr; gap: 24px 48px; padding-top: 32px; padding-bottom: 32px; }
.footer-brand p { color: var(--text-2); font-size: .9rem; margin-top: 10px; max-width: 40ch; }
.footer-links { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 16px; }
.footer-links a { color: var(--text-2); text-decoration: none; font-size: .92rem; }
.footer-links a:hover { color: var(--text); text-decoration: underline; }
.footer-note { grid-column: 1 / -1; color: var(--text-3); font-size: .82rem; margin: 0; border-top: 1px solid var(--border); padding-top: 16px; }
@media (max-width: 720px) { .footer-inner { grid-template-columns: 1fr; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius);
  font-weight: 600; font-size: .92rem; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px);
}
.toast a { color: inherit; }

.callout { background: var(--accent-soft); border-radius: var(--radius-lg); padding: 18px 20px; margin: 16px 0 8px; }
.callout p:last-child { margin: 0; }
.form-status { min-height: 1.5em; font-weight: 600; }

/* Controller navigation (src/js/ui/gamepad.js): focus is always visible and generous. */
.pad-active :focus { outline: 3px solid var(--focus); outline-offset: 3px; }
.pad-active .check:focus-within, .pad-active .pill:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
.pad-active .card:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }

/* browse.css */
/* Browse layout: collapsible filter sidebar (desktop) / slide-out drawer (mobile). */
.browse { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); gap: 28px; padding-top: 24px; padding-bottom: 24px; align-items: start; }
.results { min-width: 0; }
.results-head h1 { margin-bottom: 6px; }
.results-head .intro { margin-bottom: 14px; }
.browse-search { margin: 14px 0 0; max-width: 640px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 16px 0 8px; }
.result-count { margin: 0; color: var(--text-2); }
.result-count strong { color: var(--text); font-variant-numeric: tabular-nums; }
.toolbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sort-select { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--text-2); }
.sort-select select {
  min-height: 36px; padding: 4px 30px 4px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 600;
}
.active-chips { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.active-chips:empty { display: none; }
.active-chips .chip { padding: 4px 4px 4px 11px; font-size: .84rem; background: var(--surface-2); border-color: transparent; }
.active-chips .chip button { border: 0; background: transparent; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); }
.active-chips .chip button:hover { background: var(--surface-3); color: var(--text); }
.active-chips .chip .i { width: 14px; height: 14px; }
.active-chips .clear-chip { background: none; border: 0; color: var(--accent-text); font-weight: 600; font-size: .85rem; text-decoration: underline; padding: 4px 6px; }

.empty { text-align: center; padding: 48px 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); }
.empty h2 { font-size: 1.2rem; }
.empty p { color: var(--text-2); }
.empty-actions { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ---- sidebar ---- */
.sidebar { position: sticky; top: calc(var(--header-h) + 16px); max-height: calc(100vh - var(--header-h) - 32px); display: flex; }
.sidebar-panel {
  width: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 14px 18px;
}
.sidebar-rail { display: none; }
.sidebar-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; position: sticky; top: -14px; background: var(--surface); padding: 2px 0 8px; z-index: 1; }
.sidebar-head h2 { font-size: 1rem; margin: 0; margin-right: auto; }
.sidebar-head .icon-btn { width: 34px; height: 34px; }
.fgroup { border: 0; padding: 12px 0 10px; margin: 0; border-top: 1px solid var(--border); min-width: 0; }
.fgroup legend { float: left; width: 100%; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin-bottom: 6px; padding: 0; }
.fgroup legend + * { clear: both; }
.check { display: flex; align-items: center; gap: 10px; padding: 5px 6px; margin: 0 -6px; border-radius: var(--radius-sm); cursor: pointer; font-size: .92rem; }
.check:hover { background: var(--surface-2); }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { width: 18px; height: 18px; border: 1.5px solid var(--border-strong); border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--surface); }
.check-box .i { width: 14px; height: 14px; color: var(--accent-contrast); opacity: 0; stroke-width: 3; }
.check input:checked + .check-box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check-box .i { opacity: 1; }
.check input:focus-visible + .check-box { outline: 3px solid var(--focus); outline-offset: 2px; }
.check-label { flex: 1; min-width: 0; }
.check .count { margin-left: auto; font-size: .8rem; }
.check.is-zero { color: var(--text-3); }
.fgroup-genres .extra { display: none; }
.fgroup-genres.is-open .extra, .fgroup-genres .extra.has-checked { display: flex; }
.more-btn { margin-top: 6px; font-size: .85rem; }

.pills { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; clear: both; }
.pill { position: relative; cursor: pointer; }
.pill input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pill > span:not(.visually-hidden) { display: block; }
.pill > span:first-of-type {
  text-align: center; padding: 8px 0 1px; border-radius: var(--radius) var(--radius) 0 0; font-weight: 800;
  border: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface);
}
.pill .pill-count { text-align: center; font-size: .7rem; color: var(--text-3); padding: 0 0 5px; border: 1px solid var(--border-strong); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); }
.pill:hover > span:first-of-type, .pill:hover .pill-count { background: var(--surface-2); }
.pill input:checked ~ span:first-of-type, .pill input:checked ~ .pill-count { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.pill input:focus-visible ~ span:first-of-type { outline: 3px solid var(--focus); outline-offset: 2px; }

/* collapsed rail (desktop) */
@media (min-width: 900px) {
  .filters-collapsed .browse { grid-template-columns: 52px minmax(0, 1fr); }
  .filters-collapsed .sidebar-panel { display: none; }
  .filters-collapsed .sidebar-rail { display: flex; flex-direction: column; align-items: center; }
  .sidebar-rail .icon-btn { width: 48px; height: 48px; border: 1px solid var(--border); background: var(--surface); position: relative; }
  .sidebar-rail .badge-count { position: absolute; top: -6px; right: -6px; }
  .drawer-scrim { display: none !important; }
}

/* drawer (tablet & phone) */
@media (max-width: 899px) {
  .browse { grid-template-columns: minmax(0, 1fr); padding-top: 16px; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; max-height: none;
    width: min(360px, 88vw); transform: translateX(-104%); visibility: hidden;
    transition: transform 200ms ease, visibility 0s linear 200ms;
  }
  .sidebar.is-open { transform: none; visibility: visible; transition: transform 200ms ease; box-shadow: var(--shadow-lg); }
  .sidebar-panel { border-radius: 0; border: 0; display: flex; flex-direction: column; padding: 12px 16px 0; }
  .sidebar-panel .filters { flex: 1; }
  .sidebar-head { top: -12px; }
  .drawer-foot { position: sticky; bottom: 0; background: var(--surface); padding: 12px 0 16px; border-top: 1px solid var(--border); display: block !important; }
  .drawer-scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 55; }
  .filters-btn .badge-count { margin-left: 2px; }
  .toolbar-right { margin-left: 0; width: 100%; justify-content: space-between; }
  .toolbar .result-count { margin-left: auto; }
}
@media (max-width: 480px) {
  .toolbar-right .btn span { display: none; }
}
body.drawer-open { overflow: hidden; }

.related-cats { margin-top: 8px; }

/* game.css */
/* Game page */
.game-page { padding-top: 20px; }
.game-hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: start; margin-bottom: 32px; }
.game-hero.has-player { grid-template-columns: minmax(0, 1fr); gap: 20px; }
.game-cover { margin: 0; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); aspect-ratio: 16 / 9; background: var(--surface-3); }
.game-cover { position: relative; }
.game-cover img { width: 100%; height: 100%; object-fit: cover; }
.game-cover figcaption { position: absolute; right: 8px; bottom: 6px; font-size: .7rem; color: #fff; background: rgb(0 0 0 / 55%); padding: 2px 7px; border-radius: 4px; max-width: calc(100% - 16px); }
.game-head h1 { margin-bottom: 8px; }
.lede { font-size: 1.1rem; color: var(--text-2); margin-bottom: 14px; }
.quick-facts { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--text-2); font-size: .95rem; }
.quick-facts li { display: inline-flex; align-items: center; gap: 7px; }
.quick-facts .i { width: 18px; height: 18px; color: var(--text-3); }
.game-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.game-actions .save-btn[aria-pressed="true"] { border-color: #e0475b; }
.source-note { display: flex; gap: 8px; align-items: flex-start; font-size: .88rem; color: var(--text-2); max-width: 60ch; }
.source-note .i { width: 17px; height: 17px; margin-top: 2px; color: var(--text-3); }
.has-player .game-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 24px; }
.has-player .game-head > * { grid-column: 1; }
.has-player .game-actions { grid-column: 2; grid-row: 1 / span 4; align-self: center; }
@media (max-width: 899px) {
  .game-hero { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .has-player .game-head { display: block; }
}

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; align-items: start; }
.game-main h2 { font-size: 1.15rem; }
.prose p { max-width: 68ch; }
.game-facts { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; position: sticky; top: calc(var(--header-h) + 16px); }
.facts { margin: 0; display: grid; gap: 0; }
.facts div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--text-3); font-weight: 600; }
.facts dd { margin: 0; font-weight: 600; }
.fact-sub { display: block; font-weight: 400; color: var(--text-2); font-size: .85rem; margin-top: 2px; }
.facts-note { font-size: .8rem; color: var(--text-3); margin: 10px 0 0; }
@media (max-width: 899px) {
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .game-facts { position: static; order: -1; }
}

/* ---- player ---- */
.player { background: #0b0d12; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.player-frame { position: relative; aspect-ratio: 16 / 9; max-height: min(72vh, 640px); width: 100%; background: #0b0d12; margin: 0 auto; }
.player-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; background: #0b0d12; }
.player-poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: .22; filter: blur(2px); }
.player-start {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 0; background: transparent; color: #fff; font-size: 1.25rem; font-weight: 800; width: 100%;
}
.player-start small { font-size: .85rem; font-weight: 500; opacity: .85; }
.player-start-icon { width: 76px; height: 76px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); display: grid; place-items: center; box-shadow: 0 8px 30px rgb(0 0 0 / 40%); transition: transform var(--t-fast); }
.player-start-icon .i { width: 34px; height: 34px; margin-left: 4px; }
.player-start:hover .player-start-icon { transform: scale(1.06); }
.player-start:focus-visible { outline-offset: -6px; }
.player-bar { display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap; }
.player-note { margin: 0; font-size: .82rem; color: var(--text-2); flex: 1 1 260px; }
.player-note .i { width: 15px; height: 15px; display: inline-block; vertical-align: -3px; margin-right: 5px; }
.player-controls { margin-left: auto; display: flex; gap: 6px; }
.player-bar-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 10px; background: #0b0d12; color: #fff; font-weight: 700; height: 44px; }
.btn-outline-light { background: transparent; color: #fff; border-color: rgb(255 255 255 / 40%); }
.btn-outline-light:hover { background: rgb(255 255 255 / 12%); color: #fff; }

/* Real fullscreen: only the game frame is shown. */
.player-frame:fullscreen { aspect-ratio: auto; max-height: none; width: 100vw; height: 100vh; }
.player-frame:-webkit-full-screen { aspect-ratio: auto; max-height: none; width: 100vw; height: 100vh; }
.player-frame:fullscreen .player-poster { display: none; }

/* Fallback for browsers without the Fullscreen API (e.g. iPhone Safari):
   the player fills the viewport; a slim bar sits above the game, never on it. */
.player.is-pseudo-fs { position: fixed; inset: 0; z-index: 200; border-radius: 0; border: 0; display: flex; flex-direction: column; }
.player.is-pseudo-fs .player-frame { flex: 1; aspect-ratio: auto; max-height: none; height: auto; }
.player.is-pseudo-fs .player-bar { display: none; }
body.pseudo-fs-open { overflow: hidden; }

/* Board-style games get a taller player on phones; wide games keep 16:9 (and suggest rotating). */
@media (max-width: 640px) {
  .player-board .player-frame { aspect-ratio: 4 / 5; max-height: 78vh; }
  .player-board .player-poster { object-fit: cover; }
}

/* pages.css */
/* ---------- home ---------- */
.hero { background: var(--surface); border-bottom: 1px solid var(--border); }
.hero-inner { padding-top: 56px; padding-bottom: 40px; max-width: 900px; }
.hero-title { font-size: clamp(2.2rem, 5vw, 3.4rem); letter-spacing: -0.035em; margin-bottom: 10px; }
.hero-sub { font-size: 1.12rem; color: var(--text-2); max-width: 60ch; margin-bottom: 26px; }
.hero-search { position: relative; }
.examples { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.examples > span { color: var(--text-3); font-size: .9rem; font-weight: 600; }
.examples ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 640px) {
  .hero-inner { padding-top: 32px; padding-bottom: 28px; }
  .search-field-xl .btn { display: none; }
  .examples ul { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; margin-right: calc(var(--gutter) * -1); }
  .examples li { flex: none; }
}

.player-tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.player-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; height: 100%;
  padding: 16px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border);
  text-decoration: none; color: var(--text); transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.player-tile:hover { border-color: var(--accent); box-shadow: var(--shadow); color: var(--text); }
.pt-glyph { font-size: 2rem; font-weight: 900; letter-spacing: -0.04em; color: var(--accent-text); line-height: 1.1; min-height: 2.3rem; display: flex; align-items: center; }
.pt-glyph .i { width: 32px; height: 32px; }
.pt-label { font-weight: 800; }
.pt-count { color: var(--text-3); font-size: .85rem; }
@media (max-width: 900px) { .player-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 400px) { .player-tiles { gap: 8px; } .player-tile { padding: 12px; } }

.genre-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.genre-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 11px 14px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-weight: 700; font-size: .93rem;
}
.genre-chip:hover { border-color: var(--accent); color: var(--accent-text); }

.mode-tiles { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.mode-tile {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); height: 100%;
}
.mode-tile:hover { border-color: var(--accent); color: var(--text); }
.mt-icon { width: 42px; height: 42px; border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.mt-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.mt-label { font-weight: 800; }
.mt-sub { color: var(--text-2); font-size: .85rem; }
.mode-tiles-compact { margin: 6px 0 4px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.mode-tiles-compact .mode-tile { padding: 10px 12px; }
.mode-tiles-compact .mt-icon { width: 36px; height: 36px; }

/* ---------- categories ---------- */
.cat-group { margin: 32px 0; }
.cat-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.cat-list a {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 14px 16px; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); text-decoration: none; color: var(--text);
}
.cat-list a:hover { border-color: var(--accent); }
.cat-name { font-weight: 800; }
.cat-desc { grid-column: 1; color: var(--text-2); font-size: .85rem; }
.cat-list .count { grid-row: 1; grid-column: 2; }

/* ---------- saved ---------- */
.saved-page .grid { margin-top: 4px; }
.empty-note { color: var(--text-2); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 18px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.empty-note .i { width: 18px; height: 18px; display: inline; }
.account-hint { margin-top: 16px; font-size: .92rem; color: var(--text-2); display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.recent-list, .saved-searches { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.recent-list li, .saved-searches li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.recent-list img { width: 80px; height: 45px; border-radius: 6px; object-fit: cover; flex: none; }
.recent-list .r-main, .saved-searches .r-main { flex: 1; min-width: 0; }
.recent-list a, .saved-searches a { font-weight: 700; color: var(--text); text-decoration: none; }
.recent-list a:hover, .saved-searches a:hover { color: var(--accent-text); text-decoration: underline; }
.r-sub { display: block; color: var(--text-3); font-size: .82rem; }
.storage-note { display: flex; gap: 8px; align-items: center; color: var(--danger); font-weight: 600; }

/* ---------- account / about / 404 ---------- */
.prose-page h2 { margin-top: 32px; }
.prose-page ul { padding-left: 1.2em; }
.prose-page li { margin-bottom: .5em; }
.prose-page p, .prose-page li { max-width: 70ch; }
.notfound .grid { margin: 16px 0 24px; }
.notfound .browse-search { margin-bottom: 20px; }
