/* ── tokens ──────────────────────────────────────────────── */
:root {
  --bg: #eef1f4;
  --ink: #17191f;
  --muted: #68707c;
  --line: #d8dde5;
  --panel: #fbfcfd;
  --panel-strong: #ffffff;
  --rail: #16181d;
  --rail-soft: #232731;
  --teal: #00a676;
  --coral: #f25c54;
  --yellow: #f4d35e;
  --indigo: #4957d8;
  --lime: #8bc34a;
  --correct: #008761;
  --error: #d8443e;
  --close: #d59a13;
  --selected: #2563eb;
  --shadow: 0 18px 50px rgba(18, 22, 30, 0.12);
  --accent: #4957d8;
}

/* ── per-game accent palette ─────────────────────────────── */
body[data-game="hub"]       { --accent: #4957d8; }
body[data-game="snake"]     { --accent: #16a34a; }
body[data-game="memory"]    { --accent: #7c3aed; }
body[data-game="tetris"]    { --accent: #0891b2; }
body[data-game="poople"]    { --accent: #d97706; }
body[data-game="angle"]     { --accent: #2563eb; }
body[data-game="connect4"]  { --accent: #dc2626; }
body[data-game="world"]     { --accent: #0d9488; }
body[data-game="shape"]     { --accent: #0284c7; }
body[data-game="tictactoe"] { --accent: #9333ea; }
body[data-game="target"]    { --accent: #e11d48; }

/* ── base ────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

/* ── shell ───────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  min-height: 100vh;
}

/* ── sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 14px;
  background: var(--rail);
  color: #fff;
}

.brand-button {
  display: inline-grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--coral));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.brand-mark {
  font-size: 1.05rem;
  font-weight: 900;
}

.game-menu {
  display: grid;
  gap: 4px;
}

.nav-divider {
  margin: 10px 0 4px;
  padding: 0 10px;
  color: rgba(255, 255, 255, 0.32);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  cursor: pointer;
  text-align: left;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.nav-item:hover,
.nav-item:focus-visible {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--rail-soft);
  color: rgba(255, 255, 255, 0.88);
}

.nav-item.is-active {
  border-color: color-mix(in srgb, var(--selected) 62%, transparent);
  background: color-mix(in srgb, var(--selected) 18%, transparent);
  color: #fff;
}

.nav-glyph {
  position: relative;
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.hub-glyph::before,
.hub-glyph::after {
  position: absolute;
  content: "";
  width: 8px;
  height: 8px;
  background: var(--yellow);
  box-shadow: 12px 0 var(--teal), 0 12px var(--coral), 12px 12px var(--indigo);
  left: 4px;
  top: 4px;
}

.snake-glyph::before {
  position: absolute;
  content: "";
  width: 8px;
  height: 8px;
  left: 4px;
  top: 13px;
  border-radius: 3px;
  background: var(--teal);
  box-shadow: 8px 0 var(--teal), 16px -8px var(--teal), 16px 0 var(--yellow);
}

.memory-glyph::before,
.memory-glyph::after {
  position: absolute;
  content: "";
  width: 9px;
  height: 12px;
  top: 8px;
  border-radius: 3px;
}

.tetris-glyph::before {
  position: absolute;
  content: "";
  width: 6px;
  height: 6px;
  left: 4px;
  top: 4px;
  border-radius: 1px;
  background: #31c7ef;
  box-shadow:
    7px 0 #31c7ef,
    14px 0 #31c7ef,
    7px 7px var(--yellow),
    14px 7px var(--yellow),
    7px 14px var(--coral),
    14px 14px var(--coral);
}

.memory-glyph::before {
  left: 5px;
  background: var(--coral);
  transform: rotate(-8deg);
}

.memory-glyph::after {
  right: 5px;
  background: var(--yellow);
  transform: rotate(8deg);
}

.poople-glyph::before,
.poople-glyph::after {
  position: absolute;
  content: "";
}

.poople-glyph::before {
  width: 8px;
  height: 8px;
  left: 4px;
  top: 5px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 10px 3px var(--coral), 4px 13px var(--yellow), 15px 14px var(--lime);
}

.poople-glyph::after {
  width: 5px;
  height: 5px;
  right: 5px;
  top: 5px;
  border-radius: 50%;
  background: var(--indigo);
}

.angle-glyph::before,
.angle-glyph::after {
  position: absolute;
  content: "";
  left: 5px;
  bottom: 7px;
  width: 17px;
  height: 3px;
  border-radius: 999px;
  background: var(--yellow);
  transform-origin: left center;
}

.angle-glyph::after {
  background: var(--teal);
  transform: rotate(-46deg);
}

.angle-glyph {
  background:
    radial-gradient(circle at 5px 21px, var(--coral) 0 4px, transparent 5px),
    rgba(255, 255, 255, 0.08);
}

.connect-glyph {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  padding: 4px;
}

.connect-glyph::before,
.connect-glyph::after {
  content: "";
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 8px 0 var(--yellow), 16px 0 var(--coral), 0 8px var(--yellow), 8px 8px var(--coral), 16px 8px var(--yellow), 0 16px var(--coral), 8px 16px var(--yellow), 16px 16px var(--coral);
}

.connect-glyph::after {
  display: none;
}

.world-glyph::before,
.world-glyph::after {
  position: absolute;
  content: "";
  border-radius: 50%;
}

.world-glyph::before {
  inset: 5px;
  border: 3px solid var(--teal);
  background:
    radial-gradient(circle at 38% 36%, var(--yellow) 0 3px, transparent 4px),
    radial-gradient(circle at 62% 60%, var(--coral) 0 3px, transparent 4px);
}

.world-glyph::after {
  left: 7px;
  right: 7px;
  top: 12px;
  height: 2px;
  background: var(--teal);
}

.shape-glyph::before,
.shape-glyph::after {
  position: absolute;
  content: "";
}

.shape-glyph::before {
  left: 5px;
  top: 4px;
  width: 15px;
  height: 18px;
  border-radius: 45% 55% 40% 60%;
  background: var(--yellow);
  clip-path: polygon(31% 0, 74% 8%, 98% 42%, 80% 84%, 42% 100%, 9% 76%, 0 34%);
  transform: rotate(-16deg);
}

.shape-glyph::after {
  right: 5px;
  top: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: -12px 14px var(--teal);
}

.ttt-glyph {
  background:
    linear-gradient(90deg, transparent 30%, rgba(255, 255, 255, 0.5) 30% 36%, transparent 36% 64%, rgba(255, 255, 255, 0.5) 64% 70%, transparent 70%),
    linear-gradient(0deg, transparent 30%, rgba(255, 255, 255, 0.5) 30% 36%, transparent 36% 64%, rgba(255, 255, 255, 0.5) 64% 70%, transparent 70%),
    rgba(255, 255, 255, 0.08);
}

.ttt-glyph::before {
  position: absolute;
  content: "X";
  left: 5px;
  top: 1px;
  color: var(--teal);
  font-weight: 900;
}

.ttt-glyph::after {
  position: absolute;
  content: "O";
  right: 4px;
  bottom: 0;
  color: var(--coral);
  font-weight: 900;
}

.target-glyph::before,
.target-glyph::after {
  position: absolute;
  content: "";
  border-radius: 50%;
}

.target-glyph::before {
  inset: 5px;
  border: 4px solid var(--coral);
}

.target-glyph::after {
  inset: 11px;
  background: var(--yellow);
}

/* ── main stage ──────────────────────────────────────────── */
.main-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  padding: 20px clamp(20px, 3vw, 42px) 32px;
}

/* ── topbar (compact, inline metrics) ───────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.08;
}

h2 {
  font-size: 1rem;
  line-height: 1.2;
}

/* ── metrics (inline pills) ──────────────────────────────── */
.metrics {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 6px;
}

body[data-game="hub"] .metrics {
  display: none;
}

.metric {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border-left: 1px solid var(--line);
  padding: 2px 14px;
}

.metric span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.metric strong {
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── toolbar ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex: 0 0 auto;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.icon-button[hidden] {
  display: none;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── content grid ────────────────────────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}

.content-grid.no-context {
  grid-template-columns: minmax(0, 1fr);
}

.content-grid.no-context .context-panel {
  display: none;
}

.context-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.game-panel {
  min-width: 0;
  min-height: 520px;
  padding: 8px 0 28px;
}

.context-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: start;
  padding: 18px;
}

/* ── hub layout ──────────────────────────────────────────── */
.hub-sections {
  display: grid;
  gap: 28px;
}

.hub-section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.hub-section-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
}

.hub-section-kicker {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hub-section-desc {
  color: var(--muted);
  font-size: 0.8rem;
}

.hub-grid--quick {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.hub-grid--deep {
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  gap: 14px;
}

/* ── game cards ──────────────────────────────────────────── */
.game-card {
  display: grid;
  grid-template-rows: 140px auto auto;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-strong);
  transition: border-color 100ms ease;
}

.hub-grid--deep .game-card {
  grid-template-rows: 160px auto auto;
}

.game-card:hover {
  border-color: color-mix(in srgb, var(--selected) 42%, var(--line));
}

.game-card .play-button {
  width: 100%;
}

.game-card h2 {
  margin-bottom: 2px;
  font-size: 0.98rem;
  font-weight: 800;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.last-played {
  margin-left: auto;
  color: var(--selected);
  font-weight: 800;
}

.card-meta .genre-tag {
  display: inline-block;
  padding: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.play-button,
.mode-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  transition: background 140ms ease;
}

.play-button:hover,
.play-button:focus-visible {
  background: color-mix(in srgb, var(--accent) 82%, var(--ink));
}

.mode-button {
  background: var(--panel-strong);
  color: var(--ink);
  border-color: var(--line);
}

.mode-button:hover,
.mode-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.mode-button.is-active {
  background: var(--selected);
  color: #fff;
  border-color: var(--selected);
}

.play-button:disabled,
.mode-button:disabled {
  cursor: default;
  opacity: 0.55;
}

.game-preview {
  position: relative;
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #111418;
}

/* ── game preview thumbnails ─────────────────────────────── */
.preview-snake {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.07) 1px, transparent 1px),
    #111418;
  background-size: 24px 24px;
}

.preview-snake::before {
  position: absolute;
  content: "";
  width: 24px;
  height: 24px;
  left: 42px;
  top: 58px;
  border-radius: 6px;
  background: var(--teal);
  box-shadow: 24px 0 var(--teal), 48px 0 var(--teal), 72px -24px var(--teal), 96px -24px var(--yellow);
}

.preview-memory {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 14px;
  background: #f8fafc;
}

.preview-memory span {
  border-radius: 6px;
  background: var(--indigo);
}

.preview-memory span:nth-child(2),
.preview-memory span:nth-child(7) {
  background: var(--coral);
}

.preview-memory span:nth-child(5),
.preview-memory span:nth-child(12) {
  background: var(--yellow);
}

.preview-memory span:nth-child(9),
.preview-memory span:nth-child(14) {
  background: var(--teal);
}

.preview-tetris {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 2px;
  padding: 10px;
}

.preview-tetris span {
  min-width: 0;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.055);
}

.preview-tetris span.is-i { background: #31c7ef; }
.preview-tetris span.is-t { background: #9b5de5; }
.preview-tetris span.is-o { background: var(--yellow); }
.preview-tetris span.is-l { background: #f29d38; }

.preview-poople {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(0, 166, 118, 0.12), rgba(242, 92, 84, 0.12)),
    #f8fafc;
}

.preview-poople span {
  display: grid;
  place-items: center;
  min-width: 0;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 900;
}

.preview-poople span:nth-child(9),
.preview-poople span:nth-child(14),
.preview-poople span:nth-child(15) {
  border-color: rgba(0, 166, 118, 0.34);
  background: rgba(0, 166, 118, 0.13);
}

.preview-angle {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    #15191f;
  background-size: 28px 28px;
}

.preview-angle::before,
.preview-angle::after,
.preview-angle span {
  position: absolute;
  content: "";
  left: 34px;
  bottom: 34px;
  border-radius: 999px;
  transform-origin: left center;
}

.preview-angle::before {
  width: 110px;
  height: 5px;
  background: var(--yellow);
}

.preview-angle::after {
  width: 98px;
  height: 5px;
  background: var(--teal);
  transform: rotate(-58deg);
}

.preview-angle span {
  width: 46px;
  height: 46px;
  border: 4px solid var(--coral);
  border-left-color: transparent;
  border-bottom-color: transparent;
  transform: translateY(23px) rotate(-58deg);
}

.preview-connect {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 12px;
  background: #15191f;
}

.preview-connect span {
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.preview-connect span.is-coral {
  background: var(--coral);
}

.preview-connect span.is-yellow {
  background: var(--yellow);
}

.preview-world {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 14px;
  background:
    radial-gradient(circle at 50% 50%, rgba(0, 166, 118, 0.26) 0 44%, transparent 45%),
    linear-gradient(135deg, #17202b, #111418);
}

.preview-world span {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.11);
}

.preview-world span::before {
  position: absolute;
  content: "";
  left: 0;
  top: 0;
  bottom: 0;
  width: 70%;
  background: var(--teal);
}

.preview-world span:nth-child(2)::before,
.preview-world span:nth-child(5)::before {
  width: 46%;
  background: var(--yellow);
}

.preview-world span:nth-child(3)::before,
.preview-world span:nth-child(6)::before {
  width: 28%;
  background: var(--coral);
}

.preview-shape {
  display: grid;
  place-items: center;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    #15191f;
  background-size: 28px 28px;
}

.preview-shape::after {
  position: absolute;
  content: "";
  right: 26px;
  top: 22px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 22px var(--teal);
}

.preview-shape span {
  width: 90px;
  height: 94px;
  border-radius: 44% 56% 39% 61%;
  background: var(--yellow);
  clip-path: polygon(36% 0, 75% 10%, 98% 38%, 84% 72%, 58% 100%, 21% 91%, 0 52%, 14% 18%);
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.28));
  transform: rotate(-18deg);
}

.preview-ttt {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 14px;
  background: #f8fafc;
}

.preview-ttt span {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 1.8rem;
  font-weight: 900;
}

.preview-target {
  background:
    radial-gradient(circle at 72% 35%, var(--yellow) 0 8px, var(--coral) 9px 20px, transparent 21px),
    radial-gradient(circle at 31% 63%, var(--teal) 0 7px, var(--indigo) 8px 18px, transparent 19px),
    linear-gradient(135deg, #252b34, #14171d);
}

/* ── shared context panel ────────────────────────────────── */
.stat-list {
  display: grid;
  gap: 10px;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.stat-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.stat-row span {
  color: var(--muted);
  font-size: 0.88rem;
}

.stat-row strong {
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── accessibility ───────────────────────────────────────── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
  padding: 0;
}

button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--selected) 40%, transparent);
  outline-offset: 2px;
}

/* ── game shell base ─────────────────────────────────────── */
.canvas-shell,
.target-shell,
.memory-shell,
.tetris-shell,
.poople-shell,
.angle-shell,
.connect-shell,
.world-shell,
.shape-shell,
.ttt-shell {
  display: grid;
  place-items: center;
  min-height: 480px;
}

.canvas-shell {
  gap: 16px;
}

.replay-button {
  min-width: 148px;
  padding-inline: 18px;
}

.game-result-copy {
  display: grid;
  justify-items: center;
  gap: 8px;
}

[data-tone="correct"] { color: var(--correct); }
[data-tone="error"] { color: var(--error); }
[data-tone="close"] { color: #8a6900; }

.game-panel[data-phase="result"] :is(.poople-status, .angle-status, .connect-status, .world-status, .shape-status, .ttt-status) {
  font-weight: 900;
}

/* ── snake ───────────────────────────────────────────────── */
.snake-wrap {
  display: grid;
  grid-template-columns: minmax(260px, 480px) 144px;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 640px;
}

.snake-canvas {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
  border: 1px solid #2f3742;
  border-radius: 8px;
  background: #111418;
}

.d-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 144px;
}

.pad-button {
  position: relative;
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.pad-button:hover,
.pad-button:focus-visible {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, white);
}

.pad-button:active {
  background: color-mix(in srgb, var(--accent) 14%, white);
}

.pad-button.empty {
  visibility: hidden;
}

.control-arrow {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
}

.control-arrow.up {
  border-bottom: 9px solid var(--ink);
}

.control-arrow.down {
  border-top: 9px solid var(--ink);
}

.control-arrow.left,
.control-arrow.right {
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
}

.control-arrow.left {
  border-right: 9px solid var(--ink);
  border-left: 0;
}

.control-arrow.right {
  border-left: 9px solid var(--ink);
  border-right: 0;
}

/* ── memory ──────────────────────────────────────────────── */
.memory-shell {
  gap: 18px;
  align-content: center;
  position: relative;
}

.memory-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, 96px));
  gap: 10px;
}

.memory-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  perspective: 700px;
}

.memory-card:disabled,
.ttt-cell:disabled {
  cursor: default;
}

.memory-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  backface-visibility: hidden;
  transition: transform 160ms ease;
}

.memory-back {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16) 25%, transparent 25% 50%, rgba(255, 255, 255, 0.16) 50% 75%, transparent 75%),
    var(--indigo);
  background-size: 24px 24px;
}

.memory-front {
  background: #fff;
  transform: rotateY(180deg);
}

.memory-card.is-open .memory-back,
.memory-card.is-matched .memory-back {
  transform: rotateY(180deg);
}

.memory-card.is-open .memory-front,
.memory-card.is-matched .memory-front {
  transform: rotateY(360deg);
}

.memory-card.is-matched .memory-front {
  border-color: var(--accent);
}

.memory-token {
  display: grid;
  width: 58%;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  font-size: 1.55rem;
  font-weight: 900;
}

.token-0, .token-5 { background: var(--teal); }
.token-1, .token-6 { background: var(--coral); }
.token-2, .token-7 { background: var(--indigo); }
.token-3 { background: var(--yellow); color: var(--ink); }
.token-4 { background: var(--lime); color: var(--ink); }

.memory-done {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 8px;
  text-align: center;
  padding: 24px;
  z-index: 10;
}

.memory-done-title {
  margin: 0 0 6px;
  font-size: 1.6rem;
  font-weight: 900;
}

.memory-done-score {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 4px;
}

.memory-done-rating {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0;
}

.memory-done .replay-button {
  margin-top: 8px;
}

.memory-done-rating.rating-excellent { color: var(--teal); }
.memory-done-rating.rating-good      { color: var(--indigo); }
.memory-done-rating.rating-fair      { color: var(--coral); }

/* ── poople ──────────────────────────────────────────────── */
/* tetris */
.tetris-shell {
  align-content: center;
  gap: 12px;
}

.tetris-layout {
  --tetris-board-size: clamp(240px, calc((100dvh - 190px) / 2), 300px);
  display: grid;
  grid-template-columns: var(--tetris-board-size) 132px;
  align-items: start;
  gap: 16px;
}

.tetris-board-wrap {
  position: relative;
  width: 100%;
}

.tetris-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 2;
  border: 1px solid #2f3742;
  border-radius: 6px;
  background: #111418;
}

