@font-face {
  font-family: "Huiwen Mincho";
  src: url("assets/fonts/HuiwenMincho-game.woff2") format("woff2");
  font-display: swap;
  font-weight: 400 500;
}

:root {
  --ink-950: #050a0e;
  --ink-900: #08131e;
  --ink-800: #102333;
  --paper-100: #efe2c4;
  --paper-200: #d8c49b;
  --paper-ink: #2a2118;
  --brass-300: #f0c465;
  --brass-500: #b8862f;
  --brass-700: #6e4818;
  --wax-500: #8a291f;
  --wax-700: #561611;
  --blue-500: #4b87aa;
  --safe-x: max(5vw, env(safe-area-inset-left));
  --safe-y: max(4vh, env(safe-area-inset-top));
  --space-1: clamp(0.4rem, 0.7vw, 0.75rem);
  --space-2: clamp(0.75rem, 1.1vw, 1.15rem);
  --space-3: clamp(1rem, 1.55vw, 1.6rem);
  --space-4: clamp(1.5rem, 2.3vw, 2.4rem);
  --radius-sm: 0.2rem;
  --radius-md: 0.55rem;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
  --layer-scene: 10;
  --layer-hud: 100;
  --layer-overlay: 200;
  --layer-modal: 300;
  --layer-toast: 400;
}

* { box-sizing: border-box; cursor:url("../../assets/ui-v2/paintbrush-cursor.png") 3 60,auto !important; }

html, body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #020405;
  color: var(--paper-100);
  font-family: "Huiwen Mincho", "STZhongsong", "Songti SC", "SimSun", serif;
  font-synthesis: none;
}
.persistence-notice { position: fixed; z-index: 410; top: max(12px,env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: min(92vw,680px); padding: 10px 16px; border: 1px solid #c79a45; background: #f0dfb8; color: #142733; box-shadow: 0 6px 24px #0009; font-weight: 500; }

button, input, select { font: inherit; }
button { color: inherit; }

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid #fff2ad;
  outline-offset: 4px;
}

button:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .45; }

#game {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 360px;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, #102333 0, #050a0e 68%),
    #050a0e;
}

#game::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: var(--layer-toast);
  opacity: .13;
  mix-blend-mode: soft-light;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  opacity: 0;
}

.screen.is-active {
  display: block;
  opacity: 1;
  animation: scene-in 360ms var(--ease-out) both;
}

.safe-zone {
  left: var(--safe-x);
  right: var(--safe-x);
}

