/* ==========================================================================
   PlayLite — site chrome & shared UI primitives
   Vanilla CSS, no framework, no build step. Light + dark themes.
   Per-game board styles live in games.css (loaded on game pages only).
   ========================================================================== */

/* ---------------------------------------------------------------- tokens */
:root {
  /* neutrals — cool grey scale */
  --bg:        #f6f7fb;
  --bg-soft:   #edeff6;
  --card:      #ffffff;
  --card-2:    #f7f8fc;
  --card-3:    #f1f3f9;
  --text:      #141824;
  --text-2:    #39405a;
  --muted:     #656e88;
  --line:      #e4e7f0;
  --line-2:    #d6dae7;

  /* brand */
  --brand:      #5b53e0;
  --brand-2:    #8b5cf6;
  --brand-3:    #c084fc;
  --brand-ink:  #ffffff;
  --brand-soft: #eeecfd;
  --accent:     #f59e0b;
  --good:       #16a34a;
  --bad:        #dc2626;

  /* category hues */
  --c-puzzle:  #6366f1;
  --c-arcade:  #f43f5e;
  --c-brain:   #0ea5e9;
  --c-casual:  #f59e0b;
  --c-skill:   #10b981;
  --c-card:    #a855f7;

  /* shape */
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;

  /* elevation */
  --sh-1: 0 1px 2px rgba(16, 20, 40, .05);
  --sh-2: 0 1px 2px rgba(16, 20, 40, .05), 0 6px 16px -8px rgba(16, 20, 40, .14);
  --sh-3: 0 2px 4px rgba(16, 20, 40, .06), 0 14px 32px -12px rgba(16, 20, 40, .22);
  --sh-4: 0 4px 8px rgba(16, 20, 40, .07), 0 24px 56px -16px rgba(16, 20, 40, .30);

  --header-h: 62px;
  --maxw: 1140px;
  --measure: 68ch;

  /* back-compat aliases: games written against the earlier token names.
     These resolve at use time, so themed values still follow the theme. */
  --radius: var(--r);
  --radius-sm: var(--r-sm);
  --shadow: var(--sh-2);

  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

html[data-theme="dark"] {
  --bg:        #0e1017;
  --bg-soft:   #151823;
  --card:      #191d29;
  --card-2:    #1f2430;
  --card-3:    #262b3a;
  --text:      #eceef6;
  --text-2:    #c3c9db;
  --muted:     #8b93ad;
  --line:      #272d3d;
  --line-2:    #333a4d;

  --brand:      #8b84f5;
  --brand-2:    #a78bfa;
  --brand-3:    #c4b5fd;
  --brand-soft: #221f45;

  --sh-1: 0 1px 2px rgba(0, 0, 0, .40);
  --sh-2: 0 1px 2px rgba(0, 0, 0, .40), 0 6px 16px -8px rgba(0, 0, 0, .55);
  --sh-3: 0 2px 4px rgba(0, 0, 0, .45), 0 14px 32px -12px rgba(0, 0, 0, .65);
  --sh-4: 0 4px 8px rgba(0, 0, 0, .5), 0 24px 56px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  overflow-x: clip;
  font-family: "Inter var", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv11", "ss01";
}

img, svg { max-width: 100%; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 2px; }

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

::selection { background: var(--brand-soft); color: var(--text); }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  html { scroll-behavior: auto; }
}

/* ---------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 60;
  height: var(--header-h);
  background: color-mix(in srgb, var(--card) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.site-header .container { height: 100%; display: flex; align-items: center; gap: 10px; }

.brand {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px;
  font-weight: 800; font-size: 1.08rem; color: var(--text);
  letter-spacing: -.02em; white-space: nowrap; flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center;
  box-shadow: var(--sh-2);
}
.brand .logo svg { width: 19px; height: 19px; display: block; }

.head-nav { display: flex; gap: 2px; margin-left: 14px; }
.head-nav a {
  padding: 7px 12px; border-radius: 999px;
  font-size: .88rem; font-weight: 600; color: var(--muted);
  transition: color .15s var(--ease), background .15s var(--ease);
}
.head-nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.head-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }

.head-spacer { flex: 1 1 auto; }

.head-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 12px; flex-shrink: 0;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); color: var(--text-2);
  font-size: .84rem; font-weight: 700; cursor: pointer;
  font-family: inherit;
  transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}
.head-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.head-btn.icon { width: 44px; padding: 0; }
.head-btn.icon svg { width: 19px; height: 19px; display: block; }

.lang-switch {
  display: inline-flex; flex-shrink: 0; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.lang-switch a {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; min-height: 36px; padding: 0 9px; border-radius: 999px;
  color: var(--muted); font-size: .78rem; font-weight: 750;
}
.lang-switch a:hover { color: var(--text); text-decoration: none; }
.lang-switch a[aria-current="true"] { color: #fff; background: var(--brand); }

/* header search */
.head-search { position: relative; margin-left: auto; max-width: 240px; flex: 1 1 140px; }
.head-search input {
  width: 100%; height: 44px; padding: 0 32px 0 38px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--card-2); color: var(--text);
  font-family: inherit; font-size: .87rem;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.head-search input::placeholder { color: var(--muted); }