.tetris-side {
  display: grid;
  gap: 10px;
}

.tetris-next {
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tetris-next canvas {
  display: block;
  width: 120px;
  aspect-ratio: 1;
  border: 1px solid #2f3742;
  border-radius: 6px;
  background: #111418;
}

.tetris-pause {
  width: 120px;
}

.tetris-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
}

.tetris-controls {
  display: grid;
  grid-template-columns: repeat(5, 44px);
  gap: 7px;
}

.tetris-controls button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
}

.tetris-controls button:hover:not(:disabled),
.tetris-controls button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.tetris-controls button:disabled {
  cursor: default;
  opacity: 0.42;
}

.game-instructions {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
  text-align: center;
}

.tetris-result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  padding: 24px;
  background: rgba(17, 20, 24, 0.9);
  color: #fff;
  text-align: center;
}

.tetris-result-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
}

.tetris-result-score {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
}

.tetris-result-best {
  margin: 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.84rem;
  font-weight: 800;
}

.poople-shell {
  gap: 14px;
}

.poople-goal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  font-weight: 800;
}

.poople-goal span,
.poople-goal strong {
  display: inline-grid;
  min-width: 78px;
  place-items: center;
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 1rem;
}

.poople-goal span {
  border: 1px solid var(--line);
  color: var(--muted);
}

