:root {
  --bg: #fffaf3;
  --ink: #2b2d42;
  --muted: #6b6f85;
  --brand: #ff7a59;
  --brand-dark: #e2603f;
  --alt: #3a86ff;
  --card: #ffffff;
  --line: #f0e4d3;
  --good: #2a9d5c;
  --bad: #d62828;
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 17px;
}
a { color: var(--alt); }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; padding: 8px; z-index: 10; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 18px 40px; }
.wrap.narrow { max-width: 760px; }
h1, h2, h3 { line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 20px 0 8px; }
h2 { font-size: 1.5rem; margin: 32px 0 12px; }
.lead { font-size: 1.15rem; color: var(--muted); margin-top: 0; }
.small { font-size: .85rem; color: var(--muted); }

.site-header { background: #fff; border-bottom: 3px solid var(--brand); }
.header-in { display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; flex-wrap: wrap; gap: 8px; }
.logo { font-size: 1.35rem; font-weight: 800; color: var(--ink); text-decoration: none; }
.nav a { margin-left: 16px; font-weight: 600; color: var(--ink); text-decoration: none; }
.nav a:hover { color: var(--brand-dark); }

.hero { background: linear-gradient(135deg, #ffe3d6, #dbeafe); padding: 36px 0 14px; margin-bottom: 8px; }
.hero .wrap { padding-bottom: 20px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-block; background: var(--brand); color: #fff; border: 0; border-radius: 999px;
  padding: 10px 20px; font-size: 1rem; font-weight: 700; cursor: pointer; text-decoration: none;
  font-family: inherit;
}
.btn:hover { background: var(--brand-dark); }
.btn.alt { background: var(--alt); }
.btn.alt:hover { background: #2a6fe0; }
.btn.big { padding: 14px 26px; font-size: 1.1rem; }
.btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.card {
  display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 18px; text-decoration: none; color: var(--ink);
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.08); }
.card-emoji { font-size: 2.4rem; }
.card-title { font-weight: 800; font-size: 1.15rem; }
.card-age { font-size: .8rem; color: var(--brand-dark); font-weight: 700; }
.card-text { color: var(--muted); font-size: .95rem; }

.guide-list { list-style: none; padding: 0; display: grid; gap: 14px; }
.guide-list li { background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.guide-list a { font-weight: 800; font-size: 1.1rem; }
.guide-list span { display: block; color: var(--muted); font-size: .95rem; }

.crumbs { font-size: .9rem; color: var(--muted); margin-top: 14px; }
.prose p, .prose li { max-width: 70ch; }
.prose ol { padding-left: 22px; }

.ad { margin: 24px 0; min-height: 90px; text-align: center; }

.site-footer { background: #fff; border-top: 3px solid var(--line); padding: 24px 0 10px; margin-top: 30px; text-align: center; }
.foot-links a { margin: 0 4px; }

/* Fullscreen / iframe game embed */
.game-frame-wrap {
  position: relative; margin: 16px 0; border-radius: var(--radius); overflow: hidden;
  border: 2px solid var(--line); background: #05060a;
  aspect-ratio: 16/10;
}
.game-frame {
  display: block; width: 100%; height: 100%; border: 0;
}
.game-fullscreen-btn {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  font-size: .85rem; padding: 6px 14px; opacity: .85;
}
.game-fullscreen-btn:hover { opacity: 1; }
@media (max-width: 600px) {
  .game-frame-wrap { aspect-ratio: 4/5; }
}

/* Games and tools */
.game-box, .tool-box {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin: 16px 0;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.toolbar label { font-weight: 600; display: flex; gap: 6px; align-items: center; }
select, input[type=text], input[type=number], textarea {
  font: inherit; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
textarea { width: 100%; min-height: 70px; }
.stat { background: #fff4ec; border-radius: 999px; padding: 4px 12px; font-weight: 600; }
.msg { min-height: 1.6em; font-weight: 700; margin: 10px 0 0; }
.msg.good { color: var(--good); }
.msg.bad { color: var(--bad); }

.mem-board { display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 10px; max-width: 520px; margin: 0 auto; }
.mem-card {
  aspect-ratio: 1; border: 0; border-radius: 14px; font-size: clamp(1.6rem, 8vw, 2.6rem);
  background: var(--alt); color: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: transform .2s, background .2s;
}
.mem-card.up { background: #fff4ec; color: inherit; border: 3px solid var(--brand); }
.mem-card.done { background: #e6f7ec; color: inherit; border: 3px solid var(--good); cursor: default; }

.big-text { font-size: clamp(2rem, 9vw, 3.4rem); font-weight: 800; text-align: center; letter-spacing: .12em; margin: 14px 0; }
.answer-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.answer-row input { font-size: 1.4rem; width: 220px; text-align: center; }
.color-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.color-btns .btn { min-width: 100px; background: #fff; color: var(--ink); border: 3px solid var(--line); }
.color-btns .btn:hover { border-color: var(--ink); }
.center { text-align: center; }

/* Printables */
.sheet { background: #fff; border: 1px dashed #bbb; padding: 24px; margin-top: 14px; color: #000; }
.sheet h2 { margin: 0 0 6px; font-size: 1.4rem; text-align: center; }
.sheet .meta { display: flex; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.problems { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 12px; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.problem { white-space: nowrap; }
.problem .ans { color: #c00; font-weight: 700; visibility: hidden; }
.show-answers .problem .ans { visibility: visible; }
.blank { display: inline-block; min-width: 2.4em; border-bottom: 2px solid #000; }
.show-answers .blank { border-bottom-color: transparent; }

table.ws { border-collapse: collapse; margin: 0 auto; font-family: "Courier New", monospace; font-size: 1.2rem; }
table.ws td { width: 1.9em; height: 1.9em; text-align: center; border: 0; }
.show-answers table.ws td.hit { background: #ffe066; border-radius: 50%; font-weight: 700; }
.wordlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; margin-top: 18px; font-weight: 700; }

.maze-wrap { text-align: center; }
.maze-wrap svg { max-width: 100%; height: auto; }
.sol { display: none; }
.show-answers .sol { display: block; }

table.tt { border-collapse: collapse; margin: 0 auto; font-size: 1rem; }
table.tt th, table.tt td { border: 1px solid #999; width: 2.4em; height: 2.2em; text-align: center; padding: 0; }
table.tt th { background: #ffe3d6; }
table.tt td.diag { background: #fff4c2; }

@media (max-width: 560px) {
  .problems { grid-template-columns: repeat(2, 1fr); }
  table.ws { font-size: .9rem; }
  table.tt { font-size: .7rem; }
}

@media print {
  @page { margin: 0.5in; }
  body { background: #fff; font-size: 12pt; }
  .no-print, .site-header, .site-footer, .toolbar, .crumbs, .skip { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .tool-box { border: 0; padding: 0; margin: 0; }
  .sheet { border: 0; padding: 0; margin: 0; }
  .problems { font-size: 14pt; }
}
