:root {
  --paper: #f3ead7;
  --ink: #3a3632;
  --ochre: #c98e3a;
  --seal: #b0442c;
  --font: "KaiTi", "STKaiti", "楷体", "Kaiti SC", "Songti SC", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9dec7; color: var(--ink); font-family: var(--font); }
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* 纸纹叠加与暗角：让整幅画面像印在宣纸上 */
#paper {
  position: fixed; inset: 0; pointer-events: none;
  background: url("../assets/build/textures/paper.png");
  background-size: 512px 512px;
  mix-blend-mode: multiply; opacity: 0.4;
}
#tint { position: fixed; inset: 0; pointer-events: none; mix-blend-mode: multiply; transition: background 2.5s ease; }
#flip {
  position: fixed; inset: 0; pointer-events: none; z-index: 12; opacity: 0;
  background: #f4ecda url("../assets/build/textures/paper.png"); background-size: 512px;
  transform-origin: left center;
}
#flip.go { animation: pageflip 1.1s ease-in-out; }
@keyframes pageflip {
  0% { opacity: 0; transform: perspective(1400px) rotateY(-70deg); }
  40% { opacity: 1; transform: perspective(1400px) rotateY(0deg); }
  60% { opacity: 1; transform: perspective(1400px) rotateY(0deg); }
  100% { opacity: 0; transform: perspective(1400px) rotateY(70deg); transform-origin: right center; }
}
#photo { position: fixed; inset: 0; z-index: 11; display: none; pointer-events: none; }
#photo.show { display: block; }
#photo .frame {
  position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); aspect-ratio: 9 / 16;
  background: url("../assets/build/b2/ui/photo_frames.png") 0 0 / 200% 200% no-repeat;
  box-shadow: 0 0 0 100vmax rgba(30, 24, 18, 0.55);
}
#photo .bar { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; color: #f4ecda; letter-spacing: 0.25em; font-size: 15px; text-shadow: 0 1px 6px rgba(0,0,0,0.6); }
#photo.flash .frame { animation: flash 0.5s ease; }
@keyframes flash { 0% { filter: brightness(2.4); } 100% { filter: none; } }
body.photo #hint, body.photo #prompt, body.photo #toasts, body.photo #zone-title { visibility: hidden; }

#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, rgba(0,0,0,0) 55%, rgba(120, 92, 60, 0.28) 100%);
}

#zone-title {
  position: fixed; left: 6vw; top: 9vh; pointer-events: none;
  display: flex; align-items: flex-start; gap: 14px;
  opacity: 0; transform: translateY(8px);
  transition: opacity 1.4s ease, transform 1.4s ease;
}
#zone-title.show { opacity: 1; transform: none; }
#zone-title .name {
  writing-mode: vertical-rl; font-size: clamp(28px, 3.4vw, 46px); letter-spacing: 0.3em;
  color: var(--ink); text-shadow: 0 0 12px rgba(243, 234, 215, 0.9);
}
#zone-title .seal {
  writing-mode: vertical-rl; font-size: 14px; color: #f7ecd8; background: var(--seal);
  padding: 6px 3px; border-radius: 3px; margin-top: 6px; opacity: 0.85;
}

#hint {
  position: fixed; left: 50%; bottom: 6vh; transform: translateX(-50%);
  font-size: 18px; letter-spacing: 0.2em; color: rgba(58, 54, 50, 0.75);
  text-shadow: 0 0 10px rgba(243, 234, 215, 0.95);
  opacity: 0; transition: opacity 1.6s ease; pointer-events: none; white-space: nowrap;
}
#hint.show { opacity: 1; }

/* 交互提示：浮在物件上方的小纸签 */
#prompt {
  position: fixed; left: 0; top: 0; pointer-events: none; z-index: 5;
  padding: 5px 12px 6px; border-radius: 3px; font-size: 16px; letter-spacing: 0.15em; white-space: nowrap;
  background: rgba(247, 240, 225, 0.92); color: var(--ink); box-shadow: 0 2px 8px rgba(60, 40, 20, 0.25);
  border: 1px solid rgba(58, 54, 50, 0.35); opacity: 0; transition: opacity 0.25s ease;
}
#prompt.show { opacity: 1; }
#prompt::first-letter { color: var(--seal); font-weight: bold; }

#toasts { position: fixed; left: 50%; bottom: 13vh; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 5; }
.toast {
  padding: 8px 20px; font-size: 17px; letter-spacing: 0.12em; color: var(--ink);
  background: linear-gradient(90deg, rgba(247,240,225,0), rgba(247,240,225,0.95) 18%, rgba(247,240,225,0.95) 82%, rgba(247,240,225,0));
  opacity: 0; transform: translateY(8px); transition: opacity 0.6s ease, transform 0.6s ease; max-width: 80vw; text-align: center;
}
.toast.show { opacity: 1; transform: none; }