.head-search input:focus {
  outline: none; border-color: var(--brand); background: var(--card);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.head-search .s-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}
.head-search kbd.hint {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-size: .68rem; padding: 1px 5px; pointer-events: none; opacity: .7;
}
.head-search input:focus ~ kbd.hint { display: none; }
@media (max-width: 720px) {
  .site-header { height: auto; }
  .site-header .container {
    min-height: 112px; padding: 0 12px 10px;
    display: grid; grid-template-columns: auto 1fr auto auto;
    grid-template-rows: 58px 44px; gap: 0 8px;
  }
  .brand { grid-column: 1; grid-row: 1; }
  .brand > span:last-child { display: none; }
  .head-nav { grid-column: 2; grid-row: 1; margin-left: 0; gap: 0; min-width: 0; }
  .head-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; font-size: .82rem; }
  .head-nav a.hide-sm { display: none; }
  .lang-switch { grid-column: 3; grid-row: 1; }
  .head-btn.icon { grid-column: 4; grid-row: 1; }
  .head-search { grid-column: 1 / -1; grid-row: 2; width: 100%; max-width: none; margin: 0; }
  .head-search kbd.hint { display: none; }
}
@media (max-width: 400px) {
  .site-header .container { gap: 0 5px; padding-inline: 10px; }
  .brand { min-width: 44px; justify-content: center; }
  .head-nav a { min-width: 44px; justify-content: center; padding-inline: 6px; font-size: .78rem; }
  .lang-switch a { min-width: 44px; min-height: 44px; padding-inline: 6px; }
}

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative; text-align: center;
  padding: 60px 0 26px;
  isolation: isolate;
  overflow: hidden;
}
.hero::before,
.hero::after {
  content: ""; position: absolute; z-index: -1; border-radius: 50%;
  filter: blur(64px); opacity: .40; pointer-events: none;
}
.hero::before {
  width: 460px; height: 320px; top: -40px; left: 50%;
  transform: translateX(-72%);
  background: radial-gradient(circle, var(--brand) 0%, transparent 70%);
}
.hero::after {
  width: 420px; height: 300px; top: 10px; left: 50%;
  transform: translateX(-8%);
  background: radial-gradient(circle, var(--brand-3) 0%, transparent 70%);
}
html[data-theme="dark"] .hero::before,
html[data-theme="dark"] .hero::after { opacity: .30; }

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(1.85rem, 5.2vw, 3.05rem);
  font-weight: 800; letter-spacing: -.035em; line-height: 1.1;
  text-wrap: balance;
}
.hero h1 .grad {
  background: linear-gradient(100deg, var(--brand) 0%, var(--brand-2) 45%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p {
  margin: 0 auto; max-width: 56ch;
  color: var(--muted); font-size: clamp(.98rem, 2.2vw, 1.1rem);
  text-wrap: pretty;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: 8px 22px; justify-content: center;
  margin-top: 20px; font-size: .84rem; font-weight: 600; color: var(--muted);
}
.hero-meta span { display: inline-flex; align-items: center; gap: 6px; }
.hero-meta .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--good); }

