/* 《梦的回响》网页原型。舞台固定为 1280x720，由脚本整体缩放。配色沿用官网的暖纸 / 海青 / 梦紫。 */
:root {
  --ink: #211915; --softink: #594d43; --paper: #f6efe2; --paper2: #efe5d3; --gold: #c99b59;
  --sea: #3e7880; --seadeep: #2f5c63; --dream: #5b4a72; --night: #17100d; --warn: #8c4a32;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --hand: "KaiTi", "STKaiti", "Kaiti SC", var(--serif);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: #0b0807; overflow: hidden; }
body { font-family: var(--sans); color: var(--ink); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid #f2c14e; outline-offset: 2px; }

#stage { position: absolute; left: 50%; top: 50%; width: 1280px; height: 720px; overflow: hidden; background: var(--night); transform-origin: center; user-select: none; -webkit-user-select: none; --fs: 22px; }
#stage[data-font="0"] { --fs: 19px; }
#stage[data-font="2"] { --fs: 26px; }
#scene, #actors, #hotspots, #panel, #dlgCatch, #modal { position: absolute; inset: 0; }
#scene { z-index: 1; }
#scene > svg, #scene > img.bg, #panel > svg { width: 100%; height: 100%; display: block; object-fit: cover; }
#scene.fade { animation: fadeIn .6s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---- 人物 ---- */
#actors { z-index: 2; pointer-events: none; }
.actor { position: absolute; top: 513px; transform: translate(-50%, -100%); transition: left linear; line-height: 0; }
.actor.flip svg { transform: scaleX(-1); }
.actor.walking svg { animation: bob .33s ease-in-out infinite; }
@keyframes bob { 50% { translate: 0 -4px; } }

/* ---- 热点 ---- */
#hotspots, #sbPins, #sbRegions, #cuHot { z-index: 3; pointer-events: none; }
#sbPins, #sbRegions, #cuHot { position: absolute; inset: 0; }
.hs { position: absolute; background: transparent; border: 0; border-radius: 10px; padding: 0; pointer-events: auto; }
.hs-dot { position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px; border-radius: 50%; background: var(--paper); border: 3px solid var(--ink); box-shadow: 0 0 0 3px rgba(246, 239, 226, .55); animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 9px rgba(246, 239, 226, 0); } }
.hs-label { position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); white-space: nowrap; background: var(--night); color: var(--paper); font-size: 15px; padding: 4px 10px; border-radius: 6px; opacity: 0; transition: opacity .15s; pointer-events: none; }
.hs:hover .hs-label, .hs:focus-visible .hs-label { opacity: 1; }
.hs:hover { background: rgba(246, 239, 226, .12); }
.hs.unmarked .hs-dot, .hs.unmarked .hs-label { display: none; }
.hs.unmarked:hover { background: transparent; }
.hs.region { border: 2px dashed transparent; }
.hs.region:hover, .hs.region:focus-visible { border-color: var(--warn); background: rgba(140, 74, 50, .08); }
.hs.region .hs-dot { background: var(--warn); border-color: var(--paper); }