.poople-goal strong {
  background: var(--ink);
  color: #fff;
}

.poople-goal::before {
  content: "→";
  color: var(--muted);
  font-weight: 800;
}

.poople-goal .start-word {
  order: -1;
}

.poople-rule {
  margin: -4px 0 2px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
}

.poople-ladder {
  display: grid;
  gap: 8px;
  width: min(100%, 360px);
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.poople-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.poople-tile {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 900;
}

.poople-row.is-start .poople-tile {
  color: var(--muted);
}

.poople-tile.is-changed {
  border-color: color-mix(in srgb, var(--selected) 42%, var(--line));
  background: color-mix(in srgb, var(--selected) 10%, white);
}

.poople-tile.is-target {
  border-color: color-mix(in srgb, var(--correct) 48%, var(--line));
  background: color-mix(in srgb, var(--correct) 14%, white);
}

.poople-collapsed {
  padding: 2px 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.poople-form {
  display: grid;
  grid-template-columns: minmax(120px, 152px) auto;
  gap: 10px;
  width: min(100%, 420px);
  align-items: stretch;
}

.poople-input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  transition: border-color 120ms ease;
}

.poople-input:focus {
  border-color: var(--accent);
  outline: none;
}

.poople-input:disabled {
  background: #edf1f5;
  color: var(--muted);
}

.poople-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(78px, 1fr));
  gap: 8px;
}

