:root{color-scheme:light;--paper:#eee8dc;--ink:#5e574a}*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font-family:"Yu Mincho","Hiragino Mincho ProN",serif;min-height:100svh;display:grid;grid-template-rows:auto 1fr auto;overflow-x:hidden}header{display:flex;align-items:baseline;justify-content:space-between;gap:1rem;padding:18px 5vw 12px}h1{font-size:clamp(15px,2.3vw,23px);font-weight:400;letter-spacing:.12em;margin:0}header span{font-size:11px;white-space:nowrap;opacity:.7}main{display:grid;place-items:center;min-height:0}button{font:inherit;color:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent;touch-action:manipulation}#page{width:100%;height:calc(100svh - 170px);min-height:200px;border:0;background:transparent;display:grid;place-items:center;position:relative;padding:0 4vw;overflow:hidden}#picture{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;opacity:0;transition:opacity 520ms ease-in-out;user-select:none;-webkit-user-drag:none}#picture.visible{opacity:1}#loading{position:absolute;font-size:14px;letter-spacing:.12em}footer{text-align:center;padding:10px 16px max(14px,env(safe-area-inset-bottom))}.controls{display:flex;align-items:center;justify-content:center;gap:32px}.controls button,#restart{min-height:44px;min-width:64px;border:1px solid #b7ae9b;border-radius:24px;background:transparent;padding:8px 20px;font-size:13px}button:disabled{opacity:.3;cursor:default}button:focus-visible{outline:2px solid #887c63;outline-offset:3px}#page:focus-visible{outline-offset:-5px}#count{font-family:system-ui,sans-serif;font-size:11px;letter-spacing:.12em;min-width:70px}#hint{font-size:12px;margin:8px 0 0;min-height:18px}#restart{margin-top:8px} [hidden]{display:none!important}@media(max-width:500px){header{padding:16px 18px 12px;flex-wrap:wrap;gap:5px}header span{display:none}#page{height:calc(100svh - 167px);padding:0 12px}#hint{font-size:11px}.controls{gap:20px}}@media(prefers-reduced-motion:reduce){#picture{transition-duration:100ms}}

:is(#chapter-title,.turn-chapter-title){position:absolute;inset:0;display:flex;align-items:center;justify-content:center;padding:10vw;font-size:clamp(22px,4.5vw,40px);font-weight:400;letter-spacing:.13em;line-height:1.8;opacity:0;transition:opacity 600ms ease-in-out;pointer-events:none;white-space:pre-line}:is(#chapter-title,.turn-chapter-title).visible{opacity:1}@media(prefers-reduced-motion:reduce){:is(#chapter-title,.turn-chapter-title){transition-duration:100ms}}

body:not(.reading)>header,body:not(.reading)>main,body:not(.reading)>footer{display:none}#cover{min-height:100svh;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:16px;gap:12px}#cover-open{border:0;background:transparent;padding:0;display:block;max-width:100%}#cover-image{display:block;max-width:min(88vw,900px);max-height:calc(100svh - 110px);object-fit:contain;box-shadow:0 8px 30px #665b4520}.cover-actions{display:flex;gap:14px;justify-content:center;flex-wrap:wrap}.cover-actions button{min-height:44px;border:1px solid #b7ae9b;border-radius:24px;background:transparent;padding:10px 24px;font-size:13px}
/* A quiet square picture book: preserve the complete original picture. */
body{background:#e8e1d4}header{width:min(100%,960px);margin:0 auto}main{padding:8px 12px}#page{width:min(90vw,calc(100svh - 190px),800px);height:auto;min-height:0;aspect-ratio:1;padding:18px;background:#f8f3e8;border:1px solid #ddd3bf;box-shadow:0 8px 28px #67583d14}#picture{max-width:100%;max-height:100%;object-fit:contain}:is(#chapter-title,.turn-chapter-title){padding:10%;font-size:clamp(20px,4vw,36px)}#cover-image{width:min(90vw,calc(100svh - 110px),800px);height:auto;aspect-ratio:1;object-fit:contain}#cover{width:100%}@media(max-width:500px){#page{width:min(94vw,calc(100svh - 170px));height:auto;padding:10px}main{padding:4px 8px}header{padding:14px 18px 8px}}@media(max-height:480px){header{padding:7px 18px}#page{width:min(90vw,calc(100svh - 140px));padding:8px}footer{padding-top:4px}#hint{margin-top:3px}}

#caption{font-size:clamp(14px,2.5vw,17px);line-height:1.9;max-width:42em;margin:0 auto 12px;min-height:3.8em;white-space:pre-line;opacity:0;transition:opacity 450ms ease-in-out;padding:0 6px}#caption.visible{opacity:1}#page{width:min(90vw,calc(100svh - 300px),760px)}@media(max-width:500px){#page{width:min(94vw,calc(100svh - 285px))}#caption{font-size:14px;margin-bottom:6px}}@media(max-height:500px){#page{width:min(60vw,260px)}#caption{min-height:0}}@media(prefers-reduced-motion:reduce){#caption{transition-duration:100ms}}

:is(#chapter-art,.turn-chapter-art){position:absolute;inset:0;width:100%;height:100%;object-fit:contain;opacity:0;transition:opacity 600ms ease-in-out;pointer-events:none}:is(#chapter-art,.turn-chapter-art).visible{opacity:1}:is(#chapter-title,.turn-chapter-title){align-items:flex-start;padding-top:14%;z-index:1;font-size:clamp(19px,3.4vw,32px);text-shadow:0 1px 12px #fff9;letter-spacing:.1em}:is(#chapter-art,.turn-chapter-art)[hidden]{display:none!important}

#page{padding:0;background:#f8f3e8}#picture-frame{display:block;position:relative;overflow:hidden;pointer-events:none}#picture{position:absolute;max-width:none;max-height:none;object-fit:fill}:is(#chapter-art,.turn-chapter-art){inset:3%;width:94%;height:94%}

/* Quiet illustrated stationery. Artwork frames and reading timings stay intact. */
body{background:#eee8dc url('art/ui/paper-background.webp') center/cover no-repeat fixed;color:#554e42}
header{align-items:center;padding:8px 24px 4px;gap:16px}
header h1{line-height:0;flex:0 1 auto}
.book-title-logo{display:block;width:170px;max-width:100%;height:auto;object-fit:contain}
header>span{color:#706958;letter-spacing:.16em}
#page{width:min(90vw,calc(100svh - 340px),760px);box-shadow:0 10px 30px #66563d16,0 1px 3px #66563d12}
footer{width:min(100%,820px);margin:0 auto;padding-top:12px}
#caption{color:#514b40;letter-spacing:.055em}
.controls{gap:22px}
.controls button,.cover-actions button,#restart{position:relative;border:1px solid transparent;border-radius:12px;background:transparent url('art/ui/paper-button.webp') center/100% 100% no-repeat;min-height:48px;min-width:92px;padding:10px 24px;color:#554d40;line-height:1.5;font-size:13px;letter-spacing:.09em;transition:filter 160ms ease,transform 160ms ease,box-shadow 160ms ease}
.cover-actions button{min-height:52px;min-width:158px;padding:12px 28px}
#restart{min-width:158px;margin-top:8px}

.controls button:disabled{opacity:.38;filter:grayscale(.65);cursor:default}
button:focus-visible{outline:2px solid #6d887b;outline-offset:3px}
#count{color:#7b715e;font-size:11px;min-width:64px;font-variant-numeric:tabular-nums}
#hint{color:#7b715e;line-height:1.6}
@media(hover:hover){.controls button:not(:disabled):hover,.cover-actions button:hover,#restart:hover{filter:brightness(1.025);box-shadow:0 3px 8px #67583d14}}
.controls button:not(:disabled):active,.cover-actions button:active,#restart:active{transform:translateY(1px);filter:brightness(.97)}
@media(max-width:500px){header{padding:8px 18px 4px;flex-wrap:nowrap}.book-title-logo{width:148px}#page{width:min(94vw,calc(100svh - 320px))}footer{padding-top:9px}.controls{gap:16px}.controls button{min-width:82px;padding:10px 18px}#caption{letter-spacing:.04em}}
@media(max-height:500px) and (orientation:landscape){body.reading{grid-template-columns:minmax(0,1fr) minmax(0,1fr);grid-template-rows:auto 1fr;align-items:center}body.reading>header{grid-column:1/-1;padding:5px 20px 0}.book-title-logo{width:136px}body.reading>main{grid-column:1;grid-row:2;padding:4px 8px 10px}body.reading>footer{grid-column:2;grid-row:2;padding:8px 14px}#page{width:min(43vw,calc(100svh - 82px),300px)}#caption{min-height:3.8em;font-size:14px;margin-bottom:6px}.controls{gap:10px}.controls button{min-width:70px;padding:10px 14px}#hint{font-size:10px}#restart{margin-top:4px}}
@media(prefers-reduced-motion:reduce){.controls button,.cover-actions button,#restart{transition:none}}

/* Storybook prose flows below the art; long passages never occupy a clipped box. */
body.reading{grid-template-rows:auto auto auto;align-content:start}
body.reading>footer{min-width:0}
#caption{height:auto;max-height:none;overflow:visible;display:block;white-space:pre-line;text-align:left;text-wrap:pretty;overflow-wrap:anywhere;line-height:1.95;max-width:34em;min-height:0;margin:0 auto 16px;padding:0 6px}
@media(max-width:500px){#caption{font-size:15px;line-height:1.95;margin-bottom:14px;letter-spacing:.035em}}
@media(max-height:500px) and (orientation:landscape){body.reading{grid-template-rows:auto auto;align-items:start}body.reading>main{align-self:start}body.reading>footer{min-width:0}#caption{font-size:14px;min-height:0;max-height:none;margin-bottom:12px}}

/* The light starts inside the book, then slowly fills the room. Never a flash: 6.5s to reach warm white. */
#light-window,#light-veil{position:absolute;inset:3%;width:94%;height:94%;pointer-events:none;opacity:0}#light-window{object-fit:contain}#light-veil{background:#fff}

/* Direct navigation and a recoverable restart. */
.controls #count{min-width:76px;min-height:48px;padding:8px 10px;font-size:11px;text-decoration:underline;text-underline-offset:4px;letter-spacing:.03em}
#restore-reading{display:block;margin:10px auto 0;min-height:48px;border:1px solid #b7ae9b;border-radius:12px;padding:10px 24px;background:transparent url('art/ui/paper-button.webp') center/100% 100% no-repeat;font-size:13px}
#page-jump{width:min(90vw,380px);max-height:90svh;overflow:auto;border:1px solid #b7ae9b;border-radius:16px;padding:24px;color:#554e42;background:#f8f3e8;box-shadow:0 12px 48px #44392730}
#page-jump::backdrop{background:#332b2155}#jump-title{font-size:19px;font-weight:400;margin:0 0 20px}#page-jump label{display:block;font-size:14px;margin-bottom:8px}#jump-number{width:100%;min-height:48px;padding:10px 12px;font:inherit;font-size:18px;color:inherit;background:#fffcf4;border:1px solid #a99d87;border-radius:8px}#jump-error{font-size:13px;line-height:1.6;color:#8a4037;min-height:1.6em;margin:8px 0 16px}.jump-actions{display:flex;gap:12px;flex-wrap:wrap}.jump-actions button{min-height:48px;flex:1;min-width:115px;border:1px solid #b7ae9b;border-radius:10px;background:transparent url('art/ui/paper-button.webp') center/100% 100% no-repeat;padding:10px 12px;font-size:13px}#jump-number:focus-visible{outline:2px solid #6d887b;outline-offset:2px}
@media(max-width:350px){.controls{gap:10px}.controls button{min-width:72px;padding-left:12px;padding-right:12px}.controls #count{min-width:74px}}

/* A white soft vignette only on explicit memory/foreshadow inserts. */
#memory-mist{position:absolute;inset:0;pointer-events:none;opacity:0;background:radial-gradient(ellipse closest-side at 50% 50%,rgba(255,253,247,0) 50%,rgba(255,253,247,.18) 70%,rgba(255,253,247,.42) 85%,rgba(255,253,247,.70) 100%);transition:opacity 520ms ease-in-out}
#page[data-memory="true"] #picture.visible + #memory-mist{opacity:1}
@media(prefers-reduced-motion:reduce){#memory-mist{transition-duration:100ms}}

/* A diagonal corner fold reveals the next illustration from bottom-right to top-left. */
.turn-sheet{position:absolute;inset:0;z-index:5;display:grid;place-items:center;background:#f8f3e8;pointer-events:none;will-change:clip-path;overflow:hidden}
.turn-art{position:relative;display:block;overflow:hidden}.turn-art img{position:absolute;max-width:none;max-height:none;object-fit:fill;display:block}.turn-mist{position:absolute;inset:0;background:radial-gradient(ellipse closest-side,transparent 50%,#fffdf72e 70%,#fffdf76b 85%,#fffdf7b3 100%)}
.turn-shade,.turn-white{position:absolute;inset:0;pointer-events:none}.turn-white{background:white}.turn-shade{background:linear-gradient(180deg,#47351d66,transparent 18%,#fff9 72%,#5c432d99);opacity:0}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
.caption-line{display:block;opacity:0;transition:opacity 650ms ease-in-out} @media(prefers-reduced-motion:reduce){.turn-sheet{display:none}#caption,.caption-line{transition:none!important}}

.turn-fold{position:absolute;inset:0;z-index:6;pointer-events:none;will-change:clip-path;background:transparent}
@media(prefers-reduced-motion:reduce){.turn-fold{display:none}}

/* Dawn: the book's furniture steps back, and the light fills the whole room. */
#light-room{position:fixed;inset:0;z-index:50;background:#fffdf8;opacity:0;pointer-events:none}
body.light-scene #light-room{pointer-events:auto;cursor:pointer}
body.reading>header,body.reading>footer{transition:opacity 1800ms ease}
body.light-scene>header,body.light-scene>footer{opacity:0;pointer-events:none}
@media(prefers-reduced-motion:reduce){body.reading>header,body.reading>footer{transition:none}}

/* The controls stay in one place whatever the length of the text. */
body.reading{min-height:100svh;grid-template-rows:auto auto 1fr;align-content:stretch;touch-action:pan-y}
body.reading>footer{display:flex;flex-direction:column;min-height:0}
body.reading #caption{width:100%;margin-bottom:auto;padding-bottom:12px}
body.reading .controls{flex:none;order:3}
body.reading #restart,body.reading #restore-reading{order:2;align-self:center;margin:0 auto 10px}
body.reading #hint{order:4;min-height:19px}
@media(max-height:500px) and (orientation:landscape){body.reading{grid-template-rows:auto 1fr}body.reading>footer{align-self:stretch}}
/* Small phones: give the longest text room so the controls never have to move. */
@media(max-width:500px) and (max-height:700px){#page{width:min(94vw,calc(100svh - 340px))}body.reading #caption{line-height:1.85;margin-bottom:auto;padding-bottom:8px}}

/* ===== The book ===== One book, held wide (picture left, text right) or held tall (picture above, text below). */
body{background:#d9c6a4 url('art/ui/desk.webp') center/cover no-repeat fixed}
body.reading{display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:auto 1fr auto;align-items:center;justify-items:center;height:100svh;min-height:0;overflow:hidden;overscroll-behavior:none;--header:48px;--footer:88px}
body.reading>header{grid-row:1;grid-column:1;width:100%;max-width:none;height:var(--header);padding:6px 18px;margin:0}
body.reading>header>span{display:none}
.book-title-logo{width:112px}
body.reading>footer{grid-row:3;grid-column:1;width:100%;max-width:none;height:var(--footer);min-height:0;padding:6px 12px 0;margin:0;position:relative;display:flex;flex-direction:column;align-items:center}
body.reading .controls{order:0;gap:16px}
body.reading #hint{order:1;margin:4px 0 0;min-height:18px;font-size:12px;color:#5d4a2d}
body.reading #restart,body.reading #restore-reading{position:absolute;top:6px;right:max(10px,calc(50% - 390px));margin:0;min-width:0;padding:10px 16px;order:0}
main{display:grid;place-items:center;min-width:0;min-height:0;padding:0;overflow:visible;position:relative}
#book{grid-row:2;grid-column:1;position:relative;display:grid;perspective:2200px;background-repeat:no-repeat;box-shadow:0 1px 0 #f4ead6,1px 2px 0 #dccfb6,0 3px 0 #f1e6d0,1px 4px 0 #d6c8ad,0 5px 0 #efe3cc,0 8px 14px #4a33172e,0 20px 44px #4a33173d;border-radius:2px}
body.reading #page{width:92%;height:auto;min-height:0;aspect-ratio:1;padding:0;background:transparent;border:0;box-shadow:none;overflow:hidden}
#text-page{position:relative;min-width:0;min-height:0;display:flex;align-items:center;justify-content:center;overflow:auto}
body.reading #caption{width:100%;max-width:26em;height:auto;margin:0 auto;padding:0;line-height:1.95;letter-spacing:.05em;color:#4c4333;font-size:clamp(15px,calc(var(--side)*.034),21px)}
:is(#chapter-title,.turn-chapter-title){position:absolute;inset:0;display:flex;align-items:center;justify-content:center;text-align:center;padding:8%;font-size:clamp(20px,calc(var(--side)*.058),36px);letter-spacing:.14em;line-height:1.7;text-shadow:none;color:#4c4333;white-space:normal}
.leaf-face{position:absolute;z-index:8;display:grid;place-items:center;pointer-events:none;overflow:hidden;backface-visibility:hidden;background:#f6ead5;will-change:transform;--shade:0}
.leaf-face::after{content:'';position:absolute;inset:0;background:#3b2a12;opacity:calc(var(--shade)*.2);pointer-events:none}
.leaf-face .turn-art{position:relative}
.leaf-chapter-art{width:92%;height:92%;object-fit:contain}
.turn-sheet{background:transparent}

@media (orientation:landscape){
 body.reading{--side:min(47vw,calc(100svh - var(--header) - var(--footer) - 18px))}
 #book{grid-template-columns:var(--side) var(--side);grid-template-rows:var(--side);background-image:url('art/ui/book-paper.webp');background-size:100% 100%}
 #text-page{padding:9% 10%}
 .leaf-text{transform-origin:left center;background:#f6ead5 url('art/ui/book-paper.webp') right center/200% 100% no-repeat}
 .leaf-picture{transform-origin:right center;background:#f6ead5 url('art/ui/book-paper.webp') left center/200% 100% no-repeat}
}
@media (orientation:landscape) and (max-height:500px){
 body.reading{--header:0px;--footer:58px}
 body.reading>header{display:none}
 body.reading #hint{display:none}
 body.reading>footer{padding-top:5px}
 #text-page{padding:6% 8%}
}
@media (orientation:portrait){
 body.reading{--header:46px;--text-min:172px;--side:min(95vw,760px,calc(100svh - var(--header) - var(--footer) - 14px - var(--text-min)));--text:min(var(--side),calc(100svh - var(--header) - var(--footer) - 14px - var(--side)))}
 #book{grid-template-columns:var(--side);grid-template-rows:var(--side) var(--text);background-image:url('art/ui/book-paper-v.webp');background-size:100% 100%}
 #text-page{padding:5% 7%;align-items:center}
 body.reading #restart,body.reading #restore-reading{position:static;order:-1;margin:0 0 6px}
 body.reading:has(#restart:not([hidden])){--footer:144px}
 .leaf-text{transform-origin:center top;background:#f6ead5 url('art/ui/book-paper-v.webp') center bottom/100% auto no-repeat}
 .leaf-picture{transform-origin:center bottom;background:#f6ead5 url('art/ui/book-paper-v.webp') center top/100% auto no-repeat}
}
/* Tall book: each page carries its own half of the paper, so the gutter always sits exactly between them. */
@media (orientation:portrait){
 #book{background-image:none;background-color:#f6ead5}
 main,.leaf-picture{background:#f6ead5 url('art/ui/book-paper-v.webp') center top/100% 200% no-repeat}
 #text-page,.leaf-text{background:#f6ead5 url('art/ui/book-paper-v.webp') center bottom/100% 200% no-repeat}
}
/* Tall book: the text page always has room for the longest passage, so it never scrolls. */
@media (orientation:portrait){
 body.reading{--text-min:max(196px,30svh)}
 #text-page{padding:12px 7%}
 body.reading #caption{line-height:1.85}
}
@media (orientation:portrait) and (max-height:680px){
 body.reading{--header:40px;--footer:60px;--text-min:188px}
 body.reading #hint{display:none}
 body.reading:has(#restart:not([hidden])){--footer:114px}
 body.reading>header{padding:4px 14px}
 .book-title-logo{width:92px}
 body.reading #caption{font-size:14px;line-height:1.72;letter-spacing:.03em}
 #text-page{padding:8px 5%}
}

/* Both recovery buttons can show on the last page: keep them apart. */
@media (orientation:landscape){body.reading #restore-reading{right:auto;left:max(10px,calc(50% - 390px))}}

/* Tall book: both pages are the same square, one above the other. */
@media (orientation:portrait){
 body.reading{--side:min(95vw,760px,calc((100svh - var(--header) - var(--footer) - 14px)/2));--text:var(--side)}
}

/* The way back to the shelf. */
.shelf-link{color:#5d4a2d;font-size:12px;letter-spacing:.06em;text-decoration:none;white-space:nowrap;padding:8px 4px;border-radius:4px}
.shelf-link:hover{text-decoration:underline;text-underline-offset:4px}
.shelf-link:focus-visible{outline:2px solid currentColor;outline-offset:2px}
.cover-shelf-link{position:absolute;left:12px;top:8px;font-size:13px}
.foot-shelf-link{display:none}
#cover{position:relative}

/* ===== Fewer buttons ===== Tap and swipe turn the page; everything else lives in the menu. */
.menu-button{display:grid;place-items:center;width:44px;height:44px;padding:0;margin-right:-6px;background:none;border:0;border-radius:10px;color:#5d4a2d;cursor:pointer}
.menu-button:focus-visible{outline:2px solid currentColor;outline-offset:-2px}
body.reading>header{align-items:center}
body.reading{--footer:62px}
body.reading:has(#restart:not([hidden])){--footer:62px}
body.reading .controls{gap:10px}
.controls #previous:not(:focus-visible),.controls #next:not(:focus-visible){position:absolute;width:1px;height:1px;min-width:0;min-height:0;padding:0;border:0;overflow:hidden;clip-path:inset(50%)}
.controls #count{min-width:0;min-height:32px;padding:2px 10px;background:none;color:#5d4a2d;font-size:12px;letter-spacing:.06em;text-decoration:none}
.end-link{display:none;min-height:36px;min-width:0;padding:6px 12px;border-radius:10px;background:transparent url('art/ui/paper-button.webp') center/100% 100% no-repeat;color:#554d40;font-size:12px;line-height:1.9;letter-spacing:.05em;text-decoration:none;white-space:nowrap}
body.at-end .end-link{display:inline-block}
.controls .end-link{min-width:0;min-height:36px;padding:6px 12px;font-size:12px}
body.at-end #hint{display:none}
#book-menu{position:fixed;inset:8px 8px auto auto;margin:0;width:min(84vw,270px);max-height:calc(100svh - 16px);overflow:auto;padding:0;border:1px solid #b7ae9b;border-radius:14px;background:#f8f3e8;color:#554e42;box-shadow:0 12px 48px #44392740}
#book-menu::backdrop{background:#332b2147}
.menu-sheet{display:flex;flex-direction:column;padding:8px}
body.reading #book-menu .menu-sheet>*{order:0;position:static;display:block;width:100%;min-width:0;min-height:48px;margin:0;padding:12px 14px;background:none;border:0;border-radius:8px;box-shadow:none;color:inherit;font:inherit;font-size:14px;line-height:1.7;letter-spacing:.05em;text-align:left;text-decoration:none;cursor:pointer;transform:none;filter:none}
body.reading #book-menu .menu-sheet>[hidden]{display:none}
body.reading #book-menu .menu-sheet>:hover{background:#ece2cd}
body.reading #book-menu .menu-sheet>:focus-visible{outline:2px solid #6d887b;outline-offset:-2px}
body.reading #book-menu #menu-close{color:#7b715e;margin-top:4px;border-top:1px solid #e3d9c4;border-radius:0 0 8px 8px}
@media (orientation:portrait) and (max-height:680px){
 body.reading{--footer:44px}
 body.reading:has(#restart:not([hidden])){--footer:44px}
}
@media (orientation:landscape) and (max-height:500px){
 body.reading{--header:0px;--footer:40px}
 body.reading>header{display:block;height:0;padding:0;overflow:visible}
 body.reading>header>:not(.menu-button){display:none}
 .menu-button{position:fixed;right:6px;bottom:0;margin:0}
 body.reading>footer{padding-top:2px}
}

/* Closing page: only the title artwork, in the middle of the text page. */
body.reading #text-page.end-page{align-items:center;justify-content:center}
body.reading #text-page.end-page #caption{margin:auto;padding:0;text-align:center;width:100%}
#caption .end-logo{display:block;width:min(74%,340px);height:auto;margin:0 auto}
/* On the cover, the book itself stays closed: no reading area below it, no scrolling. */
body:not(.reading)>#book{display:none}

/* ===== Sideways phone ===== The book takes the whole height. The page number is printed in the
   corner of the text page, and the menu sits at the top right. Only the last page brings the
   bottom row back, for its two buttons. */
@media (orientation:landscape) and (max-height:500px){
 body.reading,body.reading:has(#restart:not([hidden])){--footer:0px;--side:min(47vw,calc((100vw - env(safe-area-inset-left) - env(safe-area-inset-right) - 12px)/2),calc(100svh - var(--footer) - 14px))}
 body.reading>footer{position:fixed;z-index:4;right:calc((100vw - 2*var(--side))/2 + 8px);bottom:calc((100svh - var(--side))/2 + 4px);left:auto;top:auto;width:auto;height:auto;min-height:0;padding:0;margin:0;background:none}
 body.reading .controls{gap:8px}
 body.reading .controls #count{min-height:24px;padding:0 6px;font-size:11px;opacity:.7}
 #text-page{padding:6% 8% 10%}
 body.reading #caption{font-size:clamp(15px,calc(var(--side)*.047),19px);line-height:1.8;letter-spacing:.04em}
 .menu-button{position:fixed;z-index:5;top:max(2px,env(safe-area-inset-top));right:max(2px,env(safe-area-inset-right));bottom:auto}
 body.reading.at-end,body.reading.at-end:has(#restart:not([hidden])){--footer:46px}
 body.reading.at-end>footer{position:static;width:100%;height:var(--footer);display:flex;flex-direction:column;justify-content:center;align-items:center}
 body.reading.at-end .controls #count{opacity:1}
}
