@import url('/play/assets/fonts/fredoka.css');

/* Librarette Play: shared tokens and components. Fix styles here, not on individual game pages. */
:root {
  --ink: #0d2b20;
  --paper: #fff7e8;
  --card: #fffdf7;
  --sun: #f4b942;
  --mango: #f08a3c;
  --clay: #c8553d;
  --indigo: #2e4a8b;
  --leaf: #6fae5b;
  --leaf-soft: #e1efd0;
  --sky: #3fa7d6;
  --sky-soft: #d7eef8;
  --teal: #2aa198;
  --muted: #4f6158;
  --warn-soft: #fbe0d9;
  --radius: 18px;
  --lift: 0 3px 0 var(--ink);
  --max: 720px;
  --surface-2: #f2eadb;
  --line-soft: rgba(13, 43, 32, .18);
  --shadow-soft: 0 14px 30px rgba(13, 43, 32, .12);
  font-family: 'Fredoka', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.mo-play-note{display:flex;align-items:center;gap:12px;max-width:var(--max);margin:18px auto 0;padding:10px 14px 10px 9px;border:3px solid var(--ink);border-radius:18px;background:#fff1a9;box-shadow:var(--lift)}.mo-play-note img{width:58px;height:70px;object-fit:contain;object-position:center bottom;background:var(--sun);border-radius:12px;flex:none}.mo-play-note>div{display:grid;gap:3px}.mo-play-note-label{font-size:.68rem;font-weight:800;letter-spacing:.1em;text-transform:uppercase}.mo-play-note strong{font-size:1.05rem}.mo-play-note p{margin:0;font-size:.82rem;line-height:1.2}.mo-play-voice,.mo-finish-note{display:flex;align-items:center;gap:9px;margin:0 0 12px;padding:7px 10px;border:2px solid var(--ink);border-radius:14px;background:var(--leaf-soft);font-size:.82rem;font-weight:700}.mo-play-voice img,.mo-finish-note img{width:38px;height:48px;object-fit:contain;object-position:center bottom;background:var(--sun);border-radius:9px;flex:none}.mo-finish-note{margin-bottom:18px;background:#fff1a9}.mo-finish-note img{width:46px;height:56px}

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

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  font-size: 1.05rem;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

img, svg { display: block; max-width: 100%; }

:focus-visible {
  outline: 4px solid var(--indigo);
  outline-offset: 3px;
}

/* ---------- Header ---------- */
.play-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ink);
  color: var(--paper);
}
.play-top a { color: var(--paper); text-decoration: none; font-weight: 600; }
.play-top a:hover { text-decoration: underline; }
.play-brand { font-size: 1.1rem; font-weight: 700; }
.mute {
  font: inherit;
  font-weight: 600;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 3px solid var(--paper);
  background: var(--sun);
  color: var(--ink);
  cursor: pointer;
}

