/* ArcadeX — Dark Neo-Brutalism design system */
:root {
  --bg: #0a0b10;
  --bg-2: #12131a;
  --card: #1a1c26;
  --card-2: #222533;
  --line: #2e3245;
  --ink: #f4f5fb;
  --muted: #8b90a8;
  --lime: #10b981;
  --cyan: #06b6d4;
  --pink: #f43f5e;
  --amber: #f59e0b;
  --violet: #a78bfa;
  --border: 2.5px solid var(--line);
  --shadow: 4px 4px 0 #000;
  --shadow-lg: 6px 6px 0 #000;
  --radius: 14px;
  --font: "Space Grotesk", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ad-top-h: 50px;
  --ad-bottom-h: 50px;
  --header-h: 60px;
}
@media (min-width: 768px) {
  :root { --ad-top-h: 90px; --ad-bottom-h: 90px; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% -10%, rgba(6, 182, 212, 0.12), transparent 40%),
    radial-gradient(circle at 110% 30%, rgba(244, 63, 94, 0.1), transparent 40%),
    linear-gradient(var(--bg), var(--bg-2));
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--ad-bottom-h) + 16px + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}
body.in-game { overflow: hidden; position: fixed; inset: 0; width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Brutal primitives ---------- */
.brutal-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  background: var(--card); border: var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.85rem;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
  user-select: none; -webkit-user-select: none;
}
.brutal-btn:active, .brutal-btn.pressed { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.brutal-btn.lime { background: var(--lime); color: #04120c; border-color: #000; }
.brutal-btn.cyan { background: var(--cyan); color: #021317; border-color: #000; }
.brutal-btn.pink { background: var(--pink); color: #1a0308; border-color: #000; }
.brutal-btn.amber { background: var(--amber); color: #1a1003; border-color: #000; }
.brutal-btn[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: var(--shadow); }

/* ---------- Header ---------- */
.top-stack { position: sticky; top: 0; z-index: 40; }
.site-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: rgba(10, 11, 16, 0.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; }
.logo-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--lime); color: #04120c; border: 2.5px solid #000; border-radius: 10px;
  box-shadow: 3px 3px 0 #000; font-weight: 900; font-size: 1.3rem; transform: rotate(-6deg);
}
.logo-text { font-weight: 900; font-size: 1.35rem; letter-spacing: -0.02em; text-transform: uppercase; }
.logo-text span { color: var(--pink); }
.live-badge {
  font-size: 0.6rem; font-weight: 800; letter-spacing: 0.1em; padding: 3px 7px; border-radius: 99px;
  border: 2px solid var(--cyan); color: var(--cyan);
  animation: glow 1.8s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 4px rgba(6, 182, 212, 0.5), inset 0 0 4px rgba(6, 182, 212, 0.3); }
  50% { box-shadow: 0 0 14px rgba(6, 182, 212, 0.95), inset 0 0 8px rgba(6, 182, 212, 0.5); }
}
.hdr-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px;
  background: var(--card); border: var(--border); border-radius: 10px; box-shadow: 3px 3px 0 #000;
  font-weight: 800; font-size: 0.85rem;
}
.hdr-chip .trophy { color: var(--amber); }
@media (max-width: 359px) { .live-badge { display: none; } .logo-text { font-size: 1.15rem; } }
.sound-btn { width: 44px; height: 40px; padding: 0; min-height: 0; }
.sound-btn svg { width: 22px; height: 22px; }
.sound-btn[aria-pressed="true"] { background: var(--pink); color: #1a0308; border-color: #000; }

/* ---------- Ads ---------- */
.ad-frame {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(-45deg, #11131b, #11131b 10px, #151722 10px, #151722 20px);
  border: 2px dashed #3a3f57;
  color: #5c627c; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  overflow: hidden;
}
.ad-frame::before {
  content: "AD"; position: absolute; top: 3px; left: 4px; font-size: 0.55rem;
  padding: 1px 4px; border-radius: 3px; background: #2e3245; color: #9aa0bb;
}
.ad-banner-wrap { display: flex; justify-content: center; background: var(--bg); border-bottom: var(--border); padding: 0; }
#ad-top-banner { width: 320px; height: 50px; }
#ad-bottom-banner-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  display: flex; justify-content: center;
  background: var(--bg); border-top: var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
#ad-bottom-banner { width: 320px; height: 50px; }
@media (min-width: 768px) {
  #ad-top-banner, #ad-bottom-banner { width: 728px; height: 90px; }
}

/* ---------- Home ---------- */
main.home { max-width: 1180px; margin: 0 auto; padding: 18px 14px 10px; }
.hero { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.hero h1 {
  margin: 0; font-size: clamp(2rem, 7vw, 3.6rem); line-height: 0.95; font-weight: 900;
  text-transform: uppercase; letter-spacing: -0.03em;
}
.hero h1 em { font-style: normal; color: var(--lime); text-shadow: 3px 3px 0 #000; }
.hero p { margin: 8px 0 0; color: var(--muted); max-width: 520px; font-size: 0.98rem; }
.hero-tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag {
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 8px; border: 2px solid #000; border-radius: 6px; box-shadow: 2px 2px 0 #000;
}

.bento {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(158px, auto);
  grid-auto-flow: dense;
  gap: 14px;
}
@media (min-width: 760px) {
  .bento { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; grid-auto-rows: minmax(170px, auto); }
}
.span-2x2 { grid-column: span 2; grid-row: span 2; }
.span-2x1 { grid-column: span 2; }

.game-card {
  --accent: var(--lime);
  position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: 14px; min-width: 0;
  background: var(--card); border: var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none; overflow: hidden; isolation: isolate;
  transition: transform 0.12s, box-shadow 0.12s, border-color 0.12s;
}
.game-card:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.game-card:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.game-card .card-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.game-card .num { font-size: 0.7rem; font-weight: 800; color: var(--muted); letter-spacing: 0.08em; }
.game-card .tag { background: var(--accent); color: #000; }
.game-card .art {
  flex: 1; display: grid; place-items: center; min-height: 60px; position: relative;
}
.game-card .art svg { width: 100%; height: 100%; max-height: 120px; overflow: visible; }
.span-2x2 .art svg { max-height: 260px; }
.game-card h3 { margin: 0; font-size: 1.05rem; font-weight: 900; text-transform: uppercase; letter-spacing: -0.01em; line-height: 1.05; }
.span-2x2 h3 { font-size: clamp(1.4rem, 4vw, 2rem); }
.game-card .desc { margin: 0; font-size: 0.78rem; color: var(--muted); line-height: 1.35; }
.game-card .card-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 4px; }
.game-card .best { font-size: 0.72rem; font-weight: 800; color: var(--accent); letter-spacing: 0.04em; }
.game-card .play {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  background: var(--accent); color: #000; border: 2px solid #000; border-radius: 9px; box-shadow: 2px 2px 0 #000;
  font-weight: 900;
}
.span-2x2 .play { width: auto; padding: 0 14px; font-size: 0.85rem; letter-spacing: 0.05em; }
.game-card::after {
  content: ""; position: absolute; inset: auto -40% -60% auto; width: 80%; aspect-ratio: 1; z-index: -1;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 65%);
}
.c-lime { --accent: var(--lime); }
.c-cyan { --accent: var(--cyan); }
.c-pink { --accent: var(--pink); }
.c-amber { --accent: var(--amber); }
.c-violet { --accent: var(--violet); }

.ad-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; background: var(--card); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.ad-card .ad-label { font-size: 0.62rem; font-weight: 800; letter-spacing: 0.16em; color: var(--muted); text-transform: uppercase; }
#ad-bento-slot { width: 300px; height: 250px; max-width: 100%; }

.info-strip {
  margin: 26px 0 8px; display: grid; gap: 14px; grid-template-columns: 1fr;
}
@media (min-width: 760px) { .info-strip { grid-template-columns: repeat(3, 1fr); } }
.info-strip article {
  background: var(--card); border: var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.info-strip h2 { margin: 0 0 6px; font-size: 0.95rem; text-transform: uppercase; font-weight: 900; }
.info-strip p { margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; }

.site-footer {
  max-width: 1180px; margin: 26px auto 0; padding: 18px 14px 22px;
  border-top: var(--border);
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: 0.82rem;
}
.site-footer nav { display: flex; gap: 16px; flex-wrap: wrap; }
.site-footer nav a { font-weight: 800; text-decoration: none; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink); }
.site-footer nav a:hover { color: var(--lime); }

/* ---------- Game View ---------- */
#game-view {
  position: fixed; left: 0; right: 0; top: 0;
  bottom: calc(var(--ad-bottom-h) + env(safe-area-inset-bottom));
  z-index: 50;
  display: none; flex-direction: column;
  background: radial-gradient(circle at 50% 0%, #161927, var(--bg) 70%);
  touch-action: none; overscroll-behavior: none;
}
#game-view.open { display: flex; animation: viewIn 0.18s ease-out; }
@keyframes viewIn { from { opacity: 0; transform: scale(0.98); } }
.gv-bar {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top));
  border-bottom: var(--border); background: rgba(10, 11, 16, 0.95);
}
.gv-bar .title { font-weight: 900; text-transform: uppercase; font-size: 0.95rem; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gv-stat { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 58px; height: 40px; padding: 0 8px; background: var(--card); border: var(--border); border-radius: 9px; }
.gv-stat small { font-size: 0.55rem; letter-spacing: 0.12em; color: var(--muted); font-weight: 800; }
.gv-stat b { font-size: 0.95rem; line-height: 1; }
#gv-score { color: var(--lime); }
.icon-btn { width: 42px; padding: 0; min-height: 40px; height: 40px; }
#game-stage {
  position: relative; flex: 1; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 10px; overflow: hidden; touch-action: none;
}
#game-controls {
  flex: none; display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 10px 12px 12px; touch-action: none; user-select: none; -webkit-user-select: none;
}
#game-controls:empty { display: none; }
.game-canvas {
  display: block; background: #07080c; border: var(--border); border-radius: 12px; box-shadow: var(--shadow);
  touch-action: none; image-rendering: auto;
}
.toast {
  position: absolute; left: 50%; top: 22%; z-index: 5; pointer-events: none;
  transform: translate(-50%, 0) rotate(-4deg);
  padding: 10px 18px; background: var(--amber); color: #000; border: 3px solid #000; border-radius: 10px; box-shadow: var(--shadow);
  font-weight: 900; font-size: clamp(1.1rem, 5vw, 1.6rem); text-transform: uppercase; white-space: nowrap;
  animation: toast 1.4s ease-out forwards;
}
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 20px) rotate(-4deg) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, 0) rotate(-4deg) scale(1.08); }
  25% { transform: translate(-50%, 0) rotate(-4deg) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -20px) rotate(-4deg); }
}

