/* ================= Offline Game Hub — design system ================= */
:root {
  --bg: #0b0920;
  --bg-2: #120e30;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --surface-solid: #17123a;
  --card: #151036;
  --text: #f5f3ff;
  --text-dim: #aba3d6;
  --text-faint: #7b73a8;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #8b5cf6;
  --accent-2: #ff4fa3;
  --accent-3: #19d3c5;
  --amber: #ffc53d;
  --good: #34d399;
  --warn: #ff5d73;
  --grad: linear-gradient(135deg, #8b5cf6 0%, #ff4fa3 100%);
  --shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.6);
  --shadow-sm: 0 6px 18px -6px rgba(0, 0, 0, 0.5);
  --r-xl: 26px;
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --font: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --c-puzzle: #19d3c5;
  --c-arcade: #ff4fa3;
  --c-board: #ffc53d;
  --c-casual: #7ee04a;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f1ff;
  --bg-2: #ebe5ff;
  --surface: rgba(40, 20, 110, 0.04);
  --surface-2: rgba(40, 20, 110, 0.08);
  --surface-solid: #ffffff;
  --card: #ffffff;
  --text: #1c1640;
  --text-dim: #5d5590;
  --text-faint: #8a83b5;
  --border: rgba(40, 20, 110, 0.1);
  --border-strong: rgba(40, 20, 110, 0.18);
  --shadow: 0 18px 40px -16px rgba(60, 30, 150, 0.28);
  --shadow-sm: 0 6px 18px -8px rgba(60, 30, 150, 0.25);
  --c-puzzle: #0d9488;
  --c-arcade: #db2777;
  --c-board: #c2860a;
  --c-casual: #3f9a1c;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden, [hidden] { display: none !important; }
kbd, .kbd {
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 3px 8px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-bottom-width: 2px; color: var(--text);
}
.kbd.sm { font-size: 11px; padding: 1px 6px; }

/* ---------- animated background ---------- */
.bg-fx { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none;
  background:
    radial-gradient(900px 500px at 8% -8%, rgba(139, 92, 246, 0.28), transparent 60%),
    radial-gradient(700px 500px at 100% 10%, rgba(255, 79, 163, 0.16), transparent 60%),
    radial-gradient(900px 600px at 50% 120%, rgba(25, 211, 197, 0.12), transparent 60%),
    var(--bg);
}
.bg-fx::after { content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 10%, transparent 70%);
  opacity: 0.6;
}
.bg-fx i { position: absolute; width: 380px; height: 380px; border-radius: 50%; filter: blur(80px); opacity: 0.22; animation: float 18s ease-in-out infinite; }
.bg-fx i:nth-child(1) { background: #8b5cf6; left: -80px; top: 30%; }
.bg-fx i:nth-child(2) { background: #ff4fa3; right: -60px; top: 50%; animation-delay: -6s; }
.bg-fx i:nth-child(3) { background: #19d3c5; left: 40%; bottom: -160px; animation-delay: -12s; }
html[data-theme="light"] .bg-fx { background:
    radial-gradient(900px 500px at 8% -8%, rgba(139, 92, 246, 0.18), transparent 60%),
    radial-gradient(700px 500px at 100% 10%, rgba(255, 79, 163, 0.12), transparent 60%), var(--bg); }
html[data-theme="light"] .bg-fx i { opacity: 0.12; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(60px, -40px) scale(1.15); } }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 3vw, 36px);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 44px; height: 44px; border-radius: 12px; box-shadow: 0 6px 20px -4px rgba(139, 92, 246, 0.6); transition: transform .3s; }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.06); }
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 850; letter-spacing: -0.02em; line-height: 1.1;
  background: linear-gradient(90deg, var(--text), color-mix(in srgb, var(--accent) 60%, var(--text))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.offline-pill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--good);
  padding: 7px 12px; border-radius: 999px; background: color-mix(in srgb, var(--good) 12%, transparent); border: 1px solid color-mix(in srgb, var(--good) 30%, transparent); margin-right: 4px; }
.offline-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: ping 2s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 70%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }

.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; font-size: 17px;
  display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .15s, background .2s, border-color .2s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-btn:active { transform: scale(.94); }