.poople-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

/* ── angle ───────────────────────────────────────────────── */
.angle-shell {
  gap: 16px;
}

.angle-board {
  width: min(100%, 520px);
  aspect-ratio: 18 / 13;
  border: 1px solid #2f3742;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    #12161c;
  background-size: 24px 24px;
}

.angle-board.is-correct .angle-ray,
.angle-board.is-correct .angle-arc {
  stroke: var(--correct);
}

.angle-board.is-close .angle-ray,
.angle-board.is-close .angle-arc {
  stroke: var(--close);
}

.angle-board.is-warm .angle-ray,
.angle-board.is-warm .angle-arc {
  stroke: var(--close);
}

.angle-board.is-cold .angle-ray,
.angle-board.is-cold .angle-arc {
  stroke: #8a929d;
}

.angle-base,
.angle-ray {
  stroke-linecap: round;
  stroke-width: 8;
}

.angle-base {
  stroke: var(--yellow);
}

.angle-ray {
  stroke: var(--teal);
}

.angle-arc {
  fill: none;
  stroke: var(--coral);
  stroke-linecap: round;
  stroke-width: 7;
}

.angle-pin {
  fill: #fff;
  stroke: var(--coral);
  stroke-width: 4;
}

.angle-form {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(92px, 122px);
  gap: 10px;
  width: min(100%, 294px);
}

