@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&family=Nunito:wght@400;700;800&family=Outfit:wght@500;700&family=Poppins:wght@400;600;700&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  /* Typeface — player-selectable via the nav font picker (sets html[data-font]); default below. */
  --font-ui: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-name: 'Space Grotesk', 'Inter', sans-serif;
  --bg: #0a0e1a;
  --bg-card: #141a2e;
  --bg-card-hover: #1b2440;
  --text: #e6ebff;
  --text-dim: #9aa6c8;
  --border: #243054;
  --accent: #ffd060;
  /* Surfaces variableized so the theme picker (html[data-theme]) can swap them, incl. light mode. */
  --bg-glow: #18203a;
  --nav-bg: rgba(10,14,26,0.7);
  --tip-bg: #0c1124;
  --pill-bg: rgba(255,255,255,0.06);
  --pill-bg-active: rgba(255,255,255,0.14);
  --border-focus: #36477d;
  --radius: 14px;
  /* Tile sizing — overridden by the density preference (html[data-density]). */
  /* Capsule tiles are square: --tile-minh tracks --tile-min so the pager's row
     estimate stays close (measureFit corrects from the real layout anyway). */
  --tile-min: 210px; --tile-icon: 32px; --tile-minh: 210px; --name-max: 25px; --name-list: 19px;
}

/* Player-selectable tile DENSITY (html[data-density]; persisted as 'playpendium:density'). */
html[data-density="cozy"]    { --tile-min: 176px; --tile-icon: 27px; --tile-minh: 176px; --name-max: 21px; --name-list: 17px; }
html[data-density="compact"] { --tile-min: 148px; --tile-icon: 22px; --tile-minh: 148px; --name-max: 18px; --name-list: 15px; }

