/* 아야메의 집 */
:root {
  --bg: #0d0b0a;
  --panel: #171311;
  --panel-2: #211b18;
  --line: rgba(232, 222, 205, .14);
  --text: #e9e2d5;
  --muted: #a99e8e;
  --accent: #b34a3c;
  --accent-soft: rgba(179, 74, 60, .22);
  --paper: #e8dcc2;
  --paper-ink: #2b231c;
  --gold: #d9b779;
  --hud-h: 52px;
  --inv-w: 176px;
  --radius: 12px;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", "Songti SC", "Noto Serif SC", "Batang", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Hiragino Sans", "Microsoft YaHei", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- layout ---------- */
.app {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: var(--hud-h) 1fr auto;
  grid-template-columns: 1fr;
  grid-template-areas: "hud" "stage" "inv";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
@media (min-width: 960px) and (min-height: 540px) {
  .app {
    grid-template-rows: var(--hud-h) 1fr;
    grid-template-columns: 1fr var(--inv-w);
    grid-template-areas: "hud hud" "stage inv";
  }
}

.hud {
  grid-area: hud;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  background: linear-gradient(#120f0d, #0f0c0b);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  z-index: 5;
}
.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  position: relative;
  flex: none;
}
.hud-btn:hover { background: rgba(255, 255, 255, .06); }
.hud-btn.text span { font-size: 14px; }
.hud-btn .wave, .hud-btn .mute { transition: opacity .2s; }
.hud-btn .mute { opacity: 0; }
.muted .hud-btn .wave { opacity: 0; }
.muted .hud-btn .mute { opacity: 1; }
.badge {
  position: absolute;
  top: 4px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
}
.hud-place { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.room-name { font-family: var(--serif); font-size: 15px; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.objective { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.obj-label { color: var(--gold); }
.saved { font-size: 12px; color: var(--muted); opacity: 0; transition: opacity .4s; white-space: nowrap; }
.saved.on { opacity: 1; }
.saved::before { content: "●"; color: #6f9a63; margin-right: 4px; font-size: 9px; vertical-align: 1px; }
.saved.fail::before { color: var(--accent); }
.hud-tools { display: flex; gap: 2px; flex: none; }
@media (max-width: 640px) {
  :root { --hud-h: 48px; }
  .hud { gap: 4px; padding: 0 4px; }
  .hud-btn.text span:not(.badge) { display: none; }
  .hud-btn { min-width: 38px; padding: 0 8px; }
  .saved { position: absolute; top: calc(var(--hud-h) + 6px + env(safe-area-inset-top)); right: 10px; background: rgba(0, 0, 0, .55); padding: 2px 8px; border-radius: 10px; z-index: 6; }
}

/* ---------- stage & scene ---------- */
.stage {
  grid-area: stage;
  position: relative;
  overflow: hidden;
  background: #060505;
  min-height: 0;
}
.scroller {
  position: absolute;
  inset: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scroller.pan {
  overflow-x: auto;
  overflow-y: hidden;
  justify-content: flex-start;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
.scroller.pan::-webkit-scrollbar { display: none; }
.scene {
  position: relative;
  flex: none;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.scene .bg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: fill;
  display: block;
  pointer-events: none;
  transition: filter .6s;
}
.scene.dim-in .bg { filter: brightness(.55); }
.props, .layers, .hotspots, .fx { position: absolute; inset: 0; }
.props, .layers, .fx { pointer-events: none; }
.prop { position: absolute; display: block; height: auto; transform-origin: 50% 50%; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .6)) brightness(.78) saturate(.85); }
.prop.dim { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)) brightness(.55) saturate(.7); }
.prop.text {
  font-family: var(--serif);
  color: #d9cdb5;
  background: #3a2c22;
  border: 1px solid #5b4637;
  text-align: center;
  writing-mode: vertical-rl;
  letter-spacing: .1em;
  padding: .3em 0;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .6);
  filter: brightness(.8);
}
.prop.text.nameplate {
  writing-mode: horizontal-tb;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #cdbb94;
  letter-spacing: .25em;
  text-indent: .25em;
  line-height: 1;
  filter: none;
  opacity: .82;
}
.layer {
  position: absolute;
  height: auto;
  transform-origin: 50% 100%;
  transition: opacity 1.2s, transform 1.4s cubic-bezier(.2, .7, .2, 1), filter .8s;
  filter: brightness(.82) contrast(1.05);
}
.layer.breathe { animation: breathe 5.5s ease-in-out infinite; }
.layer.waver { animation: waver 3.2s ease-in-out infinite; }
.layer.approach-1 { transform: translate(-10%, 4%) scale(1.14); }
.layer.approach-2 { transform: translate(-22%, 9%) scale(1.32); filter: brightness(.9) contrast(1.15); }
@keyframes breathe { 50% { transform: translateY(-.4%) scale(1.006); } }
@keyframes waver { 0%, 100% { opacity: var(--op, .2); } 50% { opacity: calc(var(--op, .2) * .45); } }

.hs {
  position: absolute;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
.scroller.pan .hs { touch-action: pan-x; }
.hs::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(closest-side, rgba(255, 236, 204, .17), rgba(255, 236, 204, .05) 70%, transparent);
  opacity: 0;
  transition: opacity .3s;
}
@media (hover: hover) and (pointer: fine) {
  .hs:hover::after { opacity: 1; }
}
.hs:focus-visible { outline: 2px solid rgba(255, 228, 186, .8); outline-offset: 0; }
.hs:focus-visible::after { opacity: 1; }
.hs.touched::after { opacity: 1; transition: none; }
.holding-on .hs { cursor: copy; }

.tip {
  position: absolute;
  z-index: 4;
  padding: 3px 9px;
  border-radius: 8px;
  background: rgba(10, 8, 7, .82);
  border: 1px solid var(--line);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -130%);
}

.veil {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s;
  z-index: 3;
}
.veil.on { opacity: 1; pointer-events: auto; }
.veil.flicker { animation: flicker .5s steps(2, end) 2; }
@keyframes flicker { 0% { opacity: .9; } 30% { opacity: .1; } 60% { opacity: .75; } 100% { opacity: 0; } }

.back-btn {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  bottom: 12px;
  z-index: 4;
  padding: 8px 14px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(12, 10, 9, .72);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  font-size: 14px;
}
.back-btn:hover { background: rgba(32, 26, 22, .9); }

.holding {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 6px;
  border-radius: 24px;
  border: 1px solid rgba(217, 183, 121, .5);
  background: rgba(20, 16, 13, .88);
  font-size: 13.5px;
  max-width: calc(100% - 20px);
}
.holding img { width: 30px; height: 30px; object-fit: contain; }
.holding .hold-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.holding .drop { width: 30px; height: 30px; border-radius: 15px; border: 0; background: rgba(255, 255, 255, .08); }

.caption {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 24px));
  z-index: 4;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(10, 8, 7, .86);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  font-size: 15px;
  line-height: 1.6;
  pointer-events: none;
  animation: rise .22s ease-out;
}
.caption button { pointer-events: auto; margin-left: 6px; }
.caption.with-back { bottom: 60px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 6px); } }