/* 往事 / 结局：一页纸 */
#memory, #ending {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 8;
  background: rgba(40, 32, 24, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.9s ease;
}
#memory.show, #ending.show { opacity: 1; pointer-events: auto; cursor: pointer; }
.page {
  width: min(760px, 90vw); padding: 26px 30px 22px; text-align: center;
  background: #f4ecda url("../assets/build/textures/paper.png"); background-size: 512px;
  box-shadow: 0 12px 40px rgba(30, 20, 10, 0.45), inset 0 0 0 1px rgba(58,54,50,0.25);
  transform: scale(0.96) rotate(-0.4deg); transition: transform 0.9s ease;
}
.show .page { transform: none; }
.page img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; box-shadow: 0 0 0 1px rgba(58,54,50,0.3); }
#ending .page img { aspect-ratio: 16 / 9; }
.page .idx { font-size: 15px; letter-spacing: 0.5em; color: var(--seal); margin-bottom: 12px; }
.page .cap, .page .line1 { margin-top: 16px; font-size: clamp(18px, 2vw, 22px); letter-spacing: 0.15em; line-height: 1.7; }
.page .cap { max-width: 36em; margin-left: auto; margin-right: auto; font-size: clamp(15px, 1.5vw, 19px); letter-spacing: 0.1em; } /* 往事旁白变长了：限宽、字略小 */
.page .line2 { margin-top: 8px; font-size: clamp(20px, 2.4vw, 28px); letter-spacing: 0.3em; color: #6a3a26; }
.page .k { margin-top: 14px; font-size: 13px; letter-spacing: 0.3em; color: rgba(58,54,50,0.55); }

/* 终点：摊开的手账（左页七折与朱印，右页收获与去向） */
#fin {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 9;
  opacity: 0; pointer-events: none; transition: opacity 2.4s ease; background: #24302e;
}
#fin .bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; filter: blur(2px); }
#fin.show { opacity: 1; pointer-events: auto; }
#fin .spread {
  position: relative; width: min(1100px, 94vw); aspect-ratio: 1752 / 897; max-height: 90vh;
  background: url("../assets/build/cx/journal_open.png") center / 100% 100% no-repeat;
  display: grid; grid-template-columns: 1fr 1fr; padding: 4.5% 6.5% 6% 6.5%; gap: 7%;
  filter: drop-shadow(0 18px 40px rgba(0,0,0,0.5));
  transform: scale(0.96); transition: transform 2s ease;
}
#fin.show .spread { transform: none; }
#fin .left, #fin .right { overflow: hidden; }
#fin ul.chapters { gap: 1px; margin-top: 8px; }
#fin ul.chapters li { font-size: clamp(12px, 1.2vw, 15px); padding: 1px 0; }
#fin ul.chapters li i { width: 24px; height: 24px; }
#fin .t { font-size: clamp(30px, 3.6vw, 52px); letter-spacing: 0.35em; }
#fin .s { margin-top: 4px; font-size: 16px; letter-spacing: 0.4em; color: var(--seal); }
#fin .h { font-size: 20px; letter-spacing: 0.4em; color: #6a3a26; }
#fin .stats { margin-top: 10px; font-size: 14px; letter-spacing: 0.08em; display: flex; gap: 6px 14px; flex-wrap: wrap; }
#fin .missing { margin-top: 10px; font-size: 14px; line-height: 1.8; color: rgba(58,54,50,0.78); letter-spacing: 0.06em; }
#fin .acts { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
#fin button, .pagelist button {
  font: inherit; font-size: 16px; letter-spacing: 0.18em; padding: 8px 18px; cursor: pointer;
  border: 1px solid rgba(58,54,50,0.35); border-radius: 3px; background: rgba(255,250,240,0.7); color: var(--ink);
}
#fin button:hover, .pagelist button:hover { background: #fffaf0; box-shadow: inset 3px 0 0 var(--seal); }
#fin .pages { display: none; margin-top: 10px; }
#fin .pages.show { display: block; }
/* 七折：已补全的盖上朱印 */
ul.chapters { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
ul.chapters li { display: flex; align-items: center; gap: 12px; font-size: 15px; letter-spacing: 0.12em; color: rgba(58,54,50,0.45); padding: 3px 0; border-bottom: 1px dashed rgba(58,54,50,0.2); }
ul.chapters li b { font-weight: normal; color: #6a3a26; min-width: 4em; }
ul.chapters li span { flex: 1; }
ul.chapters li i { width: 30px; height: 30px; flex: none; background: url("../assets/build/cx/seal_square.png") center / contain no-repeat; opacity: 0; transform: scale(1.6) rotate(-12deg); transition: opacity .5s, transform .5s; position: relative; }
ul.chapters li i::after { content: "补"; position: absolute; inset: 0; display: grid; place-items: center; color: #b0442c; font-size: 15px; }
ul.chapters li.on { color: var(--ink); }
ul.chapters li.on i { opacity: 0.9; transform: rotate(-8deg); }
.pagelist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pagelist button { min-width: 0; text-align: left; display: flex; justify-content: space-between; align-items: center; }
.pagelist button small { font-size: 12px; letter-spacing: 0.05em; color: rgba(58,54,50,0.6); }
.pagelist button[disabled] { opacity: 0.35; cursor: default; }
#pause .note.small { margin: 0 0 14px; font-size: 14px; }
#pause .grid.dyes { grid-template-columns: repeat(4, 1fr); gap: 14px; }
#pause .dye { font: inherit; border: 1px solid rgba(58,54,50,0.2); background: rgba(255,250,240,0.5); border-radius: 4px; padding: 6px 6px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--ink); }
#pause .dye i { width: 90px; height: 90px; display: block; background: url("../assets/build/b2/character/traveler_cloak_dyes.png") 0 0 / 400% 200% no-repeat; }
#pause .dye b { font-weight: normal; letter-spacing: 0.3em; font-size: 15px; }
#pause .dye small { font-size: 11px; color: rgba(58,54,50,0.6); text-align: center; line-height: 1.4; }
#pause .dye.locked { cursor: default; }
#pause .dye.locked i { filter: grayscale(1) brightness(1.3); opacity: 0.35; }
#pause .dye.on { box-shadow: inset 0 0 0 2px var(--seal); background: #fffaf0; }
#pause .row { display: flex; align-items: center; gap: 18px; margin: 14px 0; font-size: 17px; letter-spacing: 0.2em; }
#pause .seg { display: flex; flex-wrap: wrap; gap: 6px; }
#pause .seg button { font: inherit; font-size: 15px; letter-spacing: 0.15em; padding: 5px 12px; border: 1px solid rgba(58,54,50,0.3); border-radius: 3px; background: transparent; cursor: pointer; color: var(--ink); }
#pause .seg button.on { background: #b0442c; color: #fbf3e2; border-color: #b0442c; }

/* Esc 暂停菜单：摊开的手账 */
#pause {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  background: rgba(36, 30, 24, 0.5); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity 0.45s ease;
}
#pause.show { opacity: 1; pointer-events: auto; }
/* 手账：深青布面封皮包着宣纸内页，四角包金回纹，一条朱红书签带 */
#pause .book {
  position: relative; width: min(1100px, 94vw); height: min(680px, 90vh); display: grid; grid-template-columns: 220px 1fr;
  background: #f4ecda url("../assets/build/textures/paper.png"); background-size: 512px;
  border: 14px solid #2e4844; border-radius: 6px; overflow: visible;
  box-shadow: 0 0 0 2px #b89656, 0 0 0 5px #2e4844, 0 0 0 6px #8a6d3c, 0 22px 60px rgba(10, 8, 4, 0.6),
    inset 0 0 0 1px rgba(184,150,86,0.8), inset 0 0 0 6px #f4ecda, inset 0 0 0 7px rgba(176,68,44,0.35), inset 0 0 40px rgba(120, 90, 50, 0.18);
  transform: translateY(10px); transition: transform 0.45s ease;
}
#pause .book::before, #pause .book::after {
  /* 上下两道回纹饰边 */
  content: ""; position: absolute; left: 30px; right: 30px; height: 9px; pointer-events: none;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='9' viewBox='0 0 18 9'><path d='M1 8V1h7v5H4V3.5h2' fill='none' stroke='%23c9a35c' stroke-width='1.2'/><path d='M10 8V1h7v5h-4V3.5h2' fill='none' stroke='%23c9a35c' stroke-width='1.2'/></svg>") repeat-x;
}
#pause .book::before { top: -12px; }
#pause .book::after { bottom: -12px; }
#pause .corner { position: absolute; width: 34px; height: 34px; z-index: 2; pointer-events: none;
  border: 2px solid #c9a35c; background: #2e4844; }