.angle-input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 900;
  text-align: center;
  transition: border-color 120ms ease;
}

.angle-input:focus {
  border-color: var(--accent);
  outline: none;
}

.angle-input:disabled {
  background: #edf1f5;
  color: var(--muted);
}

.angle-history {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: min(100%, 420px);
  min-height: 30px;
}

.angle-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 48px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 900;
}

.angle-chip .chip-dir {
  font-size: 0.7rem;
  opacity: 0.72;
}

.angle-chip.is-correct {
  border-color: color-mix(in srgb, var(--correct) 48%, var(--line));
  background: color-mix(in srgb, var(--correct) 14%, white);
}

.angle-chip.is-close {
  border-color: color-mix(in srgb, var(--close) 48%, var(--line));
  background: color-mix(in srgb, var(--close) 16%, white);
}

.angle-chip.is-warm {
  border-color: color-mix(in srgb, var(--close) 34%, var(--line));
  background: color-mix(in srgb, var(--close) 9%, white);
}

.angle-chip.is-cold {
  border-color: var(--line);
  background: #f2f4f7;
}

.history-overflow {
  align-self: center;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.angle-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

/* ── connect 4 ───────────────────────────────────────────── */
.connect-shell {
  gap: 12px;
}

.connect-col-row {
  display: grid;
  grid-template-columns: repeat(7, 58px);
  gap: 8px;
}

.connect-col-btn {
  min-width: 44px;
  height: 32px;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.28);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 900;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.connect-col-btn:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.connect-col-row.is-p1 .connect-col-btn:not(:disabled) {
  color: var(--coral);
}

.connect-col-row.is-p2 .connect-col-btn:not(:disabled) {
  color: var(--yellow);
}

.connect-col-btn.preview-p1 {
  color: var(--coral);
  background: rgba(242, 92, 84, 0.15);
  border-color: rgba(242, 92, 84, 0.3);
}

.connect-col-btn.preview-p2 {
  color: var(--yellow);
  background: rgba(244, 211, 94, 0.15);
  border-color: rgba(244, 211, 94, 0.3);
}

.connect-col-btn:disabled {
  cursor: default;
  opacity: 0.25;
}

.connect-board {
  display: grid;
  grid-template-columns: repeat(7, 58px);
  gap: 8px;
  border: 1px solid #28313d;
  border-radius: 8px;
  padding: 12px;
  background: #15191f;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.04);
}

.connect-cell {
  display: grid;
  width: 58px;
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  cursor: default;
  pointer-events: none;
  box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.24), inset 0 0 0 2px rgba(255, 255, 255, 0.06);
}

.connect-cell span {
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition: background 160ms ease, box-shadow 160ms ease;
}

.connect-cell.is-p1 span {
  background: var(--coral);
  box-shadow: inset 0 -7px 0 rgba(120, 28, 27, 0.2);
}

.connect-cell.is-p2 span {
  background: var(--yellow);
  box-shadow: inset 0 -7px 0 rgba(116, 83, 0, 0.2);
}

.connect-cell.is-winner span {
  box-shadow: inset 0 -7px 0 rgba(0, 0, 0, 0.15), 0 0 0 3px #fff;
}

.connect-cell.is-preview-p1 span {
  background: rgba(242, 92, 84, 0.45);
}

.connect-cell.is-preview-p2 span {
  background: rgba(244, 211, 94, 0.45);
}

.connect-next {
  width: min(100%, 168px);
}

.connect-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.connect-status[data-player="1"] {
  color: var(--coral);
}

.connect-status[data-player="2"] {
  color: #8a6900;
}

/* ── world countries ─────────────────────────────────────── */
.world-shell {
  align-content: start;
  gap: 12px;
  width: 100%;
}

.world-setup {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  justify-content: center;
  width: min(100%, 760px);
}

.world-playbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(100%, 760px);
}

.world-mode-switch {
  grid-template-columns: repeat(2, 96px);
}

.world-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(100%, 900px);
}

.world-controls button {
  min-width: 110px;
}

.world-settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease;
}