/* ---------------------------------------------------------------- category pills */
.cats {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
  padding: 26px 0 4px;
}
.cat-pill {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  min-height: 44px; border-radius: 999px; padding: 8px 16px;
  font-size: .88rem; font-weight: 650; cursor: pointer; font-family: inherit;
  transition: border-color .16s var(--ease), color .16s var(--ease),
              background .16s var(--ease), transform .1s var(--ease);
  box-shadow: var(--sh-1);
}
.cat-pill .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--hue, var(--brand)); }
.cat-pill:hover { border-color: var(--hue, var(--brand)); color: var(--text); text-decoration: none; transform: translateY(-1px); }
.cat-pill.active {
  background: var(--hue, var(--brand)); border-color: var(--hue, var(--brand)); color: #fff;
}
.cat-pill.active .swatch { background: rgba(255, 255, 255, .85); }
.cat-pill[data-cat="puzzle"] { --hue: var(--c-puzzle); }
.cat-pill[data-cat="arcade"] { --hue: var(--c-arcade); }
.cat-pill[data-cat="brain"]  { --hue: var(--c-brain); }
.cat-pill[data-cat="casual"] { --hue: var(--c-casual); }
.cat-pill[data-cat="skill"]  { --hue: var(--c-skill); }
.cat-pill[data-cat="card"]   { --hue: var(--c-card); }

/* ---------------------------------------------------------------- section heads */
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; margin: 40px 0 14px;
}
.sec-head h2 {
  margin: 0; font-size: clamp(1.15rem, 2.6vw, 1.4rem);
  font-weight: 750; letter-spacing: -.02em;
}
.sec-head .sub { color: var(--muted); font-size: .88rem; font-weight: 500; }
.sec-head a.more { font-size: .87rem; font-weight: 650; white-space: nowrap; }

/* ---------------------------------------------------------------- game grid */
.games-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
}
.games-grid.featured { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }

.game-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--sh-2);
  transition: transform .22s var(--ease-out), box-shadow .22s var(--ease-out),
              border-color .22s var(--ease);
  /* skip layout/paint for the cards below the fold — the home page carries
     30 of them, and this keeps first render cheap without lazy-loading hacks */
  content-visibility: auto;
  contain-intrinsic-size: auto 260px;
}

.game-card[hidden] {
  display: none !important;
}
.game-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-4);
  border-color: color-mix(in srgb, var(--hue, var(--brand)) 45%, var(--line));
  text-decoration: none;
}
.game-card:active { transform: translateY(-1px); }

.game-card .shot {
  position: relative; aspect-ratio: 16 / 10; overflow: hidden;
  background: var(--bg-soft);
}
.game-card .shot .thumb {
  width: 100%; height: 100%; display: block;
  transition: transform .35s var(--ease-out);
}
.game-card:hover .shot .thumb { transform: scale(1.055); }

.game-card .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(10, 12, 24, .34);
  opacity: 0; transition: opacity .2s var(--ease);
}
.game-card:hover .play, .game-card:focus-visible .play { opacity: 1; }
.game-card .play span {
  display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255, 255, 255, .95); color: #16192b;
  font-size: 15px; padding-left: 3px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  transform: scale(.82); transition: transform .24s var(--ease-out);
}
.game-card:hover .play span { transform: scale(1); }

.game-card .body {
  padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1;
}
.game-card .name {
  font-weight: 700; font-size: .98rem; line-height: 1.3; letter-spacing: -.01em;
}
.games-grid.featured .game-card .name { font-size: 1.06rem; }
.game-card .line {
  color: var(--muted); font-size: .82rem; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.game-card .tag {
  align-self: flex-start; margin-top: auto;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .78rem; font-weight: 700; letter-spacing: .01em;
  color: var(--hue, var(--brand));
  background: color-mix(in srgb, var(--hue, var(--brand)) 12%, transparent);
  border-radius: 999px; padding: 3px 10px;
}
.game-card[data-cat="puzzle"] { --hue: var(--c-puzzle); }
.game-card[data-cat="arcade"] { --hue: var(--c-arcade); }
.game-card[data-cat="brain"]  { --hue: var(--c-brain); }
.game-card[data-cat="casual"] { --hue: var(--c-casual); }
.game-card[data-cat="skill"]  { --hue: var(--c-skill); }
.game-card[data-cat="card"]   { --hue: var(--c-card); }

/* compact card (sidebars / related) */
.games-grid.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.games-grid.compact .game-card .body { padding: 10px 12px 12px; }
.games-grid.compact .game-card .line { display: none; }

.no-results {
  text-align: center; padding: 44px 20px; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: var(--r-lg);
}
.no-results strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: 4px; }