#pause .corner::after { content: ""; position: absolute; inset: 6px; border: 1px solid #c9a35c; transform: rotate(45deg); }
#pause .corner.tl { left: -20px; top: -20px; } #pause .corner.tr { right: -20px; top: -20px; }
#pause .corner.bl { left: -20px; bottom: -20px; } #pause .corner.br { right: -20px; bottom: -20px; }
#pause .ribbon { position: absolute; right: 70px; top: -14px; width: 18px; height: 84px; background: #b0442c; z-index: 3; pointer-events: none;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 86%, 0 100%); box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
#pause .xclose {
  position: absolute; right: 22px; top: 16px; z-index: 4; width: 34px; height: 34px; padding: 0; border-radius: 50%;
  font: 16px/32px var(--font); color: #f7ecd8; background: #2e4844; border: 2px solid #c9a35c; cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3); transition: background 0.2s, transform 0.2s;
}
#pause .xclose:hover { background: #b0442c; transform: rotate(90deg); }
#pause.standalone nav button[data-tab]:not([data-tab="lore"]), #pause.standalone nav button[data-act="restart"] { display: none; }
#pause .grid.eight, #pause .grid.nine { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }
#pause .grid > * { min-width: 0; }
#pause .grid .cell span { overflow-wrap: anywhere; text-align: center; }
#pause button.cell { font: inherit; border: 0; background: none; cursor: default; color: var(--ink); padding: 0; }
#pause button.cell.got { cursor: pointer; }
#pause .poem { font-size: 17px; line-height: 2.1; letter-spacing: 0.25em; padding: 6px 18px; border-left: 3px solid rgba(176,68,44,0.4); }
#pause .poem p { margin: 0; color: rgba(58,54,50,0.3); }
#pause .poem p.got { color: var(--ink); }
#pause h2 small { font-size: 14px; letter-spacing: 0.1em; color: #b0442c; }
#pause h3 small { font-size: 12px; letter-spacing: 0.1em; color: rgba(58,54,50,0.55); }
#pause .grid.lores { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
#pause .lc { font: inherit; border: 1px solid rgba(58,54,50,0.15); background: rgba(255,250,240,0.4); border-radius: 3px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--ink); cursor: default; }
#pause .lc i { width: 64px; height: 64px; background-repeat: no-repeat; filter: grayscale(1) brightness(1.35); opacity: 0.3; }
#pause .lc.got { cursor: pointer; }
#pause .lc.got i { filter: none; opacity: 1; }
#pause .lc.got:hover { background: #fffaf0; box-shadow: inset 0 0 0 1px rgba(176,68,44,0.5); }
#pause.show .book { transform: none; }
#pause nav { display: flex; flex-direction: column; gap: 6px; padding: 26px 18px; border-right: 1px dashed rgba(58,54,50,0.35); background: rgba(201, 142, 58, 0.08); }
#pause .brand { font-size: 28px; letter-spacing: 0.3em; margin-bottom: 18px; }
#pause nav button {
  font: inherit; font-size: 18px; letter-spacing: 0.3em; text-align: left; padding: 9px 12px; border: 0; border-radius: 3px;
  background: transparent; color: var(--ink); cursor: pointer;
}
#pause nav button:hover, #pause nav button.on { background: rgba(58, 54, 50, 0.08); }
#pause nav button.on { box-shadow: inset 3px 0 0 var(--seal); }
#pause nav button[data-act="resume"] { color: #6a3a26; }
#pause .tip { margin-top: auto; font-size: 13px; letter-spacing: 0.2em; color: rgba(58,54,50,0.55); }
#pause .panel { display: none; padding: 26px 32px; overflow: auto; }
#pause .panel.on { display: block; }
#pause h2 { margin: 0 0 10px; font-size: 26px; letter-spacing: 0.4em; font-weight: normal; }
#pause h3 { margin: 18px 0 8px; font-size: 17px; letter-spacing: 0.4em; font-weight: normal; color: #6a3a26; }
#pause .stats { display: flex; gap: 22px; flex-wrap: wrap; font-size: 15px; letter-spacing: 0.1em; color: rgba(58,54,50,0.8); }
#pause .stats b { color: var(--seal); font-weight: normal; }
#pause .grid { display: grid; gap: 10px; }
#pause .grid.six { grid-template-columns: repeat(6, 1fr); }
#pause .grid.seven { grid-template-columns: repeat(7, 1fr); }
#pause .grid.mems { grid-template-columns: repeat(4, 1fr); }
#pause h2 small { font-size: 14px; letter-spacing: 0.2em; color: rgba(58,54,50,0.6); }
#pause .cell { font: inherit; border: 0; background: none; padding: 0; color: var(--ink); cursor: default; }
#pause .cell.got.clickable { cursor: pointer; }
#pause .cell .swatch { width: 44px; height: 44px; margin: 10px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(255,255,255,0.35), 0 1px 3px rgba(0,0,0,0.25); }
#pause .mem .todo { width: 100%; aspect-ratio: 4 / 3; display: grid; place-items: center; font-size: 12px; letter-spacing: 0.2em; color: rgba(58,54,50,0.45); box-shadow: 0 0 0 1px rgba(58,54,50,0.2); background: rgba(255,250,240,0.4); }
#pause .hi { display: inline-block; width: 26px; height: 26px; vertical-align: -6px; margin-right: 8px; background: url("../assets/build/b6/ui/journal_icons.png") 0 0 / 800% 100% no-repeat; }
#pause .panel.mark { background-repeat: no-repeat; background-position: right 24px bottom 18px; background-size: 210px auto; }
#pause ul.chapters li.bio { cursor: pointer; }
#pause ul.chapters li.bio:hover { background: rgba(176,68,44,0.06); }
#pause ul.chapters li small { font-size: 12px; color: rgba(58,54,50,0.55); letter-spacing: 0.1em; }
#pause .slots { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
#pause .slot { display: grid; grid-template-columns: 90px 1fr auto auto; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid rgba(58,54,50,0.2); border-radius: 4px; background: rgba(255,250,240,0.5); }
#pause .slot b { font-weight: normal; letter-spacing: 0.3em; color: #6a3a26; }
#pause .slot span { font-size: 15px; letter-spacing: 0.08em; }
#pause .slot small { display: block; font-size: 12px; color: rgba(58,54,50,0.55); margin-top: 2px; }
#pause .slot.empty span { color: rgba(58,54,50,0.4); }
#pause .slot button { font: inherit; font-size: 14px; letter-spacing: 0.15em; padding: 6px 14px; border: 1px solid rgba(58,54,50,0.3); border-radius: 3px; background: #fffaf0; color: var(--ink); cursor: pointer; }
#pause .slot button:hover:not([disabled]) { box-shadow: inset 0 -2px 0 #b0442c; }
#pause .slot button[disabled] { opacity: 0.35; cursor: default; }
#pause .voltabs { display: flex; gap: 8px; margin: 10px 0 2px; flex-wrap: wrap; }
#pause .voltabs button { font: inherit; font-size: 14px; letter-spacing: 0.2em; padding: 4px 12px; border: 1px solid rgba(58,54,50,0.25); border-radius: 3px; background: rgba(255,250,240,0.45); color: var(--ink); cursor: pointer; }
#pause .voltabs button.on { background: #b0442c; color: #fbf3e2; border-color: #b0442c; }
#pause .volgrid .vol .prog { font-size: 12px; color: #6a3a26; letter-spacing: 0.1em; }
#pause .volgrid .vol.locked { opacity: 0.45; filter: grayscale(0.8); cursor: not-allowed; }
#pause .grid.dyes .dye i.sw { background: none !important; border-radius: 50%; }
#pause .cell { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; letter-spacing: 0.05em; text-align: center; opacity: 0.32; filter: grayscale(1); transition: opacity .4s, filter .4s; }
#pause .cell.got { opacity: 1; filter: none; }
#pause .cell .spr { width: 64px; height: 64px; display: block; background-repeat: no-repeat; }
#pause .mem { font: inherit; border: 0; padding: 0; background: none; cursor: default; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--ink); letter-spacing: 0.2em; }
#pause .mem img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; filter: grayscale(1) blur(3px) brightness(1.15); opacity: 0.35; box-shadow: 0 0 0 1px rgba(58,54,50,0.25); }
#pause .mem.got { cursor: pointer; }
#pause .mem.got img { filter: none; opacity: 1; }
#pause label { display: flex; align-items: center; gap: 18px; margin: 16px 0; font-size: 17px; letter-spacing: 0.2em; }
#pause label input[type="range"] { flex: 1; max-width: 360px; accent-color: #b0442c; }
#pause label.check input { width: 18px; height: 18px; accent-color: #b0442c; }
#pause dl { display: grid; grid-template-columns: 160px 1fr; gap: 10px 18px; font-size: 17px; }
#pause dt { color: #6a3a26; letter-spacing: 0.1em; }
#pause dd { margin: 0; }
#pause .note { margin-top: 26px; line-height: 1.9; font-size: 16px; color: rgba(58,54,50,0.85); letter-spacing: 0.08em; }
@media (max-width: 700px) {
  #pause .book { grid-template-columns: 1fr; height: 92vh; }
  #pause nav { flex-direction: row; flex-wrap: wrap; padding: 12px; }
  #pause .brand, #pause .tip { display: none; }
  #pause .grid.six, #pause .grid.seven { grid-template-columns: repeat(4, 1fr); }
}