/* ---------- layout ---------- */
.view { padding: 24px clamp(16px, 3vw, 36px) 40px; max-width: 1440px; margin: 0 auto; }
#view-game { max-width: none; padding-top: 14px; padding-bottom: 16px; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(280px, 1fr); gap: 20px; margin-bottom: 34px; }
.featured {
  position: relative; border-radius: var(--r-xl); overflow: hidden; min-height: 320px;
  box-shadow: var(--shadow); isolation: isolate; border: 1px solid var(--border-strong);
  display: flex; align-items: flex-end;
}
.featured .fx-art { position: absolute; inset: 0; z-index: -2; }
.featured .fx-art svg { width: 100%; height: 100%; display: block; }
.fx-bgart { position: absolute; inset: -30px; filter: blur(22px) saturate(1.2); opacity: .85; }
.fx-fg { position: absolute; right: 0; top: 0; bottom: 0; width: 64%; -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 30%); mask-image: linear-gradient(90deg, transparent 0%, #000 30%); transition: transform 1.2s cubic-bezier(.2,.7,.2,1); }
.featured:hover .fx-fg { transform: scale(1.05); }
.featured::after { content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(90deg, rgba(8, 6, 26, 0.85) 0%, rgba(8, 6, 26, 0.45) 40%, rgba(8, 6, 26, 0) 60%); }
.fx-body { padding: clamp(22px, 3.2vw, 38px); max-width: 520px; color: #fff; }
.fx-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,.14); backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,.2); }
.fx-title { font-size: clamp(30px, 4vw, 48px); line-height: 1.02; margin: 14px 0 10px; font-weight: 900; letter-spacing: -0.03em; text-shadow: 0 4px 24px rgba(0,0,0,.4); }
.fx-desc { margin: 0 0 20px; font-size: 15.5px; line-height: 1.5; color: rgba(255,255,255,.85); }
.fx-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fx-meta .chip { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.2); }

.side { display: grid; grid-template-rows: auto 1fr; gap: 20px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; backdrop-filter: blur(10px); min-width: 0; }
.panel-title { margin: 0 0 12px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); font-weight: 800; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); }
.stat-box b { display: block; font-size: 24px; font-weight: 900; letter-spacing: -0.02em; }
.stat-box span { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.stat-box:nth-child(1) b { color: var(--accent); }
.stat-box:nth-child(2) b { color: var(--accent-2); }
.stat-box:nth-child(3) b { color: var(--amber); }
.stat-box:nth-child(4) b { color: var(--accent-3); }
html[data-theme="light"] .stat-box:nth-child(3) b { color: #c2860a; }
.continue-list { display: flex; flex-direction: column; gap: 8px; }
.cont-item { display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-md); border: 1px solid transparent; background: none; text-align: left; width: 100%; transition: background .2s, border-color .2s; }
.cont-item:hover { background: var(--surface-2); border-color: var(--border); }
.cont-thumb { width: 54px; height: 38px; border-radius: 9px; overflow: hidden; flex: none; }
.cont-thumb svg { width: 100%; height: 100%; display: block; }
.cont-item b { display: block; font-size: 14px; }
.cont-item small { color: var(--text-dim); font-size: 12px; }
.cont-item .go { margin-left: auto; font-size: 13px; color: var(--text-faint); }
.cont-empty { color: var(--text-dim); font-size: 13.5px; line-height: 1.5; margin: 0; }

/* ---------- buttons ---------- */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 22px; font-weight: 800; font-size: 15px; color: #fff;
  background: var(--grad); box-shadow: 0 10px 24px -8px rgba(255, 79, 163, .6), inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.primary-btn:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: 0 14px 30px -8px rgba(255, 79, 163, .75), inset 0 1px 0 rgba(255,255,255,.3); }
.primary-btn:active { transform: translateY(0) scale(.97); }
.primary-btn.big { padding: 14px 28px; font-size: 16px; border-radius: 16px; }
.ghost-btn { border-radius: 14px; padding: 12px 20px; font-weight: 700; font-size: 15px; background: var(--surface-2); border: 1px solid var(--border-strong); transition: background .2s, transform .15s; }
.ghost-btn:hover { background: color-mix(in srgb, var(--surface-2) 60%, var(--border-strong)); transform: translateY(-1px); }
.fav-btn { width: 46px; height: 46px; border-radius: 14px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12); color: #fff; font-size: 20px; backdrop-filter: blur(8px); transition: transform .2s; }
.fav-btn:hover { transform: scale(1.08); }
.fav-btn.active { color: #ff4d6d; }

/* ---------- library ---------- */
.library-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.section-title { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: -0.025em; }
.count { font-size: 14px; font-weight: 800; color: var(--text-dim); background: var(--surface-2); padding: 3px 10px; border-radius: 999px; vertical-align: middle; margin-left: 6px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 13px; width: 17px; height: 17px; color: var(--text-faint); }
.search-wrap input {
  width: min(320px, 70vw); padding: 11px 40px 11px 40px; border-radius: 14px; font: inherit; font-size: 14.5px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); background: var(--surface-2); }