/* ---------- Page column ---------- */
.play-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 18px 72px;
}
.play-screen { position: relative; padding-top: 4px; }
.play-screen::before { content: ''; display: block; width: 72px; height: 7px; margin: 0 0 16px 4px; border-radius: 99px; background: var(--accent, var(--sun)); box-shadow: 0 3px 0 var(--ink); }
.play-screen .play-title { letter-spacing: -.02em; }
.play-screen .round-label { color: var(--muted); }
.play-screen .dots .dot.now { background: var(--accent, var(--mango)); }
.play-screen.engine-memory .stage, .play-screen.engine-rhythm .stage { background: linear-gradient(145deg, rgba(255,253,247,.98), color-mix(in srgb, var(--accent, var(--sun)) 13%, var(--card))); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 1.1rem;
  min-height: 52px;
  min-width: 52px;
  padding: 10px 22px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--sun);
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--lift);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.big { font-size: 1.35rem; min-height: 64px; padding: 12px 30px; }
.btn.ghost { background: var(--card); }
.btn.small { font-size: 1rem; min-height: 44px; padding: 6px 16px; }
.btn.next { background: var(--leaf); margin-top: 6px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Cards ---------- */
.card {
  max-width: 680px;
  margin: 0 auto;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 7px 0 var(--ink), 0 20px 42px rgba(13,43,32,.12);
  padding: 28px;
}
.intro, .finish { background: var(--card); box-shadow: 0 7px 0 var(--ink), 0 20px 42px rgba(13,43,32,.12); }
.intro .hero {
  width: 100%;
  height: 190px;
  margin: 10px auto 18px;
  border-radius: 24px;
  border: 0;
  background: linear-gradient(135deg, var(--accent, var(--sun)), color-mix(in srgb, var(--accent, var(--sun)) 45%, var(--indigo)));
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}
.intro .hero::before, .intro .hero::after { content: ''; position: absolute; border-radius: 999px; background: rgba(255,255,255,.2); transform: rotate(-18deg); }
.intro .hero::before { width: 280px; height: 90px; left: -38px; bottom: -24px; }
.intro .hero::after { width: 220px; height: 70px; right: -36px; top: -20px; }
.intro .hero svg { width: 128px; height: 128px; padding: 18px; border-radius: 32px; background: var(--card); border: 3px solid var(--ink); box-shadow: 0 8px 0 rgba(13,43,32,.8); position: relative; z-index: 1; }
body[data-game="LP-001"] .intro .hero { height: 280px; background: linear-gradient(90deg, rgba(13,43,32,.08), rgba(13,43,32,0)), url('/play/assets/art/lp-001-word-safari-v2.png') center/cover; }
body[data-game="LP-001"] .intro .hero::before, body[data-game="LP-001"] .intro .hero::after { display: none; }
body[data-game="LP-001"] .intro .hero svg { display: none; }
.intro h1 { font-size: clamp(2.1rem, 5vw, 3.3rem); line-height: 1.02; margin: 0 0 10px; text-align: center; letter-spacing: -.035em; }
.intro .lede { text-align: center; font-size: 1.15rem; margin: 0 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-start; margin-bottom: 4px; }
.chip {
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.9rem;
  font-weight: 600;
}
.goal {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  padding: 10px 14px;
  margin: 12px 0;
}
.how-title { font-size: 1.1rem; margin: 14px 0 4px; }
.how { margin: 0 0 12px; padding-left: 22px; }
.how li { margin: 4px 0; }
.best { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 10px 0; font-weight: 600; }
.intro .start { width: 100%; margin-top: 8px; }
.story-box {
  margin-top: 16px;
  background: var(--indigo);
  color: var(--paper);
  border-radius: 14px;
  padding: 12px 14px;
  border: 2px solid var(--ink);
}
.story-box p { margin: 0 0 8px; }
.story-box .btn { background: var(--paper); }
.finish { text-align: center; }
.finish h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); line-height: .95; letter-spacing: -.04em; margin: 12px 0; }
.finish .lede { max-width: 34rem; margin: 0 auto 18px; font-size: 1.15rem; }
.finish .actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
.finish .stars-legend { color: var(--muted); font-size: .9rem; }
.note-box {
  background: var(--sky-soft);
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 12px 14px;
}
.note-box p { margin: 0; }
.fact-title { font-weight: 700; margin: 0 0 4px; }
.fact-box {
  background: var(--leaf-soft);
  border: 2px solid var(--ink);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 4px 0;
}
.fact-box p { margin: 0; }