#hud {
  position: fixed; right: 10px; top: 10px; font: 12px/1.5 ui-monospace, Consolas, monospace;
  background: rgba(255,255,255,0.6); padding: 6px 8px; border-radius: 4px; display: none; white-space: pre;
}
#hud.show { display: block; }

/* 开始：桌上一本合上的书，点一下封面翻开，里页是菜单 */
#title {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: #1f2826; transition: opacity 1.6s ease; overflow: hidden;
}
#title.hide { opacity: 0; pointer-events: none; }
#title .cover-bg {
  position: absolute; inset: -4%; background: url("../assets/ui/key_art_book.png") center / cover no-repeat;
  filter: blur(6px) brightness(0.45) saturate(0.9); transform: scale(1.05); transition: transform 6s ease, filter 2s ease;
}
#title.open .cover-bg { transform: scale(1.12); filter: blur(4px) brightness(0.5); }
#title .desk { position: relative; perspective: 2200px; }
#title .book3d { position: relative; width: min(1000px, 92vw); aspect-ratio: 1752 / 897; transform-style: preserve-3d; transform: translateX(-23%); transition: transform 1.3s cubic-bezier(.6,.05,.3,1); }
#title.open .book3d { transform: none; } /* 合着时书居中；翻开时整本书往右挪半页，对开页正好居中 */
#title .inside {
  position: absolute; inset: 0; background: url("../assets/build/cx/journal_open.png") center / 100% 100% no-repeat;
  display: grid; grid-template-columns: 1fr 1fr; padding: 5% 7% 6.5%; gap: 8%;
  filter: drop-shadow(0 20px 40px rgba(0,0,0,0.55)); opacity: 0; transition: opacity 0.8s ease 0.5s;
}
#title.open .inside { opacity: 1; }
/* 合上的书：封面只有一页大，放在右页的位置，书脊在中线；翻开时封面绕书脊转到左边，露出整个对开页 */
#title .cover {
  position: absolute; left: 50%; right: 3.2%; top: 3%; bottom: 5.5%;
  background: url("../assets/build/cx/book_cover_closed.png") center / 100% 100% no-repeat; border-radius: 2px 8px 8px 2px;
  transform-origin: 0 50%; transform: rotateY(0deg); transform-style: preserve-3d; backface-visibility: hidden;
  transition: transform 1.4s cubic-bezier(.6,.05,.3,1), opacity 0.6s ease 0.9s;
  box-shadow: 0 26px 46px rgba(0,0,0,0.55), 0 4px 10px rgba(0,0,0,0.35);
  cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
