:root {
  color-scheme: dark;
  --paper: #ece1c6;
  --paper-deep: #d1bc93;
  --ink: #f2e9d7;
  --muted: #c6bba5;
  --ochre: #d8bd87;
  --accent: #caa874;
  --line: #dcc39b66;
  --serif: "KaiTi", "STKaiti", "FangSong", "Songti SC", "SimSun", serif;
  --sans: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --hud-top: clamp(20px, 3vw, 44px);
  --scene-gutter: clamp(22px, 5.3vw, 84px);
  --panel-safe: 210px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #171b18; color: var(--ink); font: 400 1rem/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .44; }
a { color: inherit; text-underline-offset: .3em; }
:where(button, a, input, select, summary):focus-visible { outline: 2px solid #f2d195; outline-offset: 5px; }
::selection { color: #fff5e0; background: #805939; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: .5rem 1rem; transform: translateY(-200%); background: #18221e; }
.skip-link:focus { transform: none; }

main, #home, #experience { position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh; }
main:focus { outline: 0; }
#home { isolation: isolate; overflow: hidden; background: #21251f url("media/menu.webp") center / cover; }
.menu-film { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 58% 50%; z-index: 0; }
.menu-shade { position: absolute; inset: 0; z-index: 1; background: linear-gradient(90deg, #111511bd 0%, #11151170 24%, #11151110 62%, #11151105 100%), linear-gradient(0deg, #0c120b80, transparent 27%, transparent 80%, #10171030); pointer-events: none; }
.menu-copy { position: absolute; z-index: 2; top: clamp(100px, 15.2vh, 180px); left: var(--scene-gutter); max-width: calc(100% - 2 * var(--scene-gutter)); text-shadow: 0 2px 18px #11150cb3; }
.menu-kicker { margin: 0 0 1.5rem; color: #e8ce9b; font: 500 .8rem/1.5 Georgia, "Times New Roman", serif; letter-spacing: .18em; }
#homeTitle { margin: 0 0 .16em; font: 400 clamp(4.5rem, 7.1vw, 7.4rem)/1.05 var(--serif); letter-spacing: .12em; }
.menu-subtitle { margin: 0; font: 400 clamp(1.8rem, 3.3vw, 3.3rem)/1.4 var(--serif); letter-spacing: .13em; }
.menu-whisper { margin: clamp(1.8rem, 4.5vh, 3rem) 0 0; color: #e3d5b8; font: 400 clamp(1.05rem, 1.4vw, 1.35rem)/1.8 var(--serif); letter-spacing: .08em; }
.entry-actions { display: flex; flex-direction: column; align-items: flex-start; gap: .45rem; margin-top: clamp(1.7rem, 4.5vh, 3.25rem); }
.opening-setting { display: inline-flex; gap: .55rem; align-items: center; margin-top: .8rem; }
.opening-setting input { accent-color: #a68250; }
#storageNotice { position: fixed; z-index: 17; inset: 4.7rem 1rem auto auto; max-width: min(22rem, 75vw); margin: 0; padding: .38rem .64rem; color: #f0e5ce; background: #141916d9; font-size: .78rem; pointer-events: none; }
#storageNotice[data-storage="available"] { inset: auto 1rem 1rem auto; }
body:not([data-screen="home"]) #storageNotice[data-storage="available"] { display: none; }
body[data-captions="off"] #mediaStage .timed-caption { visibility: hidden; }
.entry-start, .entry-resume { position: relative; padding: .45rem 2.1rem .5rem 0; min-height: 48px; color: #f5e9cd; background: transparent; border: 0; text-align: left; font: 400 clamp(1.45rem, 2vw, 1.9rem)/1.4 var(--serif); letter-spacing: .16em; text-shadow: 0 2px 14px #08100d; transition: color .2s ease, transform .2s ease; }
.entry-start::after { content: ""; position: absolute; left: 0; right: 1.9rem; bottom: .05rem; height: 1px; background: linear-gradient(90deg, #ddbd84, #ddbd8433 74%, transparent); transform: scaleX(.74); transform-origin: left; transition: transform .2s ease; }
.entry-start:hover, .entry-resume:hover { color: #ffe5b3; transform: translateX(4px); }
.entry-start:hover::after { transform: scaleX(1); }
.entry-resume { font-size: 1.05rem; color: #d4c6a9; letter-spacing: .12em; }

.scene-tools { position: fixed; z-index: 30; top: max(var(--hud-top), env(safe-area-inset-top)); right: var(--scene-gutter); display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .1rem clamp(.75rem, 1.6vw, 1.6rem); max-width: calc(100% - 2 * var(--scene-gutter)); }
.scene-tools button { min-height: 36px; padding: .2rem 0; border: 0; background: transparent; color: #f0e8d2d9; font-size: .78rem; text-shadow: 0 1px 5px #111, 0 1px 16px #111; letter-spacing: .06em; }
.scene-tools button:hover { color: #ffe4ad; }
body:has(#home:not([hidden])) #homeButton { display: none; }
body:has(#experience:not([hidden])) #motionToggle { display: none; }
body.has-idle:has(#experience:not([hidden])) #motionToggle { display: inline-flex; }
.scene-idle { transition: opacity .25s ease; }
@media (prefers-reduced-motion: reduce) { .scene-idle { transition: none; } }

#experience { isolation: isolate; background: #171c19; }
.experience-heading { position: absolute; z-index: 10; top: var(--hud-top); left: var(--scene-gutter); max-width: 35%; pointer-events: none; text-shadow: 0 2px 9px #0009; }
#chapterLabel { margin: 0; font-size: .7rem; color: #e2cda8c9; letter-spacing: .22em; }
#chapterTitle { margin: .25rem 0 0; font: 400 clamp(1.35rem, 2.2vw, 2rem)/1.2 var(--serif); letter-spacing: .15em; }
#chapterTitle:focus { outline: none; }
body.is-media .experience-heading { opacity: 0; }
#sceneBody, #mediaStage { position: absolute; inset: 0; overflow: hidden; }
.scene-visual { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; color: #f4ead6; background: #18201b; }
.scene-visual > img, .scene-visual > video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; max-height: none; object-fit: cover; }
.desk-reveal { opacity: 0; pointer-events: none; }
.desk-corner { clip-path: inset(83% 0 0); }
.desk-brush { z-index: 1; }
.desk-visible .desk-corner { animation: desk-appear .36s ease both; }
.desk-visible .desk-brush { animation: desk-appear .42s .26s ease both; }
.desk-visible .desk-stone { animation: desk-appear .55s .62s ease both; }
.desk-ready .desk-stone, .desk-ready .desk-brush { opacity: 1; }
@keyframes desk-appear { to { opacity: 1; } }
.desk-hotspot { position:absolute; inset: 28% 16% 32%; z-index: 2; border: 0; background: transparent; color: transparent; cursor: pointer; }
.desk-hotspot:disabled { pointer-events: none; }
.desk-hotspot:focus-visible { outline: 2px solid #f7dba4; border-radius: 14px; }
@media (prefers-reduced-motion: reduce) { .desk-visible .desk-reveal { animation: none; opacity: 1; } }
.scene-panel { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; padding: 40px var(--scene-gutter) max(26px, env(safe-area-inset-bottom)); max-height: 48dvh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #b9a78280 transparent; background: linear-gradient(0deg, #0b100ef2, #0b100ed4 55%, #0b100e90 82%, transparent); color: #eee5d2; text-shadow: 0 2px 8px #0b0c08; }
.scene-panel h2, .scene-panel h3 { margin: 0 0 .45rem; font: 400 clamp(1.2rem, 2.15vw, 1.8rem)/1.55 var(--serif); letter-spacing: .035em; }
.scene-panel p { margin: 0 0 .4rem; max-width: 68em; color: #ddd4c3; font-size: .88rem; line-height: 1.7; }
.scene-panel p:empty { display: none; }
.options { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem 1.6rem; margin-top: .65rem; }
.primary, .secondary, .options > button { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; min-height: 44px; padding: .4rem .2rem; border: 0; border-radius: 0; background: transparent; color: #eee1c5; font: 400 .98rem/1.55 var(--serif); letter-spacing: .05em; text-shadow: 0 1px 7px #000; transition: color .18s ease; }
.primary, .options > button.primary { color: #f7dba4; box-shadow: inset 0 -1px #bd976c70; }
.primary:hover:enabled, .secondary:hover:enabled, .options > button:hover:enabled { color: #fff1c8; }
.feedback { color: #e6c491 !important; margin-top: .45rem; font-size: .85rem; }
#mediaStage { z-index: auto; }
.scene-dissolve, .scene-frozen-blend { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; background: #171c19; }
.scene-dissolve .scene-visual { position: absolute; inset: 0; }
#mediaStage .scene-panel { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 72px; background: linear-gradient(0deg,#080d0cdc, #080d0c84 55%, transparent); }
#mediaStage .scene-panel h2 { display: none; }
#mediaStage .scene-panel p { max-width: 60em; font: 400 clamp(1rem, 1.45vw, 1.25rem)/1.7 var(--serif); }
#mediaStage[data-clip="V01"] .scene-panel p { display: block; min-height: 1.7em; }
#mediaStage .options { margin-top: .65rem; gap: 1.75rem; }
#mediaStage .options button { font-size: .82rem; color: #ddd2be; min-height: 36px; }
noscript { position: fixed; z-index: 60; bottom: 30px; left: 20px; right: 20px; text-align: center; color: #f8d9aa; }

@media (max-width: 700px) {
  :root { --hud-top: 15px; --scene-gutter: 24px; --panel-safe: 245px; }
  .menu-copy { top: 22dvh; }
  .menu-film { object-position: 58% 50%; }
  .menu-shade { background: linear-gradient(90deg,#0c1714ad,#0c171450 64%,#0c171420), linear-gradient(0deg,#0b1212ac, transparent 38%); }
  .menu-kicker { font-size: .65rem; margin-bottom: 1.3rem; }
  #homeTitle { font-size: clamp(4.1rem, 17vw, 5.4rem); }
  .menu-subtitle { font-size: clamp(1.7rem, 7vw, 2.2rem); }
  .menu-whisper { margin-top: 2rem; font-size: 1.05rem; }
  .entry-actions { margin-top: 2.1rem; }
  .scene-tools { gap: .9rem; }
  .scene-tools button { font-size: .7rem; min-height: 40px; }
  .experience-heading { top: 70px; max-width: 75%; }
  #chapterLabel { font-size: .63rem; }
  #chapterTitle { font-size: 1.35rem; }
  .scene-panel { max-height: 50dvh; padding-top: 32px; padding-bottom: max(20px,env(safe-area-inset-bottom)); }
  .scene-panel h2, .scene-panel h3 { font-size: 1.25rem; }
  .scene-panel p { font-size: .82rem; }
  .options { gap: .1rem 1.2rem; }
  .primary, .secondary, .options > button { font-size: .93rem; }
  #mediaStage .scene-panel { padding-top: 60px; }
  #mediaStage .scene-panel p { font-size: 1rem; }
}
@media (max-height: 540px) and (min-width: 701px) {
  :root { --hud-top: 12px; --scene-gutter: 30px; }
  .menu-copy { top: 48px; }
  .menu-kicker { margin-bottom: .65rem; font-size: .65rem; }
  #homeTitle { font-size: 4.1rem; }
  .menu-subtitle { font-size: 1.9rem; }
  .menu-whisper { margin-top: 1.2rem; }
  .entry-actions { margin-top: 1.1rem; gap: 0; }
  .scene-panel { padding-top: 20px; padding-bottom: 12px; max-height: 56dvh; }
}
@media (max-width: 700px) and (max-height: 650px) {
  .menu-copy { top: 17dvh; }
  .menu-whisper { margin-top: 1.4rem; }
  .entry-actions { margin-top: 1.3rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
