/* Plagomo — shared styles. No inline styles anywhere (strict CSP). */

:root {
  --bg: #f6f4ef;
  --bg-2: #ece8df;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --text: #1d1b22;
  --muted: #6b6775;
  --line: #ddd8cc;
  --accent: #5b4bdb;
  --accent-ink: #ffffff;
  --good: #1f9d63;
  --bad: #d64545;
  --shadow: 0 1px 2px rgba(20, 16, 40, .06), 0 6px 20px rgba(20, 16, 40, .08);
  --radius: 16px;
  --radius-sm: 10px;
  --max: 1080px;
  --tap: 44px;

  /* per-game accents */
  --g-memory: #e0567a;
  --g-2048: #e8913a;
  --g-snake: #22a06b;
  --g-ttt: #3f7be0;
  --g-cricket: #0e8fa3;
  --g-sudoku: #8a4fd8;
  --g-bear: #9a5b32;
  --g-tiles: #d9486b;
  --g-hoops: #e8702a;

  /* 2048 tiles */
  --t-empty: #e3ddd0;
  --t-board: #cfc6b4;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121118;
    --bg-2: #18171f;
    --surface: #1e1d27;
    --surface-2: #26252f;
    --text: #efedf5;
    --muted: #a3a0ad;
    --line: #33313d;
    --accent: #8c7dff;
    --accent-ink: #120f24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --t-empty: #2c2a35;
    --t-board: #222029;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121118;
  --bg-2: #18171f;
  --surface: #1e1d27;
  --surface-2: #26252f;
  --text: #efedf5;
  --muted: #a3a0ad;
  --line: #33313d;
  --accent: #8c7dff;
  --accent-ink: #120f24;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  --t-empty: #2c2a35;
  --t-board: #222029;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

a { color: var(--accent); }
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
p { margin: 0 0 1em; }

[hidden] { display: none !important; }

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

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

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* ---------- Header / footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.site-header .wrap { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text);
  font-weight: 800; font-size: 1.1rem; letter-spacing: -.02em; margin-right: auto;
}
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.icon-btn {
  min-width: var(--tap); height: var(--tap); border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; padding: 0 10px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: .95rem;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 20px; height: 20px; }

