* { box-sizing: border-box }
body { --background:#fff; --ink:#242424; --border:#ddd; --muted:#999; margin:0; background:var(--background); color:var(--ink); font-family:Arial,sans-serif }
body.dark { --background:#000; --ink:#eee; --border:#555; --muted:#888; color-scheme:dark }
main { min-height:100vh; min-height:100svh; display:grid; place-content:center; justify-items:center; gap:25px; padding:18px }
.stage { --width:min(46vw,73svh,850px); width:calc(2 * var(--width)); height:calc(var(--width) * 1.125); perspective:2200px; touch-action:pan-y pinch-zoom }
#book { position:relative; width:100%; height:100%; transform-style:preserve-3d; transition:transform .32s ease }
#book.front { transform:translateX(-25%) }
#book.back { transform:translateX(25%) }
.leaf { position:absolute; left:50%; width:50%; height:100%; transform-origin:left center; transform-style:preserve-3d; transition:transform .32s ease; cursor:pointer }
.turned { transform:rotateY(-180deg) }
.face { position:absolute; inset:0; background:white; backface-visibility:hidden; box-shadow:1px 2px 5px #0002; overflow:hidden }
.face.reverse { transform:rotateY(180deg) }
.face img { display:block; width:100%; height:100%; object-fit:contain; user-select:none }
.face::after { content:""; position:absolute; inset:0; background:linear-gradient(90deg,#0002,transparent 4%); pointer-events:none }
.reverse::after { transform:scaleX(-1) }
.board { border:1px solid #706e653d; border-radius:1px 4px 4px 1px; box-shadow:2px 3px 0 #c7c4ba,3px 8px 16px #0002 }
nav { max-width:100%; justify-content:center; flex-wrap:wrap; display:flex; align-items:center; gap:10px; font-size:13px }
button { background:var(--background); color:inherit; border:1px solid var(--border); border-radius:50%; width:42px; height:42px; cursor:pointer; font-size:19px }
button:disabled { color:var(--muted); cursor:default }
output { min-width:82px; text-align:center; font-variant-numeric:tabular-nums }
a { margin-left:12px; color:inherit; text-underline-offset:4px }
.rotation-tip { display:none; margin:0; text-align:center; font-size:14px; line-height:1.5 }
@media (orientation:portrait) and (pointer:coarse), (orientation:portrait) and (max-width:680px) {
 .rotation-tip { display:block }
}
@media (orientation:landscape) and (max-height:600px) {
 main { padding:8px; gap:8px }
 .stage { --width:min(46vw,calc((100svh - 68px) / 1.125)) }
}
@media(prefers-reduced-motion:reduce) { *,*::after { transition:none!important; animation:none!important } }
