/* ============================================================================
   Story Room + books (SR1 v2): the storybook look (BRIEF v2.1, master
   style-test/sr-pip-rumble-v3.png): coral, peach, teal, deep blue and gold.
   Loads after ../shared/world.css (menu, gate, fonts, buttons).
   ========================================================================== */
:root {
  --coral: #F39A7F; --coral-2: #E77E66; --peach: #F8C9A4; --teal: #2F7E7C; --teal-deep: #1E4E57;
  --deep: #22304A; --plum: #2B2233; --gold: #E8B55A; --gold-soft: #F6D98B; --paper2: #FBF3E3; --ink2: #3A3024;
}
html, body { height: 100%; }
body.book, body.room { margin: 0; overflow: hidden; background: var(--plum); color: var(--ink2); overscroll-behavior: none; touch-action: manipulation; }
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; transition: opacity .2s; }
#scene.dip { opacity: 0; }
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; z-index: 30; pointer-events: none; }
.loading[hidden] { display: none; }
.loading span { font-family: var(--hand); font-size: 22px; color: var(--paper2); padding: 10px 18px; border-radius: 999px; background: rgba(43, 34, 51, .55); animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .55; } }

/* ── the words card ───────────────────────────────────────────────────── */
.card {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 22px max(var(--gutter), env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  background: var(--paper2);
  box-shadow: 0 -18px 40px -24px rgba(30, 20, 30, .5);
  border-radius: 26px 26px 0 0;
}
.card::before { /* a soft painted edge where the paper meets the picture */
  content: ""; position: absolute; left: 0; right: 0; top: -14px; height: 16px; pointer-events: none;
  background: radial-gradient(14px 10px at 14px 16px, var(--paper2) 98%, transparent) 0 0 / 28px 16px repeat-x;
  opacity: .9; border-radius: 26px 26px 0 0; display: none;
}
.card[hidden] { display: none; }
.words { margin: 0 auto 10px; max-width: 920px; font-family: var(--body); font-weight: 650; font-size: clamp(18px, 2.2vw + 8px, 25px); line-height: 1.5; color: var(--ink2); min-height: 3em; transition: opacity .25s; }
.words.fade { opacity: 0; }
.words.in .line { animation: lineIn .6s var(--ease-out) both; }
.words.in .line:nth-child(2) { animation-delay: .06s; } .words.in .line:nth-child(3) { animation-delay: .12s; } .words.in .line:nth-child(4) { animation-delay: .18s; } .words.in .line:nth-child(5) { animation-delay: .24s; } .words.in .line:nth-child(6) { animation-delay: .3s; } .words.in .line:nth-child(n+7) { animation-delay: .36s; }
@keyframes lineIn { from { opacity: 0; transform: translateY(8px); } }
.line { display: inline; }
.line::after { content: " "; }
@media (min-width: 700px) and (max-aspect-ratio: 23/20) { .line { display: block; } .line::after { content: none; } }
.w { display: inline-block; padding: 0 .08em; margin: 0 -.04em; border-radius: .35em; cursor: pointer; transition: background-color .15s, color .15s, transform .18s var(--ease-out); -webkit-tap-highlight-color: transparent; }
.w.link { color: var(--coral-2); text-decoration: underline dotted rgba(231, 126, 102, .7); text-decoration-thickness: 2px; text-underline-offset: 4px; }
.w.on { background: var(--gold-soft); color: var(--ink2); transform: translateY(-1px) scale(1.05); box-shadow: 0 2px 0 rgba(200, 150, 60, .35); }
.w.said { background: #F9E6B7; }
.w.bounce { animation: wb .5s var(--ease-out); }
@keyframes wb { 30% { transform: translateY(-6px) scale(1.12); } 60% { transform: translateY(1px) scale(.98); } }

.card__title { display: none; margin: 0 0 18px; font-family: var(--hand); font-size: 22px; color: var(--coral-2); }
.ctrl { display: flex; align-items: center; justify-content: center; gap: 10px; max-width: 920px; margin: 0 auto; }
.arrow, .sfxbtn { flex: 0 0 auto; width: 48px; height: 48px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; color: var(--paper2); background: var(--teal); box-shadow: 0 6px 14px -8px rgba(20, 50, 50, .8); transition: transform .2s var(--ease-out), opacity .2s; }
.arrow svg, .sfxbtn svg { width: 24px; height: 24px; }
.arrow:hover { transform: translateY(-2px); }
.arrow:disabled { opacity: .3; cursor: default; transform: none; }
#next { background: var(--coral-2); }
.sfxbtn { width: 40px; height: 40px; background: transparent; color: var(--teal-deep); box-shadow: inset 0 0 0 1.5px rgba(30, 78, 87, .35); }
.sfxbtn .off-x { display: none; }
.sfxbtn[aria-pressed="false"] .off-x { display: block; } .sfxbtn[aria-pressed="false"] .on-wave { display: none; }
.play { display: inline-flex; align-items: center; gap: 8px; height: 48px; padding: 0 18px 0 14px; border: 0; border-radius: 999px; cursor: pointer; font: 400 19px var(--display); letter-spacing: .015em; color: var(--ink2); background: var(--gold-soft); box-shadow: 0 6px 14px -8px rgba(160, 110, 30, .8); }
.play { white-space: nowrap; }
.play svg { width: 22px; height: 22px; }
.play .i-pause { display: none; }
.play[aria-pressed="true"] .i-pause { display: block; } .play[aria-pressed="true"] .i-play { display: none; }
.play[aria-pressed="true"] { background: #F3C66A; }
.pno { min-width: 54px; text-align: center; font: 700 14px var(--body); color: rgba(58, 48, 36, .6); }
@media (max-width: 420px) { .ctrl { gap: 6px; } .play { padding: 0 14px 0 10px; } .pno { min-width: 44px; } }

@media (min-width: 900px) and (min-aspect-ratio: 23/20) {
  .card { left: auto; top: 0; width: clamp(360px, 31vw, 480px); display: flex; flex-direction: column; justify-content: center; padding: 90px 34px 34px 38px; border-radius: 30px 0 0 30px; box-shadow: -18px 0 40px -24px rgba(30, 20, 30, .55); }
  .words { font-size: clamp(20px, 1.25vw + 6px, 26px); line-height: 1.6; margin: 0 0 26px; max-width: none; }
  .line { display: inline; } .line::after { content: " "; }
  .ctrl { margin: 0; justify-content: space-between; gap: 4px; }
  .pno { min-width: 34px; }
  .play { font-size: 17px; gap: 6px; padding: 0 12px 0 10px; }   /* F1: Chewy is a touch wider than Nunito 800 here */
  .card__title { display: block; }
  .hint { left: 35%; }
}
.hint { position: fixed; z-index: 25; left: 50%; top: 84px; transform: translate(-50%, -8px); opacity: 0; transition: opacity .5s, transform .5s var(--ease-out); pointer-events: none; font-family: var(--hand); font-size: 22px; color: var(--plum); background: var(--gold-soft); padding: 8px 18px; border-radius: 999px; box-shadow: 0 10px 24px -12px rgba(0, 0, 0, .5); }
.hint.show { opacity: 1; transform: translate(-50%, 0); }

/* ── cover ────────────────────────────────────────────────────────────── */
.coverUI { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; gap: clamp(20px, 5vw, 70px); padding: 80px var(--gutter) 40px; flex-wrap: wrap; overflow: auto;
  background: radial-gradient(ellipse at 50% 30%, rgba(255, 196, 120, .35), transparent 60%), linear-gradient(rgba(43, 34, 51, .55), rgba(43, 34, 51, .78)), url("art/lib-w-m.webp") center / cover;
  color: var(--paper2); }
.book .coverUI { background: radial-gradient(ellipse at 50% 30%, rgba(255, 196, 120, .35), transparent 60%), linear-gradient(rgba(43, 34, 51, .55), rgba(43, 34, 51, .8)), url("art/lib-w-m.webp") center / cover; }
.coverUI[hidden] { display: none; }
.cover3d { position: relative; width: min(300px, 62vw); aspect-ratio: 0.56; perspective: 1400px; flex: 0 0 auto; }
.cover3d__pages { position: absolute; inset: 2% 2% 2% 4%; background: repeating-linear-gradient(90deg, #f6ecd6 0 2px, #e8dcc2 2px 3px); border-radius: 4px 10px 10px 4px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .7); }
.cover3d__front { position: absolute; inset: 0; transform-origin: left center; transition: transform .9s cubic-bezier(.5, 0, .3, 1); border-radius: 4px 12px 12px 4px; overflow: hidden; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .75), inset 6px 0 10px -4px rgba(0, 0, 0, .35); animation: coverIn 1s var(--ease-out) both; }
@keyframes coverIn { from { transform: translateY(30px) rotateY(-12deg); opacity: 0; } }
.cover3d__front img { width: 100%; height: 100%; object-fit: cover; }
.cover3d__front::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, .25), transparent 8%, transparent 92%, rgba(255, 255, 255, .08)); }
.cover3d__title { position: absolute; left: 8%; right: 8%; top: 6%; padding: 10px 8px 12px; text-align: center; font-family: var(--hand); font-size: clamp(22px, 5.6vw, 30px); line-height: 1.05; color: var(--plum); background: rgba(251, 243, 227, .92); border-radius: 14px 30px 14px 30px / 30px 14px 30px 14px; box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .5); }
.opening .cover3d__front { transform: rotateY(-160deg); }
.opening .coverUI { transition: opacity .6s .25s; opacity: 0; }
.coverUI__text { max-width: 420px; text-align: left; }
.coverUI h1 { margin: 0 0 8px; font-size: clamp(34px, 6vw, 52px); color: #FFF8EA; text-shadow: 0 2px 18px rgba(20, 10, 20, .5); }
.coverUI .tag { margin: 0 0 20px; font-size: 17px; opacity: .92; }
.coverUI__btns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.coverUI__btns .btn svg { width: 18px; height: 18px; }
.coverUI .btn--ghost { color: var(--paper2); }
.coverUI .back { color: var(--paper2); opacity: .85; font-size: 15px; }
@media (max-width: 700px) { .coverUI { flex-direction: column; justify-content: flex-start; padding-top: 84px; gap: 18px; } .coverUI__text { text-align: center; } .coverUI__btns { justify-content: center; } .cover3d { width: min(220px, 56vw); } }

/* ── the end ──────────────────────────────────────────────────────────── */
.endUI { position: fixed; inset: 0; z-index: 45; overflow: auto; padding: 76px var(--gutter) 30px; background: rgba(43, 34, 51, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn .6s both; }
@keyframes fadeIn { from { opacity: 0; } }
.endUI[hidden] { display: none; }
.end-card { max-width: 640px; margin: 0 auto; padding: 26px 22px 22px; background: var(--paper2); border-radius: 22px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6); text-align: center; }
.end-title { margin: 0; font-size: 56px; color: var(--coral-2); line-height: 1; outline: none; }
.end-sub { margin: 6px 0 16px; }
.end-btns { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.end-btns .btn--ghost { color: var(--teal-deep); }
.endUI .btn { background: var(--teal); }
.endUI .btn--ghost { background: transparent; }
.more { padding: 16px 12px; border-radius: 16px; background: #F6E7CF; margin-bottom: 16px; }
.more p { margin: 0 0 10px; }
.more .kicker { color: var(--coral-2); font-size: 22px; }
.more__row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more__row li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; font-weight: 750; font-size: 14px; line-height: 1.2; }
.more__row img { width: 100%; aspect-ratio: .56; object-fit: cover; border-radius: 4px 8px 8px 4px; box-shadow: 0 10px 18px -10px rgba(0, 0, 0, .6); filter: saturate(.9); }
.more__row--2 { grid-template-columns: repeat(2, minmax(0, 150px)); justify-content: center; }
.more__wren img { object-fit: contain; background: radial-gradient(circle at 50% 40%, #F9D9A8, #E9A88E 60%, #6E7FA8); padding: 14px; box-sizing: border-box; }
.more__row em { position: absolute; top: 10px; font-style: normal; font: 700 12px var(--body); color: var(--paper2); background: var(--teal); padding: 3px 8px; border-radius: 999px; transform: rotate(-4deg); }
.grown { margin: 6px 0 14px; }
.grown__btn { display: inline-block; font-family: var(--hand); font-size: 20px; color: var(--teal-deep); padding: 8px 16px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px rgba(30, 78, 87, .4); text-decoration: none; }
.grown__btn[hidden] { display: none; }
.grown__box { text-align: left; padding: 14px 16px; border-radius: 14px; background: #EEF3EC; }
.grown__box .kicker { color: var(--teal-deep); font-size: 21px; }
.grown__box ol { margin: 0 0 10px; padding-left: 22px; } .grown__box li { margin-bottom: 6px; }
.grown__note { font-size: 15px; color: #5a5146; margin: 0; }
.small-ai { margin: 0; font-size: 13px; color: rgba(58, 48, 36, .7); }
.credit-line { position: fixed; z-index: 41; left: 0; right: 0; bottom: calc(6px + env(safe-area-inset-bottom)); margin: 0; text-align: center; font-size: 12px; color: rgba(251, 243, 227, .75); pointer-events: none; }
.reading .credit-line, .ended .credit-line, .quizzing .credit-line { display: none; }
/* ── quiz time (stories/js/quiz.js): sits between the last spread and the end page, same paper look as the end card ───────────── */
.quizUI { position: fixed; inset: 0; z-index: 44; display: flex; overflow: auto; padding: 76px var(--gutter) 30px; background: rgba(43, 34, 51, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fadeIn .5s both; }
.quizUI[hidden] { display: none; }
.quiz-card { width: 100%; max-width: 640px; margin: auto; padding: 20px 20px 16px; background: var(--paper2); border-radius: 22px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6); color: var(--ink2); }
.quiz-view[hidden] { display: none; }
.quiz-bar { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-bottom: 10px; }
.quiz-kicker { flex: 1 0 100%; margin: 0; font-size: 26px; color: var(--coral-2); line-height: 1.05; }
.quiz-count { font: 800 15px var(--body); color: var(--teal-deep); }
.quiz-dots { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.quiz-dots i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(30, 78, 87, .45); box-sizing: border-box; }
.quiz-dots i.done { background: var(--teal); border-color: var(--teal); }
.quiz-dots i.now { border-color: var(--coral-2); background: var(--gold-soft); }
.quiz-qwrap { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.quiz-emoji { flex: 0 0 auto; display: grid; place-items: center; width: 52px; height: 52px; font-size: 30px; line-height: 1; border-radius: 50%; background: #F6E7CF; }
.quiz-emoji[hidden] { display: none; }
.quiz-q { margin: 0; font: 800 clamp(21px, 2.4vw + 11px, 27px)/1.25 var(--body); color: var(--ink2); outline: none; }
.quiz-opts { display: grid; gap: 10px; }
.quiz-opt { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 10px 14px; font: 750 clamp(17px, 1vw + 13px, 20px)/1.25 var(--body); text-align: left; color: var(--ink2); background: #fff; border: 2.5px solid rgba(30, 78, 87, .38); border-radius: 16px; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: border-color .15s, background-color .15s, transform .15s var(--ease-out); }
.quiz-opt:hover { border-color: var(--teal); }
.quiz-opt:focus-visible { outline: 3px solid #1F6FB5; outline-offset: 2px; }
.quiz-opt[aria-disabled="true"] { cursor: default; }
.quiz-mark { flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px; box-sizing: border-box; border-radius: 50%; border: 2.5px solid rgba(30, 78, 87, .4); }
.quiz-opt.is-right { background: #E2F1DE; border-color: #3F8F4F; }
.quiz-opt.is-right .quiz-mark { background: #3F8F4F; border-color: #3F8F4F; }
.quiz-opt.is-right .quiz-mark::before { content: ""; width: 6px; height: 12px; margin-top: -2px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.quiz-opt.is-miss { background: #F1E8DC; border-color: #D8BD97; color: #6B5F50; }
.quiz-opt.is-miss .quiz-mark { border-color: #D8BD97; }
.quiz-opts:has(.is-right) .quiz-opt:not(.is-right) { opacity: .6; }
.quiz-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.quiz-fb { min-height: 3.1em; margin: 12px 2px 4px; font: 700 17px/1.4 var(--body); color: var(--ink2); }
.quiz-fb--soft { color: #7A5A2E; }
.quiz-fb--good { color: #2C6B3A; }
.quiz-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.quiz-next[hidden], .quizUI [hidden] { display: none; }
.quiz-next { margin-left: auto; background: var(--teal); min-width: 120px; }
.quiz-skip { min-height: 44px; padding: 0 6px; font: 700 15px var(--body); color: var(--teal-deep); background: none; border: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.quiz-skip:focus-visible { outline: 3px solid #1F6FB5; outline-offset: 2px; }
.quiz-result { text-align: center; padding: 10px 0 6px; }
.quiz-rtitle { margin: 0 0 8px; font-size: clamp(36px, 8vw, 50px); color: var(--coral-2); outline: none; }
.quiz-rmsg { margin: 0 0 20px; font: 750 19px/1.4 var(--body); }
.quiz-rbtns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.quizUI .btn { background: var(--teal); }
.quizUI .btn--ghost { background: transparent; color: var(--teal-deep); }
@media (prefers-reduced-motion: no-preference) {
  .quiz-opt.is-right { animation: quizPop .45s var(--ease-out); }
  .quiz-view:not([hidden]) .quiz-qwrap { animation: lineIn .4s var(--ease-out) both; }
}
@keyframes quizPop { 40% { transform: scale(1.03); } }
@media (prefers-reduced-motion: reduce) { .quizUI { animation: none; } .quiz-opt { transition: none; } }
/* phone held sideways (or any short window): answers side by side so the whole question fits without scrolling */
@media (max-height: 520px) {
  .quizUI { padding: 52px 14px 10px; }
  .quiz-card { padding: 12px 16px 8px; max-width: 760px; }
  .quiz-kicker { display: none; }
  .quiz-bar { margin-bottom: 4px; }
  .quiz-qwrap { margin: 2px 0 8px; gap: 10px; }
  .quiz-emoji { width: 40px; height: 40px; font-size: 24px; }
  .quiz-q { font-size: 19px; }
  .quiz-opts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .quiz-opt { min-height: 56px; padding: 6px 10px; gap: 8px; font-size: 16px; }
  .quiz-mark { width: 22px; height: 22px; }
  .quiz-opt.is-right .quiz-mark::before { width: 5px; height: 10px; }
  .quiz-fb { min-height: 2.6em; margin: 6px 2px 0; font-size: 15px; }
  .quiz-rmsg { margin-bottom: 12px; }
}

/* ── the Pages button + page picker (stories/js/pages.js): same paper look as the quiz and end card ─────────────────────────── */
.pagesBtn { position: absolute; right: max(var(--gutter), env(safe-area-inset-right)); bottom: calc(100% + 12px); z-index: 2; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px 0 12px; font: 400 19px/1 var(--display); letter-spacing: .015em; color: #2B2620; background: #FFFAEE; border: 2px solid rgba(43, 38, 32, .14); border-radius: 999px; box-shadow: 0 8px 18px -8px rgba(20, 10, 20, .7); cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform .2s var(--ease-out); }
.pagesBtn svg { width: 22px; height: 22px; color: var(--teal); }
.pagesBtn:hover { transform: translateY(-2px); }
.pagesBtn:focus-visible { outline: 3px solid #1F6FB5; outline-offset: 2px; }
.pagesBtn--side { bottom: auto; top: 16px; right: 22px; }
body.ended .pagesBtn, body.quizzing .pagesBtn { display: none; }
.pagesUI { position: fixed; inset: 0; z-index: 46; display: flex; overflow: hidden; padding: 70px var(--gutter) 16px; background: rgba(43, 34, 51, .6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.pagesUI[hidden] { display: none; }
.pg-card { display: flex; flex-direction: column; width: 100%; max-width: 700px; max-height: 100%; margin: auto; padding: 16px 14px 12px; box-sizing: border-box; background: #FBF4E4; border-radius: 22px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .6); color: #2B2620; outline: none; }
.pg-head { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; margin: 0 2px 10px; }
.pg-titles { flex: 1 1 auto; min-width: 0; }
.pg-title { margin: 0; font-size: 30px; color: var(--coral-2); line-height: 1.05; }
.pg-sub { margin: 2px 0 0; font: 700 14px/1.3 var(--body); color: rgba(43, 38, 32, .68); }
.pg-close { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px 0 12px; border: 0; border-radius: 999px; cursor: pointer; font: 400 18px/1 var(--display); letter-spacing: .015em; color: #FFFAEE; background: var(--teal); box-shadow: 0 6px 14px -8px rgba(20, 50, 50, .8); -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.pg-close svg { width: 18px; height: 18px; }
.pg-close:focus-visible, .pg-tile:focus-visible { outline: 3px solid #1F6FB5; outline-offset: 2px; }
.pg-grid { list-style: none; margin: 0; padding: 5px 4px 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 10px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; -webkit-overflow-scrolling: touch; }
.pg-li { display: flex; min-width: 0; }
.pg-tile { flex: 1 1 auto; display: flex; flex-direction: column; gap: 5px; min-width: 0; min-height: 44px; padding: 5px 5px 6px; font: 700 12.5px/1.25 var(--body); text-align: left; color: #2B2620; background: #FFFAEE; border: 2.5px solid rgba(30, 78, 87, .25); border-radius: 14px; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: border-color .15s, transform .15s var(--ease-out); }
.pg-tile:hover { border-color: var(--teal); }
.pg-thumb { position: relative; display: block; aspect-ratio: 3 / 2; border-radius: 9px; overflow: hidden; background: #E8DCC2; }
.pg-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-tile--cover .pg-thumb img { object-position: 50% 30%; }
.pg-num { position: absolute; top: 4px; left: 4px; display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; box-sizing: border-box; font: 400 15px/1 var(--display); color: #2B2620; background: #FFFAEE; border-radius: 12px; box-shadow: 0 2px 5px rgba(0, 0, 0, .35); }
.pg-thumb--quiz, .pg-thumb--end { display: grid; place-items: center; }
.pg-thumb--quiz { background: linear-gradient(135deg, #F6D98B, #F3C66A); }
.pg-thumb--end { background: linear-gradient(135deg, #3A8E8B, #1E4E57); }
.pg-glyph { font: 400 38px/1 var(--display); font-style: normal; color: #2B2620; }
.pg-thumb--end .pg-glyph { font-size: 24px; color: #FFFAEE; }
.pg-tile--cover .pg-thumb .pg-glyph { font-size: 24px; }
.pg-cap { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; padding: 0 2px; }
.pg-here { display: none; position: absolute; right: 4px; bottom: 4px; font: 400 12px/1 var(--display); font-style: normal; color: #fff; background: var(--coral-2); padding: 4px 8px 5px; border-radius: 999px; }
.pg-tile.is-here { border-color: var(--coral-2); background: #FFF1DF; box-shadow: 0 0 0 3px rgba(231, 126, 102, .28); }
.pg-tile.is-here .pg-num { background: var(--coral-2); color: #fff; }
.pg-tile.is-here .pg-here { display: block; }
.pg-tile.is-here .pg-cap { font-weight: 850; }
@media (prefers-reduced-motion: no-preference) {
  .pagesUI { animation: fadeIn .3s both; }
  .pg-card { animation: pgIn .35s var(--ease-out) both; }
}
@keyframes pgIn { from { opacity: 0; transform: translateY(14px); } }
@media (prefers-reduced-motion: reduce) { .pagesBtn, .pg-tile { transition: none; } }
/* phone held sideways (or any short window): smaller header, wider grid, the list scrolls inside the card */
@media (max-height: 520px) {
  .pagesUI { padding: 56px 12px 8px; }
  .pg-card { padding: 10px 12px 8px; max-width: 820px; }
  .pg-sub { display: none; }
  .pg-title { font-size: 24px; }
  .pg-head { margin-bottom: 6px; }
  .pg-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
}

.nogl-box { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: var(--gutter); background: var(--plum); }
.nogl-box[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .cover3d__front { transition: none; } }

/* ══ THE STORY ROOM (index.html) ═════════════════════════════════════════ */
.lib { position: fixed; inset: 0; overflow: hidden; background: #3a2531; }
.lib__stage { position: absolute; transform-origin: 50% 47%; transition: transform 1.6s cubic-bezier(.25, .6, .2, 1); }
.walking .lib__stage { transform: scale(1.22); }
.walking.inside .lib__stage, .nowalk .lib__stage { transform: none; }
.lay { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; will-change: transform; }
.lay--room img { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-drag: none; }
.lay--room .glow { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 30% 26% at 50% 44%, rgba(255, 214, 140, .28), transparent 70%); mix-blend-mode: screen; animation: lampglow 5s ease-in-out infinite; }
@keyframes lampglow { 50% { opacity: .55; } }
.slot { position: absolute; width: 0; height: 0; }
.rbook { position: absolute; left: 0; bottom: 0; transform: translateX(-50%); display: block; width: calc(var(--bh) * .58); height: var(--bh); padding: 0; border: 0; background: none; cursor: pointer; perspective: 600px; -webkit-tap-highlight-color: transparent; }
.book__in { position: absolute; inset: 0; display: block; border-radius: 3px 7px 7px 3px; overflow: hidden; transform-origin: 50% 100%; transform: rotateX(4deg); transition: transform .35s var(--ease-out), box-shadow .35s;
  box-shadow: 4px 6px 10px -3px rgba(40, 20, 10, .55), inset 3px 0 4px -2px rgba(0, 0, 0, .4), inset -1px 0 0 rgba(255, 240, 210, .4); background: #e9d6b4; }
.book__in img { width: 100%; height: 100%; object-fit: cover; display: block; }
.book__in b { position: absolute; left: 6%; right: 6%; top: 5%; padding: .28em .2em .34em; text-align: center; font: 400 calc(var(--bh) * .085)/1.05 var(--hand); color: var(--plum); background: rgba(251, 243, 227, .9); border-radius: 6px 14px 6px 14px / 14px 6px 14px 6px; }
.book__in::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(0, 0, 0, .22), transparent 9%, transparent 80%, rgba(255, 245, 220, .16)); pointer-events: none; }
.rbook:hover .book__in, .rbook:focus-visible .book__in { transform: rotateX(-8deg) translateZ(18px) translateY(-6px); box-shadow: 6px 16px 18px -6px rgba(40, 20, 10, .6); }
.rbook.away .book__in { opacity: 0; }
.small .book__in b { display: none; }
.small .book__tag { font-size: 15px; top: -16px; }
@media (max-width: 520px) { .lib__foot .wfoot__ai { font-size: 11px; line-height: 1.35; } .lib__title p { font-size: 15px; } }
.book__tag { position: absolute; left: 50%; top: -14px; transform: translateX(-50%) rotate(-4deg); font: 400 calc(var(--bh) * .1) var(--hand); font-style: normal; color: var(--plum); background: var(--gold-soft); padding: 2px 9px 3px; border-radius: 999px; white-space: nowrap; box-shadow: 0 4px 10px -4px rgba(0, 0, 0, .5); animation: tagbob 2.6s ease-in-out infinite; pointer-events: none; }
.rbook[data-id="red"] .book__tag { animation-delay: -1.3s; }
@keyframes tagbob { 50% { transform: translateX(-50%) translateY(-4px) rotate(3deg); } }
.soon .book__in { filter: saturate(.85) brightness(.95); }
.lay--near, .lay--fg { pointer-events: none; }
.prop { pointer-events: auto; position: absolute; padding: 0; border: 0; background: none; cursor: pointer; transform: translate(-50%, -100%); -webkit-tap-highlight-color: transparent; }
.prop.top { transform: translate(-50%, 0); transform-origin: 50% 0; animation: swing 4.5s ease-in-out infinite; }
.prop img { height: 100%; width: auto; display: block; pointer-events: none; }
.prop--cat img { filter: drop-shadow(0 6px 8px rgba(40, 20, 10, .35)); }
.prop--fl1, .prop--fl2 { transform-origin: 50% 100%; }
.prop.poke { animation: poke .6s var(--ease-out); }
.prop.top.poke { animation: swingBig 1.6s ease-in-out; }
@keyframes swing { 50% { transform: translate(-50%, 0) rotate(2.5deg); } }
@keyframes swingBig { 25% { transform: translate(-50%, 0) rotate(-9deg); } 60% { transform: translate(-50%, 0) rotate(6deg); } }
@keyframes poke { 30% { transform: translate(-50%, -100%) scale(1.08, .9); } 60% { transform: translate(-50%, -100%) scale(.96, 1.06); } }
.burst { position: fixed; z-index: 60; pointer-events: none; font-size: 26px; color: var(--coral); text-shadow: 0 2px 8px rgba(0, 0, 0, .3); animation: burst 1.6s ease-out both; }
@keyframes burst { from { opacity: 0; transform: translate(0, 0) scale(.6); } 15% { opacity: 1; } to { opacity: 0; transform: translate(var(--dx), -110px) scale(1.2); } }
#motes { position: absolute; inset: 0; pointer-events: none; }
.lib__title { position: fixed; z-index: 12; left: 0; right: 0; bottom: 0; padding: 60px var(--gutter) 70px; text-align: center; pointer-events: none; background: linear-gradient(transparent, rgba(43, 34, 51, .55) 45%, rgba(43, 34, 51, .78)); color: var(--paper2); }
.lib__title h1 { margin: 0; font-size: clamp(38px, 6vw, 64px); }
.lib__title p { margin: 4px auto 0; max-width: 30em; font-size: 16px; opacity: .92; }
.lib__foot { position: fixed; z-index: 13; left: 0; right: 0; bottom: 0; padding: 6px var(--gutter) calc(8px + env(safe-area-inset-bottom)); font-size: 12px; }
.lib__foot p { margin: 2px 0; }
.lib__foot .wfoot__links { margin: 0; gap: 14px; }
.soon-note { position: fixed; z-index: 62; left: 50%; bottom: 14%; transform: translateX(-50%); text-align: center; padding: 12px 22px 14px; border-radius: 18px; background: var(--paper2); color: var(--ink2); box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .6); animation: noteIn .45s var(--ease-out) both; max-width: calc(100vw - 32px); }
.soon-note[hidden] { display: none; }
.soon-note b { display: block; font: 400 24px var(--hand); color: var(--coral-2); }
.soon-note span { font-weight: 700; font-size: 15px; }
@keyframes noteIn { from { opacity: 0; transform: translate(-50%, 12px); } }
.fly { position: fixed; z-index: 61; left: 0; top: 0; pointer-events: none; perspective: 1200px; --bh: 300px; }
.fly[hidden] { display: none; }
.fly .book__in { transform: none; box-shadow: 0 40px 70px -20px rgba(0, 0, 0, .7); transform-origin: 0 50%; transition: transform .8s cubic-bezier(.5, 0, .3, 1); }
.fly .book__in b { font-size: clamp(16px, 4.6vw, 26px); }
.fly.open .book__in { transform: rotateY(-150deg); }
.fly.open::before { content: ""; position: absolute; inset: 1.5% 1.5% 1.5% 0; background: repeating-linear-gradient(90deg, #f6ecd6 0 2px, #e8dcc2 2px 3px); border-radius: 3px 8px 8px 3px; }
.fly.wiggle .book__in { animation: wig .7s ease-in-out 2; }
@keyframes wig { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
body.room::after { content: ""; position: fixed; inset: 0; z-index: 80; pointer-events: none; background: #FBF3E3; opacity: 0; transition: opacity .45s; }
body.room.leaving::after { opacity: 1; }

/* the door */
.entry { position: fixed; inset: 0; z-index: 70; overflow: hidden; cursor: pointer; }
.entry.gone { opacity: 0; transition: opacity .5s; pointer-events: none; }
.entry__stage { position: absolute; perspective: 1600px; transition: transform 1.5s cubic-bezier(.55, 0, .3, 1), opacity 1.2s .25s; }
.entry.through .entry__stage { transform: scale(3.6); opacity: 0; }
.entry__frame { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; }
.entry__hinge { position: absolute; left: 43.49%; top: 26.37%; width: 20.83%; height: 47.66%; transform-origin: 0 50%; transform-style: preserve-3d; transition: transform 1.25s cubic-bezier(.45, 0, .25, 1); }
.entry__leaf { width: 100%; height: 100%; display: block; backface-visibility: hidden; filter: drop-shadow(-6px 0 10px rgba(40, 20, 10, .35)); }
.entry.open .entry__hinge { transform: rotateY(-104deg); }
.entry__light { position: absolute; left: 41%; top: 18%; width: 27%; height: 64%; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at 50% 60%, rgba(255, 220, 150, .75), transparent 65%); mix-blend-mode: screen; transition: opacity 1s .3s; }
.entry.open .entry__light { opacity: 1; }
.entry__hint { position: absolute; left: 50%; bottom: 9%; transform: translateX(-50%); margin: 0; padding: 8px 22px 10px; font-size: 26px; color: #4A2A1E; background: rgba(255, 244, 222, .92); border-radius: 999px; box-shadow: 0 10px 26px -10px rgba(40, 20, 10, .6); white-space: nowrap; opacity: 0; transition: opacity .6s .6s; }
.entry.ready .entry__hint { opacity: 1; animation: hintBob 1.8s ease-in-out .9s infinite; }
.entry.open .entry__hint { opacity: 0; transition-delay: 0s; animation: none; }
@keyframes hintBob { 50% { transform: translateX(-50%) translateY(-6px); } }
/* "tap me": a soft ring pulses on the door and the door gives a little knock-wiggle every few seconds */
.entry__hinge::after { content: ""; position: absolute; left: 50%; top: 52%; width: 34%; aspect-ratio: 1; border-radius: 50%; transform: translate(-50%, -50%); border: 3px solid rgba(255, 236, 190, .9); box-shadow: 0 0 18px 4px rgba(255, 220, 150, .55); opacity: 0; pointer-events: none; }
.entry.ready:not(.open) .entry__hinge::after { animation: tapRing 2s ease-out 1s infinite; }
.entry.ready:not(.open) .entry__hinge { animation: doorWiggle 3.6s ease-in-out 2.2s infinite; }
@keyframes tapRing { 0% { opacity: .9; transform: translate(-50%, -50%) scale(.5); } 80%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } }
@keyframes doorWiggle { 0%, 82%, 100% { transform: rotateY(0); } 86% { transform: rotateY(-9deg); } 90% { transform: rotateY(-2deg); } 94% { transform: rotateY(-6deg); } }
.entry__veil { position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, #FFF8E6 0%, #F6F0E1 40%, #EFE6CF 100%); transition: opacity .8s .1s; pointer-events: none; }
.entry.ready .entry__veil { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .lib__stage, .entry__stage, .entry__hinge { transition: none; } .prop.top { animation: none; } .book__tag { animation: none; } .lay--room .glow { animation: none; } }

/* W7: the new room painting is bright (sunlit cream and honey), so the shared menu pill needs a darker wash here to keep its cream words at AA contrast (shared/world.css untouched). */
body.room .wnav { background: rgba(38, 30, 22, .74); }

/* ── W5 · 2026-11-17: more picture, less furniture ─────────────────────────
   Words panel only as tall as the words; readable colours (4.5:1 or better on the paper);
   ONE sound control on screen (Read to me); music + tap sounds behind a small gear. */
.card { padding: 14px max(var(--gutter), env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; }
.words { margin: 0 auto 8px; min-height: 0; line-height: 1.42; max-width: 62ch; font-size: clamp(19px, 1.6vw + 12px, 25px); }
.w.link { color: #B4472F; text-decoration-color: rgba(180, 71, 47, .55); }           /* was #E77E66: 2.5:1, now 4.9:1 */
.pno { color: #5C5040; }                                                                /* 7:1 */
.ctrl { gap: 8px; }
.gearbtn { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; background: transparent; color: #5C5040; }
.gearbtn svg { width: 24px; height: 24px; }
.gearbtn[aria-expanded="true"] { background: rgba(47, 126, 124, .14); color: var(--teal-deep); }
.soundsheet { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: calc(100% + 10px); z-index: 30; min-width: 230px; padding: 12px 14px; border-radius: 18px; background: var(--paper2); color: var(--ink2); box-shadow: 0 16px 40px -14px rgba(30, 20, 30, .6); }
.soundsheet[hidden] { display: none; }
.soundsheet__t { margin: 0 0 6px; font: 400 19px var(--display); color: var(--teal-deep); }
.soundsheet__row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; font: 700 17px var(--body); }
.soundsheet .sfxbtn { width: 44px; height: 44px; }
.soundsheet .soundsheet__music { position: static; width: auto; height: 44px; min-width: 44px; padding: 0 14px; border-radius: 999px; border: 0; cursor: pointer; font: 700 15px var(--body); color: var(--paper2); background: var(--teal); }
.soundsheet .soundsheet__music[aria-pressed="false"] { background: transparent; color: var(--teal-deep); box-shadow: inset 0 0 0 1.5px rgba(30, 78, 87, .45); }
@media (max-width: 420px) { .ctrl { gap: 4px; } .gearbtn { width: 44px; } }
@media (min-width: 900px) and (min-aspect-ratio: 23/20) {
  .card { width: clamp(320px, 27vw, 420px); padding: 72px 26px 26px 30px; }
  .card__title { display: none; }
  .words { font-size: clamp(20px, 1vw + 9px, 25px); line-height: 1.55; margin: 0 0 22px; }
  .soundsheet { right: 16px; bottom: 96px; }
}
/* cover: the 3D library is not loaded yet; a tap starts it (stories/js/boot.js) */
.fetching .coverUI__btns { opacity: .75; pointer-events: none; }
.fetching .coverUI__btns .btn { cursor: progress; }
.coverUI .wfoot { flex: 1 0 100%; padding: 8px 0 0; font-size: 13px; color: rgba(251, 243, 227, .88); }
/* the end page: one big button, then small things */
.end-btns .btn--go { font-size: 24px; min-height: 64px; padding: 0 30px; background: #B8432C; color: #fff; box-shadow: 0 10px 22px -10px rgba(120, 30, 20, .7); }
.end-btns .btn--go img { width: 40px; height: 56px; object-fit: cover; border-radius: 4px 7px 7px 4px; margin-right: 12px; box-shadow: 0 4px 10px -4px rgba(0, 0, 0, .5); }
.end-small { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin: 14px 0 6px; }
.end-small a, .end-small button { font: 700 16px var(--body); color: var(--teal-deep); background: none; border: 0; padding: 10px 6px; min-height: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.end-card details.try { margin: 12px 0; }
.end-card details.try summary { cursor: pointer; font: 400 19px var(--display); color: var(--teal-deep); min-height: 44px; display: flex; align-items: center; }
.end-card [data-qr-makers] { margin-top: 14px; }
.end-title { color: #B4472F; }   /* W5: 4.9:1 on the paper (was 2.5:1) */