.toast {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
.toast > div {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 20px;
  background: rgba(20, 16, 13, .9);
  border: 1px solid rgba(217, 183, 121, .35);
  font-size: 13.5px;
  animation: toastIn .3s ease-out, toastOut .5s 2.6s ease-in forwards;
}
.toast img { width: 26px; height: 26px; object-fit: contain; }
.toast .ic { width: 26px; text-align: center; color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateX(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

.pan-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  padding: 8px 14px;
  border-radius: 20px;
  background: rgba(0, 0, 0, .7);
  font-size: 13.5px;
  pointer-events: none;
  animation: panHint 3.2s ease-in-out forwards;
}
@keyframes panHint { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }

.scene.shake { animation: shake .45s; }
@keyframes shake {
  20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); }
  60% { transform: translate(-3px, 2px); } 80% { transform: translate(2px, -1px); }
}
.fx-mirror {
  position: absolute;
  overflow: hidden;
  border-radius: 40% / 30%;
}
.fx-mirror img { position: absolute; width: 100%; height: auto; left: 0; top: 0; filter: brightness(.7) contrast(1.2); animation: ghostFlash 1.1s steps(3, end) forwards; }
.soft .fx-mirror img { animation: ghostFade 2.4s ease-in-out forwards; }
@keyframes ghostFlash { 0% { opacity: 0; } 15% { opacity: .95; } 45% { opacity: .3; } 70% { opacity: .9; } 100% { opacity: 0; } }
@keyframes ghostFade { 0% { opacity: 0; } 40% { opacity: .55; } 100% { opacity: 0; } }

