/* ui.css — every word the player reads is DOM, layered over the WebGL canvas.
   Look: parchment cards, brown ink lines, round serif type, big clear buttons. */
:root {
  --paper: #f8eed6; --paper2: #eedcb4; --ink: #3d2816; --ink2: #6d4c30; --line: #6b4727; --red: #a8321f; --gold: #d2a04a;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --kai: "Kaiti SC", "STKaiti", "KaiTi", "Songti SC", "Noto Serif CJK SC", serif;
  --vh: 100vh;
  --u: calc(var(--vh) / 100);
  --card: linear-gradient(175deg, #fcf4de 0%, #f1e0b8 100%);
  --card-shadow: 0 10px 28px rgba(40, 20, 6, 0.38), inset 0 0 0 2px rgba(255, 255, 255, 0.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2a1c12; font-family: var(--serif); color: var(--ink);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: default; }
#stage, img { -webkit-touch-callout: none; }
#ui { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.zh { font-family: var(--kai); color: #9a4630; font-size: 0.94em; }
.ghost { visibility: hidden; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* cursors that say what a tap will do */
#stage[data-cursor="talk"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36'%3E%3Cpath d='M5 5h26a3 3 0 0 1 3 3v14a3 3 0 0 1-3 3H17l-8 7v-7H5a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3z' fill='%23fff7e2' stroke='%235b3a1e' stroke-width='2.5'/%3E%3Ccircle cx='11' cy='15' r='2.2' fill='%235b3a1e'/%3E%3Ccircle cx='18' cy='15' r='2.2' fill='%235b3a1e'/%3E%3Ccircle cx='25' cy='15' r='2.2' fill='%235b3a1e'/%3E%3C/svg%3E") 9 30, pointer; }
#stage[data-cursor="puzzle"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36'%3E%3Cpath d='M5 5h26a3 3 0 0 1 3 3v14a3 3 0 0 1-3 3H17l-8 7v-7H5a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3z' fill='%23a8321f' stroke='%234d1509' stroke-width='2.5'/%3E%3Crect x='16' y='8' width='4' height='9' rx='2' fill='%23fff1d2'/%3E%3Ccircle cx='18' cy='21' r='2.3' fill='%23fff1d2'/%3E%3C/svg%3E") 9 30, pointer; }
#stage[data-cursor="look"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36'%3E%3Ccircle cx='15' cy='15' r='10' fill='%23fff7e2' fill-opacity='.55' stroke='%235b3a1e' stroke-width='3'/%3E%3Cpath d='M23 23l9 9' stroke='%235b3a1e' stroke-width='5' stroke-linecap='round'/%3E%3C/svg%3E") 15 15, pointer; }
#stage[data-cursor="walk"] { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='36'%3E%3Cellipse cx='18' cy='27' rx='12' ry='5' fill='%23fff7e2' fill-opacity='.7' stroke='%235b3a1e' stroke-width='2.5'/%3E%3Cpath d='M18 4v15m-6-6l6 7 6-7' fill='none' stroke='%235b3a1e' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 18 27, pointer; }
body.can-grab #stage { cursor: grab; }
body.grabbing #stage { cursor: grabbing; }

#loader { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #f8ecd0, #e2c891); color: var(--ink2); font-size: 20px; font-style: italic; transition: opacity 0.5s 0.1s; z-index: 50; }
#loader .ico { font-size: 44px; animation: sealPulse 1.2s ease-in-out infinite; }
body.loaded #loader { opacity: 0; pointer-events: none; }
@keyframes sealPulse { 50% { transform: scale(1.1) rotate(-8deg); } }
.wipe { position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, #f8ecd0, #e0c48a); opacity: 0; transition: opacity 0.24s ease; z-index: 40; }
.wipe.on { opacity: 1; }
@keyframes pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes popS { 0% { scale: 0.7; } 60% { scale: 1.12; } 100% { scale: 1; } }
body.instant *, body.instant *::before, body.instant *::after { transition: none !important; animation-duration: 0.001s !important; }
body.instant #loader { display: none; }

/* a round coin with a square hole (no writing on it), used as an icon */
.ico { display: inline-block; flex: none; }
.ico.coin { width: 1.25em; height: 1.25em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f0cf86, #c2913f 70%); box-shadow: inset 0 0 0 0.11em #8a5f24, 0 1px 2px rgba(40, 20, 6, 0.4); position: relative; }
.ico.coin::after { content: ""; position: absolute; inset: 33%; background: var(--paper); box-shadow: 0 0 0 0.09em #8a5f24; }
.ico.seal { width: 1.05em; height: 1.05em; border-radius: 0.2em; background: var(--red); box-shadow: inset 0 0 0 0.1em #fff1d2, 0 0 0 0.08em var(--red); transform: rotate(-6deg); }
.ico.coin.fly { position: absolute; font-size: 30px; z-index: 30; pointer-events: none; }
.ico.coin.fly::after { background: transparent; box-shadow: 0 0 0 0.09em #8a5f24, inset 0 0 0 1em rgba(60, 36, 12, 0.55); }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; opacity: 0; transition: opacity 0.6s; }
.hud.on { opacity: 1; }
.hud > * { transition: opacity 0.35s, transform 0.35s; }
.hud.quiet > .hud-goal, .hud.quiet > .hud-strip, .hud.quiet > .hud-place, .hud.quiet > .hud-marks { opacity: 0; pointer-events: none; }
.hud.quiet > .hud-strip { transform: translate(-50%, 20px); }
.hud.away > * { opacity: 0 !important; pointer-events: none !important; }
.hud-place { position: absolute; left: calc(var(--u) * 2.2); top: calc(var(--u) * 2.2); display: flex; flex-direction: column; padding: 6px 14px 7px; background: rgba(60, 38, 20, 0.78); color: #fff3d8; border-radius: 10px; border: 1.5px solid rgba(255, 226, 170, 0.4); }
.hud-place strong { font-size: clamp(13px, calc(var(--u) * 2), 17px); }
.hud-place span { font-size: clamp(11px, calc(var(--u) * 1.6), 14px); font-style: italic; opacity: 0.85; }
.hud-goal { position: absolute; left: 50%; top: calc(var(--u) * 2.2); transform: translateX(-50%); max-width: min(560px, 52vw); display: flex; align-items: center; gap: 10px; padding: 8px 18px 9px 10px;
  background: var(--card); border: 2.5px solid var(--line); border-radius: 12px; box-shadow: var(--card-shadow); opacity: 0; }
.hud-goal.on { opacity: 1; }
.hud-goal.pop { animation: goalPop 0.5s cubic-bezier(0.2, 1.5, 0.4, 1); }
@keyframes goalPop { 0% { transform: translateX(-50%) scale(0.86); } 60% { transform: translateX(-50%) scale(1.05); } 100% { transform: translateX(-50%) scale(1); } }
.hud-goal .tag { flex: none; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; color: #fff1d2; background: var(--red); padding: 3px 9px 4px; border-radius: 6px; }
.hud-goal p { margin: 0; font-size: clamp(14px, calc(var(--u) * 2.3), 19px); line-height: 1.22; }
.hud-counters { position: absolute; right: calc(var(--u) * 2.2); top: calc(var(--u) * 2.2); display: flex; gap: 8px; }
.hud-chip { display: flex; align-items: center; gap: 7px; padding: 6px 13px 7px 10px; background: var(--card); border: 2.5px solid var(--line); border-radius: 999px; box-shadow: var(--card-shadow); font-weight: 700; font-size: clamp(14px, calc(var(--u) * 2.3), 19px); }
.hud-chip.pop { animation: pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1); }
.hud-strip { position: absolute; left: 50%; bottom: calc(var(--u) * 2); transform: translateX(-50%); display: flex; gap: 0; padding: 5px 8px; background: rgba(60, 38, 20, 0.72); border-radius: 999px; border: 1.5px solid rgba(255, 226, 170, 0.35); pointer-events: auto; }
.stop { position: relative; display: flex; align-items: center; gap: 7px; padding: 5px 14px 5px 6px; margin: 0 2px; background: transparent; border: 0; color: #f6e6c6; font-size: clamp(12px, calc(var(--u) * 1.9), 15px); border-radius: 999px; transition: background 0.2s; }
.stop i { width: 1.7em; height: 1.7em; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-weight: 700; background: #f6e6c6; color: #4a2e16; border: 2px solid #4a2e16; }
.stop:hover { background: rgba(255, 236, 190, 0.16); }
.stop.here { background: rgba(255, 236, 190, 0.22); }
.stop.here i { background: var(--gold); }
.stop.next i { animation: nextPulse 1.2s ease-in-out infinite; }
.stop.done i { background: #6f9a6a; color: #fff; border-color: #2f5a34; }
@keyframes nextPulse { 50% { box-shadow: 0 0 0 5px rgba(255, 214, 120, 0.55); transform: scale(1.1); } }
.hud-title { position: absolute; left: calc(var(--u) * 6); bottom: calc(var(--u) * 12); color: #fff8e6; text-shadow: 0 2px 14px rgba(40, 20, 6, 0.75), 0 0 2px rgba(40, 20, 6, 0.9);
  display: flex; flex-direction: column; gap: 2px; opacity: 0; transform: translateY(12px); transition: opacity 0.9s, transform 0.9s; }
.hud-title.on { opacity: 1; transform: none; }
.hud-title strong { font-size: clamp(26px, calc(var(--u) * 6.6), 62px); }
.hud-title > span { font-size: clamp(14px, calc(var(--u) * 2.8), 26px); font-style: italic; }
.hud-title::before { content: ""; width: 54px; height: 3px; background: var(--gold); margin-bottom: 8px; border-radius: 2px; }
.hud-toast { position: absolute; left: 50%; top: calc(var(--u) * 11); transform: translate(-50%, -8px); padding: 6px 16px 7px; background: rgba(60, 38, 20, 0.86); color: #fff3d8; border-radius: 999px; font-size: clamp(13px, calc(var(--u) * 2.1), 17px); opacity: 0; }
.hud-toast.on { opacity: 1; transform: translate(-50%, 0); }
.mk-bubble { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); transform-origin: 0 0; width: 1.5em; height: 1.5em; display: grid; place-items: center; font-weight: 800; font-size: clamp(18px, calc(var(--u) * 3.3), 28px); color: #fff3d8;
  background: var(--red); border: 2.5px solid #5a140a; border-radius: 50% 50% 50% 6px; box-shadow: 0 4px 10px rgba(40, 20, 6, 0.35); opacity: 0; transition: opacity 0.25s; }
.mk-bubble.on { opacity: 1; animation: bob 0.9s ease-in-out infinite; }
@keyframes bob { 0%, 100% { margin-top: 0; } 50% { margin-top: -7px; } }

/* ---------- buttons ---------- */
.btn, .pz-continue, .insp-close { pointer-events: auto; flex: none; padding: 9px 26px 11px; font-size: clamp(16px, calc(var(--u) * 2.7), 21px); font-weight: 700; color: #fff3d8; background: linear-gradient(#b8402c, #932718); border: 2.5px solid #5a140a;
  border-radius: 999px; box-shadow: 0 5px 0 #5a140a, 0 10px 18px rgba(40, 20, 6, 0.35); transition: transform 0.08s, box-shadow 0.08s; }
.btn:active, .pz-continue:active, .insp-close:active { transform: translateY(4px); box-shadow: 0 1px 0 #5a140a; }
.btn.alt, .pz-hint, .pz-leave { color: #fff1d2; background: linear-gradient(#9a6a3a, #76492a); border-color: #4a2c14; box-shadow: 0 5px 0 #4a2c14, 0 9px 16px rgba(40, 20, 6, 0.35); }
.btn.alt:active, .pz-hint:active, .pz-leave:active { transform: translateY(4px); box-shadow: 0 1px 0 #4a2c14; }

/* ---------- dialogue ---------- */
.dlg { position: absolute; inset: 0; pointer-events: auto; cursor: pointer; }
.dlg::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(40, 22, 10, 0.42), rgba(40, 22, 10, 0) 42%); opacity: 0; transition: opacity 0.3s; }
.dlg.open::before { opacity: 1; }
.dlg-box { position: absolute; left: 50%; bottom: calc(var(--u) * 3); width: min(860px, 92vw); min-height: clamp(84px, calc(var(--u) * 15.5), 142px); padding: clamp(18px, calc(var(--u) * 3.4), 30px) clamp(20px, 3vw, 38px) clamp(12px, calc(var(--u) * 2.2), 22px);
  background: var(--card); border: 3px solid var(--line); border-radius: 16px; box-shadow: 0 14px 40px rgba(40, 20, 6, 0.5), inset 0 0 0 3px rgba(255, 255, 255, 0.45), inset 0 0 40px rgba(170, 120, 60, 0.14);
  transform: translate(-50%, 30px); opacity: 0; transition: transform 0.28s cubic-bezier(0.2, 1.2, 0.4, 1), opacity 0.2s; }
.dlg.open .dlg-box { transform: translate(-50%, 0); opacity: 1; }
.dlg-name { position: absolute; top: 0; left: clamp(18px, 3vw, 40px); transform: translateY(-58%) rotate(-1.5deg); padding: 5px 18px 6px; background: linear-gradient(#8f2c1e, #74200f); color: #fff1d2;
  font-weight: 700; font-size: clamp(15px, calc(var(--u) * 2.5), 21px); border-radius: 8px; border: 2px solid #4d1509; box-shadow: 0 3px 8px rgba(40, 20, 6, 0.4); white-space: nowrap; }
.dlg-box[data-side="right"] .dlg-name { left: auto; right: clamp(18px, 3vw, 40px); transform: translateY(-58%) rotate(1.5deg); }
.dlg-box[data-who="hero"] .dlg-name { background: linear-gradient(#d9772a, #b85c18); border-color: #7a3a0c; }
.dlg-box[data-who="cartgirl"] .dlg-name { background: linear-gradient(#8a6a44, #6d4f30); border-color: #46301a; }
.dlg-box[data-who="official"] .dlg-name { background: linear-gradient(#55545a, #3c3b40); border-color: #232226; }
.dlg-box.bump .dlg-name { animation: tabBump 0.3s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes tabBump { 0% { scale: 0.85; } 100% { scale: 1; } }
.dlg-text { margin: 0; font-size: clamp(18px, calc(var(--u) * 3.3), 30px); line-height: 1.3; color: var(--ink); text-wrap: pretty; }
.dlg-next { position: absolute; right: 16px; bottom: 8px; color: var(--red); font-size: 16px; animation: nudge 0.8s ease-in-out infinite; }
.dlg.typing .dlg-next, .dlg.choosing .dlg-next { visibility: hidden; }
@keyframes nudge { 50% { transform: translateY(4px); } }
.dlg-choices { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.dlg-choices:empty { display: none; }
.dlg-choice { pointer-events: auto; padding: 8px 18px 9px; font-size: clamp(15px, calc(var(--u) * 2.5), 21px); color: var(--ink); background: #fffaf0; border: 2.5px solid var(--line); border-radius: 12px; box-shadow: 0 4px 0 var(--line); }
.dlg-choice:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--line); }

/* ---------- puzzle intro card ---------- */
.pcard { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(40, 22, 10, 0); pointer-events: auto; transition: background 0.25s; }
.pcard.open { background: rgba(40, 22, 10, 0.42); }
.pcard-card { width: min(520px, 86vw); padding: clamp(16px, calc(var(--u) * 3.4), 30px) clamp(20px, 4vw, 38px) clamp(16px, calc(var(--u) * 3), 26px); text-align: center; background: var(--card); border: 3px solid var(--line); border-radius: 18px;
  box-shadow: 0 18px 50px rgba(40, 20, 6, 0.55), inset 0 0 0 3px rgba(255, 255, 255, 0.45); transform: translateY(24px) scale(0.92) rotate(-1deg); opacity: 0; transition: transform 0.32s cubic-bezier(0.2, 1.4, 0.4, 1), opacity 0.2s; }
.pcard.open .pcard-card { transform: none; opacity: 1; }
.pcard-no { display: inline-block; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: #fff1d2; background: var(--red); padding: 3px 12px 4px; border-radius: 6px; font-weight: 700; }
.pcard-card h2 { margin: 10px 0 6px; font-size: clamp(24px, calc(var(--u) * 5), 40px); line-height: 1.1; }
.pcard-blurb { margin: 0 0 6px; font-size: clamp(15px, calc(var(--u) * 2.6), 21px); color: var(--ink2); line-height: 1.3; }
.pcard-note { margin: 0 0 4px; font-size: 14px; font-style: italic; color: #9a6b3c; }
.pcard-row { display: flex; justify-content: center; gap: 14px; margin-top: clamp(10px, calc(var(--u) * 2.4), 20px); }

/* ---------- puzzle window (shared by all puzzles) ---------- */
.pz { position: absolute; inset: 0; }
.pz-head { position: absolute; left: calc(var(--u) * 2.5); top: calc(var(--u) * 2.5); width: min(430px, 46vw); padding: 12px 18px 13px; background: var(--card); border: 3px solid var(--line); border-radius: 14px;
  box-shadow: var(--card-shadow); transform: translateY(-16px); opacity: 0; transition: transform 0.4s 0.15s cubic-bezier(0.2, 1.3, 0.4, 1), opacity 0.3s 0.15s; }
.pz.open .pz-head { transform: none; opacity: 1; }
.pz-num { display: inline-block; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: #fff1d2; background: var(--red); padding: 2px 9px 3px; border-radius: 5px; font-weight: 700; }
.pz-head h2 { margin: 4px 0 3px; font-size: clamp(20px, calc(var(--u) * 4), 32px); line-height: 1.1; }
.pz-brief { margin: 0; font-size: clamp(13px, calc(var(--u) * 2.2), 18px); line-height: 1.3; color: var(--ink2); }
.pz-hint, .pz-leave { position: absolute; top: calc(var(--u) * 2.5); pointer-events: auto; padding: 8px 20px 9px; font-size: clamp(15px, calc(var(--u) * 2.4), 19px); font-weight: 700; border-width: 2.5px; border-style: solid; border-radius: 999px; transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s; }
.pz-hint { right: calc(var(--u) * 2.5); padding-left: 38px; }
.pz-leave { right: calc(var(--u) * 2.5 + clamp(104px, 9.5vw, 132px)); }
.pz-hint::before { content: "?"; position: absolute; left: 10px; top: 50%; width: 22px; height: 22px; margin-top: -11px; background: #ffe3a6; color: #5a3618; border-radius: 50%; font-size: 15px; line-height: 22px; }
.pz.won .pz-hint, .pz.won .pz-leave { opacity: 0; pointer-events: none; }
.pz-coach { position: absolute; left: calc(var(--u) * 1.8); bottom: calc(var(--u) * 1.8); display: flex; align-items: flex-end; gap: 10px; max-width: min(520px, 58vw); opacity: 0; transition: opacity 0.3s 0.3s; }
.pz-coach.on { opacity: 1; }
.pz-coach img { width: clamp(58px, calc(var(--u) * 11), 96px); height: clamp(58px, calc(var(--u) * 11), 96px); border-radius: 50%; object-fit: cover; object-position: 50% 30%; background: #f3e2bd; border: 3px solid var(--line); box-shadow: 0 5px 12px rgba(40, 20, 6, 0.45); flex: none; }
.pz-coach p { position: relative; margin: 0 0 calc(var(--u) * 1.6); padding: 10px 16px 11px; background: #fff8e6; border: 2.5px solid #5b3a1e; border-radius: 16px; font-size: clamp(14px, calc(var(--u) * 2.5), 20px); line-height: 1.28; box-shadow: 0 6px 14px rgba(40, 20, 6, 0.4); }
.pz-coach p::before { content: ""; position: absolute; left: -9px; bottom: 16px; width: 14px; height: 14px; background: #fff8e6; border-left: 2.5px solid #5b3a1e; border-bottom: 2.5px solid #5b3a1e; transform: rotate(45deg); }
.pz-coach.pop p { animation: pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1); transform-origin: 0 100%; }
.pz-coach[data-kind="bad"] p { border-color: #a3281b; background: #ffeede; }
.pz-coach[data-kind="found"] p, .pz-coach[data-kind="ok"] p { border-color: #2f6b4a; }
.pz.won .pz-coach { opacity: 0; }
.pz-chip { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); transform-origin: 0 0; white-space: nowrap; padding: 3px 10px 4px; border-radius: 999px; background: rgba(48, 28, 14, 0.84); color: #fff1d6; font-size: clamp(11px, calc(var(--u) * 1.9), 15px);
  opacity: 0; transition: opacity 0.15s; will-change: translate; border: 1.5px solid rgba(255, 226, 170, 0.35); }
.pz-chip .zh { color: #ffd896; }
.pz-chip.show { opacity: 0.92; }
.pz-chip.active { opacity: 1; border-color: #ffd27a; }
.pz-chip .badge:empty { display: none; }
.pz-chip .badge { margin-left: 7px; padding: 1px 8px 2px; border-radius: 999px; font-weight: 700; background: #2f7d4f; color: #fff; }
.pz-chip[data-tested="light"] .badge { background: #c2331f; }
.pz-chip.basket { opacity: 0.95; background: rgba(255, 244, 220, 0.94); color: #5a3618; border: 1.5px dashed #7a4b22; font-weight: 700; }
.pz.won .pz-chip { opacity: 0; }
.pz-readout { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); transform-origin: 0 0; width: clamp(34px, calc(var(--u) * 6.5), 54px); height: clamp(34px, calc(var(--u) * 6.5), 54px); border-radius: 50%; display: grid; place-items: center; font-size: clamp(20px, calc(var(--u) * 4), 34px);
  font-weight: 800; color: #fff; background: #2f7d4f; border: 3px solid #fff3d6; box-shadow: 0 4px 12px rgba(40, 20, 6, 0.5); opacity: 0; }
.pz-readout[data-kind="tilt"] { background: #c2731f; }
.pz-readout.on { opacity: 1; animation: popS 0.4s cubic-bezier(0.2, 1.6, 0.4, 1); }
.pz.won .pz-readout { opacity: 0; }
.pz-stamp { position: absolute; left: 50%; top: 42%; display: flex; align-items: center; gap: 0.22em; padding: 0.1em 0.34em 0.14em 0.26em; font-size: clamp(46px, calc(var(--u) * 12.5), 112px); font-weight: 800; font-style: italic;
  color: #fff3de; background: #be2418; border: 0.06em solid #fff3de; outline: 0.07em solid #be2418; border-radius: 0.14em; filter: url(#ink) drop-shadow(0 0.06em 0.12em rgba(40, 8, 2, 0.45)); opacity: 0;
  transform: translate(-50%, -50%) rotate(-9deg) scale(2.8); pointer-events: none; letter-spacing: -0.01em; white-space: nowrap; }
.pz-stamp .seal.coin { width: 0.72em; height: 0.72em; border-radius: 50%; background: #fff3de; position: relative; flex: none; }
.pz-stamp .seal.coin::after { content: ""; position: absolute; inset: 31%; background: #be2418; }
.pz-stamp.on { animation: stampIn 0.36s cubic-bezier(0.3, 0, 0.2, 1) forwards; }
@keyframes stampIn { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-9deg) scale(2.8); } 70% { opacity: 1; transform: translate(-50%, -50%) rotate(-9deg) scale(0.94); } 100% { opacity: 0.96; transform: translate(-50%, -50%) rotate(-9deg) scale(1); } }
.pz-note { position: absolute; left: 50%; bottom: calc(var(--u) * 5); width: min(680px, 88vw); padding: 14px 22px 16px; display: flex; align-items: center; gap: 18px; background: var(--card); border: 3px solid var(--line); border-radius: 16px;
  box-shadow: 0 14px 36px rgba(40, 20, 6, 0.55), inset 0 0 0 2px rgba(255, 255, 255, 0.4); transform: translate(-50%, 40px); opacity: 0; transition: transform 0.35s cubic-bezier(0.2, 1.3, 0.4, 1), opacity 0.25s; pointer-events: none; }
.pz-note.on { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.pz-note p { margin: 0; font-size: clamp(15px, calc(var(--u) * 2.7), 22px); line-height: 1.3; flex: 1; }

/* ---------- coin inspector ---------- */
.insp { position: absolute; inset: 0; color: #fff3d8; text-align: center; }
.insp-title { position: absolute; left: 50%; top: calc(var(--u) * 4); transform: translateX(-50%); margin: 0; font-size: clamp(22px, calc(var(--u) * 5), 40px); white-space: nowrap; text-shadow: 0 2px 12px rgba(40, 20, 6, 0.8); }
.insp-title .zh { color: #ffd98a; }
.insp-hint { position: absolute; left: 50%; top: calc(var(--u) * 4 + clamp(30px, calc(var(--u) * 7), 56px)); transform: translateX(-50%); margin: 0; font-style: italic; font-size: clamp(14px, calc(var(--u) * 2.6), 20px); opacity: 0.9; white-space: nowrap; text-shadow: 0 1px 8px rgba(40, 20, 6, 0.9); transition: opacity 0.3s; }
.insp-hint.off { opacity: 0; }
.insp-fact { position: absolute; left: 50%; bottom: calc(var(--u) * 5); width: min(640px, 86vw); padding: 14px 24px 16px; color: var(--ink); text-align: left; background: var(--card); border: 3px solid var(--line); border-radius: 16px;
  box-shadow: 0 14px 36px rgba(40, 20, 6, 0.55), inset 0 0 0 2px rgba(255, 255, 255, 0.4); transform: translate(-50%, 30px); opacity: 0; transition: transform 0.3s cubic-bezier(0.2, 1.3, 0.4, 1), opacity 0.2s; }
.insp-fact.on { transform: translate(-50%, 0); opacity: 1; }
.insp-fact.pop p { animation: pop 0.4s cubic-bezier(0.2, 1.5, 0.4, 1); transform-origin: 50% 100%; }
.insp-fact p { margin: 0; font-size: clamp(15px, calc(var(--u) * 2.9), 23px); line-height: 1.3; }
.insp-close { position: absolute; right: calc(var(--u) * 2.5); top: calc(var(--u) * 2.5); }

/* ---------- small landscape phones ---------- */
@media (max-height: 480px) {
  .hud-place { display: none; }
  .hud-goal { left: 8px; transform: none; max-width: 56vw; padding: 5px 12px 6px 8px; }
  .hud-goal.pop { animation: none; }
  .hud-strip { bottom: 6px; padding: 3px 6px; }
  .stop span { display: none; }
  .stop { padding: 3px 5px; }
  .dlg-box { min-height: 0; padding: 18px 20px 12px; bottom: 8px; }
  .pz-head { padding: 5px 12px 6px; width: auto; display: flex; align-items: center; gap: 10px; }
  .pz-head h2 { margin: 0; font-size: 19px; }
  .pz-brief { display: none; }
  .pz-coach { max-width: 52vw; }
  .pz-coach img { width: 48px; height: 48px; }
  .pz-coach p { margin-bottom: 4px; padding: 6px 11px 7px; }
  .pz-note { bottom: 8px; padding: 9px 14px 10px; }
  .insp-fact { bottom: 8px; padding: 9px 16px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .mk-bubble.on, .dlg-next, #loader .ico, .stop.next i { animation: none; }
}

/* ?hud=0: clean frames for art review */
#ui.no-hud .hud { display: none; }
/* Source evidence belongs to the modern visitor interface, above the ancient stage. */
.exam-source .exam-card{width:min(680px,88vw);max-height:90vh;overflow:auto;background:#f5f1e7;color:#24373d}
.exam-source-image{display:block;max-width:100%;height:min(42vh,340px);object-fit:contain;margin:12px auto 20px}
.label-exhibit{display:block;width:210px;height:130px;object-fit:contain;margin:0 auto 20px}
#ui[data-level="shang-s1"] .hud-place{top:76px}
body:has(#ui[data-level="shang-s1"] .exam-overlay:not([hidden])) .guide-toggle{visibility:hidden}
@media(max-height:450px){#ui[data-level="shang-s1"] .hud-place{display:none}}
/* Reserve the right-hand counters and museum Menu while keeping the goal readable. */
@media(max-width:1300px){#ui[data-level="shang-s1"] .hud-goal{left:12px;transform:none;max-width:min(560px,calc(100vw - 400px));animation:none}}

/* Phone puzzles resume from the same state when rotated back to landscape. */
.phone-landscape-prompt { width: min(88vw, 420px); padding: 28px; border: 2px solid #b29055; border-radius: 20px; background: var(--paper); color: var(--ink); text-align: center; }
.phone-landscape-prompt::backdrop { background: #16202df2; }
.phone-landscape-prompt h1 { font-size: 28px; margin: 0 0 18px; }
.phone-landscape-prompt p { font-size: 20px; line-height: 1.5; margin: 0; }