.site-footer {
  margin-top: auto; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem;
  padding: 24px 0 calc(24px + env(safe-area-inset-bottom));
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.site-footer a { color: var(--muted); }
.site-footer .copy { margin-right: auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer;
  text-decoration: none; touch-action: manipulation; transition: transform .08s ease, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.nogap { gap: 0; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button {
  border: 0; background: transparent; min-height: 38px; padding: 0 12px; border-radius: 9px; cursor: pointer;
  font-weight: 600; color: var(--muted); touch-action: manipulation;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Hub ---------- */
.hero { padding-top: 40px; padding-bottom: 16px; }
.hero h1 { font-size: clamp(1.9rem, 6vw, 3rem); font-weight: 850; }
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 56ch; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding: 0; list-style: none; }
.pills li { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: .88rem; font-weight: 600; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); padding: 16px 0 8px; }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); }
.card:active { transform: scale(.985); }
.card .art { aspect-ratio: 16 / 10; display: grid; place-items: center; background: var(--c, var(--accent)); }
.card .art img { width: 46%; height: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.18)); }
.card .body { padding: 14px 16px 16px; }
.card h2, .card h3 { font-size: 1.15rem; margin: 0 0 4px; }
.card p { margin: 0; color: var(--muted); font-size: .93rem; }
.card .best { margin-top: 10px; font-size: .82rem; font-weight: 700; color: var(--muted); }
.card.memory { --c: var(--g-memory); }
.card.g2048 { --c: var(--g-2048); }
.card.snake { --c: var(--g-snake); }
.card.ttt { --c: var(--g-ttt); }
.card.cricket { --c: var(--g-cricket); }
.card.sudoku { --c: var(--g-sudoku); }
.card.bear { --c: #6fae3e; }
.card.tiles { --c: #c2417a; }
.card.hoops { --c: #e8702a; }

.section { padding-top: 28px; padding-bottom: 28px; }
.section h2 { font-size: 1.4rem; }
.features { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; }
.feature h3 { font-size: 1rem; margin-bottom: 4px; }
.feature p { margin: 0; color: var(--muted); font-size: .93rem; }

.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0 16px; margin-bottom: 8px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; min-height: var(--tap); }
.faq details p { color: var(--muted); }

.prose { max-width: 70ch; padding: 32px 0; }
.prose h1 { font-size: 2rem; }
.prose h2 { font-size: 1.25rem; margin-top: 1.4em; }
.prose p, .prose li { color: var(--text); }
.prose .muted { color: var(--muted); }

/* ---------- Hub: bento tiles ---------- */
.hub-hero { padding-top: 22px; padding-bottom: 4px; }
.hub-hero h1 { font-size: clamp(1.7rem, 7vw, 2.4rem); margin: 0; }
.hub-hero p { margin: 4px 0 0; font-size: .95rem; }
.hub-hero .tagline { color: var(--accent); font-weight: 800; }
.bento { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 118px; gap: 12px; padding: 14px 0 12px; grid-auto-flow: dense; }
.bt {
  --c: var(--accent);
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; isolation: isolate;
  padding: 14px; border-radius: 22px; color: #fff; text-decoration: none;
  background: linear-gradient(145deg, var(--c), color-mix(in srgb, var(--c) 78%, #000));
  box-shadow: 0 8px 20px color-mix(in srgb, var(--c) 30%, transparent), inset 0 1px 0 rgba(255, 255, 255, .18);
  transition: transform .18s cubic-bezier(.2, 1.2, .4, 1), box-shadow .18s;
  animation: btin .45s cubic-bezier(.2, 1.2, .4, 1) backwards;
}
.bt::after { /* soft light blob */
  content: ""; position: absolute; z-index: -1; width: 70%; aspect-ratio: 1; right: -20%; top: -30%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%);
}
.bt:hover { transform: translateY(-3px) scale(1.01); box-shadow: 0 14px 28px color-mix(in srgb, var(--c) 38%, transparent); }
.bt:active { transform: scale(.97); }
.bt:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.bt img { position: absolute; right: 10px; top: 12px; width: 34%; height: auto; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .22)); transition: transform .3s ease; z-index: -1; }
.bt:hover img { transform: rotate(-6deg) scale(1.06); }
.bt h2 { position: relative; margin: 0; font-size: 1.08rem; line-height: 1.15; text-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.bt p { position: relative; margin: 3px 0 0; font-size: .8rem; font-weight: 600; opacity: .92; line-height: 1.3; }
.bt.small p { display: none; }
.bt-badge {
  position: absolute; left: 12px; top: 12px; padding: 4px 10px; border-radius: 99px; font-size: .72rem; font-weight: 800;
  background: rgba(255, 255, 255, .24); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.bt.big { grid-column: span 2; grid-row: span 2; padding: 20px; }
.bt.big img { width: 40%; max-width: 230px; right: 16px; top: 14%; }
.bt.big h2, .bt.big p { max-width: 62%; }
.bt.big h2 { font-size: clamp(1.45rem, 6.2vw, 2.1rem); }
.bt.big p { font-size: .95rem; }
.bt-play {
  position: relative; align-self: flex-start; margin-top: 12px; padding: 9px 18px; border-radius: 99px;
  background: #fff; color: #14141a; font-weight: 800; font-size: .92rem; box-shadow: 0 4px 10px rgba(0, 0, 0, .15);
}
.bt.wide { grid-column: span 2; }
.bt.wide img { width: 26%; max-width: 110px; right: 16px; top: 50%; transform: translateY(-50%); }
.bt.wide:hover img { transform: translateY(-50%) rotate(-6deg) scale(1.06); }
.bt.wide h2, .bt.wide p { max-width: 64%; }
.bt.tall { grid-row: span 2; }
.bt.tall img { width: 70%; right: 15%; top: 42px; }
.bt.c-cricket { --c: var(--g-cricket); }
.bt.c-sudoku { --c: var(--g-sudoku); }
.bt.c-hoops { --c: #e8702a; }
.bt.c-tiles { --c: #c2417a; }
.bt.c-bear { --c: #5f9f3a; }
.bt.c-g2048 { --c: #e0892f; }
.bt.c-snake { --c: var(--g-snake); }
.bt.c-memory { --c: var(--g-memory); }
.bt.c-ttt { --c: var(--g-ttt); }
.bento .bt:nth-child(1) { animation-delay: 0ms; } .bento .bt:nth-child(2) { animation-delay: 50ms; }
.bento .bt:nth-child(3) { animation-delay: 100ms; } .bento .bt:nth-child(4) { animation-delay: 150ms; }
.bento .bt:nth-child(5) { animation-delay: 200ms; } .bento .bt:nth-child(6) { animation-delay: 250ms; }
.bento .bt:nth-child(7) { animation-delay: 300ms; } .bento .bt:nth-child(8) { animation-delay: 350ms; }
.bento .bt:nth-child(9) { animation-delay: 400ms; }
@keyframes btin { from { opacity: 0; transform: translateY(18px) scale(.94); } }
@media (min-width: 720px) {
  .bento { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 150px; gap: 16px; }
  .bt h2 { font-size: 1.2rem; }
}

/* ---------- Ad slots (hidden until ads are enabled) ---------- */
.ad-slot { display: none; }
html.ads-on .ad-slot {
  display: flex; align-items: center; justify-content: center; margin: 16px auto; width: 100%;
  min-height: 100px; max-width: 728px; border: 1px dashed var(--line); border-radius: var(--radius-sm);
  color: var(--muted); font-size: .8rem;
}

/* ---------- Game page shell ---------- */
.game-main { flex: 1; display: flex; flex-direction: column; }
.game-shell { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 12px; padding-bottom: 20px; }
.game-shell h1 { font-size: 1.35rem; margin: 0; }
.game-top { width: 100%; max-width: 520px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stats { display: flex; gap: 8px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; min-width: 70px; text-align: center;
}
.stat span { display: block; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.toolbar { width: 100%; max-width: 520px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.board-wrap { width: min(92vw, 520px, calc(100dvh - 260px)); min-width: 260px; }
.hint { color: var(--muted); font-size: .88rem; text-align: center; margin: 0; }

.game-info { border-top: 1px solid var(--line); padding: 8px 0 24px; }
.game-info .wrap { max-width: 760px; }
.game-info h2 { font-size: 1.2rem; margin-top: 1.2em; }
.game-info p, .game-info li { color: var(--muted); }
.more-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.more-games a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; text-decoration: none; color: var(--text); font-weight: 700;
}
.more-games img { width: 28px; height: 28px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 16px; background: rgba(10, 8, 20, .55); }
.modal.open { display: grid; animation: fade .18s ease; }
.modal-card {
  width: min(360px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 24px;
  text-align: center; box-shadow: var(--shadow); animation: pop .22s cubic-bezier(.2, 1.4, .4, 1);
}
.modal-card h2 { font-size: 1.5rem; margin-bottom: 4px; }
.modal-card p { color: var(--muted); }
.modal-card .big { font-size: 2.4rem; font-weight: 850; color: var(--text); margin: 4px 0; font-variant-numeric: tabular-nums; }
.modal-card .new-best { color: var(--good); font-weight: 800; }
.modal-actions { display: grid; gap: 8px; margin-top: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); z-index: 60;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i {
  position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; opacity: .95;
  animation: confetti-fall 2s cubic-bezier(.25, .6, .4, 1) forwards;
}
.confetti i.round { width: 10px; height: 10px; border-radius: 50%; }
@keyframes confetti-fall {
  to { transform: translate(var(--dx, 0), 105vh) rotate(var(--rot, 360deg)); opacity: .9; }
}

/* Memory: found-name banner */
.mm-found {
  min-height: 2.2em; margin: 0; text-align: center; font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.mm-found .emo { font-size: 1.6rem; }
.mm-found .hi { color: var(--g-memory); }
.mm-found.pop { animation: pop .3s cubic-bezier(.2, 1.4, .4, 1); }

/* ================= Memory Match ================= */
.mm-board { display: grid; gap: 8px; grid-template-columns: repeat(4, 1fr); touch-action: manipulation; }
.mm-board.cols-5 { grid-template-columns: repeat(5, 1fr); }
.mm-board.cols-6 { grid-template-columns: repeat(6, 1fr); gap: 6px; }
.mm-card { aspect-ratio: 1; perspective: 700px; border: 0; padding: 0; background: none; cursor: pointer; }
.mm-inner { display: block; position: relative; width: 100%; height: 100%; transition: transform .38s cubic-bezier(.3, .7, .3, 1); transform-style: preserve-3d; }
.mm-card.flipped .mm-inner, .mm-card.matched .mm-inner { transform: rotateY(180deg); }
.mm-face {
  position: absolute; inset: 0; border-radius: 12px; display: grid; place-items: center; backface-visibility: hidden;
  -webkit-backface-visibility: hidden; font-size: clamp(1.4rem, 7vw, 2.4rem);
}
.mm-board.cols-6 .mm-face { font-size: clamp(1.1rem, 5.5vw, 1.9rem); border-radius: 10px; }
.mm-back {
  background: var(--g-memory);
  background-image: radial-gradient(circle at 30% 30%, rgba(255,255,255,.28) 0 12%, transparent 13%), radial-gradient(circle at 70% 70%, rgba(255,255,255,.18) 0 10%, transparent 11%);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.15);
}
.mm-front { background: var(--surface); border: 2px solid var(--line); transform: rotateY(180deg); }
.mm-card.matched .mm-front { border-color: var(--good); background: color-mix(in srgb, var(--good) 14%, var(--surface)); }
.mm-card.matched { animation: bump .35s ease .15s; }
.mm-card.wrong .mm-front { border-color: var(--bad); animation: shake .35s ease; }
@keyframes bump { 50% { transform: scale(1.08); } }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.mm-card.deal { animation: deal .35s cubic-bezier(.2, 1.2, .4, 1) backwards; }
@keyframes deal { from { opacity: 0; transform: translateY(-24px) scale(.6) rotate(-8deg); } }
.mm-back.mm-back-animals {
  background-color: #2f9e62;
  background-image: radial-gradient(ellipse at 30% 30%, rgba(255,255,255,.25) 0 14%, transparent 15%), radial-gradient(ellipse at 72% 68%, rgba(255,255,255,.16) 0 12%, transparent 13%);
}
.mm-back.mm-back-food {
  background-color: #e8813a;
  background-image: radial-gradient(circle at 30% 30%, rgba(255,255,255,.28) 0 12%, transparent 13%), radial-gradient(circle at 70% 70%, rgba(255,255,255,.18) 0 10%, transparent 11%);
}

/* ================= 2048 ================= */
.g-board {
  position: relative; aspect-ratio: 1; background: var(--t-board); border-radius: 14px; padding: 2.4%;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.g-grid, .g-tiles { position: absolute; inset: 2.4%; }
.g-cell, .g-tile { position: absolute; width: 22.6%; height: 22.6%; border-radius: 9px; }
.g-cell { background: var(--t-empty); }
.g-tile {
  display: grid; place-items: center; font-weight: 850; color: #3b3326; background: #eee4da;
  font-size: clamp(1.2rem, 8vw, 2.4rem); transition: left .11s ease, top .11s ease; font-variant-numeric: tabular-nums;
}
.g-tile.new { animation: appear .16s ease .08s backwards; }
.g-tile.merged { animation: merge .18s ease; z-index: 2; }
@keyframes appear { from { transform: scale(0); } }
@keyframes merge { 50% { transform: scale(1.14); } }
.g-tile.v4 { background: #ede0c8; }
.g-tile.v8 { background: #f2b179; color: #fff; }
.g-tile.v16 { background: #f59563; color: #fff; }
.g-tile.v32 { background: #f67c5f; color: #fff; }
.g-tile.v64 { background: #f65e3b; color: #fff; }
.g-tile.v128 { background: #edcf72; color: #fff; font-size: clamp(1rem, 6.6vw, 2rem); }
.g-tile.v256 { background: #edcc61; color: #fff; font-size: clamp(1rem, 6.6vw, 2rem); }
.g-tile.v512 { background: #edc850; color: #fff; font-size: clamp(1rem, 6.6vw, 2rem); }
.g-tile.v1024 { background: #edc53f; color: #fff; font-size: clamp(.85rem, 5.2vw, 1.6rem); }
.g-tile.v2048 { background: #edc22e; color: #fff; font-size: clamp(.85rem, 5.2vw, 1.6rem); box-shadow: 0 0 24px rgba(237, 194, 46, .6); }
.g-tile.vbig { background: #3c3a32; color: #fff; font-size: clamp(.75rem, 4.4vw, 1.35rem); }

.g-board.emoji .g-tile { flex-direction: column; }
.g-tile .g-emo { font-size: clamp(1.7rem, 10vw, 3rem); line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.15)); }
.g-tile small { position: absolute; right: 7%; bottom: 5%; font-size: clamp(.55rem, 2.6vw, .8rem); font-weight: 800; opacity: .75; }
.g-board.emoji .g-tile.merged .g-emo { animation: wiggle .35s ease; }
@keyframes wiggle { 30% { transform: rotate(-12deg) scale(1.2); } 60% { transform: rotate(10deg); } }

/* ================= Snake ================= */
.s-stage { position: relative; }
.s-canvas {
  display: block; width: 100%; aspect-ratio: 1; border-radius: 14px; background: var(--surface-2);
  border: 1px solid var(--line); touch-action: none;
}
.s-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
}
.s-overlay[hidden] { display: none; }
.s-overlay p { font-weight: 700; margin: 8px 0 0; color: var(--muted); }
.dpad { display: grid; grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(2, 56px); gap: 6px; justify-content: center; }
.dpad button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 14px; cursor: pointer; font-size: 1.3rem;
  touch-action: manipulation; box-shadow: var(--shadow);
}
.dpad button:active { background: var(--surface-2); transform: scale(.96); }
.dpad .up { grid-column: 2; grid-row: 1; }
.dpad .left { grid-column: 1; grid-row: 2; }
.dpad .down { grid-column: 2; grid-row: 2; }
.dpad .right { grid-column: 3; grid-row: 2; }
.dpad.off { display: none; }

/* ================= Tic-tac-toe ================= */
.t-board {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 8px; aspect-ratio: 1; touch-action: manipulation;
}
.t-cell {
  border: 0; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
  display: grid; place-items: center; padding: 14%; min-height: 0; overflow: hidden;
}
.t-cell:disabled { cursor: default; }
.t-cell svg { width: 100%; height: 100%; overflow: visible; }
.t-cell .mark { fill: none; stroke-width: 12; stroke-linecap: round; stroke-dasharray: 300; stroke-dashoffset: 300; animation: draw .3s ease forwards; }
.t-cell .x { stroke: var(--g-ttt); }
.t-cell .o { stroke: var(--g-memory); }
.t-cell.win { background: color-mix(in srgb, var(--good) 18%, var(--surface)); }
@keyframes draw { to { stroke-dashoffset: 0; } }
.t-status { font-weight: 700; min-height: 1.6em; text-align: center; margin: 0; }
.t-tally { display: flex; gap: 8px; justify-content: center; }

/* ================= Book Cricket ================= */
.bc-wrap { width: min(94vw, 520px); display: flex; flex-direction: column; gap: 12px; }
.bc-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 14px;
}
.bc-panel h2 { font-size: 1.15rem; margin: 0; }
.bc-field { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-weight: 700; }
.bc-field select {
  font: inherit; font-weight: 600; min-height: var(--tap); padding: 0 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); max-width: 60%;
}
.bc-rules { color: var(--muted); font-size: .92rem; }
.bc-rules summary { cursor: pointer; font-weight: 700; color: var(--text); min-height: 32px; }
.bc-rules ul { margin: 8px 0 0; padding-left: 20px; }
.bc-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.bc-row .btn { flex: 1; }
#bc-toss { text-align: center; align-items: center; }
#bc-toss p { margin: 0; font-weight: 600; }
.bc-coin { font-size: 64px; line-height: 1; height: 72px; display: grid; place-items: center; }
.bc-coin.spin { animation: coin 1.1s cubic-bezier(.3, .6, .4, 1); }
@keyframes coin { 0% { transform: translateY(0) rotateY(0); } 50% { transform: translateY(-50px) rotateY(900deg); } 100% { transform: translateY(0) rotateY(1800deg); } }

.bc-score {
  background: #0f2e25; color: #f2f7f4; border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow);
  border-top: 4px solid #3ecf8e;
}
.bc-team-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.bc-team-line b { font-size: 1rem; letter-spacing: .04em; }
.bc-runs { font-size: 2rem; font-weight: 850; line-height: 1.1; }
.bc-overs { color: #a9c7bb; font-weight: 600; }
.bc-sub { margin: 2px 0 8px; color: #a9c7bb; font-size: .88rem; font-weight: 600; }
.bc-over { display: flex; gap: 6px; min-height: 30px; flex-wrap: wrap; }
.bc-ball {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; font-weight: 800;
  background: #1f4a3c; color: #e6f2ec; animation: pop .2s ease;
}
.bc-ball.b4 { background: #3f7be0; color: #fff; }
.bc-ball.b6 { background: #8c5cf0; color: #fff; }
.bc-ball.bW { background: #d64545; color: #fff; }
.bc-ball.bNB { background: #e8a33a; color: #2a1a00; }
.bc-ball.bD { background: #2c5a4a; color: #9fc0b3; }

.bc-book-wrap { perspective: 1400px; padding: 6px 0; }
.bk {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; aspect-ratio: 1.55; width: 100%;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, .18));
}
.bk-page {
  position: relative; background: #fffaf0; border: 1px solid #e6dcc6; overflow: hidden;
  background-image: repeating-linear-gradient(to bottom, transparent 0 13px, rgba(90, 80, 60, .09) 13px 15px);
  background-clip: content-box; padding: 14% 12% 22%;
}
.bk-left { border-radius: 14px 4px 4px 14px; box-shadow: inset -14px 0 18px -12px rgba(0, 0, 0, .25); }
.bk-right { border-radius: 4px 14px 14px 4px; box-shadow: inset 14px 0 18px -12px rgba(0, 0, 0, .25); }
.bk-page::before {
  content: ""; position: absolute; left: 12%; right: 12%; top: 7%; height: 5px; border-radius: 3px; background: rgba(90, 80, 60, .22);
}
.bk-num {
  position: absolute; bottom: 5%; font: 700 clamp(1rem, 5vw, 1.35rem)/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: #3d3528; font-variant-numeric: tabular-nums;
}
.bk-left .bk-num { left: 8%; }
.bk-right .bk-num { right: 8%; color: #9b917e; }
.bk-num b { color: var(--g-cricket); font-size: 1.45em; padding: 0 2px; border-bottom: 3px solid currentColor; }
.bk::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; background: #f7f0df; border-radius: 4px 14px 14px 4px;
  transform-origin: left center; opacity: 0; border: 1px solid #e6dcc6; backface-visibility: visible;
}
.bk.flip::after { animation: leaf .22s linear infinite; }
@keyframes leaf { 0% { opacity: 1; transform: rotateY(0); } 100% { opacity: 1; transform: rotateY(-180deg); } }
.bk-burst {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0;
  font-weight: 900; font-size: clamp(2rem, 11vw, 3.4rem); letter-spacing: -.02em; text-shadow: 0 3px 0 rgba(0, 0, 0, .15);
}
.bk-burst.show { animation: burst 1.1s ease forwards; }
.bk-burst.r6 { color: #8c5cf0; }
.bk-burst.r4 { color: #3f7be0; }
.bk-burst.r2 { color: #1f9d63; }
.bk-burst.out { color: #d64545; }
.bk-burst.nb { color: #d88a14; }
@keyframes burst { 0% { opacity: 0; transform: scale(.4); } 18% { opacity: 1; transform: scale(1.12); } 30% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

.bc-comm { min-height: 3em; margin: 0; text-align: center; font-weight: 600; }
.bc-actions { display: flex; gap: 10px; }
.bc-actions .btn { flex: 1; }
.bc-main { min-height: 56px; font-size: 1.1rem; }
.bc-card { margin: 0; text-align: center; color: var(--muted); font-size: .88rem; }
.bc-link { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; text-decoration: underline; min-height: 36px; }

/* ================= Sudoku ================= */
.sd-label { margin: -4px 0 0; color: var(--muted); font-weight: 700; font-size: .9rem; }
.sd-board {
  display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); grid-template-rows: repeat(9, minmax(0, 1fr));
  aspect-ratio: 1; border: 2px solid var(--text); border-radius: 10px; overflow: hidden; background: var(--surface);
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.sd-cell {
  position: relative; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0;
  background: var(--surface); color: var(--g-sudoku); font-size: clamp(1.05rem, 5.6vw, 1.65rem); font-weight: 600;
  display: grid; place-items: center; cursor: pointer; min-width: 0; min-height: 0; font-variant-numeric: tabular-nums;
}
.sd-cell:nth-child(9n) { border-right: 0; }
.sd-cell:nth-child(n+73) { border-bottom: 0; }
.sd-cell.bR { border-right: 2px solid var(--text); }
.sd-cell.bB { border-bottom: 2px solid var(--text); }
.sd-cell.given { color: var(--text); font-weight: 800; }
.sd-cell.hinted { color: var(--good); font-weight: 800; }
.sd-cell.peer { background: var(--surface-2); }
.sd-cell.same { background: color-mix(in srgb, var(--g-sudoku) 18%, var(--surface)); }
.sd-cell.sel { background: color-mix(in srgb, var(--g-sudoku) 32%, var(--surface)); }
.sd-cell.err { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--surface)); }
.sd-cell.err.sel { background: color-mix(in srgb, var(--bad) 26%, var(--surface)); }
.sd-cell:focus-visible { outline: 3px solid var(--g-sudoku); outline-offset: -3px; border-radius: 0; }
.sd-cell.flash { animation: sdflash .6s ease; }
@keyframes sdflash { 40% { background: color-mix(in srgb, var(--good) 35%, var(--surface)); } }
.sd-board.won { animation: bump .5s ease; }
.sd-notes {
  display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; height: 100%; padding: 1px 2px;
  font-size: clamp(.5rem, 2.3vw, .72rem); font-weight: 600; color: var(--muted); line-height: 1;
}
.sd-notes span { display: grid; place-items: center; }
.sd-notes span.on { color: #fff; background: var(--g-sudoku); border-radius: 3px; }

.sd-tools { width: 100%; max-width: 520px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sd-tools .btn { padding: 0 6px; }
.sd-tools .btn.on { background: var(--g-sudoku); color: #fff; border-color: transparent; }
.sd-pad { width: 100%; max-width: 520px; display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 5px; }
.sd-pad button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px; min-height: 58px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; touch-action: manipulation;
  font-size: 1.5rem; font-weight: 700; color: var(--g-sudoku); box-shadow: var(--shadow); padding: 0;
}
.sd-pad button:active { transform: scale(.95); background: var(--surface-2); }
.sd-pad small { font-size: .66rem; color: var(--muted); font-weight: 700; min-height: 1em; }
.sd-pad button.done { opacity: .28; box-shadow: none; }
.sd-levels { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.sd-levels .seg button { padding: 0 10px; }

/* ================= Hit the Bear ================= */
.wb-stage { position: relative; }
.wb-board {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 3%;
  aspect-ratio: 1; padding: 4%; border-radius: 18px; touch-action: none; user-select: none; -webkit-user-select: none;
  background: radial-gradient(circle at 20% 15%, #9ad66b 0 18%, transparent 19%), radial-gradient(circle at 85% 80%, #8acb5c 0 14%, transparent 15%),
    linear-gradient(180deg, #86c95a, #5f9f3a);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .12), var(--shadow);
}
.wb-hole { position: relative; border: 0; padding: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.wb-hole::before {
  content: ""; position: absolute; left: 6%; right: 6%; bottom: 14%; height: 20%; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 35%, #2a1a10, #4a2e1a 70%);
}
.wb-mask { position: absolute; left: 10%; right: 10%; top: -12%; bottom: 22%; overflow: hidden; }
.wb-critter { position: absolute; inset: 0; transform: translateY(105%); transition: transform .15s ease-out; }
.wb-hole.up .wb-critter { transform: translateY(8%); }
.wb-hole.up.hit .wb-critter { transform: translateY(18%) scaleY(.86); transition: transform .08s ease-in; }
.wb-critter svg { display: block; width: 100%; height: 100%; overflow: visible; }
.wb-lip {
  position: absolute; left: 2%; right: 2%; bottom: 6%; height: 20%; border-radius: 50%;
  background: linear-gradient(180deg, #a0703f, #6e4524); box-shadow: 0 4px 0 rgba(0, 0, 0, .15);
}
.wb-hole.whiff .wb-lip { animation: shake .25s ease; }
.wb-fur { fill: var(--fur, #9a5b32); }
.wb-ear { fill: #e2aa78; }
.wb-muzzle { fill: #f3d3ae; }
.wb-ink { fill: #2a1a10; }
.wb-line { fill: none; stroke: #2a1a10; stroke-width: 3.5; stroke-linecap: round; }
.wb-eyes-hit, .wb-crown, .wb-bee { display: none; }
.wb-crown { fill: #ffd23f; stroke: #c8930c; stroke-width: 1.5; }
.wb-hole.golden { --fur: #e7a91e; }
.wb-hole.golden .wb-crown { display: inline; }
.wb-hole.golden .wb-critter { filter: drop-shadow(0 0 8px rgba(255, 215, 64, .9)); }
.wb-hole.hit .wb-eyes { display: none; }
.wb-hole.hit .wb-eyes-hit { display: inline; }
.wb-hole.bee .wb-bear { display: none; }
.wb-hole.bee svg.wb-bee { display: block; }
.wb-hole.bee.up:not(.hit) .wb-critter svg { animation: buzz .18s linear infinite alternate; }
@keyframes buzz { from { transform: translateX(-2px) rotate(-3deg); } to { transform: translateX(2px) rotate(3deg); } }
.wb-pop {
  position: absolute; left: 50%; top: 4%; z-index: 3; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  font-weight: 900; font-size: clamp(.95rem, 4.6vw, 1.35rem); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  animation: floatup .75s ease-out forwards;
}
.wb-pop.gold { color: #ffe066; }
.wb-pop.bad { color: #ff7070; }
.wb-pop.hot { color: #ffc27a; }
@keyframes floatup { from { opacity: 1; transform: translate(-50%, 0) scale(.9); } 30% { transform: translate(-50%, -18px) scale(1.15); } to { opacity: 0; transform: translate(-50%, -48px) scale(1); } }
.wb-overlay {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; text-align: center; border-radius: 18px; padding: 20px;
  background: color-mix(in srgb, var(--bg) 72%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.wb-overlay[hidden] { display: none; }
.wb-overlay p { color: var(--text); font-weight: 600; max-width: 30ch; margin: 6px auto 14px; }
.wb-combo { min-height: 1.5em; margin: 0; font-weight: 800; color: var(--muted); text-align: center; }
.wb-combo.hot { color: #e8712a; }

/* ================= Match the Tiles ================= */
.tt-board { position: relative; aspect-ratio: 7 / 8; width: 100%; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.tt-tile {
  position: absolute; width: calc(100% / 7); height: calc(100% / 8); padding: 0; border: 0; cursor: pointer;
  background: none; display: grid; place-items: center;
}
.tt-tile::before {
  content: ""; position: absolute; inset: 3%; border-radius: 16%;
  background: linear-gradient(180deg, #fffdf6, #f3ead4); border: 1px solid #d9cba6;
  box-shadow: 0 5px 0 #c8b68b, 0 7px 10px rgba(0, 0, 0, .18); transition: filter .2s;
}
.tt-tile span { position: relative; font-size: clamp(1.1rem, 7vw, 2rem); line-height: 1; transform: translateY(-2px); transition: filter .2s, opacity .2s; }
.tt-tile.blocked { cursor: default; }
.tt-tile.blocked::before { filter: brightness(.62) saturate(.7); }
.tt-tile.blocked span { filter: grayscale(.6) brightness(.65); }
.tt-tile.deal { animation: tdeal .4s cubic-bezier(.2, 1.3, .4, 1) backwards; }
@keyframes tdeal { from { opacity: 0; transform: translateY(-30px) scale(.5); } }
.tt-tile.taken { visibility: hidden; }
.tt-tile.nope { animation: shake .3s ease; }
.tt-tile.back { animation: pop .3s ease; }
.tt-tile.spin { animation: tspin .45s ease; }
@keyframes tspin { 50% { transform: rotateY(90deg) scale(.9); } }
.tt-tile:not(.blocked):active::before { filter: brightness(1.06); }
.tt-fly {
  position: fixed; z-index: 80; display: grid; place-items: center; pointer-events: none; border-radius: 16%;
  background: linear-gradient(180deg, #fffdf6, #f3ead4); border: 1px solid #d9cba6; box-shadow: 0 8px 18px rgba(0, 0, 0, .25);
  font-size: clamp(1.1rem, 7vw, 2rem);
}
.tt-tray {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; padding: 7px; border-radius: 16px; width: 100%;
  background: linear-gradient(180deg, #8a5a33, #6b4224); box-shadow: inset 0 3px 6px rgba(0, 0, 0, .35), var(--shadow);
  transition: box-shadow .2s;
}
.tt-tray.danger { box-shadow: inset 0 3px 6px rgba(0, 0, 0, .35), 0 0 0 3px var(--bad); }
.tt-tray.shake { animation: shake .4s ease; }
.tt-slot { aspect-ratio: 1; border-radius: 10px; background: rgba(0, 0, 0, .22); display: grid; place-items: center; }
.tt-in {
  width: 100%; height: 100%; display: grid; place-items: center; border-radius: 10px; font-size: clamp(1rem, 6vw, 1.7rem);
  background: linear-gradient(180deg, #fffdf6, #f3ead4); box-shadow: 0 3px 0 #c8b68b; animation: pop .18s ease;
}
.tt-in.incoming { visibility: hidden; }
.tt-in.clear { animation: tclear .26s ease forwards; }
@keyframes tclear { 40% { transform: scale(1.25); } to { transform: scale(0); opacity: 0; } }
.tt-tools { width: 100%; max-width: 520px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ================= Basketball ================= */
.bb-stage { position: relative; }
.bb-canvas { display: block; width: 100%; aspect-ratio: 2 / 3; border-radius: 16px; touch-action: none; background: #1b2238; }
.bb-overlay {
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; text-align: center; border-radius: 16px; padding: 20px;
  background: rgba(10, 12, 24, .55); color: #fff;
}
.bb-overlay[hidden] { display: none; }
.bb-overlay p { font-weight: 600; max-width: 30ch; margin: 6px auto 14px; color: #e8ebf5; }
.bb-board-wrap { width: min(92vw, 440px, calc((100dvh - 230px) * 2 / 3)); min-width: 250px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media (max-width: 420px) {
  .stat { min-width: 60px; padding: 4px 8px; }
  .game-shell h1 { font-size: 1.15rem; }
}
