@font-face { font-family: "Fraunces"; font-style: normal; font-weight: 400 800; font-display: swap; src: url(../fonts/fraunces.woff2) format("woff2"); }
:root {
  --night: #061427;
  --deep: #0b2c44;
  --sea: #1f7a80;
  --lamp: #ffb347;
  --paper: #fff3dc;
  --foam: #bfe9ee;
  --px: 0; --py: 0;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: #020812; overflow: hidden; }
body { font-family: "Fraunces", Georgia, serif; font-variation-settings: "SOFT" 100; color: var(--paper); -webkit-tap-highlight-color: transparent; }

#stage { position: fixed; inset: 0; overflow: hidden; background: var(--night); --lift: 11vh; }
#layers, .layer, #fx, #flash, #scrim { position: absolute; inset: 0; }
/* turning the page: the old picture swings up off its left edge like a page, and the next one is lying underneath */
#layers { perspective: 300vw; }
.layer { overflow: hidden; background: var(--night); }
.layer.turn { z-index: 2; transform-origin: 0 50%; backface-visibility: hidden; pointer-events: none; animation: turn 1.2s cubic-bezier(.5, .05, .6, .95) forwards; }
.layer.turn::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to right, rgba(2, 8, 18, .85), rgba(2, 8, 18, .1) 46%, rgba(255, 240, 210, .28) 90%, rgba(255, 240, 210, 0)); animation: turnshade 1.2s ease-in forwards; }
.layer.under { animation: under 1.2s ease-out; }
@keyframes turn { from { transform: rotateY(0); } to { transform: rotateY(-97deg); } }
@keyframes turnshade { from { opacity: 0; } to { opacity: 1; } }
@keyframes under { from { filter: brightness(.35); } 60% { filter: brightness(.8); } to { filter: brightness(1); } }
/* the picture rides high so the words sit on its calm dark foot, not on the heroes */
.layer .tilt { position: absolute; inset: -5%; top: calc(-5% - var(--lift)); bottom: calc(-5% + var(--lift)); transform: translate(calc(var(--px) * -14px), calc(var(--py) * -10px)); transition: transform .5s ease-out; }
.layer .cam { position: absolute; inset: 0; transform-origin: 50% 55%; }
.layer canvas, .layer img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; -webkit-mask-image: linear-gradient(to top, transparent 0, #000 16%); mask-image: linear-gradient(to top, transparent 0, #000 16%); }
.rim { position: absolute; inset: 0; pointer-events: none; border-radius: 50%; }

#fx { width: 100%; height: 100%; pointer-events: none; mix-blend-mode: screen; }
#flash { background: #eaf6ff; opacity: 0; pointer-events: none; }
#flash.go { animation: flash .5s ease-out; }
/* beats: the whole picture reacts on a word */
#stage.shake1 #layers, #stage.shake1 #fx { animation: shake1 .45s linear; }
#stage.shake2 #layers, #stage.shake2 #fx { animation: shake2 .75s linear; }
#stage.punch #layers { animation: punch .75s cubic-bezier(.2, .8, .2, 1); }
#stage.drop #layers { animation: drop 1.05s cubic-bezier(.3, 0, .3, 1); }
#shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: rgba(2, 6, 14, .62); overflow: hidden; }
#shade::before { content: ""; position: absolute; top: -30%; left: -90%; width: 90%; height: 160%; background: radial-gradient(ellipse at 50% 50%, rgba(0, 0, 0, .95) 0, rgba(0, 0, 0, .8) 45%, transparent 70%); }
#stage.dark #shade { animation: dim 5s ease-in-out; }
#stage.dark #shade::before { animation: wing 2.2s ease-in; }
#stage.hop #layers, #stage.hop #fx { animation: hop .6s cubic-bezier(.3, 0, .3, 1); }
@keyframes hop { 0%, 100% { translate: 0 0; scale: 1; } 12% { translate: 0 8px; scale: 1.02 .98; } 42% { translate: 0 -34px; scale: .99 1.02; } 72% { translate: 0 0; scale: 1.03 .97; } 86% { translate: 0 -6px; scale: 1; } }
#stage.freeze #layers, #stage.freeze #fx { animation: freeze 3.6s ease-in-out; }
#stage.freeze .cam { animation-play-state: paused; }
@keyframes freeze { 0%, 100% { filter: none; } 10%, 82% { filter: grayscale(1) contrast(1.12) brightness(.82); } }
@keyframes shake1 { 0%, 100% { translate: 0 0; } 15% { translate: -7px 4px; } 30% { translate: 6px -5px; } 45% { translate: -5px -3px; } 60% { translate: 4px 4px; } 80% { translate: -2px 1px; } }
@keyframes shake2 { 0%, 100% { translate: 0 0; rotate: 0deg; } 8% { translate: -16px 9px; rotate: -.6deg; } 18% { translate: 14px -11px; rotate: .5deg; } 30% { translate: -12px -6px; rotate: -.4deg; } 44% { translate: 10px 8px; rotate: .3deg; } 60% { translate: -6px 4px; } 78% { translate: 4px -2px; } }
@keyframes punch { 0% { scale: 1; } 22% { scale: 1.09; } 100% { scale: 1; } }
@keyframes drop { 0% { translate: 0 0; } 55% { translate: 0 -9%; scale: 1.08; } 72% { translate: 0 1.5%; scale: 1; } 86% { translate: 0 -.8%; } 100% { translate: 0 0; } }
@keyframes dim { 0% { opacity: 0; } 30%, 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes wing { from { translate: 0 0; } to { translate: 330% 0; } }
#scrim { pointer-events: none; background:
  radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(2, 8, 18, .55) 100%),
  linear-gradient(to top, rgba(2, 8, 18, .96) 0, rgba(2, 8, 18, .8) 20%, transparent 44%); }