.search-kbd { position: absolute; right: 10px; font-size: 11px; padding: 1px 7px; opacity: .7; }
.sort-select { padding: 11px 14px; border-radius: 14px; font: inherit; font-size: 14px; font-weight: 600; background: var(--surface); color: var(--text); border: 1px solid var(--border); outline: none; cursor: pointer; }
.sort-select option { background: var(--surface-solid); color: var(--text); }

.category-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 14px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); transition: all .2s;
}
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab .n { font-size: 11.5px; font-weight: 800; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); }
.tab.active { color: #fff; background: var(--grad); border-color: transparent; box-shadow: 0 8px 20px -8px rgba(255, 79, 163, .7); }
.tab.active .n { background: rgba(255,255,255,.22); }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.game-card {
  position: relative; display: flex; flex-direction: column; border-radius: var(--r-lg); overflow: hidden;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s, border-color .25s; cursor: pointer;
  animation: cardIn .45s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.game-card:hover { transform: translateY(-6px); border-color: var(--border-strong); box-shadow: 0 24px 44px -18px rgba(0,0,0,.7), 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent); }
.game-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.card-art { position: relative; aspect-ratio: 16 / 10; overflow: hidden; }
.card-art svg { width: 100%; height: 100%; display: block; transition: transform .6s cubic-bezier(.2,.8,.2,1); }
.game-card:hover .card-art svg { transform: scale(1.08); }
.card-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.35)); }
.play-fab {
  position: absolute; z-index: 2; right: 12px; bottom: 12px; width: 46px; height: 46px; border-radius: 50%; border: 0;
  display: grid; place-items: center; background: #fff; color: #1c1640; font-size: 17px; padding-left: 3px;
  box-shadow: 0 10px 22px -6px rgba(0,0,0,.6); opacity: 0; transform: translateY(10px) scale(.85); transition: all .25s cubic-bezier(.2,.8,.2,1);
}
.game-card:hover .play-fab, .game-card:focus-within .play-fab { opacity: 1; transform: none; }
.badge-new { position: absolute; z-index: 2; left: 10px; top: 10px; font-size: 10.5px; font-weight: 900; letter-spacing: .1em; padding: 4px 9px; border-radius: 8px; color: #2a1600; background: linear-gradient(135deg, #ffe45c, #ffb13d); box-shadow: 0 4px 12px -2px rgba(255, 177, 61, .6); }
.card-fav { position: absolute; z-index: 2; right: 10px; top: 10px; width: 34px; height: 34px; border-radius: 11px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(10, 8, 30, .35); backdrop-filter: blur(8px); color: #fff; font-size: 16px; display: grid; place-items: center; transition: transform .2s, background .2s; }
.card-fav:hover { transform: scale(1.1); background: rgba(10, 8, 30, .55); }
.card-fav.active { color: #ff4d6d; }
.card-fav.pop { animation: heartPop .4s; }
@keyframes heartPop { 40% { transform: scale(1.4); } }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-title { margin: 0; font-size: 16.5px; font-weight: 800; letter-spacing: -0.01em; }
.card-desc { margin: 0; font-size: 13.2px; color: var(--text-dim); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 38px; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; font-size: 12.5px; }
.card-best { margin-left: auto; color: var(--text-dim); font-weight: 700; white-space: nowrap; }
.card-best b { color: var(--text); }
.card-last { font-size: 11.5px; color: var(--text-faint); }

.chip { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; border: 1px solid; letter-spacing: .02em; }
.cat-puzzle { color: var(--c-puzzle); border-color: color-mix(in srgb, var(--c-puzzle) 35%, transparent); background: color-mix(in srgb, var(--c-puzzle) 10%, transparent); }
.cat-arcade { color: var(--c-arcade); border-color: color-mix(in srgb, var(--c-arcade) 35%, transparent); background: color-mix(in srgb, var(--c-arcade) 10%, transparent); }
.cat-board { color: var(--c-board); border-color: color-mix(in srgb, var(--c-board) 35%, transparent); background: color-mix(in srgb, var(--c-board) 10%, transparent); }
.cat-casual { color: var(--c-casual); border-color: color-mix(in srgb, var(--c-casual) 35%, transparent); background: color-mix(in srgb, var(--c-casual) 10%, transparent); }
.diff { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; color: var(--text-faint); }
.diff::before { content: ""; width: 26px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--dc) var(--dp), var(--surface-2) var(--dp)); margin-right: 3px; }
.diff-easy { --dc: #34d399; --dp: 33%; }
.diff-medium { --dc: #ffc53d; --dp: 66%; }
.diff-hard { --dc: #ff5d73; --dp: 100%; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-emoji { font-size: 44px; margin-bottom: 6px; }
.foot { margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.foot img { width: 22px; height: 22px; border-radius: 6px; }

/* ---------- game view ---------- */
.game-header {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); backdrop-filter: blur(12px);
  max-width: 1100px; margin: 0 auto 14px;
}
.back-btn { display: inline-flex; gap: 6px; align-items: center; padding: 10px 14px; border-radius: 12px; font-weight: 800; font-size: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.back-btn:hover { border-color: var(--border-strong); }
.game-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.game-thumb { width: 52px; height: 36px; border-radius: 9px; overflow: hidden; flex: none; box-shadow: var(--shadow-sm); }
.game-thumb svg { width: 100%; height: 100%; display: block; }
.game-title { margin: 0; font-size: 18px; font-weight: 900; letter-spacing: -0.02em; white-space: nowrap; }
.game-cat { font-size: 12px; color: var(--text-dim); font-weight: 700; }
.hud { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.hud-pill { display: inline-flex; flex-direction: column; align-items: center; min-width: 66px; padding: 5px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); line-height: 1.15; }
.hud-pill em { font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--text-faint); font-weight: 800; }
.hud-pill b { font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }
.hud-pill.score b { color: var(--accent-2); }
.hud-pill.best b { color: var(--amber); }
html[data-theme="light"] .hud-pill.best b { color: #c2860a; }
.hud-pill.bump b { animation: bump .3s; }
@keyframes bump { 40% { transform: scale(1.25); } }
.game-actions { display: flex; gap: 6px; }

.game-root { position: relative; display: flex; justify-content: center; align-items: flex-start; min-height: calc(100vh - 160px); }
.game-stage { position: relative; width: 100%; max-width: 1100px; display: flex; flex-direction: column; align-items: center; gap: 14px; animation: stageIn .4s ease both; }
@keyframes stageIn { from { opacity: 0; transform: scale(.98); } }
.cv-frame { position: relative; box-sizing: border-box; padding: 8px; border-radius: 22px; background: linear-gradient(145deg, rgba(255,255,255,.12), rgba(255,255,255,.02)); border: 1px solid var(--border-strong); box-shadow: 0 30px 60px -24px rgba(0,0,0,.8), 0 0 80px -30px rgba(139, 92, 246, .6); max-width: 100%; }
.game-canvas { display: block; border-radius: 15px; touch-action: none; user-select: none; background: #0d0b1f; height: auto; }
.game-load-error { padding: 40px; color: var(--warn); font-weight: 700; }

/* overlays */
.game-overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(10px); opacity: 0; transition: opacity .25s; }
.game-overlay.show { opacity: 1; }
.ov-start { background: color-mix(in srgb, var(--bg) 35%, transparent); }
.ov-card { position: relative; width: min(440px, 100%); text-align: center; padding: 26px; border-radius: var(--r-xl); background: color-mix(in srgb, var(--surface-solid) 92%, transparent); border: 1px solid var(--border-strong); box-shadow: var(--shadow); transform: translateY(12px) scale(.97); transition: transform .35s cubic-bezier(.2,.9,.3,1.2); }
.game-overlay.show .ov-card { transform: none; }
.ov-cover { margin: -12px -12px 16px; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 8; box-shadow: var(--shadow-sm); }
.ov-cover svg { width: 100%; height: 100%; display: block; }
.ov-kicker { display: flex; gap: 10px; justify-content: center; align-items: center; }
.ov-title { margin: 10px 0 8px; font-size: 30px; font-weight: 900; letter-spacing: -0.03em; }
.ov-text { color: var(--text-dim); margin: 0 0 14px; line-height: 1.5; font-size: 14.5px; }
.ov-controls { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 16px; }
.ov-best { font-size: 14px; color: var(--text-dim); margin-bottom: 16px; }
.ov-best b { color: var(--amber); }
.ov-hint { margin-top: 14px; font-size: 12px; color: var(--text-faint); }
.ov-emoji { font-size: 52px; line-height: 1; animation: pop .6s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes pop { from { transform: scale(0) rotate(-20deg); } }
.ov-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.ov-score { padding: 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.ov-score span { display: block; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); }
.ov-score b { font-size: 34px; font-weight: 900; letter-spacing: -0.03em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; font-variant-numeric: tabular-nums; }
.ov-score.best b { background: linear-gradient(135deg, #ffe45c, #ff9f1c); -webkit-background-clip: text; background-clip: text; }
.new-best { display: inline-block; margin-bottom: 14px; font-weight: 900; font-size: 13px; letter-spacing: .06em; text-transform: uppercase; padding: 6px 14px; border-radius: 999px; color: #2a1600; background: linear-gradient(135deg, #ffe45c, #ffb13d); animation: glowPulse 1.4s ease-in-out infinite; }
@keyframes glowPulse { 50% { box-shadow: 0 0 24px rgba(255, 197, 61, .8); } }
.ov-actions { display: flex; gap: 10px; justify-content: center; }
.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(calc(var(--rx) * 120px), 110vh) rotate(calc(var(--rx) * 900deg)); } }

/* ---------- shared DOM game pieces ---------- */
.g-panel { padding: 18px; border-radius: 24px; background: linear-gradient(145deg, rgba(255,255,255,.1), rgba(255,255,255,.02)); border: 1px solid var(--border-strong); box-shadow: 0 30px 60px -24px rgba(0,0,0,.7); }
.g-msg { font-size: 16px; font-weight: 800; color: var(--text); text-align: center; min-height: 24px; }
.g-sub { font-size: 13.5px; color: var(--text-dim); text-align: center; }
.g-row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.g-btn { padding: 10px 18px; border-radius: 12px; font-weight: 800; font-size: 14px; border: 1px solid var(--border-strong); background: var(--surface-2); transition: transform .12s, background .2s; }
.g-btn:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--surface-2) 50%, var(--border-strong)); }
.g-btn.on { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(5, 3, 18, .6); backdrop-filter: blur(8px); animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card { width: min(520px, 100%); max-height: 88vh; overflow: auto; padding: 24px; border-radius: var(--r-xl); background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: modalIn .3s cubic-bezier(.2,.9,.3,1.2); }
@keyframes modalIn { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.modal-card.small { width: min(400px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h3, .modal-card h3 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: -0.02em; }
.settings-section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.settings-section:last-child { border-bottom: 0; }
.settings-section h4 { margin: 0 0 10px; font-size: 12.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--text-dim); }
.seg-control { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); }
.seg-btn { padding: 8px 16px; border-radius: 10px; border: 0; background: none; font-weight: 700; font-size: 14px; color: var(--text-dim); }
.seg-btn.active { background: var(--grad); color: #fff; box-shadow: 0 6px 14px -6px rgba(255, 79, 163, .7); }
.hint { font-size: 13.5px; color: var(--text-dim); line-height: 1.55; margin: 0 0 10px; }
.danger-row { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-btn { padding: 9px 14px; border-radius: 11px; font-weight: 700; font-size: 13.5px; background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.danger-btn:hover { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.danger-btn.solid { background: var(--warn); color: #fff; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.ach-list { display: grid; gap: 10px; margin-top: 12px; }
.ach { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--border); }
.ach-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 22px; background: var(--grad); flex: none; }
.ach.locked { opacity: .5; }
.ach.locked .ach-icon { background: var(--surface-2); filter: grayscale(1); }
.ach b { display: block; font-size: 15px; }
.ach small { color: var(--text-dim); font-size: 13px; }
.ach .tick { margin-left: auto; color: var(--good); font-weight: 900; }

.toast { position: fixed; left: 50%; bottom: 26px; z-index: 60; transform: translateX(-50%); padding: 12px 20px; border-radius: 14px; font-weight: 800; font-size: 14.5px; color: #fff;
  background: linear-gradient(135deg, #2a1f63, #151036); border: 1px solid rgba(255,255,255,.18); box-shadow: 0 16px 40px -10px rgba(0,0,0,.6); animation: toastIn .35s cubic-bezier(.2,.9,.3,1.3); }
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .side { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .side { grid-template-columns: 1fr; }
  .offline-pill, .brand-sub, .search-kbd { display: none; }
  .featured { min-height: 300px; }
  .fx-fg { width: 100%; bottom: 40%; -webkit-mask-image: none; mask-image: none; }
  .featured::after { background: linear-gradient(0deg, rgba(8,6,26,.95) 10%, rgba(8,6,26,.2) 80%); }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card-desc { display: none; }
  .hud { margin-left: 0; order: 3; width: 100%; justify-content: center; }
  .hud-pill { min-width: 58px; padding: 4px 8px; }
  .back-btn span { display: none; }
  .game-actions { margin-left: auto; }
  .search-wrap input { width: 100%; }
  .controls, .search-wrap { width: 100%; }
}

/* ---------- reduced motion ---------- */
html[data-animations="reduced"] *, html[data-animations="reduced"] *::before, html[data-animations="reduced"] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .bg-fx i { animation: none; } }