/* ---------------------------------------------------------------- guide cards */
.guide-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); }
.guide-card {
  display: flex; gap: 13px; align-items: flex-start;
  padding: 16px; background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--sh-1);
  transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out), border-color .18s var(--ease);
}
.guide-card:hover {
  transform: translateY(-2px); box-shadow: var(--sh-3);
  border-color: var(--brand); text-decoration: none;
}
.guide-card .ico {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 11px;
  display: grid; place-items: center; font-size: 20px;
  background: var(--brand-soft); border: 1px solid var(--line);
}
.guide-card .gt { font-weight: 700; font-size: .95rem; line-height: 1.35; letter-spacing: -.01em; }
.guide-card .gd {
  color: var(--muted); font-size: .82rem; margin-top: 3px; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ---------------------------------------------------------------- info panel */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 26px 28px;
  box-shadow: var(--sh-1);
}
.panel h2 { margin: 0 0 10px; font-size: 1.14rem; font-weight: 750; letter-spacing: -.02em; }
.panel p { margin: 10px 0; color: var(--text-2); font-size: .95rem; }
.panel p:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------------- game page */
.game-head { text-align: center; padding: 30px 0 4px; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }
.crumbs .sep { opacity: .5; margin: 0 5px; }

.game-head h1 {
  margin: 0; font-size: clamp(1.5rem, 4vw, 2.15rem);
  font-weight: 800; letter-spacing: -.03em; line-height: 1.15;
  display: inline-flex; align-items: center; gap: 12px;
}
.game-head h1 .gi {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 24px;
  background: var(--brand-soft); border: 1px solid var(--line);
}
.game-head .tagline {
  color: var(--muted); margin: 10px auto 0; max-width: 60ch;
  font-size: 1rem; text-wrap: pretty;
}

.game-shell { max-width: 900px; margin: 0 auto; }

.game-frame {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--sh-3);
  padding: 22px 20px; margin: 22px auto;
}
@media (max-width: 560px) { .game-frame { padding: 16px 10px; border-radius: var(--r-lg); } }

#game { display: flex; flex-direction: column; align-items: center; gap: 13px; touch-action: manipulation; }
#game canvas { max-width: 100%; border-radius: var(--r-sm); background: var(--bg-soft); display: block; }

/* stat bar */
.stat-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.stat {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 7px 17px; text-align: center; min-width: 86px;
}
.stat .label {
  font-size: .76rem; font-weight: 750; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); white-space: nowrap;
}
.stat .value {
  font-size: 1.24rem; font-weight: 800; font-variant-numeric: tabular-nums;
  line-height: 1.25; letter-spacing: -.02em;
}

.game-toolbar { display: flex; flex-wrap: wrap; gap: 9px; justify-content: center; align-items: center; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--r-sm); cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: .91rem; padding: 10px 19px;
  background: linear-gradient(180deg, var(--brand), color-mix(in srgb, var(--brand) 84%, #000));
  color: var(--brand-ink);
  box-shadow: var(--sh-1);
  transition: filter .15s var(--ease), transform .07s var(--ease), box-shadow .15s var(--ease);
}
.btn:hover { filter: brightness(1.09); text-decoration: none; box-shadow: var(--sh-2); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.secondary {
  background: var(--card-2); color: var(--text); border-color: var(--line-2);
}
.btn.secondary:hover { border-color: var(--brand); color: var(--brand); filter: none; }
.btn.small { padding: 7px 13px; font-size: .83rem; }
.btn.large { padding: 13px 26px; font-size: 1rem; }
.btn[disabled] { opacity: .48; cursor: not-allowed; transform: none; filter: none; }

/* segmented control */
.seg {
  display: inline-flex; background: var(--card-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
}
.seg button {
  border: none; background: transparent; color: var(--muted); font-weight: 700;
  padding: 8px 15px; cursor: pointer; font-size: .85rem; font-family: inherit;
  transition: color .13s var(--ease), background .13s var(--ease);
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--brand); color: var(--brand-ink); }

.hint-bar { text-align: center; color: var(--muted); font-size: .85rem; }
kbd {
  background: var(--card-2); border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 5px; padding: 1.5px 6px; font-size: .78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text-2);
}

/* overlay */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; text-align: center;
}
.overlay.show { display: flex; animation: ovIn .22s var(--ease-out); }
@keyframes ovIn { from { opacity: 0; } to { opacity: 1; } }
.overlay .panel {
  padding: 24px; background: none; border: none; box-shadow: none;
  animation: ovUp .28s var(--ease-out);
}
@keyframes ovUp { from { transform: translateY(10px) scale(.97); } to { transform: none; } }
.overlay .big {
  font-size: clamp(1.4rem, 4vw, 1.75rem); font-weight: 800;
  letter-spacing: -.025em; margin-bottom: 7px;
}
.overlay .sub { color: var(--muted); margin-bottom: 18px; font-size: .95rem; }