.world-settings-toggle:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.world-display-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(100%, 760px);
}

.world-scope-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.world-scope-select {
  min-width: 150px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.world-scope-select:disabled {
  color: var(--muted);
  cursor: not-allowed;
}

.world-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
}

.world-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--selected);
}

.world-form {
  display: grid;
  grid-template-columns: minmax(220px, 420px);
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: min(100%, 520px);
}

.world-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
}

.world-input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
  padding: 10px 12px;
  transition: border-color 120ms ease;
}

.world-input:focus {
  border-color: var(--accent);
  outline: none;
}

.world-input:disabled {
  background: #edf1f5;
  color: var(--muted);
}

.world-map {
  display: grid;
  gap: 10px;
  width: 100%;
}

.world-map-stage {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dcecf3;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.42);
}

.world-map-tools {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(72, 88, 103, 0.22);
  border-radius: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 18px rgba(42, 54, 65, 0.12);
}

.world-map-tool {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}

.world-map-tool.is-reset {
  min-width: 52px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.world-map-tool:hover:not(:disabled) {
  border-color: rgba(0, 135, 97, 0.55);
  background: #eefaf6;
}

.world-map-tool:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.world-map-zoom {
  min-width: 42px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.world-svg {
  display: block;
  width: 100%;
  aspect-ratio: 960 / 500;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.world-map-stage.is-panning .world-svg {
  cursor: grabbing;
}

.world-ocean { fill: #d8ebf2; }
.world-graticule {
  fill: none;
  stroke: rgba(83, 104, 121, 0.17);
  stroke-width: 1;
}

.world-country-layer {
  shape-rendering: geometricPrecision;
}

.world-country-shape {
  fill: #f7f9fb;
  stroke: rgba(82, 98, 114, 0.58);
  stroke-linejoin: round;
  stroke-width: 0.55;
  transition: fill 140ms ease, stroke 140ms ease, opacity 140ms ease;
  vector-effect: non-scaling-stroke;
}

.world-map-stage.no-borders .world-country-shape {
  stroke: transparent;
}

.world-country-shape.is-outside {
  fill: rgba(215, 224, 232, 0.62);
  opacity: 0.46;
}

.world-country-shape.is-found {
  fill: var(--correct);
  stroke: #006e50;
}

.world-country-shape.is-missed {
  fill: color-mix(in srgb, var(--error) 36%, white);
  stroke: rgba(165, 42, 38, 0.54);
}

.world-country-shape:not(.is-found):not(.is-missed):not(.is-outside):hover {
  fill: #edf4f7;
}

.world-marker-layer { pointer-events: auto; }
.world-map-stage.no-markers .world-marker-layer { display: none; }

.world-country-marker {
  fill: #e3342f;
  fill-opacity: 1;
  stroke: #ffffff;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 2px rgba(45, 18, 16, 0.45));
  transition: fill 140ms ease, fill-opacity 140ms ease, filter 140ms ease, stroke 140ms ease;
  vector-effect: non-scaling-stroke;
}

.world-country-marker.is-found {
  fill: var(--correct);
  fill-opacity: 1;
  stroke: #ffffff;
}

.world-country-marker.is-missed {
  fill: var(--error);
  fill-opacity: 1;
  stroke: #ffffff;
}

.world-country-marker:hover {
  fill-opacity: 1;
  filter: drop-shadow(0 0 3px rgba(45, 18, 16, 0.6));
  stroke: var(--ink);
}

.world-label-layer { pointer-events: none; }
.world-map-stage.no-labels .world-label-layer { display: none; }

.world-country-label {
  fill: var(--ink);
  stroke: #ffffff;
  font-weight: 950;
  letter-spacing: 0;
  paint-order: stroke fill;
  text-anchor: middle;
  user-select: none;
}

.world-map-missing {
  fill: var(--muted);
  font-size: 16px;
  font-weight: 900;
}

.world-region-meters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.world-region-meter {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  padding: 10px;
  background: #e7ebf0;
}

.world-region-meter span,
.world-region-meter strong {
  position: relative;
  z-index: 1;
  font-size: 0.8rem;
  font-weight: 900;
}

.world-region-meter strong {
  color: var(--muted);
}

.world-region-meter i {
  position: absolute;
  inset: 0 auto 0 0;
  background: color-mix(in srgb, var(--correct) 18%, transparent);
}

.world-answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-height: 620px;
  overflow-y: auto;
  padding-right: 4px;
}

.world-region {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.world-region h2 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.world-country-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.world-country {
  min-height: 28px;
  overflow: hidden;
  border: 1px solid #edf0f5;
  border-radius: 6px;
  padding: 5px 7px;
  background: #f7f9fb;
  color: transparent;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.world-country.is-found {
  border-color: color-mix(in srgb, var(--correct) 38%, var(--line));
  background: color-mix(in srgb, var(--correct) 12%, white);
  color: var(--ink);
}

.world-country.is-missed {
  border-color: color-mix(in srgb, var(--error) 32%, var(--line));
  background: color-mix(in srgb, var(--error) 10%, white);
  color: var(--ink);
}

.world-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

/* ── country shape ───────────────────────────────────────── */
.shape-shell {
  align-content: start;
  align-items: start;
  gap: 12px;
  justify-items: center;
  width: 100%;
}

.shape-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: min(100%, 700px);
}

.shape-round-actions,
.shape-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.shape-round-actions {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  width: 244px;
}

#shapeHint { grid-column: 1; }
#shapeSkip { grid-column: 2; }
#shapeNext { grid-column: 3; }

.shape-settings {
  justify-content: center;
  width: min(100%, 760px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.shape-round-actions button {
  min-width: 76px;
}

.shape-card {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: min(100%, 700px);
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.shape-svg {
  display: block;
  width: min(100%, 620px);
  height: min(52vh, 390px);
  min-height: 240px;
}

.shape-transform {
  transform-box: fill-box;
  transform-origin: center;
}

.shape-path {
  fill: #17191f;
  stroke: #ffffff;
  stroke-linejoin: round;
  stroke-width: 0.85;
  filter: drop-shadow(0 14px 18px rgba(18, 22, 30, 0.22));
  transition: fill 160ms ease, stroke 160ms ease;
  vector-effect: non-scaling-stroke;
}

.shape-path.is-revealed {
  fill: var(--correct);
  stroke: #006e50;
}

.shape-reveal {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: calc(100% - 24px);
  overflow-wrap: anywhere;
  border: 1px solid rgba(216, 221, 229, 0.9);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.shape-reveal.is-visible {
  opacity: 1;
}

.shape-empty {
  color: var(--muted);
  font-weight: 900;
}

.shape-form {
  display: grid;
  grid-template-columns: minmax(190px, 330px) minmax(92px, 118px);
  gap: 8px;
  width: min(100%, 470px);
}

.shape-form.is-hidden,
.shape-choices.is-hidden {
  display: none;
}

.shape-input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 850;
  padding: 10px 12px;
  transition: border-color 120ms ease;
}

.shape-input:focus {
  border-color: var(--accent);
  outline: none;
}

.shape-input:disabled {
  background: #edf1f5;
  color: var(--muted);
}

.shape-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 580px);
}

.shape-choice {
  min-height: 46px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease;
}

.shape-choice:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: color-mix(in srgb, var(--accent) 6%, white);
}

.shape-choice.is-wrong {
  border-color: color-mix(in srgb, var(--error) 34%, var(--line));
  background: color-mix(in srgb, var(--error) 10%, white);
  color: #9c2f2b;
}

.shape-choice.is-correct {
  border-color: color-mix(in srgb, var(--correct) 48%, var(--line));
  background: color-mix(in srgb, var(--correct) 14%, white);
  color: #006e50;
}

.shape-choice:disabled {
  cursor: default;
  opacity: 0.78;
}

.shape-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

/* ── tic tac toe ─────────────────────────────────────────── */
.ttt-shell {
  gap: 18px;
}

.mode-selection-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
}
.ttt-selection-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}
.ttt-modes-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 240px;
}
.ttt-mode-btn {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  font-size: 14px;
  transition: all 140ms ease;
}
.ttt-mode-btn:hover,
.ttt-mode-btn:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 118px);
  gap: 8px;
}

