:root {
  --ink: #162b2a;
  --ink-soft: #2d4844;
  --cream: #f5efe2;
  --paper: rgba(250, 247, 239, .94);
  --mist: #dfe8df;
  --sage: #a9bda8;
  --gold: #dcaa5c;
  --gold-deep: #b9783b;
  --white: #fffdf8;
  --shadow: 0 1.5rem 4rem rgba(19, 38, 37, .22);
  --ease: cubic-bezier(.2, .85, .25, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-height: 100%; overflow: hidden; background: var(--ink); }
body { color: var(--white); font-family: "Iowan Old Style", "Baskerville", "STSong", serif; }
button { font: inherit; }
[hidden] { display: none !important; }

.app-shell, .view { width: 100vw; height: 100dvh; min-height: 420px; position: relative; overflow: hidden; }
.view { isolation: isolate; }

.orientation-gate { position: fixed; inset: 0; z-index: 30; display: grid; place-content: center; text-align: center; background: #162b2a; color: var(--cream); padding: 2rem; }
.orientation-gate h1 { margin: .8rem 0 .35rem; font-size: clamp(1.65rem, 4vw, 2.65rem); font-weight: 400; letter-spacing: .02em; }
.orientation-gate p { margin: 0; color: #bfcec1; font-size: clamp(.9rem, 2vw, 1.1rem); }
.gate-kicker { letter-spacing: .22em; font-family: ui-sans-serif, system-ui, sans-serif; font-size: .65rem !important; color: var(--gold) !important; }
.rotate-mark { width: 4.6rem; height: 4.6rem; margin: 0 auto 1.25rem; position: relative; border: 1px solid rgba(220,170,92,.65); border-radius: 1.1rem; transform: rotate(-12deg); animation: rotateHint 2.4s var(--ease) infinite; }
.rotate-mark::before { content: ""; position: absolute; inset: .7rem; border: 1px solid rgba(245,239,226,.75); border-radius: .35rem; }
.rotate-mark span { position: absolute; width: .35rem; height: .35rem; border-radius: 50%; background: var(--gold); }
.rotate-mark span:nth-child(1) { top: .65rem; left: 1.1rem; } .rotate-mark span:nth-child(2) { top: .65rem; right: 1.1rem; } .rotate-mark span:nth-child(3) { bottom: .65rem; left: 50%; }
@keyframes rotateHint { 0%,100% { transform: rotate(-12deg) } 50% { transform: rotate(78deg) } }

.title-image, .scene-image { position: absolute; inset: 0; z-index: -3; background: center / cover no-repeat; transition: opacity .5s var(--ease), transform 1.2s var(--ease); }
.title-image { background-image: url('../assets/images/01_library_cover.webp'); }
.title-wash { position: absolute; inset: 0; z-index: -2; background: linear-gradient(90deg, rgba(17,35,34,.9) 0%, rgba(17,35,34,.7) 28%, rgba(17,35,34,.12) 70%), linear-gradient(0deg, rgba(17,35,34,.65), transparent 42%); }
.title-content { width: min(48rem, 59vw); position: absolute; left: clamp(2rem, 8vw, 9rem); top: 50%; transform: translateY(-50%); animation: riseIn .9s var(--ease) both; }
.eyebrow { display: flex; align-items: center; gap: .65rem; margin-bottom: 1.35rem; color: #d0d9cf; font: 600 .72rem/1.2 ui-sans-serif, system-ui, sans-serif; letter-spacing: .11em; text-transform: uppercase; }
.eyebrow-dot { width: .42rem; height: .42rem; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 .28rem rgba(220,170,92,.18); }
.title-content h1 { margin: 0; font-size: clamp(3.8rem, 8.6vw, 8.3rem); line-height: .86; font-weight: 400; letter-spacing: -.055em; }
.title-content h1 em { color: var(--gold); font-style: normal; }
.title-subtitle { margin: 1.05rem 0 0; padding-left: .25rem; font-size: clamp(1.35rem, 2.4vw, 2.15rem); color: #d7dfd3; letter-spacing: .12em; }
.title-note { max-width: 29rem; margin: 1.8rem 0 2.1rem; color: #bbc9bd; font-size: clamp(.95rem, 1.6vw, 1.15rem); line-height: 1.75; }
.button { border: 0; cursor: pointer; transition: transform .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease); }
.button-primary { display: inline-flex; align-items: center; gap: 2.8rem; padding: 1rem 1.2rem 1rem 1.45rem; color: var(--ink); background: var(--gold); box-shadow: 0 .7rem 1.7rem rgba(10, 21, 20, .26); font: 700 .84rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; }
.button-primary b { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid rgba(22,43,42,.4); border-radius: 50%; font-size: 1.1rem; font-weight: 400; }
.button:hover { transform: translateY(-3px); box-shadow: 0 1rem 2.5rem rgba(10, 21, 20, .33); }
.title-meta { position: absolute; left: clamp(2rem, 8vw, 9rem); bottom: 2rem; display: flex; gap: 2.5rem; color: rgba(227,235,224,.62); font: .62rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .2em; }
.title-stamp { position: absolute; right: 7vw; bottom: 7vh; padding: .65rem .85rem; border: 1px solid rgba(234,217,177,.45); color: rgba(245,239,226,.76); text-align: center; font: .6rem/1.45 ui-sans-serif, system-ui, sans-serif; letter-spacing: .15em; transform: rotate(7deg); }
.title-stamp strong { font-size: .9rem; letter-spacing: .1em; }

.scene-image { z-index: -4; transform: scale(1.03); }
.scene-shade { position: absolute; inset: 0; z-index: -3; background: linear-gradient(90deg, rgba(12,28,27,.92) 0%, rgba(16,34,32,.75) 30%, rgba(16,34,32,.12) 72%), linear-gradient(0deg, rgba(12,28,27,.78), transparent 43%); }
.grain { position: absolute; inset: 0; z-index: -2; opacity: .16; pointer-events: none; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E"); mix-blend-mode: overlay; }
.story-header { position: absolute; left: clamp(1.4rem, 4vw, 4rem); right: clamp(1.4rem, 4vw, 4rem); top: clamp(1rem, 3vw, 2.2rem); display: flex; align-items: center; justify-content: space-between; z-index: 2; }
.icon-button { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 1px solid rgba(231,239,228,.3); border-radius: 50%; color: var(--white); background: rgba(22,43,42,.3); cursor: pointer; font-size: 1.2rem; transition: background .2s, transform .2s; }
.icon-button:hover { background: rgba(22,43,42,.72); transform: translateX(-2px); }
.brand-lockup { display: flex; align-items: center; gap: .65rem; margin-left: 1rem; margin-right: auto; color: rgba(238,244,235,.78); font: .64rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .12em; text-transform: uppercase; }
.brand-mark { display: grid; place-items: center; width: 1.7rem; height: 1.7rem; border: 1px solid rgba(220,170,92,.7); color: var(--gold); font-family: Georgia, serif; font-size: .9rem; }
.story-progress { display: flex; align-items: center; gap: 1rem; color: rgba(238,244,235,.7); font: .66rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .12em; }
.story-progress i { display: block; width: clamp(5rem, 12vw, 9rem); height: 2px; background: rgba(239,246,233,.27); overflow: hidden; }
.story-progress b { display: block; height: 100%; background: var(--gold); transition: width .6s var(--ease); }
.story-layout { position: absolute; inset: 13% clamp(1.4rem, 8vw, 9rem) 19%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(10rem, 17rem); gap: clamp(2rem, 8vw, 9rem); align-items: center; }
.story-main { max-width: 46rem; animation: riseIn .55s var(--ease) both; }
.chapter-label { margin-bottom: .9rem; color: var(--gold); font: 700 .68rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .2em; text-transform: uppercase; }
.story-main h2 { margin: 0 0 1.25rem; color: var(--white); font-size: clamp(2rem, 4.2vw, 4.2rem); font-weight: 400; line-height: 1.06; letter-spacing: -.04em; }
.story-body { display: grid; gap: .8rem; max-width: 43rem; color: rgba(242,246,236,.9); font-size: clamp(.94rem, 1.45vw, 1.16rem); line-height: 1.78; text-wrap: pretty; }
.story-body p { margin: 0; }
.story-body p:nth-child(3) { padding: .85rem 1.1rem; color: #f4dbab; border-left: 2px solid var(--gold); background: rgba(11,28,26,.22); }
.quote { margin-top: 1.3rem; color: #d9e2d7; font-style: italic; font-size: clamp(.94rem, 1.3vw, 1.05rem); opacity: .92; }
.quote::before { content: "“"; margin-right: .35rem; color: var(--gold); font-size: 1.5em; vertical-align: -.12em; }
.story-aside { align-self: center; display: grid; gap: 1.4rem; justify-items: center; }
.bookmark-card { width: min(10rem, 16vw); aspect-ratio: .62; position: relative; padding: 1.25rem .95rem; background: #e2b770; color: #684727; box-shadow: .9rem 1.2rem 2rem rgba(8, 19, 18, .3); transform: rotate(5deg); }
.bookmark-card::before { content: ""; position: absolute; inset: .45rem; border: 1px solid rgba(104,71,39,.48); }
.bookmark-fold { position: absolute; right: 0; top: 0; width: 1.2rem; height: 1.2rem; background: #f2d197; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.bookmark-label { position: relative; font: 700 .58rem/1.15 ui-sans-serif, system-ui, sans-serif; letter-spacing: .13em; }
.bookmark-line { position: relative; height: 1px; margin: 1rem 0 .75rem; background: rgba(104,71,39,.6); }
.bookmark-copy { position: relative; font-size: clamp(.72rem, 1.1vw, .9rem); line-height: 1.8; letter-spacing: .1em; }
.clue-tray { width: 100%; color: rgba(239,246,233,.7); font: .63rem ui-sans-serif, system-ui, sans-serif; letter-spacing: .1em; text-align: center; }
.tray-label { display: block; margin-bottom: .55rem; color: var(--gold); text-transform: uppercase; }
.clue-list { display: flex; justify-content: center; flex-wrap: wrap; gap: .4rem; }
.clue-list span { padding: .35rem .55rem; border: 1px solid rgba(231,239,228,.22); color: rgba(239,246,233,.75); background: rgba(13,31,29,.24); }
.clue-list .clue-empty { color: rgba(239,246,233,.45); border-style: dashed; }
.story-footer { position: absolute; left: clamp(1.4rem, 8vw, 9rem); right: clamp(1.4rem, 8vw, 9rem); bottom: clamp(1.25rem, 4vw, 3rem); display: grid; grid-template-columns: minmax(12rem, .72fr) minmax(24rem, 1.4fr); align-items: end; gap: 2rem; z-index: 2; }
.footer-note { color: rgba(232,239,229,.62); font: .7rem/1.5 ui-sans-serif, system-ui, sans-serif; letter-spacing: .08em; }
.choices { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .55rem; }
.choice-button { min-height: 2.65rem; padding: .75rem 1rem; border: 1px solid rgba(233,239,230,.35); color: rgba(248,249,239,.93); background: rgba(13,29,28,.44); cursor: pointer; text-align: left; font-size: clamp(.78rem, 1.2vw, .94rem); line-height: 1.25; transition: background .25s var(--ease), border-color .25s, transform .25s var(--ease); }
.choice-button:hover, .choice-button:focus-visible { border-color: var(--gold); background: rgba(221,172,94,.16); transform: translateY(-3px); outline: none; }
.choice-button.primary { border-color: var(--gold); background: var(--gold); color: var(--ink); font-weight: 700; }
.choice-button.secondary { border-color: rgba(221,172,94,.85); color: var(--gold); }

@keyframes riseIn { from { opacity: 0; transform: translateY(1rem); } to { opacity: 1; transform: translateY(0); } }
@media (orientation: portrait) { .orientation-gate { display: grid; } .app-shell { visibility: hidden; } }
@media (orientation: landscape) { .orientation-gate { display: none; } }
@media (max-height: 620px) and (min-aspect-ratio: 1/1) {
  .story-layout { inset-top: 14%; bottom: 22%; }
  .story-body { line-height: 1.52; font-size: .91rem; }
  .story-main h2 { margin-bottom: .7rem; font-size: clamp(1.7rem, 4vw, 3rem); }
  .story-aside { transform: scale(.82); transform-origin: right center; }
  .story-footer { bottom: 1rem; }
}
@media (max-width: 720px) and (min-aspect-ratio: 1/1) {
  .story-layout { grid-template-columns: 1fr; inset: 16% 1.4rem 24%; }
  .story-aside { display: none; }
  .story-footer { grid-template-columns: 1fr; gap: .6rem; }
  .choices { justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .001ms !important; } }

/* 阅读页在各个横屏高度内使用独立正文区域与选择区域。 */
.app-shell, .view { min-height: 0; }
.title-content { animation-name: titleAppear; }
@keyframes titleAppear { from { opacity: 0; translate: 0 15px; } to { opacity: 1; translate: 0 0; } }
.story-header { top: max(22px, env(safe-area-inset-top)); }
.story-layout { inset: 16% 7vw 23%; display: block; }
.story-main { width: 48%; max-width: 700px; position: absolute; top: 50%; transform: translateY(-50%); animation: none; }
.story-main h2 { font-size: clamp(25px, 3.5vw, 58px); line-height: 1.25; letter-spacing: .01em; }
.story-body { font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif; font-weight: 400; font-size: clamp(16px, 1.4vw, 21px); line-height: 1.95; letter-spacing: .035em; }
.story-body p:nth-child(3) { padding: 0; background: none; border: 0; color: inherit; }
.story-body .spoken-line { border-left: 2px solid var(--gold); padding-left: 1.2rem; color: #f4d7a1; font-family: 'STSong', serif; font-size: 1.14em; }
.page-indicator { margin-top: 22px; color: #c8cabc; font: 11px 'PingFang SC', sans-serif; letter-spacing: .18em; }
.story-aside { position: absolute; right: 0; bottom: 0; width: 150px; }
.bookmark-card { display: none; }
.clue-tray { padding: 13px; background: rgba(19,39,35,.78); backdrop-filter: blur(12px); border: 1px solid #d2bd8a44; }
.scene-shade { background: linear-gradient(90deg, rgba(14,32,29,.96), rgba(19,39,34,.86) 29%, rgba(22,42,35,.54) 48%, rgba(26,43,35,.02) 69%), linear-gradient(0deg, rgba(16,31,27,.82), transparent 22%); }
.scene-image { transform: none; background-position: center; }
.story-footer { display: flex; flex-direction: column; align-items: stretch; gap: 15px; left: 7vw; right: 7vw; bottom: max(30px, env(safe-area-inset-bottom)); }
.choices { justify-content: flex-start; }
.choices.multiple { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.choices.multiple:has(button:nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0,1fr)); }
.choice-button { min-height: 52px; padding: 13px 19px; font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: clamp(14px, 1.05vw, 17px); line-height: 1.55; border-radius: 2px; }
.next-page { min-width: 188px; display: inline-block; }
.choice-button:active, .button:active { transform: translateY(1px) scale(.98); }
button:focus-visible { outline: 2px solid #f7dca5; outline-offset: 5px; }
.story-view[data-ending='pass-on'] .scene-image { background-position: 60% center; }
.story-view[data-ending='relay'] .scene-image { background-size: auto 120%; background-position: right center; }
@media (max-height: 620px) and (orientation: landscape) {
  .title-content { width: 52vw; left: 7vw; }
  .title-content h1 { font-size: clamp(40px, 9.5vh, 65px); line-height: 1.05; }
  .eyebrow { font-size: 10px; margin-bottom: 12px; }
  .title-subtitle { font-size: 20px; margin-top: 10px; }
  .title-note { font-size: 12px; line-height: 1.6; margin: 13px 0 15px; max-width: 330px; }
  .button-primary { padding: 9px 12px 9px 18px; }
  .button-primary b { width: 25px; height: 25px; }
  .title-meta { bottom: 13px; left: 7vw; font-size: 8px; gap: 20px; }
  .title-stamp { right: 5vw; bottom: 24px; }
  .story-header { top: max(12px, env(safe-area-inset-top)); left: max(24px, env(safe-area-inset-left)); right: max(24px, env(safe-area-inset-right)); }
  .icon-button { width: 30px; height: 30px; }
  .story-layout { inset: 62px 6vw 107px; display: block; }
  .story-main { width: 56%; }
  .chapter-label { font-size: 9px; margin-bottom: 9px; letter-spacing: .12em; }
  .story-main h2 { font-size: clamp(23px, 5.8vh, 32px); margin-bottom: 13px; }
  .story-body { font-size: 15px; line-height: 1.8; }
  .page-indicator { margin-top: 10px; font-size: 9px; }
  .story-aside { display: none; }
  .story-footer { left: max(6vw, env(safe-area-inset-left)); right: max(6vw, env(safe-area-inset-right)); bottom: max(15px, env(safe-area-inset-bottom)); gap: 8px; }
  .footer-note { font-size: 9px; }
  .choice-button { padding: 8px 12px; font-size: 13px; min-height: 40px; }
  .choices.multiple { gap: 8px; }
}
@media (max-height: 340px) and (orientation: landscape) {
  .story-layout { top: 52px; bottom: 95px; }
  .story-main { width: 70%; }
  .story-main h2 { font-size: 20px; margin-bottom: 8px; }
  .chapter-label { margin-bottom: 5px; }
  .story-body { font-size: 13px; line-height: 1.65; }
  .page-indicator { margin-top: 6px; }
  .title-note { display: none; }
}