/* generic board container */
.board { display: grid; gap: 5px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }

/* on-screen d-pad */
.dpad {
  display: grid; grid-template-columns: repeat(3, 54px); grid-auto-rows: 54px; gap: 6px;
  justify-content: center; user-select: none;
}
.dpad button {
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--card-2);
  font-size: 19px; cursor: pointer; color: var(--text-2); font-family: inherit;
}
.dpad button:active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.dpad .blank { visibility: hidden; }
@media (min-width: 760px) { .dpad.desktop-hide { display: none; } }

/* on-screen keyboard (word games) */
.kb { display: flex; flex-direction: column; gap: 6px; align-items: center; width: 100%; }
.kb-row { display: flex; gap: 5px; justify-content: center; width: 100%; }
.kb-key {
  flex: 1; max-width: 42px; height: 50px; border: none; border-radius: 8px;
  background: var(--card-3); color: var(--text); font-weight: 700; font-size: .95rem;
  cursor: pointer; text-transform: uppercase; font-family: inherit;
  display: flex; align-items: center; justify-content: center;
  transition: background .14s var(--ease), color .14s var(--ease), transform .06s var(--ease);
}
.kb-key:active { transform: scale(.94); }
.kb-key.wide { max-width: 66px; flex: 1.6; font-size: .72rem; }
.kb-key.correct { background: var(--good); color: #fff; }
.kb-key.present { background: var(--accent); color: #fff; }
.kb-key.absent { background: var(--muted); color: var(--card); opacity: .5; }

/* ---------------------------------------------------------------- prose */
.prose {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px 34px; box-shadow: var(--sh-1);
  font-size: 1rem; color: var(--text-2);
}
@media (max-width: 560px) { .prose { padding: 22px 18px; } }

.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h1 {
  font-size: clamp(1.55rem, 4vw, 2.05rem); font-weight: 800;
  letter-spacing: -.03em; line-height: 1.18; color: var(--text);
  margin: 0 0 14px; text-wrap: balance;
}
.prose h2 {
  font-size: clamp(1.1rem, 2.7vw, 1.3rem); font-weight: 750;
  letter-spacing: -.02em; color: var(--text);
  margin: 30px 0 10px; scroll-margin-top: calc(var(--header-h) + 16px);
}
.prose h3 { font-size: 1.02rem; font-weight: 700; color: var(--text); margin: 22px 0 6px; }
.prose p { margin: 12px 0; max-width: var(--measure); text-wrap: pretty; }
.prose .lead { font-size: 1.06rem; color: var(--text); }
.prose ul, .prose ol { margin: 12px 0; padding-left: 24px; max-width: var(--measure); }
.prose li { margin: 7px 0; }
.prose li::marker { color: var(--brand); font-weight: 700; }
.prose strong { color: var(--text); font-weight: 700; }
.prose hr { border: none; border-top: 1px solid var(--line); margin: 28px 0; }

/* accordion FAQ */
.prose details {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 0; margin: 9px 0; background: var(--card-2);
  overflow: hidden; transition: border-color .16s var(--ease);
}
.prose details[open] { border-color: var(--line-2); }
.prose details:hover { border-color: var(--brand); }
.prose summary {
  font-weight: 700; cursor: pointer; color: var(--text);
  padding: 13px 17px; list-style: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.prose summary::-webkit-details-marker { display: none; }
.prose summary::after {
  content: "+"; font-size: 1.2rem; font-weight: 400; color: var(--muted);
  flex-shrink: 0; transition: transform .2s var(--ease);
}
.prose details[open] summary::after { transform: rotate(45deg); }
.prose details > p { margin: 0 17px 15px; color: var(--muted); }

/* callout */
.callout {
  border-left: 3px solid var(--brand); background: var(--brand-soft);
  border-radius: 0 var(--r) var(--r) 0; padding: 14px 18px; margin: 18px 0;
}
.callout p { margin: 0; color: var(--text-2); }

/* ---------------------------------------------------------------- article */
.article-head { padding: 34px 0 0; max-width: 760px; margin: 0 auto; }
.article-head .crumbs { margin-bottom: 14px; }
.article-head h1 {
  font-size: clamp(1.7rem, 4.6vw, 2.5rem); font-weight: 800;
  letter-spacing: -.035em; line-height: 1.14; margin: 0; text-wrap: balance;
}
.article-head .kicker {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 12px;
  font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .07em;
  color: var(--brand);
}
.article-body { max-width: 760px; margin: 0 auto; }
.article-body .prose { font-size: 1.04rem; line-height: 1.75; }

/* ---------------------------------------------------------------- page body */
.page-body { max-width: 780px; margin: 0 auto; padding: 34px 0 10px; }

/* ---------------------------------------------------------------- ads */
/* Reserve the slot height up front. Without this, an ad arriving after paint
   shoves the page down — that is a Core Web Vitals (CLS) hit and it makes
   people mis-tap, which is exactly what you don't want next to an ad. */
.ad-container {
  margin: 26px auto; text-align: center; overflow: hidden;
  min-height: 280px;
  display: flex; align-items: center; justify-content: center;
}
@media (min-width: 768px) { .ad-container { min-height: 280px; } }
@media (max-width: 480px) { .ad-container { min-height: 250px; } }
.adsbygoogle { display: block; width: 100%; }
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
/* placeholder IDs, or an unfilled slot: collapse entirely, reserve nothing */
.ad-container.ad-disabled { display: none; min-height: 0; }

/* ---------------------------------------------------------------- footer */
.site-footer {
  border-top: 1px solid var(--line); margin-top: 56px;
  background: var(--card);
}
.footer-top {
  display: grid; gap: 28px 24px;
  /* explicit tracks: repeat(auto-fit,…) resolves to a single repetition when
     another flexible track is present, which silently collapsed this to one
     column on every page */
  grid-template-columns: 1.6fr 1fr 1fr 1fr 1fr;
  padding: 40px 20px 30px;
  max-width: var(--maxw); margin: 0 auto;
}
@media (max-width: 980px) {
  .footer-top { grid-template-columns: repeat(3, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .footer-top { grid-template-columns: repeat(2, 1fr); padding: 32px 18px 24px; }
}
.footer-brand .brand { margin-bottom: 10px; }
.footer-brand p { color: var(--muted); font-size: .87rem; margin: 0; max-width: 34ch; }
.footer-col h3 {
  font-size: .75rem; font-weight: 750; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text); margin: 0 0 11px;
}
.footer-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.footer-col a { color: var(--muted); font-size: .86rem; }
.footer-col a:hover { color: var(--brand); }
.footer-bot {
  border-top: 1px solid var(--line);
  padding: 16px 20px; max-width: var(--maxw); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  align-items: center; justify-content: space-between;
  font-size: .82rem; color: var(--muted);
}
.footer-bot nav { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.footer-bot a { color: var(--muted); }
.footer-bot a:hover { color: var(--brand); }

/* ---------------------------------------------------------------- lang splash */
.lang-splash {
  min-height: 100svh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
  text-align: center; padding: 24px; position: relative; isolation: isolate; overflow: hidden;
}
.lang-splash::before {
  content: ""; position: absolute; z-index: -1; inset: -20%;
  background: radial-gradient(circle at 30% 30%, var(--brand) 0%, transparent 45%),
              radial-gradient(circle at 70% 65%, var(--brand-3) 0%, transparent 45%);
  filter: blur(80px); opacity: .32;
}
.lang-splash .logo-big {
  width: 88px; height: 88px; border-radius: 26px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; box-shadow: var(--sh-4);
}
.lang-splash .logo-big svg { width: 48px; height: 48px; }
.lang-splash h1 {
  margin: 0; font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 800; letter-spacing: -.03em;
}
.lang-splash .lang-buttons { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.lang-splash .btn { min-width: 168px; }

/* ---------------------------------------------------------------- utilities */
.center { text-align: center; }
.muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.stack-lg > * + * { margin-top: 34px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
