:root {
  color-scheme: dark;
  --ink: #0b1012;
  --paper: #eee7d7;
  --muted: rgba(238, 231, 215, 0.64);
  --line: rgba(238, 231, 215, 0.24);
  --gold: #bd8a46;
  --gold-bright: #e4bc78;
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
  --ease-heavy: cubic-bezier(0.16, 1, 0.3, 1);
  --font-display: "Songti SC", "STSong", serif;
  --font-ui: "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --text-hero: clamp(38px, 4.35vw, 64px);
  --text-section: clamp(32px, 4vw, 52px);
  --text-body: clamp(13px, 1.05vw, 14px);
  --text-label: 11px;
  --text-micro: 8px;
}

* { box-sizing: border-box; }
html { background: var(--ink); scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--gold) var(--ink); }
html.is-guided-scrolling { scroll-behavior: auto; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  overscroll-behavior-y: none;
}
button, a { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, [tabindex="0"]:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 4px; }
button:active { transform: scale(.98); }
[hidden] { display: none !important; }

.experience { min-height: 900vh; }
.stage { position: fixed; inset: 0; min-height: 100vh; min-height: 100dvh; overflow: hidden; isolation: isolate; background: var(--ink); }
.visual-stack, .visual-layer, .atmosphere, .grain { position: absolute; inset: 0; }
.visual-stack { z-index: -2; overflow: hidden; background: #080d0f; }
.visual-layer {
  width: 100%; height: 100%; object-fit: cover; object-position: center;
  opacity: 0; transform: scale(1.012);
  transition: none;
  contain: layout paint style;
}
.visual-layer.is-active { opacity: 1; transform: scale(1); will-change: opacity, transform; }
.still-layer { filter: saturate(.9) contrast(1.03); }
.video-layer { display: block; pointer-events: none; }
.opening-orbit {
  z-index: 2; display: block; pointer-events: none; opacity: 0; transform: scale(1);
  transition: opacity 460ms ease; will-change: opacity;
}
.opening-orbit.is-orbit-visible { opacity: 1; }
.transition-veil {
  position: absolute; z-index: 3; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 52% 46%, rgba(83,53,32,.22), transparent 42%), linear-gradient(110deg, rgba(5,9,10,.98), rgba(8,12,13,.9));
  transition: none; will-change: opacity;
}
.atmosphere { z-index: 4; pointer-events: none; background: linear-gradient(90deg, rgba(5,9,10,.55), transparent 52%, rgba(5,9,10,.24)), linear-gradient(0deg, rgba(5,9,10,.74), transparent 40%, rgba(5,9,10,.22)); }
.grain, .overlay-scrim::after {
  z-index: 5; pointer-events: none; opacity: .08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

.topbar { position: absolute; z-index: 10; top: var(--safe-top); left: clamp(20px, 4.4vw, 72px); right: clamp(20px, 4.4vw, 72px); display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.brand { display: inline-grid; grid-template-columns: 40px auto; align-items: center; gap: 12px; color: var(--paper); text-decoration: none; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid rgba(228,188,120,.58); color: var(--gold-bright); font-family: var(--font-display); font-size: 22px; }
.brand-copy { display: grid; gap: 3px; }
.brand-copy b { font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: .18em; }
.brand-copy small { color: var(--muted); font-size: var(--text-micro); letter-spacing: .2em; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.load-state { color: var(--muted); font-size: var(--text-label); letter-spacing: .16em; transition: opacity 300ms ease; }
.load-state.is-ready { opacity: 0; }
.tour-trigger, .source-trigger, .dialog-close, .overlay-back {
  border: 0; border-bottom: 1px solid var(--line); padding: 5px 0 7px; background: transparent;
  color: var(--paper); font-size: var(--text-label); letter-spacing: .15em;
  transition: border-color 180ms ease, color 180ms ease;
}
.tour-trigger:hover, .tour-trigger[aria-pressed="true"], .source-trigger:hover, .dialog-close:hover, .overlay-back:hover { border-color: var(--gold-bright); color: var(--gold-bright); }

.story-copy { position: absolute; z-index: 8; left: clamp(22px, 8vw, 136px); bottom: clamp(104px, 18vh, 190px); width: min(620px, calc(100vw - 44px)); text-wrap: balance; transition: opacity 420ms ease, transform 580ms var(--ease-heavy); }
.story-copy > * { transition: opacity 380ms ease, transform 520ms var(--ease-heavy); }
.story-copy.is-changing > * { opacity: 0; transform: translateY(12px); }
.story-copy.is-motion-hidden { opacity: 0; transform: translateY(10px); pointer-events: none; }
body.is-auto-touring { touch-action: none; }
body.is-auto-touring .brand,
body.is-auto-touring .source-trigger,
body.is-auto-touring .chapter-rail { pointer-events: none; }
body.is-auto-touring .story-copy.is-motion-hidden { opacity: 1; transform: none; }
body.is-auto-touring .story-copy.is-motion-hidden > :not(.story-actions) { opacity: 0; transform: translateY(10px); }
.eyebrow, .lab-kicker { margin: 0 0 14px; color: var(--gold-bright); font-family: var(--font-display); font-size: var(--text-label); letter-spacing: .24em; }
.chapter-no { position: absolute; left: -68px; top: 35px; margin: 0; color: var(--muted); font-size: var(--text-micro); letter-spacing: .12em; writing-mode: vertical-rl; }
.story-copy h1 { margin: 0; font-family: var(--font-display); font-size: var(--text-hero); font-weight: 500; line-height: 1.06; letter-spacing: -.05em; text-shadow: 0 3px 28px rgba(0,0,0,.36); }
.story-copy[data-lines="2"] { width: min(650px, calc(100vw - 44px)); }
.story-copy[data-lines="3"] { width: min(540px, calc(100vw - 44px)); }
.story-copy[data-lines="3"] h1 { font-size: var(--text-hero); line-height: 1.03; }
.scene-body { max-width: 44ch; margin: 22px 0 0; color: rgba(238,231,215,.78); font-size: var(--text-body); line-height: 1.8; letter-spacing: .06em; }
.chapter-rail { position: absolute; z-index: 9; top: 50%; right: clamp(20px,4.4vw,72px); display: grid; grid-template-columns: 1px auto; align-items: stretch; gap: 16px; transform: translateY(-50%); transition: opacity 300ms ease; }
.rail-track { position: relative; display: block; width: 1px; background: var(--line); overflow: hidden; }
.rail-track i { position: absolute; inset: 0; background: var(--gold-bright); transform: translateY(-100%); will-change: transform; }
.rail-items { display: grid; gap: 16px; }
.rail-item { display: grid; grid-template-columns: 24px auto; gap: 10px; border: 0; padding: 0; background: transparent; color: var(--muted); text-align: left; transition: color 220ms ease, transform 300ms var(--ease-heavy); }
.rail-item:hover, .rail-item.is-active { color: var(--paper); transform: translateX(-4px); }
.rail-item b { font-size: var(--text-label); font-weight: 400; letter-spacing: .1em; }
.rail-item span { font-family: var(--font-display); font-size: var(--text-body); letter-spacing: .1em; white-space: nowrap; }
.scroll-cue { position: absolute; z-index: 8; left: 50%; bottom: var(--safe-bottom); display: grid; justify-items: center; gap: 8px; color: var(--muted); font-size: var(--text-micro); letter-spacing: .2em; transform: translateX(-50%); transition: opacity 300ms ease; }
.scroll-cue.is-hidden { opacity: 0; }
.scroll-cue i { position: relative; display: block; width: 1px; height: 28px; overflow: hidden; background: var(--line); }
.scroll-cue i::after { content: ""; position: absolute; inset: 0; background: var(--gold-bright); animation: cue 1.8s var(--ease-heavy) infinite; }
.disclaimer { position: absolute; z-index: 8; right: clamp(20px,4.4vw,72px); bottom: var(--safe-bottom); margin: 0; color: rgba(238,231,215,.38); font-family: var(--font-ui); font-size: var(--text-micro); font-style: italic; letter-spacing: .06em; }
.scroll-track { position: relative; z-index: 1; pointer-events: none; }
.scroll-track section { height: 150vh; height: 150dvh; }
/* 承载多段连续镜头的章节加长滚动行程，压低每像素对应的 seek 跨度 */
#scene-interior { height: 260vh; height: 260dvh; }
#scene-retreat { height: 250vh; height: 250dvh; }
.scroll-track::after { content: ""; display: block; height: 100vh; height: 100dvh; }

.guardian-entry {
  position: absolute; z-index: 12; left: 50%; top: 85%;
  width: max-content; opacity: 0; visibility: hidden; pointer-events: none;
  transform: translate(-50%,16px) scale(.94); clip-path: inset(48% 48% 48% 48%);
  transition: opacity 360ms ease, transform 620ms var(--ease-heavy), clip-path 680ms var(--ease-heavy), visibility 0s linear 680ms;
}
.guardian-entry.is-visible { opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%,0) scale(1); clip-path: inset(0); transition-delay: 0s; }
.guardian-entry > button {
  position: relative; display: grid; min-width: 168px; min-height: 44px; place-items: center;
  border: 0; padding: 10px 28px; overflow: hidden; background: rgba(5,9,10,.72);
  clip-path: polygon(14px 0,calc(100% - 14px) 0,100% 50%,calc(100% - 14px) 100%,14px 100%,0 50%);
  box-shadow: inset 0 0 0 1px rgba(228,188,120,.08), 0 12px 38px rgba(0,0,0,.5), 0 0 28px rgba(189,138,70,.08);
  backdrop-filter: blur(4px); color: var(--paper); font-size: var(--text-label); letter-spacing: .2em;
  transition: color 200ms ease, border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
}
.guardian-entry > button::before {
  content: ""; position: absolute; inset: 3px 5px; pointer-events: none;
  background: rgba(228,188,120,.68);
  clip-path: polygon(11px 0,calc(100% - 11px) 0,100% 50%,calc(100% - 11px) 100%,11px 100%,0 50%,11px 0,12px 2px,2px 50%,12px calc(100% - 2px),calc(100% - 12px) calc(100% - 2px),calc(100% - 2px) 50%,calc(100% - 12px) 2px,12px 2px,11px 0);
}
.guardian-entry > button:hover { border-color: var(--paper); background: rgba(5,9,10,.82); color: var(--gold-bright); box-shadow: inset 0 0 0 1px rgba(228,188,120,.12), 0 14px 42px rgba(0,0,0,.56), 0 0 32px rgba(189,138,70,.15); }
.guardian-entry.is-visible > button { animation: guardian-breathe 2800ms 640ms ease-in-out infinite; }
.guardian-guide { display: none; }

.guardian-overlay {
  position: fixed; z-index: 40; inset: 0; min-height: 100vh; min-height: 100dvh; overflow: auto;
  opacity: 0; visibility: hidden; pointer-events: none; overscroll-behavior: contain;
  transition: opacity 460ms var(--ease-heavy), visibility 0s linear 460ms;
}
.guardian-overlay.is-open { opacity: 1; visibility: visible; pointer-events: auto; transition-delay: 0s; }
.overlay-scrim { position: fixed; inset: 0; background: linear-gradient(110deg, rgba(5,9,10,.89), rgba(5,9,10,.67) 55%, rgba(5,9,10,.78)); backdrop-filter: blur(8px) saturate(.72); }
.overlay-scrim::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 42%, rgba(189,138,70,.11), transparent 44%); }
.overlay-scrim::after { content: ""; position: absolute; inset: 0; }
.overlay-topbar { position: fixed; z-index: 44; top: var(--safe-top); left: clamp(20px,4.4vw,72px); right: clamp(20px,4.4vw,72px); display: flex; justify-content: space-between; align-items: center; }
.overlay-topbar p { display: flex; gap: 16px; margin: 0; font-size: var(--text-label); letter-spacing: .16em; }
.overlay-topbar p span { color: var(--muted); }
.overlay-topbar p b { color: var(--gold-bright); font-weight: 500; }
.overlay-view { position: relative; z-index: 42; min-height: 100dvh; }

