/* Paper Lantern Alley: painted rooms, rosewood, red lacquer, gold and old paper. */

@font-face { font-family: 'Cinzel Decorative'; font-weight: 700; font-display: swap; src: url(fonts/cinzel-decorative-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; font-display: swap; src: url(fonts/cormorant-garamond-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 700; font-display: swap; src: url(fonts/cormorant-garamond-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 500; font-style: italic; font-display: swap; src: url(fonts/cormorant-garamond-latin-500-italic.woff2) format('woff2'); }
/* Chinese: LXGW WenKai (SIL OFL), cut down to the characters the game uses (tools/build_font.py). The unicode-range
   means the file is only fetched when Chinese text is on screen. */
@font-face { font-family: 'LXGW WenKai'; font-weight: 400 700; font-display: swap; src: url(fonts/lxgw-wenkai-zh.woff2) format('woff2');
  unicode-range: U+2E80-9FFF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF, U+2018-201D, U+2026, U+00B7; }
@font-face { font-family: 'Caveat'; font-weight: 500; font-display: swap; src: url(fonts/caveat-latin-500-normal.woff2) format('woff2'); }

:root {
  --night: #0d0604; --wood: #1d0d08; --wood-2: #33180e; --wood-3: #4a2415;
  --red: #c9271c; --red-deep: #7c100d; --red-dark: #4a0907;
  --gold: #e2b458; --gold-hi: #f8e2a4; --gold-lo: #8a6424;
  --paper: #f3e5c6; --paper-2: #dcc496; --ink: #37200f; --ink-soft: #6b4a2a;
  --cream: #ffeecb;
  --display: 'Cinzel Decorative', 'Cormorant Garamond', 'LXGW WenKai', Georgia, serif;
  --text: 'Cormorant Garamond', 'LXGW WenKai', Georgia, 'Times New Roman', serif;
  --tray-h: 92px; --tray-w: 0px;   /* the tray is along the bottom, or down the left on short landscape screens */
  --vh: 1vh;   /* 1% of the height actually showing: see the @supports rule under this block */
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  /* a double gold line with a squared spiral in each corner, for border-image */
  --fret: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 90 90'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23f8e2a4'/%3E%3Cstop offset='.5' stop-color='%23c9952f'/%3E%3Cstop offset='1' stop-color='%23f0cf7a'/%3E%3C/linearGradient%3E%3Cpath id='c' d='M24 9V20H14V14.5H19' /%3E%3C/defs%3E%3Cg fill='none' stroke='url(%23g)' stroke-linejoin='miter'%3E%3Crect x='2.5' y='2.5' width='85' height='85' stroke-width='3'/%3E%3Crect x='9' y='9' width='72' height='72' stroke-width='1.6'/%3E%3Cg stroke-width='1.6'%3E%3Cuse href='%23c'/%3E%3Cuse href='%23c' transform='matrix(-1 0 0 1 90 0)'/%3E%3Cuse href='%23c' transform='matrix(1 0 0 -1 0 90)'/%3E%3Cuse href='%23c' transform='matrix(-1 0 0 -1 90 90)'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* on phones 1vh is measured with the browser's bars hidden, so things sized by it come out too tall when they show */
@supports (height: 1dvh) { :root { --vh: 1dvh; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--night); color: var(--cream);
  font: 600 18px/1.3 var(--text);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; }
.hidden { display: none !important; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; overflow: hidden; opacity: 0; visibility: hidden; pointer-events: none; }
.screen.active { opacity: 1; visibility: visible; pointer-events: auto; }
.screen:not(.active) *, .screen:not(.active) *::before, .screen:not(.active) *::after { animation-play-state: paused !important; }
#curtain { position: fixed; inset: 0; z-index: 90; background: #050201; opacity: 0; pointer-events: none; transition: opacity .28s ease; }
#curtain.on { opacity: 1; pointer-events: auto; }

.backdrop { position: absolute; inset: -3%; }
.backdrop img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; animation: kenburns 46s ease-in-out infinite alternate; }
.backdrop.dim img { filter: blur(7px) brightness(.36) saturate(1.1); animation: none; }
@keyframes kenburns { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.09) translate(-1.2%, -1.6%); } }
canvas.embers { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- icons ---------- */
.ico { display: inline-block; width: 1.15em; height: 1.15em; flex: none; background: center / contain no-repeat; vertical-align: -0.2em; }
.ico.coin { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='10.8' fill='%23e9b949' stroke='%238a5a12' stroke-width='1.2'/%3E%3Ccircle cx='12' cy='12' r='7.8' fill='none' stroke='%23fdeeb8' stroke-width='1'/%3E%3Crect x='9.2' y='9.2' width='5.6' height='5.6' fill='%234a2a08' stroke='%23fdeeb8' stroke-width='.7'/%3E%3C/svg%3E"); }
.ico.flame { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 1.5c1 4.2 6.3 6.7 6.3 12.4a6.3 6.3 0 0 1-12.6 0c0-3 1.7-4.7 2.7-6.5.6 1.7 1.4 2.5 2.3 2.7C10.2 7.400 11 4.300 12 1.5z' fill='%23ff7a22'/%3E%3Cpath d='M12 10.5c.6 2.1 2.7 3.2 2.7 5.6a2.7 2.7 0 0 1-5.4 0c0-1.6 1-2.3 1.5-3.3.3.6.6.9 1 1-.2-1.1 0-2.2.2-3.3z' fill='%23ffe08a'/%3E%3C/svg%3E"); }
.ico.mag { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='10' r='6.3' fill='%23fff3d0' fill-opacity='.2' stroke='%23ffeecb' stroke-width='2.3'/%3E%3Cpath d='M6.8 9.2a3.4 3.4 0 0 1 2.6-2.5' fill='none' stroke='%23fff' stroke-width='1.2' stroke-linecap='round'/%3E%3Cpath d='M14.9 14.9L21 21' stroke='%23ffeecb' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico.plus { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 5v14M5 12h14' stroke='%23ffeecb' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico.minus { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12h14' stroke='%23ffeecb' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico.back { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M14.5 5L7.5 12l7 7' fill='none' stroke='%23ffeecb' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ico.close { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' stroke='%23ffeecb' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico.book { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4.5c2.6-1 5.4-1 8 .8v15c-2.6-1.8-5.4-1.8-8-.8z' fill='%23ffeecb' fill-opacity='.18' stroke='%23ffeecb' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M20 4.5c-2.6-1-5.4-1-8 .8v15c2.6-1.8 5.4-1.8 8-.8z' fill='%23ffeecb' fill-opacity='.18' stroke='%23ffeecb' stroke-width='1.8' stroke-linejoin='round'/%3E%3Cpath d='M6.5 8.5c1.3-.4 2.6-.3 3.6.3M6.5 11.5c1.3-.4 2.6-.3 3.6.3M13.9 8.8c1-.6 2.3-.7 3.6-.3' stroke='%23ffeecb' stroke-width='1.1' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico.lock { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7.5 11V8a4.5 4.5 0 0 1 9 0v3' fill='none' stroke='%23e2b458' stroke-width='2.2'/%3E%3Crect x='5' y='10.5' width='14' height='10.5' rx='2' fill='%23e2b458' stroke='%238a5a12'/%3E%3Ccircle cx='12' cy='15' r='1.7' fill='%234a2a08'/%3E%3Cpath d='M12 15.5v3' stroke='%234a2a08' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); }

/* ---------- buttons ---------- */
.btn {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 44px; padding: 8px 22px; border-radius: 999px;
  border: 1.5px solid var(--gold);
  background: linear-gradient(180deg, #e0392a 0%, var(--red) 38%, var(--red-deep) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 220, 190, .55), inset 0 -3px 6px rgba(40, 0, 0, .45), 0 0 0 3px rgba(20, 8, 4, .75), 0 0 0 4px rgba(226, 180, 88, .45), 0 6px 14px rgba(0, 0, 0, .55);
  color: var(--cream); font: 700 17px/1 var(--text); letter-spacing: .09em; text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(60, 0, 0, .8);
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: translateY(1px) scale(.97); filter: brightness(.92); }
.btn:focus-visible, .round-btn:focus-visible, .chapter:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 4px; }
.btn.primary::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 240, 200, .5) 50%, transparent 62%);
  transform: translateX(-120%); animation: shine 3.6s ease-in-out infinite;
}
@keyframes shine { 0%, 55% { transform: translateX(-120%); } 85%, 100% { transform: translateX(120%); } }
.btn.big { min-height: 56px; padding: 12px 46px; font-size: 22px; letter-spacing: .16em; }
.btn.ghost { background: rgba(26, 12, 8, .6); border-color: rgba(226, 180, 88, .55); box-shadow: none; color: var(--gold-hi); text-shadow: none; }

.round-btn {
  position: relative; width: 54px; height: 54px; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
  border: 2px solid var(--gold);
  background: radial-gradient(circle at 35% 28%, #ef5a3f 0%, var(--red) 34%, var(--red-deep) 72%, var(--red-dark) 100%);
  box-shadow: inset 0 2px 2px rgba(255, 225, 200, .5), inset 0 -4px 8px rgba(40, 0, 0, .5), 0 0 0 3px rgba(20, 8, 4, .8), 0 0 0 4.5px rgba(226, 180, 88, .5), 0 6px 14px rgba(0, 0, 0, .6);
  transition: transform .12s ease, filter .12s ease;
}
.round-btn:active { transform: scale(.93); filter: brightness(.9); }
.round-btn .ico { width: 28px; height: 28px; filter: drop-shadow(0 1px 1px rgba(60, 0, 0, .8)); }
.round-btn.sm { width: 42px; height: 42px; }
.round-btn.sm .ico { width: 22px; height: 22px; }
.round-btn small {
  position: absolute; right: -8px; bottom: -6px; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(#fbe7a6, #d9a53c); border: 1.5px solid #7a4d0e; color: #4a2a08;
  font: 700 15px/1 var(--text); box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
}
.round-btn small.paid::before { content: ''; width: 11px; height: 11px; margin-right: 3px; border-radius: 50%; background: #b8791a; box-shadow: inset 0 0 0 2px #fbe7a6, 0 0 0 1px #7a4d0e; }

.pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 3px 14px 3px 6px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(58, 26, 14, .92), rgba(22, 9, 5, .92));
  border: 1.5px solid var(--gold-lo); box-shadow: inset 0 1px 0 rgba(255, 220, 160, .25), 0 3px 8px rgba(0, 0, 0, .5);
  font: 700 19px/1 var(--text); color: var(--gold-hi); white-space: nowrap;
}
.pill .ico { width: 24px; height: 24px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.pill b { font-weight: 700; display: inline-flex; align-items: baseline; gap: 6px; }
.pill.time { padding: 3px 14px; font-variant-numeric: tabular-nums; }
.pill small { font: 600 13px/1 var(--text); color: #c9a877; letter-spacing: .02em; }
.stats { display: flex; gap: 8px; align-items: center; }

/* ---------- parchment panel ---------- */
.panel {
  position: relative; color: var(--ink);
  background: linear-gradient(rgba(255, 244, 214, .25), rgba(190, 150, 90, .22)), url(art/ui/paper.webp) center / 520px, var(--paper);
  border-radius: 10px;
  box-shadow: 0 0 0 2px #2a130a, 0 0 0 3.5px var(--gold-lo), 0 18px 50px rgba(0, 0, 0, .7), inset 0 0 40px rgba(120, 70, 20, .35);
}
.panel::before { content: ''; position: absolute; inset: 5px; pointer-events: none; border: 20px solid transparent; border-image: var(--fret) 30 / 20px stretch; opacity: .95; }

/* ---------- title ---------- */
#screen-title .fog {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(8, 3, 2, .82) 0%, rgba(8, 3, 2, .45) 45%, transparent 72%),
    linear-gradient(0deg, rgba(8, 3, 2, .88) 0%, rgba(8, 3, 2, .3) 26%, transparent 46%);
}
.title-box {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: calc(var(--sat) + calc(3 * var(--vh))) 16px calc(var(--sab) + calc(5.5 * var(--vh)));
}
.emblem {
  width: clamp(30px, calc(9 * var(--vh)), 54px); aspect-ratio: 1; flex: none; margin-bottom: calc(.5 * var(--vh));
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cdefs%3E%3CradialGradient id='r' cx='.5' cy='.45' r='.6'%3E%3Cstop offset='0' stop-color='%23ffd27a'/%3E%3Cstop offset='.45' stop-color='%23e8402c'/%3E%3Cstop offset='1' stop-color='%237c100d'/%3E%3C/radialGradient%3E%3C/defs%3E%3Cpath d='M24 2v6' stroke='%23e2b458' stroke-width='2'/%3E%3Crect x='17' y='7' width='14' height='4' rx='1.5' fill='%23e2b458'/%3E%3Cellipse cx='24' cy='23' rx='14' ry='12.5' fill='url(%23r)' stroke='%23e2b458' stroke-width='1.2'/%3E%3Cpath d='M24 10.5v25M17.5 12c-4 7-4 15 0 22M30.5 12c4 7 4 15 0 22' fill='none' stroke='%23ffd27a' stroke-opacity='.55' stroke-width='1'/%3E%3Crect x='17' y='35' width='14' height='4' rx='1.5' fill='%23e2b458'/%3E%3Cpath d='M21 39v6M24 39v8M27 39v6' stroke='%23e2b458' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 14px rgba(255, 150, 60, .85));
  animation: sway 5s ease-in-out infinite; transform-origin: 50% 0;
}
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
#screen-title h1 {
  margin: 0; font: 700 clamp(34px, min(8.6vw, calc(16 * var(--vh))), 92px)/1.02 var(--display); letter-spacing: .02em;
  filter: drop-shadow(0 2px 0 #3a1505) drop-shadow(0 0 22px rgba(255, 160, 60, .55)) drop-shadow(0 6px 14px rgba(0, 0, 0, .8));
}
#screen-title h1 span {
  display: inline-block; color: var(--gold);
  background: linear-gradient(180deg, #fff6d2 0%, #f6d98c 30%, #d79f35 56%, #f3cf7a 72%, #a56b17 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.kicker {
  display: flex; align-items: center; gap: 14px; margin: calc(1.2 * var(--vh)) 0 0;
  font: italic 500 clamp(17px, calc(4.4 * var(--vh)), 26px)/1 var(--text); color: var(--cream); letter-spacing: .12em;
  text-shadow: 0 2px 8px #000, 0 0 18px rgba(0, 0, 0, .9);
}
.kicker i { width: clamp(30px, 9vw, 90px); height: 1.5px; background: linear-gradient(90deg, transparent, var(--gold)); position: relative; }
.kicker i:last-child { transform: scaleX(-1); }
.kicker i::after { content: ''; position: absolute; right: -3px; top: -3px; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); }
#t-play { margin-top: auto; animation: breathe 2.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 220, 190, .55), inset 0 -3px 6px rgba(40, 0, 0, .45), 0 0 0 3px rgba(20, 8, 4, .75), 0 0 0 4px rgba(226, 180, 88, .45), 0 6px 14px rgba(0, 0, 0, .55), 0 0 0 rgba(255, 170, 70, 0); }
  50% { box-shadow: inset 0 1px 0 rgba(255, 220, 190, .55), inset 0 -3px 6px rgba(40, 0, 0, .45), 0 0 0 3px rgba(20, 8, 4, .75), 0 0 0 4px rgba(226, 180, 88, .8), 0 6px 14px rgba(0, 0, 0, .55), 0 0 34px rgba(255, 170, 70, .7); } }

/* ---------- top bar ---------- */
.bar {
  position: relative; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--sat) + 9px) calc(var(--sar) + 14px) 9px calc(var(--sal) + 14px);
}
.bar h2 {
  margin: 0; white-space: nowrap; font: 700 clamp(18px, calc(5.4 * var(--vh)), 26px)/1 var(--display); color: var(--gold);
  background: linear-gradient(180deg, #fff3c8, #e0ac45 60%, #a56b17); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .9));
}

/* ---------- map ---------- */
#screen-map { display: flex; flex-direction: column; }
#screen-map .bar { background: linear-gradient(180deg, rgba(13, 6, 4, .9), rgba(13, 6, 4, 0)); }
.map-body { position: relative; flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 2px calc(var(--sar) + 16px) calc(var(--sab) + 22px) calc(var(--sal) + 16px); scrollbar-width: none; }
.map-body::-webkit-scrollbar { display: none; }
#acts { max-width: 1040px; margin: 0 auto; }
.act h3 { display: flex; align-items: center; gap: 14px; margin: 12px 0 10px; font: 700 clamp(14px, 2.2vw, 18px)/1 var(--display); color: var(--gold-hi); letter-spacing: .06em; text-shadow: 0 2px 6px #000; }
.act h3 i { flex: 1; height: 1.5px; background: linear-gradient(90deg, transparent, var(--gold)); position: relative; }
.act h3 i:last-child { transform: scaleX(-1); }
.act h3 i::after { content: ''; position: absolute; right: -3px; top: -3px; width: 7px; height: 7px; background: var(--gold); transform: rotate(45deg); }
.chapters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.chapter {
  position: relative; display: flex; flex-direction: column; padding: 0; text-align: left; overflow: hidden;
  border-radius: 10px; border: 1.5px solid var(--gold-lo);
  background: linear-gradient(180deg, #3a1a0e, #1a0b06);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, .18), 0 6px 16px rgba(0, 0, 0, .6);
  color: var(--cream); transition: transform .14s ease;
}
.chapter:not(.locked) { border-color: var(--gold); animation: beckon 2.6s ease-in-out infinite; }
.chapter:not(.locked):active { transform: scale(.97); }
@keyframes beckon { 0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 220, 160, .18), 0 6px 16px rgba(0, 0, 0, .6), 0 0 0 rgba(255, 180, 80, 0); } 50% { box-shadow: inset 0 1px 0 rgba(255, 220, 160, .18), 0 6px 16px rgba(0, 0, 0, .6), 0 0 22px rgba(255, 180, 80, .65); } }
.thumb { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; border-bottom: 1.5px solid var(--gold-lo); background: #120805; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 22px rgba(0, 0, 0, .7); }
.thumb em {
  position: absolute; left: 6px; top: 6px; z-index: 1; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font: 700 12px/1 var(--display); font-style: normal; color: var(--cream);
  background: radial-gradient(circle at 35% 30%, #e8402c, var(--red-deep)); border: 1.5px solid var(--gold); box-shadow: 0 2px 5px rgba(0, 0, 0, .6);
}
.thumb .lock { position: absolute; left: 50%; top: 50%; z-index: 1; width: 30px; height: 30px; margin: -15px; filter: drop-shadow(0 2px 4px #000); }
.chapter.locked .thumb img { filter: saturate(.35) brightness(.42); }
.chapter.locked .thumb em { background: #3a2a22; border-color: var(--gold-lo); color: #c9b08a; }
.chapter.locked { cursor: default; }
.info { display: flex; flex-direction: column; gap: 3px; padding: 7px 9px 9px; min-height: 62px; }
.info b { font: 700 17px/1.05 var(--text); color: var(--gold-hi); }
.info .g { font: italic 500 14.5px/1.1 var(--text); color: #dcc7a2; }
.chapter.locked .info b { color: #b89e78; } .chapter.locked .info .g { color: #8f7a5e; }
.info .row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 4px; }
.cost { display: inline-flex; align-items: center; gap: 3px; font: 700 15px/1 var(--text); color: #ffcf8a; }
.cost .ico { width: 15px; height: 15px; }
.map-actions { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin: 22px 0 6px; }
.map-actions .btn { font-size: 14px; min-height: 40px; padding: 6px 18px; }
/* the music model's licence asks for its name in the game and for the music to be marked as machine-made:
   a quiet footer under the chapter map */
/* the language switch: a quiet corner button on the title, one more button in the map's menu */
#screen-title .lang-btn {
  position: absolute; z-index: 2; top: calc(var(--sat) + 12px); right: calc(var(--sar) + 14px); min-height: 36px; padding: 6px 14px;
  border: 1px solid rgba(226, 180, 88, .45); border-radius: 18px; background: rgba(20, 8, 4, .55); color: var(--gold-hi);
  font: 600 15px/1 var(--text); letter-spacing: .04em; cursor: pointer;
}
#screen-title .lang-btn:focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; }
/* Chinese reads better without the wide letter-spacing the English capitals use */
/* Chinese has no italic: never slant it (the font has one weight, so no faked bold either) */
html:lang(zh) { font-synthesis: none; }
:lang(zh) .btn, :lang(zh) .kicker, :lang(zh) #screen-title h1 { letter-spacing: .08em; }
:lang(zh) #screen-title h1 { letter-spacing: .14em; }
.credit { margin: 26px 0 4px; text-align: center; font-size: 10.5px; letter-spacing: .04em; color: rgba(243, 226, 189, .34); }
.credit a { color: inherit; text-underline-offset: 2px; }

.st3 { display: inline-flex; gap: 2px; }
.st3 i { width: 16px; height: 16px; display: block; }
.st3 svg { width: 100%; height: 100%; display: block; fill: rgba(0, 0, 0, .35); stroke: rgba(226, 180, 88, .5); stroke-width: 1.2; stroke-linejoin: round; }
.st3 i.on svg { fill: #f6cd5c; stroke: #8a5a12; filter: drop-shadow(0 0 4px rgba(255, 200, 90, .8)); }
.st3.big { gap: 8px; margin: 4px 0 2px; }
.st3.big i { width: 46px; height: 46px; }
.st3.big i:nth-child(2) { width: 58px; height: 58px; margin-top: -8px; }
.st3.big svg { fill: rgba(80, 50, 20, .18); stroke: rgba(120, 80, 30, .5); }
.st3.big i.on { animation: starpop .55s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes starpop { from { transform: scale(0) rotate(-50deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- the scene ---------- */
#viewport { position: absolute; inset: 0 0 calc(var(--tray-h) + var(--sab)) var(--tray-w); overflow: hidden; touch-action: none; background: #070302; cursor: grab; }
#viewport::before { content: ''; position: absolute; inset: -30px; background: var(--room, url(art/room.webp)) center / cover; filter: blur(22px) brightness(.3); }
#viewport::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 46%, transparent 56%, rgba(8, 3, 1, .5) 100%); }
#world { position: absolute; left: 0; top: 0; width: 1600px; height: 900px; transform-origin: 0 0; --u: 1; box-shadow: 0 0 60px 20px rgba(0, 0, 0, .75); }
#room, #front { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#targets, #lights, #spots { position: absolute; inset: 0; pointer-events: none; }
.target {
  position: absolute; height: auto; transform: translate(-50%, -50%) scaleY(var(--flat)) rotate(var(--rot));
  filter: brightness(var(--lit)) saturate(.92) drop-shadow(0 2px 2px rgba(10, 3, 0, .6));
  transition: opacity .2s ease;
}
.target.found { opacity: 0; }
/* what marks a place as worth a closer look */
.glint { position: absolute; width: calc(var(--u) * 26px); height: calc(var(--u) * 26px); transform: translate(-50%, -50%); transition: opacity .6s ease;
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 0c.7 6.800 4.500 10.600 12 12-7.500 1.400-11.300 5.200-12 12-.7-6.800-4.500-10.600-12-12 7.500-1.400 11.300-5.200 12-12z' fill='%23fff3c4'/%3E%3C/svg%3E");
  filter: drop-shadow(0 0 calc(var(--u) * 4px) #ffb347); animation: glint 2.6s ease-in-out infinite; }
@keyframes glint { 0%, 100% { transform: translate(-50%, -50%) scale(.25) rotate(0deg); opacity: 0; } 45% { transform: translate(-50%, -50%) scale(1) rotate(40deg); opacity: 1; } 70% { transform: translate(-50%, -50%) scale(.55) rotate(70deg); opacity: .6; } }
.prop { position: absolute; transform: translate(-50%, -50%) rotate(var(--rot)); transition: opacity .6s ease; }
.prop.scrap { width: 17px; height: 12px; background: linear-gradient(140deg, #efe1bd, #c9b384); clip-path: polygon(0 12%, 22% 0, 48% 14%, 74% 2%, 100% 20%, 92% 62%, 100% 96%, 66% 86%, 40% 100%, 12% 84%, 4% 52%); filter: brightness(.86); }
.prop.tile { width: 11px; height: 7px; border-radius: 1.6px; background: linear-gradient(160deg, #3d9a6a, #1c5b3c); box-shadow: 0 1.6px 0 #e9e0c6, 0 3px 2px rgba(10, 3, 0, .6); filter: brightness(.8); }
.prop.dframe { width: 34px; height: 22px; border: 2px solid #d9a53c; border-radius: 2px; background: rgba(30, 12, 4, .55);
  box-shadow: 0 0 0 1px rgba(40, 16, 4, .8), 0 0 10px 2px rgba(255, 190, 90, .45), inset 0 0 6px rgba(0, 0, 0, .8); animation: dframe 3.2s ease-in-out infinite; }
@keyframes dframe { 50% { box-shadow: 0 0 0 1px rgba(40, 16, 4, .8), 0 0 16px 5px rgba(255, 200, 100, .7), inset 0 0 6px rgba(0, 0, 0, .8); } }
.glint.gone, .prop.gone { opacity: 0; animation: none; }
.glow { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); mix-blend-mode: screen;
  background: radial-gradient(closest-side, rgba(255, 176, 90, .34), rgba(255, 120, 40, .13) 48%, transparent 72%); animation: flicker 5s ease-in-out infinite; }
@keyframes flicker { 0%, 100% { opacity: .75; } 22% { opacity: 1; } 40% { opacity: .62; } 58% { opacity: .95; } 77% { opacity: .7; } }
.mote { position: absolute; width: var(--s); height: var(--s); border-radius: 50%; background: rgba(255, 228, 176, .9); box-shadow: 0 0 6px 2px rgba(255, 190, 110, .45); opacity: 0; animation: mote 14s linear infinite; }
@keyframes mote { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: .75; } 50% { transform: translate(26px, -46px); opacity: .35; } 80% { opacity: .7; } 100% { transform: translate(-14px, -100px); opacity: 0; } }

#fx { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.burst { fill: none; stroke: #fff0b8; stroke-width: calc(var(--u) * 4px); transform-box: fill-box; transform-origin: center; filter: drop-shadow(0 0 5px #ffb347); animation: burst .8s ease-out forwards; }
.burst.b2 { stroke: #ffc45c; stroke-width: calc(var(--u) * 2px); animation-duration: 1.05s; animation-delay: .08s; opacity: 0; }
@keyframes burst { 0% { transform: scale(.35); opacity: 1; } 100% { transform: scale(1.7); opacity: 0; } }
.spark { fill: #fff2bf; filter: drop-shadow(0 0 3px #ffb347); opacity: 0; animation: spark .95s cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes spark {
  0% { transform: translate(var(--x), var(--y)) scale(calc(var(--s) * var(--u) * 1.5)) rotate(0deg); opacity: 1; }
  100% { transform: translate(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy))) scale(0) rotate(180deg); opacity: 0; } }
.ripple { fill: none; stroke: rgba(255, 236, 196, .55); stroke-width: calc(var(--u) * 2px); transform-box: fill-box; transform-origin: center; animation: miss .65s ease-out forwards; }
@keyframes miss { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
.hint-ring { fill: none; stroke: #ffe59a; stroke-width: calc(var(--u) * 4px); transform-box: fill-box; transform-origin: center; filter: drop-shadow(0 0 6px #ffae3d); animation: hintpulse 1.3s ease-in-out infinite; }
.hint-ring.h2 { stroke-width: calc(var(--u) * 2px); animation: hintwave 1.3s ease-out infinite; }
@keyframes hintpulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.12); opacity: .75; } }
@keyframes hintwave { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(2.1); opacity: 0; } }

img.ghost { position: fixed; left: 0; top: 0; z-index: 60; height: auto; pointer-events: none; will-change: transform;
  filter: drop-shadow(0 0 10px rgba(255, 214, 130, .95)) drop-shadow(0 10px 12px rgba(0, 0, 0, .55)); }

.play-bar { position: absolute; left: var(--tray-w); right: 0; top: 0; pointer-events: none; background: linear-gradient(180deg, rgba(8, 3, 2, .82), rgba(8, 3, 2, 0)); padding-bottom: 20px; }
.play-bar > * { pointer-events: auto; }
.p-title { position: absolute; left: 50%; top: calc(var(--sat) + 8px); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: none; white-space: nowrap; }
.p-title b { font: 700 clamp(13px, calc(4.2 * var(--vh)), 18px)/1 var(--display); color: var(--gold-hi); text-shadow: 0 2px 6px #000, 0 0 12px rgba(0, 0, 0, .9); letter-spacing: .03em; }
.p-title span { pointer-events: auto; cursor: pointer; font: italic 500 clamp(14px, calc(4.2 * var(--vh)), 17px)/1 var(--text); color: var(--cream); padding: 3px 12px 4px; border-radius: 10px; background: rgba(20, 8, 4, .62); border: 1px solid rgba(226, 180, 88, .35); }
.side { position: absolute; z-index: 6; right: calc(var(--sar) + 14px); top: calc(50% - (var(--tray-h) + var(--sab)) / 2); transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 14px; }

.tip { position: absolute; z-index: 4; left: calc(50% + var(--tray-w) / 2); top: calc(var(--sat) + 66px); transform: translateX(-50%); width: max-content; max-width: min(92vw - var(--tray-w), 520px); padding: 7px 16px; border-radius: 16px; text-align: center;
  font: italic 500 17px/1.2 var(--text); color: var(--cream); background: rgba(20, 8, 4, .86); border: 1px solid rgba(226, 180, 88, .5); pointer-events: none; animation: tipin .5s ease both; }
@keyframes tipin { from { opacity: 0; transform: translate(-50%, -8px); } }
#count.flash { animation: flash .8s ease-out; }

/* ---------- tray ---------- */
#tray {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; height: calc(var(--tray-h) + var(--sab));
  display: flex; align-items: stretch; gap: 8px;
  padding: 7px calc(var(--sar) + 10px) calc(var(--sab) + 5px) calc(var(--sal) + 10px);
  background: linear-gradient(180deg, rgba(255, 210, 150, .1), rgba(0, 0, 0, .25)), url(art/ui/wood.webp) center / auto 200%, var(--wood-2);
  border-top: 2px solid var(--gold); box-shadow: 0 -1px 0 3px #1a0b06, 0 -5px 0 0 var(--gold-lo), 0 -14px 26px rgba(0, 0, 0, .6);
}
#count {
  flex: none; align-self: center; width: 60px; height: 60px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: radial-gradient(circle at 35% 28%, #ef5a3f 0%, var(--red) 34%, var(--red-deep) 74%, var(--red-dark) 100%);
  border: 2px solid var(--gold); box-shadow: inset 0 2px 2px rgba(255, 225, 200, .45), inset 0 -4px 8px rgba(40, 0, 0, .5), 0 0 0 3px #1a0b06, 0 0 0 4.5px rgba(226, 180, 88, .5);
}
#count b { font: 700 19px/1 var(--text); color: var(--cream); text-shadow: 0 1px 2px rgba(60, 0, 0, .8); }
#count span { font: 600 11px/1 var(--text); letter-spacing: .1em; text-transform: uppercase; color: #ffd9a0; }
#items { flex: 1; min-width: 0; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; align-items: flex-start; }
#items::-webkit-scrollbar { display: none; }
.item { flex: 1 0 84px; max-width: 110px; display: flex; flex-direction: column; align-items: center; gap: 3px; text-align: center; padding: 0; border: 0; background: none; }
.slot {
  position: relative; width: 46px; height: 46px; flex: none; border-radius: 9px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, #7c5a22, #2a1508 80%);
  border: 1.5px solid var(--gold); box-shadow: inset 0 3px 7px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 220, 160, .22);
  transition: transform .15s ease, box-shadow .15s ease;
}
.slot .spr { width: 82%; height: 82%; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.item .nm { font: 600 12.5px/1 var(--text); color: #f3dcb4; text-shadow: 0 1px 2px #000; max-width: 100%; overflow-wrap: break-word; }
.item.empty .slot { background: radial-gradient(circle at 50% 40%, #3a1d11, #170905 78%); border-color: rgba(138, 100, 36, .55); box-shadow: inset 0 3px 7px rgba(0, 0, 0, .75); }
.item.arriving .spr { opacity: 0; }
.item.held .slot { transform: translateY(-3px) scale(1.08); border-color: var(--gold-hi); box-shadow: 0 0 0 2px var(--gold-hi), 0 0 16px 3px rgba(255, 200, 100, .8), inset 0 0 12px rgba(255, 220, 150, .5); }
.item.held .nm { color: var(--gold-hi); }
.item.nudge .slot { animation: itemnudge .7s ease-in-out infinite; }
@keyframes itemnudge { 50% { transform: translateY(-5px) scale(1.1); box-shadow: 0 0 0 2px var(--gold-hi), 0 0 18px 4px rgba(255, 200, 100, .85); } }
.item.flash .slot { animation: flash .7s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(255, 220, 130, .95), inset 0 0 18px rgba(255, 230, 160, .9); transform: scale(1.22); } 100% { box-shadow: 0 0 0 16px rgba(255, 220, 130, 0), inset 0 3px 7px rgba(0, 0, 0, .75); transform: none; } }

/* ---------- close-ups: one per puzzle ---------- */
#puzzle { position: absolute; inset: 0 0 calc(var(--tray-h) + var(--sab)) var(--tray-w); z-index: 5; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center;
  padding: calc(var(--sat) + 8px) calc(var(--sar) + 80px) 8px 12px; background: rgba(8, 3, 2, .76); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
#screen-play.in-panel #p-zin, #screen-play.in-panel #p-zout { display: none; }
/* Everything in a close-up is sized from the card it sits in (container units), never from the screen:
   a phone browser's bars, a split view or a small window all change the room there really is. */
.pz { container: pz / size; position: relative; width: min(100%, 780px); height: min(100%, 580px); display: flex; flex-direction: column; border-radius: 12px; border: 2px solid var(--gold);
  background: linear-gradient(180deg, rgba(255, 210, 150, .08), rgba(0, 0, 0, .38)), url(art/ui/wood.webp) center / 640px, var(--wood-2);
  box-shadow: 0 0 0 3px #1a0b06, 0 0 0 4.5px var(--gold-lo), 0 18px 50px rgba(0, 0, 0, .75), inset 0 0 50px rgba(0, 0, 0, .5);
  animation: cardin .32s cubic-bezier(.2, 1.2, .4, 1) both; }
/* the heading keeps one height whatever Mei says, so the puzzle under it never jumps (main.js shrinks a long line to fit) */
.pz-head { flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; height: 62px; padding: 6px 8px 4px 16px; }
.pz-head h3 { margin: 0; min-width: 0; white-space: nowrap; font: 700 clamp(14px, calc(4.4 * var(--vh)), 19px)/1.2 var(--display); font-size: clamp(14px, 2.9cqw, 19px); color: var(--gold);
  background: linear-gradient(180deg, #fff3c8, #e0ac45 60%, #a56b17); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .9)); }
#pz-say { margin: 0; max-height: 52px; overflow: hidden; font: italic 500 17px/1.12 var(--text); color: var(--cream); text-shadow: 0 1px 3px #000; }
#pz-say.in { animation: sayin .35s ease both; }
@keyframes sayin { from { opacity: 0; transform: translateY(4px); } }
#pz-body { container: pzb / size; flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 2px 14px 12px; }
/* the working part of a puzzle: it takes whatever room the note beside it leaves, and what is in it is sized to that room */
.pz-stage { container: stage / size; flex: 1 1 0; align-self: stretch; min-width: 0; min-height: 0; display: grid; place-items: center; }
/* a narrow card: the heading above, Mei's words under it */
@container pz (max-width: 559.9px) {
  .pz-head { height: auto; grid-template-columns: minmax(0, 1fr) auto; padding-bottom: 6px; }
  .pz-head h3 { font-size: clamp(12px, 4.6cqw, 19px); }
  #pz-say { grid-column: 1 / -1; grid-row: 2; height: 38px; max-height: none; padding-right: 8px; }
}
/* narrow and short (a small phone on its side): no room for a heading, only what she says */
@container pz (max-width: 559.9px) and (max-height: 380px) {
  .pz-head h3 { display: none; }
  #pz-say { grid-column: 1; grid-row: 1; }
}

/* a note pinned beside a puzzle: what Mei has learned that bears on it */
.pz-clue { flex: none; max-width: 100%; padding: 8px 16px; border-radius: 3px; transform: rotate(-.8deg); color: #3b2412;
  font: 500 clamp(17px, calc(4.9 * var(--vh)), 21px)/1.1 'Caveat', 'LXGW WenKai', 'Segoe Script', cursive; font-size: clamp(13px, min(7cqh, 5.4cqw), 21px);
  background: linear-gradient(rgba(255, 244, 214, .3), rgba(190, 150, 90, .25)), url(art/ui/paper.webp) center / 520px, var(--paper);
  box-shadow: 0 6px 14px rgba(0, 0, 0, .55), inset 0 0 22px rgba(120, 70, 20, .35); }
.pz-clue.poem { display: grid; gap: 4px 18px; }
.pz-clue.none { transform: none; background: none; box-shadow: none; max-width: 34ch; padding: 0 8px; text-align: center; color: #dcc7a2; font: italic 500 16px/1.2 var(--text); font-size: clamp(13px, min(5.6cqh, 4.6cqw), 16px); }
.pz-count { flex: none; text-align: center; color: #b49a70; font: 500 13px/1.2 var(--text); font-size: clamp(12px, min(4.6cqh, 3.8cqw), 14px); }
/* a wide, low card: the rhyme goes two lines across, to leave the height for the cabinet */
@container pz (min-width: 420px) and (min-aspect-ratio: 5/4) { .pz-clue.poem { grid-template-columns: auto auto; font-size: clamp(13px, min(6.5cqh, 3.5cqw), 21px); } }
/* the drawer has its note beside it wherever the card is wider than tall */
@container pz (min-aspect-ratio: 1/1) {
  #puzzle[data-pz="drawer"] #pz-body { flex-direction: row; gap: 14px; }
  #puzzle[data-pz="drawer"] .pz-clue { flex: 0 0 clamp(100px, 30%, 190px); }
}
/* a place for something Mei is carrying */
.pz-slot { position: relative; width: 58px; height: 58px; padding: 0; border-radius: 10px; display: grid; place-items: center;
  border: 1.5px dashed rgba(226, 180, 88, .75); background: rgba(10, 4, 2, .55); box-shadow: inset 0 3px 8px rgba(0, 0, 0, .7); }
.pz-slot .spr { width: 80%; height: 80%; object-fit: contain; filter: brightness(0) invert(.86) sepia(.7) saturate(1.4) hue-rotate(-12deg) opacity(.38); transition: filter .3s ease; }
.pz-slot.full { border-style: solid; border-color: var(--gold); }
.pz-slot.full .spr { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)); }

/* the torn rhyme */
.jg { position: relative; flex: 1; align-self: stretch; min-height: 0; touch-action: none; }
.jg-board { position: absolute; border: 1.5px dashed rgba(226, 180, 88, .5); border-radius: 3px; background: rgba(10, 4, 2, .42); box-shadow: inset 0 0 30px rgba(0, 0, 0, .6); }
.jg-piece { position: absolute; left: 0; top: 0; touch-action: none; cursor: grab; background-repeat: no-repeat; will-change: transform; box-shadow: 0 0 0 .5px rgba(90, 50, 20, .7), 0 3px 8px rgba(0, 0, 0, .6); }
.jg-piece.drag { cursor: grabbing; box-shadow: 0 0 0 1px var(--gold-hi), 0 12px 22px rgba(0, 0, 0, .7); }
.jg-piece.home { cursor: default; box-shadow: 0 0 0 .5px rgba(90, 50, 20, .4); transition: transform .28s ease; }
.jg-piece.glide { transition: transform .45s ease; }
.jg.done .jg-piece { box-shadow: none; }
.jg.done .jg-board { border-color: transparent; animation: pageglow 1.7s ease-out both; }
.jg.done.still .jg-board { animation: none; box-shadow: 0 10px 26px rgba(0, 0, 0, .7); }
@keyframes pageglow { 0% { box-shadow: 0 0 0 0 rgba(255, 225, 150, 0); } 35% { box-shadow: 0 0 46px 16px rgba(255, 214, 130, .95); } 100% { box-shadow: 0 0 18px 2px rgba(255, 214, 130, .35), 0 10px 26px rgba(0, 0, 0, .7); } }

/* the seasons cabinet */
.cab { container-type: size; position: relative; flex: none; width: min(100%, 430px); width: min(100cqw, 470px, 100cqh * 1.72); aspect-ratio: 1.72; display: flex; padding: 9px; perspective: 1100px; border-radius: 8px;
  background: linear-gradient(#2a1209, #1a0a05); border: 2px solid var(--gold-lo); box-shadow: 0 10px 26px rgba(0, 0, 0, .7); }
.cab-in { position: absolute; inset: 9px; border-radius: 4px; display: flex; align-items: center; justify-content: center; gap: 8%;
  background: radial-gradient(circle at 50% 60%, #6b3d16, #150804 75%); box-shadow: inset 0 0 40px #000; }
.cab-in .spr { width: 30%; height: 70%; object-fit: contain; opacity: 0; transition: opacity .8s ease .5s; filter: drop-shadow(0 0 14px rgba(255, 210, 120, .9)) drop-shadow(0 6px 6px rgba(0, 0, 0, .6)); }
.cab.open .cab-in .spr { opacity: 1; animation: bob 2.6s ease-in-out infinite; }
.leaf { position: relative; z-index: 1; flex: 1; min-width: 0; display: flex; gap: 6%; padding: 4% 5%;
  background: linear-gradient(rgba(255, 200, 140, .08), rgba(0, 0, 0, .3)), url(art/ui/wood.webp) center / 300px, var(--wood-3);
  border: 1.5px solid var(--gold-lo); box-shadow: inset 0 0 0 4px rgba(20, 8, 4, .5), inset 0 0 24px rgba(0, 0, 0, .5); transition: transform 1.3s cubic-bezier(.5, 0, .2, 1); }
.leaf.l { transform-origin: 0 50%; border-radius: 4px 0 0 4px; }
.leaf.r { transform-origin: 100% 50%; border-radius: 0 4px 4px 0; }
.cab.open .leaf.l { transform: rotateY(-102deg); }
.cab.open .leaf.r { transform: rotateY(102deg); }
.cab.open .leaf > * { opacity: 0; transition: opacity .4s ease .3s; }
.niche { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: var(--gold-hi); }
.sico { flex: none; width: clamp(16px, calc(5 * var(--vh)), 24px); width: clamp(11px, 9.5cqh, 24px); aspect-ratio: 1; filter: drop-shadow(0 1px 2px #000); }
.sico svg { display: block; width: 100%; height: 100%; }
.niche .hole { flex: 1; align-self: stretch; min-height: 0; display: grid; place-items: center; overflow: hidden; border-radius: 999px 999px 6px 6px;
  background: radial-gradient(circle at 50% 70%, #3a1d11, #0d0503 80%); border: 1.5px solid var(--gold-lo); box-shadow: inset 0 6px 14px rgba(0, 0, 0, .85); }
.niche .hole .spr { width: 84%; height: 84%; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .7)); animation: seat .3s ease both; }
@keyframes seat { from { transform: translateY(-10px) scale(1.2); opacity: 0; } }
.niche b { font: 700 clamp(10px, min(calc(3.3 * var(--vh)), 2.9vw), 14px)/1 var(--text); font-size: clamp(7.5px, 3.25cqw, 14px); letter-spacing: .06em; text-transform: uppercase; text-shadow: 0 1px 2px #000; }
.niche.full .hole { border-color: var(--gold); }
.cab.lit .hole { animation: nichelit .7s ease both; }
.cab.lit .leaf.l .niche:nth-child(2) .hole { animation-delay: .16s; }
.cab.lit .leaf.r .niche:nth-child(1) .hole { animation-delay: .32s; }
.cab.lit .leaf.r .niche:nth-child(2) .hole { animation-delay: .48s; }
@keyframes nichelit { to { border-color: var(--gold-hi); box-shadow: inset 0 0 18px rgba(255, 214, 130, .75), 0 0 14px 3px rgba(255, 214, 130, .8); background: radial-gradient(circle at 50% 70%, #8a5a22, #2a1508 80%); } }
.cab-lock { --k: clamp(16px, 13cqh, 30px); position: absolute; z-index: 2; left: 50%; top: 50%; width: var(--k); height: var(--k); margin: calc(var(--k) / -2); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fbe7a6, #b8791a 60%, #6b4310); border: 1.5px solid #4a2a08; box-shadow: 0 2px 5px rgba(0, 0, 0, .7); transition: transform .8s ease, opacity .5s ease .7s, box-shadow .5s ease; }
.cab-lock::after { content: ''; position: absolute; left: 50%; top: 22%; width: 14%; height: 56%; margin-left: -7%; border-radius: 2px; background: #3a2208; }
.cab.lit .cab-lock { transform: rotate(90deg); box-shadow: 0 0 16px 4px rgba(255, 210, 120, .9); }
.cab.open .cab-lock { opacity: 0; }
.cab.shake { animation: shake .45s ease; }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

/* the letter */
.lt { flex: 1; align-self: stretch; min-height: 0; display: flex; align-items: stretch; justify-content: center; gap: 12px; }
.lt .paper { flex: 0 1 580px; width: auto; min-height: 0; max-height: none; overflow: hidden; padding: 14px 22px; padding: clamp(8px, 4cqh, 14px) clamp(12px, 5cqw, 22px); transform: none; animation: none; touch-action: none; }
.lt .tea { position: absolute; inset: 0 0 auto; height: var(--page-h, 100%); background: radial-gradient(60% 50% at 30% 30%, rgba(150, 95, 40, .34), transparent 70%), radial-gradient(50% 60% at 75% 70%, rgba(140, 85, 30, .38), transparent 70%), rgba(170, 120, 60, .2); }
/* puzzles.js sets the size of the hand so the whole letter fits the page, whatever size the page comes out */
.lt .paper-text { position: relative; white-space: normal; color: #55300f; font-size: clamp(12px, min(calc(5.2 * var(--vh)), 5.3vw), 24px); line-height: 1.14; }
.lt .paper-text p { margin: 0 0 .3em; }
.lt .paper-text p:last-of-type { margin: 0; display: flex; align-items: center; justify-content: flex-end; gap: .7em; }
/* her seal sits beside her name, and shows on the blank page too */
.lt .seal { position: relative; right: auto; bottom: auto; z-index: 1; flex: none; width: 1.9em; height: 1.9em; }
.lt .seal::after { inset: 28%; border-width: .09em; }
/* on a screen too small for even a small hand, the page scrolls once it can be read */
.lt.read .paper.long { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: rgba(120, 70, 20, .6) transparent; }
.lt .paper.long { padding-top: 0; padding-bottom: 0; }
.lt .paper.long .paper-text { padding: var(--pad, 10px) 0; }
/* a long page on a very small screen: a mark at the foot says there is more to scroll to */
.lt-more { display: none; position: sticky; z-index: 2; bottom: 0; height: 0; pointer-events: none; }
.lt.read .paper.long:not(.end) .lt-more { display: block; }
.lt-more::before { content: ''; position: absolute; left: -30px; right: -30px; bottom: 0; height: 30px; background: linear-gradient(rgba(224, 203, 163, 0), rgba(224, 203, 163, .96) 75%); }
.lt-more::after { content: ''; position: absolute; left: 50%; bottom: 6px; width: 9px; height: 9px; margin-left: -6px; border: solid #7a4517; border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg); filter: drop-shadow(0 0 3px #f3e2bd) drop-shadow(0 0 3px #f3e2bd); animation: more 1.3s ease-in-out infinite; }
@keyframes more { 50% { transform: translateY(-4px) rotate(45deg); } }
.lt canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; transition: opacity 1.8s ease; }
.lt.ready canvas { cursor: crosshair; }
.lt .paper-note { position: absolute; left: 0; right: 0; top: 42%; margin: 0; text-align: center; pointer-events: none; color: #3b2412; font: 500 clamp(20px, calc(7 * var(--vh)), 30px)/1 'Caveat', 'LXGW WenKai', 'Segoe Script', cursive; transition: opacity .45s ease; }
.lt.wet .paper-note, .lt.read .paper-note { opacity: 0; }
.lt.read canvas { opacity: 0; pointer-events: none; }
.lt-brush { position: absolute; z-index: 2; left: 0; top: 0; width: 52px; height: auto; pointer-events: none; opacity: 0; transition: opacity .2s ease; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .4)); }
.lt.washing .lt-brush { opacity: 1; }
.lt-tools { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.lt .pz-slot { width: clamp(42px, min(17cqh, 17cqw), 58px); height: clamp(42px, min(17cqh, 17cqw), 58px); }
/* a card taller than wide: the page above, the cup and brush in a row under it */
@container pz (max-aspect-ratio: 5/4) {
  .lt { flex-direction: column; align-items: center; gap: 10px; }
  .lt .paper { flex: 1; align-self: stretch; }
  .lt-tools { flex-direction: row; }
}
.lt.ready .paper { box-shadow: 0 0 0 2px rgba(255, 214, 130, .75), 0 0 22px 2px rgba(255, 200, 110, .45), inset 0 0 50px rgba(120, 70, 20, .4); }

/* the mahjong table */
.mj { --c: 7; --r: 2; --t: clamp(34px, min(8.6vw, calc(14 * var(--vh))), 64px); display: grid; grid-template-columns: repeat(var(--c), var(--t)); gap: calc(var(--t) * .18); padding: 14px 18px; border-radius: 10px;
  background: radial-gradient(circle at 50% 40%, #1f6a47, #0f3a27); border: 2px solid var(--gold-lo); box-shadow: inset 0 0 30px rgba(0, 0, 0, .6), 0 8px 20px rgba(0, 0, 0, .6); }
.mj-tile { position: relative; width: var(--t); height: calc(var(--t) * 1.33); padding: 0; border: 0; background: none; perspective: 500px; transition: opacity .45s ease, transform .45s ease; }
.mj-in { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .38s cubic-bezier(.4, 0, .2, 1); }
.mj-tile.up .mj-in { transform: rotateY(180deg); }
.mj-back, .mj-face { position: absolute; inset: 0; border-radius: 14% / 10%; -webkit-backface-visibility: hidden; backface-visibility: hidden; box-shadow: 0 3px 0 #b9ad8c, 0 5px 6px rgba(0, 0, 0, .55); }
.mj-back { background: linear-gradient(150deg, #4bb37e, #1f7a50 55%, #145a3a); border: 1px solid #0f3f29; }
.mj-back::after { content: ''; position: absolute; inset: 14%; border: 1.5px solid rgba(255, 255, 255, .25); border-radius: 10%; }
.mj-face { transform: rotateY(180deg); display: grid; place-items: center; background: linear-gradient(160deg, #fffaf0, #eadfc4); border: 1px solid #b9ad8c; }
.mj-face svg { width: 82%; height: 86%; }
.mj-tile.gone { opacity: 0; transform: scale(.55) translateY(-10px); pointer-events: none; }
.mj-tile.peek .mj-face { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 14px 3px rgba(255, 214, 130, .9); }
.mj-tile.lucky { z-index: 2; animation: lucky 1.6s ease both; }
.mj-tile.lucky .mj-face { box-shadow: 0 0 0 2px var(--gold-hi), 0 0 26px 8px rgba(255, 214, 130, .95); }
@keyframes lucky { 45% { transform: scale(1.45) rotate(-4deg); } 100% { transform: scale(1.28); } }
/* thirteen tiles: seven across on a wide table, five on a squarer one, four on a tall one; as large as the table allows */
@container stage (max-aspect-ratio: 13/10) { .mj { --c: 5; --r: 3; } }
@container stage (max-aspect-ratio: 3/4) { .mj { --c: 4; --r: 4; } }
@supports (width: 1cqw) {
  .mj { --t: min((100cqw - 42px) / (var(--c) + (var(--c) - 1) * .18), (100cqh - 40px) / (var(--r) * 1.33 + (var(--r) - 1) * .18), 68px); }
}

/* the counting drawer */
.dr { --b: clamp(15px, min(calc(5.6 * var(--vh)), 5.3vw), 27px); position: relative; flex: none; display: flex; flex-direction: column; align-items: center; }
.dr-inside { width: 88%; height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 10%; border-radius: 6px 6px 0 0;
  background: linear-gradient(#150804, #3a1d11); box-shadow: inset 0 8px 20px #000, inset 0 0 0 2px var(--gold-lo); transition: height 1.2s cubic-bezier(.3, 0, .2, 1); }
.dr.open .dr-inside { height: calc(var(--b) * 3.2); height: min(var(--b) * 3.2, 100cqh - var(--b) * 7 - 80px); }
/* the beads as large as the room allows, keeping some back for the drawer to slide open into */
@supports (width: 1cqw) { .dr { --b: clamp(9px, min((100cqh - 82px) / 9, (100cqw - 56px) / 11.8), 27px); } }
.dr-inside .spr { height: 82%; width: auto; max-width: 40%; object-fit: contain; opacity: 0; transition: opacity .8s ease .7s; filter: drop-shadow(0 0 12px rgba(255, 210, 120, .9)); }
.dr.open .dr-inside .spr { opacity: 1; }
.dr-front { position: relative; display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-radius: 8px;
  background: linear-gradient(rgba(255, 200, 140, .08), rgba(0, 0, 0, .3)), url(art/ui/wood.webp) center / 300px, var(--wood-3);
  border: 2px solid var(--gold-lo); box-shadow: inset 0 0 0 4px rgba(20, 8, 4, .45), inset 0 0 26px rgba(0, 0, 0, .5), 0 10px 24px rgba(0, 0, 0, .7); }
.dr-frame { display: grid; place-items: center; min-width: calc(var(--b) * 9.6); min-height: calc(var(--b) * 7 + 47px); }
.pz-slot.wide { width: calc(var(--b) * 8.4); height: calc(var(--b) * 6); }
.pz-slot.tile { width: calc(var(--b) * 2.1); height: calc(var(--b) * 2.8); border-radius: 6px; }
.abacus { position: relative; display: flex; gap: calc(var(--b) * .5); padding: 8px 10px 4px; border-radius: 6px; background: linear-gradient(#2a1209, #1a0a05);
  border: 3px solid #6b3d16; outline: 1.5px solid var(--gold-lo); box-shadow: inset 0 0 14px #000; transition: box-shadow .5s ease, outline-color .5s ease; }
.abacus::before { content: ''; position: absolute; z-index: 1; left: 0; right: 0; top: calc(8px + var(--b) * 2); height: 5px; background: linear-gradient(#a0672a, #5d3410); }
.rod { position: relative; width: calc(var(--b) * 2.6); height: calc(var(--b) * 7 + 29px); }
.rod::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 24px; width: 3px; margin-left: -1.5px; background: linear-gradient(90deg, #d9a53c, #8a5a12); }
.bead { position: absolute; z-index: 2; left: 0; width: 100%; height: var(--b); padding: 0; border: 0; border-radius: 50%; transition: transform .16s ease;
  background: radial-gradient(ellipse at 40% 28%, #b5673a, #7a2f14 55%, #3d1407); box-shadow: inset 0 -2px 3px rgba(0, 0, 0, .5), 0 1px 2px rgba(0, 0, 0, .6); }
.bead.h { top: 0; }
.bead.h.on { transform: translateY(var(--b)); }
.bead.e { top: calc(var(--b) * 2 + 5px + var(--b) * (var(--i) + 1)); }
.bead.e.on { transform: translateY(calc(var(--b) * -1)); }
.bead.on { background: radial-gradient(ellipse at 40% 28%, #f0a060, #b84a1c 55%, #5a1d08); }
.rod output { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font: 700 18px/22px var(--text); color: var(--gold-hi); }
.abacus.set { outline-color: var(--gold-hi); box-shadow: inset 0 0 14px #000, 0 0 22px 6px rgba(255, 214, 130, .85); }

@media (orientation: portrait) {
  /* the hint button drops to the edge of the tray, so the card can have the height */
  #puzzle { padding: calc(var(--sat) + 10px) 8px 30px; }
  #screen-play.in-panel .side { bottom: calc(var(--tray-h) + var(--sab) - 36px); }
  .pz { height: min(100%, 660px); }
}
/* older browsers without container queries: lay the close-ups out by which way the screen is held */
@supports not (container-type: size) {
  @media (orientation: landscape) {
    #puzzle[data-pz="drawer"] #pz-body { flex-direction: row; gap: 18px; }
    #puzzle[data-pz="drawer"] .pz-clue { flex: 0 1 190px; }
  }
  @media (orientation: portrait) {
    .pz-head { height: auto; grid-template-columns: minmax(0, 1fr) auto; padding-bottom: 6px; }
    #pz-say { grid-column: 1 / -1; grid-row: 2; height: 38px; padding-right: 8px; }
    .lt { flex-direction: column; align-items: center; }
    .lt .paper { flex: 1; align-self: stretch; }
    .lt-tools { flex-direction: row; }
    .mj { --c: 5; --t: min(13.5vw, calc(9 * var(--vh)), 64px); }
  }
}

/* ---------- the journal, the codex, the playtest survey ---------- */
#modal.wide .card { width: min(94vw, 640px); }
.tabs { display: flex; gap: 6px; justify-content: center; margin: 2px 0 10px; flex-wrap: wrap; }
.tabs button { position: relative; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(138, 100, 36, .6); background: rgba(255, 240, 210, .4); color: var(--ink); font: 700 15px/1 var(--text); }
.tabs button[aria-selected="true"] { background: linear-gradient(180deg, #e0392a, var(--red-deep)); color: var(--cream); border-color: var(--gold); }
.tabs button.new::after, .round-btn.new::after, .btn.new::after { content: ''; position: absolute; right: -2px; top: -2px; width: 10px; height: 10px; border-radius: 50%; background: #ff5a3c; box-shadow: 0 0 0 2px #fff3d6, 0 0 8px #ff5a3c; }
.btn.new { position: relative; }
.journal { max-height: min(56vh, 460px); overflow-y: auto; text-align: left; }
.journal ul.notes { margin: 0 0 6px; padding-left: 20px; }
.journal ul.notes li { margin: 4px 0; font-size: 16px; line-height: 1.25; color: var(--ink); }
.person { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid rgba(138, 100, 36, .35); }
.person .face { width: 64px; height: 76px; object-fit: cover; object-position: 50% 12%; border-radius: 6px; border: 1.5px solid var(--gold-lo); flex: none; background: #2a1209; }
.person b { font: 700 18px/1.1 var(--text); color: var(--red-deep); }
.person small { display: block; font: italic 500 14px/1.2 var(--text); color: var(--ink-soft); margin: 2px 0 4px; }
.person p { margin: 3px 0; font-size: 15.5px; line-height: 1.25; text-align: left; }
.person.new b::after { content: ' ●'; color: #e0392a; font-size: 12px; vertical-align: 3px; }
.person ul.rel { margin: 4px 0 0; padding-left: 18px; font-size: 14.5px; color: var(--ink-soft); }
.survey { text-align: left; max-height: min(58vh, 480px); overflow-y: auto; }
.survey .q { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 0; border-bottom: 1px dashed rgba(138, 100, 36, .35); font-size: 15px; }
.survey .scale { display: flex; gap: 4px; flex: none; }
.survey .scale button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--gold-lo); background: rgba(255, 240, 210, .5); color: var(--ink); font: 700 14px/1 var(--text); }
.survey .scale button.on { background: var(--red-deep); color: var(--cream); }
.survey .free { display: block; margin-top: 8px; font-size: 15px; }
.survey textarea { width: 100%; margin-top: 4px; font: 15px/1.3 var(--text); border-radius: 6px; border: 1px solid var(--gold-lo); background: rgba(255, 248, 230, .8); padding: 6px; }
pre.data { max-height: 46vh; overflow: auto; text-align: left; font: 11px/1.35 ui-monospace, monospace; background: rgba(255, 248, 230, .7); padding: 8px; border-radius: 6px; white-space: pre-wrap; word-break: break-all; }
.going-tag { position: absolute; right: 6px; top: 6px; z-index: 1; padding: 3px 8px; border-radius: 999px; background: rgba(124, 16, 13, .9); border: 1px solid var(--gold); color: var(--cream); font: 700 11px/1 var(--text); letter-spacing: .04em; }
.glow.cool { background: radial-gradient(circle, rgba(150, 190, 255, .45), rgba(120, 160, 255, 0) 70%) !important; }


/* ---------- shared by the Act I close-ups ---------- */
.shake { animation: shake .45s ease; }
.pz-row { flex: none; display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; max-width: 100%; }
.pz-row .btn { font-size: 14px; min-height: 36px; padding: 4px 16px; }
.hint-ring-pz { fill: none; stroke: #ffe59a; stroke-width: 2.5; filter: drop-shadow(0 0 3px #ffae3d); animation: hintpulse 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }

/* chapter 2: the two photographs */
.photos { display: flex; gap: 3%; width: min(100cqw, 100cqh * 3.2); justify-content: center; }
.photos figure { margin: 0; flex: 1; padding: 2.2%; background: #f1e6cc; border-radius: 2px; box-shadow: 0 8px 18px rgba(0, 0, 0, .65); transform: rotate(-1.2deg); }
.photos figure + figure { transform: rotate(1.4deg); }
svg.photo { display: block; width: 100%; height: auto; cursor: crosshair; filter: sepia(.35) contrast(1.05); }
.found-ring { fill: none; stroke: #c4241a; stroke-width: 2.2; stroke-dasharray: 3 1.6; animation: ringin .35s ease-out both; transform-box: fill-box; transform-origin: center; }
@keyframes ringin { from { transform: scale(1.6); opacity: 0; } }
@container stage (max-aspect-ratio: 5/4) { .photos { flex-direction: column; width: min(100cqw, 100cqh * .7); } }

/* chapter 2: the pantry */
.pantry { position: relative; width: min(92cqw, 100cqh * 1.25, 440px); aspect-ratio: 1.25; border-radius: 8px; background: #120804; box-shadow: 0 10px 26px rgba(0, 0, 0, .7); perspective: 1000px; }
.pantry-in { position: absolute; inset: 8%; display: grid; place-items: center; border-radius: 4px; background: linear-gradient(#2a1209, #140804); box-shadow: inset 0 0 30px #000; }
.rbox { position: relative; width: 52%; aspect-ratio: 1.6; border-radius: 6px; display: grid; place-items: center; cursor: pointer;
  background: linear-gradient(rgba(255, 200, 140, .12), rgba(0, 0, 0, .35)), url(art/ui/wood.webp) center / 200px, #5a2c14; border: 2px solid #c9952f; box-shadow: 0 6px 14px rgba(0, 0, 0, .7); }
.rbox-lid { position: absolute; left: -2px; right: -2px; top: -2px; height: 30%; border-radius: 6px 6px 2px 2px; background: inherit; border: 2px solid #c9952f; transform-origin: 50% 0; transition: transform 1s cubic-bezier(.3, 0, .2, 1); }
.pantry.unlocked .rbox-lid { transform: rotateX(70deg) translateY(-40%); }
.rbox .pz-slot.key { width: 34%; height: auto; aspect-ratio: 1; }
.pantry.unlocked .rbox .pz-slot { border-color: var(--gold-hi); box-shadow: 0 0 18px 4px rgba(255, 214, 130, .8); }
.pantry-door { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7%; border-radius: 8px; transform-origin: 0 50%;
  background: linear-gradient(rgba(255, 200, 140, .06), rgba(0, 0, 0, .35)), url(art/ui/wood.webp) center / 300px, #3d1c0e; border: 2px solid var(--gold-lo);
  box-shadow: inset 0 0 0 6px rgba(20, 8, 4, .5), inset 0 0 30px rgba(0, 0, 0, .6); transition: transform 1.3s cubic-bezier(.5, 0, .2, 1); }
.pantry.open .pantry-door { transform: rotateY(-100deg); pointer-events: none; }
.dials { display: flex; gap: 5%; padding: 4% 6%; border-radius: 10px; background: linear-gradient(#a0672a, #5d3410); box-shadow: inset 0 2px 4px rgba(255, 220, 160, .4), 0 4px 10px rgba(0, 0, 0, .6); }
.dial { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dial output { display: grid; place-items: center; width: clamp(38px, 13cqw, 58px); aspect-ratio: .82; border-radius: 6px; font: 700 clamp(22px, 8cqw, 34px)/1 var(--text); color: #2a1406; touch-action: none; cursor: ns-resize;
  background: linear-gradient(#f3e3bd, #c9a86a 50%, #f3e3bd); box-shadow: inset 0 0 6px rgba(0, 0, 0, .55); }
.dial button { width: clamp(30px, 10cqw, 44px); height: clamp(22px, 7cqw, 30px); border: 0; padding: 0; background: none; position: relative; }
.dial button::before { content: ''; position: absolute; left: 50%; top: 50%; border: 9px solid transparent; transform: translate(-50%, -50%); }
.dial .up::before { border-bottom: 12px solid #f8e2a4; border-top: 0; }
.dial .down::before { border-top: 12px solid #f8e2a4; border-bottom: 0; }
.pantry-door .try { font-size: 15px; min-height: 38px; padding: 4px 18px; }

/* chapter 2: the sealed scroll */
.scroll-sheet { width: min(80cqw, 100cqh, 330px); aspect-ratio: 1; padding: 6%; border-radius: 4px; transform: rotate(-1deg);
  background: linear-gradient(rgba(255, 244, 214, .3), rgba(190, 150, 90, .25)), url(art/ui/paper.webp) center / 400px, var(--paper); box-shadow: 0 14px 30px rgba(0, 0, 0, .7), inset 0 0 30px rgba(120, 70, 20, .35); }
.seal-svg { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.seal-box { fill: none; stroke: #8a2f1c; stroke-width: 1.5; }
.seal-wax { fill: #b77a3e; opacity: .88; }
.cover { transition: opacity 1.2s ease, transform 1.2s ease; transform-origin: 50% 50%; }
.lifted .cover { opacity: 0; transform: translateY(-14px) scale(1.04); }
.guide { fill: none; stroke: rgba(70, 30, 10, .35); stroke-width: 7; stroke-linecap: round; }
.ink { fill: none; stroke: #5a1d08; stroke-width: 6.5; stroke-linecap: round; opacity: 0; transition: opacity .4s ease; }
.ink.on { opacity: 1; }
.wet { fill: none; stroke: rgba(90, 30, 8, .55); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.start { fill: #ffe59a; opacity: 0; }
.start.show { animation: startdot 2.4s ease-out; }
@keyframes startdot { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
.dot { stroke: rgba(40, 10, 0, .6); stroke-width: 1; }
.dot.red { fill: #d23a2a; } .dot.green { fill: #2f8a4c; } .dot.blue { fill: #2f5fb3; } .dot.amber { fill: #e3a32c; }
.pz-clue.seq { display: flex; gap: 10px; padding: 8px 14px; }
.pz-clue.seq .dot { width: 18px; height: 18px; border-radius: 50%; display: block; border: 1px solid rgba(40, 10, 0, .6); }
.pz-clue .dot.red { background: #d23a2a; } .pz-clue .dot.green { background: #2f8a4c; } .pz-clue .dot.blue { background: #2f5fb3; } .pz-clue .dot.amber { background: #e3a32c; }

/* chapter 2: the stove lanterns */
.stove { display: flex; flex-direction: column; align-items: center; gap: 8%; width: min(94cqw, 100cqh * 1.7, 520px); padding: 5% 4% 4%; border-radius: 10px;
  background: linear-gradient(#3a1a0e, #1c0c06); border: 2px solid var(--gold-lo); box-shadow: inset 0 -30px 50px rgba(255, 120, 40, .12), 0 10px 26px rgba(0, 0, 0, .7); transition: box-shadow 1s ease; }
.stove.alight { box-shadow: inset 0 -40px 70px rgba(255, 140, 50, .55), 0 0 40px 8px rgba(255, 150, 60, .35), 0 10px 26px rgba(0, 0, 0, .7); }
.lamps { display: flex; justify-content: space-around; width: 100%; gap: 4%; }
.lamp { --c: #d23a2a; width: clamp(48px, 17cqw, 92px); aspect-ratio: .62; padding: 0; border: 0; border-radius: 40% 40% 18% 18%; position: relative;
  background: radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--c) 30%, #1a0c06), #120804 75%); box-shadow: inset 0 0 0 2px rgba(201, 149, 47, .6), 0 4px 8px rgba(0, 0, 0, .6); transition: background .15s ease, box-shadow .15s ease; }
.lamp i { position: absolute; left: 50%; top: 42%; width: 22%; aspect-ratio: .6; border-radius: 50% 50% 45% 45%; transform: translate(-50%, -50%); background: rgba(255, 220, 160, .14); }
.lamp.green { --c: #2f9a54; } .lamp.blue { --c: #3a6fd0; } .lamp.amber { --c: #f0a830; }
.lamp.lit { background: radial-gradient(ellipse at 50% 55%, #fff4d6, var(--c) 45%, color-mix(in srgb, var(--c) 40%, #120804) 85%); box-shadow: inset 0 0 0 2px #f8e2a4, 0 0 26px 8px var(--c); }
.lamp.lit i { background: #fffbe8; box-shadow: 0 0 10px 4px #fff2c0; }
.stove.cold .lamp, .stove.watch .lamp { cursor: default; }
.stove.dark .lamp { filter: brightness(.45); }
.rounds { display: flex; gap: 10px; }
.rounds i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--gold); background: rgba(0, 0, 0, .4); }
.rounds i.on { background: var(--gold-hi); box-shadow: 0 0 8px 2px rgba(255, 214, 130, .8); }

/* chapter 2: the dumbwaiter motor */
svg.wires { width: min(92cqw, 100cqh, 360px); height: auto; aspect-ratio: 1; }
.wbox { fill: #24120a; stroke: var(--gold-lo); stroke-width: 2; }
.feed { stroke: #c9952f; stroke-width: 5; stroke-linecap: round; }
.fusebox { fill: #efe6d2; stroke: #6b4a2a; stroke-width: 1; }
.ncell { fill: #3a1d11; stroke: rgba(201, 149, 47, .35); stroke-width: 1; cursor: pointer; }
.node .arms { transition: transform .22s ease; transform-box: fill-box; transform-origin: center; pointer-events: none; }
.node .arms path { stroke: #7a5a3a; stroke-width: 6; stroke-linecap: round; }
.node .arms circle { fill: #7a5a3a; }
.node.on .arms path { stroke: #f2c45a; filter: drop-shadow(0 0 2px #ffcf6a); }
.node.on .arms circle { fill: #f2c45a; }
.wlamp { fill: #3a2414; stroke: #c9952f; stroke-width: 1.5; transition: fill .3s ease; }
.wlamp.lit { fill: #fff0b0; filter: drop-shadow(0 0 5px #ffd36a); }
svg.wires.done .wbox { stroke: var(--gold-hi); }

/* chapter 3: the wall of drawers */
.drawers { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2.2%; width: min(96cqw, 100cqh * 2.1, 600px); padding: 2.4%; border-radius: 8px;
  background: linear-gradient(rgba(255, 200, 140, .06), rgba(0, 0, 0, .35)), url(art/ui/wood.webp) center / 300px, #2e150a; box-shadow: 0 10px 26px rgba(0, 0, 0, .7), inset 0 0 0 3px rgba(20, 8, 4, .6); }
.hd { position: relative; aspect-ratio: 1.15; padding: 0; border: 0; border-radius: 4px; background: #140804; overflow: hidden; perspective: 400px; }
.hd-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: radial-gradient(#4a2a14, #1a0c06); }
.hd-in svg { width: 52%; height: auto; }
.hd-in small { font: 600 clamp(9px, 2.2cqw, 13px)/1 var(--text); color: var(--cream); }
.hd-front { position: absolute; inset: 0; display: grid; place-items: center; transition: transform .35s ease;
  background: linear-gradient(rgba(255, 200, 140, .12), rgba(0, 0, 0, .25)), url(art/ui/wood.webp) center / 160px, #6a3518; border: 1.5px solid #3a1a0c; box-shadow: inset 0 0 0 3px rgba(255, 200, 140, .08); }
.hd-front i { width: 26%; height: 10%; border-radius: 0 0 50% 50%; border: 2px solid #d9a53c; border-top: 0; }
.hd.up .hd-front { transform: translateY(-88%); }
.hd.gone .hd-in { box-shadow: inset 0 0 0 2px var(--gold-hi); }

/* chapter 3: the parcels */
.parcels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4%; width: min(92cqw, 100cqh * 1.5, 480px); }
.parcel { position: relative; aspect-ratio: 1.1; padding: 0; border: 0; border-radius: 6px; background: linear-gradient(160deg, #cfa87a, #a07a4c); box-shadow: 0 6px 12px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(60, 30, 10, .5); }
.parcel .string { position: absolute; inset: 0; background: linear-gradient(90deg, transparent 47%, #6b4a2a 47%, #6b4a2a 53%, transparent 53%), linear-gradient(transparent 47%, #6b4a2a 47%, #6b4a2a 53%, transparent 53%); }
.parcel .tag { position: absolute; right: 6%; bottom: 8%; width: 44%; aspect-ratio: 1; border-radius: 4px; display: grid; place-items: center; background: #f3e5c6; border: 1.5px solid #3f7a3a; box-shadow: 0 2px 4px rgba(0, 0, 0, .5); }
.parcel .tag svg { width: 78%; }
/* every tag frayed a different way; only the odd one's tear is the kitchen label's shape */
.parcel.torn.t0 .tag { clip-path: polygon(0 0, 100% 0, 100% 78%, 70% 86%, 44% 80%, 20% 92%, 0 84%); }
.parcel.torn.t1 .tag { clip-path: polygon(8% 0, 100% 0, 100% 100%, 0 100%, 0 30%, 14% 18%); }
.parcel.torn.t2 .tag { clip-path: polygon(0 0, 100% 0, 100% 42%, 78% 55%, 58% 46%, 36% 62%, 18% 52%, 0 64%); }
.parcel.torn.t3 .tag { clip-path: polygon(0 0, 88% 0, 100% 12%, 100% 100%, 0 100%); }
.parcel.torn.t4 .tag { clip-path: polygon(0 0, 100% 0, 100% 100%, 64% 100%, 52% 88%, 40% 100%, 0 100%); }
.parcel.torn.t5 .tag { clip-path: polygon(0 10%, 30% 0, 100% 0, 100% 100%, 0 100%); }
.parcel.torn.mended .tag { clip-path: none; box-shadow: 0 0 16px 4px rgba(255, 214, 130, .85); }
.parcel.picked { outline: 2px solid var(--gold-hi); outline-offset: 3px; }
.parcel.peek, .hd.peek, .shadow.peek, .loose.peek, .wc.peek, .earth.peek, .gap.peek { animation: peek 1.1s ease-in-out infinite; }
@keyframes peek { 50% { filter: drop-shadow(0 0 8px #ffd36a) brightness(1.25); } }

/* chapter 3: the cipher wheel */
.cipher { display: flex; align-items: center; gap: 4%; width: min(96cqw, 640px); justify-content: center; }
svg.wheel { width: min(46cqw, 92cqh, 280px); height: auto; touch-action: none; cursor: grab; flex: none; }
.wheel .rim { fill: #3a2410; stroke: #c9952f; stroke-width: 1.5; }
.wheel .band { fill: none; stroke: #8a6424; stroke-width: 11; }
.wheel .ring:nth-of-type(2) .band { stroke: #a07a34; } .wheel .ring:nth-of-type(3) .band { stroke: #b58a3c; }
.wheel .ring { transition: transform .18s ease; }
.wheel .num { font: 700 6.5px/1 var(--text); fill: #fff3d0; pointer-events: none; }
.wheel .hub { fill: #c9952f; stroke: #6b4a1c; }
.wheel .pointer { fill: #e0392a; stroke: #fff3d0; stroke-width: .6; }
.cnote { flex: 1; min-width: 0; max-width: 320px; padding: 12px 16px; border-radius: 3px; transform: rotate(1deg); color: #3b2412;
  background: linear-gradient(rgba(255, 244, 214, .3), rgba(190, 150, 90, .25)), url(art/ui/paper.webp) center / 400px, var(--paper); box-shadow: 0 8px 18px rgba(0, 0, 0, .6); }
.cnote p { margin: 4px 0; font: 500 clamp(15px, 4.6cqw, 22px)/1.15 'Caveat', 'LXGW WenKai', cursive; color: #8a7a68; letter-spacing: .02em; filter: blur(.3px); transition: color .3s ease; }
.cnote p.clear { color: #3b2412; filter: none; }
@container stage (max-aspect-ratio: 1/1) { .cipher { flex-direction: column; } svg.wheel { width: min(70cqw, 52cqh, 260px); } .cnote { max-width: 100%; } }

/* chapter 3: the sooty photograph */
.frame-wrap { position: relative; height: min(96cqh, 100cqw * 1.1, 420px); aspect-ratio: .8; padding: 0; border: 8px solid #3a2414; border-radius: 3px; box-shadow: 0 10px 26px rgba(0, 0, 0, .75), inset 0 0 0 2px #c9952f; background: #d8c39a; }
.frame-wrap svg { display: block; width: 100%; height: 100%; }
.frame-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.oldphoto .marktext { font: 700 5.6px/1 var(--text); fill: #8a2416; letter-spacing: .02em; }
:lang(zh) .oldphoto .marktext { font-family: 'LXGW WenKai', serif; font-size: 7.5px; }
.frame-wrap.clean { animation: pageglow 1.7s ease-out both; }

/* chapter 4: frames and shadows */
.shadow-wall { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2.5%; width: min(96cqw, 100cqh * 3.4, 620px); padding: 3% 2.5%; border-radius: 6px;
  background: radial-gradient(ellipse at 20% 70%, #f6e2bc, #d9bf92 60%, #b89a6c); box-shadow: 0 10px 26px rgba(0, 0, 0, .7); }
.shadow { position: relative; aspect-ratio: .9; padding: 0; border: 0; background: none; }
.shadow svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.shadow .sil { transform: skewX(-16deg) scale(1.08, .94); transform-origin: 50% 100%; }   /* the lamp throws them at a slant */
.sil .outline { fill: rgba(60, 36, 20, .62); }
.sil .ribs { display: none; }
.frame .outline { fill: none; stroke: #c9952f; stroke-width: 2.2; }
.frame .ribs { fill: none; stroke: #a07a34; stroke-width: 1.4; }
.shadow .frame { filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .5)); }
.shadow.empty-glow .sil .outline { fill: rgba(140, 30, 20, .75); }
.shadow.empty-glow { animation: peek 1.1s ease-in-out 3; }
.frames-row { gap: 8px; }
.loose { width: clamp(42px, 13cqw, 70px); aspect-ratio: .9; padding: 2px; border-radius: 8px; border: 1.5px solid rgba(201, 149, 47, .5); background: rgba(10, 4, 2, .5); }
.loose svg { width: 100%; height: 100%; }
.loose.held { border-color: var(--gold-hi); box-shadow: 0 0 12px 3px rgba(255, 214, 130, .7); transform: translateY(-4px); }
.loose.used { opacity: .15; pointer-events: none; }

/* chapter 4: the sliding panel */
.slider { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; width: min(80cqw, 92cqh, 330px); aspect-ratio: 1; padding: 3px; border-radius: 4px; background: #1a0a05; box-shadow: 0 10px 26px rgba(0, 0, 0, .7); }
.slider .tile { padding: 0; border: 0; border-radius: 2px; background-size: 300% 300%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35); transition: transform .12s ease; }
.slider .tile.gap { background: rgba(255, 220, 160, .06); box-shadow: inset 0 3px 8px rgba(0, 0, 0, .8); }
.slider.whole { gap: 0; box-shadow: 0 0 30px 8px rgba(255, 214, 130, .6); }
.slide-ref { width: 64px; height: 64px; border-radius: 3px; box-shadow: 0 4px 10px rgba(0, 0, 0, .6); }

/* chapter 4: the four panels */
.panels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3%; width: min(96cqw, 100cqh * 2.6, 560px); }
.lpanel { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10% 6% 8%; border-radius: 40% 40% 12px 12px / 22% 22% 12px 12px; border: 2px solid #e9b84a;
  background: radial-gradient(ellipse at 50% 40%, #e2553c, #a5281a 70%); box-shadow: 0 8px 16px rgba(0, 0, 0, .6), inset 0 0 18px rgba(255, 200, 120, .35); }
.lpanel svg { width: 86%; background: #f0d6a0; border-radius: 50%; padding: 6%; }
.lpanel small { font: 700 clamp(11px, 2.6cqw, 14px)/1 var(--text); color: var(--cream); }
.panels.set .lpanel { box-shadow: 0 0 24px 6px rgba(255, 214, 130, .75), inset 0 0 18px rgba(255, 220, 140, .6); }

/* chapter 4: light through the seam */
svg.lampscene { width: min(96cqw, 100cqh * 1.54, 560px); height: auto; touch-action: none; border-radius: 6px; background: #120804; box-shadow: 0 10px 26px rgba(0, 0, 0, .7); }
.lampscene .wall { fill: #3a2a1c; }
.lampscene.lit .wall { fill: #8a6a48; }
.lampscene .beam, .lampscene .beam-spot, .lampscene .btn-shadow { opacity: 0; transition: opacity .4s ease; }
.lampscene.lit .beam-spot { opacity: .25; fill: #ffe2a0; }
.lampscene.through .beam { opacity: .28; fill: #ffd98a; }
.lampscene.through .beam-spot { opacity: .7; }
.lampscene.through .btn-shadow { opacity: 1; fill: #2a1a10; cursor: pointer; }
.lampscene .btn-shadow .hole { fill: #ffe2a0; }
.lampscene.done .btn-shadow { animation: peek 1s ease-in-out 2; }
.lampscene .lampbase { fill: #b8862a; } .lampscene .glass { fill: rgba(255, 240, 200, .18); stroke: #d9b060; stroke-width: 1; }
.lampscene .flame { fill: none; } .lampscene.lit .flame { fill: #ffcf5a; filter: drop-shadow(0 0 4px #ffb030); }
.lampscene .lan-body { fill: #b2402c; stroke: #e9b84a; stroke-width: 1.5; cursor: grab; }
.lampscene .lan-ribs { stroke: #7a2416; stroke-width: 1; }
.lampscene .seam { fill: #1a0a05; stroke: #e9b84a; stroke-width: .6; }
.lampscene.lit .seam { fill: #ffe6a8; }
.lampscene .caught { fill: #c9952f; stroke: #5a3a10; stroke-width: .6; }
.lampscene .lan-hub { fill: #e9b84a; }
.lampscene .spin { transition: transform .12s linear; transform-box: view-box; }
.lampscene .turn { font-size: 20px; min-width: 46px; }

/* chapter 5: the garden board (word search) */
.wgrid { position: relative; display: grid; grid-template-columns: repeat(var(--w), 1fr); width: min(94cqw, 100cqh * var(--w) / var(--h) * .94, 520px); padding: 2%; border-radius: 6px; touch-action: none; user-select: none;
  background: linear-gradient(rgba(255, 244, 214, .2), rgba(150, 120, 80, .2)), #8a8378; box-shadow: 0 10px 26px rgba(0, 0, 0, .7), inset 0 0 0 3px rgba(60, 50, 40, .5); }
.wc { display: grid; place-items: center; aspect-ratio: 1; font: 700 clamp(14px, 4.6cqw, 26px)/1 var(--text); color: #2a2018; cursor: pointer; border-radius: 50%; }
:lang(zh) .wc { font-family: 'LXGW WenKai', serif; }
.wc.sel { background: rgba(255, 214, 130, .55); }
.wlines { position: absolute; inset: 2%; width: 96%; height: 96%; pointer-events: none; overflow: visible; }
.wl { stroke: rgba(190, 50, 30, .45); stroke-width: .62; stroke-linecap: round; vector-effect: none; }
.wl.gold { stroke: rgba(230, 170, 40, .6); }
.wlist { display: flex; flex-wrap: wrap; gap: 4px 14px; justify-content: center; }
.wlist span.got { text-decoration: line-through; text-decoration-color: #b8321f; opacity: .7; }
.wlist span.secret.got { text-decoration: none; opacity: 1; color: #8a5a12; }

/* chapter 5: the well and its two jugs */
.well { display: flex; gap: 6%; justify-content: center; width: min(96cqw, 560px); }
.jug { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.jug-body { position: relative; width: clamp(60px, 18cqw, 100px); height: clamp(80px, 34cqh, 150px); border-radius: 18px 18px 26px 26px; overflow: hidden; border: 2px solid var(--gold-lo); background: rgba(20, 10, 6, .7); }
.jug.smalljug .jug-body { height: clamp(56px, 22cqh, 96px); }
.jug .level { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(#6aa8d8, #2f6a9a); transition: height .45s ease; }
.jug-body b { position: absolute; left: 0; width: 22%; bottom: calc(var(--k) * 100%); border-top: 1.5px solid rgba(255, 238, 203, .55); }
.jug output { font: 700 16px/1 var(--text); color: var(--gold-hi); }
.jug-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.jug-acts .btn { font-size: 13px; min-height: 32px; padding: 3px 8px; }

/* chapter 5: digging, and the tin */
.dig { position: relative; width: min(90cqw, 100cqh * 1.2, 420px); aspect-ratio: 1.2; }
.earth { position: absolute; inset: 0; border-radius: 50% 50% 12px 12px / 30% 30% 12px 12px; cursor: pointer; background: radial-gradient(ellipse at 50% 40%, #5a3a22, #3a2414 70%); box-shadow: inset 0 10px 30px rgba(0, 0, 0, .6); }
.earth .hole { position: absolute; left: 50%; top: 50%; width: calc(var(--d) * 70%); height: calc(var(--d) * 46%); transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(#140a04, #2a1a0e); transition: all .3s ease; }
.tin { position: absolute; left: 50%; top: 50%; width: 66%; padding: 6% 4%; transform: translate(-50%, -30%) scale(.6); opacity: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 10px; border-radius: 8px;
  background: linear-gradient(160deg, #c8361f, #8a1d10); border: 3px solid #e9b84a; box-shadow: 0 10px 22px rgba(0, 0, 0, .7); transition: all .7s cubic-bezier(.2, 1.2, .4, 1); }
.dig.up .tin { opacity: 1; transform: translate(-50%, -50%); pointer-events: auto; }
.tin.open { box-shadow: 0 0 30px 8px rgba(255, 214, 130, .8); }
.tin .dials { background: linear-gradient(#e9b84a, #a07a34); }

/* chapter 5: the back gate */
svg.gate { width: min(80cqw, 80cqh, 330px); height: auto; }
.gwood { fill: #3a2414; stroke: #6b4320; stroke-width: .12; }
.grail { stroke: #7a5232; stroke-width: .5; }
.gap .hole path { fill: #0e0603; stroke: rgba(201, 149, 47, .6); stroke-width: .06; stroke-dasharray: .2 .12; }
.gap .fill path { fill: #8a5a30; stroke: #c9952f; stroke-width: .05; opacity: 0; transition: opacity .3s ease; }
.gap.filled .fill path { opacity: 1; }
.ghit { fill: transparent; cursor: pointer; }
.beadg { fill: #2f9a54; stroke: #bfe8c8; stroke-width: .08; opacity: 0; transition: opacity 1s ease .6s; }
.gate.whole .beadg { opacity: 1; filter: drop-shadow(0 0 .2px #fff); }
.gpieces { gap: 10px; }
.gpiece { width: clamp(46px, 13cqw, 70px); aspect-ratio: 1; padding: 6px; border-radius: 8px; border: 1.5px solid rgba(201, 149, 47, .5); background: rgba(10, 4, 2, .5); }
.gpiece svg { width: 100%; height: 100%; }
.gpiece .pc path { fill: #8a5a30; stroke: #c9952f; stroke-width: .06; }
.gpiece .pc { transition: transform .2s ease; }
.gpiece.held { border-color: var(--gold-hi); box-shadow: 0 0 12px 3px rgba(255, 214, 130, .7); }
.gpiece.used { opacity: .15; pointer-events: none; }

/* ---------- dialogue ---------- */
#dialog {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  padding: 12px calc(var(--sar) + 12px) calc(var(--sab) + 12px) calc(var(--sal) + 12px);
  background: linear-gradient(0deg, rgba(8, 3, 2, .88) 0%, rgba(8, 3, 2, .5) 45%, rgba(8, 3, 2, .22) 100%); cursor: pointer;
}
.dlg-portrait { flex: none; height: min(calc(44 * var(--vh)), 400px); aspect-ratio: 0.78; margin: 0 0 -26px 4px; pointer-events: none; position: relative; z-index: 1; }
.dlg-portrait:empty { display: none; }
.dlg-portrait img { width: 100%; height: 100%; object-fit: contain; object-position: 50% 100%; display: block; filter: drop-shadow(0 0 18px rgba(255, 160, 70, .35)) drop-shadow(0 10px 20px rgba(0, 0, 0, .7)); animation: portrait .45s ease both; }
@keyframes portrait { from { opacity: 0; transform: translateX(-24px); } }
.dlg-box { width: 100%; min-height: 112px; padding: 30px 34px 26px; }
.dlg-name {
  position: absolute; left: 26px; top: -15px; z-index: 2; padding: 5px 20px 6px; border-radius: 999px;
  font: 700 14px/1 var(--display); color: var(--cream); letter-spacing: .05em;
  background: linear-gradient(180deg, #e0392a, var(--red-deep)); border: 1.5px solid var(--gold); box-shadow: 0 3px 8px rgba(0, 0, 0, .55);
}
.dlg-name:empty { display: none; }
.dlg-text { font: 600 clamp(18px, 2.6vw, 23px)/1.28 var(--text); min-height: 2.56em; }
.dlg-next { position: absolute; right: 30px; bottom: 26px; width: 0; height: 0; border: 8px solid transparent; border-top: 11px solid var(--red-deep); border-bottom: 0; opacity: 0; }
#dialog.done .dlg-next { opacity: 1; animation: nudge .9s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(5px); } }
.dlg-skip { position: absolute; right: calc(var(--sar) + 14px); top: calc(var(--sat) + 58px); padding: 7px 18px; border-radius: 999px; background: rgba(20, 8, 4, .75); border: 1px solid rgba(226, 180, 88, .6); color: var(--gold-hi); font: 700 14px/1 var(--text); letter-spacing: .1em; text-transform: uppercase; }
#dialog.narrator { align-items: center; }
#dialog.noface .dlg-portrait { display: none; }
#dialog.narrator .dlg-portrait { display: none; }
#dialog.narrator .dlg-box { max-width: 720px; text-align: center; }
#dialog.narrator .dlg-text { font-style: italic; font-weight: 500; }
/* Nai Nai's note (style 'note'): her own hand on the paper, a little askew */
#dialog.note .dlg-box { transform: rotate(-1.2deg); }
#dialog.note .dlg-text { font: 500 clamp(24px, 3.4vw, 34px)/1.15 'Caveat', 'LXGW WenKai', 'Segoe Script', cursive; color: #4a2a10; font-style: normal; }
:lang(zh) #dialog.note .dlg-text { font-size: clamp(21px, 2.9vw, 29px); }
/* fx 'dark' (the opening): black, then the lanterns stutter back on */
#blackout { position: fixed; inset: 0; z-index: 39; background: #050202; pointer-events: none; }
#blackout.lift { animation: relight 3.4s ease-out forwards; }
@keyframes relight { 0% { opacity: 1; } 22% { opacity: .93; } 30% { opacity: .62; } 36% { opacity: .9; } 48% { opacity: .45; } 55% { opacity: .7; } 72% { opacity: .25; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #blackout.lift { animation: relight-soft 1.2s ease forwards; } @keyframes relight-soft { to { opacity: 0; } } }

/* ---------- paper (the letter, the rhyme) ---------- */
.paper {
  position: relative; width: min(92vw, 560px); max-height: calc(82 * var(--vh)); overflow: auto; padding: 26px 34px 40px; transform: rotate(-1.2deg);
  background: linear-gradient(rgba(255, 244, 214, .3), rgba(190, 150, 90, .25)), url(art/ui/paper.webp) center / 520px, var(--paper);
  color: #3b2412; border-radius: 3px; box-shadow: 0 20px 60px rgba(0, 0, 0, .8), inset 0 0 50px rgba(120, 70, 20, .4);
  animation: unfold .6s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes unfold { from { transform: rotate(-5deg) scale(.7) translateY(40px); opacity: 0; } }
.paper-text { font: 500 clamp(19px, min(3.2vw, calc(5.4 * var(--vh))), 27px)/1.22 'Caveat', 'LXGW WenKai', 'Segoe Script', cursive; white-space: pre-line; }
.seal { position: absolute; right: 22px; bottom: 14px; width: 46px; height: 46px; border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  background: radial-gradient(circle at 36% 30%, #ef5a45, #a8160f 55%, #5f0906); box-shadow: inset 0 0 0 5px rgba(120, 10, 6, .55), inset 0 0 0 6.5px rgba(255, 150, 120, .25), 0 3px 6px rgba(0, 0, 0, .5); }
.seal::after { content: ''; position: absolute; inset: 13px; border: 2px solid rgba(255, 170, 140, .45); transform: rotate(45deg); }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 14px; background: rgba(8, 3, 2, .74); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.card { width: min(100%, 440px); max-height: calc(calc(100 * var(--vh)) - 28px); overflow: auto; padding: 40px 38px 30px; text-align: center; animation: cardin .38s cubic-bezier(.2, 1.3, .4, 1) both; scrollbar-width: none; }
@keyframes cardin { from { transform: scale(.82) translateY(16px); opacity: 0; } }
.card h3 { margin: 0 0 8px; font: 700 clamp(20px, 3vw, 25px)/1.1 var(--display); color: var(--red-deep); }
.card p { margin: 6px 0; font-size: 18px; line-height: 1.25; }
.card small { font: italic 500 16px/1.2 var(--text); color: var(--ink-soft); }
.card .over { margin: 0 0 6px; font: 700 13px/1 var(--text); letter-spacing: .22em; text-transform: uppercase; color: var(--gold-lo); }
.acts { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-top: 16px; }
.card .btn.ghost { background: rgba(90, 50, 20, .1); border-color: var(--gold-lo); color: var(--ink); }
.facts { display: flex; justify-content: center; gap: 10px; margin: 10px 0 6px; }
.facts div { flex: 1; max-width: 104px; padding: 7px 4px 6px; border-radius: 8px; background: rgba(110, 66, 24, .13); border: 1px solid rgba(138, 100, 36, .45); font: 600 12px/1 var(--text); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }
.facts b { display: block; margin-bottom: 4px; font: 700 23px/1 var(--text); letter-spacing: 0; color: var(--red-deep); }
.reveal { position: relative; width: 132px; height: 132px; margin: 2px auto 8px; display: grid; place-items: center; }
.reveal .rays { position: absolute; inset: -22px; border-radius: 50%;
  background: repeating-conic-gradient(from 0deg, rgba(226, 160, 50, .55) 0deg 9deg, transparent 9deg 22.5deg);
  -webkit-mask: radial-gradient(closest-side, #000 30%, transparent 96%); mask: radial-gradient(closest-side, #000 30%, transparent 96%);
  animation: spin 16s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reveal .spr { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(60, 30, 0, .55)); animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(2deg); } }
.inv { text-align: left; }
.inv h4 { margin: 12px 0 6px; font: 700 13px/1 var(--text); letter-spacing: .2em; text-transform: uppercase; color: var(--gold-lo); border-bottom: 1px solid rgba(138, 100, 36, .45); padding-bottom: 5px; }
.inv .row { display: flex; gap: 12px; align-items: center; padding: 5px 0; }
.inv .row .spr { width: 54px; height: 54px; object-fit: contain; flex: none; filter: drop-shadow(0 3px 4px rgba(60, 30, 0, .5)); }
.inv .row b { color: var(--red-deep); font-size: 19px; }
.inv .row p { margin: 2px 0 0; font-size: 16px; line-height: 1.15; }
.inv .none { font-style: italic; font-weight: 500; color: var(--ink-soft); margin: 4px 0; }

.petals { position: absolute; inset: 0; overflow: hidden; pointer-events: none; display: none; }
#modal.win .petals { display: block; }
.petals i { position: absolute; top: -30px; width: var(--w); height: calc(var(--w) * .72); border-radius: 80% 10% 80% 10%;
  background: linear-gradient(135deg, #ffd9e2, #f48aa6); opacity: .9; animation: petal 7s linear infinite; }
@keyframes petal { 0% { transform: translate(0, calc(-5 * var(--vh))) rotate(var(--r)); } 50% { transform: translate(9vw, calc(52 * var(--vh))) rotate(calc(var(--r) + 200deg)); } 100% { transform: translate(-4vw, calc(112 * var(--vh))) rotate(calc(var(--r) + 420deg)); } }

#toast { position: fixed; left: 50%; bottom: calc(var(--tray-h) + var(--sab) + 18px); z-index: 70; transform: translate(-50%, 12px); padding: 9px 22px; border-radius: 999px; pointer-events: none; opacity: 0;
  background: linear-gradient(180deg, #3a1a0e, #170905); border: 1.5px solid var(--gold); color: var(--gold-hi); font: 700 17px/1.1 var(--text); box-shadow: 0 8px 22px rgba(0, 0, 0, .65); transition: opacity .25s ease, transform .25s ease; white-space: nowrap; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- layouts ---------- */
@media (orientation: landscape) {
  #dialog { flex-direction: row; align-items: flex-end; }
  .dlg-portrait { height: min(calc(88 * var(--vh)), 560px); margin: 0 -54px -12px -6px; }
  .dlg-box { flex: 1; width: auto; margin-bottom: 4px; padding-left: 62px; }
  .dlg-name { left: 54px; }
  #dialog.narrator { justify-content: center; }
  #dialog.narrator .dlg-box { flex: 0 1 720px; padding-left: 34px; }
}
@media (orientation: portrait) {
  :root { --tray-h: 126px; }
  #screen-title h1 { font-size: clamp(46px, 15.5vw, 104px); }
  #screen-title h1 span { display: block; }
  .title-box { padding-top: calc(var(--sat) + calc(5 * var(--vh))); padding-bottom: calc(var(--sab) + calc(9 * var(--vh))); }
  .emblem { width: 58px; }
  .kicker { font-size: 22px; margin-top: 12px; }
  .chapters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #tray { flex-direction: column; gap: 5px; }
  #items { flex: 1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: min-content; gap: 3px 2px; overflow: visible; }
  .item { max-width: none; }
  .item .nm { font-size: 12px; }
  .bar h2 { font-size: clamp(12px, 4.3vw, 17px); }
  .p-title b { font-size: 15px; }
  #screen-map .pill { font-size: 16px; min-height: 30px; padding-right: 10px; gap: 5px; } #screen-map .pill .ico { width: 20px; height: 20px; }
  .side { top: auto; bottom: calc(var(--tray-h) + var(--sab) + 16px); transform: none; }
}
/* small upright phones: with the whole room in view the buttons would sit on its corner, so they drop onto the tray edge */
@media (orientation: portrait) and (max-height: 640px) {
  .side { bottom: calc(var(--tray-h) + var(--sab) - 30px); gap: 8px; }
  #p-zin, #p-zout { width: 46px; height: 46px; }
}
@media (orientation: portrait) and (min-width: 620px) { .chapters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (orientation: landscape) and (max-width: 720px) { .chapters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* short landscape screens (phones on their side): the tray goes down the left so the room gets the full height */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --tray-h: 0px; --tray-w: calc(150px + var(--sal)); }
  #tray { right: auto; top: 0; width: var(--tray-w); height: auto; flex-direction: column; gap: 5px;
    padding: calc(var(--sat) + 6px) 6px calc(var(--sab) + 5px) calc(var(--sal) + 6px);
    border-top: 0; border-right: 2px solid var(--gold); box-shadow: 1px 0 0 3px #1a0b06, 5px 0 0 0 var(--gold-lo), 14px 0 26px rgba(0, 0, 0, .6);
    background-size: auto, 400% 100%, auto; }
  #items { flex: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 2px; overflow: visible; }
  .item { max-width: none; gap: 2px; }
  .item .nm { font-size: 11.5px; }
  .slot { width: 40px; height: 40px; }
  .tip { max-width: min(100vw - var(--tray-w) - var(--sar) - 160px, 520px); }   /* clear of the buttons down the right */
}
@media (orientation: portrait), (orientation: landscape) and (max-height: 520px) {
  #count { align-self: center; width: auto; height: 26px; flex: none; flex-direction: row; gap: 6px; padding: 0 16px; border-radius: 999px; border-width: 1.5px; }
  #count b { font-size: 17px; } #count span { font-size: 11px; }
}
@media (max-height: 460px) {
  .card { padding: 24px 30px 20px; }
  .panel::before { inset: 4px; border-width: 13px; border-image: var(--fret) 30 / 13px stretch; }
  .card p { margin: 4px 0; font-size: 17px; }
  .st3.big i { width: 38px; height: 38px; } .st3.big i:nth-child(2) { width: 48px; height: 48px; }
  .reveal { width: 96px; height: 96px; margin-bottom: 4px; }
  .acts { margin-top: 10px; }
  .btn { min-height: 40px; }
  .btn.big { min-height: 48px; font-size: 19px; }
  .round-btn { width: 48px; height: 48px; } .round-btn.sm { width: 38px; height: 38px; }
  .side { gap: 11px; }
  .tip { top: calc(var(--sat) + 58px); }
}
@media (min-height: 700px) and (orientation: landscape) {
  :root { --tray-h: 104px; }
  .slot { width: 58px; height: 58px; } .item .nm { font-size: 15px; } #count { width: 74px; height: 74px; } #count b { font-size: 23px; }
}

/* the very shortest screens: slimmer buttons, so they stay off the cabinet in the corner of the room */
@media (orientation: landscape) and (max-height: 300px) {
  .side { right: calc(var(--sar) + 6px); gap: 8px; }
  #p-zin, #p-zout { width: 42px; height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .mote, .petals { display: none !important; }
}