.ttt-shell .mode-switch {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 390px);
}

.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 112px);
  gap: 0;
  border: 2px solid var(--ink);
  border-radius: 4px;
  overflow: hidden;
}

.ttt-cell {
  display: grid;
  width: 112px;
  aspect-ratio: 1;
  place-items: center;
  border: 0;
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 3rem;
  font-weight: 900;
  transition: background 100ms ease;
}

.ttt-cell:nth-child(3n) {
  border-right: 0;
}

.ttt-cell:nth-child(7),
.ttt-cell:nth-child(8),
.ttt-cell:nth-child(9) {
  border-bottom: 0;
}

.ttt-cell:hover:not([data-mark]):not(:disabled),
.ttt-cell:focus-visible:not([data-mark]) {
  background: rgba(99, 102, 241, 0.06);
}

.ttt-cell[data-mark="X"] { color: var(--teal); }
.ttt-cell[data-mark="O"] { color: var(--coral); }

.ttt-cell.is-winner {
  background: color-mix(in srgb, var(--correct) 14%, white);
}

.ttt-status {
  min-height: 22px;
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  color: var(--muted);
}

.ttt-status[data-turn="X"] { color: var(--teal); }
.ttt-status[data-turn="O"] { color: var(--coral); }

/* ── reflex grid ─────────────────────────────────────────── */
.target-shell {
  gap: 18px;
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(4, 88px);
  gap: 10px;
}

.target-grid.is-done {
  min-height: 382px;
  align-content: center;
}

.target-cell {
  position: relative;
  width: 88px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: background 100ms ease;
}

.target-cell::before,
.target-cell::after {
  position: absolute;
  content: "";
  border-radius: 50%;
  opacity: 0;
  transition: opacity 120ms ease, transform 120ms ease;
}

.target-cell::before {
  inset: 14px;
  border: 10px solid var(--coral);
  transform: scale(0.72);
}

.target-cell::after {
  inset: 34px;
  background: var(--yellow);
  transform: scale(0.72);
}

.target-cell.is-live {
  background: rgba(225, 29, 72, 0.04);
}

.target-cell.is-live::before,
.target-cell.is-live::after {
  opacity: 1;
  transform: scale(1);
}

.time-track {
  width: min(100%, 390px);
  height: 10px;
  border-radius: 999px;
  background: #dfe4eb;
  overflow: hidden;
}

.time-bar {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transition: width 140ms linear;
}

.target-done {
  display: grid;
  grid-column: 1 / -1;
  place-items: center;
  min-height: 100%;
  text-align: center;
  gap: 6px;
  padding: 20px;
}

.target-done-score {
  font-size: 3rem;
  font-weight: 900;
  line-height: 1;
}

.target-done-label {
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 700;
  margin: 0;
}

.target-done-label.is-best {
  color: var(--correct);
  font-weight: 900;
}