/* ---------- Play screen ---------- */
.play-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.play-bar { padding: 16px 18px; border: 3px solid var(--ink); border-radius: 20px; background: var(--card); box-shadow: 0 4px 0 var(--ink); }
.round-label { font-weight: 700; font-size: 1.1rem; }
.dots { display: flex; gap: 8px; }
.dot-pip, .dots .dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--card);
  display: inline-block;
}
.dots .dot.done { background: var(--ink); }
.dots .dot.now { background: var(--mango); }
.stage { display: flex; flex-direction: column; gap: 18px; margin-top: 18px; padding: 18px; border: 3px solid var(--ink); border-radius: 24px; background: linear-gradient(145deg, rgba(255,253,247,.98), rgba(242,234,219,.82)); box-shadow: 0 6px 0 var(--ink); }
.stage > .map-wrap, .stage > .suitcase, .stage > .memory-board, .stage > .pads, .stage > .seq-tray, .stage > .build-slots, .stage > .story-slots, .stage > .path-board { position: relative; }
.stage > .map-wrap, .stage > .suitcase, .stage > .memory-board, .stage > .pads, .stage > .seq-tray, .stage > .build-slots, .stage > .story-slots, .stage > .path-board { z-index: 0; }
.stage > .suitcase { border-width: 3px; box-shadow: 0 5px 0 var(--ink), 0 12px 24px rgba(13,43,32,.08); }
.stage > .map-wrap { padding: 4px; border-radius: 22px; background: var(--card); box-shadow: 0 5px 0 var(--ink); }
.stage > .memory-board, .stage > .pads, .stage > .seq-tray, .stage > .build-slots, .stage > .story-slots, .stage > .path-board { padding: 4px; }
.stage .build-prompt, .stage .story-prompt, .stage .pattern-prompt { padding: 12px 14px; margin: 0; border: 2px solid var(--ink); border-radius: 14px; background: var(--surface-2); font-weight: 700; }
.stage > .build-art,
.stage > .count-field,
.stage > .beat-grid,
.stage > .web,
.stage > .pie,
.stage > .note-box,
.stage > .fact-box,
.stage > .story-text,
.stage > .story-options,
.stage > .token-tray,
.stage > .pat-row {
  position: relative;
  z-index: 0;
}
.stage > .build-art,
.stage > .count-field,
.stage > .web,
.stage > .pie,
.stage > .note-box,
.stage > .fact-box,
.stage > .story-text,
.stage > .pat-row {
  box-shadow: 0 4px 0 var(--ink);
}
.stage > .build-art,
.stage > .count-field,
.stage > .note-box,
.stage > .fact-box,
.stage > .story-text {
  border-width: 3px;
}
.stage > .beat-grid,
.stage > .story-options,
.stage > .token-tray {
  padding: 4px;
}
.stage > .web,
.stage > .pie {
  background: var(--card);
  padding: 4px;
}
.stage > .web { max-width: 488px; }
.stage > .pie { max-width: 288px; }
.stage > .count-field { width: 100%; }
.stage > .story-options { border: 2px dashed var(--line-soft); border-radius: 16px; }
.stage > .beat-grid { border: 2px solid var(--ink); border-radius: 16px; background: var(--surface-2); }
.stage > .pattern-status,
.stage > .build-status,
.stage > .count-tally,
.stage > .found-count,
.stage > .round-title,
.stage > .seq-title {
  width: 100%;
  margin: 0;
  padding: 9px 12px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--surface-2);
}
.stage > .pattern-status,
.stage > .build-status,
.stage > .count-tally,
.stage > .found-count { box-shadow: 0 3px 0 var(--ink); }
.stage > .round-title,
.stage > .seq-title { background: var(--card); font-size: 1.1rem; }
.msg {
  min-height: 2.4em;
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  margin: 0;
  border: 2px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}
.msg.ok { background: var(--leaf-soft); }
.msg.no { background: var(--warn-soft); }
.msg-icon { width: 22px; height: 22px; flex: 0 0 22px; }

/* Feedback uses outline and motion together, so it still shows with reduced motion. */
.shake { outline: 4px solid var(--clay) !important; outline-offset: 2px; animation: shake 0.45s; }
.pulse-ok { outline: 4px solid var(--leaf) !important; outline-offset: 2px; animation: pulse 0.45s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

.pattern-status { text-align: center; font-size: 1.2rem; font-weight: 600; min-height: 1.5em; margin: 0; }
.build-status { text-align: center; font-weight: 600; min-height: 1.5em; margin: 0; }
.round-title { font-weight: 700; font-size: 1.15rem; margin: 0; }
.found-count { font-weight: 700; text-align: center; margin: 0; font-size: 1.15rem; }

/* ---------- sort ---------- */
.pick-tray, .suitcase-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
}
.pick {
  font: inherit;
  color: var(--ink);
  min-height: 112px;
  padding: 10px 8px;
  width: 100%;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--lift);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.1s ease;
}
.pick.is-selected { background: var(--sun); transform: translateY(-3px); }
.pick-art { width: 62px; height: 62px; }
.pick-label { font-size: 0.95rem; font-weight: 600; text-align: center; }

