/* =========================================================================
   Rachael's Scrapbook — the approved design: cream paper, cut-out letters,
   white cards with photo blocks, serif headings, washi tape.
   No external fonts, no CDN, nothing to load from anyone else.
   ========================================================================= */

:root {
  --cream: #fdf6ec;
  --cream-2: #fbead8;
  --card: #fffdf9;
  --ink: #3b2b23;
  --ink-soft: #8a7566;
  --line: #efe2d2;

  --coral: #e8756a;
  --coral-soft: #fbe3df;
  --yellow: #f5c542;
  --yellow-soft: #fdf0c9;
  --teal: #3fa08e;
  --teal-soft: #dbefe9;
  --peach: #f6dcc8;
  --red: #8e3b32;
  --olive: #7d6c22;
  --green: #2f6b5e;
  --sky: #7fc4de;

  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --hand: "Segoe Script", "Bradley Hand", "Noteworthy", "Comic Sans MS", cursive;
  --body: "Trebuchet MS", ui-sans-serif, system-ui, -apple-system, sans-serif;

  --shadow: 0 10px 24px rgba(96, 68, 48, 0.10);
  --shadow-sm: 0 4px 12px rgba(96, 68, 48, 0.10);
  --r: 20px;
  --tap: 48px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 12% 6%, rgba(255,255,255,.85), transparent 42%),
    radial-gradient(circle at 88% 10%, rgba(246,220,200,.55), transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(219,239,233,.5), transparent 55%);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(15px, 0.55vw + 13px, 18px);
  line-height: 1.5;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-family: var(--serif); font-weight: 700; letter-spacing: -0.01em; }

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

.tape {
  position: absolute;
  width: 92px; height: 24px;
  background: rgba(246, 220, 200, .95);
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,.4) 0 5px, transparent 5px 11px);
  box-shadow: 0 2px 4px rgba(96,68,48,.10);
  transform: rotate(-3deg);
  pointer-events: none;
}
.tape-top { top: -12px; left: 50%; translate: -50% 0; }

/* ── gate ─────────────────────────────────────────────────────────────── */
.gate {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 20px;
  background: var(--cream);
  background-image: radial-gradient(circle at 50% 20%, #fff, transparent 60%);
}
.gate-card {
  position: relative;
  width: min(400px, 100%);
  padding: clamp(22px, 4vw, 32px);
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  transform: rotate(-0.5deg);
  text-align: center;
}
.gate-title { font-size: 1.6rem; }
.gate-sub { margin: 6px 0 18px; color: var(--ink-soft); font-family: var(--hand); font-size: .95rem; }

/* four boxes and a button */
.pin-form { display: grid; gap: 18px; justify-items: center; }
.pin-boxes { display: flex; justify-content: center; gap: 12px; }
.pin-box {
  width: clamp(52px, 16vw, 62px);
  height: clamp(62px, 19vw, 72px);
  padding: 0;
  border: 2px solid #d9c6b4;
  border-radius: 14px;
  background: #fff;
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(1.5rem, 5vw, 1.8rem);
  color: var(--ink);
  box-shadow: inset 0 2px 6px rgba(120, 90, 60, .07);
  transition: border-color .14s ease, box-shadow .14s ease, transform .1s ease;
}
.pin-box:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 4px rgba(232, 117, 106, .18);
  transform: translateY(-2px);
}
.pin-box.is-filled { border-color: var(--coral); background: #fffdf8; }
.pin-box.is-bad { border-color: var(--red); background: #fdecea; animation: pin-shake .3s ease; }
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}
.pin-submit { min-width: 200px; }
.gate-msg { min-height: 1.4em; margin: 14px 0 0; color: var(--coral); font-weight: 700; }

/* ── shell ────────────────────────────────────────────────────────────── */
.app {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(12px, 2.4vw, 28px) 90px;
}

/* ── top bar ──────────────────────────────────────────────────────────── */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: clamp(10px, 2vw, 26px);
  padding: 14px 0 18px;
}
.brand {
  display: flex; align-items: center; gap: 10px; min-width: 0;
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
}
.brand-badge {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--yellow-soft);
  border: 1px solid #f3e2b0;
  color: var(--yellow);
  font-size: 1.1rem;
  flex: 0 0 auto;
}
.brand-copy { display: grid; min-width: 0; }
.brand-name {
  font-family: var(--serif);
  font-size: clamp(.95rem, 1.3vw, 1.15rem);
  font-weight: 700;
  color: var(--red);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub { font-family: var(--hand); font-size: .72rem; color: var(--ink-soft); }

.nav-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  background: rgba(255,255,255,.6);
  border-radius: 999px;
  border: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-pills::-webkit-scrollbar { display: none; }

/* on a phone the rooms wrap onto a second line instead of hiding off the edge */
@media (max-width: 620px) {
  .nav-pills {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    border-radius: 20px;
    overflow-x: visible;
    row-gap: 6px;
  }
  .nav-pill { flex: 0 1 auto; }
}
@media (max-width: 420px) {
  .peek-left, .peek-right { display: none; }
  .help-btn, .message-btn, .grown-btn {
    right: 10px;
    width: 44px; min-width: 44px;
    padding: 0; justify-content: center;
  }
  .message-btn { bottom: 112px; }
  .help-btn { bottom: 62px; }
}
.nav-pill {
  min-height: 40px;
  padding: 0 16px;
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: .88rem;
  font-weight: 600;
  color: #6d5a4c;
  cursor: pointer;
  white-space: nowrap;
}
.nav-pill.is-on { background: var(--coral); color: #fff; }

.round-btn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 1.15rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.round-btn[aria-pressed="false"] { opacity: .45; }

/* ── views ────────────────────────────────────────────────────────────── */
.view { animation: page-in .22s ease both; }
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.view-head { margin: 6px 0 clamp(12px, 2vw, 20px); }
.view-title { font-size: clamp(1.4rem, 2.6vw, 2rem); color: var(--red); }
.view-sub { margin: 4px 0 0; color: var(--ink-soft); font-family: var(--hand); font-size: .92rem; }

/* ── cover: name + note ───────────────────────────────────────────────── */
.cover-top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: clamp(12px, 2vw, 24px);
  margin-bottom: clamp(14px, 2vw, 24px);
}

.name-block { display: flex; align-items: flex-end; gap: clamp(8px, 1.6vw, 18px); min-width: 0; }

.name-row { display: flex; gap: clamp(3px, .6vw, 7px); flex-wrap: nowrap; }
.name-letter {
  position: relative;
  display: grid; place-items: center;
  width: clamp(30px, 5.2vw, 56px);
  height: clamp(44px, 7.4vw, 78px);
  border-radius: 10px;
  font-family: var(--serif);
  font-size: clamp(1.3rem, 3.4vw, 2.5rem);
  font-weight: 700;
  color: #fffdf7;
  box-shadow: 0 6px 12px rgba(96,68,48,.18);
  transform: rotate(var(--tilt, -2deg)) translateY(var(--lift, 0));
}
.name-letter.flip { --tilt: 2.4deg; --lift: -3px; }

.listen-block { display: flex; align-items: center; gap: 6px; padding-bottom: 4px; }
.listen-word { font-family: var(--hand); font-size: clamp(.85rem, 1.4vw, 1.05rem); color: var(--coral); }
.listen-arrow { color: var(--coral); font-size: 1.1rem; }
.listen-btn {
  position: relative;
  width: clamp(48px, 5vw, 62px);
  height: clamp(48px, 5vw, 62px);
  border-radius: 50%;
  border: none;
  background: var(--yellow);
  color: #5a4308;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(245,197,66,.45);
}
.listen-count {
  position: absolute; top: -4px; right: -2px;
  min-width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--coral); color: #fff;
  font-size: .68rem; font-weight: 700;
}

