/* ==========================================================================
   Digital Hub - design system for the Home and Tools pages
   ========================================================================== */

:root {
  --brand: #4c6ef5;
  --brand-2: #15aabf;
  --grad: linear-gradient(135deg, #4c6ef5 0%, #15aabf 100%);

  --bg: #f6f7fb;
  --bg-alt: #eef1f8;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e4e8f1;
  --line-2: #d3d9e8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 2px 8px rgba(15, 23, 42, .04);
  --shadow-md: 0 10px 30px rgba(30, 41, 90, .10);
  --shadow-lg: 0 24px 60px rgba(30, 41, 90, .16);
  --header-bg: rgba(255, 255, 255, .78);
  --radius: 16px;
  --radius-lg: 22px;
  --header-h: 68px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0b1020;
  --bg-alt: #0f1630;
  --surface: #131a35;
  --ink: #eef1fb;
  --ink-2: #c3cbe3;
  --muted: #8f9bbd;
  --line: #222c52;
  --line-2: #2d3965;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, .35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .5);
  --header-bg: rgba(11, 16, 32, .78);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 76px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.6;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 8px; }

.wrap { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }
.skip { position: fixed; left: 12px; top: -60px; z-index: 200; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; transition: top .2s; }
.skip:focus { top: 12px; }
kbd {
  font: 600 11px/1 var(--font); padding: 4px 6px; border-radius: 6px;
  background: var(--bg-alt); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; font-size: 15px; line-height: 1.2; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .2s, background .2s, border-color .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(76, 110, 245, .35); }
.btn-primary:hover { box-shadow: 0 12px 28px rgba(76, 110, 245, .45); }
.btn-soft { background: color-mix(in srgb, var(--brand) 10%, var(--surface)); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 22%, transparent); }
:root[data-theme="dark"] .btn-soft { color: #9db0ff; }
.btn-light { background: #fff; color: #1b2a6b; box-shadow: 0 8px 22px rgba(0, 0, 0, .18); }
.btn-ghost-light { background: rgba(255, 255, 255, .12); color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .22); }
.btn-sm { padding: 9px 14px; font-size: 14px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  transition: background .2s, border-color .2s, color .2s, transform .2s var(--ease);
}
.icon-btn:hover { border-color: var(--line-2); color: var(--brand); transform: translateY(-1px); }
.icon-btn.is-on { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100; height: var(--header-h);
  background: var(--header-bg); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid transparent; transition: border-color .2s, box-shadow .2s;
}
.site-header.scrolled { border-color: var(--line); box-shadow: 0 6px 24px rgba(15, 23, 42, .06); }
.bar { height: 100%; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--grad); color: #fff; font-size: 17px; box-shadow: 0 6px 16px rgba(76, 110, 245, .4); }
.nav { display: flex; align-items: center; gap: 4px; margin-left: 12px; }
.nav a { padding: 8px 14px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--ink-2); transition: background .2s, color .2s; }
.nav a:hover { background: var(--bg-alt); color: var(--ink); }
.nav a.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 11%, transparent); }
:root[data-theme="dark"] .nav a.active { color: #9db0ff; }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-btn {
  display: inline-flex; align-items: center; gap: 10px; height: 42px; padding: 0 12px 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--muted); font-weight: 500; font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}
.search-btn:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.burger { display: none; }

/* ---------- Hero ---------- */
.hero, .page-head { position: relative; overflow: hidden; }
.hero-bg {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 480px at 85% -10%, color-mix(in srgb, var(--brand) 26%, transparent), transparent 70%),
    radial-gradient(700px 420px at 0% 10%, color-mix(in srgb, var(--brand-2) 22%, transparent), transparent 70%);
}
.hero-bg::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 44px 44px; opacity: .5;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%); mask-image: radial-gradient(ellipse at 50% 0%, #000 0%, transparent 72%);
}
.hero { padding: clamp(40px, 7vw, 84px) 0 0; }
.hero-grid { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px; align-items: center; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  color: var(--brand); font-weight: 700; font-size: 13px;
}
:root[data-theme="dark"] .eyebrow { color: #9db0ff; }
h1 { font-size: clamp(2.1rem, 5.2vw, 3.7rem); line-height: 1.07; letter-spacing: -.035em; font-weight: 800; margin: 18px 0 16px; text-wrap: balance; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.lead { font-size: clamp(1rem, 1.6vw, 1.15rem); color: var(--muted); max-width: 58ch; }

/* Search box (shared by home and tools) */
.searchbox {
  position: relative; display: flex; align-items: center; gap: 10px; margin-top: 28px; max-width: 640px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 8px 8px 8px 18px;
  box-shadow: var(--shadow-md); transition: border-color .2s, box-shadow .2s;
}
.searchbox:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent), var(--shadow-md); }
.searchbox > i { color: var(--muted); font-size: 18px; }
.searchbox input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 16px; padding: 10px 0; }
.searchbox input::placeholder { color: var(--muted); opacity: .85; }
.searchbox input::-webkit-search-cancel-button { display: none; }
.kbd-hint { margin-right: 8px; }