.bins {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}
.bin {
  font: inherit;
  color: var(--ink);
  min-height: 118px;
  padding: 8px;
  background: #fff8e4;
  border: 2px dashed rgba(13, 43, 32, 0.35);
  border-radius: 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.bin.letter .bin-head { font-size: 2.6rem; font-weight: 700; line-height: 1; }
.bin-head { font-size: 1rem; font-weight: 600; text-align: center; }
.bin-pile { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; min-height: 36px; }
.pile-art { width: 34px; height: 34px; }

/* ---------- sequence ---------- */
.seq-title { font-weight: 700; margin: 0; }
.seq-slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.seq-slot {
  min-height: 58px;
  border: 2px dashed rgba(13, 43, 32, 0.35);
  border-radius: 14px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
}
.seq-slot.filled { border-style: solid; background: var(--card); }
.seq-num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-weight: 700; flex: 0 0 30px;
}
.seq-slot.filled .seq-num { display: none; }
.seq-mini { width: 44px; height: 44px; flex: 0 0 44px; }
.seq-tray { display: grid; gap: 10px; }
.seq-card {
  font: inherit;
  color: var(--ink);
  width: 100%;
  min-height: 68px;
  padding: 8px 12px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--lift);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  font-size: 1.05rem;
}
.seq-art { width: 52px; height: 52px; flex: 0 0 52px; }
.seq-text { font-weight: 600; }