/* 书脊：封面左缘一道圆起来的布脊 */
#title .cover::before { content: ""; position: absolute; left: -2.2%; top: 0; bottom: 0; width: 4.4%; border-radius: 6px 0 0 6px;
  background: linear-gradient(90deg, #172a27, #2c4a45 45%, #203834); box-shadow: inset 0 0 0 1px rgba(206,168,92,0.35); }
/* 书页的厚度：右边和下边露出一叠纸边 */
#title .pages-edge {
  position: absolute; left: 50.6%; right: 2.4%; top: 3.8%; bottom: 4.6%; border-radius: 2px 6px 6px 2px;
  background: repeating-linear-gradient(90deg, #efe4c8 0 2px, #d9cba6 2px 3px), #e9dcbc;
  box-shadow: 0 22px 40px rgba(0,0,0,0.5); transition: opacity 0.6s ease 0.6s;
}
#title .pages-edge::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.4%;
  background: repeating-linear-gradient(0deg, #efe4c8 0 2px, #d6c7a0 2px 3px); border-radius: 0 0 6px 2px; }
#title.open .cover { transform: rotateY(-178deg); opacity: 0; pointer-events: none; }
#title.open .pages-edge { opacity: 0; }
#title .pages-edge { pointer-events: none; } /* 纸边只是装饰：翻开后它还盖在右页上，会挡住按钮 */
#title .ct { font-size: clamp(32px, 4.2vw, 60px); color: #e9c98a; letter-spacing: 0.5em; padding-top: 0.5em; writing-mode: vertical-rl; border: 1px solid rgba(233,201,138,0.6); padding: 0.6em 0.35em 0.1em; background: rgba(20,40,37,0.35); text-shadow: 0 2px 6px rgba(0,0,0,0.5); }
#title .press { position: absolute; left: 0; right: 0; bottom: -9%; text-align: center; font-size: 15px; letter-spacing: 0.35em; color: #e9dcc0; opacity: 0; animation: breathe 2.8s ease-in-out infinite; }
#title.ready .press { opacity: 1; }
#title .lp { display: flex; flex-direction: column; position: relative; }
#title .name { font-size: clamp(34px, 4.2vw, 60px); letter-spacing: 0.35em; }
#title .sub { margin-top: 4px; font-size: clamp(14px, 1.3vw, 18px); letter-spacing: 0.5em; color: var(--seal); }
#title .intro { margin-top: 6%; font-size: clamp(13px, 1.15vw, 16px); line-height: 2; letter-spacing: 0.08em; color: rgba(58,54,50,0.85); }
#title .seal { position: absolute; right: 4%; bottom: 4%; width: 58px; height: 58px; display: grid; place-items: center; writing-mode: vertical-rl;
  color: #f7ecd8; background: #b0442c; border-radius: 4px; font-style: normal; font-size: 16px; letter-spacing: 0.1em; transform: rotate(-6deg); opacity: 0.85; }
#title .rp { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
#title .rp button {
  font: inherit; font-size: clamp(15px, 1.4vw, 19px); letter-spacing: 0.3em; padding: 10px 14px; text-align: left; cursor: pointer;
  background: transparent; border: 0; border-bottom: 1px dashed rgba(58,54,50,0.35); color: var(--ink);
}
#title .rp button:hover:not([disabled]) { color: #6a3a26; box-shadow: inset 3px 0 0 var(--seal); background: rgba(176,68,44,0.06); }
#title .rp button[disabled] { opacity: 0.35; cursor: default; }
#title .rp .small { margin-top: 8px; font-size: 13px; letter-spacing: 0.2em; color: rgba(58,54,50,0.55); }
#title .loading { position: absolute; bottom: 5vh; color: #f3ead7; letter-spacing: 0.4em; font-size: 15px; opacity: 0.8; }
#title.ready .loading { display: none; }
@keyframes breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* 主线书签：右上角的一张竖签 */
#quest {
  position: fixed; right: 18px; top: 16px; width: 260px; padding: 12px 16px 12px 18px; z-index: 4; pointer-events: none;
  background: rgba(247, 240, 225, 0.9) url("../assets/build/textures/paper.png"); background-size: 300px;
  box-shadow: 0 4px 16px rgba(60, 40, 20, 0.22), inset 3px 0 0 #b0442c; border-radius: 2px;
  opacity: 0; transform: translateY(-6px); transition: opacity 0.8s, transform 0.8s;
}
#quest.show { opacity: 1; transform: none; }
body.photo #quest, body.paused #quest { opacity: 0; }
#quest .seals { display: flex; gap: 4px; margin-bottom: 6px; }
#quest .seals i { width: 14px; height: 14px; border: 1px solid rgba(176,68,44,0.45); border-radius: 2px; }
#quest .seals i.on { background: #b0442c; border-color: #b0442c; }
#quest .n { font-size: 15px; letter-spacing: 0.12em; color: #6a3a26; }
#quest .g { margin-top: 4px; font-size: 14px; line-height: 1.6; letter-spacing: 0.05em; }
#quest .p { margin-top: 6px; font-size: 12px; letter-spacing: 0.1em; color: rgba(58,54,50,0.55); }