/* ── responsive: tablet ──────────────────────────────────── */
@media (max-width: 1100px) {
  .hub-grid--deep {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 0;
    height: auto;
    min-height: auto;
    overflow: hidden;
    padding: 12px 14px;
  }

  .brand-button {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
  }

  .game-menu {
    display: flex;
    gap: 4px;
    min-width: 0;
    width: auto;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .game-menu::-webkit-scrollbar {
    display: none;
  }

  .nav-divider {
    display: none;
  }

  .nav-item {
    grid-template-columns: 24px auto;
    flex: 0 0 auto;
    min-width: max-content;
    width: auto;
    padding: 6px 9px;
    text-align: left;
    gap: 7px;
  }

  .nav-item span:last-child {
    font-size: 0.7rem;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .context-panel {
    align-self: stretch;
  }
}

@media (max-width: 700px) {
  .main-stage {
    padding: 14px;
    gap: 12px;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  h1 {
    font-size: 1.25rem;
  }

  .metrics {
    order: 3;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    width: 100%;
  }

  body[data-game="hub"] .metrics {
    display: none;
  }

  .metric {
    display: grid;
    align-content: center;
    gap: 1px;
    min-width: 0;
    padding: 4px 10px;
  }

  .metric strong {
    max-width: 100%;
  }

  .toolbar {
    margin-left: 0;
  }

  .hub-grid--quick,
  .hub-grid--deep {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-panel {
    min-height: 420px;
    padding: 4px 0 20px;
  }

  .canvas-shell,
  .target-shell,
  .memory-shell,
  .tetris-shell,
  .poople-shell,
  .angle-shell,
  .connect-shell,
  .world-shell,
  .shape-shell,
  .ttt-shell {
    min-height: 390px;
  }

  .snake-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
    max-width: 420px;
  }

  .snake-canvas {
    max-width: 420px;
  }

  .d-pad {
    width: 144px;
    grid-template-columns: repeat(3, 44px);
  }

  .pad-button {
    width: 44px;
    height: 44px;
  }

  .tetris-layout {
    grid-template-columns: minmax(210px, 250px) 96px;
    gap: 12px;
  }

  .tetris-next canvas,
  .tetris-pause {
    width: 96px;
  }

  .tetris-controls {
    grid-template-columns: repeat(5, 42px);
    gap: 6px;
  }

  .tetris-controls button {
    width: 42px;
    height: 42px;
  }

  .memory-board {
    grid-template-columns: repeat(4, minmax(50px, 72px));
    gap: 8px;
  }

  .poople-ladder {
    width: min(100%, 290px);
  }

  .poople-form {
    grid-template-columns: 1fr;
    width: min(100%, 290px);
  }

  .poople-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .poople-tile {
    font-size: 1.12rem;
  }

  .angle-board {
    width: min(100%, 310px);
  }

  .angle-form {
    grid-template-columns: 1fr;
    width: min(100%, 260px);
  }

  .connect-col-row,
  .connect-board {
    grid-template-columns: repeat(7, 36px);
    gap: 5px;
    padding: 8px;
  }

  .connect-col-btn {
    height: 44px;
    min-height: 44px;
    font-size: 0.62rem;
  }

  .ttt-shell .mode-switch {
    grid-template-columns: 1fr;
    width: min(100%, 240px);
  }

  .connect-cell {
    width: 36px;
  }

  .world-form,
  .world-map,
  .world-answers {
    grid-template-columns: 1fr;
  }

  .world-playbar,
  .shape-toolbar {
    width: 100%;
  }

  .shape-toolbar {
    align-items: flex-start;
  }

  .world-toggle {
    width: 100%;
    justify-content: center;
  }

  .world-scope-control {
    width: 100%;
    justify-content: center;
  }

  .world-map-tools {
    right: 8px;
    left: 8px;
    justify-content: center;
  }

  .world-map-tool {
    min-width: 30px;
  }

  .world-region-meters {
    grid-template-columns: 1fr;
  }

  .world-country-grid {
    grid-template-columns: 1fr;
  }

  .shape-form,
  .shape-choices {
    grid-template-columns: 1fr;
  }

  .shape-card {
    min-height: 300px;
  }

  .shape-svg {
    height: 280px;
    min-height: 220px;
  }

  .ttt-board {
    grid-template-columns: repeat(3, 82px);
  }

  .ttt-cell {
    width: 82px;
    font-size: 2.2rem;
  }

  .target-grid {
    grid-template-columns: repeat(4, 68px);
    gap: 8px;
  }

  .target-grid.is-done {
    min-height: 296px;
  }

  .target-cell {
    width: 68px;
  }
}

@media (max-width: 480px) {
  .hub-grid--quick,
  .hub-grid--deep {
    grid-template-columns: 1fr;
  }

  .hub-section-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }

  .shape-toolbar {
    flex-direction: column;
  }

  .shape-round-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .shape-round-actions button {
    min-width: 0;
  }

  .tetris-layout {
    grid-template-columns: minmax(180px, 220px) 80px;
    gap: 10px;
  }

  .tetris-next canvas,
  .tetris-pause {
    width: 80px;
  }

  .tetris-controls {
    grid-template-columns: repeat(5, 40px);
  }

  .tetris-controls button {
    width: 40px;
    height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
button,
[role="button"] {
  touch-action: manipulation;
}

button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #f2c94c;
  outline-offset: 2px;
}

@media (pointer: coarse) {
  button,
  [role="button"] {
    min-height: 44px;
  }
}