/* ---------- memory (shadow match) ---------- */
.memory-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 10px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}
.mcard {
  position: relative;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
}
.mcard.open, .mcard.matched { transform: rotateY(180deg); }
.mcard-back, .mcard-face {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  border: 2px solid var(--ink);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.mcard-back {
  background:
    radial-gradient(circle at 50% 50%, var(--sun) 0 18%, transparent 19%),
    var(--indigo);
  box-shadow: var(--lift);
}
.mcard-face {
  transform: rotateY(180deg);
  background: var(--card);
  display: grid;
  place-items: center;
  padding: 10%;
}
.mcard.matched .mcard-face { background: var(--leaf-soft); }
.mcard-art { width: 100%; height: 100%; }
.mcard-art.shadow { filter: brightness(0); }

/* ---------- rhythm ---------- */
.pads {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 440px;
  width: 100%;
  margin: 0 auto;
}
.pad {
  font: inherit;
  min-height: 136px;
  background: var(--pad);
  border: 2px solid var(--ink);
  border-radius: 24px;
  box-shadow: var(--lift);
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 10px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.pad-label {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 12px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
}
.pad.lit {
  transform: scale(1.04);
  box-shadow: inset 0 0 0 8px var(--card), var(--lift);
}
.pad.lit::after { content: ''; }
.pad:disabled { cursor: default; }

/* ---------- build (word tiles) ---------- */
.build-art {
  width: 160px;
  height: 160px;
  margin: 0 auto;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 22px;
  padding: 14px;
}
.build-pic { width: 100%; height: 100%; }
.build-slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.build-slot {
  min-width: 96px;
  min-height: 64px;
  padding: 4px 12px;
  border: 2px dashed rgba(13, 43, 32, 0.35);
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  font-weight: 700;
}
.build-slot.filled { border-style: solid; background: var(--sun); }
.tile-tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tile {
  font: inherit;
  font-size: 1.4rem;
  font-weight: 700;
  min-width: 86px;
  min-height: 64px;
  padding: 6px 14px;
  background: var(--card);
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--lift);
  cursor: pointer;
}
.tile.used { opacity: 0.25; box-shadow: none; cursor: default; }
.build-controls, .shop-controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* ---------- shop (coins) ---------- */
.shop-head { display: flex; align-items: center; gap: 16px; }
.shop-art {
  width: 118px; height: 118px; flex: 0 0 118px;
  background: var(--leaf-soft);
  border: 2px solid var(--ink);
  border-radius: 20px;
  padding: 10px;
}
.shop-pic { width: 100%; height: 100%; }
.shop-tag p { margin: 0; }
.shop-name { font-size: 1.4rem; font-weight: 700; }
.shop-price, .shop-paid { font-size: 1.15rem; font-weight: 600; }
.shop-ask { text-align: center; font-size: 1.25rem; font-weight: 600; margin: 0; }
.shop-total { text-align: center; font-size: 2.2rem; font-weight: 700; margin: 0; }
.coins { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.coin {
  font: inherit;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  box-shadow: var(--lift);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  background: var(--sun);
}
.coin-1 { background: #e9cf93; }
.coin-2 { background: #e8b29c; }
.coin-5 { background: #b9c9ec; }
.coin-10 { background: var(--sun); }

/* ---------- connect (stars) ---------- */
.sky {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  background: #1f2f5c;
  border: 2px solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--lift);
}
.bg-star { fill: #cfd9ff; opacity: 0.7; }
.sky .dot { cursor: pointer; }
.sky .dot .hit { fill: transparent; }
.sky .dot circle:not(.hit) { fill: var(--sun); stroke: var(--ink); stroke-width: 1.5; }
.sky .dot text { fill: var(--ink); }
.sky .dot.done circle:not(.hit) { fill: var(--leaf); }
.sky .dot circle.wrong { stroke: var(--clay); stroke-width: 5; }
.sky .dot:focus-visible { outline: none; }
.sky .dot:focus-visible circle:not(.hit) { stroke: #ffffff; stroke-width: 3; }
.sky .link { stroke: var(--sun); stroke-width: 1.8; stroke-linecap: round; }

/* ---------- spot the change ---------- */
.scene { margin: 0; display: grid; gap: 6px; }
.scene figcaption { font-weight: 700; }
.scene-frame {
  border: 2px solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  background: var(--card);
}
.scene-frame svg { width: 100%; height: auto; }
.scene-tap svg { cursor: pointer; }
.scene-bg { fill: #fbe9c6; }
.scene-ground { fill: #cfe6b9; }
.found-ring { fill: none; stroke: var(--leaf); stroke-width: 3; }

/* ---------- pattern ---------- */
.pat-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(40px, 1fr));
  overflow-x: auto;
  gap: 6px;
}
.cell {
  font: inherit;
  aspect-ratio: 1 / 1;
  padding: 0;
  min-width: 0;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.cell.blank { border-style: dashed; border-color: rgba(13, 43, 32, 0.35); background: #fff8e4; }
.cell.set, .cell.filled { cursor: default; }
.cell:disabled { opacity: 1; }
.token-art { width: 72%; height: 72%; }
.token-tray { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; }
.token {
  font: inherit;
  width: 72px;
  height: 72px;
  padding: 8px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 16px;
  box-shadow: var(--lift);
  cursor: pointer;
}
.token.is-selected { background: var(--sun); transform: translateY(-3px); }

/* ---------- place (map) ---------- */
.map-wrap { max-width: 520px; width: 100%; margin: 0 auto; }
.map {
  width: 100%;
  height: auto;
  display: block;
  border: 2px solid var(--ink);
  border-radius: 18px;
  overflow: hidden;
}
.sea { fill: #bfe3ee; }
.land { fill: #8cc474; stroke: #2f5d3a; stroke-width: 0.8; }
.hit { fill: transparent; }
.island { cursor: pointer; }
.island:focus-visible { outline: none; }
.island:focus-visible .land { stroke: var(--indigo); stroke-width: 2; }
.map-label { fill: var(--ink); font-weight: 700; paint-order: stroke; stroke: var(--card); stroke-width: 1px; }
.placed { pointer-events: none; }
.suitcase {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 18px;
  padding: 12px;
  box-shadow: var(--lift);
}
.suitcase-label { font-weight: 700; margin: 0 0 8px; }

/* ---------- catalogue ---------- */
.catalog-head h1 { font-size: 2.2rem; margin: 6px 0 6px; line-height: 1.1; }
.catalog-head { min-height: 330px; display: flex; flex-direction: column; justify-content: flex-end; background: linear-gradient(0deg, rgba(13,43,32,.94) 0%, rgba(13,43,32,.46) 42%, rgba(13,43,32,0) 78%), url('/play/assets/art/play-hero-v2.png') center/cover; color: var(--paper); border-radius: 24px; padding: 26px; margin-bottom: 22px; box-shadow: var(--shadow-soft); }
.catalog-head .lede { color: rgba(255,247,232,.88); max-width: 34rem; }
.catalog-head .lede { margin: 0; font-size: 1.1rem; }
.game-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 232px));
  justify-content: center;
  gap: 18px;
}
.game-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 3px 0 var(--ink);
  color: var(--ink);
  text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease;
}
.game-card:hover { transform: translateY(-2px); }
.game-art {
  height: 96px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--accent);
  display: grid;
  place-items: center;
}
.game-art svg { width: 70px; height: 70px; }
.game-meta { display: flex; justify-content: space-between; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.game-card h2 { font-size: 1.2rem; margin: 4px 0 0; line-height: 1.15; }
.game-card p { margin: 0; font-size: 0.95rem; color: var(--muted); }
.game-new { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-top: auto; }
.game-card .stars { margin-top: auto; }
.game-card:focus-visible { outline: 4px solid var(--indigo); outline-offset: 4px; }
.catalog-note { margin: 24px 0 0; font-size: 0.95rem; color: var(--muted); text-align: center; }
.catalog-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 18px; }
.catalog-filter { min-height: 46px; padding: 8px 36px 8px 14px; border: 2px solid var(--ink); border-radius: 999px; background: var(--card); color: var(--ink); font: inherit; font-weight: 600; }
.catalog-filter-status { margin: 0 0 0 auto; color: var(--muted); font-size: .92rem; }

/* ---------- finish ---------- */
.finish { text-align: center; }
.finish h1 { font-size: 2.2rem; margin: 10px 0 6px; line-height: 1.1; }
.finish .lede { margin: 0 0 16px; font-size: 1.1rem; }
.finish .actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.finish .actions .btn { width: 100%; }
.finish .story-box { text-align: left; }

/* ---------- stars ---------- */
.stars { display: inline-flex; gap: 4px; vertical-align: middle; }
.stars .star { width: 40px; height: 40px; }
.stars .star path { fill: #ede6d0; stroke: var(--ink); stroke-width: 4; stroke-linejoin: round; }
.stars .star.on path { fill: var(--sun); }
.finish .stars .star { width: 56px; height: 56px; }
.stars-legend { margin: 4px 0 14px; color: var(--muted); font-size: .92rem; }

@media (min-width: 640px) {
  .play-main { padding-top: 28px; }
  .pads { grid-template-columns: 1fr 1fr; }
  .scene-pair { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Header audio controls ---------- */
.play-audio { display: flex; align-items: center; gap: 10px; }
.vol { width: 110px; height: 28px; accent-color: var(--sun); }
.vol-label { display: inline-flex; align-items: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.audio-note { font-size: 0.9rem; color: var(--muted); text-align: center; margin: 8px 0 0; }
.chip-id { background: var(--indigo); }

/* ---------- Place: targets and placed marks ---------- */
.target { cursor: pointer; }
.target:focus-visible { outline: none; }
.target:focus-visible .slot, .target:focus-visible .land, .target:focus-visible .pin { stroke: var(--indigo); stroke-width: 2; }
.target .slot { fill: rgba(255, 253, 247, 0.85); stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 3 2; }
.target .outline * { fill: none; stroke: var(--ink); stroke-width: 6; stroke-dasharray: 10 6; }
.target .outline { fill: none; }
.target .pin { fill: var(--mango); stroke: var(--ink); stroke-width: 0.8; }
.target .dotmark { fill: var(--clay); stroke: #fff7e8; stroke-width: 0.6; }
.chip-bg { fill: var(--card); stroke: var(--ink); stroke-width: 0.8; }
.chip-text { fill: var(--ink); font-weight: 700; }
.placed { pointer-events: none; }
.text-pick .pick-label { display: none; }
.pick-text { font-weight: 700; font-size: 1.05rem; text-align: center; }
.pick .pick-art { width: 56px; height: 56px; }

/* ---------- Memory: text cards ---------- */
.mcard-text { font-weight: 700; font-size: 0.95rem; text-align: center; line-height: 1.15; padding: 4px; }
.mcard-art.shadow { filter: brightness(0); }
.mcard.text-card .mcard-face { padding: 8%; }

/* ---------- Sort and sequence extras ---------- */
.pile-chip { font-size: 0.8rem; font-weight: 700; background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 1px 7px; }
.seq-card.big-card { min-height: 76px; }
.seq-big { font-size: 1.9rem; font-weight: 700; min-width: 52px; text-align: center; }
.seq-big.mini { font-size: 1.2rem; min-width: 40px; }
.seq-title { margin: 0 0 4px; font-weight: 700; }
.build-prompt { font-size: 1.2rem; font-weight: 600; text-align: center; margin: 0; }

/* ---------- Count ---------- */
.count-field { position: relative; height: 240px; background: var(--card); border: 2px solid var(--ink); border-radius: 18px; overflow: hidden; }
.count-obj { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); width: 64px; height: 64px; padding: 0; border: 0; background: transparent; cursor: pointer; }
.count-obj::after { content: attr(data-n); position: absolute; left: 50%; top: -6px; transform: translateX(-50%); background: var(--ink); color: var(--paper); border-radius: 999px; font-size: 0.8rem; padding: 0 6px; opacity: 0; }
.count-obj.counted::after { opacity: 1; }
.count-obj.counted .count-art { opacity: 0.6; }
.count-art { width: 100%; height: 100%; }
.count-tally { text-align: center; font-weight: 700; margin: 0; }
.keypad-show { min-height: 2.4em; text-align: center; font-size: 2rem; font-weight: 700; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 320px; width: 100%; margin: 0 auto; }
.key { font: inherit; font-size: 1.4rem; font-weight: 700; min-height: 56px; background: var(--card); border: 2px solid var(--ink); border-radius: 14px; box-shadow: var(--lift); cursor: pointer; color: var(--ink); }
.key.wide { grid-column: span 1.5; font-size: 1rem; }
.key.go { background: var(--leaf); }

/* ---------- Beat grid ---------- */
.beat-grid { display: grid; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.beat-row { display: grid; grid-template-columns: 96px repeat(8, minmax(26px, 1fr)); gap: 5px; align-items: center; min-width: 320px; }
.beat-lane { font: inherit; font-size: 0.85rem; font-weight: 700; min-height: 44px; background: var(--lane); color: var(--ink); border: 2px solid var(--ink); border-radius: 12px; cursor: pointer; padding: 2px 4px; }
.beat-cell { min-height: 44px; background: var(--card); border: 2px solid var(--ink); border-radius: 8px; cursor: pointer; padding: 0; }
.beat-cell.bar { border-width: 3px; }
.beat-cell.on { background: var(--sun); }
.beat-cell.now { outline: 3px solid var(--indigo); outline-offset: 1px; }

/* ---------- Shade (pie) ---------- */
.pie { width: 100%; max-width: 280px; height: auto; margin: 0 auto; display: block; }
.slice { fill: var(--card); stroke: var(--ink); stroke-width: 1.6; cursor: pointer; }
.slice.on { fill: var(--sun); }
.slice:focus-visible { outline: none; stroke: var(--indigo); stroke-width: 3; }
.pie-edge { fill: none; stroke: var(--ink); stroke-width: 2; pointer-events: none; }

/* ---------- Tap-clear (reef) ---------- */
.reef { background: #8fd3e8; }
.clear-item { cursor: pointer; }
.clear-item.litter { filter: drop-shadow(0 1px 0 rgba(13, 43, 32, 0.4)); }
.clear-item.gone { opacity: 0; transition: opacity 0.4s; pointer-events: none; }
.clear-item:focus-visible { outline: none; }
.clear-item:focus-visible { filter: drop-shadow(0 0 2px var(--indigo)); }

/* ---------- Story builder ---------- */
.story-text { font-size: 1.25rem; line-height: 1.5; background: var(--card); border: 2px solid var(--ink); border-radius: 16px; padding: 14px; margin: 0; min-height: 3em; }
.story-text mark { background: var(--sun); padding: 0 3px; border-radius: 4px; }
.story-slot-label { font-weight: 700; margin: 4px 0 0; }
.story-options { display: flex; flex-wrap: wrap; gap: 8px; }
.story-option { font: inherit; font-size: 1rem; min-height: 48px; padding: 8px 14px; background: var(--card); color: var(--ink); border: 2px solid var(--ink); border-radius: 999px; box-shadow: var(--lift); cursor: pointer; }
.story-option.is-selected { background: var(--leaf-soft); transform: translateY(-2px); }

/* ---------- Path (Anansi's web) ---------- */
.web { width: 100%; max-width: 480px; height: auto; margin: 0 auto; display: block; border: 2px solid var(--ink); border-radius: 18px; overflow: hidden; }
.thread { stroke: #2b2b2b; stroke-width: 0.8; stroke-dasharray: 2 1.4; }
.web-node { cursor: pointer; }
.web-node:focus-visible { outline: none; }
.web-node .node-dot { fill: var(--card); stroke: var(--ink); stroke-width: 1.2; }
.web-node.got .node-dot { fill: var(--leaf); }
.web-node .hit { fill: transparent; }
.node-item { pointer-events: none; }
.spider { pointer-events: none; transition: transform 0.35s ease; }

/* ---------- Little Stories reader pages ---------- */
.story-page { max-width: 640px; }
.story-read { background: var(--card); border: 2px solid var(--ink); border-radius: 22px; box-shadow: 0 4px 0 var(--ink); padding: 26px 24px; font-size: 1.12rem; line-height: 1.65; }
.story-read h1 { font-size: 2rem; line-height: 1.15; margin: 0 0 8px; }
.story-read .story-meta { font-size: 0.95rem; color: var(--muted); }
.story-read hr { border: 0; border-top: 2px dashed var(--ink); margin: 18px 0; }
.story-read p { margin: 0 0 14px; }
.story-play, .story-back { text-align: center; margin: 18px 0 0; }
.story-play .btn { margin: 4px; }

/* ---------- Language links (games with a Kreyòl or Kiswahili version) ---------- */
.lang-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 0 0 12px; }
.lang-link { font-size: 0.95rem; font-weight: 600; padding: 4px 12px; border: 2px solid var(--ink); border-radius: 999px; color: var(--ink); text-decoration: none; background: var(--card); }
.lang-link.is-current { background: var(--ink); color: var(--paper); }

/* Board hint: spots that accept the selected piece */
.target.hint .slot, .target.hint .land, .target.hint .pin { stroke: var(--leaf); stroke-width: 2.5; }
.target.hint .slot { fill: var(--leaf-soft); }

/* ---------- Play screen header, help card, error state ---------- */
.play-heading { display: flex; flex-direction: column; gap: 2px; }
.play-title { font-weight: 700; font-size: 1.1rem; line-height: 1.2; }
.play-tools { display: flex; align-items: center; gap: 10px; }
.help-btn { min-height: 40px; }
.help-card { background: var(--card); border: 3px solid var(--ink); border-radius: 20px; padding: 16px 18px; margin-top: 10px; box-shadow: 0 4px 0 var(--ink); }
.help-card h2 { font-size: 1.05rem; margin: 0 0 6px; }
.help-card ol { margin: 0 0 8px; padding-left: 22px; }
.engine-error { background: var(--warn-soft); border: 2px solid var(--ink); border-radius: 16px; padding: 14px; text-align: center; }
.engine-error p { margin: 0 0 10px; font-weight: 600; }
.catalog-note a { color: var(--ink); font-weight: 600; }
.policy h1 { font-size: 2rem; }
.policy h2 { font-size: 1.2rem; margin-top: 22px; }
.policy p, .policy li { font-size: 1.05rem; }
.policy-back { margin-top: 26px; }

/* Phones: pictures first, then the board they go on */
@media (max-width: 640px) {
  .play-main { padding: 20px 12px 48px; }
  .card { padding: 20px 16px; border-radius: 22px; }
  .play-bar { padding: 12px 14px; }
  .stage { gap: 14px; padding: 12px; border-radius: 20px; }
  .stage > .build-art { width: 136px; height: 136px; }
  .stage > .count-field { min-height: 220px; }
  .stage > .story-text { font-size: 1.08rem; }
  .stage > .beat-grid { padding: 8px 6px; }
  .stage > .memory-board { gap: 7px; }
  .stage > .pads { gap: 10px; }
  .pad { min-height: 112px; border-radius: 18px; }
  .stage:has(> .suitcase) { flex-direction: column-reverse; }
}

/* Language matching: keep the picture tray before the word board so children
   choose a picture and then move forward to the words without backtracking. */
.play-screen.game-language .stage {
  flex-direction: column-reverse;
}

/* Small phones: header wraps onto two rows instead of squeezing */
.play-top a, .play-brand, .mute { white-space: nowrap; }
@media (max-width: 480px) {
  .play-top { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px; }
  .play-brand { font-size: 1rem; }
  .mute { font-size: 0.9rem; padding: 6px 10px; }
  .vol { width: 84px; }
  .catalog-filter { flex: 1 1 180px; }
  .catalog-filter-status { width: 100%; margin: 0; }
}