#fx-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: var(--layer-toast);
}
body:has(#puzzle-screen.is-active) #fx-canvas { opacity:.08; }

.title-screen {
  background:
    linear-gradient(90deg, rgba(2, 7, 12, .93) 0%, rgba(3, 8, 14, .78) 31%, rgba(3, 8, 14, .08) 62%, rgba(3, 8, 14, .22)),
    url("assets/images/backgrounds/title.png") center / cover no-repeat;
}

.title-screen::before,
.title-vignette {
  content: "";
  position: absolute;
  pointer-events: none;
}

.title-screen::before {
  inset: 1.5vh 1.2vw;
  border: 1px solid rgba(212, 162, 66, .7);
  clip-path: polygon(0 0, 24% 0, 24% .25%, 76% .25%, 76% 0, 100% 0, 100% 100%, 76% 100%, 76% 99.75%, 24% 99.75%, 24% 100%, 0 100%);
}

.title-vignette {
  inset: 0;
  background: radial-gradient(ellipse at 64% 48%, transparent 30%, rgba(0, 0, 0, .58) 100%);
}

.title-content {
  position: absolute;
  top: max(12vh, env(safe-area-inset-top));
  width: min(36rem, 43vw);
  z-index: var(--layer-hud);
}

.archive-stamp {
  display: inline-flex;
  flex-direction: column;
  min-width: 16rem;
  margin-bottom: var(--space-3);
  padding: .7rem 1rem;
  color: #e1c684;
  border: 1px solid rgba(197, 149, 61, .58);
  background: rgba(6, 14, 21, .78);
  font-size: clamp(.75rem, .95vw, 1rem);
  letter-spacing: .1em;
  box-shadow: inset 0 0 0 3px rgba(7, 12, 17, .85), 0 10px 28px rgba(0, 0, 0, .28);
}

.archive-stamp span + span { opacity: .68; margin-top: .25rem; }

.eyebrow {
  margin: 0 0 .55rem;
  color: var(--brass-300);
  font-size: clamp(.76rem, .9vw, 1rem);
  font-style: normal;
  font-weight: 500;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.title-content h1 {
  margin: 0;
  color: #fff8df;
  font-family: "Huiwen Mincho", serif;
  font-size: clamp(4rem, 6vw, 6.4rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: .12em;
  text-shadow: 0 5px 24px rgba(0, 0, 0, .82);
}

.title-subtitle {
  max-width: 30rem;
  margin: var(--space-2) 0 var(--space-3);
  color: #d8c8a8;
  font-size: clamp(1rem, 1.28vw, 1.3rem);
  line-height: 1.75;
  text-shadow: 0 2px 3px #000;
}

.menu-stack { display: grid; width: min(27rem, 36vw); gap: .7rem; margin-top: var(--space-4); }
.menu-stack .game-button { min-height: 4.5rem; padding: .85rem 1.6rem; }
.menu-stack .game-button strong { font-size: clamp(1.4rem, 1.8vw, 1.8rem); letter-spacing: .08em; }

.game-button {
  position: relative;
  min-height: 3.6rem;
  padding: .7rem 1.4rem;
  overflow: hidden;
  cursor: pointer;
  color: #f1e6cb;
  border: 1px solid var(--brass-500);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 36%),
    radial-gradient(circle at 20% 0, #142536, #07111b 72%);
  box-shadow:
    inset 0 0 0 3px #071018,
    inset 0 0 0 4px rgba(184, 134, 47, .34),
    0 8px 20px rgba(0, 0, 0, .36);
  text-align: left;
  transition: transform 180ms var(--ease-out), border-color 180ms, filter 180ms, box-shadow 180ms;
}

.game-button::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-110%);
  background: linear-gradient(110deg, transparent 25%, rgba(255, 224, 150, .18) 48%, transparent 70%);
  transition: transform 420ms var(--ease-out);
}

.game-button:hover:not(:disabled),
.game-button:focus-visible:not(:disabled) {
  z-index: 1;
  border-color: #ffe29a;
  box-shadow: inset 0 0 0 3px #071018, inset 0 0 0 5px #bd8830, 0 0 24px rgba(235, 176, 64, .28), 0 12px 24px rgba(0, 0, 0, .45);
  transform: translateX(.45rem);
}

.game-button:hover::before,
.game-button:focus-visible::before { transform: translateX(110%); }
.game-button:active:not(:disabled) { transform: translateX(.25rem) scale(.985); }

.game-button--primary {
  color: #fff2cf;
  border-color: #dba95b;
  background:
    linear-gradient(180deg, rgba(255, 223, 157, .12), transparent 45%),
    radial-gradient(circle at 20% 0, #a43a2d, var(--wax-700) 74%);
}

.button-kicker,
.game-button strong { position: relative; display: block; }
.button-kicker { color: #c8ab72; font-size: clamp(.74rem, .83vw, .9rem); letter-spacing: .08em; }
.game-button strong { margin-top: .12rem; font-size: clamp(1rem, 1.2vw, 1.25rem); }
.game-button--primary .button-kicker { color: #e9c999; }

.title-route {
  position: absolute;
  bottom: max(4vh, env(safe-area-inset-bottom));
  z-index: var(--layer-hud);
  display: flex;
  align-items: center;
  width: min(48rem, 55vw);
}

.title-route span { flex: 1; height: 1px; background: linear-gradient(90deg, #a97b2d, rgba(169, 123, 45, .28)); }
.route-dot { width: 1rem; height: 1rem; border: 2px solid var(--brass-500); border-radius: 50%; background: #09131c; box-shadow: 0 0 0 4px rgba(4, 9, 13, .7); }
.route-dot.is-current { background: var(--brass-300); box-shadow: 0 0 20px #ddaa42; }

.round-button {
  display: grid;
  place-items: center;
  width: 3.15rem;
  height: 3.15rem;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  cursor: pointer;
  color: #f2d58e;
  border: 1px solid #bd8c37;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 25%, #283949, #08121b 68%);
  box-shadow: inset 0 0 0 3px #08121b, inset 0 0 0 4px rgba(224, 178, 82, .48), 0 5px 14px rgba(0, 0, 0, .42);
  font-size: 1.15rem;
  font-weight: 500;
  transition: transform 160ms var(--ease-back), filter 160ms;
}

.round-button svg { width: 1.55rem; height: 1.55rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.round-button svg path[d*="h3"] { fill: currentColor; stroke: none; }
.round-button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + .5rem);
  left: 50%;
  min-width: 3.8rem;
  padding: .3rem .5rem;
  color: #f3e4bd;
  border: 1px solid rgba(190, 142, 54, .75);
  background: rgba(5, 13, 20, .96);
  font-size: .85rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -.2rem);
  transition: opacity 150ms, transform 150ms;
}
.round-button[data-tooltip]:hover::after,
.round-button[data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }

.round-button:hover,
.round-button:focus-visible { filter: brightness(1.28); transform: scale(1.08); }
.round-button:active { transform: scale(.94); }
.title-sound { position: absolute; top: var(--safe-y); right: var(--safe-x); z-index: var(--layer-hud); }

.story-screen { background: var(--ink-950); }
.scene-media { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: var(--layer-scene); pointer-events: none; }
.scene-fallback { opacity: 0; transition: opacity 240ms; }
.scene-fallback.is-visible { opacity: 1; }

.scene-grade {
  position: absolute;
  inset: 0;
  z-index: calc(var(--layer-scene) + 1);
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(2, 6, 9, .62) 0, transparent 24%, transparent 55%, rgba(2, 5, 8, .7) 100%),
    radial-gradient(ellipse at 50% 48%, transparent 38%, rgba(0, 0, 0, .45) 100%);
}

.character-layer {
  position: absolute;
  z-index: calc(var(--layer-scene) + 2);
  right: 6vw;
  bottom: 10vh;
  width: min(36vw, 34rem);
  height: 74vh;
  pointer-events: none;
  opacity: 0;
  transform: translateX(5vw);
  transition: opacity 260ms, transform 420ms var(--ease-out);
}

.character-layer.is-visible { opacity: 1; transform: translateX(0); }
.character-layer img { width: 100%; height: 100%; object-fit: contain; object-position: bottom center; filter: drop-shadow(0 20px 30px rgba(0, 0, 0, .65)); }
.character-layer.is-framed img { clip-path: ellipse(43% 44% at 52% 42%); background: var(--paper-100); mix-blend-mode: normal; }

.hud {
  position: absolute;
  top: var(--safe-y);
  z-index: var(--layer-hud);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.hud > * { pointer-events: auto; }
.hud-actions { display: flex; gap: .65rem; }
.hint-button { position: relative; }
.hint-count { position: absolute; right: -.3rem; top: -.3rem; display: grid; place-items: center; min-width: 1.35rem; height: 1.35rem; padding: 0 .2rem; color: #241507; border: 1px solid #fff0b3; border-radius: 999px; background: #f1c663; box-shadow: 0 3px 8px rgba(0, 0, 0, .45); font-size: .9rem; font-weight: 500; }
.hint-button.is-guiding { animation: hint-button-pulse 900ms ease-in-out infinite alternate; }
.hud-text { text-shadow: 0 2px 3px #000, 0 0 8px #000; }

.chapter-plaque {
  display: grid;
  grid-template-columns: auto auto;
  min-width: min(27rem, 45vw);
  padding: .65rem 1.15rem .7rem 1.4rem;
  border-left: 4px solid var(--brass-300);
  border-bottom: 1px solid rgba(213, 169, 80, .65);
  background: linear-gradient(90deg, rgba(4, 12, 19, .94), rgba(5, 13, 20, .64), transparent);
}

.chapter-plaque span { grid-row: 1 / span 2; align-self: center; margin-right: 1rem; color: var(--brass-300); font-size: clamp(.78rem, .9vw, 1rem); letter-spacing: .12em; }
.chapter-plaque strong { color: #fff4d7; font-size: clamp(1.05rem, 1.35vw, 1.4rem); }
.chapter-plaque em { color: #c5b89d; font-size: clamp(.75rem, .82vw, .9rem); font-style: normal; }

.objective-card {
  position: absolute;
  top: calc(var(--safe-y) + 5.6rem);
  z-index: var(--layer-hud);
  width: min(24rem, 34vw);
  padding: .85rem 1.1rem .9rem 1.25rem;
  border-left: 3px solid var(--brass-300);
  background: linear-gradient(95deg, rgba(5, 14, 22, .94), rgba(6, 17, 27, .74));
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
  transition: opacity 250ms, transform 250ms;
}

.objective-card span { display: block; color: var(--brass-300); font-size: clamp(.75rem, .84vw, .9rem); letter-spacing: .1em; }
.objective-card strong { display: block; margin-top: .25rem; color: #f3e5c8; font-size: clamp(.9rem, 1.05vw, 1.08rem); line-height: 1.45; }
.objective-progress { display: flex; gap: .4rem; margin-top: .6rem; }
.objective-progress i { width: .65rem; height: .65rem; border: 1px solid #9d7d46; border-radius: 50%; background: transparent; }
.objective-progress i.is-complete { background: var(--brass-300); box-shadow: 0 0 10px rgba(255, 207, 103, .65); }

.hotspot-layer { position: absolute; inset: 0; z-index: calc(var(--layer-hud) - 10); pointer-events: none; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.hotspot {
  position: absolute;
  display: grid;
  place-items: center;
  width: clamp(3rem, 4vw, 4.2rem);
  height: clamp(3rem, 4vw, 4.2rem);
  min-width: 48px;
  min-height: 48px;
  cursor: pointer;
  pointer-events: auto;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  opacity: .38;
  transform: translate(-50%, -50%);
  animation: hotspot-glint 2.8s ease-in-out infinite;
}

.hotspot::before { content: ""; width: .48rem; height: .48rem; border-radius: 50%; background: #e8c06d; box-shadow: 0 0 .35rem #e8c06d, 0 0 1.1rem rgba(232, 192, 109, .55); }
.hotspot::after { content: ""; position: absolute; inset: 20%; border: 1px solid rgba(232, 192, 109, .45); border-radius: 50%; opacity: 0; transform: scale(.7); transition: transform 180ms, opacity 180ms; }
.hotspot:hover, .hotspot:focus-visible { opacity: 1; animation-play-state: paused; }
.hotspot:hover::after, .hotspot:focus-visible::after { opacity: 1; transform: scale(1.25); border-color: #f0ca78; }
.hotspot.is-complete { animation: none; opacity: 0; pointer-events: none; }
.hotspot.is-hinted { opacity: 1; }
.is-hinted-strong { z-index: 6 !important; overflow: visible !important; }
.hotspot.is-hinted::before { width: .7rem; height: .7rem; background: #fff0a8; box-shadow: 0 0 .6rem #fff0a8, 0 0 2rem #f1bd55; }
.hotspot.is-hinted::after { inset: 4%; opacity: 1; border: 3px solid #ffe08a; border-radius: .65rem; background: rgba(246, 191, 70, .08); box-shadow: 0 0 0 2px rgba(5, 10, 14, .75), 0 0 2rem rgba(246, 191, 70, .9), inset 0 0 2rem rgba(246, 191, 70, .16); transform: scale(1); animation: hint-ring 850ms ease-in-out infinite alternate; }
.hint-callout { position: absolute !important; left: 50% !important; top: -2.3rem !important; z-index: 2; width: auto !important; height: auto !important; min-width: 5.8rem; margin: 0 !important; padding: .45rem .75rem !important; overflow: visible !important; clip: auto !important; color: #241507; border: 1px solid #fff1b6 !important; border-radius: .25rem; background: #f1c663; box-shadow: 0 .4rem 1rem rgba(0, 0, 0, .55); font-size: 1rem; font-weight: 500; white-space: nowrap !important; transform: translateX(-50%); }
.hint-callout::after { content: ""; position: absolute; left: 50%; bottom: -.65rem; border: .35rem solid transparent; border-top-color: #f1c663; transform: translateX(-50%); }

.dialogue-panel {
  position: absolute;
  bottom: max(1.8vh, env(safe-area-inset-bottom));
  z-index: var(--layer-hud);
  display: grid;
  grid-template-columns: minmax(9rem, .8fr) minmax(26rem, 2.25fr) minmax(9rem, .8fr);
  align-items: end;
  min-height: 54vh;
  padding: 0;
  pointer-events: none;
  transform: translateY(10%);
  opacity: 0;
  transition: transform 360ms var(--ease-out), opacity 220ms;
}

.dialogue-panel.is-visible { transform: translateY(0); opacity: 1; }
.dialogue-center { grid-column: 2; align-self: center; display: grid; align-content: center; gap: .85rem; min-width: 0; pointer-events: auto; }
.dialogue-copy {
  position: relative;
  min-height: clamp(8.5rem, 17vh, 11rem);
  padding: clamp(2rem, 3vw, 2.8rem) clamp(2rem, 3.4vw, 3.4rem) 1.3rem;
  color: #2d2016;
  border: 1px solid #9b7849;
  background: linear-gradient(148deg, #fffaf0, #e9dcc0 76%);
  box-shadow: 0 14px 35px rgba(0, 0, 0, .42), inset 0 0 0 4px rgba(255, 255, 255, .28);
  transform: rotate(-.35deg);
}
.dialogue-copy::after { content: ""; position: absolute; right: 12%; bottom: -1.1rem; width: 2.2rem; height: 1.4rem; background: #e9dcc0; clip-path: polygon(0 0, 100% 0, 100% 100%); }
.speaker-name { position: absolute; left: 1.4rem; top: -.8rem; z-index: 2; display: inline-block; padding: .35rem 1rem; color: #fff5df; border-radius: 999px; background: linear-gradient(180deg, #b75c45, #833324); box-shadow: 0 4px 10px rgba(0, 0, 0, .28); font-size: clamp(.95rem, 1.1vw, 1.15rem); font-weight: 500; letter-spacing: .08em; }
.dialogue-text { min-height: 3.4em; margin: 0; color: #2d2016; font-size: clamp(1rem, 1.25vw, 1.35rem); font-weight: 600; line-height: 1.72; white-space: pre-line; }
.advance-hint { justify-self: center; display: block; min-width: 7rem; padding: .4rem .8rem; color: #e8d8b6; border: 1px solid rgba(201, 154, 63, .62); background: rgba(5, 14, 22, .86); font-size: clamp(.75rem, .84vw, .9rem); text-align: center; letter-spacing: .08em; }
.choice-list { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin: 0; }
.has-choices .choice-list { display: grid; }
.choice-button { min-height: 4.5rem; padding: .8rem 1.2rem; color: #eadab8; border-color: #88652b; background: linear-gradient(160deg, #2d2042, #171426 72%); text-align: center; white-space: pre-line; }
.choice-button:nth-child(even) { transform: rotate(.3deg); }
.choice-button:hover:not(:disabled), .choice-button:focus-visible:not(:disabled) { transform: translateY(-.2rem); border-color: #f1cc7c; background: linear-gradient(160deg, #593a72, #2b1f42 72%); }
.choice-button::after { content: ""; position: absolute; left: .8rem; top: 50%; width: .5rem; height: .5rem; border: 1px solid #c99a3e; border-radius: 50%; transform: translateY(-50%); }
.choice-button:hover::after, .choice-button:focus-visible::after { background: var(--brass-300); box-shadow: 0 0 12px var(--brass-300); }
.choice-button.is-hinted { border-color: #ffe09b; box-shadow: inset 0 0 0 3px #0b1018, 0 0 30px rgba(245, 191, 75, .75); animation: hint-choice 900ms ease-in-out infinite alternate; }

.dialogue-character { position: relative; align-self: end; min-width: 0; height: min(47vh, 31rem); pointer-events: none; opacity: .55; filter: saturate(.7) brightness(.75); transform: scale(.94); transition: opacity 180ms, filter 180ms, transform 220ms var(--ease-out); }
.dialogue-character.is-speaking { opacity: 1; filter: saturate(1) brightness(1); transform: scale(1); }
.dialogue-character img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; filter: drop-shadow(0 16px 24px rgba(0, 0, 0, .58)); }
.dialogue-character--left { grid-column: 1; }
.dialogue-character--right { grid-column: 3; }
.character-caption { position: absolute; left: 50%; bottom: .35rem; min-width: 7rem; padding: .38rem .7rem; color: #f4e2b9; border: 1px solid #ac7b2e; background: rgba(7, 17, 25, .93); text-align: center; transform: translateX(-50%); }
.affinity-badge { position: absolute; right: 0; bottom: 3.6rem; padding: .45rem .75rem; color: #f3ddb0; border: 1px solid #a56a2d; background: rgba(91, 30, 24, .95); box-shadow: 0 6px 16px rgba(0, 0, 0, .4); }
.affinity-badge strong { margin-left: .35rem; color: #ffe79c; font-size: 1.25rem; }

.dialogue-panel.is-narration .dialogue-character { opacity: .15; filter: grayscale(1) brightness(.55); }
.dialogue-panel.is-narration .dialogue-copy::after { display: none; }
.dialogue-panel.is-narration .speaker-name { background: #5b4936; }

@keyframes hint-choice { from { filter: brightness(1); } to { filter: brightness(1.25); } }

.context-cta {
  position: absolute;
  z-index: var(--layer-hud);
  left: var(--safe-x);
  right: var(--safe-x);
  bottom: max(5vh, env(safe-area-inset-bottom));
  width: min(22rem, 42vw);
  margin-inline: auto;
  text-align: center;
  transform: none;
}

.context-cta.game-button:hover:not(:disabled),
.context-cta.game-button:focus-visible:not(:disabled) { transform: translateY(-.25rem); }

.toast {
  position: absolute;
  z-index: var(--layer-toast);
  top: calc(var(--safe-y) + 6rem);
  right: var(--safe-x);
  width: min(23rem, 36vw);
  padding: .9rem 1.1rem .9rem 3.2rem;
  pointer-events: none;
  border: 1px solid var(--brass-500);
  background: linear-gradient(110deg, #0b1a26, #071018);
  box-shadow: 0 10px 32px rgba(0, 0, 0, .52);
  color: #f5e5bf;
  font-size: clamp(.85rem, 1vw, 1rem);
  line-height: 1.55;
  transform: translateX(130%);
  opacity: 0;
  transition: transform 280ms var(--ease-out), opacity 220ms;
}
.toast::before { content: "✦"; position: absolute; left: 1.1rem; top: 50%; color: var(--brass-300); font-size: 1.25rem; transform: translateY(-50%); }
.toast.is-visible { transform: translateX(0); opacity: 1; }

.overlay-screen { z-index: var(--layer-overlay); }
.overlay-scrim, .modal-scrim { position: absolute; inset: 0; background: rgba(1, 5, 8, .78); backdrop-filter: blur(5px); }

.puzzle-shell {
  position: absolute;
  top: max(5vh, env(safe-area-inset-top));
  bottom: max(5vh, env(safe-area-inset-bottom));
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(20px,2.2vw,40px);
  border: 28px solid transparent;
  background:
    linear-gradient(#b7a47b,#a89469) padding-box;
  border-image: url("../../assets/ui-v2/frame-9slice.png") 115 / 42px / 8px stretch;
  box-shadow: 0 24px 80px #000;
}

.puzzle-header { display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid rgba(199, 154, 69, .48); padding-bottom: .85rem; }
.archive-tab { position:relative; display:grid; grid-template-columns:auto 1fr; align-items:center; color:#35271b; }
.archive-tab::before { content:""; position:absolute; inset:-18px -24px -8px; z-index:-1; background:#d7c498; border:1px solid #80613a; box-shadow:4px 4px 0 #80613a35; }
.puzzle-header h2 { margin: 0 0 0 18px; color: #362719; font-size: clamp(1.45rem, 2.2vw, 2.35rem); font-weight:500; }
.puzzle-header .eyebrow { margin:0; color:#70281f; }
.puzzle-header p { margin:.45rem 0 0; color:#443222; font-size:clamp(.9rem,1.05vw,1.1rem); }
.objective-slip { grid-column:1/-1; min-width:min(620px,60vw); padding:8px 18px; background:url("../../assets/ui-v2/hint-note.png") center/100% 100% no-repeat; }
.puzzle-counter { display: grid; place-items: center; min-width: 8rem; min-height: 3.4rem; color: #3b2919; background:url("../../assets/ui-v2/gauge.png") center/100% 100% no-repeat; font-weight:500; }
.puzzle-counter { width:clamp(150px,13vw,190px); max-width:190px; padding:0 14px; white-space:nowrap; overflow:hidden; text-overflow:clip; font-size:clamp(15px,1.05vw,18px); }
.puzzle-workbench { display:grid; grid-template-columns:minmax(0,1fr) minmax(160px,20%); gap:12px; min-height:0; padding:12px 0; }
.puzzle-content { position: relative; display: grid; place-items: center; min-height: 0; overflow: auto; background:#b9a77e; border:2px solid #80613a; box-shadow:inset 0 0 0 6px #d4c399,inset 0 0 35px #43301c42; }
.tool-tray { display:grid; grid-template-rows:auto minmax(120px,1fr) auto; min-width:0; padding:12px; color:#ddcda5; background:#26372e; border:10px solid #51351f; box-shadow:inset 0 0 0 2px #a87938; }
.tool-tray > span { text-align:center; color:#2f2014; background:#c3aa76; border:1px solid #6a4a2a; padding:8px; }
.tool-tray .tool-image { width:100%; min-height:120px; margin:auto; background-position:center; background-size:contain; background-repeat:no-repeat; filter:drop-shadow(0 7px 8px #0008); }
.tool-tray[data-tool="storage"] .tool-image { background-image:url("../../assets/ui-v2/tool-storage.png"); }
.tool-tray[data-tool="cleaning"] .tool-image { background-image:url("../../assets/ui-v2/tool-cleaning.png"); }
.tool-tray[data-tool="magnifier"] .tool-image { background-image:url("../../assets/ui-v2/tool-magnifier.png"); }
.tool-tray[data-tool="collection"] .tool-image { background-image:url("../../assets/ui-v2/wax-seal.png"); }
.tool-tray[data-tool="jigsaw"] .tool-image { background-image:url("../../assets/ui-v2/tool-jigsaw.png"); }
.tool-tray[data-tool="route"] .tool-image { background-image:url("../../assets/ui-v2/tool-route.png"); }
.tool-tray p { margin:0; line-height:1.6; font-size:15px; }
.puzzle-footer { display:flex; align-items:center; gap:0; min-height:58px; padding:0 8px; border:1px solid #6c4b2a; background:linear-gradient(180deg,#3a281b,#21160f); box-shadow:inset 0 2px #77532d; }
.ledger-control { flex:0 0 auto; min-width:108px; color:#d9bd7b; background:transparent; border-width:0 1px 0 0; border-color:#80613a; box-shadow:none; }
.ledger-control::before { display:inline-block; margin-right:8px; font-size:21px; vertical-align:-2px; }.ledger-control:hover,.ledger-control:focus-visible { background:#ffffff0b; transform:none; }
#puzzle-undo::before { content:"↶"; } #puzzle-reset::before { content:"↻"; } #puzzle-hint-button::before { content:"?"; width:22px; height:22px; line-height:22px; border:1px solid currentColor; border-radius:50%; text-align:center; font-size:15px; }
.hint-note-button { color:#d9bd7b; background:transparent; }
.wax-submit { align-self:center; justify-self:center; width:82px; height:82px; min-width:64px; min-height:64px; margin:-13px 8px; padding:11px; color:#f1d9b1; border:0; border-radius:50%; background:url("../../assets/ui-v2/wax-seal.png") center/contain no-repeat; text-shadow:0 2px 3px #42120e; cursor:pointer; transition:transform 220ms ease-out,filter 220ms ease-out; }
.wax-submit { margin-left:auto; }.wax-submit[hidden] { display:none; }
.wax-submit:hover { transform:translateY(-3px) rotate(-3deg); filter:brightness(1.1); }.wax-submit:focus-visible { outline:3px solid #ffe1a0; outline-offset:3px; }.wax-submit:active { transform:translateY(1px) scale(.97); }
.parent-return-bookmark { position:fixed; z-index:210; left:max(2vw,env(safe-area-inset-left)); top:max(3vh,env(safe-area-inset-top)); min-width:64px; min-height:92px; max-width:126px; padding:12px 16px 22px; color:#e0c990; border:0; background:url("../../assets/ui-v2/return-bookmark.png") center/100% 100% no-repeat; cursor:pointer; writing-mode:vertical-rl; }
.parent-return-bookmark:focus-visible { outline:3px solid #ffe3a1; outline-offset:4px; }
@media (max-width:920px) {
  #puzzle-screen,#puzzle-screen button,#puzzle-screen p,#puzzle-screen li,#puzzle-screen strong,#puzzle-screen small,#puzzle-screen span { font-size:15px; }
}
.high-contrast .puzzle-shell { background:#fff7d7; border-image:none; border-color:#120c08; box-shadow:inset 0 0 0 5px #fff,0 0 0 8px #000; }
.high-contrast .puzzle-content,.high-contrast .objective-slip,.high-contrast .archive-tab::before { color:#050403; background-color:#fffbe8; }
.high-contrast .tool-tray { color:#fff; background:#06120d; border-color:#fff; }
.high-contrast .ledger-control,.high-contrast .overhaul-button { color:#fff; background:#120c08; border-color:#fff; }
.high-contrast .overhaul-status,.high-contrast .keyboard-guide,.high-contrast .route-board,.high-contrast .route-map { color:#050403; background-color:#fffbe8; border-color:#050403; }

/* Legacy renderer styles are quarantined for loopback-only migration tests and never match production media. */
@media not all {
.painting-stack { position: relative; width: min(48rem, 70vw); height: min(30rem, 58vh); }
.stack-painting {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(28rem, 44vw);
  aspect-ratio: 1.5;
  min-height: 12rem;
  cursor: pointer;
  border: .9rem solid #291d12;
  background-position: center;
  background-size: cover;
  box-shadow: 0 18px 38px rgba(0, 0, 0, .62), inset 0 0 0 2px #c29036;
  transform: translate(-50%, -50%) rotate(var(--rotation));
  transition: transform 520ms var(--ease-out), opacity 400ms;
}
.stack-painting:hover, .stack-painting:focus-visible { filter: brightness(1.12); }
.stack-painting.is-moved { transform: translate(calc(-50% + var(--move-x)), calc(-50% + var(--move-y))) rotate(var(--move-r)); opacity: .38; pointer-events: none; }
.stack-painting.is-secret { background-image: url("assets/images/backgrounds/title.png"); pointer-events: none; }

.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(9rem, 1fr)); gap: clamp(.65rem, 1.15vw, 1.15rem); width: min(58rem, 72vw); }
.gallery-painting { position: relative; aspect-ratio: 1.55; min-height: 7rem; overflow: hidden; cursor: pointer; border: .55rem solid #2a1c10; background: #392a1b center / cover; box-shadow: inset 0 0 0 2px #a8782d, 0 12px 24px rgba(0, 0, 0, .44); transition: transform 200ms var(--ease-out), filter 200ms; }
.gallery-painting:hover, .gallery-painting:focus-visible { transform: translateY(-.4rem) scale(1.02); filter: brightness(1.15); }
.gallery-painting::after { display: none; }

.jigsaw-board { display: grid; grid-template-columns: repeat(3, 1fr); width: min(46rem, 70vw); aspect-ratio: 16 / 9; overflow: hidden; border: .85rem solid #2a1c10; box-shadow: inset 0 0 0 2px #b6802d, 0 18px 42px rgba(0, 0, 0, .62); }
.jigsaw-tile { min-width: 0; min-height: 0; cursor: pointer; border: 1px solid rgba(225, 178, 77, .38); background-image: url("assets/images/backgrounds/chapter-3.png"); background-size: 300% 200%; transition: filter 160ms, box-shadow 160ms; }
.jigsaw-tile:hover, .jigsaw-tile:focus-visible { filter: brightness(1.15); }
.jigsaw-tile.is-selected { box-shadow: inset 0 0 0 4px #f3ca77; filter: brightness(1.22); }
.gallery-painting.is-wrong { animation: reject 280ms ease; filter: grayscale(.7) brightness(.62); }
.gallery-painting.is-correct { box-shadow: inset 0 0 0 3px #ffdc82, 0 0 32px #d08e1f; }
.gallery-painting.is-hinted, .stack-painting.is-hinted, .jigsaw-tile.is-hinted, .detail-hotspot.is-hinted, .assembly-slot.is-hinted, .assembly-piece.is-hinted, .scratch-canvas.is-hinted, .steady-safe.is-hinted { box-shadow: inset 0 0 0 4px #ffe49a, 0 0 34px rgba(246, 191, 70, .8); filter: brightness(1.2); }

.scratch-board { position: relative; width: min(46rem, 72vw); aspect-ratio: 16 / 9; overflow: hidden; border: .9rem solid #291d12; background: #b89659; box-shadow: inset 0 0 0 2px #c9973d, 0 18px 42px #000; }
.seal-reveal { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 1rem; color: #422513; background: radial-gradient(circle, #dec48e, #a8783d); font-size: clamp(1.8rem, 3vw, 3.4rem); letter-spacing: .25em; text-shadow: 0 1px #f4ddad; }
.seal-reveal b { display: grid; place-items: center; width: 5rem; aspect-ratio: 1; border: .35rem double #7e241a; color: #7e241a; font-size: 2.4rem; transform: rotate(-7deg); }
.scratch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; transition: opacity .5s; }
.scratch-canvas:focus-visible { outline: 4px solid #ffe49a; outline-offset: -5px; }
.scratch-canvas:active { cursor: grabbing; }
.scratch-canvas.is-cleared { opacity: .22; pointer-events: none; }
.scratch-keyboard-cursor { position:absolute; z-index:3; width:2rem; height:2rem; transform:translate(-50%,-50%); border:3px solid #fff0b0; border-radius:50%; box-shadow:0 0 0 2px #3b2412,0 0 16px #ffd46c; pointer-events:none; opacity:0; }
.scratch-canvas:focus-visible + .scratch-keyboard-cursor { opacity:1; }
.scratch-keyboard-help { position:absolute; z-index:4; left:50%; bottom:.4rem; transform:translateX(-50%); margin:0; padding:.45rem .8rem; color:#fff0bd; background:#07111be6; border:1px solid #a9853f; font-size:.9rem; white-space:nowrap; pointer-events:none; }

.boot-inspection { position: relative; width: min(48rem, 72vw); aspect-ratio: 16 / 9; border: .85rem solid #291d12; background: #251a10 center / cover no-repeat; box-shadow: inset 0 0 0 2px #c29036, 0 18px 42px #000; }
.detail-hotspot { position: absolute; width: clamp(3.2rem, 5vw, 5rem); aspect-ratio: 1; padding: 0; cursor: crosshair; border: 1px solid rgba(252, 217, 139, .42); border-radius: 50%; background: rgba(7, 15, 20, .12); color: transparent; transform: translate(-50%, -50%); transition: width .25s, border-radius .25s, background .25s, color .25s; }
.detail-hotspot::after { content: ""; position: absolute; inset: 32%; border-radius: 50%; background: rgba(255, 223, 148, .38); animation: hotspot-glint 2.4s infinite; }
.detail-hotspot:hover, .detail-hotspot:focus-visible { background: rgba(230, 184, 86, .2); }
.detail-hotspot.is-found { width: auto; min-width: 8rem; aspect-ratio: auto; padding: .5rem .8rem; border-radius: .15rem; background: rgba(5, 14, 21, .9); color: #ffe4a3; box-shadow: 0 0 0 2px #bd8731; }
.detail-hotspot.is-found::after { display: none; }

.steady-board { display: grid; justify-items: center; align-content: center; gap: 1.2rem; width: min(48rem, 72vw); min-height: min(28rem, 54vh); padding: 2rem; border: 1px solid #9a6d28; background: radial-gradient(circle at 50% 22%, #25343d, #071018 68%); box-shadow: inset 0 0 0 5px #03090d, inset 0 0 0 6px #80591f; }
.carving-figure { display: grid; place-items: center; width: clamp(7rem, 12vw, 11rem); aspect-ratio: .72; color: #bb7b32; background: linear-gradient(130deg, #6c3e1e, #29170d); clip-path: polygon(50% 0, 86% 23%, 72% 100%, 28% 100%, 14% 23%); font-size: 3rem; filter: drop-shadow(0 14px 10px #000); transform-origin: 50% 100%; }
.steady-track { position: relative; width: min(38rem, 62vw); height: 1.4rem; border: 2px solid #7b5a29; border-radius: 1rem; background: #02070a; }
.steady-safe { position: absolute; left: 30%; top: 0; width: 40%; height: 100%; background: linear-gradient(90deg, #6d842d, #d3b34b, #6d842d); box-shadow: 0 0 18px rgba(221, 190, 89, .4); }
.steady-marker { position: absolute; top: 50%; width: 1.2rem; height: 2.5rem; border: 2px solid #fff1ba; border-radius: .2rem; background: #b53425; transform: translate(-50%, -50%); box-shadow: 0 0 16px #db9a4c; }
.steady-feedback { min-height: 1.8em; margin: 0; color: #cdbd9c; }

.assembly-board { display: grid; grid-template-columns: 1.3fr .7fr; gap: 1.4rem; width: min(60rem, 80vw); min-height: min(31rem, 58vh); }
.assembly-canvas { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; align-items: center; padding: 1.2rem; border: .8rem solid #2a1c10; background: radial-gradient(circle at 50% 42%, #20303a, #071017); box-shadow: inset 0 0 0 2px #aa7930, 0 18px 38px #000; }
.assembly-slot { min-width: 0; aspect-ratio: .72; cursor: pointer; border: 2px dashed rgba(222, 177, 84, .56); background: rgba(255, 255, 255, .025) center / cover; box-shadow: inset 0 0 25px #000; transition: filter .2s, transform .2s; }
.assembly-slot::after { content: "放置"; color: #a9946e; }
.assembly-slot.is-filled { border-style: solid; border-color: #e2bd68; filter: sepia(.28) saturate(.8); }
.assembly-slot.is-filled::after { content: ""; }
.assembly-slot.is-wrong { animation: reject .3s ease; border-color: #bc3f31; }
.assembly-tray { display: grid; align-content: center; gap: .8rem; }
.assembly-piece { min-height: 7rem; cursor: grab; border: .45rem solid #2a1c10; background: #15222b center / cover; box-shadow: inset 0 0 0 1px #b68332, 0 9px 20px #000; transition: transform .2s, opacity .2s; }
.assembly-piece:hover, .assembly-piece:focus-visible, .assembly-piece.is-selected { transform: translateX(-.45rem); box-shadow: inset 0 0 0 2px #ffe09a, 0 0 25px rgba(237, 186, 77, .45); }
.assembly-piece:disabled { opacity: .2; cursor: default; transform: none; }

.composition-board { display: grid; grid-template-columns: 1.15fr .85fr; gap: var(--space-3); width: min(66rem, 82vw); min-height: min(30rem, 58vh); }
.composition-canvas { position: relative; overflow: hidden; border: 1rem solid #2b1e13; background: linear-gradient(155deg, #485867 0 42%, #25170f 43%); box-shadow: inset 0 0 0 2px #b8822b, 0 18px 40px #000; }
.composition-canvas::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(100deg, transparent, rgba(255, 207, 108, .08)); }
.composition-items { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; align-content: center; }
.still-item { position: relative; display: grid; place-items: center; min-height: 7rem; cursor: grab; border: 1px solid #8e692f; background: radial-gradient(circle at 30% 20%, #263b49, #0a1720); box-shadow: inset 0 0 0 3px #071018; font-size: 3.2rem; transition: transform 180ms var(--ease-back), filter 180ms; }
.still-item:hover, .still-item:focus-visible { transform: scale(1.05); filter: brightness(1.2); }
.still-item[aria-pressed="true"] { border-color: #ffe096; box-shadow: inset 0 0 0 3px #071018, 0 0 24px rgba(239, 188, 79, .35); }
.placed-item { position: absolute; display: grid; place-items: center; width: 22%; aspect-ratio: 1; font-size: clamp(2.5rem, 5vw, 5rem); transform: translate(-50%, -50%); filter: drop-shadow(0 10px 8px rgba(0, 0, 0, .55)); animation: place-pop 240ms var(--ease-back); }

.memory-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); width: min(68rem, 84vw); }
.memory-card { position: relative; min-height: min(25rem, 52vh); padding: 1rem; cursor: pointer; border: 1px solid var(--brass-500); background: #0b1721; box-shadow: inset 0 0 0 4px #060c11, 0 14px 32px rgba(0, 0, 0, .5); transition: transform 200ms var(--ease-out), filter 200ms; }
.memory-card:hover, .memory-card:focus-visible { transform: translateY(-.5rem); filter: brightness(1.12); }
.memory-card.is-selected { border-color: #ffe09a; box-shadow: inset 0 0 0 4px #060c11, 0 0 28px rgba(241, 189, 77, .48); }
.memory-card .memory-icon { display: grid; place-items: center; height: 55%; color: var(--brass-300); font-size: clamp(3.8rem, 7vw, 7rem); background: radial-gradient(circle, #26313a, #080e13 68%); }
.memory-card h3 { margin: 1rem 0 .45rem; color: #f2dfb9; font-size: clamp(1rem, 1.3vw, 1.35rem); }
.memory-card p { margin: 0; color: #b9aa8d; font-size: clamp(.8rem, .92vw, .98rem); line-height: 1.55; }
}

.transition-card {
  position: absolute;
  top: 50%;
  z-index: 1;
  display: grid;
  justify-items: center;
  width: min(58rem, 78vw);
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 4rem);
  border: 1px solid var(--brass-500);
  background:
    linear-gradient(rgba(34, 24, 16, .84), rgba(19, 13, 9, .9)),
    url("../../assets/ui-v2/objective-note.png") center / cover;
  box-shadow: inset 0 0 0 5px #050a0f, inset 0 0 0 6px #a07024, 0 30px 90px #000;
  text-align: center;
  transform: translateY(-50%);
}
.transition-card h2 { margin: 1rem 0 .4rem; color: #fff1c7; font-size: clamp(2rem, 4vw, 4rem); }
.transition-card blockquote { margin: .6rem 0; color: var(--brass-300); font-size: clamp(1.05rem, 1.5vw, 1.55rem); line-height: 1.6; }
.transition-card p { max-width: 38rem; color: #cbbd9e; line-height: 1.7; }
.transition-card .game-button { min-width: 17rem; margin-top: 1rem; text-align: center; }

.fragment-medallion { position: relative; display: block; width: clamp(7rem, 10vw, 10rem); aspect-ratio: 1; overflow: hidden; border: 3px solid #22160b; border-radius: 50%; background: #07121b; box-shadow: 0 0 0 2px #c99437, 0 0 28px rgba(205, 145, 41, .24); }
.fragment-medallion i { position: absolute; inset: 0; opacity: .22; background: #182634; transition: opacity 260ms, background 260ms; }
.fragment-medallion i:nth-of-type(1) { clip-path: polygon(50% 50%, 0 0, 100% 0); }
.fragment-medallion i:nth-of-type(2) { clip-path: polygon(50% 50%, 100% 0, 100% 100%, 50% 100%); }
.fragment-medallion i:nth-of-type(3) { clip-path: polygon(50% 50%, 50% 100%, 0 100%, 0 0); }
.fragment-medallion i.is-found { opacity: 1; background: radial-gradient(circle at 45% 45%, #9a4931, #311516 60%, #10171c); }
.fragment-medallion b { position: absolute; left: 50%; top: 50%; width: 1.7rem; aspect-ratio: 1; border: 2px solid #6f1d17; border-radius: 50%; background: var(--wax-500); transform: translate(-50%, -50%); box-shadow: 0 0 0 2px #c08a3c; }

.ending-screen { background: #05090d; }
.cinematic-screen { background: #020609; }
.cinematic-screen video,.cinematic-fallback { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.cinematic-fallback { z-index:0; display:block; }
.cinematic-screen video { z-index:1; }
.cinematic-screen video.is-failed { display:none; }
.cinematic-grade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0, 0, 0, .25), transparent 42%, rgba(0, 0, 0, .68)); }
.cinematic-caption { position: absolute; left: 50%; bottom: 6vh; z-index: 1; color: #f6e7bd; font-size: clamp(1.15rem, 1.7vw, 1.7rem); letter-spacing: .1em; text-align: center; text-shadow: 0 3px 8px #000; transform: translateX(-50%); }
.cinematic-caption[hidden] { display: none; }
.cinematic-skip { position: absolute; right: max(2rem, env(safe-area-inset-right)); top: max(2rem, env(safe-area-inset-top)); z-index: 2; min-width: 6rem; min-height: 2.8rem; background: rgba(5, 13, 18, .76); }
.ending-screen > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ending-grade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(2, 7, 12, .92) 0, rgba(3, 8, 12, .62) 38%, rgba(2, 6, 10, .08) 70%, rgba(1, 4, 7, .28)); }
.ending-copy { position: absolute; top: 50%; z-index: 1; width: min(38rem, 43vw); transform: translateY(-50%); }
.ending-copy h2 { margin: 0; color: #fff3cc; font-family: "Huiwen Mincho", serif; font-size: clamp(3.2rem, 6vw, 6rem); font-weight: 400; line-height: 1.05; text-shadow: 0 4px 20px #000; }
.ending-copy blockquote { margin: var(--space-2) 0; color: var(--brass-300); font-size: clamp(1.15rem, 1.6vw, 1.65rem); line-height: 1.7; text-shadow: 0 2px 4px #000; }
.ending-copy p { color: #d6c7a8; font-size: clamp(.95rem, 1.1vw, 1.12rem); line-height: 1.8; text-shadow: 0 2px 3px #000; }
.ending-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .65rem; margin-top: var(--space-3); }
.ending-actions .game-button:first-child { grid-column: 1 / -1; }

.modal { position: absolute; inset: 0; z-index: var(--layer-modal); display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal-card, .pause-card, .journal-book { position: relative; z-index: 1; width: min(62rem, 86vw); max-height: 84vh; padding: var(--space-3); overflow: auto; border: 1px solid var(--brass-500); background: linear-gradient(145deg, rgba(10, 24, 35, .98), rgba(4, 10, 15, .99)); box-shadow: inset 0 0 0 5px #050b10, inset 0 0 0 6px #956925, 0 30px 90px #000; }
.modal-card header, .journal-book header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); padding-bottom: .8rem; border-bottom: 1px solid rgba(197, 148, 60, .5); }
.modal-card h2, .journal-book h2, .pause-card h2 { margin: 0; color: #fbeac0; font-size: clamp(1.8rem, 2.8vw, 3rem); }

.journal-book { width: min(72rem, 90vw); background: linear-gradient(90deg, #d3bd91, #f0e3c5 48%, #d6bf91 50%, #efe0c1); color: #2a2118; }
.journal-book header { border-color: #896834; }
.journal-book h2 { color: #38281c; }
.journal-pages { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.witness-list { display: grid; gap: .7rem; }
.witness-entry { display: grid; grid-template-columns: 4.5rem 1fr; gap: .8rem; min-height: 5.2rem; padding: .55rem; border: 1px solid #987443; background: rgba(255, 249, 231, .42); }
.witness-entry img { width: 4rem; aspect-ratio: 1; object-fit: cover; border: 2px solid #4e371d; border-radius: 50%; background: #d8c69e; }
.witness-entry.is-locked { filter: grayscale(1); opacity: .45; }
.witness-entry h3 { margin: .1rem 0 .25rem; font-size: 1rem; }
.witness-entry p { margin: 0; font-size: clamp(.78rem, .9vw, .92rem); line-height: 1.45; }
.journal-fragments { display: grid; place-items: center; align-content: center; min-height: 24rem; border-left: 1px dashed #9b7844; }
.fragment-medallion--large { width: min(22rem, 28vw); }
.journal-fragments p { max-width: 25rem; text-align: center; line-height: 1.65; }

.backlog-list { margin: 0; padding: 0 0 0 1.4rem; }
.backlog-list li { margin-bottom: .65rem; padding: .7rem .9rem; color: #cdbd9d; border-left: 2px solid #79571e; background: rgba(255, 255, 255, .025); line-height: 1.6; }
.backlog-list strong { color: var(--brass-300); }

.settings-card { width: min(40rem, 86vw); }
.settings-card > label { display: grid; grid-template-columns: 1fr minmax(12rem, 1.2fr); align-items: center; gap: 1rem; min-height: 4rem; padding: .65rem 0; border-bottom: 1px solid rgba(188, 145, 65, .24); }
.settings-card input[type="range"] { accent-color: var(--brass-300); }
.settings-card select { min-height: 3rem; color: #f0e2c4; border: 1px solid #94702f; background: #08131d; padding: 0 .8rem; }
.settings-card .toggle-row { grid-template-columns: auto 1fr; }
.settings-card input[type="checkbox"] { width: 1.4rem; height: 1.4rem; accent-color: var(--brass-300); }
.settings-card > .game-button { width: 100%; margin-top: .7rem; text-align: center; }
.danger-button { border-color: #82382f; color: #e6b5ad; }

.chapter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; }
.chapter-card { position: relative; min-height: 11rem; padding: 1rem; overflow: hidden; cursor: pointer; border: 1px solid #986c25; background: center / cover; text-align: left; }
.chapter-card::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(3, 9, 14, .94), rgba(4, 10, 15, .55)); }
.chapter-card > * { position: relative; }
.chapter-card span { color: var(--brass-300); font-size: .85rem; letter-spacing: .12em; }
.chapter-card h3 { margin: .35rem 0; color: #f8e8bf; font-size: 1.4rem; }
.chapter-card p { max-width: 72%; margin: 0; color: #c8b99c; line-height: 1.55; }
.chapter-card.is-locked { filter: grayscale(1); opacity: .5; cursor: not-allowed; }

.pause-card { width: min(30rem, 78vw); text-align: center; }
.pause-card .game-button { width: 100%; margin-top: .65rem; text-align: center; }

.guide-tip { position: absolute; right: var(--safe-x); top: calc(var(--safe-y) + 5rem); z-index: var(--layer-overlay); width: min(26rem, 36vw); padding: 1rem; color: #ead9b6; border: 1px solid #c28d35; background: linear-gradient(145deg, rgba(9, 23, 34, .98), rgba(5, 12, 18, .98)); box-shadow: 0 18px 38px rgba(0, 0, 0, .52); }
.guide-tip[hidden] { display: none; }
.guide-tip p { margin: 0 0 .75rem; line-height: 1.7; }
.guide-tip .game-button { width: 100%; min-height: 3rem; text-align: center; }

.hint-quiz-card { width: min(42rem, 86vw); }
.quiz-question { margin: 1.2rem 0; color: #f3e5c5; font-size: clamp(1.15rem, 1.5vw, 1.5rem); line-height: 1.7; }
.quiz-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.quiz-option { min-height: 4rem; text-align: center; font-size: 1.15rem; }
.quiz-feedback { min-height: 2em; margin: 1rem 0 0; color: #f0c96f; line-height: 1.6; }

.onboarding-overlay { position: absolute; inset: 0; z-index: calc(var(--layer-toast) + 1); pointer-events: none; background: rgba(1, 6, 10, .34); }
.onboarding-overlay[hidden] { display: none; }
.onboarding-focus { position: absolute; border: 3px solid #ffe08a; border-radius: .7rem; box-shadow: 0 0 0 9999px rgba(1, 5, 9, .42), 0 0 2rem rgba(255, 204, 92, .95); transition: left 220ms var(--ease-out), top 220ms var(--ease-out), width 220ms var(--ease-out), height 220ms var(--ease-out); }
.onboarding-focus span { position: absolute; right: -.8rem; bottom: -1.6rem; font-size: 2rem; filter: drop-shadow(0 4px 4px #000); animation: onboarding-hand 850ms ease-in-out infinite alternate; }
.onboarding-card { position: absolute; width: min(24rem, 34vw); padding: 1rem 1.1rem; color: #f2e1bd; border: 1px solid #c89034; background: linear-gradient(145deg, rgba(8, 22, 33, .98), rgba(4, 11, 17, .98)); box-shadow: 0 16px 38px rgba(0, 0, 0, .6); pointer-events: auto; }
.onboarding-card strong { color: #f4ca70; font-size: 1.15rem; }
.onboarding-card p { margin: .45rem 0 .75rem; line-height: 1.65; }
.onboarding-card .game-button { min-height: 2.8rem; width: 100%; text-align: center; }
.hud-actions.is-onboarding-locked [data-action="journal"],
.hud-actions.is-onboarding-locked [data-action="backlog"] { display: none; }

@keyframes onboarding-hand { from { transform: translateY(0); } to { transform: translateY(.45rem); } }

.rotate-notice { display: none; }

.high-contrast .dialogue-panel { background: #f4e8c9; }
.high-contrast .dialogue-text { color: #080604; font-weight: 500; }
.high-contrast .objective-card, .high-contrast .chapter-plaque { background: #020609; }

@keyframes scene-in { from { opacity: 0; filter: brightness(.3); } to { opacity: 1; filter: brightness(1); } }
@keyframes hotspot-breathe { 0%, 100% { transform: translate(-50%, -50%) scale(.92); } 50% { transform: translate(-50%, -50%) scale(1.08); } }
@keyframes hotspot-glint { 0%, 72%, 100% { opacity: .28; } 82% { opacity: .58; } }
@keyframes hint-ring { from { opacity: 1; filter: brightness(1); } to { opacity: .55; filter: brightness(1.4); } }
@keyframes hint-button-pulse { from { box-shadow: inset 0 0 0 3px #08121b, inset 0 0 0 4px rgba(224, 178, 82, .48), 0 0 0 rgba(241, 198, 99, 0); } to { box-shadow: inset 0 0 0 3px #08121b, inset 0 0 0 4px #f1c663, 0 0 28px rgba(241, 198, 99, .8); } }
@keyframes reject { 25% { transform: translateX(-.4rem); } 75% { transform: translateX(.4rem); } }
@keyframes place-pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.45) rotate(-12deg); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

@media (max-width: 900px) {
  .title-content { width: 48vw; }
  .title-content h1 { font-size: clamp(3.3rem, 8vw, 5rem); }
  .menu-stack { width: 40vw; }
  .archive-stamp { min-width: 0; }
  .dialogue-panel { grid-template-columns: minmax(7rem, .65fr) minmax(20rem, 2.4fr) minmax(7rem, .65fr); min-height: 58vh; }
  .dialogue-character { height: min(44vh, 22rem); }
  .dialogue-text { font-size: 1rem; }
  .gallery-grid { gap: .55rem; }
  .gallery-painting { border-width: .45rem; }
  .memory-card { min-height: 44vh; }
}

@media (orientation: portrait) and (max-width: 900px) {
  html,body,#game { width:100vw; max-width:100vw; min-width:0; overflow:hidden; }
  .screen,.modal,.parent-return-bookmark { visibility:hidden; }
  .rotate-notice { visibility:visible; position:fixed; inset:0; width:100vw; max-width:100vw; overflow:hidden; z-index:var(--layer-toast); display:grid; place-items:center; align-content:center; gap:.75rem; padding:2rem; background:#07131d; color:#eadcb9; text-align:center; }
  .rotate-icon { color: var(--brass-300); font-size: 4rem; animation: rotate-hint 1.6s ease-in-out infinite; }
  .rotate-notice strong { font-size: 1.5rem; }
  .rotate-notice span { color: #bdb092; }
}

@keyframes rotate-hint { 0%, 100% { transform: rotate(-15deg); } 50% { transform: rotate(75deg); } }

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

.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
.reduced-motion .hotspot.is-hinted::after { animation: none !important; opacity: 1 !important; filter: none !important; }

@media (max-height: 620px) {
  .title-content { top: 3vh; }
  .archive-stamp { display: none; }
  .title-content h1 { font-size: clamp(3.1rem, 7vw, 4.6rem); }
  .title-subtitle { margin: .55rem 0 .75rem; }
  .title-route { display: none; }
  .game-button { min-height: 3rem; padding: .45rem 1rem; }
  .menu-stack { margin-top: .8rem; gap: .45rem; }
  .menu-stack .game-button { min-height: 3.4rem; }
  .menu-stack .game-button strong { font-size: 1.35rem; }
  .dialogue-panel { min-height: 64vh; }
  .dialogue-character { height: 50vh; }
  .dialogue-copy { min-height: 7rem; padding: 1.55rem 1.4rem .9rem; }
  .choice-button { min-height: 3rem; padding-top: .45rem; padding-bottom: .45rem; }
  .objective-card { top: calc(var(--safe-y) + 4.7rem); }
  .puzzle-shell { top: 2vh; bottom: 2vh; padding: 1rem; }
  .puzzle-header { padding-bottom: .5rem; }
  .puzzle-header h2 { font-size: 1.5rem; }
  .puzzle-footer { padding-top: .5rem; }
  .gallery-grid { width: min(48rem, 58vw); gap: .5rem; }
  .gallery-painting { aspect-ratio: 1.65; border-width: .4rem; }
}

@media (max-height:500px) and (orientation:landscape) {
  .puzzle-shell { top:1vh; bottom:1vh; padding:6px; border-width:14px; grid-template-rows:54px minmax(0,1fr) 50px; }
  .puzzle-header { min-height:0; height:54px; padding:0 4px; align-items:center; overflow:hidden; }
  .archive-tab { display:grid; grid-template-columns:auto auto minmax(0,1fr); align-items:center; width:calc(100% - 158px); white-space:nowrap; }
  .archive-tab::before { inset:-4px -8px; }
  .puzzle-header h2 { margin-left:10px; font-size:19px; }
  .objective-slip { grid-column:3; margin:0 0 0 12px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; padding:5px 10px; }
  .puzzle-counter { width:154px; min-width:154px; min-height:44px; padding:0 10px; font-size:15px; }
  .puzzle-workbench { grid-template-columns:1fr; grid-template-rows:minmax(0,1fr) 58px; gap:4px; padding:4px 0; }
  .tool-tray { grid-row:2; display:grid; grid-template-columns:150px 90px minmax(0,1fr); grid-template-rows:1fr; align-items:center; height:58px; padding:4px 8px; border-width:4px; }
  .tool-tray>span { padding:5px; }.tool-tray .tool-image { width:80px; min-height:46px; height:46px; }.tool-tray p { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .puzzle-footer { min-height:48px; height:48px; padding:0 4px; }
  .ledger-control { min-width:100px; min-height:46px; padding:4px 8px; }.wax-submit { width:58px; height:58px; min-width:58px; min-height:58px; margin:-5px 4px -5px auto; }
}