/* 角落知识卡 */
/* 对话：半身像立在台词框一侧，像从书页里探出身来 */
#dialog { position: fixed; left: 0; right: 0; bottom: 0; height: 40vh; z-index: 9; pointer-events: none; opacity: 0; transition: opacity 0.25s ease; }
#dialog.show { opacity: 1; pointer-events: auto; cursor: pointer; }
#dialog::before { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(40,30,20,0.4), rgba(40,30,20,0)); }
#dialog .box {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); width: min(980px, 94vw); min-height: 140px; box-sizing: border-box;
  padding: 28px 34px 14px 166px;
  background: rgba(246, 239, 222, 0.97) url("../assets/build/textures/paper.png"); background-size: 420px;
  border: 2px solid #2e4844; outline: 1px solid #c9a35c; outline-offset: -7px; border-radius: 4px; box-shadow: 0 10px 30px rgba(30,20,10,0.4);
}
/* 小幅画像：嵌在台词框一角的方框里，像手账上贴的一张小像 */
#dialog .portrait {
  position: absolute; left: 22px; top: 16px; width: 116px; height: 116px; box-sizing: border-box; overflow: hidden;
  border: 2px solid #c9a35c; outline: 1px solid #2e4844; outline-offset: 2px; border-radius: 3px;
  background: radial-gradient(circle at 50% 40%, #fbf5e6, #e8dcc2); opacity: 0; transform: scale(0.92); transition: opacity 0.25s, transform 0.25s;
}
#dialog .portrait.on { opacity: 1; transform: none; }
#dialog .portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 50%; }
#dialog.right .box { padding: 28px 166px 14px 34px; }
#dialog.right .portrait { left: auto; right: 22px; }
#dialog.right .portrait img { transform: scaleX(-1); }
#dialog.narr .box { padding: 28px 40px 14px; text-align: center; }
#dialog .name { position: absolute; top: -16px; left: 150px; padding: 4px 16px; font-size: 16px; letter-spacing: 0.3em; color: #fbf3e2; background: #b0442c; border-radius: 2px; box-shadow: 0 2px 4px rgba(0,0,0,0.25); }
#dialog.right .name { left: auto; right: 150px; }
#dialog .name:empty { display: none; }
#dialog .text { font-size: 20px; line-height: 1.85; letter-spacing: 0.08em; min-height: 3.7em; }
#dialog .text.thought { color: rgba(58,54,50,0.7); }
#dialog .more { text-align: right; word-spacing: 0.6em; font-size: 12px; letter-spacing: 0.2em; color: rgba(58,54,50,0.5); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
#mini { position: fixed; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; background: rgba(40, 32, 24, 0.42); opacity: 0; pointer-events: none; transition: opacity 0.4s ease; }
#mini.show { opacity: 1; pointer-events: auto; }
#mini .sheet {
  position: relative; width: min(760px, 92vw); max-height: 88vh; overflow: auto; padding: 24px 28px 18px; text-align: center;
  background: #f4ecda url("../assets/build/textures/paper.png"); background-size: 512px;
  border: 10px solid #8a3a28; outline: 2px solid #c9a35c; outline-offset: -6px; border-radius: 4px; box-shadow: 0 14px 40px rgba(30, 20, 10, 0.45);
}
#mini .t { font-size: 22px; letter-spacing: 0.4em; color: #8a3a28; }
#mini .x { margin: 10px auto 14px; max-width: 560px; font-size: 17px; line-height: 1.9; letter-spacing: 0.08em; white-space: pre-line; }
#mini .choices { display: grid; gap: 10px; }
#mini .choices button { font: inherit; color: var(--ink); cursor: pointer; padding: 8px 6px 10px; border: 1px solid rgba(58,54,50,0.25); border-radius: 4px; background: rgba(255,250,240,0.55); display: flex; flex-direction: column; align-items: center; gap: 4px; transition: background 0.2s, box-shadow 0.2s; }
#mini .choices button:hover { background: #fffaf0; box-shadow: inset 0 -3px 0 #b0442c; }
#mini .choices button.on { background: #fffaf0; box-shadow: inset 0 0 0 2px #b0442c; }
#mini .choices i { width: 100%; max-width: 120px; aspect-ratio: 1; background-repeat: no-repeat; background-position: center; }
#mini .choices b { font-weight: normal; font-size: 17px; letter-spacing: 0.15em; }
#mini .choices b em { font-style: normal; font-size: 12px; color: #b0442c; margin-right: 4px; }
#mini .choices small { font-size: 12px; color: rgba(58,54,50,0.6); }
#mini .res { min-height: 26px; margin-top: 12px; font-size: 16px; letter-spacing: 0.1em; opacity: 0; transition: opacity 0.3s; }
#mini .res.show { opacity: 1; }
#mini .res.ok { color: #6a3a26; }
#mini .res.no { color: rgba(58,54,50,0.6); }
#mini .close { margin-top: 8px; font: inherit; font-size: 14px; letter-spacing: 0.2em; border: 0; background: none; color: rgba(58,54,50,0.6); cursor: pointer; }
#lorecard {
  position: fixed; left: 18px; bottom: 18px; width: min(420px, 86vw); z-index: 6; display: flex; gap: 12px; padding: 12px; cursor: pointer;
  background: rgba(247, 240, 225, 0.96) url("../assets/build/textures/paper.png"); background-size: 300px;
  box-shadow: 0 8px 26px rgba(40, 26, 12, 0.35), inset 0 0 0 1px rgba(58,54,50,0.25);
  opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity 0.7s, transform 0.7s;
}
#lorecard.show { opacity: 1; transform: none; pointer-events: auto; }
#lorecard .img { width: 96px; height: 96px; flex: none; background-repeat: no-repeat; background-position: center; background-size: contain; }
#lorecard .cat { font-size: 12px; letter-spacing: 0.2em; color: #b0442c; }
#lorecard .t { margin-top: 2px; font-size: 18px; letter-spacing: 0.2em; }
#lorecard .x { margin-top: 4px; font-size: 13px; line-height: 1.75; color: rgba(58,54,50,0.85); }
#lorepage { position: fixed; inset: 0; z-index: 15; display: none; align-items: center; justify-content: center; background: rgba(30,24,18,0.45); cursor: pointer; }
#lorepage.show { display: flex; }
#lorepage .sheet {
  width: min(520px, 90vw); padding: 26px 30px; text-align: center;
  background: #f4ecda url("../assets/build/textures/paper.png"); background-size: 512px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(58,54,50,0.3), inset 0 0 0 8px rgba(247,240,225,0.8), inset 0 0 0 9px rgba(176,68,44,0.35);
}
#lorepage .img { width: 180px; height: 180px; margin: 0 auto; background-repeat: no-repeat; background-position: center; background-size: contain; }
#lorepage .cat { margin-top: 10px; font-size: 13px; letter-spacing: 0.3em; color: #b0442c; }
#lorepage .t { margin-top: 4px; font-size: 26px; letter-spacing: 0.3em; }
#lorepage .x { margin-top: 12px; font-size: 16px; line-height: 2; text-align: left; color: rgba(58,54,50,0.9); }
#lorepage .k { margin-top: 12px; font-size: 12px; letter-spacing: 0.3em; color: rgba(58,54,50,0.5); }

