@charset "UTF-8";
:root {
  --paper: #ebe2cc; --paper-2: #f4ecd9; --sheet: #f7f0de; --ink: #2f2a21; --ink-soft: #4a3f31;
  --muted: #7f745f; --line: #c8bb9f; --red: #933e2b; --red-ink: #a23a22; --green: #4a5c48; --violet: #53377a; --violet-glow: #b893ff;
  --display: "IM Fell English", "LXGW WenKai GB", "Palatino Linotype", Palatino, Georgia, "Kaiti SC", serif;
  --caps: "IM Fell English SC", "IM Fell English", "LXGW WenKai GB", Palatino, Georgia, "Kaiti SC", serif;
  --body: "EB Garamond", "LXGW WenKai GB", "Palatino Linotype", Palatino, Georgia, "Kaiti SC", serif;
  /* One typeface per voice: the Echo's even inscription, Marta's hand, the Collector's book hand, print. */
  --echo: "Marcellus", "Cormorant Garamond", Georgia, serif;
  --marta: "Carattere", "IM Fell English", Georgia, cursive;
  --collector: "IM Fell English", Palatino, Georgia, serif;
  --echo-ink: #1c2c6a; --echo-glow: #8fb0ff; --marta-ink: #3b2313; --collector-ink: #3f2d1b;
  /* Kepler's working hand: a quick humanist italic in blue-black ink. */
  --kepler: "Cormorant Garamond", "EB Garamond", Georgia, serif; --kepler-ink: #23283c;
  /* Chinese that is not spoken: the narrator in a Song face, the Echo in an even, airy one. Dialogue keeps WenKai. */
  --narrator: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --echo-zh: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", sans-serif;
  --speech: "LXGW WenKai GB", "LXGW WenKai", "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", serif;
  --ui: "EB Garamond", "LXGW WenKai GB", system-ui, sans-serif;
  --gutter: clamp(14px, 2.2vw, 30px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100svh; color: var(--ink); font-family: var(--body); background: var(--paper); font-synthesis-style: none;
  background-image:
    radial-gradient(ellipse 80% 60% at 20% -10%, #fff8e6aa, transparent 60%),
    radial-gradient(ellipse 70% 50% at 110% 110%, #b8a27a33, transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .22 0 0 0 0 .12 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
}
.defs { position: absolute; width: 0; height: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible, .stage:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
[hidden] { display: none !important; }
kbd { font: 600 10px var(--ui); letter-spacing: 1px; border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 5px; border-radius: 3px; background: var(--paper-2); }
.eyebrow { font: 600 10.5px/1.2 var(--ui); letter-spacing: 2.2px; text-transform: uppercase; color: var(--muted); margin: 0; }
.seal { display: inline-flex; color: var(--red); width: 34px; height: 34px; flex: none; }
.seal svg { width: 100%; height: 100%; }

/* ——— Buttons ——— */
.ink-button {
  position: relative; border: 1px solid var(--ink); background: var(--ink); color: var(--sheet);
  font: 500 14px var(--ui); letter-spacing: .4px; padding: 10px 16px; min-height: 42px; border-radius: 2px;
  box-shadow: 0 1px 0 #fff6 inset, 2px 3px 0 #2f2a2122; transition: transform .15s, box-shadow .15s, background .2s;
}
.ink-button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 1px 0 #fff6 inset, 3px 5px 0 #2f2a2122; }
.ink-button:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 #fff6 inset, 1px 1px 0 #2f2a2122; }
.ink-button.wide { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.ink-button.pale { background: #f8eed6; color: #3e2f20; border-color: #5b4833; }
.ink-button.big { font-size: 16px; padding: 14px 30px; min-height: 52px; }
.ink-button.ready { animation: ready 2.4s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 1px 0 #fff6 inset, 2px 3px 0 #2f2a2122, 0 0 0 5px #93402b22; } }
.quiet, .text-button { border: 0; background: none; padding: 6px 2px; font: 500 14px var(--ui); color: var(--ink-soft); }
.quiet:hover, .text-button:hover { color: var(--red); }
.quiet[aria-pressed=true] { color: var(--red); }
.ring { display: inline-grid; place-items: center; width: 19px; height: 19px; border: 1px solid var(--line); border-radius: 50%; font-size: 11px; margin-left: 4px; }
.text-button { font-size: 13px; color: var(--muted); }

/* ——— Full-screen stage ——— */
html, body { height: 100%; overflow: hidden; background: #140e09; }
.stage {
  position: fixed; inset: 0; width: 100vw; height: 100svh; overflow: hidden; overflow: clip; isolation: isolate; background: #140e09;
  cursor: crosshair; touch-action: manipulation; user-select: none; -webkit-user-select: none; outline: none;
}
.stage:focus-visible { outline: none; }

/* ——— In-scene HUD ——— */
.hud-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 12; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  padding: max(12px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 26px max(18px, env(safe-area-inset-left));
  background: linear-gradient(#120b06d9, #120b0688 55%, #120b0600); color: #f6ead0; pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hud-brand .seal { width: 30px; height: 30px; color: #e0845f; filter: drop-shadow(0 1px 2px #0008); }
.hud-brand { text-decoration: none; }
.hud-brand b { display: block; font: 600 16px/1.1 var(--narrator); letter-spacing: 1px; }
.hud-scene { display: block; font: 400 15px/1.2 var(--display); color: #f0e0bd; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-scene i { color: #cdb58c; margin-left: 10px; }
.hud-scene i::before { content: "·"; margin-right: 10px; font-style: normal; }
.pips { display: flex; align-items: center; gap: 14px; margin: 0; padding: 7px 14px; list-style: none; background: #120b0666; border: 1px solid #f6ead01f; border-radius: 30px; backdrop-filter: blur(3px); }
.pips .act { display: flex; align-items: center; gap: 6px; opacity: .55; transition: opacity .4s; }
.pips .act.current { opacity: 1; }
.pips .act.visited { opacity: .8; }
.pips .numeral { font: 400 13px var(--display); color: #e8d6b2; margin-right: 2px; min-width: 14px; text-align: center; }
.pips .act.current .numeral { color: #ffb48f; }
.pips li li { width: 8px; height: 8px; transform: rotate(45deg); border: 1px solid #d9c8a6aa; transition: background .5s, border-color .5s, box-shadow .5s; list-style: none; }
.pips ol { display: flex; gap: 6px; padding: 0; margin: 0; }
.pips li li.memory { border-radius: 50%; }
.pips li li.done { background: #e0845f; border-color: #e0845f; }
.pips li li.now { border-color: #ffc9a8; box-shadow: 0 0 0 3px #e0845f44; animation: pip 1.8s ease-in-out infinite; }
@keyframes pip { 50% { box-shadow: 0 0 0 6px #e0845f11; } }
.hud-actions { display: flex; justify-content: flex-end; gap: 6px; }
.hud-icon { position: relative; width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid #f6ead02b; background: #120b0666; color: #f6ead0; border-radius: 50%; backdrop-filter: blur(3px); transition: background .2s, border-color .2s; }
.hud-icon:hover { background: #f6ead022; border-color: #f6ead066; }
.hud-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hud-icon[aria-pressed=false] .wave, .hud-icon[aria-pressed=true] .mute { display: none; }
.hud-icon[aria-pressed=true] { color: #ffc9a8; }
.hud-icon::after { content: attr(aria-label); position: absolute; top: calc(100% + 8px); right: 0; white-space: nowrap; font: 500 13px var(--ui); color: var(--ink); background: var(--sheet); padding: 4px 9px; border-radius: 2px; box-shadow: 0 4px 12px #0005; opacity: 0; transform: translateY(-3px); pointer-events: none; transition: .18s; }
.hud-icon:hover::after, .hud-icon:focus-visible::after { opacity: 1; transform: none; }

.hud-objective {
  position: absolute; z-index: 11; left: max(18px, env(safe-area-inset-left)); top: 82px; width: min(330px, calc(100vw - 36px));
  padding: 14px 18px 14px; background: #f6eedbf0; color: var(--ink); border: 1px solid #d8c7a2; box-shadow: 0 16px 34px -14px #000b, 3px 3px 0 #0000001a;
  transition: opacity .45s, transform .45s; pointer-events: auto; cursor: default;
}
.hud-objective::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--red); }
.hud-objective h2 { font: 400 23px/1.1 var(--display); margin: 7px 0 5px; }
.hud-objective p { font: 15px/1.45 var(--body); color: #5d5444; margin: 0; }
.hud-objective.fresh { animation: objective-in .7s cubic-bezier(.2, .9, .3, 1) both; }
@keyframes objective-in { from { opacity: 0; transform: translateX(-14px); } }
body[data-mode=encounter] .hud-objective, body[data-mode=ending] .hud-objective, body[data-mode=transition] .hud-objective { opacity: 0; transform: translateX(-12px); pointer-events: none; }
.satchel { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); margin-top: 11px; padding-top: 10px; }
.satchel .eyebrow { font-size: 9px; flex: none; }
#inventory { display: flex; flex-wrap: wrap; gap: 5px; }
.inventory-empty { font: italic 14px var(--display); color: var(--muted); }
.chip { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 1px solid var(--line); background: #fbf6e9; border-radius: 50%; animation: chip-in .6s cubic-bezier(.2, 1.4, .4, 1) both; position: relative; }
.chip svg { width: 16px; height: 16px; color: var(--red); }
.chip::after { content: attr(aria-label); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; font: 12px var(--ui); background: var(--ink); color: var(--sheet); padding: 3px 8px; opacity: 0; pointer-events: none; transition: .15s; }
.chip:hover::after { opacity: 1; }
@keyframes chip-in { from { opacity: 0; transform: translateY(6px) scale(.8); } }

.hud-hint { position: absolute; z-index: 11; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); white-space: nowrap; font: 14px var(--ui); color: #f6ead0; background: #120b0699; border: 1px solid #f6ead022; padding: 7px 14px; border-radius: 30px; backdrop-filter: blur(3px); transition: opacity .8s; pointer-events: none; }
.hud-hint i { font-style: normal; margin: 0 7px; opacity: .6; }
.hud-hint kbd { background: #f6ead0; color: var(--ink); border-color: #f6ead0; }
.hud-hint.gone, body:not([data-mode=play]) .hud-hint { opacity: 0; }

/* The table: papers laid into the scene, on whichever side keeps the people in view. */
.table-panel {
  position: absolute; z-index: 10; top: 76px; max-height: calc(100% - 76px - var(--ctrl-room)); width: clamp(300px, 27vw, 410px); display: flex; flex-direction: column;
  background: #f5ecd6f5; color: var(--ink); border: 1px solid #d3c19b; box-shadow: 0 24px 50px -16px #000c, 0 0 0 5px #3a2a1a33;
  transition: transform .5s cubic-bezier(.2, .9, .3, 1), opacity .4s; pointer-events: auto; cursor: default;
}
.table-panel[data-side=right] { right: max(18px, env(safe-area-inset-right)); animation: table-in-right .55s cubic-bezier(.2, .9, .3, 1) both; }
.table-panel[data-side=left] { left: max(18px, env(safe-area-inset-left)); animation: table-in-left .55s cubic-bezier(.2, .9, .3, 1) both; }
@keyframes table-in-right { from { opacity: 0; transform: translateX(30px) rotate(1deg); } }
@keyframes table-in-left { from { opacity: 0; transform: translateX(-30px) rotate(-1deg); } }
.table-head { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); cursor: default; }
.table-head h2 { font: 400 25px/1.08 var(--display); margin: 6px 0 4px; }
.table-count { font: italic 14px var(--display); color: var(--muted); }
.table-count .eyebrow, .table-count [data-ui] { font: italic 14px var(--display); letter-spacing: 0; text-transform: none; }
.table-body { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 4px 20px 18px; scrollbar-width: thin; }
.documents { display: grid; gap: 14px; margin: 12px 0 4px; perspective: 900px; }
.interaction-controls:empty { display: none; }
.interaction-controls { margin: 12px 0 0; font: 15px var(--ui); color: var(--muted); }

.world { position: absolute; left: 0; top: 0; width: 1536px; height: 1024px; transform-origin: 0 0; will-change: transform; }
.backdrop { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.lights { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: screen; opacity: .55; pointer-events: none; }
.lights polygon { fill: url(#shaft-grad); animation: shaft 9s ease-in-out infinite alternate; }
.lights polygon:nth-child(3) { animation-duration: 12s; animation-delay: -3s; }
.lights polygon:nth-child(4) { animation-duration: 7s; animation-delay: -5s; }
@keyframes shaft { from { opacity: var(--o); } to { opacity: calc(var(--o) * .55); } }
.candles > div { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); mix-blend-mode: screen; pointer-events: none;
  background: radial-gradient(circle, #ffc56eaa 0, #ff9d3a44 22%, #ff8a2a14 48%, transparent 70%); }
.beam { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: screen; pointer-events: none; opacity: 0; transition: opacity 1.4s; }
.beam #beam-shape { filter: hue-rotate(-25deg); }
.beam.on { opacity: .55; animation: beam 4.5s ease-in-out infinite; }
@keyframes beam { 50% { opacity: .36; } }
.stone-glow { position: absolute; width: 170px; height: 170px; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; mix-blend-mode: screen; opacity: 0; transition: opacity 1.2s;
  background: radial-gradient(circle, #caa2ffcc 0, #8e5ee066 22%, #5a2fb022 45%, transparent 70%); }
.stone-glow.on { opacity: 1; animation: stone 3.2s ease-in-out infinite; }
@keyframes stone { 50% { transform: translate(-50%, -50%) scale(1.18); opacity: .7; } }
/* The first time: the stone answers a voice before anyone knows it can. */
.stone-glow.stirring { opacity: .95; transition: opacity 2.8s ease-in; animation: stir 1.7s ease-in-out infinite; }
@keyframes stir { 0%, 100% { transform: translate(-50%, -50%) scale(.9); filter: saturate(1.5) brightness(1.1); } 45% { transform: translate(-50%, -50%) scale(1.45); filter: saturate(1.8) brightness(1.3); } }

/* The discovery on the riverbank: page → prism → stone. */
.sunpath { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.sunpath .rays, .sunpath .glyphs { opacity: 0; transition: opacity 1.8s ease; }
.sunpath .rays { mix-blend-mode: screen; }
.sunpath.on .rays { opacity: 1; animation: rays 5s ease-in-out infinite; }
.sunpath.on .glyphs { opacity: 1; }
@keyframes rays { 50% { opacity: .72; } }
.sunpath .glyphs text { font-family: var(--collector); font-style: italic; fill: #4a2f17; paint-order: stroke; stroke: #fff4d6; stroke-width: 3px; stroke-opacity: .55; }
.sunpath .glyphs text.bent { font-family: var(--echo); font-style: normal; fill: #efe2ff; stroke: #9a63ff; stroke-width: 2.5px; stroke-opacity: .5; }
.sunpath .prism .spark { opacity: 0; transition: opacity 1.2s; }
.sunpath.on .prism .spark { opacity: .9; animation: rays 2.4s ease-in-out infinite; }

.catch-target { position: absolute; z-index: 2; border: 2px dashed #e7d6ffcc; border-radius: 3px; background: radial-gradient(ellipse, #c9a2ff38, #c9a2ff10 70%); cursor: pointer; box-shadow: 0 0 0 4px #9a63ff22, 0 0 28px #b58cff88; animation: catch 1.8s ease-in-out infinite; padding: 0; }
.catch-target:hover, .catch-target:focus-visible { background: radial-gradient(ellipse, #d9c0ff66, #c9a2ff20 70%); outline: none; }
.catch-target .catch-label { position: absolute; left: 50%; top: calc(100% + 12px); transform: translateX(-50%); font: italic 500 16px var(--display); color: #fff7e2; background: #2b2016e6; padding: 4px 12px 5px; border-radius: 2px; white-space: nowrap; box-shadow: 0 2px 10px #0006, 0 0 14px #9a63ff66; }
@keyframes catch { 50% { box-shadow: 0 0 0 9px #9a63ff14, 0 0 44px #b58cffcc; } }
.linen { position: absolute; display: grid; place-items: center; pointer-events: none; }
.linen p {
  margin: 0; text-align: center; white-space: pre-line; color: var(--echo-ink); font: 400 26px/1.24 var(--echo); letter-spacing: .6px;
  text-shadow: 0 0 1px #fff, 0 0 7px #d6e3ffee, 0 0 20px #7fa3ffaa;
}
.linen p .ghost { opacity: 0; }
.linen p .lit { animation: glyph .5s ease-out both; }
@keyframes glyph { from { opacity: 0; filter: blur(3px); } }
.linen-strike { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.linen-strike path { fill: none; stroke: #7d1f14; stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-dasharray: 400; stroke-dashoffset: 400; animation: draw .9s ease forwards; }
.linen.lit::after { content: ""; position: absolute; inset: -12%; background: radial-gradient(ellipse, #b9ccff40, transparent 70%); mix-blend-mode: screen; }
.actors { position: absolute; inset: 0; }
.actor { position: absolute; transform: translate(-50%, -100%); pointer-events: none; }
.actor .shadow { position: absolute; left: 50%; bottom: -1.5%; width: 64%; height: 4.4%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse, #1a0e06aa, #1a0e0600 70%); }
.actor .figure { position: absolute; inset: 0; transform-origin: 50% 100%; }
.actor .sprite { position: absolute; inset: 0; background: var(--atlas, url('../assets/game/characters-v1.png')) no-repeat; background-size: 300% 100%; background-position: var(--col, 0%) 0; }
/* Figures drawn with a wider margin are scaled about their soles and set down on Chapter I's ground line. */
.actor .figure-inner { transform-origin: 50% var(--foot, 96.8%); transform: translateY(calc(var(--ground, 96.8%) - var(--foot, 96.8%))) scale(var(--scale, 1)); }
.actor .upper { clip-path: inset(0 0 calc(100% - var(--hip) - .6%) 0); transform-origin: 50% var(--hip); }
.actor .lower { clip-path: inset(var(--hip) 0 0 0); transform-origin: 50% var(--hip); }
.actor .figure-inner { position: absolute; inset: 0; filter: drop-shadow(0 0 1px #1c120a88); }
.motes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; mix-blend-mode: screen; }

/* Stage grade: a light vignette everywhere. Memories are painted as finely as the present. */
.grade { position: absolute; inset: 0; pointer-events: none; z-index: 2; box-shadow: inset 0 0 90px #1b0f0655, inset 0 0 22px #1b0f0644; transition: background 1.2s; }
.stage[data-scene=printshop] .grade { box-shadow: inset 0 0 120px #05081488, inset 0 0 30px #05081455; }
.stage[data-scene=attic-night] .grade { box-shadow: inset 0 0 140px #030818aa, inset 0 0 34px #03081866; }
.stage[data-scene=linz] .grade { box-shadow: inset 0 0 110px #1b0f0670, inset 0 0 26px #1b0f0655; }

/* The new star of 1604, lit where the painted sky was left bare. */
.new-star { position: absolute; width: 0; height: 0; pointer-events: none; z-index: 1; }
.new-star i { position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; border-radius: 50%; mix-blend-mode: screen;
  background: radial-gradient(circle, #fffef6 0 16%, #fff1c2cc 30%, #ffe08a40 56%, transparent 72%); animation: twinkle 2.8s ease-in-out infinite; }
.new-star i::before, .new-star i::after { content: ""; position: absolute; left: 50%; top: 50%; width: 52px; height: 1.6px; transform: translate(-50%, -50%); background: linear-gradient(90deg, transparent, #fff6d6, transparent); }
.new-star i::after { transform: translate(-50%, -50%) rotate(90deg); }
.new-star.spotted i { animation: twinkle 2.8s ease-in-out infinite, flare 1.6s ease-out; }
@keyframes twinkle { 50% { transform: scale(.82); opacity: .82; } }
@keyframes flare { 30% { transform: scale(2.4); filter: brightness(1.6); } }
.catch-target[data-target=star] { border-radius: 50%; }
.catch-target[data-target=star] .catch-label, .catch-target[data-target=prism] .catch-label { top: calc(100% + 8px); }

/* ——— Overlay: markers, bubbles, captions ——— */
.overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: clip; }
.overlay button, .overlay .speech-bubble { pointer-events: auto; }
.marker { position: absolute; transform: translate(-50%, -50%); border: 0; background: none; padding: 0; display: grid; justify-items: center; gap: 4px; }
.marker .seal-mark { width: 30px; height: 30px; color: #fff3cf; filter: drop-shadow(0 0 6px #ffd98a) drop-shadow(0 1px 1px #3b2410); animation: mark 2.2s ease-in-out infinite; }
.marker .seal-mark svg { animation: spin 18s linear infinite; }
@keyframes mark { 50% { transform: scale(1.14); filter: drop-shadow(0 0 12px #ffd98a) drop-shadow(0 1px 1px #3b2410); } }
@keyframes spin { to { transform: rotate(360deg); } }
.marker .mark-label { font: italic 500 14px var(--display); color: #fff7e2; background: #2b2016d9; padding: 3px 10px 4px; border-radius: 2px; white-space: nowrap; box-shadow: 0 2px 8px #0005; }
.marker .mark-key { position: absolute; top: -30px; font: 600 11px var(--ui); background: var(--sheet); color: var(--ink); border: 1px solid var(--ink); border-bottom-width: 2px; border-radius: 3px; padding: 1px 6px; opacity: 0; transform: translateY(6px); transition: .25s; }
.marker.near .mark-key { opacity: 1; transform: none; }
.destination { position: absolute; width: 34px; height: 12px; transform: translate(-50%, -50%); border: 2px solid #fff4d0; border-radius: 50%; box-shadow: 0 0 8px #ffe2a2; animation: dest .9s ease-out infinite; }
@keyframes dest { from { opacity: 1; transform: translate(-50%, -50%) scale(.6); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.3); } }
.edge-arrow { position: absolute; z-index: 2; font-size: 22px; color: #fff4d0; text-shadow: 0 0 8px #000, 0 0 12px #ffd98a; }
.edge-arrow span { display: block; animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { translate: 5px 0; } }
.caption {
  position: absolute; left: 50%; top: 84px; transform: translateX(-50%); width: max-content; max-width: min(560px, 80%); padding: 13px 20px 14px; pointer-events: auto;
  background: #f4e5bd; color: #3a2d1f; border: 1.5px solid #3a2d1f; box-shadow: 4px 4px 0 #2a1c0f55; animation: caption-in .5s ease both;
}
.caption p { margin: 0; font: italic 19px/1.4 var(--display); }
/* When the Echo answers, its words are read out above the scene in its own even inscription. */
.caption .caption-label { display: none; }
.caption.echo { background: linear-gradient(160deg, #eef2fdf6, #dde5f9f6); border-color: #45549a; color: var(--echo-ink); text-align: center; box-shadow: 0 0 34px -4px #7fa3ffaa, 4px 4px 0 #1d2a5a44; min-width: min(300px, 80%); }
.caption.echo .caption-label { display: block; font: 600 10px var(--ui); letter-spacing: 2.4px; text-transform: uppercase; color: #6b7db0; margin-bottom: 6px; }
.caption.echo p { font: 300 22px/1.65 var(--echo-zh); letter-spacing: 1.5px; text-shadow: 0 0 10px #c3d3ff; }
.caption.echo { max-width: min(600px, 86%); }
/* The narrator, the cards and the heading speak Chinese, in the Song face. */
.caption:not(.echo) p { font: 400 18px/1.8 var(--narrator); letter-spacing: .6px; }
.hud-scene { font: 400 15px/1.2 var(--narrator); letter-spacing: 1px; }
.hud-scene i { font-style: normal; }
.curtain-card p { font: 400 13px var(--narrator); letter-spacing: 4px; }
.curtain-card h2 { font: 600 clamp(30px, 4vw, 48px)/1.2 var(--narrator); letter-spacing: 6px; }
.curtain-card small { font: 400 19px var(--narrator); font-style: normal; letter-spacing: 2px; }
.caption.echo .ghost { opacity: 0; }
@keyframes caption-in { from { opacity: 0; translate: 0 -6px; } }

.speech-bubble { position: absolute; left: 0; top: 0; z-index: 3; color: #2f261c; cursor: default; transition: opacity .25s; }
.speech-bubble.enter { animation: bubble-in .32s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(10px) scale(.94); } }
.bubble-art { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.bubble-art [data-bubble-outline], .bubble-tail-fill { fill: #fbf3dd; }
.bubble-art [data-bubble-outline], .bubble-tail-ink { stroke: #33271b; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.bubble-tail-ink { fill: none; }
.bubble-shadow { fill: #1d120833; transform: translate(4px, 5px); }
.bubble-echo { fill: none; stroke: #33271b; stroke-width: .8; opacity: .45; transform: translate(1.5px, 1px); }
.bubble-copy { position: relative; }
.speaker-name { display: block; font: 600 10.5px var(--ui); letter-spacing: 2px; text-transform: uppercase; color: #8a4a31; margin-bottom: 6px; }
.dialogue-words { margin: 0; font: 400 23px/1.55 var(--speech); overflow-wrap: anywhere; min-height: 1.55em; text-wrap: pretty; }
.dialogue-words .ghost { opacity: 0; }
.dialogue-counter { display: block; text-align: right; font: 500 10px var(--ui); color: #9a8769; margin-top: 4px; letter-spacing: 1px; }
.speech-bubble[data-shape=cloud] .speaker-name, .speech-bubble[data-shape=cloud] .dialogue-counter { text-align: center; }
.speech-bubble[data-shape=cloud] .dialogue-words { text-align: center; }

:root { --ctrl: 80px; --ctrl-gap: 18px; --ctrl-room: calc(var(--ctrl) + var(--ctrl-gap) * 2 + 12px); }
/* Put aside / previous always sit in the bottom-left corner, the action always in the bottom-right. */
.conversation-controls { position: absolute; z-index: 12; left: max(var(--ctrl-gap), env(safe-area-inset-left)); right: max(var(--ctrl-gap), env(safe-area-inset-right)); bottom: max(var(--ctrl-gap), env(safe-area-inset-bottom)); display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; pointer-events: none; }
.conversation-controls button { pointer-events: auto; }
/* Chinese action labels can run long: wrap inside the corner rather than reach across to the back buttons. */
.conversation-controls .ink-button { min-height: var(--ctrl); padding: 8px 40px; font-size: 28px; line-height: 1.15; letter-spacing: .6px; border-width: 2px; box-shadow: 0 1px 0 #fff6 inset, 4px 6px 0 #1a0f0540; max-width: min(560px, calc(100% - var(--ctrl) * 2 - 40px)); text-align: center; text-wrap: balance; }
.conversation-back { display: flex; gap: 12px; }
.conversation-back button { width: var(--ctrl); height: var(--ctrl); border: 2px solid #5b4833; background: #f8eed6; color: #3e2f20; font: 40px/1 var(--display); border-radius: 3px; box-shadow: 4px 6px 0 #1a0f0540; transition: transform .15s, box-shadow .15s; }
.conversation-back button:hover { transform: translateY(-2px); box-shadow: 5px 8px 0 #1a0f0540; }
.conversation-back button:active, .conversation-controls .ink-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 2px 2px 0 #1a0f0540; }
#action-hint { align-self: center; }
#action-hint { font: italic 14px var(--display); color: #fff5dd; text-shadow: 0 1px 6px #000, 0 0 2px #000; text-align: center; }
.stage.conversing { cursor: pointer; }

.finale { position: absolute; z-index: 9; inset: 0; display: grid; place-content: start start; padding: 7% 0 0 6%; text-align: left; gap: 6px; background: radial-gradient(ellipse 70% 60% at 12% 10%, #0b0704cc, #0b070400 70%), radial-gradient(ellipse at 60% 45%, transparent 45%, #0b070477 100%); color: #f7ecd2; pointer-events: none; }
.finale p { margin: 0; font: italic 400 clamp(26px, 4vw, 48px)/1.2 var(--display); opacity: 0; animation: finale 1.6s ease forwards; text-shadow: 0 2px 18px #000; }
.finale p:first-child { font: 400 clamp(26px, 3.6vw, 46px)/1.2 var(--echo); letter-spacing: 1.5px; color: #dfe8ff; text-shadow: 0 0 18px #7fa3ffcc, 0 2px 18px #000; }
.finale p + p { animation-delay: 2.2s; font: 400 clamp(38px, 5.4vw, 70px)/1.1 var(--marta); color: #ffd9a6; }
@keyframes finale { from { opacity: 0; transform: translateY(8px); letter-spacing: 3px; } to { opacity: 1; } }

/* Chapter II's last frame: Linz on the left, a Prague library on the right. */
.split { position: absolute; z-index: 8; top: 0; right: 0; bottom: 0; width: 50%; overflow: hidden; pointer-events: none;
  clip-path: polygon(3% 0, 100% 0, 100% 100%, 0 100%, 2% 64%, .4% 33%); box-shadow: -20px 0 40px #0009; animation: split-in 2.2s cubic-bezier(.3, .1, .2, 1) both; }
.split img { width: 100%; height: 100%; object-fit: cover; display: block; }
@keyframes split-in { from { transform: translateX(100%); } }
body[data-chapter="2"] .finale { grid-template-columns: 1fr 1fr; place-content: end stretch; padding: 0 3% 8%; gap: 0; background: linear-gradient(#0b070400 50%, #0b0704c8 100%); }
body[data-chapter="2"] .finale p { text-align: center; font: italic 400 clamp(26px, 3.4vw, 44px)/1.2 var(--display); color: #f7ecd2; letter-spacing: 0; }
body[data-chapter="2"] .finale p:first-child { color: #ffe3b0; text-shadow: 0 2px 18px #000; }

/* Interludes: the years between, told over a painting. */
.interlude { position: absolute; inset: 0; z-index: 22; overflow: hidden; background: #0d0905; cursor: pointer; transition: opacity .7s; }
.interlude.out { opacity: 0; }
.interlude-frame { position: absolute; left: 0; top: 0; width: 1536px; height: 1024px; transform-origin: 0 0; will-change: transform; transition: opacity .7s; }
.interlude-frame.changing { opacity: 0; transition: opacity .6s; }
.interlude-frame img { display: block; width: 100%; height: 100%; }
.interlude::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 85% 70% at 50% 42%, transparent 40%, #0b0704aa 100%), linear-gradient(#0b070400 52%, #0b0704d9 100%); }
.interlude-star { position: absolute; width: 0; height: 0; }
.interlude-star::before { content: ""; position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; mix-blend-mode: screen; background: radial-gradient(circle, #fffef6 0 16%, #fff1c2cc 30%, #ffe08a40 56%, transparent 72%); animation: twinkle 2.8s ease-in-out infinite, star-born 4s ease-out both; }
@keyframes star-born { from { opacity: 0; transform: scale(.2); } }
.interlude-text { position: absolute; z-index: 2; left: 50%; bottom: 12%; transform: translateX(-50%); width: min(760px, calc(100% - 40px)); text-align: center; }
.interlude-line { margin: 0; font: italic 400 clamp(19px, 2vw, 26px)/1.48 var(--display); color: #f7ecd2; text-shadow: 0 2px 14px #000, 0 0 3px #000; opacity: 0; }
.interlude-line.in { animation: interlude-in 1.1s ease both; }
.interlude-line span { display: block; text-wrap: balance; }
.caption p { text-wrap: balance; }
.interlude-line[data-kind=title] span:first-child { font: 400 clamp(40px, 6vw, 76px)/1 var(--display); font-style: normal; letter-spacing: 2px; }
.interlude-line[data-kind=title] span:nth-child(2) { font: 400 clamp(16px, 1.7vw, 21px) var(--caps); letter-spacing: 4px; margin-top: 12px; color: #e8d6b2; font-style: normal; }
.interlude-line[data-kind=title] span:last-child { margin-top: 16px; color: #e3d2ab; }
@keyframes interlude-in { from { opacity: 0; transform: translateY(10px); filter: blur(2px); } to { opacity: 1; } }
body[data-chapter="2"] .interlude-line { font: 400 clamp(18px, 1.9vw, 24px)/1.85 var(--narrator); letter-spacing: 1px; }
body[data-chapter="2"] .interlude-line[data-kind=title] span:first-child { font: 600 clamp(44px, 6vw, 80px)/1.1 var(--narrator); letter-spacing: .32em; text-indent: .32em; }
body[data-chapter="2"] .interlude-line[data-kind=title] span:nth-child(2) { font: 400 clamp(17px, 1.8vw, 22px) var(--narrator); letter-spacing: .3em; margin-top: 14px; }
body[data-chapter="2"] .interlude-line[data-kind=title] span:last-child { font-size: clamp(16px, 1.7vw, 20px); }
.interlude-hint { position: absolute; z-index: 2; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); font: 13px var(--ui); color: #cdb58cbb; white-space: nowrap; }
.interlude-skip { position: absolute; z-index: 3; top: max(16px, env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); color: #e8d6b2; font-size: 15px; }
.interlude-skip:hover { color: #fff; }

/* Ink-bleed scene transition. */
.curtain { position: absolute; inset: 0; z-index: 20; pointer-events: none; display: grid; place-items: center; }
.curtain.active { pointer-events: auto; }
.curtain-ink { position: absolute; inset: -12%; width: 124%; height: 124%; }
.curtain-ink circle { fill: #1c140d; }
.curtain-card { position: relative; text-align: center; color: #f3e6c6; opacity: 0; transform: translateY(8px); transition: opacity .6s, transform .6s; }
.curtain.show-card .curtain-card { opacity: 1; transform: none; }
.curtain-card .seal { width: 40px; height: 40px; color: #d18a5d; margin-bottom: 10px; }
.curtain-card p { margin: 0 0 8px; font: 600 11px var(--ui); letter-spacing: 3px; color: #cdb58c; }
.curtain-card h2 { margin: 0; font: 400 clamp(28px, 4vw, 50px)/1.1 var(--display); }
.curtain-card small { display: block; margin-top: 10px; font: italic 18px var(--display); color: #d9c49d; }
.asset-error { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 30; background: var(--sheet); padding: 12px 16px; border: 1px solid var(--ink); }

.touch-controls { display: none; }

/* ——— Papers ——— */
.doc {
  position: relative; padding: 16px 18px 18px; background: #fbf5e4; color: #2e271e; border: 1px solid #d8c9a8;
  box-shadow: 0 1px 0 #fff inset, 0 8px 16px -10px #3b2a1688, 1px 2px 0 #e7dcc3; transform: rotate(var(--tilt, 0deg));
  animation: paper-in .6s cubic-bezier(.2, .9, .3, 1) both; animation-delay: var(--delay, 0s);
}
.doc::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 30% 20%, #fff8, transparent 50%), radial-gradient(ellipse at 90% 100%, #b99b6522, transparent 60%); }
@keyframes paper-in { from { opacity: 0; transform: translateY(18px) rotate(calc(var(--tilt, 0deg) + 3deg)) rotateX(8deg); } }
.doc-label { display: block; font: 600 10px var(--ui); letter-spacing: 2px; text-transform: uppercase; color: #9a8866; margin-bottom: 10px; }
.doc-text { margin: 0; white-space: pre-line; font: italic 18px/1.45 var(--display); }
.doc .line { display: block; }
.doc[data-kind=playbill] { text-align: center; padding: 18px 16px 16px; background: #f8f1dc; border-color: #cfbe98; }
.doc[data-kind=playbill] .frame { border: 1px solid #3d3326; outline: 3px double #3d3326; outline-offset: 3px; padding: 14px 10px; margin: 4px; }
.doc[data-kind=playbill] .doc-text { font: 400 16px/1.35 var(--display); }
.doc[data-kind=playbill] .venue { font: 400 15px var(--caps); letter-spacing: 2.5px; }
.doc[data-kind=playbill] .title { font: 400 25px/1.1 var(--display); margin: 10px 0 2px; }
.doc[data-kind=playbill] .title + .line { font-style: italic; margin-bottom: 10px; }
.doc[data-kind=playbill] .venue + .line { margin-top: 3px; }
.documents.pair .doc[data-kind=playbill] { padding: 10px 10px 10px; }
.documents.pair .doc[data-kind=playbill] .frame { padding: 8px 8px; }
.documents.pair .doc[data-kind=playbill] .doc-text { font-size: 14px; line-height: 1.25; }
.documents.pair .doc[data-kind=playbill] .title { font-size: 20px; margin: 5px 0 1px; }
.documents.pair .doc[data-kind=playbill] .rule { margin: 4px auto; }
.doc[data-kind=playbill] .imprint { font: 400 11px var(--caps); letter-spacing: 2px; margin-top: 12px; color: #6b5d48; }
.doc[data-kind=playbill] .rule { display: block; height: 9px; margin: 8px auto; width: 60%; background: radial-gradient(circle, #3d3326 0 2px, transparent 2.5px) center / 9px 9px no-repeat, linear-gradient(#3d3326, #3d3326) left center / 42% 1px no-repeat, linear-gradient(#3d3326, #3d3326) right center / 42% 1px no-repeat; }
.doc[data-voice=echo] { background: linear-gradient(160deg, #eef2fd, #e1e8fa); border-color: #b7c5ec; color: var(--echo-ink); text-align: center; box-shadow: 0 0 24px -6px #7fa3ff66, 0 8px 16px -10px #1d2a5a88; }
.doc[data-voice=echo] .doc-label { color: #6b7db0; }
.doc[data-voice=echo] .doc-text { font: 400 20px/1.45 var(--echo); letter-spacing: .5px; text-shadow: 0 0 10px #a9c2ffaa; }
/* Marta's own hand: chancery italic in iron-gall ink. */
.doc[data-voice=marta] .doc-text { font: 400 29px/1.2 var(--marta); color: var(--marta-ink); }
.doc[data-voice=marta][data-kind=work-note] .doc-text { font-size: 26px; line-height: 1.3; }
/* The Collector's book hand. */
.doc[data-voice=collector] .doc-text { font: italic 18px/1.45 var(--collector); color: var(--collector-ink); }
.doc[data-kind=note] { background: #f8f0da; padding-top: 22px; }
.doc[data-kind=note] .wax { position: absolute; right: 14px; top: -12px; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: #f0c9a8;
  background: radial-gradient(circle at 38% 34%, #c2553c, #8f2a19 60%, #6e1d10); box-shadow: 0 3px 6px #5d1a0e66, inset 0 -3px 5px #0003; }
.doc[data-kind=note] .wax svg { width: 30px; height: 30px; opacity: .8; }
.doc[data-kind=note].folded { cursor: pointer; }
.doc[data-kind=note].folded .doc-text { clip-path: inset(0 0 100% 0); max-height: 0; opacity: 0; }
.doc[data-kind=note] .doc-text { transition: clip-path .9s ease, max-height .9s ease, opacity .6s; max-height: 12em; clip-path: inset(0 0 0 0); }
.doc[data-kind=note] .unfold-hint { font: italic 15px var(--display); color: var(--muted); }
.doc[data-kind=note]:not(.folded) .unfold-hint { display: none; }
.doc[data-kind=letter] { background: repeating-linear-gradient(#fbf5e4 0 26px, #e8dcc0 26px 27px); }
.doc[data-kind=letter]::before { content: ""; position: absolute; left: 0; right: 0; top: 33%; border-top: 1px solid #d9caa9; box-shadow: 0 1px 0 #fff; }
.doc[data-kind=diagram] svg { display: block; width: 100%; height: 92px; margin-top: 8px; color: #5d4a33; }
.doc[data-kind=shop-label] { width: 78%; justify-self: center; text-align: center; border-radius: 4px 4px 4px 4px; background: #efe0bd; border-color: #bda172; }
.doc[data-kind=shop-label]::before { content: ""; position: absolute; left: 50%; top: 8px; width: 9px; height: 9px; margin-left: -4px; border-radius: 50%; background: var(--sheet); border: 1px solid #a28858; }
.doc[data-kind=shop-label] .doc-label { margin-top: 10px; }
.doc[data-kind=schedule] .doc-text { font: 400 19px/1.3 var(--display); }
.doc[data-kind=work-note] .line { display: flex; gap: 10px; align-items: baseline; }
.doc[data-kind=work-note] .line::before { content: ""; flex: none; width: 12px; height: 12px; border: 1.3px solid #5d4a33; transform: translateY(1px) rotate(-2deg); }
.doc[data-kind=unfinished-copy] { min-height: 130px; background: repeating-linear-gradient(#fbf4e1 0 31px, #cfd8e4 31px 32px) 0 12px / 100% 100%; border-color: #d4c29c; }
.doc[data-kind=unfinished-copy] .doc-text { font: 400 32px/32px var(--marta); color: var(--marta-ink); min-height: 64px; padding-top: 4px; }
.doc[data-kind=unfinished-copy] .writing { display: inline; background: linear-gradient(90deg, #2a2014 50%, transparent 50%); }
.doc mark.echoed { background: none; color: inherit; box-shadow: inset 0 -.38em 0 #9fb7f055; transition: box-shadow 1.2s, color 1.2s; }
.doc mark.missed { background: none; color: #9b8e78; transition: color 1.2s; }
.documents.awaiting mark.echoed { box-shadow: none; }
.documents.awaiting mark.missed { color: inherit; }
/* River-soaked pages, still drying in the sun. */
.doc[data-damp]::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: inherit; mix-blend-mode: multiply; background: radial-gradient(ellipse 60% 38% at 78% 88%, transparent 62%, #9a7a4a2e 66%, #9a7a4a12 70%, transparent 74%), radial-gradient(ellipse 44% 30% at 12% 18%, transparent 58%, #8f6d3f24 63%, transparent 70%), linear-gradient(175deg, #00000000 60%, #7a5a2d14); }
/* Before the cloth is raised, the Echo has said nothing anyone can read. */
.doc.veiled .doc-text { opacity: 0; filter: blur(6px); }
.doc.veiled { box-shadow: 0 0 0 1px #b7c5ec, 0 0 26px -4px #9a63ff88; animation: veiled 2s ease-in-out infinite; }
.doc[data-voice=echo] .doc-text { transition: opacity 1.4s ease .4s, filter 1.4s ease .4s; }
@keyframes veiled { 50% { box-shadow: 0 0 0 1px #b7c5ec, 0 0 36px 0 #9a63ffaa; } }
.doc.crossed .doc-text { color: #5b6690; }

/* ——— Chapter II papers ——— */
.doc.pending { display: none; }
.doc[data-voice=kepler] .doc-text { font: italic 600 21px/1.35 var(--kepler); color: var(--kepler-ink); }
.doc[data-voice=tycho] { background: #f6edd4; }
.doc[data-voice=tycho] .doc-text { font: 400 17px/1.45 var(--collector); color: #3a2c1c; }
.doc .rows { display: grid; gap: 1px; white-space: normal; }
.doc .row { display: flex; gap: 10px; align-items: baseline; padding: 4px 6px; border-bottom: 1px dotted #cdbd9b; text-align: left; font: inherit; color: inherit; }
.doc .row .cell { flex: 1; min-width: 0; }
.doc .row .cell:first-child { flex: 1.25; }
.doc[data-kind=logbook] .row .cell:first-child:not(:only-child) { flex: 0 0 7.2em; font-style: italic; color: #7a6646; }
.doc .row.head { font: 600 10px/1.3 var(--ui); letter-spacing: 1.4px; text-transform: uppercase; color: #8a7a5e; border-bottom: 1px solid #b9a988; font-style: normal; }
.doc[data-voice=echo] .rows { text-align: left; }
.doc[data-voice=echo] .row:not(.head) { font: 400 16px/1.35 var(--echo); text-shadow: none; }
.doc[data-kind=figures][data-voice=kepler] .row:not(.head) { font: italic 600 18px/1.3 var(--kepler); }
button.row { all: unset; box-sizing: border-box; display: flex; gap: 10px; align-items: baseline; width: 100%; padding: 4px 6px; border-bottom: 1px dotted #cdbd9b; border-radius: 2px; cursor: pointer; transition: background .2s, box-shadow .2s; }
button.row:hover { background: #ffffff8c; }
button.row:focus-visible { outline: 2px solid var(--red); }
button.row[aria-pressed=true] { background: #f8ddd0; box-shadow: inset 4px 0 0 var(--red-ink); color: #7b2414; }
button.row[aria-pressed=true] .cell:last-child::after { content: " ✓"; color: var(--red-ink); font: 600 16px var(--ui); }
button.row.nope { animation: nope .4s ease; }
@keyframes nope { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
/* The stone's face: twenty sheets fit, and the twenty-first pushes out the first. */
.doc[data-kind=surface] .sheets { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 2px 0 12px; }
.doc[data-kind=surface] .sheets span { aspect-ratio: 3 / 4; display: grid; place-items: end center; padding-bottom: 2px; border: 1px solid #b9a988; background: #fffaf0; box-shadow: 1px 1px 0 #e1d5bb; font: 10px var(--ui); color: #8a7a5e; }
.doc[data-kind=surface] .sheets .faded { animation: sheet-fade 2.6s ease-in 1.2s both; }
.doc[data-kind=surface] .sheets .newest { border-color: #7c5fc0; background: #efe7ff; color: var(--violet); animation: sheet-new .9s ease-out .6s both; }
@keyframes sheet-fade { to { opacity: .12; filter: blur(1px); } }
@keyframes sheet-new { from { opacity: 0; transform: translateY(-8px) scale(1.2); } }
.doc[data-kind=surface] .doc-text { font: italic 17px/1.45 var(--display); color: #4a3f31; }
.doc[data-kind=orbit] svg { display: block; width: 100%; height: 118px; margin-top: 10px; color: #4e3f2c; }
.doc[data-kind=orbit] .sun { fill: #d9902b; stroke: #8c5a14; }
.doc[data-kind=orbit] .tycho circle { fill: var(--red-ink); }
.doc[data-kind=ledger] { background: repeating-linear-gradient(#fbf5e4 0 27px, #e2d6bb 27px 28px); }
.doc[data-kind=ledger] .doc-text { line-height: 28px; font-size: 19px; }
/* Ringing the eight minutes in ink. */
.mark-target { all: unset; position: relative; display: inline-block; cursor: pointer; padding: 0 5px; font-weight: 700; color: var(--red-ink); }
.mark-target svg { position: absolute; left: -38%; top: -42%; width: 176%; height: 184%; overflow: visible; pointer-events: none; }
.mark-target path { fill: none; stroke: #8c2414; stroke-width: 2.6; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 400; stroke-dashoffset: 400; }
.doc.marked .mark-target path { animation: draw 1s ease forwards; }
.mark-target:focus-visible { outline: 2px solid var(--red); }
.doc:not(.marked) .mark-target { animation: mark-wait 2s ease-in-out infinite; }
@keyframes mark-wait { 50% { text-shadow: 0 0 8px #e0845f; } }
/* Kepler's own pages: the carry slip, the figures worked by hand, the letter. */
.doc[data-kind=unfinished-copy][data-voice=kepler] { background: repeating-linear-gradient(#fbf4e1 0 29px, #d6dce6 29px 30px) 0 12px / 100% 100%; }
.doc[data-kind=unfinished-copy][data-voice=kepler] .doc-text { font: italic 600 22px/30px var(--kepler); color: var(--kepler-ink); min-height: 90px; }
.doc[data-kind=unfinished-copy][data-size=letter] { background: repeating-linear-gradient(#fbf4e1 0 23px, #dfe2e6 23px 24px) 0 12px / 100% 100%; }
.doc[data-kind=unfinished-copy][data-size=letter] .doc-text { font-size: 17px; line-height: 24px; min-height: 140px; }

/* Handwriting: each fragment is revealed like a nib travelling across the line. */
.hand { display: inline; white-space: pre-wrap; }
.hand .pen { clip-path: inset(0 100% 0 0); animation: nib var(--dur, 1s) steps(28, end) forwards; }
@keyframes nib { to { clip-path: inset(0 0 0 0); } }
.hand .pen-block { display: inline-block; }

/* Strike-through interaction. */
.strike-zone { position: relative; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.strike-zone svg { position: absolute; inset: -6px -4px; width: calc(100% + 8px); height: calc(100% + 12px); overflow: visible; pointer-events: none; }
.strike-zone path { fill: none; stroke: #8c2414; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.strike-zone path.clean { stroke-dasharray: 800; stroke-dashoffset: 800; animation: draw .7s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.strike-tip { font: italic 15px var(--display); color: var(--red); margin-top: 10px; display: flex; gap: 8px; align-items: center; }
.strike-tip::before { content: "✎"; font-style: normal; }
.correction-note { font: 400 28px/1.2 var(--marta); color: var(--red-ink); margin: 12px 0 0; transform: rotate(-1.2deg); animation: caption-in .5s ease both; }

/* Checking facts and stamping bills. */
.check-line { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 12px; width: 100%; padding: 4px 6px; margin: 2px -6px; border-radius: 2px; transition: background .2s; }
.check-line:hover { background: #efe3c6; }
.check-line:focus-visible { outline: 2px solid var(--red); }
.check-line .tick { flex: none; width: 22px; height: 22px; }
.check-line .tick path { fill: none; stroke: var(--red-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 40; stroke-dashoffset: 40; transition: stroke-dashoffset .45s ease; }
.check-line .tick circle { fill: none; stroke: #b9a988; stroke-width: 1.3; stroke-dasharray: 2 2.5; }
.check-line[aria-pressed=true] .tick path { stroke-dashoffset: 0; }
.check-line[aria-pressed=true] .tick circle { stroke: transparent; }
.doc.stampable { cursor: pointer; }
.doc.stampable:hover { transform: rotate(var(--tilt, 0deg)) translateY(-2px); }
.stamp { position: absolute; right: 12px; bottom: 16px; z-index: 2; padding: 5px 10px; border: 2.5px solid #a3301c; color: #a3301c; font: 400 15px var(--caps); letter-spacing: 2px; transform: rotate(-9deg) scale(1.8); opacity: 0; pointer-events: none; mix-blend-mode: multiply; filter: url(#ink-rough); transition: none; }
.doc[aria-pressed=true] .stamp { opacity: .88; transform: rotate(-9deg) scale(1); transition: transform .22s cubic-bezier(.5, 1.8, .6, 1), opacity .1s; }
.stamp-hint { font: italic 15px var(--display); color: var(--muted); text-align: center; margin: 6px 0 0; }
.progress-dots { display: flex; gap: 8px; align-items: center; font: italic 15px var(--display); }
.progress-dots b { font: 18px var(--ui); color: var(--red); letter-spacing: 3px; font-weight: 400; }

/* ——— Toast & dialogs ——— */
.toast { position: absolute; left: 50%; bottom: calc(var(--ctrl-room) + 4px); z-index: 30; transform: translate(-50%, 16px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--sheet); padding: 11px 18px; font: 15px var(--ui); box-shadow: 0 10px 30px #0004; transition: .3s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { width: min(560px, calc(100vw - 28px)); max-height: calc(100svh - 40px); border: 0; padding: 34px 34px 28px; background: var(--sheet); color: var(--ink); box-shadow: 0 30px 80px #000a; }
dialog::backdrop { background: #1a110acc; backdrop-filter: blur(2px); }
dialog[open] { animation: sheet-in .5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) rotate(-1.5deg); } }
.close-button { position: absolute; right: 12px; top: 10px; border: 0; background: none; font: 26px var(--display); color: var(--muted); }
.dialog-heading h2 { font: 400 32px/1.1 var(--display); margin: 8px 0 18px; }
.help-copy { font: 17px/1.55 var(--body); }
.help-copy dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 16px 0; }
.help-copy dt { font: 400 17px var(--caps); color: var(--red); }
.help-copy dd { margin: 0; }
.journal-entries { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.journal-entries li { display: flex; gap: 14px; align-items: center; border-bottom: 1px dotted var(--line); padding: 6px 0; }
.journal-entries li > span { font: 13px var(--ui); color: var(--muted); width: 22px; }
.journal-entries button { all: unset; cursor: pointer; flex: 1; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font: 20px var(--display); padding: 4px 0; }
.journal-entries button:hover { color: var(--red); }
.journal-entries button:focus-visible { outline: 2px solid var(--red); }
.journal-entries small { font: italic 14px var(--display); color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 16px; margin-top: 22px; align-items: center; }
.ending { text-align: center; }
.ending .seal { width: 52px; height: 52px; margin-bottom: 4px; }
.ending h3 { font: 400 44px/1.1 var(--marta); margin: 6px 0 18px; color: var(--red); }
dialog[data-kind=ending] .dialog-heading h2 { font-family: var(--echo); letter-spacing: 1px; color: var(--echo-ink); }
.ending blockquote { margin: 0 auto 20px; max-width: 360px; padding: 18px 20px; text-align: left; white-space: pre-line; font: 400 34px/34px var(--marta); color: var(--marta-ink);
  background: repeating-linear-gradient(#fbf4e1 0 33px, #cfd8e4 33px 34px) 0 16px; border: 1px solid #d4c29c; box-shadow: 0 8px 16px -10px #3b2a1688; }
.ending p { font: 17px/1.5 var(--body); color: #544938; margin: 6px 0; }
.ending .ink-button { margin-top: 18px; }
body[data-chapter="2"] .ending h3 { font: italic 400 40px/1.1 var(--display); }
body[data-chapter="2"] .ending blockquote { font: italic 600 23px/34px var(--kepler); color: var(--kepler-ink); }
.ending .next-chapter { display: block; margin: 12px auto 0; font-size: 15px; color: var(--red); }


/* ——— Smaller screens ——— */
@media (max-width: 1100px) {
  .hud-scene i { display: none; }
}
@media (max-width: 760px) {
  .hud-top { grid-template-columns: auto 1fr auto; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 10px 20px; }
  .hud-brand b { display: none; }
  .hud-brand .seal { width: 26px; height: 26px; }
  .hud-scene { display: none; }
  .pips { justify-self: center; gap: 7px; padding: 6px 9px; }
  .pips .numeral { display: none; }
  .pips ol { gap: 4px; }
  .pips li li { width: 6px; height: 6px; }
  .hud-actions { gap: 4px; }
  .hud-icon { width: 34px; height: 34px; }
  .hud-icon::after { display: none; }
  .hud-objective { top: 58px; left: 10px; width: calc(100vw - 20px); padding: 10px 14px; }
  .hud-objective h2 { font-size: 19px; margin: 4px 0 3px; }
  .hud-objective p { font-size: 13.5px; }
  .satchel { margin-top: 8px; padding-top: 7px; }
  .hud-hint { display: none; }
  .caption { top: 58px; max-width: calc(100% - 20px); padding: 10px 14px; }
  .caption p { font-size: 16px; }
  .dialogue-words { font-size: 18px; }
  #action-hint { display: none; }
  :root { --ctrl: 60px; --ctrl-gap: 10px; }
  .conversation-controls .ink-button { padding: 6px 16px; font-size: 19px; }
  .conversation-back { gap: 8px; }
  .conversation-back button { font-size: 30px; }
  /* On a phone the table becomes a sheet that rises from the floor. */
  .table-panel, .table-panel[data-side] { left: 0 !important; right: 0 !important; top: auto; bottom: var(--ctrl-room); width: auto; max-height: 40svh; border-width: 1px 0; border-width: 1px 0 0; animation: sheet-up .5s cubic-bezier(.2, .9, .3, 1) both; }
  .table-panel.peek { max-height: none; }
  .table-panel.peek .table-body { display: none; }
  .table-head { cursor: pointer; padding: 10px 16px 9px; position: relative; }
  .table-head::after { content: ""; position: absolute; left: 50%; top: 4px; width: 36px; height: 3px; margin-left: -18px; border-radius: 3px; background: #cbb996; }
  .table-head h2 { font-size: 20px; margin: 3px 0 2px; }
  .table-body { padding: 0 16px 12px; }
  @keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } }
  .touch-controls { display: grid; position: absolute; z-index: 11; left: 10px; bottom: max(10px, env(safe-area-inset-bottom)); grid-template-columns: repeat(4, 42px); gap: 5px; opacity: .85; }
  .touch-controls button { height: 42px; border: 1px solid #f6ead033; background: #120b0688; color: #f6ead0; font-size: 18px; border-radius: 50%; touch-action: none; backdrop-filter: blur(3px); }
  body:not([data-mode=play]) .touch-controls { display: none; }
  .marker .mark-label { font-size: 12px; }
  /* On a phone Prague comes down over the top; Kepler stays in view below. */
  .split { left: 0; width: 100%; bottom: auto; height: 42%; clip-path: polygon(0 0, 100% 0, 100% 97%, 62% 100%, 0 97.5%); box-shadow: 0 18px 40px #0009; animation-name: split-down; }
  @keyframes split-down { from { transform: translateY(-100%); } }
  body[data-chapter="2"] .finale { grid-template-columns: 1fr; place-content: end stretch; padding: 0 6% 12%; background: linear-gradient(#0b070400 55%, #0b0704d0); gap: 8px; }
  .caption.echo p { font-size: 18px; }
  .caption:not(.echo) p { font-size: 16px; }
  .interlude-text { bottom: 10%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}

.save-note { font: italic 14px var(--display); color: var(--muted); margin: 16px 0 0; }
.edge-arrow { border: 0; background: #120b0688; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