.lab-layout { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(280px,.55fr); min-height: 100dvh; padding: clamp(104px,14vh,150px) clamp(28px,6vw,94px) 54px; gap: clamp(24px,4vw,72px); align-items: center; }
.joinery-board { position: relative; min-height: 540px; display: grid; place-items: center; border-left: 1px solid rgba(228,188,120,.24); border-bottom: 1px solid rgba(228,188,120,.16); background: radial-gradient(circle at 50% 46%, rgba(228,188,120,.09), transparent 52%); contain: layout style paint; perspective: 900px; }
#jointSvg { width: min(100%,900px); max-height: 72vh; overflow: visible; user-select: none; }
.fit-guides { color: var(--gold-bright); pointer-events: none; }
.fit-target, .approach-guide { fill: none; stroke: currentColor; opacity: 0; transition: opacity 300ms ease; }
.fit-target { stroke-width: 2; stroke-dasharray: 7 8; }
.approach-guide { stroke-width: 1.8; stroke-dasharray: 5 8; marker-end: url(#guideArrow); }
.is-exploded .fit-target { opacity: .12; }
.is-exploded .approach-guide { opacity: .2; }
.joint-piece { cursor: default; filter: url(#jointShadow); transform-box: fill-box; transform-origin: center; transition: transform 1.15s var(--ease-heavy), opacity 320ms ease, filter 320ms ease; }
.piece-core { --explode-x: 0px; --explode-y: 108px; --explode-scale: .94; --explode-rotate: -1deg; --reject-x: 0px; --reject-y: 10px; }
.piece-left { --explode-x: -124px; --explode-y: 72px; --explode-scale: .88; --explode-rotate: -4deg; --reject-x: -10px; --reject-y: 6px; }
.piece-right { --explode-x: 116px; --explode-y: -68px; --explode-scale: .9; --explode-rotate: 4deg; --reject-x: 10px; --reject-y: -6px; }
.piece-lock { --explode-x: 14px; --explode-y: -142px; --explode-scale: .82; --explode-rotate: 2deg; --reject-x: 0px; --reject-y: -10px; }
.joint-piece .top { fill: url(#woodTop); }
.joint-piece .front { fill: url(#woodFront); }
.joint-piece .side { fill: url(#woodSide); }
.joint-piece .face { stroke: rgba(238,231,215,.16); stroke-width: 1.5; }
.touch-hit { fill: transparent; stroke: none; pointer-events: all; }
.cut-void, .fork-void, .saddle-cut { fill: rgba(18,12,11,.96); stroke: rgba(228,188,120,.28); stroke-width: 1.5; }
.cut-wall { fill: url(#cutWall); stroke: rgba(238,231,215,.12); stroke-width: 1.2; }
.cut-edge, .shoulder-line { fill: none; stroke: rgba(241,199,135,.76); stroke-width: 2; }
.tenon-end { fill: #b57946 !important; }
.wedge-tip { fill: #2d1c17; stroke: rgba(228,188,120,.3); stroke-width: 1.4; }
.grain-line { fill: none; stroke: rgba(240,193,129,.23); stroke-width: 2; pointer-events: none; }
.piece-label { fill: var(--gold-bright); font-family: var(--font-display); font-size: var(--text-label); letter-spacing: .08em; text-anchor: middle; opacity: 0; pointer-events: none; transition: opacity 260ms ease; }
.is-exploded .piece-label, .is-playing .piece-label { opacity: 1; }
.is-preview .joint-piece { transform: translate(0,0); }
.is-exploded .joint-piece, .is-playing .joint-piece:not(.is-locked) { transform: translate(var(--explode-x),var(--explode-y)) rotate(var(--explode-rotate)) scale(var(--explode-scale)); }
.is-playing .joint-piece { cursor: pointer; }
.is-playing .joint-piece:hover { filter: url(#jointShadow) drop-shadow(0 0 12px rgba(228,188,120,.42)); }
.is-playing .joint-piece[aria-disabled="true"]:not(.is-locked) { cursor: default; opacity: .26; pointer-events: none; filter: url(#jointShadow) saturate(.45); }
.joint-piece.is-locked { transform: translate(0,0) rotate(0) scale(1) !important; cursor: default; }
.joint-piece.is-locked .piece-label { opacity: 0; }
.joint-piece.is-locked .face { transition: filter 420ms ease, opacity 420ms ease; }
#jointSvg[data-assembled="2"] .piece-core,
#jointSvg[data-assembled="3"] .piece-core,
#jointSvg[data-assembled="4"] .piece-core { filter: url(#jointShadow) drop-shadow(-5px 4px 4px rgba(18,10,7,.72)); }
.piece-lock .wedge-face, .piece-lock .wedge-tip { transition: opacity 420ms ease; }
.piece-lock.is-locked.is-seated { transform: translate(0,92px) rotate(0) scale(1) !important; transition-duration: 580ms; }
.piece-lock.is-seated .wedge-face, .piece-lock.is-seated .wedge-tip { opacity: 0; }
.joint-piece.is-correct { animation: lock-pulse 680ms var(--ease-heavy); }
.joint-piece.is-wrong { animation: wrong-shake 420ms ease; }
.first-guide { opacity: 0; fill: var(--gold-bright); stroke: var(--gold-bright); stroke-width: 1.4; pointer-events: none; transition: opacity 280ms ease; }
.first-guide text { stroke: none; font-family: var(--font-display); font-size: var(--text-label); letter-spacing: .1em; text-anchor: end; }
.is-playing.is-first-step .first-guide { opacity: 1; animation: guide-breathe 1.6s ease-in-out infinite; }
.is-playing.is-first-step .piece-core { filter: url(#jointShadow) drop-shadow(0 0 13px rgba(228,188,120,.62)); }
#jointSvg[data-step="core"] .piece-core,
#jointSvg[data-step="left"] .piece-left,
#jointSvg[data-step="right"] .piece-right,
#jointSvg[data-step="lock"] .piece-lock { filter: url(#jointShadow) drop-shadow(0 0 13px rgba(228,188,120,.58)); }
#jointSvg[data-step="core"] [data-target="core"],
#jointSvg[data-step="left"] [data-target="left"],
#jointSvg[data-step="right"] [data-target="right"],
#jointSvg[data-step="lock"] [data-target="lock"] { opacity: .78; }
#jointSvg[data-step="core"] [data-for="core"],
#jointSvg[data-step="left"] [data-for="left"],
#jointSvg[data-step="right"] [data-for="right"],
#jointSvg[data-step="lock"] [data-for="lock"] { opacity: .9; animation: guide-breathe 1.45s ease-in-out infinite; }
.step-meter { position: absolute; left: 18px; right: 18px; bottom: 16px; display: grid; grid-template-columns: repeat(4,1fr); border-top: 1px solid var(--line); }
.step-meter span { display: flex; gap: 9px; padding: 13px 8px 0; color: rgba(238,231,215,.34); font-size: var(--text-label); letter-spacing: .12em; transition: color 220ms ease; }
.step-meter span.is-active { color: var(--paper); }
.step-meter span.is-done { color: var(--gold-bright); }
.step-meter i { font-style: normal; font-size: var(--text-micro); }
.lab-copy { align-self: center; max-width: 310px; }
.lab-copy h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-section); font-weight: 500; line-height: 1.12; letter-spacing: -.04em; text-wrap: balance; }
.lab-instruction { margin: 22px 0 0; color: var(--gold-bright); font-family: var(--font-display); font-size: var(--text-body); line-height: 1.6; letter-spacing: .14em; }
.timer { margin: 20px 0 0; color: var(--paper); font-family: var(--font-display); font-size: var(--text-body); }
.timer span { color: var(--gold-bright); font-size: 48px; font-variant-numeric: tabular-nums; }

.identity-view, .result-view { padding: clamp(100px,14vh,150px) clamp(24px,6vw,92px) 48px; }
.identity-view { display: grid; place-items: center; }
.identity-panel { width: min(100%,820px); text-align: center; }
.identity-panel h2, .result-copy h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-section); font-weight: 500; letter-spacing: -.05em; }
.completion-line { margin: 18px 0 42px; color: var(--muted); font-size: var(--text-body); }
.completion-line strong { color: var(--gold-bright); font-weight: 500; }
.identity-options { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: clamp(10px,2vw,22px); }
.identity-options button { position: relative; isolation: isolate; display: grid; justify-items: center; align-content: center; gap: 18px; min-height: 230px; border: 0; padding: 24px 12px 20px; overflow: hidden; background: linear-gradient(150deg, rgba(121,75,42,.72), rgba(39,26,22,.96)); clip-path: polygon(16% 0,84% 0,100% 10%,100% 90%,84% 100%,16% 100%,0 90%,0 10%); filter: drop-shadow(0 18px 26px rgba(0,0,0,.32)); transition: transform 320ms var(--ease-heavy), filter 260ms ease; }
.identity-options button::before { content: ""; position: absolute; z-index: -1; inset: 6px; border: 1px solid rgba(228,188,120,.48); clip-path: inherit; background: linear-gradient(180deg, rgba(228,188,120,.08), transparent 38%); }
.identity-options button::after { content: "守塔令"; position: absolute; top: 15px; color: rgba(238,231,215,.44); font-size: var(--text-micro); letter-spacing: .26em; }
.identity-options button:hover { transform: translateY(-8px); filter: drop-shadow(0 24px 34px rgba(0,0,0,.44)); }
.identity-options button:active { transform: translateY(-3px) scale(.98); }
.identity-options i { display: grid; width: 58px; height: 58px; place-items: center; border: 1px solid rgba(228,188,120,.66); color: var(--gold-bright); font-family: var(--font-display); font-size: var(--text-section); font-style: normal; transform: rotate(45deg); }
.identity-options i span { transform: rotate(-45deg); }
.identity-options b { color: var(--paper); font-family: var(--font-display); font-size: var(--text-body); font-weight: 400; letter-spacing: .12em; }
@media (min-width: 821px) {
  .identity-options i { font-size: clamp(27px, 2.35vw, 38px); }
}
.result-layout { width: min(100%,1200px); min-height: calc(100dvh - 200px); margin: auto; display: grid; grid-template-columns: minmax(0,.8fr) minmax(320px,.62fr); grid-template-rows: auto 1fr; gap: 12px clamp(36px,7vw,100px); align-items: center; }
.result-intro { grid-column: 1; grid-row: 1; align-self: end; margin: 0; color: var(--muted); font-size: var(--text-label); letter-spacing: .14em; }
.result-intro span, .result-intro strong { display: block; }
.result-intro strong { margin-top: 8px; color: var(--paper); font-family: var(--font-display); font-size: clamp(28px,3.4vw,48px); font-weight: 500; letter-spacing: .02em; }
.result-copy { grid-column: 1; grid-row: 2; }
.poster-preview { grid-column: 2; grid-row: 1 / 3; }
.result-copy > p:not(.lab-kicker,.save-note) { max-width: 38ch; margin: 26px 0 0; color: var(--muted); font-size: var(--text-body); line-height: 1.9; }
.save-note { margin-top: 18px; color: rgba(238,231,215,.42); font-size: var(--text-micro); }
.poster-preview { position: relative; justify-self: end; width: min(46vh,430px); aspect-ratio: 3/4; overflow: hidden; border: 1px solid rgba(228,188,120,.32); box-shadow: 0 30px 100px rgba(0,0,0,.52); }
.poster-preview img, .poster-shade { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.poster-shade { background: linear-gradient(0deg, rgba(5,9,10,.96) 0%, rgba(5,9,10,.18) 58%, rgba(5,9,10,.42) 100%); }
.poster-type { position: absolute; inset: auto 9% 8%; }
.poster-type strong { display: block; font-family: var(--font-display); font-size: var(--text-section); font-weight: 500; letter-spacing: -.06em; }
.poster-type p { margin: 12px 0 0; color: var(--muted); font-size: var(--text-label); letter-spacing: .12em; }
.poster-type i { position: absolute; right: 0; bottom: 0; display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--gold); color: var(--gold-bright); font-family: var(--font-display); font-size: 22px; font-style: normal; }

.source-dialog { width: min(560px,calc(100vw - 32px)); max-height: min(760px,calc(100dvh - 32px)); border: 1px solid rgba(228,188,120,.34); padding: clamp(28px,5vw,58px); overflow: auto; background: rgba(13,19,20,.97); color: var(--paper); box-shadow: 0 30px 100px rgba(0,0,0,.58); backdrop-filter: blur(18px); }
.source-dialog::backdrop { background: rgba(2,5,6,.76); backdrop-filter: blur(7px); }
.dialog-close { position: absolute; top: 24px; right: 26px; }
.dialog-kicker { margin: 0 0 20px; color: var(--gold-bright); font-size: var(--text-micro); letter-spacing: .22em; }
.source-dialog h2 { margin: 0 0 24px; font-family: var(--font-display); font-size: var(--text-section); font-weight: 500; }
.source-dialog > p:not(.dialog-kicker) { color: rgba(238,231,215,.72); font-size: var(--text-body); line-height: 1.85; }
.source-dialog dl { margin: 28px 0; border-top: 1px solid var(--line); }
.source-dialog dl div { display: grid; grid-template-columns: 72px 1fr; gap: 12px; border-bottom: 1px solid var(--line); padding: 15px 0; }
.source-dialog dt { color: var(--gold-bright); font-family: var(--font-display); font-size: var(--text-body); }
.source-dialog dd { margin: 0; color: var(--muted); font-size: var(--text-body); line-height: 1.7; }
.dialog-note { border-left: 1px solid var(--gold); padding-left: 14px; }
.no-script { position: fixed; z-index: 100; inset: auto 20px 20px; border: 1px solid var(--gold); padding: 16px; background: var(--ink); }

@keyframes cue { 0% { transform: translateY(-100%); } 55%,100% { transform: translateY(100%); } }
@keyframes lock-pulse { 0% { filter: url(#jointShadow); } 45% { filter: url(#jointShadow) drop-shadow(0 0 18px rgba(228,188,120,.95)); } 100% { filter: url(#jointShadow); } }
@keyframes wrong-shake {
  0%,100% { translate: 0 0; }
  28% { translate: var(--reject-x) var(--reject-y); }
  56% { translate: calc(var(--reject-x) * -.65) calc(var(--reject-y) * -.65); }
  78% { translate: calc(var(--reject-x) * .3) calc(var(--reject-y) * .3); }
}
@keyframes guide-breathe { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes guardian-guide-enter { to { opacity: 1; transform: scaleY(1); } }
@keyframes guardian-button-enter { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes guardian-copy-enter { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes guardian-breathe {
  0%,100% { box-shadow: inset 0 0 0 1px rgba(228,188,120,.08),0 12px 38px rgba(0,0,0,.5),0 0 18px rgba(189,138,70,.08); }
  50% { box-shadow: inset 0 0 0 1px rgba(228,188,120,.18),0 14px 42px rgba(0,0,0,.56),0 0 38px rgba(228,188,120,.3); }
}

@media (max-width: 820px) {
  :root {
    --text-hero: clamp(27px, 7.7vw, 36px);
    --text-section: clamp(26px, 7vw, 34px);
    --text-body: 12px;
    --text-label: 9px;
    --text-micro: 7px;
  }
  .visual-layer { object-position: 50% 48%; }
  .atmosphere { background: linear-gradient(0deg,rgba(5,9,10,.84),rgba(5,9,10,.2) 56%,rgba(5,9,10,.3)); }
  .brand { grid-template-columns: 34px auto; gap: 9px; }
  .brand-mark { width: 34px; height: 34px; font-size: 19px; }
  .brand-copy b { font-size: 12px; }
  .load-state, .brand-copy small { display: none; }
  .story-copy { left: 22px; bottom: 100px; width: min(84vw,430px); }
  .eyebrow { margin-bottom: 11px; }
  .chapter-no { position: static; margin-bottom: 10px; writing-mode: initial; }
  .story-copy h1,
  .story-copy[data-lines] h1 { font-size: var(--text-hero); line-height: 1.08; }
  .story-copy[data-lines="2"],
  .story-copy[data-lines="3"] { width: min(86vw,430px); }
  .scene-body { max-width: 31ch; margin-top: 16px; font-size: var(--text-body); line-height: 1.7; }
  .chapter-rail { right: 18px; grid-template-columns: 1px 5px; gap: 8px; }
  .rail-items { gap: 18px; }
  .rail-item { display: block; width: 5px; height: 5px; border: 1px solid rgba(238,231,215,.58); border-radius: 50%; }
  .rail-item.is-active { border-color: var(--gold-bright); background: var(--gold-bright); transform: scale(1.35); }
  .rail-item b, .rail-item span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .disclaimer { right: 18px; bottom: 9px; max-width: 190px; line-height: 1.45; text-align: right; }
  .scroll-cue { left: 22px; justify-items: start; transform: none; }

  .guardian-entry { left: 50%; top: 77%; }
  .guardian-entry.is-visible { display: grid; justify-items: center; gap: 9px; }
  .guardian-guide { position: relative; display: block; width: 1px; height: 38px; overflow: visible; opacity: 0; transform: scaleY(.2); transform-origin: top; animation: guardian-guide-enter 700ms 0ms var(--ease-heavy) forwards; }
  .guardian-guide::before { content: ""; position: absolute; inset: 0; background: linear-gradient(var(--gold-bright),rgba(228,188,120,.4)); }
  .guardian-guide::after { content: ""; position: absolute; left: 50%; bottom: -1px; width: 8px; height: 8px; border-right: 1px solid var(--gold-bright); border-bottom: 1px solid var(--gold-bright); transform: translateX(-50%) rotate(45deg); }
  .guardian-entry > button {
    min-width: 168px; min-height: 44px; border: 0; padding: 10px 27px; font-size: var(--text-label);
    clip-path: polygon(12px 0,calc(100% - 12px) 0,100% 50%,calc(100% - 12px) 100%,12px 100%,0 50%);
    opacity: 0; transform: translateY(10px) scale(.96);
  }
  .guardian-entry > button::before {
    inset: 4px 7px;
    clip-path: polygon(9px 0,calc(100% - 9px) 0,100% 50%,calc(100% - 9px) 100%,9px 100%,0 50%,9px 0,10px 2px,2px 50%,10px calc(100% - 2px),calc(100% - 10px) calc(100% - 2px),calc(100% - 2px) 50%,calc(100% - 10px) 2px,10px 2px,9px 0);
  }
  .guardian-entry.is-visible > button { animation: guardian-button-enter 620ms 0ms var(--ease-heavy) forwards,guardian-breathe 2800ms 620ms ease-in-out infinite; }
  .is-guardian-entry-ready .story-copy { transform: translateY(-96px); }
  .is-guardian-entry-ready .story-copy h1 { font-size: var(--text-hero); line-height: 1.1; }
  .is-guardian-entry-ready .scene-body { animation: guardian-copy-enter 700ms var(--ease-heavy) both; }

  .overlay-topbar { top: max(126px,calc(var(--safe-top) + 100px)); left: 18px; right: auto; }
  .overlay-topbar p { display: none; }
  .overlay-back { border-bottom-color: rgba(238,231,215,.3); padding-bottom: 5px; }
  .lab-layout { grid-template-columns: 1fr; align-content: start; min-height: 100dvh; padding: 168px 16px 24px; gap: 8px; }
  .joinery-board { order: 2; min-height: 0; height: min(61vh,540px); border-left: 0; perspective: 720px; }
  #jointSvg { width: 100%; max-height: calc(61vh - 28px); }
  .piece-core { --explode-x: -4px; --explode-y: 84px; --explode-scale: .93; --explode-rotate: -1deg; }
  .piece-left { --explode-x: -82px; --explode-y: 56px; --explode-scale: .84; --explode-rotate: -5deg; }
  .piece-right { --explode-x: 78px; --explode-y: -48px; --explode-scale: .87; --explode-rotate: 5deg; }
  .piece-lock { --explode-x: 10px; --explode-y: -106px; --explode-scale: .78; --explode-rotate: 2deg; }
  .piece-label { font-size: var(--text-label); }
  .is-exploded .piece-left, .is-playing .piece-left:not(.is-locked) { filter: url(#jointShadow) brightness(.88); }
  .is-exploded .piece-right, .is-playing .piece-right:not(.is-locked) { filter: url(#jointShadow) brightness(1.08); }
  .is-exploded .piece-lock, .is-playing .piece-lock:not(.is-locked) { filter: url(#jointShadow) brightness(.78); }
  .lab-copy { order: 1; max-width: none; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px 14px; align-items: end; }
  .lab-kicker { grid-column: 1 / 3; margin-bottom: 0; }
  .lab-copy h2 { grid-column: 1; font-size: var(--text-section); }
  .lab-instruction { grid-column: 1 / 3; margin: 2px 0 0; font-size: var(--text-body); line-height: 1.55; }
  .timer { grid-column: 2; grid-row: 2; margin: 0; text-align: right; white-space: nowrap; }
  .timer span { font-size: 30px; }
  .step-meter { left: 4px; right: 4px; bottom: 2px; }
  .step-meter span { justify-content: center; padding: 8px 2px 0; font-size: var(--text-label); }
  .step-meter i { display: none; }

  .identity-view, .result-view { padding: 174px 20px 28px; }
  .identity-view { place-items: start center; }
  .identity-panel h2, .result-copy h2 { font-size: var(--text-section); line-height: 1.2; }
  .completion-line { margin: 14px 0 24px; }
  .identity-options { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 7px; }
  .identity-options button { min-height: 154px; padding: 34px 8px 19px; gap: 15px; }
  .identity-options button::before { inset: 6px; }
  .identity-options button::after { top: 15px; letter-spacing: .12em; }
  .identity-options i { width: 36px; height: 36px; font-size: 21px; }
  .identity-options b { position: relative; z-index: 1; padding: 2px 5px; background: rgba(46,29,23,.28); font-size: var(--text-label); line-height: 1.3; letter-spacing: .02em; white-space: nowrap; }
  .result-view { padding-bottom: max(42px,var(--safe-bottom)); }
  .result-layout { grid-template-columns: 1fr; grid-template-rows: auto auto auto; align-content: start; min-height: calc(100dvh - 190px); gap: 16px; }
  .result-intro { grid-column: 1; grid-row: 1; align-self: auto; text-align: center; }
  .result-intro strong { margin-top: 4px; font-size: 26px; }
  .poster-preview { order: 1; justify-self: center; width: min(72vw,330px); }
  .poster-preview { grid-column: 1; grid-row: 2; }
  .result-copy { grid-column: 1; grid-row: 3; text-align: center; }
  .result-kicker, .result-heading { display: none; }
  .result-copy > p:not(.lab-kicker,.save-note) {
    max-width: 22em; margin: 0 auto; color: rgba(238,231,215,.76);
    font-family: var(--font-display);
    font-size: var(--text-body); line-height: 1.75; letter-spacing: .08em; white-space: pre-line;
  }
  .save-note { position: fixed; z-index: 45; right: 14px; bottom: max(8px,var(--safe-bottom)); max-width: 218px; margin: 0; color: rgba(238,231,215,.34); font-family: var(--font-ui); font-size: var(--text-micro); font-style: italic; line-height: 1.45; text-align: right; letter-spacing: .04em; }
}

@media (max-width: 375px), (max-height: 680px) {
  .guardian-entry { top: 74%; }
  .overlay-topbar { top: max(118px,calc(var(--safe-top) + 92px)); }
  .lab-layout { padding-top: 158px; }
  .lab-copy h2 { font-size: var(--text-section); }
  .lab-instruction { font-size: var(--text-body); }
  .joinery-board { height: min(59vh,450px); }
  #jointSvg { max-height: calc(59vh - 24px); }
  .identity-view, .result-view { padding-top: 166px; }
  .identity-options button { min-height: 132px; padding: 31px 7px 17px; gap: 12px; }
  .identity-options button::after { top: 13px; }
  .identity-options i { width: 31px; height: 31px; font-size: 18px; }
  .poster-preview { width: min(58vw,280px); }
  .result-copy > p:not(.lab-kicker,.save-note) { line-height: 1.6; }
  .is-guardian-entry-ready .story-copy { transform: translateY(-88px); }
}

@media (hover: none), (pointer: coarse) {
  .joint-piece:hover { filter: url(#jointShadow); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; }
  .video-layer, .opening-orbit { display: none; }
}