/* Virtual controls */
.ctl {
  display: grid; place-items: center;
  min-width: 64px; height: 64px; padding: 0 14px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  font-weight: 900; font-size: 1.05rem; letter-spacing: 0.05em; text-transform: uppercase;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 0.06s, box-shadow 0.06s;
}
.ctl svg { width: 28px; height: 28px; pointer-events: none; }
.ctl.pressed { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; background: var(--card-2); }
.ctl.big { flex: 1; max-width: 420px; height: 76px; font-size: 1.4rem; background: var(--lime); color: #04120c; border-color: #000; }
.ctl.big.pink { background: var(--pink); color: #1a0308; }
.ctl.big.cyan { background: var(--cyan); color: #021317; }
.ctl.wide { flex: 1; max-width: 200px; height: 80px; }
.ctl.boost { width: 84px; height: 84px; border-radius: 50%; background: var(--amber); color: #000; border-color: #000; font-size: 0.85rem; }
.dpad { display: grid; grid-template-columns: repeat(3, 60px); grid-template-rows: repeat(3, 60px); gap: 6px; }
.dpad .ctl { min-width: 0; width: 60px; height: 60px; padding: 0; }
.dpad .up { grid-area: 1 / 2; } .dpad .left { grid-area: 2 / 1; } .dpad .right { grid-area: 2 / 3; } .dpad .down { grid-area: 3 / 2; }
.dpad .hub { grid-area: 2 / 2; border-radius: 50%; background: #0d0e14; border: 2px dashed var(--line); }
@media (max-height: 700px) {
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); }
  .dpad .ctl { width: 52px; height: 52px; }
  .ctl.big { height: 64px; }
  .ctl.wide { height: 66px; }
}

/* ---------- Game Over Modal ---------- */
#gameover-ad-modal {
  position: fixed; inset: 0; z-index: 80;
  display: none; align-items: center; justify-content: center;
  padding: 14px; background: rgba(5, 6, 10, 0.82); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
}
#gameover-ad-modal.open { display: flex; }
.go-panel {
  width: min(360px, 100%); margin: auto;
  background: var(--card); border: 3px solid #000; border-radius: 18px; box-shadow: 8px 8px 0 #000;
  padding: 16px; text-align: center; animation: pop 0.25s cubic-bezier(.2,1.6,.4,1);
  outline: 2.5px solid var(--line); outline-offset: -6px;
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } }
.go-title {
  display: inline-block; margin: 2px 0 10px; padding: 6px 14px;
  font-size: 1.6rem; font-weight: 900; text-transform: uppercase; letter-spacing: -0.01em;
  background: var(--pink); color: #000; border: 3px solid #000; border-radius: 10px; box-shadow: var(--shadow); transform: rotate(-2deg);
}
.go-panel.win .go-title { background: var(--lime); }
.go-panel.draw .go-title { background: var(--amber); }
.go-score-label { font-size: 0.65rem; font-weight: 800; letter-spacing: 0.16em; color: var(--muted); }
.go-score { font-size: 2.6rem; font-weight: 900; line-height: 1; margin: 2px 0 4px; }
.go-detail { font-size: 0.82rem; color: var(--muted); margin: 0 0 6px; min-height: 1em; }
.go-newbest {
  display: none; margin: 0 auto 8px; width: max-content; padding: 3px 10px; font-size: 0.72rem; font-weight: 900; letter-spacing: 0.1em;
  background: var(--amber); color: #000; border: 2px solid #000; border-radius: 6px; animation: glowAmber 1s infinite;
}
.go-newbest.show { display: block; }
@keyframes glowAmber { 50% { box-shadow: 0 0 16px var(--amber); } }
#gameover-ad-slot { width: 300px; height: 250px; max-width: 100%; margin: 8px auto 12px; }
.go-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.go-actions .brutal-btn { min-height: 52px; font-size: 0.95rem; }
@media (max-height: 640px) {
  #gameover-ad-slot { transform: scale(0.8); margin: -18px auto -14px; }
}

/* ---------- DOM games shared ---------- */
.gpanel { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 460px; }
.seg { display: flex; gap: 8px; width: 100%; }
.seg .brutal-btn { flex: 1; min-height: 42px; font-size: 0.75rem; padding: 0 8px; }
.seg .brutal-btn.active { background: var(--cyan); color: #000; border-color: #000; }
.tally { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.tally div { background: var(--card); border: var(--border); border-radius: 10px; padding: 6px; text-align: center; }
.tally small { display: block; font-size: 0.6rem; font-weight: 800; letter-spacing: 0.12em; color: var(--muted); }
.tally b { font-size: 1.2rem; }
.turn-line { font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.95rem; min-height: 1.3em; }

/* Tic-Tac-Toe */
.ttt-board {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  width: min(100%, 52vh, 400px); aspect-ratio: 1;
}
.ttt-cell {
  display: grid; place-items: center; aspect-ratio: 1;
  background: var(--card); border: var(--border); border-radius: 14px; box-shadow: var(--shadow);
  font-size: clamp(2.6rem, 12vw, 4.6rem); font-weight: 900; line-height: 1;
}
.ttt-cell:active:not([disabled]) { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
.ttt-cell.x { color: var(--pink); text-shadow: 0 0 18px rgba(244, 63, 94, 0.7); }
.ttt-cell.o { color: var(--cyan); text-shadow: 0 0 18px rgba(6, 182, 212, 0.7); }
.ttt-cell.mark { animation: pop 0.2s cubic-bezier(.2,1.6,.4,1); }
.ttt-cell.win { background: var(--lime); color: #000; text-shadow: none; border-color: #000; }

/* 2048 */
.g2048-board {
  position: relative; width: min(100%, 56vh, 440px); aspect-ratio: 1;
  background: #0d0e15; border: 3px solid #000; outline: 2.5px solid var(--line); outline-offset: -7px;
  border-radius: 16px; box-shadow: var(--shadow-lg); touch-action: none;
}
.g2048-cell, .g2048-tile {
  position: absolute; width: 21.25%; height: 21.25%; border-radius: 10px;
}
.g2048-cell { background: #171925; border: 2px solid #232636; }
.g2048-tile {
  display: grid; place-items: center; font-weight: 900; color: #000;
  border: 2.5px solid #000; box-shadow: 3px 3px 0 #000;
  transition: left 0.11s ease-out, top 0.11s ease-out;
  font-size: clamp(1.1rem, 6vw, 2.2rem); z-index: 1;
}
.g2048-tile.new { animation: tileIn 0.18s ease-out; }
.g2048-tile.merged { animation: tileMerge 0.18s ease-out; z-index: 2; }
@keyframes tileIn { from { transform: scale(0.1); opacity: 0; } }
@keyframes tileMerge { 50% { transform: scale(1.18); } }

/* Reflex */
.reflex-pad {
  width: min(78vw, 46vh, 330px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, #fb7185, var(--pink) 45%, #9f1239);
  border: 4px solid #000; box-shadow: 8px 8px 0 #000, 0 0 50px rgba(244, 63, 94, 0.4);
  font-weight: 900; font-size: clamp(1.4rem, 7vw, 2.4rem); color: #fff; text-shadow: 3px 3px 0 #000;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.reflex-pad.hit { transform: translate(4px, 4px) scale(0.97); box-shadow: 3px 3px 0 #000, 0 0 70px rgba(244, 63, 94, 0.7); }
.reflex-pad.done { filter: grayscale(0.8); }
.reflex-pad small { display: block; font-size: 0.45em; letter-spacing: 0.12em; opacity: 0.9; }
.meter { width: 100%; height: 16px; background: var(--card); border: var(--border); border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--lime), var(--amber), var(--pink)); transform-origin: left; }

/* Memory */
.mem-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: min(100%, 58vh, 440px); }
.mem-card { aspect-ratio: 1; perspective: 600px; background: none; border: 0; padding: 0; }
.mem-inner { position: relative; width: 100%; height: 100%; transition: transform 0.35s; transform-style: preserve-3d; }
.mem-card.flip .mem-inner, .mem-card.done .mem-inner { transform: rotateY(180deg); }
.mem-face {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 12px;
  border: 2.5px solid #000; box-shadow: 3px 3px 0 #000; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.mem-back {
  background: repeating-linear-gradient(45deg, #1d2030, #1d2030 6px, #23263a 6px, #23263a 12px);
  color: var(--violet); font-weight: 900; font-size: clamp(1.2rem, 6vw, 2rem);
}
.mem-front { background: var(--card-2); transform: rotateY(180deg); font-size: clamp(1.8rem, 9vw, 3rem); }
.mem-card.done .mem-front { background: var(--lime); }
.mem-card.bad .mem-front { background: var(--pink); }

/* Connect 4 */
.c4-wrap { width: min(100%, 470px, 62vh); }
.c4-board {
  position: relative; display: grid; grid-template-columns: repeat(7, 1fr); gap: 0;
  padding: 6px; background: #1b2a6b; background: linear-gradient(#1e2a78, #151d52);
  border: 3px solid #000; border-radius: 14px; box-shadow: var(--shadow-lg);
}
.c4-col { display: grid; grid-template-rows: repeat(6, 1fr); background: none; border: 0; padding: 0; border-radius: 8px; }
.c4-col:hover:not([disabled]), .c4-col.hover { background: rgba(255, 255, 255, 0.06); }
.c4-slot { aspect-ratio: 1; display: grid; place-items: center; padding: 9%; }
.c4-hole { width: 100%; height: 100%; border-radius: 50%; background: #07080c; box-shadow: inset 2px 3px 0 #000; position: relative; overflow: visible; }
.c4-disc {
  position: absolute; inset: 0; border-radius: 50%; border: 2.5px solid #000;
  animation: drop var(--dur, 0.35s) cubic-bezier(.45, 0, .7, 1.3);
}
.c4-disc.p { background: radial-gradient(circle at 35% 30%, #fda4af, var(--pink) 55%); }
.c4-disc.c { background: radial-gradient(circle at 35% 30%, #fde68a, var(--amber) 55%); }
.c4-disc.win { box-shadow: 0 0 0 3px #fff, 0 0 18px #fff; }
@keyframes drop { from { transform: translateY(var(--from, -400%)); } }

/* Fit DOM boards to the available stage (container query units, vh fallbacks above) */
#game-stage { container-type: size; }
@supports (width: 1cqh) {
  .ttt-board { width: min(100cqw, 100cqh - 180px, 400px); }
  .g2048-board { width: min(100cqw - 8px, 100cqh - 48px, 440px); }
  .mem-board { width: min(100cqw, 100cqh - 76px, 440px); }
  .c4-wrap { width: min(100cqw, (100cqh - 120px) * 7 / 6, 470px); max-width: none; }
  .reflex-pad { width: min(78cqw, 100cqh - 170px, 330px); }
}

/* Generic overlay text in DOM stage */
.hint { color: var(--muted); font-size: 0.8rem; text-align: center; font-weight: 700; }

/* ---------- Legal pages ---------- */
.legal { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.legal h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); text-transform: uppercase; font-weight: 900; margin: 6px 0 4px; }
.legal h2 { font-size: 1.05rem; text-transform: uppercase; margin: 26px 0 6px; color: var(--lime); }
.legal p, .legal li { color: #c3c7da; line-height: 1.65; font-size: 0.95rem; }
.legal .card { background: var(--card); border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

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