#chips { position: absolute; z-index: 4; left: 0; right: 0; top: 596px; display: flex; justify-content: center; gap: 14px; }
.chip, .opt, .mbtn { color: var(--ink); border: 2px solid var(--ink); background: var(--paper); border-radius: 999px; padding: 10px 22px; font-size: 17px; font-family: var(--serif); box-shadow: 0 3px 0 rgba(33, 25, 21, .35); }
.chip:hover, .opt:hover { background: #fffdf8; }
.chip.strong, .opt.strong { background: var(--seadeep); color: var(--paper); border-color: var(--night); }
.chip.strong:hover, .opt.strong:hover { background: var(--sea); }
.opt { font-size: 16px; padding: 8px 16px; }
.opt:disabled { opacity: .45; cursor: default; }

/* ---- 特写与速写本 ---- */
#panel { z-index: 5; }
#sbPins.lock { display: none; }
.pin { position: absolute; width: 30px; height: 30px; margin: -15px; border-radius: 50%; border: 2.5px solid var(--ink); background: rgba(246, 239, 226, .92); padding: 0; pointer-events: auto; touch-action: none; font-size: 13px; }
.pin i { font-style: normal; font-weight: 700; }
.pin span { position: absolute; top: 4px; white-space: nowrap; font-size: 13px; background: rgba(246, 239, 226, .88); padding: 1px 6px; border-radius: 4px; pointer-events: none; }
.pin.lab-l span { right: 34px; }
.pin.lab-r span { left: 34px; }
.pin.ph { cursor: grab; }
.pin.sel { background: var(--warn); box-shadow: 0 0 0 5px rgba(140, 74, 50, .3); }
.pin.used { background: var(--sea); color: #fff; opacity: 1; cursor: default; }
#sbPrompt, #sbFeedback, #sbOpts, #sbSlider, #sbHint, #cuNote { position: absolute; z-index: 4; font-family: var(--serif); }
#sbPrompt { left: 82px; top: 588px; width: 530px; font-size: calc(var(--fs) - 5px); color: var(--ink); }
#sbFeedback { left: 82px; top: 624px; width: 530px; font-size: calc(var(--fs) - 6px); color: var(--warn); line-height: 1.45; }
#sbOpts { left: 668px; top: 622px; width: 540px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
#sbSlider { left: 690px; top: 54px; font-size: 14px; color: var(--softink); display: flex; align-items: center; gap: 10px; }
#sbHint { left: 82px; top: 50px; width: 530px; font-size: 15px; display: flex; gap: 12px; align-items: center; }
#sbHint button { border: 1.5px solid var(--softink); background: transparent; border-radius: 999px; padding: 4px 14px; font-size: 14px; white-space: nowrap; }
#sbHint p { margin: 0; color: var(--softink); }
#ghost { mix-blend-mode: multiply; pointer-events: none; }
#hypoRing { transition: stroke-dashoffset 1.1s ease; }
#hypoRing.draw { stroke-dashoffset: 0; }
.calm #hypoRing { transition: none; }

#cuDark { position: absolute; inset: 0; z-index: 2; pointer-events: none; background: radial-gradient(circle at var(--lx, 640px) var(--ly, 330px), transparent 0, transparent 95px, rgba(6, 6, 8, .6) 180px, rgba(6, 6, 8, .93) 320px); }
#cuDark:not([hidden]) ~ #cuHot .hs-dot { display: none; }
#cuDark:not([hidden]) ~ #cuHot .hs:hover { background: transparent; }
#cuNote { left: 0; right: 0; bottom: 34px; text-align: center; color: var(--paper); font-size: calc(var(--fs) - 5px); text-shadow: 0 1px 4px #000; pointer-events: none; padding: 0 240px; }
.opt.back { position: absolute; left: 40px; bottom: 28px; pointer-events: auto; }

.present, .choice { position: absolute; inset: 0; background: rgba(23, 16, 13, .62); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--paper); font-family: var(--serif); font-size: calc(var(--fs) - 2px); padding: 60px 120px; text-align: center; }
.present p, .choice p { margin: 0; }
.present .q { font-size: calc(var(--fs) + 4px); }
.present .opts { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.present .fb { min-height: 1.6em; color: #f0c9a8; }
.choice .q { max-width: 900px; line-height: 1.6; }
.cards { display: flex; gap: 26px; }
.card { width: 420px; text-align: left; background: var(--paper); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px; padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; font-family: var(--serif); font-size: calc(var(--fs) - 5px); line-height: 1.5; }
.card b { font-size: calc(var(--fs) - 2px); }
.card i { font-style: normal; display: inline-block; font-size: 13px; background: var(--ink); color: var(--paper); border-radius: 4px; padding: 0 7px; margin-right: 8px; }
.card[aria-pressed="true"] { border-color: var(--sea); box-shadow: 0 0 0 5px rgba(62, 120, 128, .55); background: #fffdf8; }
.card[aria-pressed="true"]::after { content: "✓ 已选"; align-self: flex-end; color: var(--seadeep); font-weight: 700; }

/* ---- 对白 ---- */
#dlgCatch { z-index: 6; background: transparent; border: 0; cursor: pointer; }
#doc { position: absolute; z-index: 7; left: 50%; top: 34px; transform: translateX(-50%); pointer-events: none; filter: drop-shadow(0 10px 24px rgba(0, 0, 0, .5)); }
#dialogue { position: absolute; z-index: 8; left: 90px; right: 90px; bottom: 20px; min-height: 132px; background: rgba(23, 16, 13, .92); border: 1px solid rgba(201, 155, 89, .6); border-radius: 12px; padding: 26px 34px 22px; color: var(--paper); font-family: var(--serif); font-size: var(--fs); line-height: 1.6; cursor: pointer; }
#dlgText { margin: 0; }
#dialogue.narr #dlgText { color: #e3d6bf; }
#dlgName { position: absolute; left: 26px; top: -17px; background: var(--gold); color: var(--ink); font-weight: 700; padding: 2px 16px; border-radius: 6px; font-size: calc(var(--fs) - 4px); }
#dlgSkip { position: absolute; right: 18px; top: -17px; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 6px; padding: 2px 12px; font-size: 14px; font-family: var(--sans); }
#dlgNext { position: absolute; right: 22px; bottom: 10px; font-size: 14px; color: var(--gold); animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.calm #dlgNext { animation: none; }

/* ---- HUD ---- */
#hud { position: absolute; z-index: 9; left: 0; right: 0; top: 0; pointer-events: none; }
#stage[data-scene="end"] #hud { display: none; }
#objective { position: absolute; left: 16px; top: 14px; max-width: 760px; background: rgba(23, 16, 13, .78); color: var(--paper); border-radius: 8px; padding: 7px 14px; font-size: 16px; font-family: var(--serif); }
#objective span { font-size: 12px; color: var(--gold); margin-right: 10px; font-family: var(--sans); letter-spacing: .1em; }
#objective b { font-weight: 500; }
#hudBtns { position: absolute; right: 16px; top: 14px; display: flex; gap: 8px; pointer-events: auto; }
#hudBtns button { background: rgba(23, 16, 13, .78); color: var(--paper); border: 1px solid rgba(246, 239, 226, .35); border-radius: 8px; padding: 7px 14px; font-size: 15px; }
#hudBtns button:hover { background: var(--seadeep); }
#toast { position: absolute; z-index: 10; left: 50%; top: 64px; transform: translate(-50%, -8px); background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; padding: 8px 20px; font-family: var(--serif); font-size: 17px; opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; white-space: pre; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#badge { position: absolute; z-index: 9; left: 10px; bottom: 4px; font-size: 11px; color: var(--paper); opacity: .6; text-shadow: 0 1px 2px #000; pointer-events: none; }

/* ---- 文书 ---- */
.doc { width: 430px; padding: 22px 26px; background: var(--paper); font-family: var(--serif); font-size: calc(var(--fs) - 5px); line-height: 1.7; color: var(--ink); border: 1px solid #b9a98c; }
.doc h4 { margin: 0 0 10px; font-size: calc(var(--fs) - 3px); letter-spacing: .08em; }
.doc p { margin: 0 0 8px; }
.doc svg { display: block; width: 100%; height: auto; max-height: 330px; }
.doc .cap { color: var(--softink); font-size: calc(var(--fs) - 8px); margin-top: 10px; }
.doc .sign, .doc .date { text-align: right; }
.doc.letter { font-family: var(--hand); font-size: calc(var(--fs) + 1px); line-height: 1.9; background: #f1e4c6; transform: rotate(-.8deg); }
.doc.letter .date { font-size: calc(var(--fs) - 5px); color: var(--softink); }
.doc.hand { font-family: var(--hand); }
.doc.photo { background: #fbf7ee; }
.doc.form table { width: 100%; border-collapse: collapse; }
.doc.form th, .doc.form td { border: 1px solid var(--softink); padding: 5px 10px; text-align: left; }
.doc.form th { width: 96px; font-weight: 500; background: var(--paper2); white-space: nowrap; }
.doc.rubbing .rub { background: repeating-linear-gradient(115deg, #55514c 0 3px, #6a665f 3px 5px, #4a4742 5px 9px); color: #ece6d8; font-family: Georgia, serif; font-size: 44px; letter-spacing: .12em; text-align: center; padding: 34px 10px; border-radius: 3px; text-shadow: 0 0 1px #fff; }

/* ---- 弹窗 ---- */
#modal { z-index: 20; background: rgba(0, 0, 0, .58); display: flex; align-items: center; justify-content: center; }
.sheet { position: relative; width: 580px; max-height: 640px; overflow: auto; background: #fffdf8; border-radius: 14px; padding: 26px 32px; font-size: calc(var(--fs) - 5px); line-height: 1.6; }
.sheet.wide { width: 860px; }
.sheet > .doc { width: auto; border: 0; padding: 4px 0; background: transparent; }
.sheet h3 { margin: 0 0 16px; font-family: var(--serif); font-size: calc(var(--fs) + 1px); }
.sheet .x { position: absolute; right: 14px; top: 10px; width: 38px; height: 38px; border: 0; background: transparent; font-size: 28px; line-height: 1; border-radius: 50%; }
.sheet .x:hover { background: var(--paper2); }
.sheet button:not(.x) { color: var(--ink); border: 1.5px solid var(--ink); background: var(--paper); border-radius: 8px; padding: 6px 16px; }
.sheet button[aria-pressed="true"], .sheet button[aria-current="true"] { background: var(--seadeep); color: var(--paper); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid rgba(33, 25, 21, .1); }
.row.end { justify-content: flex-end; border: 0; padding-top: 18px; }
.row input[type="range"] { width: 240px; }
.row input[type="checkbox"] { width: 22px; height: 22px; }
.seg { display: flex; gap: 6px; }
.help { color: var(--softink); font-size: calc(var(--fs) - 7px); }
.sheet textarea { width: 100%; font: 13px/1.5 ui-monospace, Consolas, monospace; border: 1px solid var(--softink); border-radius: 8px; padding: 10px; resize: none; }
.evid { display: grid; grid-template-columns: 170px 1fr; gap: 22px; align-items: start; }
.evid nav { display: flex; flex-direction: column; gap: 8px; }
.evid nav button { text-align: left; }
.evid .doc { width: auto; }
.backlog { max-height: 460px; overflow: auto; font-family: var(--serif); }
.backlog p { margin: 0 0 10px; }
.backlog b { color: var(--warn); margin-right: 10px; }

/* ---- 主菜单 ---- */
.menu { position: absolute; inset: 0; padding: 64px 84px; background: linear-gradient(90deg, rgba(23, 16, 13, .93) 0, rgba(23, 16, 13, .78) 38%, rgba(23, 16, 13, 0) 78%); color: var(--paper); display: flex; flex-direction: column; align-items: flex-start; }
.menu .logo { width: 430px; height: auto; }
.menu .tag { font-family: var(--serif); font-size: 21px; margin: 22px 0 30px; letter-spacing: .06em; }
.menu nav { display: flex; flex-direction: column; gap: 14px; }
.mbtn { width: 300px; text-align: left; padding: 12px 26px; font-size: 20px; background: rgba(246, 239, 226, .96); }
.mbtn:hover { background: #fff; transform: translateX(4px); }
.menu .warn { max-width: 470px; margin: 18px 0 0; font-size: 14px; line-height: 1.6; color: #f0c9a8; }
.menu .foot { margin: auto 0 0; font-size: 13px; line-height: 1.7; color: rgba(246, 239, 226, .75); }

/* ---- 结尾 ---- */
.end { position: absolute; inset: 0; background: var(--paper); padding: 40px 70px; font-family: var(--serif); font-size: calc(var(--fs) - 5px); line-height: 1.65; overflow: auto; }
.end h2 { margin: 0 0 18px; font-size: 30px; letter-spacing: .06em; }
.end .cols { display: grid; grid-template-columns: 1.15fr .9fr 1.1fr; gap: 28px; }
.end section { border-top: 3px solid var(--ink); padding-top: 10px; }
.end h3 { margin: 0 0 6px; font-size: 19px; color: var(--seadeep); }
.end ul { margin: 0; padding-left: 1.2em; }
.end li b { margin-right: 8px; color: var(--warn); }
.end p { margin: 6px 0; }
.end .note { color: var(--softink); font-size: .9em; }
.end .ask { margin: 24px 0 8px; font-size: 26px; text-align: center; color: var(--warn); }
.end .meta, .end .status { text-align: center; color: var(--softink); font-size: 14px; font-family: var(--sans); margin: 4px 0; }
.end .btns { display: flex; gap: 14px; justify-content: center; margin-top: 16px; }

/* ---- 梦 ---- */
#stage.dream #scene > svg { filter: hue-rotate(205deg) saturate(1.5) brightness(.58) contrast(1.1); animation: sway 7s ease-in-out infinite; transform-origin: 50% 70%; }
@keyframes sway { 0%, 100% { transform: scale(1.04) rotate(-.5deg); } 50% { transform: scale(1.04) rotate(.5deg) translateX(6px); } }
#stage.dream.calm #scene > svg { animation: none; transform: scale(1.04); }
#bird { transform: translate(640px, 506px); }
#bird.fly { transform: translate(410px, 300px) scale(1.5); transition: transform 3s ease-out; }
.calm #bird.fly { transition: none; }
#watch { position: absolute; right: 110px; top: 80px; text-align: center; color: #efe6d2; filter: drop-shadow(0 0 18px rgba(170, 140, 220, .7)); animation: flick 1.4s steps(1) 2; }
#watch b { display: block; font-family: Georgia, serif; font-size: 34px; letter-spacing: .1em; margin-top: 6px; }
@keyframes flick { 0%, 30%, 60% { opacity: .25; } 15%, 45%, 100% { opacity: 1; } }
.calm #watch { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .hs-dot, #dlgNext { animation: none; }
}