.birthday-note {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px 12px 12px;
  background: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.note-heart {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 1.1rem;
  flex: 0 0 auto;
}
.note-copy { display: grid; }
.note-title { font-family: var(--serif); font-weight: 700; font-size: .98rem; color: var(--ink); }
.note-sub { font-family: var(--hand); font-size: .8rem; color: var(--ink-soft); }

/* ── cover tiles ──────────────────────────────────────────────────────── */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(12px, 1.8vw, 22px);
}

.tile {
  grid-column: span 2;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 44%) minmax(0, 1fr);
  align-items: end;
  gap: 14px;
  min-height: 180px;
  padding: 14px 16px 14px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  text-align: left;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.tile.wide { grid-column: span 3; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.tile:active { transform: scale(.99); }

.tile-media {
  position: relative;
  align-self: stretch;
  min-height: 138px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(150deg, var(--m1, #fbe3df), var(--m2, #f6dcc8));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.6);
}
.tile-media img { width: 100%; height: 100%; object-fit: cover; }
.tile-media .glyph { font-size: clamp(2.4rem, 4.6vw, 3.6rem); filter: drop-shadow(0 3px 6px rgba(0,0,0,.12)); }

.tile-pill {
  position: absolute;
  left: 12px; bottom: 12px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  font-family: var(--body);
  font-size: .72rem;
  font-weight: 600;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0,0,0,.10);
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--coral)); flex: 0 0 auto; }

.tile-copy { display: grid; gap: 4px; align-content: end; min-width: 0; padding-right: 44px; }
.tile-name {
  font-family: var(--serif);
  font-size: clamp(1.15rem, 1.9vw, 1.5rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--name-colour, var(--ink));
}
.tile-blurb { font-size: .8rem; color: var(--ink-soft); line-height: 1.32; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.tile-icon {
  position: absolute;
  right: 12px; top: 12px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: var(--chip, var(--coral-soft));
  font-size: 1.05rem;
}

/* ── garden strip / footer ────────────────────────────────────────────── */
.garden-strip {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-top: clamp(14px, 2vw, 22px);
}
.garden-pill {
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--green);
  font-size: .78rem;
  font-weight: 600;
}
.sticker-tease { font-family: var(--hand); font-size: .8rem; color: var(--ink-soft); }

.book-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: clamp(18px, 3vw, 30px);
  padding: 14px 4px;
  border-top: 1px solid var(--line);
  font-family: var(--hand);
  font-size: .8rem;
  color: var(--ink-soft);
}
.foot-heart { color: var(--coral); }
.foot-love { flex: 1 1 auto; }
.foot-marks { font-size: .75rem; }

/* ── family album ─────────────────────────────────────────────────────── */
.album-wrap { display: grid; gap: clamp(14px, 2.4vw, 26px); }
.album {
  padding: clamp(14px, 2.4vw, 22px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.album-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.album-title { font-size: clamp(1.05rem, 2vw, 1.3rem); color: var(--red); }
.album-count { font-family: var(--hand); color: var(--ink-soft); font-size: .78rem; }
.shots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  gap: clamp(10px, 1.6vw, 16px);
}
.shot-card {
  position: relative;
  padding: 7px 7px 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: transform .16s ease;
}
.shot-card:nth-child(4n+1) { transform: rotate(-1deg); }
.shot-card:nth-child(4n+2) { transform: rotate(.7deg); }
.shot-card:nth-child(4n+3) { transform: rotate(-.4deg); }
.shot-card:nth-child(4n+4) { transform: rotate(1deg); }
.shot-card:hover { transform: rotate(0) scale(1.02); z-index: 2; }
.shot-img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 5px; background: var(--cream-2); }
.shot-cap {
  display: block; padding: 7px 3px 9px;
  font-family: var(--hand); font-size: .8rem; line-height: 1.25;
  color: var(--ink); word-break: break-word;
}
.empty {
  padding: 22px; text-align: center;
  font-family: var(--hand); color: var(--ink-soft);
  border: 2px dashed var(--line); border-radius: var(--r);
}