/* camera moves, one per scene */
.cam-push    { animation: push 26s ease-out both; }
.cam-drift   { animation: drift 30s ease-in-out infinite alternate; }
.cam-rock    { animation: rock 5.5s ease-in-out infinite alternate; }
.cam-rise    { animation: rise 9s cubic-bezier(.2, .7, .2, 1) both; }
.cam-sway    { animation: sway 4.2s ease-in-out infinite alternate; }
.cam-breathe { animation: breathe 6s ease-in-out infinite alternate; }
.cam-rush    { animation: rush 2.8s ease-in-out infinite alternate; }
.cam-climb   { animation: climb 3.4s ease-in-out infinite alternate; }
.cam-spin    { animation: spin 40s linear infinite; }
.cam-soar    { animation: soar 5s ease-in-out infinite alternate; }
.cam-loom    { animation: loom 14s cubic-bezier(.2, .6, .2, 1) both; }
#stage[data-fx~="rumble"] .layer.open .tilt { animation: rumble 4.5s linear infinite; }
@keyframes push    { from { transform: scale(1.02); } to { transform: scale(1.16); } }
@keyframes drift   { from { transform: scale(1.06) translateX(-1.6%); } to { transform: scale(1.06) translateX(1.6%); } }
@keyframes rock    { from { transform: scale(1.1) rotate(-2.2deg) translateY(-1%); } to { transform: scale(1.1) rotate(2.2deg) translateY(1.2%); } }
@keyframes rise    { from { transform: scale(1.12) translateY(-5%); } to { transform: scale(1.04) translateY(0); } }
@keyframes sway    { from { transform: scale(1.1) rotate(-1.4deg) translateX(-1%); } to { transform: scale(1.1) rotate(1.4deg) translateX(1%); } }
@keyframes breathe { from { transform: scale(1.03); } to { transform: scale(1.07); } }
@keyframes rush    { from { transform: scale(1.08) translateY(-.6%); } to { transform: scale(1.08) translateY(.9%); } }
@keyframes climb   { from { transform: scale(1.08) translateY(-.8%) rotate(-.4deg); } to { transform: scale(1.08) translateY(.8%) rotate(.4deg); } }
@keyframes soar    { from { transform: scale(1.14) rotate(-3.2deg) translate(-1.5%, 1%); } to { transform: scale(1.14) rotate(3.2deg) translate(1.5%, -1%); } }
@keyframes loom    { from { transform: scale(1.3) translateY(9%); } to { transform: scale(1.04) translateY(0); } }
@keyframes spin    { from { transform: scale(1.5) rotate(0); } to { transform: scale(1.5) rotate(360deg); } }
@keyframes rumble  { 0%, 62%, 100% { translate: 0 0; } 66% { translate: 3px -2px; } 70% { translate: -3px 2px; } 74% { translate: 2px 2px; } 78% { translate: -2px -1px; } 84% { translate: 1px 0; } }
@keyframes flash   { 0% { opacity: 0; } 8% { opacity: .85; } 22% { opacity: .15; } 30% { opacity: .6; } 100% { opacity: 0; } }

.screen { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 clamp(20px, 5vw, 72px) max(clamp(22px, 4.5vh, 54px), env(safe-area-inset-bottom)); }
.screen[hidden] { display: none; }

/* title */
#title { top: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding-top: clamp(20px, 5vh, 56px); }
.brand { margin: 0; font-weight: 800; font-size: clamp(3.4rem, 11vw, 9.5rem); line-height: .82; letter-spacing: -.035em; }
.brand span { display: block; }
.brand span:first-child { color: var(--lamp); text-shadow: 0 0 60px rgba(255, 179, 71, .55); }
.brand span:last-child { margin-left: .42em; }