.chips-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 18px; font-size: 14px; color: var(--muted); }
.chip { padding: 6px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; color: var(--ink-2); transition: border-color .2s, color .2s, transform .2s var(--ease); }
.chip:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }

/* Search results list (suggestions and palette) */
.results { display: flex; flex-direction: column; gap: 2px; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 10px); z-index: 30; padding: 8px; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.res { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; }
.res:hover, .res.is-active { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.res-ico { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-size: 18px;
  background: color-mix(in srgb, var(--c, var(--brand)) 14%, transparent); color: var(--c, var(--brand)); }
.res-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.res-main b { font-weight: 700; font-size: 15px; }
.res-main small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res-cat { flex: none; font-size: 12px; font-weight: 600; color: var(--muted); padding: 3px 9px; border-radius: 999px; background: var(--bg-alt); }
.res-empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 14px; }
.res-label { padding: 8px 12px 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
mark { background: color-mix(in srgb, var(--brand) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* Hero visual */
.hero-visual { position: relative; height: 380px; }
.float { position: absolute; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 16px; animation: bob 7s ease-in-out infinite; }
.f1 { top: 20px; left: 4%; width: 250px; }
.f2 { top: 190px; right: 2%; width: 200px; animation-delay: -2.5s; }
.f3 { top: 0; right: 14%; width: 66px; height: 66px; display: grid; place-items: center; font-size: 30px; color: var(--brand-2); animation-delay: -4s; }
.f4 { bottom: 10px; left: 10%; display: flex; align-items: center; gap: 10px; padding: 12px 18px; font-size: 22px; color: #f76707; animation-delay: -1.2s; }
.f4 b { font-size: 15px; color: var(--ink); }
.f5 { bottom: 40px; right: 24%; width: 58px; height: 58px; display: grid; place-items: center; font-size: 28px; border-radius: 18px; animation-delay: -5s; }
.f-head { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.f-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand); }
.f-ico.c2 { background: color-mix(in srgb, #12b886 16%, transparent); color: #12b886; }
.f-big { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin: 14px 0 10px; }
.f-big small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.f-bar { height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--brand-2) 28%, transparent); overflow: hidden; }
.f-bar i { display: block; height: 100%; border-radius: 99px; background: var(--grad); }
.f-row { display: flex; justify-content: space-between; margin-top: 8px; font-size: 12px; color: var(--muted); font-weight: 600; }
.spark { width: 100%; height: 56px; margin-top: 10px; }
.spark path { fill: none; stroke: #12b886; stroke-width: 3; stroke-linecap: round; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* Stats */
.stats {
  position: relative; z-index: 2; display: grid; grid-template-columns: repeat(4, 1fr); margin-top: clamp(36px, 6vw, 64px); margin-bottom: -1px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden;
}
.stats li { padding: 22px 20px; text-align: center; border-left: 1px solid var(--line); }
.stats li:first-child { border-left: 0; }
.stats b { display: block; font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; letter-spacing: -.03em; background: var(--grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; line-height: 1.2; }
.stats span { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- Sections ---------- */
.sec { padding: clamp(48px, 7vw, 84px) 0; }
.sec.tight { padding-top: 24px; }
.sec.alt { background: var(--bg-alt); border-block: 1px solid var(--line); }
.hero + .sec { padding-top: clamp(56px, 8vw, 96px); }
.sec-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.kicker { display: block; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
:root[data-theme="dark"] .kicker { color: #9db0ff; }
h2 { font-size: clamp(1.45rem, 3vw, 2.1rem); line-height: 1.2; letter-spacing: -.025em; font-weight: 800; }
.more { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; color: var(--brand); white-space: nowrap; }
:root[data-theme="dark"] .more { color: #9db0ff; }
.more i { transition: transform .2s var(--ease); }
.more:hover i { transform: translateX(4px); }

.grid { display: grid; gap: 16px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- Icon tile ---------- */
.ico {
  flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; font-size: 22px;
  background: color-mix(in srgb, var(--c, var(--brand)) 13%, transparent); color: var(--c, var(--brand));
  transition: transform .3s var(--ease), background .3s, color .3s;
}
.ico-emoji { font-size: 24px; }

/* ---------- Tool / game card ---------- */
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--c, var(--brand)) 45%, var(--line)); }
.card:hover .ico { background: var(--c, var(--brand)); color: #fff; transform: scale(1.06) rotate(-4deg); }
.card-link { display: flex; align-items: flex-start; gap: 14px; height: 100%; padding: 18px 44px 18px 18px; border-radius: inherit; }
.card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.card-title { font-weight: 700; font-size: 16px; line-height: 1.3; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card-desc { font-size: 14px; line-height: 1.5; color: var(--muted); }
.go { position: absolute; right: 16px; bottom: 16px; font-size: 14px; color: var(--muted); opacity: 0; transform: translate(-4px, 4px); transition: opacity .2s, transform .2s var(--ease), color .2s; }
.card:hover .go { opacity: 1; transform: none; color: var(--c, var(--brand)); }
.fav {
  position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px;
  background: transparent; border: 0; color: var(--muted); font-size: 15px; opacity: .55; transition: opacity .2s, color .2s, background .2s, transform .2s var(--ease);
}
.card:hover .fav, .fav:focus-visible, .fav[aria-pressed="true"] { opacity: 1; }
.fav:hover { background: var(--bg-alt); color: #f59f00; transform: scale(1.12); }
.fav[aria-pressed="true"] { color: #f59f00; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; color: var(--muted); background: var(--bg-alt); border: 1px solid var(--line); }

/* ---------- Category tile (home) ---------- */
.cat {
  position: relative; display: flex; align-items: center; gap: 16px; padding: 20px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
}
.cat:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.cat:hover .ico { background: var(--c); color: #fff; transform: scale(1.06) rotate(-4deg); }
.cat .ico { width: 56px; height: 56px; font-size: 26px; border-radius: 16px; }
.cat-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cat-name { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.cat-desc { font-size: 14px; color: var(--muted); line-height: 1.45; margin-top: 2px; }
.cat-count { position: absolute; top: 14px; right: 16px; font-size: 12px; font-weight: 700; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); padding: 3px 10px; border-radius: 999px; }
.cat .cat-body { padding-top: 14px; }

/* ---------- Games (home) ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.game {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px 16px 16px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--surface) 88%, #f03e3e) 0%, var(--surface) 70%);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s, border-color .25s;
}
.game:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: color-mix(in srgb, #f03e3e 40%, var(--line)); }
.game-emoji { font-size: 38px; line-height: 1; margin-bottom: 8px; transition: transform .3s var(--ease); }
.game:hover .game-emoji { transform: scale(1.18) rotate(-6deg); }
.game-name { font-weight: 700; font-size: 15px; line-height: 1.3; }

/* ---------- Why / CTA ---------- */
.why { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.why .ico { margin-bottom: 16px; }
.why h3 { font-size: 17px; font-weight: 800; margin-bottom: 6px; letter-spacing: -.01em; }
.why p { font-size: 14.5px; color: var(--muted); }

.cta {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 28px; flex-wrap: wrap;
  padding: clamp(28px, 5vw, 48px); border-radius: 28px; color: #fff; background: var(--grad); box-shadow: var(--shadow-lg);
}
.cta::before, .cta::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); pointer-events: none; }
.cta::before { width: 320px; height: 320px; right: -80px; top: -140px; }
.cta::after { width: 200px; height: 200px; left: 30%; bottom: -120px; }
.cta > * { position: relative; z-index: 1; }
.cta h2 { color: #fff; margin-bottom: 8px; }
.cta p { color: rgba(255, 255, 255, .88); max-width: 52ch; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cta.slim { margin-top: 48px; padding: 28px 32px; }
.cta.slim h2 { font-size: 1.35rem; }

/* ---------- Footer ---------- */
.site-footer { margin-top: 24px; background: var(--surface); border-top: 1px solid var(--line); padding: 56px 0 24px; }
.foot-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: 36px; }
.foot-brand p { margin: 14px 0 18px; color: var(--muted); font-size: 14.5px; max-width: 34ch; }
.foot-col h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 14px; font-weight: 800; }
.foot-col li + li { margin-top: 9px; }
.foot-col a { font-size: 14.5px; font-weight: 500; color: var(--ink-2); transition: color .2s; }
.foot-col a:hover { color: var(--brand); }
.foot-bottom { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 44px; padding-top: 22px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.to-top { font-weight: 700; color: var(--ink-2); }
.to-top:hover { color: var(--brand); }

/* ---------- Search palette ---------- */
.palette { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(8, 12, 30, .55); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); animation: fade .2s; }
.palette-box { position: relative; width: 100%; max-width: 620px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .25s var(--ease); }
.palette-in { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); font-size: 18px; color: var(--muted); }
.palette-in input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 17px; color: var(--ink); }
.palette-x { border: 1px solid var(--line); background: var(--bg-alt); color: var(--muted); font-size: 11px; font-weight: 700; padding: 5px 8px; border-radius: 8px; }
.palette .results { max-height: min(56vh, 460px); overflow-y: auto; padding: 8px; }
.palette-foot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--bg-alt); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(.98); } }

/* ---------- Tools page ---------- */
.page-head { padding: clamp(28px, 5vw, 56px) 0 clamp(28px, 4vw, 44px); border-bottom: 1px solid var(--line); }
.page-head .wrap { position: relative; z-index: 1; }
.page-head h1 { font-size: clamp(1.9rem, 4.4vw, 3rem); margin: 10px 0 12px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.crumbs a:hover { color: var(--brand); }
.crumbs i { font-size: 11px; }

.filterbar { position: sticky; top: var(--header-h); z-index: 50; background: color-mix(in srgb, var(--bg) 94%, transparent); -webkit-backdrop-filter: saturate(180%) blur(16px); backdrop-filter: saturate(180%) blur(16px); border-bottom: 1px solid var(--line); }
.fb-in { display: flex; align-items: center; gap: 14px; padding-block: 12px; }
.pills { flex: 1; min-width: 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; padding: 2px; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 999px; scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s, transform .2s var(--ease);
}
.pill:hover { border-color: var(--line-2); transform: translateY(-1px); }
.pill .n { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--bg-alt); color: var(--muted); }
.pill .bi-star-fill { color: #f59f00; font-size: 12px; }
.pill.is-on { background: var(--c, var(--brand)); border-color: var(--c, var(--brand)); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--c, var(--brand)) 40%, transparent); }
.pill.is-on .n { background: rgba(255, 255, 255, .24); color: #fff; }
.pill.is-on .bi-star-fill { color: #fff; }
.view-toggle { display: flex; gap: 6px; flex: none; }
.view-toggle .icon-btn { width: 38px; height: 38px; }

.result-line { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.cat-sec { padding-top: 34px; }
.cat-head { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.cat-head .ico { width: 52px; height: 52px; font-size: 24px; }
.cat-head h2 { font-size: 1.35rem; }
.cat-head p { font-size: 14px; color: var(--muted); }
.cat-n { margin-left: auto; font-size: 13px; font-weight: 800; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); padding: 4px 12px; border-radius: 999px; }

.is-list .list-target { grid-template-columns: 1fr; gap: 10px; }
.is-list .card-link { align-items: center; padding-block: 14px; }
.is-list .card-body { flex-direction: row; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.is-list .card-title { min-width: 180px; }
.is-list .go { bottom: auto; top: 50%; margin-top: -8px; }

.empty { text-align: center; padding: 56px 16px; }
.empty-ico { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; font-size: 30px; color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); margin-bottom: 18px; }
.empty p { color: var(--muted); margin: 8px auto 22px; max-width: 46ch; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Reveal on scroll (only when JS is on) ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .6s var(--ease); transition-delay: var(--d, 0ms); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1040px) {
  .g4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-visual { display: none; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
}
@media (max-width: 860px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .burger { display: inline-grid; }
  .search-btn-txt, .search-btn kbd { display: none; }
  .search-btn { width: 42px; padding: 0; justify-content: center; }
  .nav {
    position: absolute; left: 0; right: 0; top: var(--header-h); margin: 0; flex-direction: column; align-items: stretch; gap: 2px;
    padding: 10px clamp(16px, 4vw, 32px) 16px; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow-md);
    display: none;
  }
  .nav.open { display: flex; }
  .nav a { padding: 12px 14px; font-size: 16px; }
}
@media (max-width: 680px) {
  .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats li:nth-child(3) { border-left: 0; }
  .stats li:nth-child(n+3) { border-top: 1px solid var(--line); }
  .sec-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .card-link { flex-direction: column; gap: 12px; padding: 16px 14px; }
  .card-body { padding-right: 0; }
  .go { display: none; }
  .fav { opacity: .8; }
  .cat { flex-direction: column; align-items: flex-start; padding: 18px 16px; gap: 12px; }
  .cat .cat-body { padding-top: 0; }
  .cat-count { top: 14px; right: 12px; }
  .game-grid { grid-template-columns: repeat(2, 1fr); }
  .searchbox { padding-left: 14px; }
  .searchbox .btn { padding: 11px 16px; }
  .is-list .g4, .is-list .list-target { grid-template-columns: 1fr; }
  .is-list .card-link { flex-direction: row; align-items: center; }
  .view-toggle { display: none; }
  .foot-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
  .cta-actions .btn { flex: 1 1 100%; }
  .kbd-hint { display: none; }
}
@media (max-width: 380px) {
  .g4, .g3 { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .js .reveal { opacity: 1; transform: none; }
}