/* ── lightbox ─────────────────────────────────────────────────────────── */
.lightbox {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center; padding: 16px;
  background: rgba(59,43,35,.82);
  animation: page-in .18s ease both;
}
.lightbox img {
  max-width: min(96vw, 1100px); max-height: 78vh; width: auto;
  border: 10px solid #fff; border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  transform: rotate(-.5deg);
}
.lightbox-cap { margin-top: 14px; color: #fff; font-family: var(--hand); font-size: 1rem; text-align: center; max-width: 70ch; }
.lightbox-close {
  position: absolute; top: 14px; right: 14px;
  width: var(--tap); height: var(--tap);
  border: none; border-radius: 50%; background: #fff; font-size: 1.2rem; cursor: pointer;
}

/* ── stories ──────────────────────────────────────────────────────────── */
.story-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.6vw, 16px);
}
@media (max-width: 860px) {
  .story-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 470px) {
  .story-list { grid-template-columns: minmax(0, 1fr); }
}
.story-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 16px 15px; min-height: 132px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-sm); text-align: left; cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.story-card:nth-child(odd) { transform: rotate(-.4deg); }
.story-card:nth-child(even) { transform: rotate(.4deg); }
.story-card.is-original { background: #fff8ee; }
.story-card:hover { transform: rotate(0) translateY(-3px); box-shadow: var(--shadow); }
.story-num { font-family: var(--hand); color: var(--coral); font-size: .72rem; letter-spacing: .07em; text-transform: uppercase; }
.story-name { font-family: var(--serif); font-size: 1.04rem; line-height: 1.2; color: var(--red); }
.story-tease { font-size: .78rem; color: var(--ink-soft); line-height: 1.34; }
.story-by {
  align-self: start;
  margin-top: 2px; padding: 2px 8px;
  border-radius: 999px;
  background: var(--peach-soft, #fbe3df);
  font-family: var(--hand); font-size: .66rem; letter-spacing: .04em;
  color: var(--teal-dark, #2f6b5e);
}
.story-page .story-by {
  margin: 2px 0 8px;
  display: inline-block;
}

/* the tile that invites a new story — the same size as any other story card */
.story-card.make {
  align-items: center; justify-content: center; text-align: center; gap: 8px;
  border-style: dashed; border-width: 2px; border-color: rgba(232,117,106,.55);
  background: linear-gradient(160deg, #fffdf8, var(--peach-soft, #fbe3df));
  transform: none;
}
.story-card.make .make-plus {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--coral); color: #fff; font-size: 1.4rem; line-height: 1;
  box-shadow: var(--shadow-sm);
}
.story-card.make .make-copy { display: grid; gap: 3px; }
.story-card.make .make-title { font-family: var(--serif); font-size: 1rem; color: var(--red); }
.story-card.make .make-sub { font-size: .76rem; color: var(--ink-soft); }

/* ── the story maker, as a sheet of picture choices ───────────────────── */
.make-modal {
  position: fixed; inset: 0; z-index: 94; display: grid; place-items: center;
  padding: clamp(10px, 2.5vw, 28px); background: rgba(59, 43, 35, .5); backdrop-filter: blur(4px);
  overflow-y: auto;
}
.make-modal[hidden] { display: none; }
.make-card {
  position: relative; width: min(760px, 100%);
  max-height: calc(100dvh - 2 * clamp(10px, 2.5vw, 28px));
  overflow-y: auto; overscroll-behavior: contain;
  padding: clamp(18px, 3vw, 28px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 24px 50px rgba(59, 43, 35, .3);
}
.story-picks {
  display: grid; gap: 10px; margin: 4px 0 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
@media (max-width: 620px) { .story-picks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } }
@media (max-width: 380px) { .story-picks { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.story-pick {
  display: grid; gap: 4px; justify-items: center; padding: 6px 6px 8px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  cursor: pointer; transition: transform .14s ease, border-color .14s ease;
}
.story-pick img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px; display: block; background: var(--cream-2); }
.story-pick .pick-emoji { display: grid; place-items: center; width: 100%; aspect-ratio: 1 / 1; font-size: 2rem; }
.story-pick span.pick-name { font-family: var(--hand); font-size: .74rem; color: var(--ink); text-align: center; line-height: 1.15; }
.story-pick:active { transform: scale(.96); }
.story-pick.is-on { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(232,117,106,.22); }

.story-maker-note { margin: 6px 0 14px; font-size: .88rem; color: var(--ink-soft); line-height: 1.45; }
.story-maker-form { display: flex; flex-wrap: wrap; gap: 10px; }
.story-maker-input {
  flex: 1 1 240px; min-height: var(--tap);
  padding: 0 16px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font: inherit; font-size: .95rem; color: var(--ink);
}
.story-maker-input:focus { outline: 3px solid rgba(232,117,106,.3); outline-offset: 1px; }
.story-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.story-chip {
  min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: .78rem; color: var(--ink-soft); cursor: pointer;
}
.story-chip:active { background: var(--peach-soft, #fbe3df); }

/* ── the writing modal ────────────────────────────────────────────────── */
body.is-writing { overflow: hidden; }
.writing {
  position: fixed; inset: 0; z-index: 92;
  display: grid; place-items: center;
  padding: clamp(14px, 4vw, 32px);
  background: rgba(59, 43, 35, .46);
  backdrop-filter: blur(6px);
  animation: writing-fade .2s ease both;
}
.writing[hidden] { display: none; }
@keyframes writing-fade { from { opacity: 0; } to { opacity: 1; } }

.writing-card {
  position: relative;
  width: min(460px, 100%);
  padding: clamp(24px, 5vw, 40px) clamp(20px, 4vw, 34px) clamp(22px, 4vw, 32px);
  text-align: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 26px 60px rgba(59, 43, 35, .3);
  animation: writing-pop .34s cubic-bezier(.2, 1.3, .4, 1) both;
}
@keyframes writing-pop {
  from { opacity: 0; transform: translateY(22px) scale(.9) rotate(-2deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

.writing-art { display: grid; place-items: center; margin-bottom: 14px; }
.writing-art svg { width: clamp(160px, 42vw, 210px); height: auto; overflow: visible; }

.writing-sheet { transform-origin: center; animation: sheet-bob 2.4s ease-in-out infinite; }
@keyframes sheet-bob {
  0%, 100% { transform: translateY(0) rotate(-1.4deg); }
  50% { transform: translateY(-5px) rotate(1.4deg); }
}

.writing-lines line { animation: line-write 2.4s ease-in-out infinite; transform-origin: left center; }
.writing-lines line:nth-child(2) { animation-delay: .28s; }
.writing-lines line:nth-child(3) { animation-delay: .56s; }
.writing-lines line:nth-child(4) { animation-delay: .84s; }
@keyframes line-write {
  0% { transform: scaleX(.25); opacity: .35; }
  45%, 70% { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(.25); opacity: .35; }
}

.writing-pencil { animation: pencil-scribble .9s ease-in-out infinite; transform-origin: 156px 65px; }
@keyframes pencil-scribble {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  35% { transform: translate(-14px, 9px) rotate(-5deg); }
  70% { transform: translate(-6px, 18px) rotate(2deg); }
}

.writing-stars circle { animation: star-twinkle 1.8s ease-in-out infinite; }
.writing-stars circle:nth-child(2) { animation-delay: .4s; }
.writing-stars circle:nth-child(3) { animation-delay: .8s; }
.writing-stars circle:nth-child(4) { animation-delay: 1.2s; }
@keyframes star-twinkle {
  0%, 100% { opacity: .25; transform: scale(.8); transform-origin: center; }
  50% { opacity: 1; transform: scale(1.25); transform-origin: center; }
}

.writing-title { font-family: var(--serif); font-size: clamp(1.15rem, 3.4vw, 1.5rem); color: var(--red); }
.writing-sub {
  margin-top: 6px; font-family: var(--hand); font-size: .92rem; color: var(--ink-soft);
  overflow-wrap: anywhere;
}
.writing-dots { display: flex; justify-content: center; gap: 7px; margin: 16px 0 10px; }
.writing-dots i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--coral);
  animation: dot-bounce 1.15s ease-in-out infinite;
}
.writing-dots i:nth-child(2) { animation-delay: .16s; background: var(--gold, #c9a227); }
.writing-dots i:nth-child(3) { animation-delay: .32s; background: var(--teal); }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .55; }
  30% { transform: translateY(-7px); opacity: 1; }
}
.writing-hint { font-size: .76rem; color: var(--ink-soft); }

@media (prefers-reduced-motion: reduce) {
  .writing, .writing-card, .writing-sheet, .writing-lines line,
  .writing-pencil, .writing-stars circle, .writing-dots i { animation: none; }
}
.story-maker-msg { margin-top: 12px; font-size: .84rem; color: var(--teal-dark, #2f6b5e); min-height: 1.2em; }
.story-maker-msg.is-bad { color: var(--red); }

.story-page-count {
  margin: -2px 0 14px;
  font-family: var(--hand);
  font-size: .78rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.story-page {
  position: relative;
  margin-top: clamp(14px, 2vw, 22px);
  padding: clamp(20px, 3.4vw, 40px);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.story-h { font-size: clamp(1.25rem, 2.4vw, 1.7rem); color: var(--red); margin-bottom: 14px; }
.story-body p {
  margin: 0 0 1em;
  font-size: clamp(1.05rem, 1.6vw, 1.22rem);
  line-height: 1.62;
}
.story-body p:last-child { margin-bottom: 0; }
.story-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

/* ── buttons ──────────────────────────────────────────────────────────── */
.big-btn {
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: scale(.97); }
.big-btn.primary { background: var(--coral); color: #fff; border-color: transparent; }

/* ── helicopter room ──────────────────────────────────────────────────── */
.heli-hero { margin-bottom: clamp(14px, 2vw, 22px); }
.launch-btn {
  display: flex; align-items: center; gap: 16px;
  width: 100%; min-height: 110px; padding: 20px 24px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: linear-gradient(140deg, #e8f4f9, #fdf6ec 65%);
  box-shadow: var(--shadow-sm);
  cursor: pointer; text-align: left;
  transition: transform .16s ease;
}
.launch-btn:hover { transform: translateY(-3px); }
.launch-emoji { font-size: clamp(2.2rem, 5vw, 3.2rem); }
.launch-text { font-family: var(--serif); font-size: clamp(1.1rem, 2.4vw, 1.45rem); color: var(--red); }

.video-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: clamp(12px, 2vw, 18px);
}
.video-card { padding: 10px 10px 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-sm); }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 9px; overflow: hidden; background: #1b1410; }
.video-frame iframe, .video-frame video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-name { margin: 10px 4px 0; font-family: var(--hand); font-size: .88rem; }
.video-help {
  display: block; margin: 6px 4px 0; padding: 0; border: none; background: none;
  font-family: var(--hand); font-size: .74rem; color: var(--ink-soft);
  text-decoration: underline; cursor: pointer; min-height: 32px;
}

/* ── games ────────────────────────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: clamp(12px, 2vw, 18px);
}
.game-card {
  padding: 22px 18px; min-height: 146px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-sm); cursor: pointer; text-align: left;
  transition: transform .16s ease;
}
.game-card:hover { transform: translateY(-3px); }
.game-emoji { font-size: 2.4rem; display: block; margin-bottom: 8px; }
.game-name { font-family: var(--serif); font-size: 1.1rem; display: block; color: var(--red); }
.game-blurb { font-size: .8rem; color: var(--ink-soft); display: block; margin-top: 4px; }

.game-stage { padding: clamp(12px, 2vw, 20px); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.stage-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stage-title { font-size: 1.05rem; flex: 1 1 auto; color: var(--red); }
.stage-body { min-height: 320px; }

.mem-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(6px, 1.4vw, 12px); max-width: 620px; margin: 0 auto; }
.mem-card {
  position: relative; aspect-ratio: 3 / 4;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; box-shadow: var(--shadow-sm); cursor: pointer; overflow: hidden; padding: 0;
}
.mem-card .face { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(1.6rem, 6vw, 2.6rem); transition: opacity .2s ease; }
.mem-card .front { background: linear-gradient(150deg, var(--peach), var(--yellow-soft)); z-index: 2; }
.mem-card .back { background: #fff; z-index: 1; }
.mem-card .back img { width: 100%; height: 100%; object-fit: cover; }
.mem-card .glyph { font-size: clamp(1.8rem, 6.5vw, 3rem); }
.mem-card.flipped .front { opacity: 0; }
.mem-card.done { box-shadow: 0 0 0 4px var(--teal) inset; }
.mem-card.done .front { opacity: 0; }

.wash-wrap { display: grid; gap: 14px; justify-items: center; }
.wash-stage { position: relative; width: 100%; max-width: 620px; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.wash-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.wash-car { pointer-events: none; }
.wash-mud { cursor: grab; }
.wash-mud-hard { pointer-events: none; }
.wash-meter { font-family: var(--hand); color: var(--ink-soft); text-align: center; }

/* the line-up of things to wash */
.wash-carousel { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 620px; }
.wash-arrow {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: .9rem; cursor: pointer;
}
.wash-arrow:active { transform: scale(.95); }
.wash-dots {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px;
  scrollbar-width: none; flex: 1 1 auto; scroll-snap-type: x proximity;
}
.wash-dots::-webkit-scrollbar { display: none; }
.wash-dot {
  flex: 0 0 auto; scroll-snap-align: center;
  display: grid; justify-items: center; gap: 1px;
  min-width: 62px; min-height: 56px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; font: inherit; color: var(--ink);
}
.wash-dot-art { font-size: 1.15rem; line-height: 1; }
.wash-dot-name { font-size: .56rem; color: var(--ink-soft); white-space: nowrap; }
.wash-dot.is-on { border-color: var(--coral); background: var(--peach-soft, #fbe3df); box-shadow: 0 0 0 2px rgba(232,117,106,.16); }
.wash-dot.is-on .wash-dot-name { color: var(--red); font-weight: 700; }

.pony-scene { position: relative; display: grid; gap: 14px; justify-items: center; }
.pony-stage { position: relative; width: min(100%, 460px); aspect-ratio: 1 / 1; border-radius: 18px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); background: #cfe0b4; }
.pony-body, .pony-head-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; }
.pony-body { animation: ponyBreath 6.5s ease-in-out infinite; transform-origin: 50% 96%; }
/* the head layer: a soft-edged mask around the head and neck, turning at the withers */
.pony-head { position: absolute; inset: 0; transform-origin: 43% 22%; animation: ponyGraze 9s ease-in-out infinite;
  -webkit-mask-image: radial-gradient(ellipse 24% 33% at 27% 35%, #000 66%, rgba(0, 0, 0, 0) 100%);
  mask-image: radial-gradient(ellipse 24% 33% at 27% 35%, #000 66%, rgba(0, 0, 0, 0) 100%);
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.pony-head-art { animation: ponyChew 1.1s ease-in-out infinite; }
.pony-stage.is-alert .pony-head { animation: ponyAlert 1.9s ease-out 1; }
.pony-treat { position: absolute; left: 24%; top: 52%; font-size: 2.1rem; opacity: 0; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(60, 40, 20, .25)); }
.pony-treat.fly { animation: ponyTreat 1.6s ease-out 1 forwards; }
@keyframes ponyBreath {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.008); }
}
@keyframes ponyGraze {
  0%, 18%, 100% { transform: rotate(0deg); }
  42%, 62% { transform: rotate(-3.2deg); }
  84% { transform: rotate(-1deg); }
}
@keyframes ponyChew {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(0.45%); }
}
@keyframes ponyAlert {
  0% { transform: rotate(0deg); }
  22% { transform: rotate(-6.5deg); }
  55% { transform: rotate(-5.5deg); }
  100% { transform: rotate(0deg); }
}
@keyframes ponyTreat {
  0% { opacity: 0; transform: translate(64px, 120px) scale(.6); }
  22% { opacity: 1; }
  62% { opacity: 1; transform: translate(0, 6px) scale(1); }
  100% { opacity: 0; transform: translate(-8px, 26px) scale(.7); }
}
.pony-tray { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.pony-item { width: 72px; height: 72px; display: grid; place-items: center; font-size: 1.9rem; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow-sm); cursor: pointer; }
.pony-item:active { transform: scale(.94); }
.pony-say { min-height: 1.6em; font-family: var(--hand); font-size: 1rem; text-align: center; }
@media (prefers-reduced-motion: reduce) {
  .pony-body, .pony-head, .pony-head-art { animation: none; }
}

.sim-wrap { position: relative; }
.sim-canvas { width: 100%; aspect-ratio: 16 / 10; border-radius: 14px; background: #bfe3f2; display: block; touch-action: none; }
.sim-hud { position: absolute; inset: auto 12px 12px; display: flex; gap: 8px; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.sim-gauge { padding: 8px 12px; background: rgba(255,253,249,.92); border-radius: 10px; font-family: var(--hand); font-size: .82rem; box-shadow: var(--shadow-sm); }
.sim-pad { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: center; margin-top: 12px; }
.sim-pad button { min-width: var(--tap); min-height: var(--tap); }

/* the engine: a race-car push button that says its state in colour */
.engine-switch {
  position: relative;
  width: 92px; height: 92px; padding: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid #b9c0c6;
  background: radial-gradient(circle at 50% 30%, #ffffff 0 16%, #e9edf0 44%, #c3cad0 72%, #98a1a8 100%);
  box-shadow: 0 4px 0 #8b949b, 0 8px 14px rgba(59, 43, 35, .28), inset 0 1px 0 #fff;
  cursor: pointer;
  touch-action: manipulation;
}
.engine-switch .engine-ring {
  position: absolute; inset: 7px; border-radius: 50%;
  background: radial-gradient(circle at 50% 26%, #f8fafb, #d0d7dc 62%, #adb5bb 100%);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .18);
}
.engine-switch .engine-face {
  position: relative;
  width: 68px; height: 68px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-family: var(--sans); font-size: .92rem; font-weight: 800; letter-spacing: .04em;
  color: #fff;
  transition: background .18s ease, box-shadow .18s ease;
}
.engine-switch.is-off .engine-face {
  background: radial-gradient(circle at 50% 34%, #ff7b6d, #e02c1c 58%, #a8180c 100%);
  box-shadow: 0 0 0 3px #fff, inset 0 -3px 6px rgba(0, 0, 0, .25);
}
.engine-switch.is-on .engine-face {
  background: radial-gradient(circle at 50% 34%, #7fe08a, #22a03a 58%, #14741f 100%);
  box-shadow: 0 0 0 3px #fff, 0 0 16px rgba(46, 180, 74, .65), inset 0 -3px 6px rgba(0, 0, 0, .25);
}
.engine-switch:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #8b949b, 0 4px 8px rgba(59, 43, 35, .25), inset 0 1px 0 #fff;
}
.engine-switch:focus-visible { outline: 3px solid rgba(232, 117, 106, .4); outline-offset: 3px; }
@media (max-width: 480px) {
  .engine-switch { width: 80px; height: 80px; }
  .engine-switch .engine-face { width: 58px; height: 58px; font-size: .8rem; }
}

/* tilt: a little landscape tablet rocking left and right */
.tilt-btn { display: grid; place-items: center; gap: 3px; min-width: 76px; padding: 6px 10px; }
.tilt-art {
  position: relative; display: block;
  width: 34px; height: 22px;
  transform-origin: 50% 100%;
  animation: tilt-rock 2.8s ease-in-out infinite;
}
.tilt-art::before {
  content: ""; position: absolute; inset: 0;
  border-radius: 5px; border: 2px solid currentColor;
  background: linear-gradient(180deg, rgba(255, 255, 255, .9), rgba(214, 232, 238, .65));
}
.tilt-art::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: .35;
  transform: translate(-50%, -50%);
}
.tilt-word { font-size: .6rem; font-weight: 700; letter-spacing: .04em; color: var(--ink-soft); }
@keyframes tilt-rock {
  0%, 100% { transform: rotate(-13deg); }
  50% { transform: rotate(13deg); }
}
.tilt-btn.is-on { border-color: var(--teal-dark, #2f6b5e); box-shadow: 0 0 0 3px rgba(47, 107, 94, .16); }
.tilt-btn.is-on .tilt-art { animation-duration: 1.1s; color: var(--teal-dark, #2f6b5e); }
.tilt-btn.is-on .tilt-word { color: var(--teal-dark, #2f6b5e); }
@media (prefers-reduced-motion: reduce) {
  .tilt-art { animation: none; transform: rotate(-9deg); }
}

/* the keys the sim listens to, along the bottom edge of the view */
.sim-legend {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 4px 8px;
  margin-inline: auto; max-width: 76%;
}
.legend-item {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 6px; border-radius: 8px;
  background: rgba(255, 253, 249, .86);
  border: 1px solid rgba(59, 43, 35, .1);
  font-family: var(--sans); font-size: .58rem; letter-spacing: .03em;
  color: #33403f;
}
.legend-key {
  font-family: var(--sans); font-size: .56rem; font-weight: 700;
  padding: 1px 4px; border-radius: 4px;
  background: #fff; border: 1px solid rgba(59, 43, 35, .22);
  box-shadow: 0 1px 0 rgba(59, 43, 35, .18);
}
@media (max-width: 700px) {
  .legend-what { display: none; }
}
@media (max-width: 420px) {
  .sim-legend { gap: 3px 5px; max-width: 86%; }
  .legend-item { padding: 2px 4px; }
}


/* the '+' gamepad: thrust up and down, nose left and right */
.pad-plus {
  display: grid;
  grid-template-columns: repeat(3, clamp(48px, 13vw, 62px));
  grid-template-rows: repeat(3, clamp(48px, 13vw, 62px));
  grid-template-areas:
    ". up ."
    "left middle right"
    ". down .";
  gap: 6px;
  touch-action: none;
}
.pad-key {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  font-size: 1.1rem;
  color: var(--ink);
  cursor: pointer;
  transition: transform .08s ease, background .12s ease;
}
.pad-key.is-down { background: var(--coral-soft); transform: scale(.95); }
.pad-hub {
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--cream-2);
  color: var(--ink-soft);
  font-size: 1.1rem;
}

/* the height pad, beside the drive pad */
.pad-lift {
  display: grid;
  grid-template-columns: clamp(48px, 13vw, 62px);
  grid-template-rows: repeat(2, clamp(48px, 13vw, 62px));
  grid-template-areas:
    "up"
    "down";
  gap: 6px;
  touch-action: none;
}
.pad-key-tall { min-height: clamp(48px, 13vw, 62px); }
.big-btn.is-on { background: var(--teal); color: #fff; border-color: transparent; }

/* ── chat ─────────────────────────────────────────────────────────────── */
.chat-shell { display: grid; gap: 12px; padding: clamp(12px, 2vw, 18px); background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }
.chat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.chat-note { font-family: var(--hand); font-size: .78rem; color: var(--ink-soft); }
.chat-clear {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.chat-clear:active { background: var(--coral-soft); }
.chat-log { display: flex; flex-direction: column; gap: 10px; min-height: 240px; max-height: 52vh; overflow-y: auto; padding: 4px; }
.bubble { max-width: 86%; padding: 12px 16px; border-radius: 16px; font-size: 1rem; line-height: 1.4; box-shadow: var(--shadow-sm); animation: page-in .18s ease both; }
.bubble.pony { align-self: flex-start; background: var(--teal-soft); border-bottom-left-radius: 5px; }
.bubble.me { align-self: flex-end; background: var(--yellow-soft); border-bottom-right-radius: 5px; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 8px; }
.suggest-chip {
  min-height: 44px; padding: 0 16px;
  border: 2px dashed var(--line); border-radius: 999px;
  background: transparent; font-family: var(--hand); font-size: .86rem; cursor: pointer;
}
.chat-form { display: flex; gap: 8px; min-width: 0; }
.chat-input { flex: 1 1 0; min-width: 0; min-height: var(--tap); padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 1rem; }
.chat-send { width: var(--tap); height: var(--tap); border: none; border-radius: 50%; background: var(--coral); color: #fff; font-size: 1.1rem; cursor: pointer; }
.chat-mic {
  width: var(--tap); height: var(--tap);
  border: 1px solid var(--line); border-radius: 50%;
  background: #fff; font-size: 1.1rem; cursor: pointer;
}
.chat-mic.is-listening { background: var(--teal); border-color: transparent; animation: mic-pulse 1s ease-in-out infinite; }
@keyframes mic-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(63,160,142,.5); } 50% { box-shadow: 0 0 0 9px rgba(63,160,142,0); } }

/* voice is on: a green ring you can see from across the room */
.chat-mic.is-live, #voiceBtn.is-live { border-color: #4f9a4f; animation: live-ring 1.8s ease-out infinite; }
#voiceBtn.is-pointing { outline: 3px solid #4f9a4f; outline-offset: 3px; animation: live-ring 1.8s ease-out infinite; }
@keyframes live-ring {
  0% { box-shadow: 0 0 0 0 rgba(79,154,79,.55); }
  70% { box-shadow: 0 0 0 14px rgba(79,154,79,0); }
  100% { box-shadow: 0 0 0 0 rgba(79,154,79,0); }
}

/* "talk or type", with pictures, the first time she opens the room */
.talk-ask {
  display: grid; gap: 12px; padding: 14px;
  background: #fffaf0; border: 2px dashed var(--line); border-radius: 16px;
}
.talk-ask[hidden] { display: none; }
.talk-q { margin: 0; font-family: var(--serif); font-size: 1.06rem; text-align: center; color: var(--ink); }
.talk-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.talk-card {
  display: grid; place-items: center; gap: 2px; min-height: 118px; padding: 12px 8px;
  background: #fff; border: 2px solid var(--line); border-radius: 16px; cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.talk-card:active { transform: scale(.97); }
.talk-art { font-size: 2.1rem; line-height: 1.1; }
.talk-name { font-family: var(--serif); font-size: 1rem; color: var(--ink); }
.talk-sub { font-size: .7rem; color: var(--ink-soft); text-align: center; }
.talk-where {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0;
  font-family: var(--hand); font-size: .8rem; color: var(--ink-soft); text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .chat-mic.is-live, #voiceBtn.is-live, #voiceBtn.is-pointing { animation: none; box-shadow: 0 0 0 4px rgba(79,154,79,.35); }
}

/* ── peek-a-boo ───────────────────────────────────────────────────────── */
.peek {
  position: fixed; bottom: 6vh;
  width: clamp(110px, 17vw, 230px);
  pointer-events: none; z-index: 5; opacity: 0;
  transition: opacity .5s ease;
}
.peek.show { opacity: 1; }
.peek svg { width: 100%; height: auto; display: block; filter: drop-shadow(0 8px 14px rgba(96,68,48,.18)); }
.peek-left { left: 0; translate: -52% 0; }
.peek-right { right: 0; translate: 52% 0; }
.peek-left.show { animation: peek-in-left 7s ease-in-out; }
.peek-right.show { animation: peek-in-right 7s ease-in-out; }
@keyframes peek-in-left {
  0% { transform: translateX(-70%); opacity: 0; }
  14% { transform: translateX(0); opacity: 1; }
  46% { transform: translateX(-6%) rotate(-3deg); opacity: 1; }
  70% { transform: translateX(-2%); opacity: 1; }
  100% { transform: translateX(-70%); opacity: 0; }
}
@keyframes peek-in-right {
  0% { transform: translateX(70%); opacity: 0; }
  14% { transform: translateX(0); opacity: 1; }
  46% { transform: translateX(6%) rotate(3deg); opacity: 1; }
  70% { transform: translateX(2%); opacity: 1; }
  100% { transform: translateX(70%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .peek-left.show, .peek-right.show { animation: none; opacity: .9; }
  .view { animation: none; }
}

/* ── grown-ups ────────────────────────────────────────────────────────── */
.grown-btn {
  position: fixed; right: 14px; bottom: 14px;
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  font-size: .8rem; color: var(--ink-soft);
  cursor: pointer; z-index: 20; box-shadow: var(--shadow-sm);
}

/* ── there's a problem / message grandad ──────────────────────────────── */
.full-btn { white-space: nowrap; }
.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 94;
  width: 100vw; height: 100vh;
  max-height: none;
  margin: 0;
  border: none; border-radius: 0;
  box-shadow: none;
  overflow: auto;
  background: var(--cream, #fdf6ec);
  padding: clamp(8px, 2vw, 22px);
}
body.is-fullscreen { overflow: hidden; }

/* the flight stage fills the screen; the picture gives way so the buttons never do */
#gameStage.is-fullscreen {
  display: flex; flex-direction: column;
  overflow: hidden;
}
#gameStage.is-fullscreen .stage-head { position: static; flex: 0 0 auto; flex-wrap: wrap; gap: 8px; }
#gameStage.is-fullscreen .stage-body {
  flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
#gameStage.is-fullscreen .sim-wrap { flex: 1 1 auto; min-height: 150px; }
#gameStage.is-fullscreen .sim-canvas { height: 100%; min-height: 150px; aspect-ratio: auto; }
#gameStage.is-fullscreen .sim-pad {
  flex: 0 0 auto;
  margin-top: 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.is-fullscreen .story-body { max-height: none; }
/* a phone held sideways: the picture gives way further so the pad still ends above the fold */
@media (max-height: 480px) {
  #gameStage.is-fullscreen { padding: 6px; }
  #gameStage.is-fullscreen .stage-head { gap: 6px; }
  #gameStage.is-fullscreen .sim-wrap { min-height: 72px; }
  #gameStage.is-fullscreen .sim-canvas { min-height: 72px; }
  #gameStage.is-fullscreen .sim-pad { margin-top: 4px; gap: 8px; }
  #gameStage.is-fullscreen .sim-hud { inset: auto 8px 4px; }
}
.is-fullscreen .story-nav,
.is-fullscreen .stage-head {
  position: sticky; bottom: 0;
  background: var(--cream, #fdf6ec);
  padding-top: 8px;
}

/* keep the floating buttons off the game controls on a phone */
@media (max-width: 620px) {
  body.in-stage .message-btn { bottom: auto; top: 10px; }
  body.in-stage .help-btn { bottom: auto; top: 62px; }
  body.is-fullscreen .help-btn,
  body.is-fullscreen .message-btn,
  body.is-fullscreen .grown-btn { display: none; }
}

.help-btn, .message-btn {
  position: fixed; right: 14px;
  display: flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 0 14px;
  border-radius: 999px;
  font-size: .8rem; font-weight: 600;
  cursor: pointer; z-index: 20; box-shadow: var(--shadow-sm);
}
.help-btn { bottom: 68px; border: 1px solid var(--line); background: rgba(255,255,255,.94); color: var(--ink-soft); }
.message-btn { bottom: 122px; border: 1px solid transparent; background: var(--coral); color: #fff; }

.help {
  position: fixed; inset: 0; z-index: 93;
  display: grid; place-items: center;
  padding: clamp(12px, 3vw, 28px);
  background: rgba(59, 43, 35, .5);
  backdrop-filter: blur(5px);
  animation: writing-fade .18s ease both;
  overflow-y: auto;
}
.help[hidden] { display: none; }
.help-card {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: clamp(20px, 4vw, 30px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 24px 50px rgba(59, 43, 35, .28);
  animation: writing-pop .28s cubic-bezier(.2, 1.3, .4, 1) both;
}
.help-close {
  position: absolute; top: 10px; right: 10px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff;
  font-size: 1rem; color: var(--ink-soft); cursor: pointer;
}
.help-title { font-family: var(--serif); font-size: clamp(1.2rem, 3.4vw, 1.5rem); color: var(--red); padding-right: 40px; }
.help-sub { margin: 6px 0 16px; font-size: .88rem; color: var(--ink-soft); line-height: 1.45; }

.help-kinds { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
.help-kind {
  display: flex; align-items: center; gap: 8px;
  min-height: 52px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 14px;
  background: #fff; font: inherit; font-size: .85rem; font-weight: 600;
  color: var(--ink); text-align: left; cursor: pointer;
}
.help-kind span[aria-hidden] { font-size: 1.15rem; }
.help-kind.is-on { border-color: var(--coral); background: var(--peach-soft, #fbe3df); }

.help-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.help-input {
  flex: 1 1 200px; min-height: var(--tap);
  padding: 0 15px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font: inherit; font-size: .92rem; color: var(--ink);
}
.help-input:focus { outline: 3px solid rgba(232,117,106,.28); outline-offset: 1px; }
.help-send { min-width: 96px; }

.help-thread { display: grid; gap: 8px; margin-top: 14px; }
.help-thread:empty { display: none; }
.help-bubble {
  max-width: 88%; padding: 10px 14px; border-radius: 16px;
  font-size: .88rem; line-height: 1.4;
  animation: bubble-in .22s ease both;
}
.help-bubble.me { justify-self: end; background: var(--coral); color: #fff; border-bottom-right-radius: 5px; }
.help-bubble.pip { justify-self: start; background: var(--cream-2, #f6ece0); color: var(--ink); border-bottom-left-radius: 5px; }
.help-bubble.grandad { justify-self: start; background: #fff; border: 1px solid var(--line); color: var(--ink); border-bottom-left-radius: 5px; }
.help-bubble.grandad::before { content: "Grandad"; display: block; font-family: var(--hand); font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; color: var(--teal); margin-bottom: 3px; }

.help-after { margin-top: 16px; display: grid; gap: 10px; }
.help-got { font-family: var(--hand); font-size: .92rem; color: var(--teal-dark, #2f6b5e); }
.help-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.help-keep { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); display: grid; gap: 10px; }
.help-keep p { font-size: .88rem; color: var(--ink); }
.help-note { margin-top: 12px; font-size: .74rem; color: var(--ink-soft); min-height: 1em; }

.help-reply { display: grid; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }
.help-preview { display: grid; gap: 8px; margin-top: 12px; }
.admin-row.help-row { width: 100%; text-align: left; cursor: pointer; }
.admin-row.help-row.is-on { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(232,117,106,.15); }
.help-dot {
  align-self: center; padding: 3px 9px; border-radius: 999px;
  background: var(--coral); color: #fff; font-size: .66rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
.help-dot.is-waiting { background: #fff; color: var(--ink-soft); border: 1px dashed var(--line); }

/* the small promises under the chat box */
.chat-trust {
  display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center;
  margin: 8px 0 2px; font-family: var(--sans); font-size: .64rem;
  letter-spacing: .04em; color: var(--ink-soft);
}
.chat-trust span {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: #fffdf8;
}

/* ── the chat room: a big sheet, never the whole screen ─────────────────── */
.help-card.is-chat {
  display: flex; flex-direction: column;
  width: min(760px, 100%);
  height: min(72vh, 720px);
  height: min(72dvh, 720px);
  max-height: calc(100dvh - 2 * clamp(12px, 3vw, 28px));
  overflow: hidden;
}
.help-card.is-chat .help-kinds { display: none; }
.help-card.is-chat .help-title { padding-right: 46px; }
.help-card.is-chat .help-thread {
  flex: 1 1 auto; min-height: 96px;
  overflow-y: auto; overscroll-behavior: contain;
  align-content: start; padding-right: 2px;
}
.help-card.is-chat .help-thread:empty { display: block; }
.help-card.is-chat .chat-trust,
.help-card.is-chat .help-tiles,
.help-card.is-chat .help-form { flex: 0 0 auto; }
.help-card.is-chat .help-after { margin-top: 10px; }
.help-card.is-chat .help-keep { margin-top: 10px; }

/* tablets get most of the screen; a phone gets nearly all of it, with the edges showing */
@media (min-width: 641px) and (max-width: 1024px) {
  .help-card.is-chat { width: min(700px, 100%); height: min(84dvh, 900px); }
}
@media (max-width: 640px) {
  .help-card.is-chat {
    width: 100%;
    height: 86dvh; height: 86svh;
    max-height: none;
    padding: 16px 14px 14px;
  }
  .help-card.is-chat .help-sub { margin-bottom: 10px; }
}

/* picture tiles: one tap says a whole sentence */
.help-tiles { display: grid; gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 10px 0 2px; }
.help-tiles[hidden] { display: none; }
@media (min-width: 560px) { .help-tiles { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
.help-tile {
  display: grid; justify-items: center; align-content: center; gap: 2px;
  min-height: 56px; padding: 6px 4px;
  border: 1px solid var(--line); border-radius: 14px;
  background: #fff; cursor: pointer;
  font: inherit; color: var(--ink);
}
.help-tile span[aria-hidden] { font-size: 1.3rem; line-height: 1; }
.help-tile .t { font-size: .58rem; font-weight: 600; color: var(--ink-soft); text-align: center; line-height: 1.15; }
.help-tile:active { transform: scale(.96); background: var(--peach-soft, #fbe3df); }

/* the message button says when something is waiting */
.message-btn { position: fixed; }
.message-btn.has-new { animation: message-pulse 1.8s ease-in-out infinite; }
.message-btn.has-new::after {
  content: ""; position: absolute; top: -3px; right: -3px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px var(--coral), 0 0 0 4px rgba(255,255,255,.55);
}
@keyframes message-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .message-btn.has-new { animation: none; }
}

/* which devices may reply */
.device-box { display: grid; gap: 10px; padding: 12px; margin-bottom: 14px; background: #fff; border: 1px dashed var(--line); border-radius: 12px; }
.device-state { margin: 0; font-family: var(--hand); font-size: .86rem; color: var(--ink); }
.device-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.device-code { margin: 0; font-family: var(--sans); font-size: .8rem; color: var(--ink-soft); }
.device-code b { font-size: 1.2rem; letter-spacing: .18em; color: var(--red); }
.device-row { display: flex; align-items: center; gap: 10px; }
.device-row .grow { flex: 1 1 auto; min-width: 0; }
.device-row .t { font-family: var(--hand); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-row .s { font-size: .7rem; color: var(--ink-soft); }

/* a clip that cannot load says so, instead of showing an empty black box */
.video-fallback {
  position: absolute; inset: 0; z-index: 2; display: grid; place-content: center;
  justify-items: center; gap: 4px; padding: 16px; text-align: center;
  background: #fff7e6; color: var(--ink);
}
.video-fallback[hidden] { display: none; }
.video-fallback-face { font-size: 1.6rem; }
.video-fallback-say { font-family: var(--hand); font-size: 1rem; }
.video-fallback-hint { font-size: .78rem; color: var(--ink-soft); }
.video-retry {
  margin-top: 6px; min-height: 44px; padding: 0 18px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-family: var(--sans);
  font-size: .86rem; font-weight: 600; cursor: pointer;
}
.video-retry:active { transform: scale(.97); }

.admin { position: fixed; inset: 0; z-index: 88; overflow-y: auto; padding: clamp(10px, 2.5vw, 30px); background: rgba(59,43,35,.55); }
.admin-card {
  position: relative; margin: 0 auto; padding: clamp(16px, 2.6vw, 26px);
  width: min(1080px, 100%);
  max-height: calc(100vh - 2 * clamp(10px, 2.5vw, 30px));
  max-height: calc(100dvh - 2 * clamp(10px, 2.5vw, 30px));
  display: flex; flex-direction: column;
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
}
.tab-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tab-body[hidden] { display: none; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex: 0 0 auto; }
.admin-head h2 { font-size: 1.3rem; color: var(--red); }
.admin-tabs { flex: 0 0 auto; }
.admin-foot { flex: 0 0 auto; }
.done-btn {
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  border: 1px solid transparent; background: var(--ink); color: #fffaf2;
  font-family: var(--sans); font-size: .9rem; font-weight: 700; cursor: pointer;
}
.done-btn:active { transform: scale(.97); }
.icon-btn {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff; font-size: 1.1rem; cursor: pointer;
}
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px; background: transparent; font-size: .88rem; cursor: pointer; }
.tab.is-on { background: var(--ink); color: #fffaf2; border-color: transparent; }
.field { display: block; margin-bottom: 14px; max-width: 100%; }
.field > span { display: block; margin-bottom: 6px; font-family: var(--hand); font-size: .82rem; color: var(--ink-soft); }
.field select, .field input { width: 100%; min-height: var(--tap); padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 1rem; }

/* two short fields share a row while the text still fits, and stack when it does not */
.admin-form-row {
  display: grid; gap: 10px 14px; align-items: end;
  grid-template-columns: minmax(180px, 0.75fr) minmax(0, 1.35fr);
  max-width: 780px;
}
.admin-form-row .field { margin-bottom: 0; }
.admin-form-row.is-reply { grid-template-columns: minmax(0, 1fr) auto; max-width: 100%; margin-bottom: 14px; }
.admin-form-row.is-who { grid-template-columns: minmax(0, 1fr) auto; max-width: 420px; margin: 4px 0 10px; }
.admin-form-row + .field, .admin-form-row + .drop, .admin-form-row + .big-btn, .admin-form-row + .hint { margin-top: 14px; }
@media (max-width: 620px) {
  .admin-form-row, .admin-form-row.is-reply { grid-template-columns: minmax(0, 1fr); max-width: 100%; }
  .admin-form-row .big-btn { width: 100%; }
}

.drop { display: grid; place-items: center; gap: 4px; padding: 16px; margin-bottom: 14px; border: 3px dashed var(--line); border-radius: 14px; background: #fff; text-align: center; cursor: pointer; max-width: 780px; }
.drop-big { font-family: var(--serif); font-size: 1rem; }
.drop-small { font-family: var(--hand); font-size: .78rem; color: var(--ink-soft); }
.progress { height: 10px; border-radius: 999px; background: var(--cream-2); overflow: hidden; margin-bottom: 14px; }
.progress .bar { height: 100%; width: 0; background: var(--teal); transition: width .2s ease; }
.admin-list { display: grid; gap: 8px; margin-top: 12px; }
.admin-row { display: flex; align-items: center; gap: 10px; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.admin-row img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
.admin-row .grow { flex: 1 1 auto; min-width: 0; }
.admin-row .t { font-family: var(--hand); font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .del { width: 44px; height: 44px; border: none; border-radius: 8px; background: var(--coral-soft); color: var(--red); cursor: pointer; font-size: 1rem; flex: 0 0 auto; }
/* the album manager: thumbnails in a grid, four across, each with its own bin */
.photo-grid { display: grid; gap: 10px; margin-top: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.photo-tile {
  position: relative; margin: 0; overflow: hidden; background: #fff;
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm);
}
.photo-tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--cream-2); }
.photo-del {
  position: absolute; top: 6px; right: 6px; width: 44px; height: 44px;
  display: grid; place-items: center; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .94); color: var(--red); font-size: 1rem;
  cursor: pointer; box-shadow: 0 2px 8px rgba(59, 43, 35, .22);
}
.photo-del:active { transform: scale(.94); }
.photo-cap { display: grid; gap: 2px; padding: 8px 10px 10px; }
.photo-name {
  min-height: 32px; padding: 0; border: none; background: none; text-align: left;
  font-family: var(--hand); font-size: .84rem; color: var(--ink); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.photo-album { font-size: .68rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }
@media (max-width: 900px) { .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 620px) { .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.hint { font-family: var(--hand); color: var(--ink-soft); font-size: .84rem; margin: 0 0 12px; }
.admin-foot { margin: 16px 0 0; font-family: var(--hand); font-size: .8rem; color: var(--ink-soft); min-height: 1.2em; }

.toast {
  position: fixed; left: 50%; bottom: 24px; translate: -50% 0;
  padding: 12px 20px; border-radius: 999px;
  background: var(--ink); color: #fffaf2;
  font-family: var(--hand); font-size: .88rem;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .25s ease; z-index: 95;
}
.toast.show { opacity: 1; }

/* ── narrower screens ─────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .topbar { grid-template-columns: auto 1fr; }
  .nav-pills { grid-column: 1 / -1; order: 3; justify-content: flex-start; }
  .birthday-note { display: none; }
  .tile, .tile.wide { grid-column: span 3; }
}

@media (max-width: 720px) {
  .tile, .tile.wide { grid-column: span 6; }
  .name-block { flex-wrap: wrap; }
  .cover-top { grid-template-columns: 1fr; }
  .story-nav .big-btn, .stage-head .big-btn { flex: 1 1 auto; }
  .grown-label { display: none; }
  .grown-btn { padding: 0 12px; }
  .help-label, .message-label { display: none; }
  .help-btn, .message-btn { padding: 0 13px; }
  .foot-marks { display: none; }
}

@media (max-width: 420px) {
  .brand-name { font-size: .92rem; }
  .nav-pill { padding: 0 12px; font-size: .82rem; }
  .tile { grid-template-columns: minmax(0, 42%) minmax(0, 1fr); gap: 10px; }
  .mem-grid { gap: 6px; }
}