/* 节拍小游戏（龙舟鼓） */
#rhythm { position: fixed; inset: 0; z-index: 9; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: rgba(40,30,20,0.35); pointer-events: none; }
#rhythm.show { display: flex; }
#rhythm .t { font-size: 22px; letter-spacing: 0.4em; color: #fbf3e2; text-shadow: 0 2px 8px rgba(0,0,0,0.5); }
#rhythm .ring { position: relative; width: 120px; height: 120px; }
#rhythm .ring b { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, #c94a2c 0 52%, #8a3a28 53% 60%, transparent 61%); box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
#rhythm .ring i { position: absolute; inset: 0; border-radius: 50%; border: 4px solid #f3d38a; z-index: 2; }
#rhythm.hit .ring b { filter: brightness(1.4); transform: scale(1.06); }
#rhythm .n { font-size: 16px; letter-spacing: 0.2em; color: #fbf3e2; }
#rhythm::after { content: "金圈压到鼓面边上时，按 E / 空格（或点一下）"; font-size: 13px; color: rgba(251,243,226,0.8); letter-spacing: 0.2em; }

/* 开始界面：四卷书架 */
#title .shelf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 10px; }
#title .shelf .vol { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px 6px; border: 1px solid rgba(58,54,50,0.2); border-radius: 3px; background: rgba(255,250,240,0.45); cursor: pointer; color: var(--ink); }
#title .shelf .vol:hover { background: #fffaf0; box-shadow: inset 0 -3px 0 #b0442c; }
#title .shelf .vol.on { box-shadow: inset 0 0 0 2px #b0442c; cursor: default; }
#title .shelf .vol i { width: 100%; aspect-ratio: 1024 / 1365; background: url("../assets/build/b4/ui/volume_covers.png") 0 0 / 400% 100% no-repeat; border-radius: 2px; box-shadow: 0 2px 5px rgba(40,26,12,0.25); }
#title .shelf .vol span { font-size: 14px; letter-spacing: 0.2em; }
#title .shelf .vol small { font-size: 11px; color: rgba(58,54,50,0.6); letter-spacing: 0.05em; }