/* ───────── Player-selectable color schemes (persisted in localStorage 'playpendium:theme'). ───────── */
html[data-theme="midnight"] { --bg:#0a0e1a; --bg-card:#141a2e; --bg-card-hover:#1b2440; --text:#e6ebff; --text-dim:#9aa6c8; --border:#243054; --bg-glow:#18203a; --nav-bg:rgba(10,14,26,.7); --tip-bg:#0c1124; --pill-bg:rgba(255,255,255,.06); --pill-bg-active:rgba(255,255,255,.14); --border-focus:#36477d; }
html[data-theme="slate"]    { --bg:#0f1115; --bg-card:#1a1d24; --bg-card-hover:#232733; --text:#e8eaf0; --text-dim:#9aa0ad; --border:#2b2f3a; --bg-glow:#20242e; --nav-bg:rgba(15,17,21,.72); --tip-bg:#15171d; --pill-bg:rgba(255,255,255,.06); --pill-bg-active:rgba(255,255,255,.14); --border-focus:#3a4150; }
html[data-theme="ocean"]    { --bg:#07131a; --bg-card:#0f2230; --bg-card-hover:#163243; --text:#e2f1f7; --text-dim:#93b3bf; --border:#1d3a48; --bg-glow:#103040; --nav-bg:rgba(7,19,26,.72); --tip-bg:#0a1e29; --pill-bg:rgba(255,255,255,.06); --pill-bg-active:rgba(255,255,255,.14); --border-focus:#2c5a6b; }
html[data-theme="plum"]     { --bg:#120a1c; --bg-card:#1e1330; --bg-card-hover:#2a1c42; --text:#efe6ff; --text-dim:#b3a3c8; --border:#36264e; --bg-glow:#2a1840; --nav-bg:rgba(18,10,28,.72); --tip-bg:#190f28; --pill-bg:rgba(255,255,255,.07); --pill-bg-active:rgba(255,255,255,.16); --border-focus:#543a73; }
html[data-theme="light"]    { --bg:#eef1f7; --bg-card:#ffffff; --bg-card-hover:#f3f5fb; --text:#1a2233; --text-dim:#5b6680; --border:#d4dae8; --bg-glow:#dfe6f3; --nav-bg:rgba(255,255,255,.82); --tip-bg:#ffffff; --pill-bg:rgba(0,0,0,.05); --pill-bg-active:rgba(0,0,0,.10); --border-focus:#9bb0e0; }
/* ── Extra palettes: styles / military / national colors (added 2026-06-20) ── */
html[data-theme="cyberpunk"] { --bg:#0a0612; --bg-card:#160a22; --bg-card-hover:#221033; --text:#f0e9ff; --text-dim:#b59ad6; --border:#36214e; --bg-glow:#2a0a3a; --nav-bg:rgba(10,6,18,.72); --tip-bg:#140820; --border-focus:#ff2bd0; }
html[data-theme="synthwave"] { --bg:#120726; --bg-card:#1e0f3a; --bg-card-hover:#2a164e; --text:#ffe9fb; --text-dim:#c2a3d6; --border:#3a2358; --bg-glow:#3a1248; --nav-bg:rgba(18,7,38,.72); --tip-bg:#170a30; --border-focus:#ff5fae; }
html[data-theme="neon-noir"] { --bg:#040a12; --bg-card:#0a1622; --bg-card-hover:#122436; --text:#dff2ff; --text-dim:#8fb4cc; --border:#163348; --bg-glow:#06283a; --nav-bg:rgba(4,10,18,.72); --tip-bg:#08141f; --border-focus:#29e0ff; }
html[data-theme="military"]  { --bg:#131510; --bg-card:#1f2218; --bg-card-hover:#2a2e20; --text:#ecefe0; --text-dim:#a6ac92; --border:#343a26; --bg-glow:#2a3016; --nav-bg:rgba(19,21,16,.72); --tip-bg:#181a12; --border-focus:#8a9a3a; }
html[data-theme="desert"]    { --bg:#ece2cf; --bg-card:#f6efe0; --bg-card-hover:#efe6d2; --text:#2a2418; --text-dim:#6b5f48; --border:#d8cbb0; --bg-glow:#e2d4b8; --nav-bg:rgba(246,239,224,.84); --tip-bg:#fffaf0; --pill-bg:rgba(0,0,0,.05); --pill-bg-active:rgba(0,0,0,.10); --border-focus:#b08948; }
html[data-theme="forest"]    { --bg:#07140d; --bg-card:#0e2217; --bg-card-hover:#163422; --text:#e4f3ea; --text-dim:#93bfa3; --border:#1d4030; --bg-glow:#0c3020; --nav-bg:rgba(7,20,13,.72); --tip-bg:#0a1e14; --border-focus:#3ec47a; }
html[data-theme="sunset"]    { --bg:#160c08; --bg-card:#251510; --bg-card-hover:#341e16; --text:#ffeede; --text-dim:#cca893; --border:#4a2c1d; --bg-glow:#3a1c0c; --nav-bg:rgba(22,12,8,.72); --tip-bg:#1c0f08; --border-focus:#ff7a3a; }
html[data-theme="mono"]      { --bg:#0d0d0f; --bg-card:#181819; --bg-card-hover:#232325; --text:#ededf0; --text-dim:#a0a0a6; --border:#2c2c30; --bg-glow:#1c1c20; --nav-bg:rgba(13,13,15,.72); --tip-bg:#161618; --border-focus:#888890; }

/* Player-selectable typeface (persisted in localStorage 'playpendium:font'; set on <html>). */
html[data-font="space"]   { --font-name: 'Space Grotesk', 'Inter', sans-serif; --font-ui: 'Inter', system-ui, -apple-system, sans-serif; }
html[data-font="poppins"] { --font-name: 'Poppins', sans-serif; --font-ui: 'Poppins', system-ui, -apple-system, sans-serif; }
html[data-font="nunito"]  { --font-name: 'Nunito', sans-serif;  --font-ui: 'Nunito', system-ui, -apple-system, sans-serif; }
html[data-font="outfit"]  { --font-name: 'Outfit', 'Inter', sans-serif; --font-ui: 'Inter', system-ui, -apple-system, sans-serif; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow) 0%, var(--bg) 55%);
  color: var(--text);
  font: 16px/1.5 var(--font-ui);
  min-height: 100vh;
}

/* Mode banner (offline preview notice) */
#mode-banner {
  background: #2a2140;
  color: #f4e7c0;
  border-bottom: 1px solid #4a3d6b;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
}

.site-header { text-align: center; padding: 56px 20px 28px; }
.site-header.compact { padding: 26px 20px 10px; }
.site-header h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 36px);
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #ffd060, #ff9d5c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.site-header .tagline { color: var(--text-dim); margin: 8px 0 0; font-size: 14px; }
/* Thin tagline line that replaces the old centered hero block; aligns to the layout. */
.tagline-bar { margin: 10px 0 0; padding: 0 20px; color: var(--text-dim); font-size: 13px; }

/* ── Layout: category sidebar + games content ────────────────────────────── */
.layout {
  max-width: none;
  margin: 0;
  padding: 8px 20px 20px;   /* 20px left aligns the sidebar under the logo icon */
  display: flex;
  gap: 26px;
  align-items: flex-start;
}

.sidebar {
  position: sticky;
  top: 66px;            /* clears the sticky top-nav */
  flex: 0 0 250px;
  width: 250px;
  border-right: 1px solid var(--border);   /* divider between categories and the game grid */
  padding-right: 18px;
  /* Pinned & stable: the page scrolls the games on the right; this pane stays put. It scrolls
     internally ONLY when you hover it and the category list overflows its capped height, and that
     scroll is isolated (overscroll-behavior) so it never chains into the page. */
  max-height: calc(100vh - 200px); /* JS (capSidebar) refines this to fit the viewport + ad bar */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  transition: margin-left 0.28s ease, opacity 0.22s ease;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.sidebar-search { margin-bottom: 12px; }
.sidebar-search input {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font: 14px var(--font-ui);
}
.sidebar-search input:focus { outline: none; border-color: var(--border-focus); }

/* Sidebar is a column of pinned items + collapsible sections; each section body is a single
   column (one category per line). The whole sidebar scrolls (see .sidebar) when it runs long. */
.cat-list { display: flex; flex-direction: column; gap: 4px; }
.cat-section-body { display: grid; grid-template-columns: 1fr; gap: 4px; }
.cat-section-body[hidden] { display: none; }
/* Items flagged .cat-span (pinned + Discover rows) span both columns. */
.cat-span { grid-column: 1 / -1; }
/* Collapsible section header (click to expand/collapse; state saved to prefs). */
.cat-section {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  background: none; border: 0; border-top: 1px solid var(--border); cursor: pointer;
  margin-top: 6px; padding: 9px 4px 3px; color: var(--text-dim);
  font: 700 10.5px var(--font-ui); text-transform: uppercase; letter-spacing: 0.6px;
}
.cat-section:hover { color: var(--text); }
.cat-caret { transition: transform 0.15s ease; font-size: 9px; }
.cat-section.collapsed .cat-caret { transform: rotate(-90deg); }
/* Section divider: a thin labeled rule grouping Games / Educational / Relaxation. */
.cat-divider {
  grid-column: 1 / -1; margin: 12px 0 3px; padding-top: 9px;
  border-top: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-dim);
}
.cat-soon { grid-column: 1 / -1; font-size: 11px; color: var(--text-dim); opacity: 0.7; padding: 3px 9px; }
.cat-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; position: relative;
  background: transparent; border: 1px solid transparent;
  color: var(--text-dim);
  border-radius: 8px; padding: 6px 9px;
  font: 600 12.5px var(--font-ui); cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.cat-item:hover { background: var(--bg-card); color: var(--text); }
.cat-item.active { background: var(--bg-card-hover); color: var(--text); border-color: var(--border-focus); }
.cat-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Hover enlarges just the category text 25% (the button box keeps its original size & style). */
.cat-left { display: flex; align-items: center; gap: 8px; min-width: 0; transform-origin: left center; transition: transform 0.12s ease; }
.cat-item:hover .cat-left { transform: scale(1.25); }
.cat-dot { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
/* the active category's left border picks up its own color (subtle, one item at a time) */
.cat-item.active { border-color: var(--cat, var(--border-focus)); }
.fav-btn {
  flex: 0 0 auto; background: none; border: 0; cursor: pointer; padding: 0 1px;
  font-size: 15px; line-height: 1; color: var(--text-dim);
  transition: color 0.12s ease, transform 0.12s ease;
}
.fav-btn:hover { color: #ffd060; transform: scale(1.18); }
.fav-btn.on { color: #ffd060; }
.lang-switch { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font: 600 12px var(--font-ui); cursor: pointer; margin-left: 10px; }
.lang-switch:focus { outline: none; border-color: var(--border-focus); }

.content { flex: 1 1 auto; min-width: 0; }
.results-bar { display: flex; align-items: baseline; gap: 10px; margin: 2px 0 16px; }
.results-bar h2 { margin: 0; font-size: 20px; }
.results-count { color: var(--text-dim); font-size: 13px; }

/* ── Compact game tiles ──────────────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
  gap: 10px;
}

/* Compact tile: no image block. Category shows as a colored LEFT STRIPE (--cat, set
   per-card by app.js) and — in mixed views only — as a tinted text badge. */
.card {
  /* Flex column centered so the icon + name sit vertically centered in the tile
     (esp. single-line names, where the grid stretches the row to the tallest card). */
  display: flex; flex-direction: column; justify-content: center;
  min-height: var(--tile-minh);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--cat, var(--border));
  border-radius: 10px;
  padding: 9px 12px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}
.card.coming-soon { opacity: 0.62; cursor: default; }
.card.coming-soon:hover { transform: none; }

.card-body { padding: 0; width: 100%; }
/* Icon + name vertically centered relative to each other (and the tile). */
.card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
/* Category chip on its own line so it never squeezes the (now large) game name. */
.card-foot { margin-top: 6px; }
/* Per-game line-art glyph, tinted to the category color (matches the left stripe). */
.tile-icon { width: var(--tile-icon); height: var(--tile-icon); flex: 0 0 auto; color: var(--cat, var(--text-dim)); }
.card-name {
  font-family: var(--font-name);
  font-size: 25px; font-weight: 700; margin: 0; flex: 1 1 auto; min-width: 0; line-height: 1.08;
  /* Whole words only (wrap at spaces, never mid-word), up to 2 lines, NEVER an ellipsis.
     app.js fitNames() shrinks the per-tile font so the full name always fits. */
  white-space: normal; overflow-wrap: normal; word-break: normal;
  max-height: 2.2em; overflow: hidden;
}
.badge {
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--cat, #8893b5) 18%, transparent);
  color: var(--cat, var(--text-dim));
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 auto;
}
.badge.soon { background: #4a3d18; color: #f4d480; }
.card-tagline {
  color: var(--text-dim); font-size: 11.5px; line-height: 1.4; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Condensed tiles on hover-capable (desktop) devices: drop the inline tagline — the
   description appears in a hover/focus tooltip instead, so more games fit per screen.
   Touch devices (no hover) keep the inline text since they can't reveal the tooltip. */
@media (hover: hover) and (pointer: fine) {
  .card-tagline { display: none; }
  .card-top { margin-bottom: 0; }
}
/* "Always show descriptions" preference — re-show the inline tagline on desktop too. */
html[data-taglines="show"] .card-tagline { display: -webkit-box !important; }
html[data-taglines="show"] .card-top { margin-bottom: 4px; }

/* ── Layout preference: LIST view (html[data-view="list"]) — one game per full-width row. ── */
html[data-view="list"] .game-grid { display: flex; flex-direction: column; gap: 6px; }
html[data-view="list"] .card { flex-direction: row; align-items: center; min-height: 0; padding: 8px 14px; }
html[data-view="list"] .card-body { display: flex; flex-direction: row; align-items: center; gap: 14px; }
html[data-view="list"] .card-top { margin: 0; flex: 0 0 auto; }
/* §7.6: list-row name size now tracks the density preference via --name-list (was a hardcoded
   19px). The !important stays deliberately — it defeats the later capsule-era 16px rule at
   `html[data-view="list"] .card .card-name`, which is more specific and would otherwise win. */
html[data-view="list"] .card-name { font-size: var(--name-list) !important; white-space: nowrap; max-height: none; overflow: visible; line-height: 1.2; }
html[data-view="list"] .card-tagline { display: block !important; flex: 1 1 auto; -webkit-line-clamp: unset; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }
html[data-view="list"] .card-foot { margin: 0; flex: 0 0 auto; }

/* ── Layout preference: HIDE the sidebar for a full-width game area. ── */
/* Sliding categories panel: hidden = slide out to the left (and the grid reflows to fill). */
html[data-sidebar="hide"] .sidebar { margin-left: -286px; opacity: 0; pointer-events: none; }

/* ── Display settings popover (the nav "▦ Display" button). ── */
.nav-display-wrap { position: relative; display: inline-block; margin-left: 10px; }
.nav-display-btn { cursor: pointer; }
.display-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 200; width: 244px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; box-shadow: 0 20px 50px rgba(0,0,0,.4);
  display: flex; flex-direction: column; gap: 9px;
}
.display-panel[hidden] { display: none; }
.display-title { font: 700 11px var(--font-ui); text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); }
.display-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font: 600 13px var(--font-ui); color: var(--text); }
.display-link { display: block; margin-top: 2px; padding-top: 9px; border-top: 1px solid var(--border); font: 600 13px var(--font-ui); color: var(--text-dim); text-decoration: none; }
.display-link:hover { color: var(--text); }
.display-row select { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 4px 8px; font: 600 12px var(--font-ui); cursor: pointer; }
.display-row select:focus { outline: none; border-color: var(--border-focus); }
.nav-cats-toggle { cursor: pointer; font-size: 16px; line-height: 1; padding: 5px 11px; }

/* Pagination bar — one screenful of games per page, so no endless scrolling. */
.pager { display: flex; align-items: center; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.pager[hidden] { display: none; }
.pager button { background: var(--bg-card); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 5px 11px; font: 600 13px var(--font-ui); cursor: pointer; }
.pager button:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--border-focus); }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pager-info { color: var(--text-dim); font: 600 13px var(--font-ui); margin: 0 6px; }

/* All Games A–Z index bar (replaces the pager in the All Games view) */
.letter-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.letter-bar[hidden] { display: none; }
.letter-bar .ltr {
  min-width: 36px; padding: 6px 10px; border-radius: 8px;
  background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  font: 700 14px var(--font-ui); cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.letter-bar .ltr:hover:not(:disabled) { background: var(--bg-card-hover); border-color: var(--border-focus); }
.letter-bar .ltr.active { background: var(--accent); color: #1a1200; border-color: transparent; }
.letter-bar .ltr:disabled { opacity: 0.28; cursor: default; }

/* Category hover preview flyout (positioned by app.js, to the right of the sidebar).
   Tiles match the main grid's capsule size so the preview looks like the real cards. */
.cat-flyout {
  position: fixed; z-index: 9998; width: auto; max-width: 70vw;
  background: var(--tip-bg, #0c1124); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 18px 48px rgba(0,0,0,.55); padding: 12px;
  font: 500 13px var(--font-ui); animation: cfIn .12s ease;
}
.cat-flyout[hidden] { display: none; }
@keyframes cfIn { from { opacity: 0; transform: translateX(-4px); } to { opacity: 1; transform: none; } }
.cf-head { color: var(--text-dim); font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; padding: 2px 4px 10px; }
.cf-grid { display: grid; grid-template-columns: repeat(2, 200px); gap: 12px; }
.cf-tile { display: block; text-decoration: none; color: var(--text); }
.cf-art { display: block; width: 200px; height: 200px; border-radius: 12px; overflow: hidden;
  background: var(--bg-card); border: 1px solid var(--border);
  transition: transform .12s ease, box-shadow .12s ease; }
.cf-tile:hover .cf-art { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.5); border-color: var(--border-focus); }
.cf-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cf-cap-name { display: block; font: 700 14px var(--font-ui); color: var(--text);
  margin: 7px 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cf-more { color: var(--text-dim); font-size: 11px; padding: 11px 4px 2px; text-align: center; }

/* Floating description tooltip (positioned by app.js; border tint set per category). */
.tile-tip {
  position: fixed; display: none; z-index: 9999;
  max-width: 320px;
  background: var(--tip-bg); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid #7aa2ff;
  border-radius: 10px; padding: 9px 13px;
  font-size: 15.6px; line-height: 1.45;   /* +25% over the old 12.5px */
  /* raised/elevated look so it clearly floats above the hovered tile */
  box-shadow: 0 16px 44px rgba(0,0,0,.62), 0 4px 12px rgba(0,0,0,.45);
  pointer-events: none;
  animation: tipRise .12s ease;
}
@keyframes tipRise { from { opacity: 0; transform: translateY(5px) scale(.97); } to { opacity: 1; transform: none; } }

.empty { text-align: center; color: var(--text-dim); margin-top: 40px; }

/* ── Responsive: stack the sidebar into a scrolling chip row ──────────────── */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  .layout { flex-direction: column; gap: 12px; padding: 8px 12px 20px; max-width: 100%; min-width: 0; }
  /* Sidebar stacks full-width above the games (its sticky/capped-height desktop behaviour is dropped). */
  .sidebar { position: static; width: 100%; max-width: 100%; min-width: 0; flex: none;
    border-right: 0; padding-right: 0; max-height: none; overflow-y: visible; }
  .content { width: 100%; max-width: 100%; min-width: 0; flex: none; }
  /* Categories stay a vertical, full-width list on mobile — the horizontal row overflowed the page. */
  .cat-list { flex-direction: column; overflow-x: visible; gap: 4px; }
  .cat-section-body { grid-template-columns: 1fr; }
  .cat-item { width: 100%; flex: 0 0 auto; }
  .cat-span { grid-column: auto; }
  .top-nav { flex-wrap: wrap; row-gap: 8px; }
  .nav-search { flex: 1 1 100%; margin-left: 0; order: 5; }
  .spotlight-strip, .spotlight-row, .game-grid { max-width: 100%; min-width: 0; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
}
code { background: #1d2742; padding: 2px 6px; border-radius: 6px; }

.site-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 24px 20px 40px;
  border-top: 1px solid var(--border);
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Top nav (injected by nav.js on every portal page) ───────────────────── */
.top-nav {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--nav-bg); position: sticky; top: 0; z-index: 50;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.nav-brand { display: inline-flex; align-items: center; text-decoration: none; }
.nav-logo { height: 36px; width: auto; display: block; }
.nav-links { display: flex; gap: 16px; }
.nav-links a { color: var(--text-dim); text-decoration: none; font-size: 14px; }
.nav-links a:hover { color: var(--text); }
.nav-auth { margin-left: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; }
/* Search lives in the nav between the links and the account area (pushed right via auto). */
.nav-search {
  margin: 0 auto; flex: 0 1 360px; min-width: 130px;
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 7px 12px; font: 14px var(--font-ui);
}
.nav-search:focus { outline: none; border-color: var(--border-focus); }
.nav-name { color: var(--text); text-decoration: none; }
.nav-name:hover { text-decoration: underline; }
.nav-toggle {
  background: none; border: 0; color: var(--text-dim); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.nav-toggle:hover { color: var(--text); }
.nav-cog {
  background: none; border: 0; color: var(--text-dim); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 2px; transition: transform .15s ease, color .12s ease;
}
.nav-cog:hover { color: var(--text); transform: rotate(25deg); }

/* ⚙ Account settings modal */
.settings-backdrop {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(4,7,15,0.6); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.settings-card {
  width: min(380px, 92vw); background: var(--bg-card);
  border: 1px solid var(--border); border-radius: 14px; padding: 22px 22px 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.settings-card h3 { margin: 0 0 14px; font-size: 18px; }
.settings-card label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; font-weight: 600; }
.settings-card input {
  width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 9px 12px; font: 14px var(--font-ui);
}
.settings-card input:focus { outline: none; border-color: var(--border-focus); }
.settings-hint { color: var(--text-dim); font-size: 11.5px; margin: 8px 0 0; line-height: 1.45; }
.settings-row { display: flex; gap: 10px; margin-top: 18px; }

/* Bottom AdSense banner zone — filled by ads.js when a slot id is set; collapses when empty. */
/* Portal AdSense banner: a pinned bottom bar so it stays visible while the catalog scrolls.
   It only appears when an ad actually serves (ads.js adds .ad-live) — no empty bar before then —
   and reserves body space so no tiles hide behind it. `body `-prefixed to outrank ads.js's
   runtime style; this file is cache-busted (ads.js is not), so the styling lives here. */
body .ad-slot[data-ad="portal"] {
  display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  margin: 0; max-width: none; min-height: 90px; padding: 6px 10px;
  align-items: center; justify-content: center; text-align: center;
  background: var(--nav-bg); border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
/* A temporary HOUSE AD shows now (pre-AdSense). When a real AdSense unit renders (ads.js adds
   .ad-live) the house ad is hidden and the <ins> banner takes its place. */
.house-ad {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  justify-content: center; text-decoration: none; color: var(--text); max-width: 970px;
}
.house-ad-badge {
  flex: 0 0 auto; font-weight: 800; letter-spacing: .3px; font-size: 13px;
  background: var(--accent); color: #1a1200; padding: 4px 11px; border-radius: 999px;
}
.house-ad-text { color: var(--text-dim); font-size: 13.5px; }
.house-ad-text b { color: var(--text); }
.house-ad:hover .house-ad-text b { text-decoration: underline; }
body .ad-slot[data-ad="portal"].ad-live .house-ad { display: none; }
/* The bar is always shown now (house ad), so always reserve space for it on the portal home. */
body:has(.ad-slot[data-ad="portal"]) { padding-bottom: 118px; }
.nav-auth a { color: var(--text); text-decoration: none; }

/* ── Generic page + panel ────────────────────────────────────────────────── */
.page { max-width: 760px; margin: 0 auto; padding: 32px 20px 60px; }
.panel h1 { margin-top: 0; }
.muted { color: var(--text-dim); }
.notice { background: #1d2742; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin: 14px 0; font-size: 14px; }
.notice.ok { background: #16331f; border-color: #2f6b3d; color: #cdeccf; }
.divider { text-align: center; color: var(--text-dim); margin: 16px 0; font-size: 13px; }

/* ── Buttons + forms ─────────────────────────────────────────────────────── */
.btn { background: linear-gradient(90deg,#ffd060,#ff9d5c); color: #14110a; border: none;
  border-radius: 10px; padding: 10px 16px; font: 600 14px var(--font-ui);
  cursor: pointer; text-decoration: none; display: inline-block; }
.btn:hover { filter: brightness(1.05); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-provider { width: 100%; background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border); text-align: center; }
.btn-provider:hover { background: var(--bg-card-hover); filter: none; }
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input, select { background: var(--bg-card); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; font: 14px var(--font-ui); }
input:focus, select:focus { outline: none; border-color: var(--border-focus); }

/* ── Plans / billing ─────────────────────────────────────────────────────── */
.tier-row { margin: 8px 0 4px; }
.plans { display: grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px; margin-top: 12px; }
.plan { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; text-align: center; }
.plan-name { font-weight: 700; }
.plan-price { color: var(--text-dim); margin: 6px 0 12px; font-size: 14px; }

/* ── Leaderboards ────────────────────────────────────────────────────────── */
.lb-you { margin: 14px 0 4px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; font-size: 14px; color: var(--text-dim); }
.lb-you b { color: var(--text); }
.lb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 18px; }
@media (max-width: 640px) { .lb-grid { grid-template-columns: 1fr; } }
.lb-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb-table th, .lb-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); }
.lb-table th { color: var(--text-dim); font-weight: 600; }

/* ─────────────────────────────────────────────────────────────────────────
   Steam-style capsule tiles (2026-06-21). Every grid tile is a uniform SQUARE
   capsule: a gameplay screenshot when the game has one (capsule.png via
   capsules.js), else an accent-tinted glyph square so the grid stays uniform.
   List view reverts to a compact row. Search/favorites/pagination unchanged.
   ───────────────────────────────────────────────────────────────────────── */
.grid { gap: 14px; }
.card {
  position: relative; padding: 0; overflow: hidden;
  border-radius: 14px; aspect-ratio: 1 / 1; min-height: 0;
  display: block; background: #11161e; border: 1px solid var(--line, #2a3543);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-4px) scale(1.02); box-shadow: 0 12px 30px rgba(0,0,0,.5); z-index: 5; }
.card.coming-soon:hover { transform: none; box-shadow: none; }

.card-art { position: absolute; inset: 0; }
.card-art .cap-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-art.is-glyph { display: flex; align-items: center; justify-content: center;
  background: #11161e;
  background: radial-gradient(125% 125% at 50% 0%, color-mix(in srgb, var(--cat) 32%, #11161e), #0c1019); }
.card-art.is-glyph .cap-glyph { display: flex; color: var(--cat, #cdd7e3); }
.card-art.is-glyph .tile-icon { width: 44%; height: 44%; opacity: .92; }

.card-scrim { position: absolute; left: 0; right: 0; bottom: 0; height: 62%; pointer-events: none;
  background: linear-gradient(0deg, rgba(5,8,13,.96) 5%, rgba(5,8,13,.5) 45%, rgba(5,8,13,0)); }

.cap-cat { position: absolute; top: 8px; left: 8px; z-index: 2;
  font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; color: #08101a; background: var(--cat, #9aa6c8); }

.card .fav-btn { position: absolute; top: 6px; right: 6px; z-index: 3; }

.card-body { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 10px 12px 11px; display: block; }
.card .card-name { color: #fff; margin: 0; font-size: 16px; font-weight: 800; line-height: 1.18;
  text-shadow: 0 1px 6px rgba(0,0,0,.8); max-height: none; }
.card .card-tagline { display: none; }
.card:hover .card-tagline { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; color: #d6dee8; font-size: 12px; margin: 6px 0 0; }
.card .card-foot { display: none; } /* category already shown as the chip */

/* List view — compact row with a small thumbnail */
html[data-view="list"] .card { aspect-ratio: auto; min-height: 0; display: flex; align-items: center;
  gap: 12px; padding: 8px 12px; border-radius: 10px; background: var(--surface, #161b24); }
html[data-view="list"] .card:hover { transform: none; box-shadow: none; }
html[data-view="list"] .card-art { position: relative; inset: auto; width: 46px; height: 46px;
  flex: 0 0 auto; border-radius: 8px; overflow: hidden; }
html[data-view="list"] .card-art.is-glyph .tile-icon { width: 58%; height: 58%; }
html[data-view="list"] .card-scrim, html[data-view="list"] .cap-cat { display: none; }
html[data-view="list"] .card-body { position: relative; inset: auto; padding: 0; flex: 1 1 auto; min-width: 0; }
html[data-view="list"] .card .card-name { color: var(--text); text-shadow: none; font-size: 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html[data-view="list"] .card .card-tagline { display: block; color: var(--text-dim, #93a1b3); font-size: 12.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 2px 0 0; }
html[data-view="list"] .card .fav-btn { position: relative; top: auto; right: auto; flex: 0 0 auto; }

/* ── In the Spotlight: persistent top strip + admin curation (2026-06-21) ───── */
/* "In the Spotlight" stays PINNED at the top of the games column while the list scrolls under it. */
.spotlight-strip {
  position: sticky; top: 60px; z-index: 6;
  margin: 0 0 14px; padding: 10px 0 12px;
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.spotlight-strip[hidden] { display: none; }
/* On stacked mobile the sidebar becomes a top chip-row, so let the spotlight scroll normally. */
@media (max-width: 900px) { .spotlight-strip { position: static; backdrop-filter: none; -webkit-backdrop-filter: none; } }
.spotlight-head { display: flex; align-items: baseline; gap: 14px; margin: 0 0 12px; }
.spotlight-head h2 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: .3px; }
.spotlight-count { color: var(--text-dim); font-size: 12.5px; }
.spotlight-row { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.spotlight-row::-webkit-scrollbar { height: 8px; }
.spotlight-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.spotlight-row .card { flex: 0 0 auto; width: 188px; height: 188px; aspect-ratio: auto; }

/* ◎ spotlight toggle (admin edit mode) — sits left of the favorite star */
.spot-btn { position: absolute; top: 6px; right: 40px; z-index: 4; width: 30px; height: 30px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.32); background: rgba(8,12,20,.72);
  color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: flex; align-items: center;
  justify-content: center; backdrop-filter: blur(3px); transition: .12s; }
.spot-btn:hover { background: rgba(40,52,70,.92); }
.spot-btn.on { background: var(--accent, #ffd060); color: #1a1200; border-color: transparent; }
.spot-btn.on:hover { filter: brightness(1.06); }

/* Admin "hide game" toggle button (sits left of the spotlight button) */
.hide-btn { position: absolute; top: 6px; right: 74px; z-index: 4; width: 30px; height: 30px;
  border-radius: 50%; border: 1px solid rgba(255,255,255,.32); background: rgba(8,12,20,.72);
  color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: flex; align-items: center;
  justify-content: center; backdrop-filter: blur(3px); transition: .12s; }
.hide-btn:hover { background: rgba(40,52,70,.92); }
.hide-btn.on { background: #e0566a; color: #fff; border-color: transparent; }
.hide-btn.on:hover { filter: brightness(1.06); }
/* When NO spotlight button is showing, the hide button takes the spotlight slot */
html:not([data-spotedit="on"]) .hide-btn { right: 40px; }
/* Admin-only view of a hidden game: dimmed tile + centered HIDDEN ribbon */
.card.is-hidden .card-art { opacity: .45; filter: grayscale(.4); }
.card.is-hidden .card-name { opacity: .6; }
.hidden-ribbon { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 3; background: #e0566a; color: #fff; font-size: 11px; font-weight: 800;
  letter-spacing: 1px; text-transform: uppercase; padding: 3px 10px; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.5); pointer-events: none; }
/* Early Access — a yellow sash that wraps the tile's top-left corner (clipped by .card overflow:hidden) */
.ea-ribbon { position: absolute; top: 0; left: 0; width: 94px; height: 94px; overflow: hidden; z-index: 3; pointer-events: none; }
.ea-ribbon > span { position: absolute; left: -42px; top: 20px; width: 164px; padding: 4px 0;
  transform: rotate(-45deg); text-align: center;
  background: linear-gradient(135deg, #ffe27a 0%, #f5b301 100%); color: #3a2a00;
  font: 800 10px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .6px; text-transform: uppercase;
  border-top: 1px solid rgba(255,255,255,.55); border-bottom: 1px solid rgba(150,100,0,.5);
  box-shadow: 0 2px 8px rgba(0,0,0,.4); }
html[data-view="list"] .ea-ribbon { width: 46px; height: 46px; }
html[data-view="list"] .ea-ribbon > span { left: -50px; top: 8px; font-size: 7px; letter-spacing: .2px; }
.card.is-ea .cap-cat { display: none; }   /* the corner category pill would sit under the ribbon — hide it */
/* Admin EA toggle button — bottom-right so it clears the top-right admin buttons and the corner ribbon */
.ea-btn { position: absolute; bottom: 6px; right: 6px; z-index: 4; width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid var(--line, #2a3543); background: rgba(20,26,36,.82);
  color: #ffd95a; font: 800 11px/1 system-ui, sans-serif; cursor: pointer; }
.ea-btn:hover { background: rgba(40,52,70,.92); }
.ea-btn.on { background: #f5b301; color: #3a2a00; border-color: transparent; }
.ea-btn.on:hover { filter: brightness(1.06); }
.admin-sep { border: none; border-top: 1px solid var(--line, #2a3543); margin: 16px 0 4px; }
/* Admin panel: collapsible sections + a scrollable card so Close is always reachable */
#admin-panel .settings-card { max-height: 86vh; overflow-y: auto; }
.admin-sec { border: 1px solid var(--line, #2a3543); border-radius: 10px; margin: 10px 0; padding: 0 12px;
  background: rgba(255,255,255,.02); }
.admin-sec > summary { cursor: pointer; font-weight: 700; padding: 11px 2px; color: #dbe2f7;
  list-style: none; user-select: none; }
.admin-sec > summary::-webkit-details-marker { display: none; }
.admin-sec > summary::after { content: "▾"; float: right; opacity: .55; transition: transform .15s ease; }
.admin-sec[open] > summary::after { transform: rotate(180deg); }
.admin-sec[open] { padding-bottom: 12px; }

/* Admin tab + panels (reuse the .settings-backdrop/.settings-card/.btn styles from nav) */
#nav-admin { color: var(--accent, #ffd060) !important; font-weight: 700; }
.admin-toggle { display: flex; align-items: center; gap: 9px; font-size: 15px; margin: 8px 0 2px; cursor: pointer; }
.admin-toggle input { width: 16px; height: 16px; }
.swap-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 14px; max-height: 220px; overflow-y: auto; }
.swap-row { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; }
.swap-row:hover { background: var(--pill-bg, rgba(255,255,255,.06)); }

/* Spotlight reorder list (Admin panel) */
.spot-order-wrap { margin: 6px 0 4px; }
.spot-order-title { font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin: 0 0 8px; }
.spot-order-list { display: flex; flex-direction: column; gap: 7px; max-height: 240px; overflow-y: auto; }
.spot-order-row { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 9px; background: var(--pill-bg, rgba(255,255,255,.05)); cursor: grab; user-select: none; }
.spot-order-row.dragging { opacity: .45; cursor: grabbing; }
.spot-grip { color: var(--text-dim); font-size: 16px; line-height: 1; }
.spot-order-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.spot-order-rm { flex: 0 0 auto; border: none; background: transparent; color: var(--text-dim); font-size: 15px;
  cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.spot-order-rm:hover { background: rgba(255,90,90,.16); color: #ff6b6b; }