/* library: the brand up in the sky, the shelves of stories on the dark foot of the picture */
#library { top: 0; display: flex; flex-direction: column; align-items: flex-start; padding-top: clamp(20px, 5vh, 56px); overflow-y: auto; }
#library[hidden] { display: none; }
#tagline { margin: clamp(14px, 2.4vh, 26px) 0 auto; padding-bottom: 24px; font-size: clamp(1.05rem, 2vw, 1.5rem); font-style: italic; color: var(--foam); }
#themes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
#themes[hidden] { display: none; }
#themes button, #back { font-size: 1rem; background: rgba(6, 20, 39, .5); border: 1px solid rgba(191, 233, 238, .35); border-radius: 999px; padding: .4em .95em; color: var(--foam); backdrop-filter: blur(6px); }
#themes button[aria-pressed="true"] { background: var(--lamp); color: #2a1600; border-color: var(--lamp); }
/* the bookcase: each age is a shelf, each story a cloth book standing on it with its picture pasted on the front */
#groups { display: flex; flex-wrap: wrap; align-items: flex-end; gap: clamp(20px, 3.2vh, 38px) clamp(20px, 2.6vw, 44px); width: 100%; transition: opacity .5s; }
.bay { --ph: clamp(64px, 8.6vh, 86px); position: relative; display: flex; flex-direction: column; padding-bottom: calc(var(--ph) * .84); }
.books { position: relative; z-index: 1; display: flex; align-items: flex-end; gap: clamp(16px, 1.7vw, 28px); padding: 0 clamp(30px, 2.8vw, 44px); }
/* the shelf is a painted board with a star on each bracket: its two ends keep their shape and only the middle stretches */
.plank { position: absolute; left: 0; right: 0; bottom: 0; height: var(--ph); border-style: solid; border-width: 0 calc(var(--ph) * .95); border-image: url(../art/ca-shelf-plank.webp) 0 170 fill / 0 calc(var(--ph) * .95) stretch; filter: drop-shadow(0 14px 12px rgba(2, 8, 18, .6)); transition: opacity .5s; }
.plank h2 { position: absolute; left: 50%; top: 62%; translate: -50% 0; white-space: nowrap; margin: 0; font-size: clamp(.82rem, 1.1vw, .98rem); font-weight: 700; line-height: 1; color: #2a1600; padding: .28em .8em .3em; border-radius: 3px; background: linear-gradient(#f0d28a, #c2933f); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5), 0 2px 5px rgba(0, 0, 0, .55); }
.plank h2 small { font-size: .86em; font-weight: 500; font-style: italic; }
/* books slim down a little as the library grows, so the shelves stay on one row for as long as they can */
.book { --w: clamp(104px, min(10.6vw, calc(61vw / var(--n, 6))), 172px); --d: calc(var(--w) * .2); position: relative; flex: none; width: var(--w); aspect-ratio: 3 / 4.15; padding: 0; border: 0; background: none; font: inherit; color: var(--paper); cursor: pointer; perspective: 1100px; perspective-origin: 30% -30%; transition: translate .9s cubic-bezier(.3, .7, .2, 1), scale .9s cubic-bezier(.3, .7, .2, 1), opacity .4s; }
.book::after { content: ""; position: absolute; left: 4%; right: -14%; bottom: -5px; height: 12px; border-radius: 50%; background: rgba(2, 8, 18, .7); filter: blur(6px); transition: opacity .3s; }
.vol { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateY(26deg); transition: transform .5s cubic-bezier(.2, .8, .2, 1); }
.vol > span { position: absolute; }
.spine { top: 0; bottom: 0; left: 0; width: var(--d); transform-origin: 0 50%; transform: translateZ(calc(var(--d) / 2)) rotateY(90deg); border-radius: 2px; background: linear-gradient(to bottom, transparent 9%, rgba(240, 210, 138, .9) 9%, rgba(240, 210, 138, .9) 10.5%, transparent 10.5%, transparent 13%, rgba(240, 210, 138, .9) 13%, rgba(240, 210, 138, .9) 14%, transparent 14%, transparent 86%, rgba(240, 210, 138, .9) 86%, rgba(240, 210, 138, .9) 87.5%, transparent 87.5%), linear-gradient(to right, rgba(0, 0, 0, .45), rgba(255, 255, 255, .08) 45%, rgba(0, 0, 0, .3)), var(--cloth); }
.edge { top: 0; left: 2%; right: 3%; height: var(--d); transform-origin: 50% 0; transform: translateZ(calc(var(--d) / 2)) rotateX(-90deg); background: repeating-linear-gradient(to bottom, #f4e6c6 0, #f4e6c6 2px, #d9c69c 3px); }
.leaf { overflow: hidden; inset: 2% 3% 2% 0; transform: translateZ(calc(var(--d) / 2 - 2px)); border-radius: 0 3px 3px 0; background: linear-gradient(to right, #cdb88a, #fff6df 14%, #fff3d6); box-shadow: inset 0 0 30px rgba(255, 190, 100, .0); }
.cover { inset: 0; transform-origin: 0 50%; transform: translateZ(calc(var(--d) / 2)); transform-style: preserve-3d; border-radius: 2px 5px 5px 2px; background: linear-gradient(to right, #e8d7ae, #fff3d6); transition: transform .8s cubic-bezier(.4, 0, .2, 1) .5s; }
.face { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 4%; padding: 8% 8% 6% 11%; text-align: left; border-radius: inherit; backface-visibility: hidden; background: linear-gradient(to right, rgba(0, 0, 0, .4), rgba(0, 0, 0, 0) 7%, rgba(255, 255, 255, .1) 9%, rgba(0, 0, 0, 0) 12%), radial-gradient(ellipse at 70% 0, rgba(255, 255, 255, .16), transparent 60%), var(--cloth); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35), inset 0 0 18px rgba(0, 0, 0, .35); }
.plate { flex: none; display: block; aspect-ratio: 1 / .92; border-radius: 2px; overflow: hidden; box-shadow: 0 0 0 1.5px rgba(240, 210, 138, .9), 0 2px 6px rgba(0, 0, 0, .5); }
.plate img, .plate canvas, .leaf img, .leaf canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.leaf img, .leaf canvas { opacity: 0; transition: opacity .5s .75s; }
.book.pulled .leaf img, .book.pulled .leaf canvas { opacity: 1; }
.face strong { font-size: calc(var(--w) * .084); font-weight: 800; line-height: 1.07; color: #f6dd9c; text-shadow: 0 1px 0 rgba(0, 0, 0, .55); text-wrap: balance; }
.face small { margin-top: auto; font-size: calc(var(--w) * .058); white-space: nowrap; font-style: italic; color: rgba(255, 243, 220, .8); }
.book:hover, .book:focus-visible { translate: 0 -10px; outline: none; }
.book:hover .vol, .book:focus-visible .vol { transform: rotateY(9deg) translateZ(18px); }
.book:hover .plate, .book:focus-visible .plate { box-shadow: 0 0 0 1.5px #ffd98a, 0 0 22px rgba(255, 179, 71, .65); }
.book:hover::after, .book:focus-visible::after { opacity: .45; }
/* pulled: the book flies to the middle of the room, turns to face you, and the cover swings open on the first page */
.book.pulled { z-index: 30; translate: var(--dx) var(--dy); scale: var(--sc); }
.book.pulled::after { opacity: 0; }
.book.pulled .vol { transform: rotateY(0deg); transition-duration: .8s; }
.book.pulled .cover { transform: translateZ(calc(var(--d) / 2)) rotateY(-158deg); }
.book.pulled .leaf { box-shadow: inset 0 0 60px rgba(255, 190, 100, .7), 0 0 60px rgba(255, 190, 100, .55); transition: box-shadow .6s .7s; }
#library.leaving .book:not(.pulled), #library.leaving .plank, #library.leaving .brand, #library.leaving #tagline, #library.leaving #themes { opacity: 0; transition: opacity .45s; }
#title:not([hidden]) { animation: arrive .7s ease-out; }
@keyframes arrive { from { opacity: 0; } to { opacity: 1; } }
#back { align-self: flex-start; margin-bottom: clamp(14px, 3vh, 30px); }
#storyname { margin: 0; font-weight: 800; font-size: clamp(2.4rem, 6.4vw, 5.6rem); line-height: .92; letter-spacing: -.03em; max-width: 13ch; text-wrap: balance; color: var(--lamp); text-shadow: 0 0 60px rgba(255, 179, 71, .45), 0 2px 22px rgba(2, 8, 18, .8); }
#blurb { margin: clamp(12px, 2vh, 22px) 0 auto; max-width: 34ch; font-size: clamp(1.05rem, 2vw, 1.5rem); font-style: italic; color: var(--foam); text-shadow: 0 2px 16px rgba(2, 8, 18, .9); }
#nameform { margin-top: clamp(18px, 3.4vh, 38px); width: min(100%, 560px); }
#nameform label { display: block; font-size: clamp(1.05rem, 1.9vw, 1.35rem); margin-bottom: 10px; }
#nameform .row { display: flex; gap: 10px; }
#name { flex: 1; min-width: 0; font: inherit; font-size: clamp(1.3rem, 2.6vw, 1.9rem); font-weight: 600; color: var(--paper); background: rgba(6, 20, 39, .6); border: 2px solid rgba(191, 233, 238, .45); border-radius: 999px; padding: .5em 1em; outline: none; backdrop-filter: blur(6px); }
#name::placeholder { color: rgba(191, 233, 238, .55); font-weight: 400; }
#name:focus { border-color: var(--lamp); box-shadow: 0 0 0 4px rgba(255, 179, 71, .22); }
button { font: inherit; cursor: pointer; color: inherit; }
#begin, #again { font-size: clamp(1.2rem, 2.3vw, 1.7rem); font-weight: 700; color: #2a1600; background: var(--lamp); border: 0; border-radius: 999px; padding: .5em 1.3em; box-shadow: 0 0 40px rgba(255, 179, 71, .5); transition: transform .2s, box-shadow .2s, opacity .2s; }
#begin:disabled { opacity: .35; box-shadow: none; cursor: default; }
#begin:not(:disabled):hover, #again:hover { transform: scale(1.05); box-shadow: 0 0 70px rgba(255, 179, 71, .8); }
:focus-visible { outline: 3px solid var(--foam); outline-offset: 3px; }

#shelf { display: flex; gap: clamp(8px, 1.4vw, 16px); margin-top: clamp(18px, 3.4vh, 36px); flex-wrap: wrap; }
#shelf .k { width: clamp(44px, 6vw, 64px); aspect-ratio: 1; border-radius: 50%; border: 2px dashed rgba(191, 233, 238, .3); display: grid; place-items: center; font-size: clamp(.95rem, 1.6vw, 1.3rem); color: rgba(191, 233, 238, .4); position: relative; }
#shelf .k.got { border: 2px solid var(--lamp); background: radial-gradient(circle at 50% 40%, rgba(255, 179, 71, .5), rgba(255, 179, 71, .08) 70%); color: var(--paper); box-shadow: 0 0 26px rgba(255, 179, 71, .45); }
#shelf .k canvas { width: 70%; height: 70%; }
#shelf .k[title]:hover::after, #shelf .k[title]:focus::after { content: attr(title); position: absolute; bottom: 118%; left: 50%; translate: -50% 0; white-space: nowrap; font-size: .9rem; background: rgba(2, 8, 18, .9); padding: .3em .7em; border-radius: 8px; color: var(--paper); }

/* painted keepsakes standing on a board. One not found yet is only its shadow. */
#shelf.painted { flex-direction: column; flex-wrap: nowrap; align-items: flex-start; gap: clamp(8px, 1.4vh, 14px); width: 100%; }
#shelf.painted .board { --kg: clamp(4px, .9vw, 14px); --ph: clamp(18px, 2.6vh, 26px); position: relative; display: flex; align-items: flex-end; gap: var(--kg); width: min(100%, calc(var(--n) * 96px + var(--ph) * 2)); padding: 0 calc(var(--ph) * .9) calc(var(--ph) * .78); }
#shelf.painted .board::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--ph); border-style: solid; border-width: 0 calc(var(--ph) * .95); border-image: url(../art/ca-shelf-plank.webp) 0 170 fill / 0 calc(var(--ph) * .95) stretch; filter: drop-shadow(0 10px 10px rgba(2, 8, 18, .6)); pointer-events: none; }
#shelf.painted .k.obj { flex: 1 1 0; min-width: 0; max-width: 84px; width: auto; aspect-ratio: 1; border: 0; border-radius: 0; background: none; box-shadow: none; padding: 0; display: flex; align-items: flex-end; justify-content: center; position: relative; z-index: 1; }
#shelf.painted .k.obj img { max-width: 100%; max-height: 100%; width: auto; height: auto; display: block; filter: brightness(0) invert(1) blur(.7px); opacity: .17; transform-origin: 50% 100%; }
#shelf.painted .k.obj.got { cursor: pointer; }
#shelf.painted .k.obj.got img { filter: drop-shadow(0 0 10px rgba(255, 179, 71, .5)) drop-shadow(0 3px 3px rgba(2, 8, 18, .7)); opacity: 1; transition: transform .28s cubic-bezier(.2, 1.4, .4, 1), filter .28s; animation: keepsit 5s ease-in-out calc(var(--i) * -.7s) infinite; }
#shelf.painted .k.obj.got:hover img, #shelf.painted .k.obj.got:focus-visible img { transform: translateY(-9%) scale(1.14) rotate(-4deg); filter: drop-shadow(0 0 20px rgba(255, 179, 71, .9)) drop-shadow(0 8px 6px rgba(2, 8, 18, .7)); animation-play-state: paused; }
#shelf.painted .k.obj.away img { visibility: hidden; }
@keyframes keepsit { 50% { transform: translateY(-3%) rotate(1.2deg); } }

/* a keepsake picked up off the shelf */
#held[hidden] { display: none; }
#held { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-rows: 1fr auto auto auto 1fr; justify-items: center; align-items: end; gap: 0; padding: 4vh 6vw; perspective: 900px; background: radial-gradient(circle at 50% 44%, rgba(11, 44, 68, .9), rgba(2, 8, 18, .97) 62%); opacity: 0; transition: opacity .4s; cursor: pointer; overflow: hidden; }
#held.in { opacity: 1; }
#held .rays { position: absolute; left: 50%; top: 44%; width: 150vmax; aspect-ratio: 1; translate: -50% -50%; background: repeating-conic-gradient(from 0deg, rgba(255, 179, 71, .17) 0 7deg, transparent 7deg 20deg); -webkit-mask: radial-gradient(circle, #000 0, rgba(0, 0, 0, .55) 16%, transparent 44%); mask: radial-gradient(circle, #000 0, rgba(0, 0, 0, .55) 16%, transparent 44%); animation: rays 46s linear infinite; pointer-events: none; }
@keyframes rays { to { rotate: 360deg; } }
#heldobj { grid-row: 2; background: none; border: 0; padding: 0; position: relative; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .18s ease-out; animation: heldfloat 4.6s ease-in-out infinite; }
#heldobj img { display: block; width: auto; height: auto; max-width: min(64vw, 46vh); max-height: 46vh; min-width: min(48vw, 34vh); filter: drop-shadow(0 0 46px rgba(255, 179, 71, .6)) drop-shadow(0 26px 22px rgba(2, 8, 18, .75)); transition: transform .42s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes heldfloat { 50% { translate: 0 -1.6vh; } }
#heldname { grid-row: 3; position: relative; margin: 3vh 0 0; font-weight: 800; font-size: clamp(1.7rem, 4.4vw, 3.2rem); line-height: 1.02; letter-spacing: -.02em; color: var(--lamp); text-align: center; text-wrap: balance; text-shadow: 0 0 40px rgba(255, 179, 71, .45), 0 2px 16px rgba(2, 8, 18, .9); }
#heldfrom { grid-row: 4; position: relative; margin: .5em 0 0; font-style: italic; font-size: clamp(1.05rem, 2vw, 1.45rem); color: var(--foam); text-align: center; }
#heldhint { grid-row: 5; position: relative; align-self: end; margin: 0; font-size: .95rem; color: rgba(191, 233, 238, .6); }
#held > p { opacity: 0; transition: opacity .5s .25s; }
#held.in > p { opacity: 1; }

/* the keepsake an ending gives */
#won:has(img) { display: flex; align-items: center; gap: .7em; }
#won img { flex: none; width: clamp(60px, 6.4vw, 92px); height: auto; filter: drop-shadow(0 0 16px rgba(255, 179, 71, .65)) drop-shadow(0 4px 4px rgba(2, 8, 18, .7)); }
#end.in #won.new img { animation: prize 1.2s cubic-bezier(.2, 1.5, .4, 1) .9s both; }
@keyframes prize { 0% { transform: scale(0) rotate(-40deg); } 70% { transform: scale(1.18) rotate(6deg); } 100% { transform: none; } }

/* story */
#text { margin: 0 0 clamp(16px, 2.8vh, 30px); max-width: 44ch; font-size: clamp(1.15rem, 2.6vw, 2.4rem); font-weight: 560; line-height: 1.22; letter-spacing: -.012em; text-wrap: balance; text-shadow: 0 2px 22px rgba(2, 8, 18, .95), 0 0 3px rgba(2, 8, 18, .9); }
/* a soft dark cloud that follows the words wherever they sit, so they read over the busiest picture */
#text { position: relative; isolation: isolate; }
#text::before { content: ""; position: absolute; z-index: -1; inset: -.9em -1.5em; border-radius: 2em; background: rgba(2, 8, 18, .58); filter: blur(26px); pointer-events: none; }
#text:empty::before { display: none; }
#text .w { display: inline-block; opacity: 0; transform: translateY(.45em); filter: blur(6px); animation: word .6s cubic-bezier(.2, .7, .2, 1) forwards; }
#text .bang { display: inline-block; font-weight: 800; font-size: 1.5em; line-height: .9; color: var(--lamp); letter-spacing: .01em; text-shadow: 0 0 30px rgba(255, 150, 40, .9), 0 2px 18px rgba(2, 8, 18, .95); animation: bang .5s cubic-bezier(.2, 1.6, .3, 1) forwards; transform: scale(2.4) rotate(-6deg); filter: none; }
#text .loud { font-weight: 800; letter-spacing: .03em; }
@keyframes bang { to { opacity: 1; transform: scale(1) rotate(-2deg); } }
#text .nm { color: var(--lamp); text-shadow: 0 0 26px rgba(255, 179, 71, .65), 0 2px 22px rgba(2, 8, 18, .95); }
@keyframes word { to { opacity: 1; transform: none; filter: none; } }

#choices { display: flex; gap: clamp(12px, 2vw, 26px); flex-wrap: wrap; }
.choice { display: flex; align-items: center; gap: clamp(10px, 1.3vw, 18px); text-align: left; background: rgba(6, 20, 39, .55); border: 2px solid rgba(255, 179, 71, .5); border-radius: 999px; padding: 6px clamp(18px, 2.2vw, 30px) 6px 6px; font-size: clamp(1.05rem, 2vw, 1.55rem); font-weight: 650; line-height: 1.12; backdrop-filter: blur(8px); opacity: 0; transform: translateY(18px) scale(.94); transition: opacity .5s, transform .5s cubic-bezier(.2, 1.5, .4, 1), border-color .2s, box-shadow .2s, background .2s; }
.choice.in { opacity: 1; transform: none; }
.choice:nth-child(2) { transition-delay: .14s, .14s, 0s, 0s, 0s; }
.choice:hover, .choice:focus-visible { border-color: var(--lamp); background: rgba(40, 24, 4, .6); box-shadow: 0 0 46px rgba(255, 179, 71, .5); }
.choice .port { flex: none; width: clamp(62px, 8.6vw, 112px); aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 2px solid var(--lamp); box-shadow: inset 0 0 18px rgba(2, 8, 18, .8); position: relative; }
.choice .port canvas, .choice .port img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s; }
.choice:hover .port canvas, .choice:hover .port img { transform: scale(1.18); }
.choice.plain { padding: .6em 1.4em; }
.choice .port { background-repeat: no-repeat; }
.choice.picked { border-color: var(--lamp); box-shadow: 0 0 80px rgba(255, 179, 71, .9); }
.choice.fade { opacity: 0; transform: scale(.9); }

#end { margin-top: 4px; }
#closing { margin: 0 0 10px; font-size: clamp(1.15rem, 2.2vw, 1.75rem); font-style: italic; color: var(--foam); max-width: 34ch; }
#won { margin: 0 0 18px; font-size: clamp(1rem, 1.7vw, 1.25rem); color: var(--lamp); }
#retry { font-size: clamp(1.05rem, 2vw, 1.4rem); font-weight: 700; color: var(--paper); background: rgba(6, 20, 39, .6); border: 2px solid var(--lamp); border-radius: 999px; padding: .45em 1.2em; margin-right: 10px; }
#retry[hidden] { display: none; }
#shelfback { font-size: clamp(1.05rem, 2vw, 1.4rem); font-weight: 700; color: var(--paper); background: rgba(6, 20, 39, .6); border: 2px solid rgba(255, 255, 255, .45); border-radius: 999px; padding: .45em 1.2em; }
#end #again, #end #retry { margin: 0 10px 10px 0; }
#end > * { opacity: 0; transform: translateY(12px); transition: opacity .9s, transform .9s; }
#end.in > * { opacity: 1; transform: none; }
#end.in > :nth-child(2) { transition-delay: .5s; }
#end.in > :nth-child(3) { transition-delay: 1s; }
#end.in > :nth-child(n+4) { transition-delay: 1.2s; }

#tools { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px; display: flex; gap: 8px; }
#tools[hidden] { display: none; }
#tools button { font-size: .95rem; background: rgba(6, 20, 39, .5); border: 1px solid rgba(191, 233, 238, .35); border-radius: 999px; padding: .4em .95em; color: var(--foam); backdrop-filter: blur(6px); }
#tools button[aria-pressed="true"] { background: var(--lamp); color: #2a1600; border-color: var(--lamp); }

@media (max-width: 640px) {
  #choices { flex-direction: column; }
  .choice { width: 100%; }
  #text { max-width: none; }
}
/* wide screens: the words move around the picture from scene to scene (data-place on the stage) */
@media (min-width: 900px) and (min-aspect-ratio: 4/5) {
  #story { top: 0; padding-top: clamp(64px, 10vh, 96px); display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; pointer-events: none; }
  #story[hidden] { display: none; }
  #story > * { pointer-events: auto; }
  #text { max-width: 28ch; font-size: clamp(1.1rem, 1.75vw, 1.7rem); }
  #end { width: min(100%, 27rem); }
  #choices { flex-direction: column; align-items: flex-start; gap: 12px; }
  #stage[data-place="br"] #story { align-items: flex-end; }
  #stage[data-place="br"] #text, #stage[data-place="br"] #end, #stage[data-place="tr"] #text { width: 28ch; max-width: 100%; }
  #stage[data-place="br"] #choices { align-items: flex-end; }
  #stage[data-place="tl"] #text, #stage[data-place="tr"] #text { margin-bottom: auto; }
  #stage[data-place="tr"] #text { align-self: flex-end; }
  #stage[data-place="tl"] #choices, #stage[data-place="tl"] #end { align-self: flex-end; align-items: flex-end; }
  #stage[data-place="tl"] #choices, #stage[data-place="tr"] #choices, #stage[data-place="bc"] #choices { flex-direction: row; flex-wrap: wrap; }
  #stage[data-place="bc"] #text { max-width: 72ch; }
  /* three or more picture choices sit side by side, so they never squeeze the words into the top corner */
  #stage[data-place="bl"] #choices:has(button:nth-child(3)), #stage[data-place="br"] #choices:has(button:nth-child(3)) { flex-direction: row; flex-wrap: wrap; align-items: center; }
  #stage[data-place="br"] #choices:has(button:nth-child(3)) { justify-content: flex-end; }
  /* a long page gets a wider column so it never runs up under the buttons at the top */
  #stage[data-long] #text, #stage[data-long] #end { max-width: 35ch; }
  #stage[data-long][data-place="br"] #text, #stage[data-long][data-place="br"] #end, #stage[data-long][data-place="tr"] #text { width: 35ch; }
  #stage[data-long][data-place="bc"] #text { max-width: 72ch; }
  #stage[data-place="bc"] #end { position: absolute; right: clamp(20px, 5vw, 72px); bottom: clamp(22px, 4.5vh, 54px); width: clamp(280px, 27vw, 420px); }
  #stage[data-place="bc"] #story:has(#end:not([hidden])) #text { max-width: min(58ch, 58vw); }
  #stage[data-place="bl"] #scrim { background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(2, 8, 18, .5) 100%), linear-gradient(to right, rgba(2, 8, 18, .88) 0, rgba(2, 8, 18, .62) 22%, transparent 46%), linear-gradient(to top, rgba(2, 8, 18, .8) 0, transparent 26%); }
  #stage[data-place="br"] #scrim { background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(2, 8, 18, .5) 100%), linear-gradient(to left, rgba(2, 8, 18, .88) 0, rgba(2, 8, 18, .62) 22%, transparent 46%), linear-gradient(to top, rgba(2, 8, 18, .8) 0, transparent 26%); }
  #stage[data-place="tl"] #scrim { background: radial-gradient(ellipse 58% 62% at 0 0, rgba(2, 8, 18, .9) 0, rgba(2, 8, 18, .6) 50%, transparent 100%), radial-gradient(ellipse 50% 40% at 100% 100%, rgba(2, 8, 18, .85) 0, transparent 100%), linear-gradient(to top, rgba(2, 8, 18, .7) 0, transparent 22%); }
  #stage[data-place="tr"] #scrim { background: radial-gradient(ellipse 58% 62% at 100% 0, rgba(2, 8, 18, .9) 0, rgba(2, 8, 18, .6) 50%, transparent 100%), radial-gradient(ellipse 50% 40% at 0 100%, rgba(2, 8, 18, .85) 0, transparent 100%), linear-gradient(to top, rgba(2, 8, 18, .7) 0, transparent 22%); }
}
/* tall screens: the picture takes the top two thirds and the words get the dark below it */
/* very wide monitors: bigger words, they are read from further back */
@media (min-width: 2400px) and (min-aspect-ratio: 4/5) { #text { font-size: 2.15rem; } }
@media (max-aspect-ratio: 4/5) {
  #stage .layer .tilt { top: -4%; bottom: 25%; }
  .book { --w: clamp(112px, 36vw, 160px); }
  .bay { width: 100%; }
  #scrim { background: linear-gradient(to top, rgba(2, 8, 18, .97) 0, rgba(2, 8, 18, .9) 34%, transparent 52%); }
}
@media (prefers-reduced-motion: reduce) {
  #stage.hop #layers, #stage.hop #fx { animation: none; }
  #shelf.painted .k.obj.got img, #held .rays, #heldobj, #end.in #won.new img { animation: none; }
  .layer.turn { animation: none; opacity: 0; } .layer.turn::after, .layer.under, #title:not([hidden]) { animation: none; }
  .book, .vol, .cover { transition: none; }
  .cam, #stage .layer .tilt { animation: none !important; transform: scale(1.04) !important; }
  #text .w { animation-duration: .01s; }
  #stage #layers, #stage #fx, #stage #shade, #stage #shade::before { animation: none !important; }
}