#title .shelf .vol.locked { opacity: 0.45; filter: grayscale(0.8); cursor: not-allowed; }
#title .shelf .vol.locked small::after { content: "（未读到）"; }
#pause .volgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 10px; }
#pause .volgrid .vol { font: inherit; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border: 1px solid rgba(58,54,50,0.2); border-radius: 4px; background: rgba(255,250,240,0.5); cursor: pointer; color: var(--ink); }
#pause .volgrid .vol:hover { background: #fffaf0; box-shadow: inset 0 -3px 0 #b0442c; }
#pause .volgrid .vol.on { box-shadow: inset 0 0 0 2px #b0442c; cursor: default; }
#pause .volgrid .vol i { width: 100%; aspect-ratio: 1024 / 1365; background: url("../assets/build/b4/ui/volume_covers.png") 0 0 / 400% 100% no-repeat; }
#pause .volgrid .vol b { font-weight: normal; letter-spacing: 0.3em; }
#pause .volgrid .vol small { font-size: 12px; color: rgba(58,54,50,0.6); }

/* 读完的卷：封面右下角盖一方朱印（浪花、荷叶、雁、梅花） */
#title .shelf .vol i, #pause .volgrid .vol i { position: relative; }
.vol i em.done { position: absolute; right: 4%; bottom: 3%; width: 38%; aspect-ratio: 1; background: url("../assets/build/b5/ui/volume_seals_done.png") 0 0 / 400% 100% no-repeat; transform: rotate(-8deg); opacity: 0.92; pointer-events: none; }