/* ---------- inventory ---------- */
.inv {
  grid-area: inv;
  background: linear-gradient(#141110, #0f0c0b);
  border-top: 1px solid var(--line);
  min-width: 0;
  min-height: 0;
  position: relative;
  z-index: 5;
  padding-bottom: env(safe-area-inset-bottom);
}
.inv-handle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 34px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  font-size: 13px;
  color: var(--muted);
}
.inv-handle .count { color: var(--gold); }
.inv-handle .chev { margin-left: auto; width: 8px; height: 8px; border-left: 1.6px solid currentColor; border-top: 1.6px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
.inv.open .inv-handle .chev { transform: rotate(225deg); }
.inv-list {
  display: flex;
  min-height: 0;
  gap: 8px;
  padding: 0 10px 10px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.inv-empty { color: var(--muted); font-size: 13px; padding: 4px 2px 8px; }
.inv-item {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 64px;
  padding: 5px 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
  font-size: 11px;
  line-height: 1.2;
  color: var(--muted);
}
.inv-item:hover { background: rgba(255, 255, 255, .07); }
.inv-item.sel { border-color: var(--gold); background: rgba(217, 183, 121, .12); color: var(--text); }
.inv-item.new { animation: newItem 1.6s ease-out; }
@keyframes newItem { 0% { box-shadow: 0 0 0 0 rgba(217, 183, 121, .7); } 100% { box-shadow: 0 0 0 10px rgba(217, 183, 121, 0); } }
.inv-item .thumb { width: 44px; height: 44px; }
.inv-item .name { display: none; }
.inv.open .inv-list { flex-wrap: wrap; max-height: 44vh; overflow-y: auto; }
.inv.open .inv-item { width: 84px; }
.inv.open .inv-item .name { display: block; text-align: center; }
.inv:not(.open) .inv-item { width: 54px; }
@media (min-width: 960px) and (min-height: 540px) {
  .inv { border-top: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; padding-bottom: 0; }
  .inv-handle { cursor: default; height: 44px; font-size: 14px; color: var(--text); pointer-events: none; }
  .inv-handle .chev { display: none; }
  .inv-list { flex-direction: column; flex-wrap: nowrap; overflow-x: hidden; overflow-y: auto; padding: 0 10px 12px; flex: 1; max-height: none !important; }
  .inv-item, .inv.open .inv-item, .inv:not(.open) .inv-item { width: 100%; flex-direction: row; gap: 10px; padding: 6px 8px; text-align: left; font-size: 13px; color: var(--text); }
  .inv-item .name { display: block; text-align: left; }
}

/* item thumbnails: trim crop seams some item PNGs carry at their edges */
.thumb, .item-big { object-fit: contain; }
.crop-cassettePlayer { clip-path: polygon(14% 6%, 100% 6%, 100% 92%, 46% 92%, 44% 89%, 14% 89%); }
.crop-cassetteTape { clip-path: polygon(0 0, 100% 0, 100% 76%, 91% 90%, 0 90%); }
.crop-musicBoxKey { clip-path: inset(0 0 0 7%); }
.crop-wellSeal { clip-path: inset(8% 0 0 0); }
.crop-oldMemo { clip-path: inset(6% 0 0 0); }
.crop-oldPhone { clip-path: inset(0 0 5% 0); }
.crop-basementKey { clip-path: inset(4% 0 0 0); }
.crop-rope { clip-path: inset(7% 0 0 0); }
.crop-memorialTablet { clip-path: inset(3% 0 6% 7%); }

/* ---------- title ---------- */
.title-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: #000;
  overflow: auto;
}
.title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; filter: brightness(.75); }
.title-shade { position: absolute; inset: 0; background: linear-gradient(transparent 20%, rgba(0, 0, 0, .55) 55%, rgba(0, 0, 0, .92)); }
.title-card {
  position: relative;
  width: min(560px, calc(100% - 32px));
  margin: 0 auto calc(28px + env(safe-area-inset-bottom));
  text-align: center;
}
.title-name {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(40px, 9vw, 64px);
  letter-spacing: .08em;
  color: #efe6d6;
  text-shadow: 0 3px 18px rgba(0, 0, 0, .8);
  transition: color .6s, letter-spacing .6s;
}
.title-name.bad { color: #d46a5a; letter-spacing: .02em; }
.title-tag { margin: 10px 0 4px; font-family: var(--serif); font-size: 16px; color: #e6dccb; }
.title-meta { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.title-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn {
  min-width: 220px;
  min-height: 46px;
  padding: 10px 22px;
  border-radius: 24px;
  border: 1px solid rgba(232, 222, 205, .3);
  background: rgba(20, 16, 13, .72);
  font-size: 15.5px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.3;
}
.btn:hover { background: rgba(40, 32, 27, .9); }
.btn.primary { background: #6e2a22; border-color: #9a4436; }
.btn.primary:hover { background: #82332a; }
.btn.ghost { background: transparent; }
.btn small { font-size: 11.5px; color: #e7cfc6; opacity: .85; }
.btn.small { min-width: 0; min-height: 38px; padding: 6px 16px; font-size: 14px; }
.title-lang { display: inline-flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 13px; color: var(--muted); }
select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.title-warning { margin: 14px auto 0; max-width: 460px; font-size: 12px; color: #a99c8b; }
.title-msg { margin: 10px 0 0; color: var(--gold); font-size: 13px; }

/* ---------- cutscene ---------- */
.cut {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: #000;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.cut-visual { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cut-frame { position: relative; flex: none; overflow: hidden; }
.cut-frame > img.full { position: absolute; inset: 0; width: 100%; height: 100%; }
.cut-event {
  height: min(100%, 86vh);
  width: auto;
  max-width: 92vw;
  object-fit: contain;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 10px 40px rgba(0, 0, 0, .8);
}
.cut-item { max-width: min(60vw, 300px); max-height: 70%; object-fit: contain; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .8)); }
.cut-portrait { max-height: 92%; max-width: 60vw; object-fit: contain; filter: sepia(.35) brightness(.85); opacity: .9; -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.cut-visual > *, .cut-frame { animation: cutIn .7s ease-out; }
@keyframes cutIn { from { opacity: 0; } }
.cut-visual.sepia img { filter: sepia(.6) contrast(1.05) brightness(.9); }
.cut-visual.dawn .cut-frame::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, rgba(255, 205, 150, .55), rgba(255, 176, 120, .18) 55%, rgba(255, 220, 180, .08)); mix-blend-mode: soft-light; pointer-events: none; }
.cut-visual.dawn .cut-frame > img.full { filter: brightness(1.38) saturate(1.12) sepia(.22) contrast(.96); }
.cut-visual.dawn .cut-frame > img.layer { filter: brightness(1.05) sepia(.12); }
.cut-visual.memory img { filter: sepia(.5) brightness(.9); }
.cut-visual.vhs .cut-frame > img.full { filter: grayscale(.7) contrast(1.35) brightness(.55) blur(.6px); }
.cut-visual.vhs .cut-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, .35) 2px 4px);
  pointer-events: none;
}
.rec {
  position: absolute;
  z-index: 3;
  left: 3%;
  top: 4%;
  font: 600 clamp(11px, 1.8vw, 16px)/1 ui-monospace, Menlo, Consolas, monospace;
  color: #f2f2f2;
  letter-spacing: .08em;
  text-shadow: 0 0 4px rgba(0, 0, 0, .9);
}
.rec::before { content: "● "; color: #e33; }
.rearview {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 6%;
  width: 34%;
  aspect-ratio: 3.2 / 1;
  transform: translateX(-50%);
  border-radius: 40px;
  border: 3px solid #1a1a1a;
  background: #0a0a0a;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .7);
}
.rearview .seat { position: absolute; inset: 0; background: linear-gradient(#1b1b1b, #090909); }
.rearview img { position: absolute; left: 38%; top: -4%; height: 230%; width: auto; filter: brightness(0) blur(.4px); opacity: 0; }
.rearview.show img { animation: silhouette 1.6s steps(4, end) forwards; }
.soft .rearview.show img { animation: silhouetteSoft 2.6s ease-in-out forwards; }
@keyframes silhouette { 0% { opacity: 0; } 20% { opacity: .9; } 40% { opacity: .2; } 60% { opacity: 1; } 100% { opacity: .85; } }
@keyframes silhouetteSoft { 0% { opacity: 0; } 100% { opacity: .8; } }
.glitch { animation: glitch .9s steps(6, end) 2; }
.soft .glitch { animation: none; }
@keyframes glitch {
  0% { transform: none; filter: none; }
  20% { transform: translate(-4px, 0) skewX(4deg); filter: hue-rotate(40deg); }
  40% { transform: translate(5px, 1px); clip-path: inset(10% 0 40% 0); }
  60% { transform: translate(-2px, -1px) skewX(-3deg); clip-path: inset(50% 0 5% 0); }
  80% { transform: none; clip-path: none; filter: invert(.15); }
}
.photo-card { position: relative; width: min(70vw, 360px); }
.photo-card img { width: 100%; display: block; }
.photo-card.warm img { filter: sepia(.25) brightness(1.08); }
.cut-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 3; font-family: var(--serif); font-size: clamp(28px, 6vw, 48px); color: #fff4e4; text-shadow: 0 2px 20px rgba(0, 0, 0, .7); animation: cutIn 2s ease-out; }
.cut-flash { position: absolute; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.cut-flash img { height: 96%; filter: brightness(.75) contrast(1.3); animation: ghostFlash .9s steps(3, end) forwards; }
.soft .cut-flash img { animation: ghostFade 2.2s ease-in-out forwards; }
.cut-box {
  flex: none;
  min-height: 120px;
  padding: 14px max(18px, env(safe-area-inset-left)) calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(0, 0, 0, .0), #000 30%);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
}
.cut-who { font-family: var(--serif); color: var(--gold); font-size: 14px; margin-bottom: 4px; letter-spacing: .05em; }
.cut-who.yuki { color: #b8d0e8; }
.cut-who.sachiko { color: #d46a5a; }
.cut-text { margin: 0; font-family: var(--serif); font-size: clamp(16px, 2.2vw, 19px); line-height: 1.7; min-height: 3.4em; white-space: pre-line; }
.cut-text.line { color: #fff; }
.cut-next { display: block; text-align: right; font-size: 12px; color: var(--muted); opacity: 0; transition: opacity .3s; }
.cut.ready .cut-next { opacity: .8; }
.cut-skip {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  right: calc(10px + env(safe-area-inset-right));
  z-index: 5;
  padding: 6px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .5);
  font-size: 13px;
  color: var(--muted);
}

/* ---------- sheet (panels) ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .6); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet {
  position: relative;
  width: min(600px, calc(100% - 24px));
  max-height: calc(100% - 40px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  animation: sheetIn .22s ease-out;
}
@keyframes sheetIn { from { opacity: 0; transform: translateY(10px); } }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 8px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; flex: 1; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.sheet-close { width: 38px; height: 38px; border-radius: 19px; border: 0; background: rgba(255, 255, 255, .06); font-size: 16px; }
.sheet-body { padding: 14px 18px 18px; overflow-y: auto; overscroll-behavior: contain; }
@media (max-width: 640px), (max-height: 520px) and (max-width: 960px) {
  .sheet-wrap { align-items: flex-end; }
  .sheet { width: 100%; max-height: 88%; border-radius: 16px 16px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.help { color: var(--muted); font-size: 13.5px; margin: 0 0 12px; }
.msg { min-height: 1.6em; margin: 10px 0 0; font-size: 14px; color: var(--gold); }
.msg.bad { color: #e08a7c; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.list button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.list button:hover { border-color: rgba(217, 183, 121, .5); }
.list .tag { margin-left: auto; font-size: 11.5px; color: var(--gold); }
.truth { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 13.5px; color: var(--muted); }
.truth .bar { flex: 1; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; }
.truth .bar i { display: block; height: 100%; background: linear-gradient(90deg, #8e3a2f, var(--gold)); }

.paper {
  position: relative;
  padding: 18px 18px 20px;
  border-radius: 6px;
  background: linear-gradient(rgba(255, 250, 238, .06), rgba(0, 0, 0, .04)), var(--paper);
  color: var(--paper-ink);
  font-family: var(--serif);
  font-size: 15.5px;
  line-height: 1.75;
  white-space: pre-line;
  box-shadow: inset 0 0 40px rgba(110, 80, 40, .25);
}
.paper .stamp { float: right; width: 74px; margin: -6px -6px 6px 10px; opacity: .9; }
.rec-img { display: block; max-width: 100%; max-height: 42vh; margin: 0 auto 12px; object-fit: contain; }

.item-view { display: flex; gap: 16px; align-items: flex-start; }
.item-big { width: 140px; height: 140px; flex: none; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .6)); }
.item-view p { margin: 0; }
@media (max-width: 420px) { .item-view { flex-direction: column; align-items: center; text-align: center; } }

.photo-zoom { position: relative; width: min(100%, 420px); margin: 0 auto; }
.photo-zoom img { width: 100%; display: block; }
.photo-zoom svg.scratch { position: absolute; left: 39%; top: 50%; width: 14%; height: 16%; stroke: rgba(236, 228, 214, .82); stroke-width: 1.2; fill: none; overflow: visible; }
.photo-back {
  aspect-ratio: 1 / 1;
  width: min(100%, 420px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(17px, 4vw, 22px);
  line-height: 2;
  color: #3a2d22;
  background: radial-gradient(circle at 30% 20%, #efe4cc, #d9c8a6);
  border-radius: 4px;
  box-shadow: inset 0 0 30px rgba(90, 60, 30, .35);
  padding: 20px;
  white-space: pre-line;
}
.photo-back .cut-edge { position: relative; }

/* altar */
.altar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 16px 10px 12px;
  border-radius: 10px;
  background: linear-gradient(#2a1a12, #1a100b);
  border: 1px solid #4a3020;
  box-shadow: inset 0 -20px 30px rgba(0, 0, 0, .4);
}
.tablet {
  position: relative;
  aspect-ratio: 230 / 360;
  border: 2px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 0;
}
.tablet img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; filter: brightness(.95); }
.tablet .nm {
  position: absolute;
  left: 50%;
  top: 11%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: row-reverse;
  gap: .12em;
  font-family: var(--serif);
  font-size: clamp(13px, 3.4vw, 21px);
  line-height: 1.08;
  color: #e9d7a8;
  text-shadow: 0 1px 2px #000;
}
.tablet .nm .col { display: flex; flex-direction: column; align-items: center; }
.tablet .nm i { display: block; font-style: normal; }
.tablet .nm.long { font-size: clamp(9px, 2.1vw, 13px); top: 13%; }
.tablet.sel { border-color: var(--gold); background: rgba(217, 183, 121, .1); }
.tablet.empty { border: 2px dashed rgba(232, 222, 205, .25); color: var(--muted); font-size: 12.5px; display: flex; align-items: center; justify-content: center; text-align: center; padding: 4px; }
.tablet.empty.can { border-color: var(--gold); color: var(--gold); }
.altar.solved .tablet img { filter: brightness(1.1) sepia(.3); }

/* music box */
.music-top { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.music-top img { width: 96px; height: 96px; object-fit: contain; }
.dots { display: flex; gap: 8px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid rgba(232, 222, 205, .4); }
.dots i.on { background: var(--gold); border-color: var(--gold); }
.keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.key {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 4px 8px;
  border-radius: 10px;
  border: 1px solid #6b5238;
  background: linear-gradient(#3a2a1d, #241912);
  touch-action: manipulation;
}
.key b { font-family: var(--serif); font-size: clamp(22px, 6vw, 30px); font-weight: 600; color: #f0dcae; line-height: 1.1; }
.key span { font-size: 12px; color: var(--muted); }
.key:active, .key.hit { transform: translateY(2px); background: linear-gradient(#4a3624, #2c1f15); }
.shake-x { animation: shakeX .4s; }
@keyframes shakeX { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* seal */
.mirror-board {
  position: relative;
  width: min(100%, 330px);
  aspect-ratio: 3 / 4;
  margin: 0 auto 12px;
}
.mirror-glass {
  position: absolute;
  left: 22%;
  top: 16%;
  width: 56%;
  height: 68%;
  border-radius: 46% / 36%;
  border: 6px solid #6b4a2a;
  background: radial-gradient(circle at 40% 35%, #44505a, #161b20 70%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .7), 0 0 0 2px #2a1a10;
}
.slot {
  position: absolute;
  width: 18%;
  aspect-ratio: 171 / 318;
  border: 2px dashed rgba(232, 222, 205, .35);
  border-radius: 4px;
  background: rgba(0, 0, 0, .25);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
}
.slot.top { left: 41%; top: 0; }
.slot.bottom { left: 41%; bottom: 0; }
.slot.left { left: 0; top: 38%; }
.slot.right { right: 0; top: 38%; }
.slot.filled { border-style: solid; border-color: transparent; }
.slot.target { border-color: var(--gold); }
.tal {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
}
.tal img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tal b {
  position: absolute;
  left: 0;
  right: 0;
  top: 56%;
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(16px, 4.6vw, 24px);
  color: #2a120d;
  font-weight: 700;
  text-shadow: 0 0 2px rgba(255, 240, 220, .6);
}
.tray { display: flex; justify-content: center; gap: 10px; min-height: 92px; }
.tray button { width: 50px; aspect-ratio: 171 / 318; padding: 0; border: 2px solid transparent; border-radius: 4px; background: transparent; }
.tray button.sel { border-color: var(--gold); }

/* well */
.well-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.well-steps div {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px dashed rgba(232, 222, 205, .3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
}
.well-steps div.done { border-style: solid; border-color: rgba(217, 183, 121, .45); background: rgba(217, 183, 121, .06); }
.well-steps img { width: 72%; height: 72%; object-fit: contain; }
.rite { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.rite button { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 104px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: 13px; }
.rite button:hover { border-color: rgba(217, 183, 121, .5); }
.rite img { width: 64px; height: 64px; object-fit: contain; }
.danger { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .06); overflow: hidden; margin: 0 0 12px; }
.danger i { display: block; height: 100%; background: linear-gradient(90deg, #5a1d17, #c0392b); transition: width .6s; }

/* settings */
.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set:last-of-type { border-bottom: 0; }
.set small { display: block; color: var(--muted); font-size: 12px; }
.switch { position: relative; width: 50px; height: 28px; flex: none; border-radius: 14px; border: 1px solid var(--line); background: #2c2522; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #8d8275; transition: transform .2s, background .2s; }
.switch[aria-checked="true"] { background: #6e2a22; }
.switch[aria-checked="true"]::after { transform: translateX(22px); background: #f2e6d3; }
input[type=range] { width: 160px; accent-color: var(--accent); }

/* ending */
.ending {
  position: fixed;
  inset: 0;
  z-index: 32;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #241a15, #000 75%);
  padding: 20px;
  overflow: auto;
  align-items: flex-start;
}
.end-card { width: min(580px, 100%); text-align: center; animation: cutIn 1.2s ease-out; margin: auto 0; }
.end-label { margin: 0; letter-spacing: .3em; font-size: 13px; color: var(--gold); }
.end-name { margin: 6px 0 10px; font-family: var(--serif); font-size: clamp(32px, 8vw, 48px); font-weight: 700; }
.ending.bad .end-name { color: #d46a5a; }
.ending.true .end-label { color: #f3d9a4; }
.end-desc { margin: 0 0 16px; font-family: var(--serif); color: #e2d8c6; }
.end-stats { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; color: var(--muted); font-size: 13px; }
.end-stats .seen b { color: var(--text); font-weight: 600; margin: 0 2px; }
.end-stats .seen i { font-style: normal; opacity: .35; margin: 0 2px; }
.end-note { color: var(--gold); font-size: 13.5px; margin: 0 0 14px; }
.end-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }

.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

/* reduced motion */
.reduced *, .reduced *::before, .reduced *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
.reduced .layer.waver { opacity: var(--op, .2); }
@media (prefers-reduced-motion: reduce) {
  .scene.shake, .glitch { animation: none; }
}

/* embedded in the site player */
body.embed .title-card { margin-bottom: 18px; }

/* portrait drawer: the expanded list floats over the scene */
@media not all and (min-width: 960px) and (min-height: 540px) {
  .inv.open .inv-list {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    padding: 12px;
    background: rgba(15, 12, 11, .97);
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .5);
  }
}

/* phones held sideways: inventory becomes a narrow right column */
@media (orientation: landscape) and (max-height: 540px) {
  :root { --hud-h: 44px; --inv-w: 92px; }
  .app {
    grid-template-rows: var(--hud-h) 1fr;
    grid-template-columns: 1fr var(--inv-w);
    grid-template-areas: "hud hud" "stage inv";
  }
  .hud-btn.text span:not(.badge) { display: none; }
  .hud-btn { min-width: 36px; height: 36px; padding: 0 7px; }
  .inv { border-top: 0; border-left: 1px solid var(--line); display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
  .inv-handle { height: 30px; font-size: 12px; pointer-events: none; padding: 0 8px; }
  .inv-handle .chev { display: none; }
  .inv-list, .inv.open .inv-list { position: static; flex-direction: column; flex-wrap: nowrap; align-items: center; overflow-x: hidden; overflow-y: auto; flex: 1; max-height: none; padding: 0 6px 8px; background: none; }
  .inv-item, .inv.open .inv-item, .inv:not(.open) .inv-item { width: 68px; }
  .inv.open .inv-item .name { display: none; }
  .back-btn { bottom: 8px; padding: 6px 12px; font-size: 13px; }
  .caption { bottom: 8px; padding: 8px 12px; font-size: 14px; }
  .caption.with-back { bottom: 48px; }
  .cut-box { min-height: 84px; padding-top: 8px; }
  .cut-text { font-size: 15px; min-height: 2.6em; }
}

/* ---------- v2: clickable-spot markers ---------- */
.mk {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 9, 8, .62);
  border: 1.5px solid rgba(255, 236, 204, .8);
  color: #fff3dd;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .2s;
}
.mk svg { width: 16px; height: 16px; stroke-width: 2.2; }
.markers .mk { opacity: .92; }
.markers .mk.seen { opacity: .38; }
.markers .mk-look:not(.seen), .markers .mk-take, .markers .mk-puzzle, .markers .mk-push { animation: mkPulse 2.6s ease-out infinite; }
.mk-go, .mk-unlock { border-color: rgba(170, 205, 255, .9); color: #dbe9ff; }
.mk-lock { border-color: rgba(205, 195, 185, .6); color: #cfc6bb; }
.mk-take, .mk-puzzle, .mk-push { border-color: rgba(240, 196, 110, .95); color: #ffd98a; background: rgba(40, 24, 8, .7); }
@media (hover: hover) and (pointer: fine) {
  .hs:hover .mk { opacity: 1; transform: scale(1.12); }
}
.hs:focus-visible .mk, .hs.touched .mk { opacity: 1; transform: scale(1.18); }
@keyframes mkPulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 214, 150, .55); }
  70% { box-shadow: 0 0 0 12px rgba(255, 214, 150, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 214, 150, 0); }
}
.reduced .mk { animation: none !important; }
.scene.scaring .mk { opacity: 0 !important; transition: opacity .2s; }

/* ---------- v2: room lighting overlays ---------- */
.grade { position: absolute; inset: 0; pointer-events: none; }
.grade-altar {
  background:
    radial-gradient(ellipse 22% 30% at 34% 44%, rgba(255, 140, 50, .34), transparent 72%),
    radial-gradient(ellipse at 40% 50%, transparent 32%, rgba(0, 0, 0, .72) 100%),
    linear-gradient(rgba(80, 18, 4, .26), rgba(40, 6, 0, .3));
  animation: candle 3.4s ease-in-out infinite;
}
@keyframes candle { 0%, 100% { opacity: 1; } 40% { opacity: .82; } 55% { opacity: .95; } 70% { opacity: .78; } }
/* the altar ledge under the three tablets, and its two candles (CSS only) */
.prop.fx-ledge {
  background: linear-gradient(#5a3a22, #2e1a0e 70%, #1a0e06);
  border-radius: 1px;
  box-shadow: 0 .25em .5em rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 200, 140, .25);
  filter: none;
}
.prop.fx-candle {
  background: linear-gradient(90deg, #b9ab90, #efe4cc 45%, #9c8f78);
  border-radius: 1px 1px 0 0;
  filter: none;
}
.prop.fx-candle::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 170%;
  height: 70%;
  transform: translateX(-50%);
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  background: radial-gradient(ellipse at 50% 75%, #fff8d8 0 22%, #ffc35a 45%, rgba(255, 110, 20, .85) 70%, transparent 74%);
  animation: flame 1.3s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}
.prop.fx-candle::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 40%;
  width: 900%;
  height: 300%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(255, 170, 70, .32), transparent);
  animation: candle 2.3s ease-in-out infinite;
}
@keyframes flame {
  0% { transform: translateX(-50%) scale(1, 1) skewX(0); }
  35% { transform: translateX(-56%) scale(.92, 1.08) skewX(-4deg); }
  70% { transform: translateX(-44%) scale(1.04, .94) skewX(3deg); }
  100% { transform: translateX(-50%) scale(.96, 1.12) skewX(-2deg); }
}

/* ---------- v2: the family photo (crop of the photo on the living-room table) ---------- */
.photo-crop { position: relative; display: block; overflow: hidden; aspect-ratio: .96; background: #000; flex: none; }
.photo-crop img { position: absolute; height: auto; max-width: none; }
.inv-item .thumb.photo-crop { width: 44px; height: auto; }
.toast-ic.photo-crop { width: 26px; }
.hold-ic.photo-crop { width: 30px; }
.holding img.hold-ic { width: 30px; height: 30px; object-fit: contain; }
.toast img.toast-ic { width: 26px; height: 26px; object-fit: contain; }
.item-big.photo-crop { width: 140px; height: auto; }
.photo-big { width: 100%; }
.photo-zoom svg.scratch { left: 41%; top: 56%; width: 14%; height: 15%; }
.photo-zoom .photo-big { filter: sepia(.3) contrast(1.08); }
.photo-zoom .photo-cut {
  position: absolute;
  left: 78%;
  top: 14%;
  width: 9%;
  height: 74%;
  background:
    linear-gradient(90deg, rgba(225, 205, 170, .4) 0 7%, transparent 10%),
    linear-gradient(90deg, #0e0906, #261b13 45%, #1a120c);
  clip-path: polygon(16% 0, 100% 0, 100% 100%, 20% 100%, 6% 90%, 18% 77%, 4% 63%, 15% 49%, 3% 34%, 13% 18%);
}
.photo-back { aspect-ratio: .96; }
@media (min-width: 960px) and (min-height: 540px) {
  .inv-item .thumb.photo-crop { width: 40px; }
}

/* ---------- v2: Sachiko (display-only effects on the untouched PNG) ---------- */
.ghost-wrap { aspect-ratio: 1056 / 1416; filter: none; }
.ghost-wrap.breathe { animation: none; }
.ghost-body { position: absolute; inset: 0; filter: drop-shadow(0 0 14px rgba(0, 0, 0, .95)); animation: ghostTwitch 6.5s steps(1, end) infinite; }
.ghost-body.calm { animation: none; }
.ghost-img, .ghost-ghost { position: absolute; inset: 0; width: 100%; height: 100%; }
.ghost-img { filter: grayscale(.45) contrast(1.5) brightness(.58) sepia(.15) hue-rotate(-15deg); }
.ghost-ghost { opacity: 0; mix-blend-mode: screen; filter: brightness(.5) sepia(1) saturate(6) hue-rotate(-40deg); animation: ghostSplit 6.5s steps(1, end) infinite; }
.ghost-body.calm .ghost-ghost { animation: none; }
.ghost-eye, .face-eye {
  position: absolute;
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, #ff4a3a 0 28%, rgba(190, 0, 0, .55) 50%, transparent 72%);
  animation: eyeGlow 2.2s ease-in-out infinite;
}
.ghost-eye { width: 1.8%; }
.fx .bg-eye.ghost-eye { width: .55%; transform: translate(-50%, -50%); }
.fx .bg-eye.ghost-eye.r { opacity: .6; }
.fx .bg-eye.ghost-tear { opacity: .85; }
.ghost-eye.l { left: 48.9%; top: 9.6%; }
.ghost-eye.r { left: 52.6%; top: 9.6%; opacity: .55; }
.ghost-tear, .face-tear { position: absolute; background: linear-gradient(rgba(28, 0, 0, .92), rgba(28, 0, 0, 0)); border-radius: 40%; }
.ghost-tear { left: 48.7%; top: 10.3%; width: .55%; height: 5%; }
@keyframes ghostTwitch {
  0%, 86%, 100% { transform: none; }
  87% { transform: translateX(1.5%) skewX(-3deg); }
  88% { transform: translateX(-1%) rotate(1.5deg); }
  89% { transform: none; }
  94% { transform: scale(1.02, .99) translateY(.6%); }
  95% { transform: none; }
}
@keyframes ghostSplit {
  0%, 86%, 100% { opacity: 0; transform: none; }
  87% { opacity: .55; transform: translateX(3%); }
  88% { opacity: .35; transform: translateX(-2%); }
  89% { opacity: 0; }
}
@keyframes eyeGlow { 0%, 100% { opacity: .95; } 50% { opacity: .45; } }
.reduced .ghost-body, .reduced .ghost-ghost, .reduced .ghost-eye { animation: none; }

.face { position: relative; overflow: hidden; aspect-ratio: 1.118; background: #000; }
.face img { position: absolute; height: auto; max-width: none; filter: grayscale(.5) contrast(1.65) brightness(.7); }
.face-eye { width: 4.5%; }
.face-eye.l { left: 45.5%; top: 60.4%; }
.face-eye.r { left: 60.5%; top: 60%; opacity: .6; }
.face-tear { left: 44.8%; top: 63%; width: 1.6%; height: 30%; }
.face-flash {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .86);
  pointer-events: none;
  animation: faceIn .7s steps(4, end) forwards;
}
.face-flash .face { height: 92vh; max-width: 100vw; }
@keyframes faceIn {
  0% { opacity: 0; transform: scale(1.4); }
  20% { opacity: 1; transform: scale(1.04); }
  60% { opacity: 1; transform: scale(1.12) translateX(-1%); }
  100% { opacity: 0; transform: scale(1.3); }
}
.fx-mirror .face { position: absolute; inset: 0; aspect-ratio: auto; background: transparent; }
.fx-mirror .face img { width: 330% !important; left: -112% !important; top: 15% !important; }
.fx-mirror .face-eye { width: 14%; }
.fx-mirror .face-eye.l { left: 49.4%; top: 45%; }
.fx-mirror .face-eye.r { left: 61.6%; top: 45%; }
.fx-mirror .face-tear { left: 48.5%; top: 48%; width: 4%; height: 20%; }
.fx-mirror .face { animation: ghostFlash 1.1s steps(3, end) forwards; }
.soft .fx-mirror .face { animation: ghostFade 2.4s ease-in-out forwards; }

.scene.lunge { animation: lunge 1.3s cubic-bezier(.2, .8, .2, 1); }
@keyframes lunge {
  0% { transform: none; filter: none; }
  25% { transform: scale(1.14); filter: saturate(.6) contrast(1.3) brightness(.8); }
  35% { transform: scale(1.12) translate(-1%, .5%); }
  45% { transform: scale(1.15) translate(1%, -.5%); }
  100% { transform: none; filter: none; }
}

/* ---------- v2: localized tablets, talismans and keys ---------- */
.tablet .nm.flat { font-family: var(--serif); font-size: clamp(9px, 2.2vw, 13px); gap: .25em; top: 12%; }
.tablet .nm.flat .line { writing-mode: vertical-rl; white-space: nowrap; letter-spacing: .04em; }
.tablet .nm.rows { flex-direction: column; align-items: center; gap: .2em; top: 16%; font-size: clamp(9px, 2.1vw, 13px); }
.tablet .nm.rows .nm-row { white-space: nowrap; line-height: 1.1; }
.key.wide b { font-size: clamp(13px, 3.4vw, 17px); }
.tal b { white-space: pre-line; line-height: 1.05; }
.tal b.v { top: 46%; font-size: clamp(13px, 3.6vw, 19px); }
.tal b.h { top: 58%; font-size: clamp(9px, 2.6vw, 13px); }
.tal b.h.small { font-size: clamp(8px, 2.1vw, 11px); }

/* ---------- v2: story recap on the ending card ---------- */
.end-story { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line); text-align: left; }
.end-story:empty { display: none; }
.end-story h3 { margin: 0 0 10px; text-align: center; font-family: var(--serif); font-size: 18px; letter-spacing: .08em; }
.story-part { margin: 0 0 14px; }
.story-part h4 { margin: 0 0 4px; font-family: var(--serif); font-size: 15px; color: var(--gold); }
.story-part p { margin: 0; font-family: var(--serif); line-height: 1.75; color: #e2d8c6; }
.story-part.locked h4 { color: var(--muted); }
.story-part.locked p, .story-part p.note { color: var(--muted); font-style: italic; }
.story-part p.note { margin-top: 4px; font-size: 13px; }
