/* Only audited hollow glyphs are repaired; the original weight and metrics stay intact. */
@font-face { font-family: Kouzan; src: url('./assets/fonts/KouzanMouhitu.ttf?v=glyph13') format('truetype'); font-display: block; font-weight: 400; }
:root { --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px); --toolbar-height: 5.5rem; --ink: #342d24; --paper: #f8f4e9; --red: #984432; --blue: #48636b; color-scheme: light; font-family: Kouzan, serif; font-weight: 700; font-synthesis: weight; }
:root { --fit-height: 100vh; }
@supports (height: 100lvh) { :root { --fit-height: 100lvh; } }
* { box-sizing: border-box; }
html { overscroll-behavior-y: none; }
html:has(body.reading-book) { scroll-padding-top: calc(var(--toolbar-height) + var(--safe-top) + 12px); }
html, body { margin: 0; width: 100%; min-height: 100%; }
body { display: grid; place-items: center; background: var(--paper); color: var(--ink); min-height: 100svh; overscroll-behavior-y: none; }
button, input, output { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus { outline: none; }
:root[data-input="keyboard"] :is(button, a, input):focus-visible { outline: 3px solid #a94028; outline-offset: 5px; }
button { min-height: 44px; min-width: 44px; }
button, a { -webkit-user-select: none; user-select: none; }
img { display: block; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
a { color: #415d65; text-underline-offset: .22em; }
button:hover:not(:disabled) { filter: brightness(1.04); }
button:active:not(:disabled) { translate: 0 2px; }
/* Fit against the stable large viewport. Only the visible height/centering
   follows browser chrome; scale, bands and book typography remain unchanged. */
#stage { position: relative; width: min(100%, calc(var(--fit-height) * 9 / 16)); height: 100dvh; overflow: hidden; container-type: inline-size; isolation: isolate; background: var(--paper); box-shadow: 0 0 65px #42382425; font-size: max(20px, 5.5cqw); --design-height: calc(100cqw * 16 / 9); --scene-horizon: calc(50% - 16cqw); }
.design-frame { position: absolute; left: 0; top: calc((100% - var(--design-height)) / 2); width: 100%; height: var(--design-height); }
#screen { position: absolute; z-index: 2; inset: 0; }
#scenery { position: absolute; z-index: 0; pointer-events: none; inset: 0; overflow: hidden; background: #f6f0e3; }
#scenery { height: max(100%, var(--fit-height)); top: calc((100% - max(100%, var(--fit-height))) / 2); bottom: auto; }
#corridor { position: absolute; inset: 0; --corridor-perspective: 95cqw; }
/* Separate projection contexts keep the crossing floor from cutting a wall.
   Both use the identical camera and shared travel; the floor is painted first. */
.corridor-projection { position: absolute; inset: 0; perspective: var(--corridor-perspective); perspective-origin: 50% var(--scene-horizon); }
.corridor-world, .corridor-floor { position: absolute; left: 50%; top: var(--scene-horizon); width: 0; height: 0; transform-style: preserve-3d; will-change: transform; }
.corridor-plane { position: absolute; left: 0; top: 0; translate: -50% -50%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.house { background: url('./assets/backgrounds/nagaya.png') center / 110% 100% no-repeat; }
.ground { background: #efe2c9 url('./assets/backgrounds/vista.png') center bottom / 100% 320% no-repeat; mask-image: linear-gradient(transparent, #000 3%, #000 97%, transparent); }
.vista { position: absolute; inset: 0; background: linear-gradient(#fdfbf5 var(--scene-horizon), #f7e2bb var(--scene-horizon)); }
/* Anchor the unmodified painting's horizon (618/1672) at the corridor's 41%.
   Matching object-position and transform-origin preserves it under cover.
   The 1.12 display scale covers the sky edge after the downward placement. */
.vista-image { position: absolute; top: calc((100% - var(--design-height)) / 2); width: 100%; height: var(--design-height); object-fit: cover; object-position: 50% 36.96%; transform-origin: 50% 36.96%; transform: translateY(4.04%) scale(1.12); }
.daylight { position: absolute; inset: 0; background: linear-gradient(#faf7eed9, #faf7ee73 28%, #faf7ee38 63%, #f5e9d459); }
#boot { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--paper); font-size: max(18px, 6cqw); }
#boot span { writing-mode: vertical-rl; letter-spacing: .2em; }
#boot.ready { opacity: 0; pointer-events: none; transition: opacity .5s; }
#curtain { position: absolute; inset: 0; z-index: 8; background: #181511; opacity: 0; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.vertical { writing-mode: vertical-rl; text-orientation: mixed; }
.title-screen, .play-screen, .result-screen { touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.title-screen, .play-screen { position: absolute; inset: 0; }
.title-logo { position: absolute; right: 3%; bottom: max(3%, var(--safe-bottom)); width: 24.8%; height: auto; border-radius: 50%; }
.game-title { position: absolute; top: max(5%, var(--safe-top)); right: 7%; margin: 0; writing-mode: vertical-rl; font-size: 17.08cqw; line-height: 1.13; font-weight: 700; letter-spacing: .08em; --title-glow: 0 0 max(15px, 2.8cqw) #fff, 0 0 max(30px, 5.6cqw) #fffe; text-shadow: var(--title-glow); }
/* Ruby adds its width to the right-anchored line. Compensate its .34→.51em
   growth so the main title stays in place and the reading grows to the right. */
.game-title { translate: .17em 0; }
/* Keep the title reading's established unsynthesized brush weight. */
.game-title rt { font-size: .51em; letter-spacing: .03em; font-synthesis: none; text-shadow: var(--title-glow); }
.book-button { position: absolute; border: 0; background: none; padding: 0; aspect-ratio: 2 / 3; line-height: 1; letter-spacing: .14em; }
.book-button img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 0 1.4cqw #fff9) drop-shadow(.15cqw .25cqw .35cqw #4a382b26); }
.book-label { position: absolute; top: 48%; left: 49%; translate: -50% -50%; width: 62%; height: 74%; display: grid; place-items: center; background: #fffbef; border: 1px solid #77674e66; box-shadow: 1px 1px 0 #77674e33; }
.book-label ruby { writing-mode: vertical-rl; white-space: nowrap; letter-spacing: .1em; line-height: 1.15; }
.book-label rt { font-size: .48em; letter-spacing: .02em; font-synthesis: none; }
.start-book { top: 40%; left: 11%; width: 36%; rotate: -3deg; font-size: 8.5cqw; }
.people-book { bottom: 6%; left: 4%; width: 28%; rotate: -5deg; font-size: 7.2cqw; }
.stories-book { bottom: 5%; left: 37%; width: 28%; rotate: 4deg; font-size: 7.2cqw; }
.hud { position: absolute; z-index: 6; inset: max(3.555556cqw, var(--safe-top)) 3% auto; display: flex; align-items: center; justify-content: space-between; gap: 2%; font-size: max(19px, 5.2cqw); }
.hud-count { display: flex; gap: .8em; background: #faf7eee8; padding: .35em .4em; border-radius: 2px; white-space: nowrap; }
.hud-number { display: inline-block; width: 1em; text-align: center; }
.hud-count strong { color: var(--red); font-weight: 700; }
.pause-button { background: #faf7eeeb; border: 1px solid #71614d77; border-radius: 50%; width: 14cqw; height: 14cqw; font-size: max(17px, 4.5cqw); flex-shrink: 0; }
.actor { position: absolute; width: 78%; height: 72%; top: 21%; left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none; }
.actor-paper { position: absolute; width: 83%; height: 70%; top: 22%; left: 50%; transform: translateX(-50%); opacity: 0; pointer-events: none; background: radial-gradient(ellipse, #faf6eb 30%, #faf6ebe0 51%, #faf6eb00 72%); }
.actor img { position: absolute; top: 50%; left: 50%; width: auto; height: auto; max-width: 100%; max-height: 100%; translate: -50% -50%; transform: scale(var(--arrival-scale, 1)); transform-origin: 50% 32.5%; opacity: 0; }
.actor img.shown { opacity: 1; }
.bubble { position: absolute; background: transparent; border: 0; border-radius: 0; color: #30271e; isolation: isolate; }
.bubble-shape { position: absolute; inset: 0; width: 100%; height: 100%; fill: #fff; stroke: none; pointer-events: none; z-index: -1; }
.bubble-compact { display: none; }
.prompt-bubble { --prompt-shift: 0; --compact-height: 60%; z-index: 4; top: calc(16% - 3% * var(--prompt-shift)); left: calc(3% + 80.8% * var(--prompt-shift)); width: calc(45% - 29.8% * var(--prompt-shift)); height: calc(68% * (1 - var(--prompt-shift)) + var(--compact-height) * var(--prompt-shift)); display: grid; place-items: start center; padding: 7% calc(5% - 2.2% * var(--prompt-shift)) 7% calc(4% - 2.2% * var(--prompt-shift)); opacity: 0; font-size: calc(8.5cqw * (1 - var(--prompt-shift)) + max(19.8px, 5.76cqw) * var(--prompt-shift)); line-height: calc(1.4 - .25 * var(--prompt-shift)); }
.prompt-bubble.tall { --compact-height: 85%; }
.prompt-text { writing-mode: vertical-rl; text-orientation: mixed; max-height: 100%; max-width: 100%; text-align: start; }
.prompt-text span { opacity: 0; }
.prompt-bubble.compact .bubble-wide { display: none; }
.prompt-bubble.compact .bubble-compact { display: initial; }
.prompt-bubble.compact .prompt-text span { opacity: 1; }
.choices { position: absolute; inset: 0; }
.choice { --reply-shift: 0; --choice-fit: 1; --choice-top: 18%; --choice-height: 63%; --reply-top: 20%; --reply-height: 65%; left: calc(var(--choice-left) * (1 - var(--reply-shift)) + 1% * var(--reply-shift)); top: calc(var(--choice-top) * (1 - var(--reply-shift)) + var(--reply-top) * var(--reply-shift)); height: calc(var(--choice-height) * (1 - var(--reply-shift)) + var(--reply-height) * var(--reply-shift)); width: calc(23% + 6% * var(--reply-shift)); padding: 7% 2.5% 12%; z-index: 5; opacity: 0; font-size: calc(max(35.1px, 10.14cqw) * var(--choice-fit)); line-height: 1.15; display: grid; place-items: start center; }
.choice:nth-child(1) { --choice-left: 4%; }
.choice:nth-child(2) { --choice-left: 29%; }
.choice:nth-child(3) { --choice-left: 54%; }
.choice.tall { --choice-height: 80%; --reply-top: 18%; --reply-height: 80%; }
.choice span { writing-mode: vertical-rl; max-height: 100%; max-width: 100%; text-align: start; }
.choice.rejected { opacity: 0; pointer-events: none; }
.play-hint { position: absolute; bottom: max(3.555556cqw, var(--safe-bottom)); left: 2%; right: 2%; margin: 0; text-align: center; font-size: max(19px, 5cqw); line-height: 1.45; color: #53402d; background: transparent; padding: .3em; white-space: nowrap; pointer-events: none; }
.reaction-note { position: absolute; top: 0; left: 68%; width: 49%; transform: translate(-50%, -100%); text-align: center; line-height: 1.2; pointer-events: none; font-size: max(25px, 7cqw); color: var(--red); margin: 0; }
.ink-button { background: #fffaf0; border: 1px solid #5a493a; border-radius: 2px; padding: .45em .7em; font-size: max(21px, 5.5cqw); }
.ink-button.primary { background: var(--red); border-color: var(--red); color: #fffaf0; }
/* The page itself scrolls in every book, including iOS status-bar scroll-to-top. */
body.reading-book { display: block; }
.reading-book #stage { height: auto; min-height: 100dvh; margin-inline: auto; overflow: visible; }
.reading-book #screen { position: relative; }
.reading-book #scenery { display: none; }
.paper-screen { position: relative; min-height: 100dvh; background: var(--paper); }
.toolbar { position: sticky; top: 0; z-index: 7; height: calc(var(--toolbar-height) + var(--safe-top)); min-height: calc(var(--toolbar-height) + var(--safe-top)); max-height: calc(var(--toolbar-height) + var(--safe-top)); flex: none; display: grid; grid-template-columns: 22% 56% 22%; align-items: center; border-bottom: 1px solid #b5a68b; margin: 0 3%; padding-top: var(--safe-top); background: var(--paper); }
.toolbar h1 { font-weight: 700; font-size: max(27px, 7cqw); text-align: center; margin: 0; white-space: nowrap; line-height: 1.3; }
.toolbar button { display: flex; align-items: center; gap: .15em; justify-self: start; padding: .3em 0; border: 0; background: none; font-size: max(19px, 5cqw); }
.toolbar button > span { width: .55em; text-indent: -.48em; }
.book-content { position: relative; padding: 3% 3% max(4%, var(--safe-bottom)); }
.image-retry { font-size: max(20px, 5.3cqw); line-height: 1.5; margin: 0 0 1em; }
.image-retry button { display: block; margin-top: .5em; }
.book-intro { margin: 0 0 .8em; font-size: max(20px, 5.3cqw); line-height: 1.5; color: #685945; }
.people-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2cqw; }
.person-card { border: 0; background: #fffdf6; box-shadow: 0 2px 0 #c8bca3; padding: 0 0 .4em; font-size: max(17px, 4.5cqw); }
.person-card img { width: 100%; aspect-ratio: 1/1.2; object-fit: contain; margin: 0 auto; }
.person-card span { display: block; padding: .2em 0 .1em; }
.person-card.unlocked { color: #904531; }
.collection-count { display: block; color: var(--red); margin-bottom: .4em; }
.detail-image { width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: contain; margin: 0 auto; }
.expression-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2%; margin: 2% 0 4%; }
.expression-picker button { padding: 0 0 .3em; border: 1px solid #cfc1a9; background: white; font-size: max(16px, 4cqw); line-height: 1.3; }
.expression-picker button[aria-pressed="true"] { border: 2px solid var(--red); color: var(--red); }
.expression-picker img { width: 100%; height: 18cqw; object-fit: contain; }
.detail-reading { text-align: center; margin: 0; color: #796952; font-size: max(19px, 5cqw); }
.biography { font-size: max(22px, 5.7cqw); line-height: 1.6; }
.biography h2 { font-weight: 700; font-size: 1.16em; color: var(--red); margin: .5em 0 .35em; }
.story-list { list-style: none; padding: 0; margin: 0; }
.stories-screen .book-content { padding-top: 0; }
.story-entry:first-child { border-top: 0; }
.story-entry { position: relative; border-top: 1px solid #c4b79d; padding: .6em 0 .8em; font-size: max(23px, 6cqw); line-height: 1.6; }
.story-entry p { margin: .25em 0; }
.story-entry .reply { padding-left: .5em; color: var(--red); }
.story-number { font-size: .8em; color: #786548; }
.result-screen { position: absolute; inset: 0; background: #f8f4e9eb; text-align: center; }
.result-intro { position: absolute; top: 4%; width: 100%; margin: 0; letter-spacing: .12em; color: #826444; font-size: max(20px, 5.3cqw); }
.result-title { position: absolute; top: 10%; left: 3%; width: 94%; margin: 0; font-weight: 700; font-size: 7.8cqw; line-height: 1.65; }
.result-title strong { color: var(--red); font-size: 1.8em; font-weight: 700; }
.result-message { position: absolute; top: 29%; left: 4%; width: 92%; font-size: max(21px, 5.5cqw); line-height: 1.5; margin: 0; white-space: nowrap; }
.result-grid { position: absolute; left: 3%; right: 3%; top: 36%; height: 46%; display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(2, 1fr); gap: 3% 2%; }
.result-person { margin: 0; display: flex; flex-direction: column; min-height: 0; background: transparent; }
.result-portrait { display: flex; flex: 1; min-height: 0; width: 100%; border: 0; padding: 0; background: transparent; }
.result-portrait img { height: 100%; }
.result-person img { width: 100%; flex: 1; min-height: 0; object-fit: contain; }
.result-person figcaption { font-size: max(14px, 3.9cqw); color: #6c5e4b; line-height: 1.4; white-space: nowrap; }
.result-person.correct figcaption { color: var(--red); }
.result-return { position: absolute; left: 23%; width: 54%; bottom: max(7%, var(--safe-bottom)); }
dialog { border: 1px solid #827257; padding: 0; width: min(94vw, calc(var(--fit-height) * .52875), 640px); max-height: 94dvh; color: var(--ink); background: var(--paper); box-shadow: 5px 6px 0 #b9a98c; font-family: Kouzan, serif; font-weight: 700; font-synthesis: weight; }
dialog::backdrop { background: #251d15a8; }
.dialog-paper { padding: 20px; display: flex; flex-direction: column; font-size: clamp(24px, 5.7vw, 38px); }
.dialog-paper label { display: flex; justify-content: space-between; }
.dialog-paper input { width: 100%; min-height: 44px; margin: 4px 0 12px; accent-color: var(--red); touch-action: none; }
.dialog-paper button { font-size: 1em; margin-top: 8px; }
.error-panel { position: absolute; inset: 5%; display: grid; align-content: center; gap: 16px; background: var(--paper); padding: 5%; font-size: max(22px, 5.7cqw); line-height: 1.6; }
ruby { ruby-position: over; ruby-align: center; }
rt { font-size: .5em; font-weight: 700; }
.person-name { white-space: nowrap; }
.person-screen .toolbar h1 { padding-top: .4em; }
.biography p { margin: .5em 0; }
.storage-note { font-size: max(17px, 4.5cqw); line-height: 1.5; margin: 1em 0 0; }
.locked-intro { text-align: center; margin-top: 1em; }
.locked-intro span { display: block; white-space: nowrap; font-size: min(1em, 6.3cqw); }
@media (min-width: 768px) {
  :root { --toolbar-height: 12rem; }
}
@media (prefers-reduced-motion: reduce) {
  .corridor-world, .corridor-floor { will-change: auto; }
  .choice, .prompt-bubble, #boot.ready { transition: none; }
}
@container (max-width: 350px) {
  .choice { font-size: calc(max(31.2px, 10.14cqw) * var(--choice-fit)); line-height: 1.12; }
}
