/* 古诗影游课 · 电影化界面 */
/* 手机上大多没有楷体：带一份只含课程用字的霞鹜文楷（scripts/make-font.py 生成），电脑上有楷体时不会下载它 */
@font-face { font-family: "Yingyou Kai"; src: url("fonts/wenkai.woff2") format("woff2"); font-display: swap; }
:root {
  --ink: #0b0907;
  --ink-2: rgba(22, 16, 11, 0.78);
  --paper: #ecdfc6;
  --paper-dim: rgba(236, 223, 198, 0.72);
  --gold: #c9a36a;
  --gold-dim: rgba(201, 163, 106, 0.45);
  --cinnabar: #b8432c;
  --jade: #7fa38a;
  --line: rgba(201, 163, 106, 0.35);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --brush: "Ma Shan Zheng", "STXingkai", "华文行楷", "KaiTi", "STKaiti", "楷体", "Yingyou Kai", var(--serif);
  --gutter: max(16px, env(safe-area-inset-left));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--paper); font-family: var(--serif); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
canvas#gl, canvas#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
canvas#fx { pointer-events: none; mix-blend-mode: screen; }
canvas#actors { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; pointer-events: none; }

/* 暗角、颗粒、电影遮幅 */
#veil { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.55) 100%); }
#veil .grain { position: absolute; inset: -50%; opacity: .07; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"); animation: grain 1.2s steps(6) infinite; }
@keyframes grain { 0%{transform:translate(0,0)} 20%{transform:translate(-4%,3%)} 40%{transform:translate(3%,-5%)} 60%{transform:translate(-2%,4%)} 80%{transform:translate(5%,1%)} 100%{transform:translate(0,0)} }
#veil .bars::before, #veil .bars::after { content: ""; position: absolute; left: 0; right: 0; height: 5vh; background: linear-gradient(var(--ink), rgba(11,9,7,0)); }
#veil .bars::before { top: 0; }
#veil .bars::after { bottom: 0; transform: scaleY(-1); }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: none; }
#ui button, #ui input, #ui .card, #ui .popover, #ui .shade, #ui .tray { pointer-events: auto; }
.layer-hotspots, .layer-poem, .layer-title, .layer-dialog, .layer-actions, .layer-panel, .layer-toast { position: absolute; inset: 0; }
#ui > .layer-hotspots.lookable { pointer-events: auto; touch-action: none; }

/* ———— 顶部栏 ———— */
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 16px; padding: max(12px, env(safe-area-inset-top)) var(--gutter) 0; z-index: 5; }
.hud .brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.hud .b-title { font-family: var(--brush); font-size: 24px; color: var(--paper); letter-spacing: .08em; }
.hud .b-author { font-size: 13px; color: var(--paper-dim); white-space: nowrap; }
.hud .tabs { margin-left: auto; display: flex; gap: 2px; background: rgba(0,0,0,.28); border: 1px solid var(--line); border-radius: 999px; padding: 3px; backdrop-filter: blur(6px); }
.hud .tab { pointer-events: auto; border: 0; background: none; padding: 5px 12px; font-size: 13px; color: var(--paper-dim); border-radius: 999px; transition: .3s; }
.hud .tab.on { background: var(--gold); color: var(--ink); }
.hud .tools { display: flex; gap: 6px; }
.hud .tool { pointer-events: auto; border: 1px solid var(--line); background: rgba(0,0,0,.28); padding: 5px 11px; border-radius: 999px; font-size: 13px; color: var(--paper-dim); backdrop-filter: blur(6px); }
.hud .tool.off { color: var(--cinnabar); }
.hud .tool:hover, .hud .tab:hover:not(.on) { color: var(--paper); }
/* 电脑上「目录」按钮不出现，菜单里的章节、工具照常排在顶栏；手机上见文末「手机紧凑版」 */
.hud-toggle { display: none; }
.hud-menu { display: contents; }

/* ———— 开场 ———— */
.start { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: radial-gradient(ellipse at 50% 60%, rgba(60,36,20,.85), var(--ink) 70%); opacity: 0; transition: opacity 1.2s; padding: 0 var(--gutter); text-align: center; }
.start.in { opacity: 1; }
.start.out { opacity: 0; pointer-events: none; }
.s-seal { font-family: var(--brush); color: var(--cinnabar); border: 2px solid var(--cinnabar); padding: 4px 8px; font-size: 18px; letter-spacing: .2em; transform: rotate(-4deg); }
.s-title { font-family: var(--brush); font-size: clamp(38px, 11vw, 132px); white-space: nowrap; letter-spacing: .12em; color: var(--paper); text-shadow: 0 0 40px rgba(201,163,106,.35); }
.s-author { color: var(--gold); letter-spacing: .4em; font-size: 16px; }
.s-sub { color: var(--paper-dim); font-size: 15px; margin-top: 6px; }
.s-btns { display: flex; gap: 12px; margin-top: 26px; flex-wrap: wrap; justify-content: center; }
.s-go { border: 1px solid var(--gold); background: transparent; padding: 12px 34px; border-radius: 999px; letter-spacing: .3em; font-size: 16px; transition: .3s; }
.s-go.primary { background: var(--gold); color: var(--ink); }
.s-go:hover { box-shadow: 0 0 24px rgba(201,163,106,.45); }
/* 手机竖屏提示：一部小手机慢慢转成横的 */
.rotate { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 0 var(--gutter); text-align: center; background: rgba(11, 9, 7, .9); opacity: 0; transition: opacity .5s; }
.rotate.in { opacity: 1; }
.r-phone { width: 44px; height: 76px; border: 2px solid var(--gold); border-radius: 9px; position: relative; margin-bottom: 18px; animation: r-turn 2.6s ease-in-out infinite; }
.r-phone i { position: absolute; left: 50%; bottom: 5px; width: 10px; height: 2px; margin-left: -5px; background: var(--gold); border-radius: 2px; }
@keyframes r-turn { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.r-text { font-family: var(--brush); font-size: 34px; letter-spacing: .16em; color: var(--paper); }
.r-sub { color: var(--paper-dim); font-size: 14px; letter-spacing: .08em; }
.r-skip { margin-top: 22px; border: 1px solid var(--gold-dim); background: transparent; color: var(--paper-dim); padding: 8px 22px; border-radius: 999px; font-size: 13px; letter-spacing: .2em; }
.s-hint { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); color: rgba(236,223,198,.45); font-size: 12px; letter-spacing: .2em; }

/* ———— 章节标题 ———— */
.titlecard { position: absolute; left: 7vw; top: 50%; transform: translateY(-40%); opacity: 0; transition: opacity 1s, transform 1.6s cubic-bezier(.2,.7,.2,1); }
.titlecard.in { opacity: 1; transform: translateY(-50%); }
.titlecard.out { opacity: 0; transform: translateY(-56%); transition-duration: .8s; }
.t-index { color: var(--gold); letter-spacing: .5em; font-size: 15px; }
.t-name { font-family: var(--brush); font-size: clamp(56px, 9vw, 120px); letter-spacing: .14em; line-height: 1.2; text-shadow: 0 4px 30px rgba(0,0,0,.7); }
.t-meta { color: var(--paper-dim); font-size: 14px; letter-spacing: .2em; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px; display: inline-block; }

/* ———— 对白框 ———— */
.dialog { position: absolute; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); width: min(860px, calc(100vw - 32px)); background: linear-gradient(180deg, rgba(28,20,14,.86), rgba(16,12,9,.92)); border: 1px solid var(--line); border-radius: 6px; padding: 18px 24px 16px; opacity: 0; transition: .5s; backdrop-filter: blur(8px); box-shadow: 0 20px 60px rgba(0,0,0,.5); pointer-events: auto; }
.dialog.in { opacity: 1; transform: translate(-50%, 0); }
.dialog .speaker { color: var(--gold); font-size: 15px; letter-spacing: .2em; margin-bottom: 6px; min-height: 1em; }
.dialog .text { font-size: clamp(16px, 2vw, 20px); line-height: 1.8; min-height: 1.8em; }
.dialog .text b, .card b { color: #f0c27a; font-weight: 600; }
.dialog .next { position: absolute; right: 16px; bottom: 12px; border: 1px solid var(--gold-dim); background: rgba(0,0,0,.25); padding: 5px 16px; border-radius: 4px; font-size: 14px; color: var(--paper); }
.dialog .next:hover { border-color: var(--gold); }
.dialog .opts { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.dialog .opts:empty { display: none; }
.opt { text-align: left; border: 1px solid var(--line); background: rgba(255,255,255,.03); padding: 10px 14px; border-radius: 4px; font-size: 16px; display: flex; gap: 12px; align-items: center; transition: .25s; }
.opt .k { color: var(--gold); font-size: 13px; width: 20px; height: 20px; border: 1px solid var(--gold-dim); border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.opt:hover:not(:disabled) { background: rgba(201,163,106,.12); border-color: var(--gold); }
.opt.right { border-color: var(--jade); background: rgba(127,163,138,.2); }
.opt.wrong { border-color: var(--cinnabar); opacity: .55; text-decoration: line-through; }
.dialog:has(.opts:not(:empty)) .next[hidden] { display: none; }
.dialog .next[hidden] { display: none; }

/* ———— 底部动作按钮 ———— */
.actionbar { position: absolute; right: var(--gutter); bottom: max(28px, env(safe-area-inset-bottom)); display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 32px); }
.layer-dialog:has(.dialog) ~ .layer-actions .actionbar { bottom: auto; top: 70px; }
.act { border: 1px solid var(--gold-dim); background: rgba(16,12,9,.7); padding: 9px 20px; border-radius: 999px; font-size: 15px; letter-spacing: .08em; backdrop-filter: blur(6px); transition: .25s; }
.act:hover { border-color: var(--gold); }
.act.primary { background: var(--gold); color: var(--ink); border-color: var(--gold); }

/* ———— 诗句：竖排毛笔字 ———— */
.poemline { position: absolute; right: 9vw; top: 50%; transform: translateY(-50%); display: flex; flex-direction: row-reverse; gap: 18px; align-items: flex-start; }
.p-label { writing-mode: vertical-rl; color: var(--gold); font-size: 14px; letter-spacing: .4em; border-left: 1px solid var(--line); padding-left: 8px; opacity: 0; transition: opacity 1s; }
/* 字号按屏高和字数一起算：短句用大字，长句自动缩小，竖排一列占屏高不超过约六成；再长就折成第二列 */
.p-text { writing-mode: vertical-rl; font-family: var(--brush); font-size: max(24px, min(clamp(44px, 7.5vh, 84px), calc(62vh / (var(--n, 7) * 1.12)))); max-height: 66vh; line-height: 1.1; letter-spacing: .12em; text-shadow: 0 0 20px rgba(0,0,0,.85), 0 2px 6px rgba(0,0,0,.9); }
.p-text span { display: inline-block; opacity: 0; filter: blur(8px); transform: translateY(-10px); transition: opacity 1.1s, filter 1.1s, transform 1.1s; }
.p-text .punct { font-size: .6em; }.poemline.in .p-text span, .poemline.in .p-label { opacity: 1; filter: none; transform: none; }
.poemline.out { opacity: 0; transition: opacity .6s; }

/* ———— 热点 ———— */
.hotspot { position: absolute; left: 0; top: 0; width: 0; height: 0; border: 0; background: none; padding: 0; pointer-events: auto; }
.hotspot .ring { position: absolute; left: -14px; top: -14px; width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid rgba(255,220,160,.9); box-shadow: 0 0 18px rgba(255,190,110,.8), inset 0 0 10px rgba(255,200,130,.5); animation: pulse 2.2s ease-in-out infinite; }
.hotspot .ring::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: #ffe0a8; }
.hotspot .hs-label { position: absolute; left: 22px; top: -12px; white-space: nowrap; font-size: 15px; letter-spacing: .15em; color: var(--paper); text-shadow: 0 1px 6px #000, 0 0 12px #000; padding: 2px 4px; }
.hotspot:hover .ring { transform: scale(1.25); }
.hotspot.flip .hs-label { left: auto; right: 22px; }
.hs-line .hs-label { font-family: var(--brush); font-size: 22px; }
.hs-line.visited .ring { border-color: var(--gold); }
.hs-line.visited .ring::after { background: var(--gold); }
.hs-map .hs-label { font-family: var(--brush); font-size: 26px; }
.hs-map.visited .ring { opacity: .55; }
.hs-word .ring { width: 22px; height: 22px; left: -11px; top: -11px; }
.hs-word .ring::after { inset: 7px; }
.hs-word .hs-label { background: rgba(16,12,9,.62); border: 1px solid var(--line); border-radius: 3px; font-family: var(--brush); font-size: 21px; letter-spacing: .12em; padding: 1px 8px; top: -16px; }
.hs-word:hover .hs-label { border-color: var(--gold); }
/* 读到这个词：光圈先放大一下，字从旁边浮现 */
.hs-word.lit .ring { animation: burst 1s ease-out, pulse 2.2s ease-in-out 1s infinite; }
.hs-word.lit .hs-label { animation: wordIn .7s ease-out; }
.hs-word.seen .ring { border-color: var(--gold); }
.hs-word.seen .ring::after { background: var(--gold); }
@keyframes burst { 0% { transform: scale(.3); } 35% { transform: scale(2.4); box-shadow: 0 0 46px rgba(255,200,120,1); } 100% { transform: scale(1); } }
@keyframes wordIn { from { opacity: 0; transform: translateX(-8px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
.hotspot.faint { opacity: 0 !important; pointer-events: none; }
/* 可点的道具：不写字，只有一圈若隐若现的光，点击范围比看到的大 */
.hs-prop .ring { width: 54px; height: 54px; left: -27px; top: -27px; border: 1px dashed rgba(255,230,190,.45); box-shadow: 0 0 14px rgba(255,200,130,.35); animation: twinkle 2.6s ease-in-out infinite; }
.hs-prop .ring::after { inset: 23px; background: rgba(255,235,200,.55); }
.hs-prop:hover .ring { border-style: solid; border-color: rgba(255,230,190,.9); opacity: 1; }
.hs-collect.faint { opacity: 1 !important; pointer-events: auto; }
/* 第三幕拾词：藏在画里的微光，慢慢柔和地明暗呼吸，不抢画面 */
.hs-collect .ring { border: 1.5px solid rgba(255,236,200,.7); box-shadow: 0 0 12px rgba(255,200,130,.45), inset 0 0 6px rgba(255,214,150,.35); animation: glimmer 3.6s ease-in-out infinite; }
.hs-collect .ring::after { inset: 10px; background: rgba(255,236,205,.85); box-shadow: 0 0 6px rgba(255,230,190,.7); }
.hs-collect:hover .ring { animation: none; opacity: 1; transform: scale(1.15); }
.hs-collect .hs-label { opacity: 0; transition: .5s; font-family: var(--brush); font-size: 24px; }
.hs-collect.got .hs-label { opacity: 1; }
.hs-collect.got .ring { border-color: var(--gold); box-shadow: 0 0 16px rgba(255,190,110,.7); animation: none; opacity: 1; }
.hs-collect.got .ring::after { background: var(--gold); }
.hs-collect.hint .ring { border-color: #ffe0a8; box-shadow: 0 0 26px rgba(255,200,130,1); opacity: 1; animation: none; transition: opacity .6s, box-shadow .6s; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.35); opacity: .55; } }
@keyframes glimmer { 0%,100% { opacity: .38; transform: scale(.96); } 50% { opacity: .85; transform: scale(1.04); } }
@keyframes twinkle { 0%,100% { opacity: .35; } 50% { opacity: .8; } }

.popover { position: absolute; width: 280px; background: linear-gradient(180deg, #2a1f15, #18120c); border: 1px solid var(--gold-dim); border-radius: 6px; padding: 14px 16px; box-shadow: 0 16px 40px rgba(0,0,0,.6); opacity: 0; transform: translateY(6px); transition: .3s; z-index: 3; }
.popover.in { opacity: 1; transform: none; }
.pv-word { font-family: var(--brush); font-size: 34px; letter-spacing: .1em; }
.pv-pinyin { color: var(--gold); font-size: 14px; letter-spacing: .1em; margin: 2px 0 8px; }
.pv-meaning { font-size: 15px; line-height: 1.7; color: var(--paper); }
.popover { width: min(320px, calc(100vw - 24px)); max-height: calc(100vh - 80px); overflow-y: auto; }
.pv-head { display: flex; align-items: baseline; gap: 10px; }
.pv-tag { font-size: 12px; color: var(--gold); border: 1px solid var(--gold-dim); border-radius: 3px; padding: 0 6px; }
.pv-pinyin { display: flex; align-items: center; gap: 10px; }
.pv-say { font: inherit; font-size: 12px; color: var(--paper); background: rgba(255,255,255,.06); border: 1px solid var(--gold-dim); border-radius: 12px; padding: 1px 10px; cursor: pointer; }
.pv-say:hover { border-color: var(--gold); }
.pv-sec { margin: 12px 0 4px; font-size: 12px; letter-spacing: .2em; color: var(--gold); }
.pv-more { font-size: 14px; line-height: 1.75; color: var(--paper); opacity: .92; }
.pv-fig { margin: 10px 0 0; }
.pv-fig img { display: block; width: 100%; height: 120px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.pv-fig figcaption { font-size: 12px; line-height: 1.6; opacity: .7; margin-top: 4px; }

/* ———— 卷轴卡片与面板 ———— */
.shade { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(5,4,3,.45); opacity: 0; transition: opacity .35s; padding: 64px var(--gutter) 24px; }
.shade.in { opacity: 1; }
.card { position: relative; width: min(620px, 100%); max-height: 100%; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; background: linear-gradient(180deg, #efe3c8, #e2d2b0); color: #2a1e14; border-radius: 4px; padding: 30px 34px 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 0 60px rgba(120,80,40,.18); transform: translateY(14px) scale(.98); transition: transform .45s cubic-bezier(.2,.7,.2,1); }
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 8px; background: linear-gradient(#6b4a2c, #3d2918); }
.card { border-bottom: 8px solid #3d2918; }
.shade.in .card { transform: none; }
.card.has-img, .card.wide { width: min(940px, 100%); }
.card-inner { display: flex; gap: 26px; align-items: flex-start; }
.card-text { flex: 1 1 320px; min-width: 0; }
.c-title { font-family: var(--brush); font-size: 38px; letter-spacing: .1em; color: #2a1e14; }
.c-sub { color: #8a5a2e; font-size: 14px; letter-spacing: .1em; margin: 4px 0 10px; border-bottom: 1px solid rgba(120,80,40,.3); padding-bottom: 10px; }
.c-body p { font-size: 17px; line-height: 1.9; margin: 0 0 10px; }
.card b { color: var(--cinnabar); }
.c-note { font-size: 13px; color: #7b6650; border-left: 3px solid rgba(184,67,44,.5); padding-left: 10px; margin-top: 8px; }
.card figure { flex: 1 1 360px; margin: 0; }
.card figure img { width: 100%; max-height: 48vh; object-fit: contain; display: block; border: 1px solid rgba(120,80,40,.35); background: #d8c7a3; }
.card figcaption { font-size: 13px; color: #6b5641; margin-top: 6px; line-height: 1.6; }
.c-close { display: block; margin: 16px 0 0 auto; border: 1px solid #8a5a2e; background: #2a1e14; color: var(--paper); padding: 8px 22px; border-radius: 999px; letter-spacing: .1em; }
.hl-poem { display: block; font-family: var(--brush); font-size: clamp(26px, 3.4vw, 40px); letter-spacing: .08em; line-height: 1.6; color: #3a2a1c; }
.hl-poem em { font-style: normal; color: var(--cinnabar); text-shadow: 0 0 1px var(--cinnabar); }

/* ———— 收集栏 ———— */
.tray { position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 8px; padding: 10px 14px; background: rgba(16,12,9,.75); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(6px); max-width: calc(100vw - 32px); flex-wrap: wrap; justify-content: center; }
.chip { border: 1px solid var(--gold-dim); background: rgba(255,255,255,.04); color: var(--paper); padding: 6px 12px; border-radius: 4px; font-family: var(--brush); font-size: 22px; min-width: 56px; text-align: center; touch-action: none; }
.chip.empty { color: rgba(236,223,198,.3); font-family: var(--serif); font-size: 16px; }
.chip.pop { animation: pop .5s; border-color: var(--gold); }
.chip.sel { background: var(--gold); color: var(--ink); }
.chip.bad { border-color: var(--cinnabar); animation: shake .4s; }
.chip.good { border-color: var(--jade); }
.chip.ghost { position: fixed; z-index: 99; pointer-events: none; transform: translate(-50%, -50%); background: var(--gold); color: var(--ink); }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.2); } 100% { transform: none; } }
@keyframes shake { 0%,100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ———— 分组 ———— */
.sorter { width: min(820px, 100%); background: linear-gradient(180deg, rgba(30,22,15,.95), rgba(18,13,9,.97)); border: 1px solid var(--line); border-radius: 8px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.s-prompt { font-size: 20px; margin-bottom: 14px; }
.s-prompt small { display: block; font-size: 13px; color: var(--paper-dim); margin-top: 4px; }
.s-pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; padding: 8px; border: 1px dashed var(--line); border-radius: 6px; margin-bottom: 14px; }
.s-bins { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bin { border: 1px solid var(--line); border-radius: 6px; min-height: 150px; padding: 10px; background: rgba(255,255,255,.02); }
.bin-name { font-family: var(--brush); font-size: 26px; color: var(--gold); margin-bottom: 8px; }
.bin-body { display: flex; flex-wrap: wrap; gap: 8px; }
.s-foot { display: flex; justify-content: flex-end; margin-top: 14px; }

/* ———— 蒙太奇大字 ———— */
.flashword { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(1.4); font-family: var(--brush); font-size: clamp(90px, 18vh, 200px); letter-spacing: .1em; text-shadow: 0 0 40px rgba(0,0,0,.9); opacity: 0; transition: opacity .18s, transform .6s; }
.flashword.in { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.flashword.out { opacity: 0; }

/* ———— 终章长卷 ———— */
.scroll-shade { align-items: stretch; padding-top: 70px; background: rgba(5,4,3,.2); }
.scroll { width: 100%; display: flex; flex-direction: column; gap: 14px; }
.sc-intro { text-align: center; color: var(--paper-dim); letter-spacing: .15em; font-size: 15px; }
.sc-row { display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 6px 30vw; scrollbar-width: none; flex: 1 1 auto; min-height: 0; align-items: center; }
.sc-row::-webkit-scrollbar { display: none; }
.pane { position: relative; flex: none; height: min(42vh, 46vw * .5625); aspect-ratio: 16 / 9; scroll-snap-align: center; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; filter: grayscale(1) brightness(.55) contrast(.9); transition: filter 2.4s, transform .6s, box-shadow .6s; }
.pane img, .pane video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pane video { opacity: 0; transition: opacity 1.5s; }
.pane.alive { filter: none; }
.pane.alive video { opacity: 1; }
.pane.current { transform: scale(1.04); box-shadow: 0 0 0 2px var(--gold), 0 20px 60px rgba(0,0,0,.6); }
.pane-text { position: absolute; right: 10px; top: 10px; bottom: 10px; writing-mode: vertical-rl; font-family: var(--brush); font-size: clamp(22px, 3.4vh, 36px); letter-spacing: .1em; text-shadow: 0 0 10px #000, 0 0 3px #000; color: var(--paper); }
.sc-input { width: min(760px, 100%); margin: 0 auto; background: rgba(16,12,9,.86); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; backdrop-filter: blur(8px); }
.rc-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.rc-no { font-family: var(--brush); font-size: 24px; color: var(--gold); }
.rc-modes { margin-left: auto; display: flex; gap: 4px; }
.rc-mode { border: 1px solid var(--line); background: none; padding: 4px 12px; border-radius: 999px; font-size: 13px; color: var(--paper-dim); }
.rc-mode.on { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.rc-mode.disabled { opacity: .35; }
.rc-slots { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.slot { width: 52px; height: 52px; border-bottom: 2px solid var(--gold-dim); font-family: var(--brush); font-size: 38px; display: flex; align-items: center; justify-content: center; }
.rc-pool { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.tile { width: 54px; height: 54px; border: 1px solid var(--gold-dim); background: rgba(255,255,255,.04); border-radius: 6px; font-family: var(--brush); font-size: 30px; transition: .2s; }
.tile:disabled { opacity: .2; }
.tile.shake { animation: shake .4s; border-color: var(--cinnabar); }
.rc-type { display: flex; gap: 10px; }
.rc-in { flex: 1; min-width: 0; background: rgba(255,255,255,.06); border: 1px solid var(--gold-dim); border-radius: 6px; padding: 10px 14px; color: var(--paper); font-family: var(--brush); font-size: 26px; letter-spacing: .15em; outline: none; user-select: text; -webkit-user-select: text; }
.rc-in:focus { border-color: var(--gold); }
.rc-diff { margin-top: 10px; font-family: var(--brush); font-size: 26px; letter-spacing: .15em; min-height: 1em; text-align: center; }
.rc-diff .ok { color: var(--jade); } .rc-diff .bad { color: var(--cinnabar); text-decoration: underline; }
.rc-voice { text-align: center; }
.rc-heard { margin-top: 10px; color: var(--paper-dim); min-height: 1.4em; }
.rc-body.ok { animation: pop .5s; }
.sc-done { text-align: center; font-family: var(--brush); font-size: 32px; color: var(--gold); }
.sc-report { display: block; margin: 12px auto 0; }

/* ———— 报告 ———— */
.report { width: min(760px, 100%); max-height: 100%; overflow: auto; background: linear-gradient(180deg, rgba(30,22,15,.96), rgba(18,13,9,.98)); border: 1px solid var(--line); border-radius: 8px; padding: 24px 26px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.r-title { font-family: var(--brush); font-size: 34px; color: var(--gold); margin-bottom: 14px; }
.r-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.r-cell { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; font-size: 14px; }
.r-k { color: var(--paper-dim); margin-bottom: 4px; }
.r-v { color: var(--paper-dim); font-size: 13px; margin-top: 4px; line-height: 1.6; }
.report .ok { color: var(--jade); } .report .no { color: rgba(236,223,198,.4); } .report .warn { color: #e0a060; }
.r-sub { margin: 18px 0 8px; color: var(--gold); letter-spacing: .1em; }
.r-lines { list-style: none; padding: 0; margin: 0; }
.r-lines li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(201,163,106,.15); }
.r-line { font-family: var(--brush); font-size: 24px; flex: 1; }
.r-back { padding: 4px 14px; font-size: 13px; }
.r-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast { position: absolute; left: 50%; top: 70px; transform: translate(-50%, -8px); background: rgba(16,12,9,.88); border: 1px solid var(--gold-dim); padding: 8px 18px; border-radius: 999px; font-size: 14px; opacity: 0; transition: .35s; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
.toast.in { opacity: 1; transform: translate(-50%, 0); }
/* 环顾提示前的小光标：在一段虚线上左右来回晃，提示往两边移动；手机上换成指尖圆点 */
.toast .cue { display: inline-block; position: relative; width: 38px; height: 16px; margin-right: 10px; vertical-align: -3px; }
.toast .cue::before { content: ''; position: absolute; left: 2px; right: 2px; top: 50%; border-top: 1px dashed var(--gold-dim); }
.toast .cue i { position: absolute; top: 0; left: 0; width: 11px; height: 16px; background: var(--gold); clip-path: polygon(0 0, 100% 68%, 55% 70%, 75% 100%, 58% 100%, 40% 74%, 0 100%); animation: cue-sway 1.6s ease-in-out infinite alternate; }
.toast .cue.touch i { top: 3px; width: 10px; height: 10px; border-radius: 50%; clip-path: none; box-shadow: 0 0 0 3px var(--gold-dim); }
@keyframes cue-sway { from { transform: translateX(0); } to { transform: translateX(27px); } }
.fatal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--paper); background: var(--ink); line-height: 2; z-index: 50; padding: 0 var(--gutter); }

/* ———— 竖屏 / 小屏 ———— */
@media (max-width: 760px), (orientation: portrait) {
  .hud { flex-wrap: wrap; gap: 8px; }
  .hud .b-author { display: none; }
  .hud .tabs { order: 3; margin-left: 0; width: 100%; justify-content: space-between; }
  .hud .tab { padding: 5px 8px; }
  .hud .tools { margin-left: auto; }
  .hud .tool { padding: 4px 9px; font-size: 12px; }
  .titlecard { left: var(--gutter); right: var(--gutter); }
  .poemline { right: 6vw; top: 44%; }
  .p-text { font-size: max(22px, min(clamp(36px, 6vh, 60px), calc(58vh / (var(--n, 7) * 1.12)))); }
  .dialog { padding: 14px 16px 14px; }
  .dialog .next { position: static; display: block; margin: 8px 0 0 auto; }
  .actionbar { left: var(--gutter); right: var(--gutter); justify-content: center; }
  .layer-dialog:has(.dialog) ~ .layer-actions .actionbar { top: 110px; }
  .card { padding: 24px 20px 18px; }
  .card-inner { flex-direction: column; }
  .card figure { width: 100%; flex: none; }
  .c-title { font-size: 30px; }
  .c-body p { font-size: 16px; }
  .s-bins { grid-template-columns: 1fr; }
  .bin { min-height: 90px; }
  .sc-row { padding: 6px 12vw; }
  .pane { height: auto; width: 76vw; }
  .slot { width: 40px; height: 44px; font-size: 30px; }
  .tile { width: 46px; height: 46px; font-size: 26px; }
  .toast { top: 110px; }
  .shade { padding-top: 110px; }
}

/* ———— 手机紧凑版：横屏手机（矮）和竖屏手机（窄） ————
   顶栏只留诗名和一个「目录」按钮，章节和声音 / 全屏 / 重来收进下拉菜单；
   对白框、按钮、收集栏、背诵面板、报告都按手机尺寸缩小，尽量少挡画面，按钮仍保持手指好点的大小（≥32px） */
@media (max-height: 520px), (max-width: 760px) {
  .hud { flex-wrap: nowrap; gap: 10px; padding-top: max(8px, env(safe-area-inset-top)); align-items: center; }
  .hud .brand { flex: 1; }
  .hud .b-title { font-size: 18px; white-space: nowrap; text-shadow: 0 1px 8px rgba(0,0,0,.8); }
  .hud .b-author { display: none; }
  .hud-toggle { display: inline-flex; align-items: center; gap: 6px; pointer-events: auto; margin-left: auto; height: 32px; padding: 0 12px 0 10px; border: 1px solid var(--line); border-radius: 999px; background: rgba(0,0,0,.35); backdrop-filter: blur(6px); font-size: 13px; color: var(--paper-dim); }
  .hud-toggle i { position: relative; width: 14px; height: 2px; background: currentColor; border-radius: 1px; }
  .hud-toggle i::before, .hud-toggle i::after { content: ''; position: absolute; left: 0; width: 14px; height: 2px; background: currentColor; border-radius: 1px; transition: .25s; }
  .hud-toggle i::before { top: -5px; } .hud-toggle i::after { top: 5px; }
  .hud.open .hud-toggle { color: var(--ink); background: var(--gold); border-color: var(--gold); }
  .hud.open .hud-toggle i { background: transparent; }
  .hud.open .hud-toggle i::before { top: 0; transform: rotate(45deg); } .hud.open .hud-toggle i::after { top: 0; transform: rotate(-45deg); }
  .hud-menu { display: flex; flex-direction: column; gap: 10px; position: absolute; top: calc(max(8px, env(safe-area-inset-top)) + 40px); right: var(--gutter); padding: 10px; background: rgba(16,12,9,.94); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.6); backdrop-filter: blur(8px); opacity: 0; transform: translateY(-6px); visibility: hidden; transition: .2s; }
  .hud.open .hud-menu { opacity: 1; transform: none; visibility: visible; }
  .hud .tabs { order: 0; margin: 0; width: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: none; border: 0; padding: 0; backdrop-filter: none; }
  .hud .tab { padding: 7px 12px; font-size: 13px; white-space: nowrap; border: 1px solid transparent; }
  .hud .tab:not(.on) { border-color: rgba(201,163,106,.15); }
  .hud .tools { margin: 0; justify-content: space-between; border-top: 1px solid rgba(201,163,106,.15); padding-top: 10px; }
  .hud .tool { padding: 5px 14px; font-size: 12px; white-space: nowrap; }

  .t-index { font-size: 12px; } .t-name { font-size: clamp(38px, 12vh, 72px); } .t-meta { font-size: 12px; padding-top: 6px; }
  .poemline { gap: 12px; } .p-text { font-size: max(18px, min(clamp(22px, 6.5vh, 40px), calc(54vh / (var(--n, 7) * 1.12)))); max-height: 62vh; } .p-label { font-size: 12px; }

  .dialog { width: min(720px, calc(100vw - 24px)); bottom: max(10px, env(safe-area-inset-bottom)); padding: 9px 14px 9px; border-radius: 8px; }
  .dialog .speaker { font-size: 12px; margin-bottom: 2px; }
  .dialog .text { font-size: 15px; line-height: 1.6; min-height: 1.6em; padding-right: 76px; }
  .dialog .next { position: absolute; right: 10px; bottom: 8px; margin: 0; padding: 5px 12px; font-size: 13px; }
  .dialog:has(.opts:not(:empty)) .text { padding-right: 0; }
  .dialog .opts { gap: 6px; margin-top: 8px; }
  .opt { padding: 7px 12px; font-size: 14px; }

  .actionbar { left: auto; right: var(--gutter); bottom: max(10px, env(safe-area-inset-bottom)); gap: 8px; justify-content: flex-end; }
  .layer-dialog:has(.dialog) ~ .layer-actions .actionbar { top: 50px; }
  .act { padding: 6px 14px; font-size: 13px; }

  .toast { top: 48px; padding: 6px 14px; font-size: 13px; }
  .hs-line .hs-label { font-size: 18px; } .hs-map .hs-label { font-size: 20px; } .hs-word .hs-label { font-size: 17px; } .hs-collect .hs-label { font-size: 19px; }
  .hotspot .hs-label { font-size: 13px; }

  .shade { padding: 48px var(--gutter) 10px; }
  .card { padding: 18px 20px 14px; }
  .c-title { font-size: 26px; } .c-sub { font-size: 12px; margin-bottom: 8px; padding-bottom: 8px; }
  .c-body p { font-size: 15px; line-height: 1.75; margin-bottom: 6px; }
  .c-close { margin-top: 10px; padding: 6px 18px; }
  .card figure img { max-height: 40vh; }
  /* 卡片上下排列时，文字区不能再按「至少 320px」撑高（那是左右排列时的宽度），否则下面空一大块 */
  .card-inner { flex-direction: column; gap: 12px; }
  .card-text, .card figure { flex: none; width: 100%; }
  .card figcaption { font-size: 12px; margin-top: 4px; }
}
/* 横屏手机：带图的卡片改回左文右图，尽量一屏看完不用滚动 */
@media (max-height: 520px) and (orientation: landscape) {
  .card.has-img { width: 100%; }
  .card-inner { flex-direction: row; gap: 18px; align-items: center; }
  .card-text { flex: 1 1 0; width: auto; }
  .card figure { flex: 0 0 40%; width: auto; }
  .card figure img { max-height: 46vh; }
  .card { padding: 14px 18px 12px; }
  .shade { padding: 44px var(--gutter) 6px; }
  .c-title { font-size: 23px; }
  .c-sub { margin-bottom: 6px; padding-bottom: 6px; }
  .c-body p { margin-bottom: 4px; }
  .c-body p { font-size: 14.5px; line-height: 1.7; }
  /* 带图卡片：「收起」放到右栏图片说明下面的空位，不再单独占一行 */
  .card.has-img .card-inner { align-items: flex-start; }
  .card.has-img figure { padding-bottom: 42px; }
  .card.has-img .c-close { position: absolute; right: 18px; bottom: 12px; margin: 0; }

  .tray { bottom: max(8px, env(safe-area-inset-bottom)); gap: 5px; padding: 5px 8px; border-radius: 12px; }
  .chip { font-size: 17px; min-width: 38px; padding: 3px 7px; }
  .chip.empty { font-size: 13px; }

  .sorter { max-height: 100%; overflow-y: auto; padding: 12px 14px; }
  .s-prompt { font-size: 16px; margin-bottom: 8px; } .s-prompt small { font-size: 12px; }
  .s-pool { min-height: 40px; padding: 6px; gap: 6px; margin-bottom: 8px; }
  .bin { min-height: 64px; padding: 6px 8px; } .bin-name { font-size: 18px; margin-bottom: 4px; } .bin-body { gap: 6px; }
  .s-foot { margin-top: 8px; }

  .scroll-shade { padding-top: 48px; }
  .scroll { gap: 8px; }
  .sc-intro { font-size: 12px; }
  .sc-row { flex: 1 1 0; padding: 4px 30vw; }
  .pane { height: 100%; width: auto; max-height: 34vh; }
  .pane-text { font-size: clamp(16px, 4.6vh, 26px); right: 6px; top: 6px; bottom: 6px; }
  .sc-input { padding: 8px 12px 10px; }
  .rc-head { margin-bottom: 6px; } .rc-no { font-size: 17px; }
  .rc-mode { padding: 3px 10px; font-size: 12px; }
  .rc-slots { gap: 6px; margin-bottom: 8px; }
  .slot { width: 32px; height: 34px; font-size: 24px; }
  .rc-pool { gap: 6px; }
  .tile { width: 38px; height: 38px; font-size: 21px; border-radius: 5px; }
  .rc-in { font-size: 19px; padding: 6px 10px; }
  .rc-diff { font-size: 19px; margin-top: 6px; }
  .sc-done { font-size: 24px; }

  .report { padding: 14px 16px; }
  .r-title { font-size: 22px; margin-bottom: 10px; }
  .r-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
  .r-cell { padding: 8px 10px; font-size: 13px; }
  .r-line { font-size: 19px; }

  .s-seal { font-size: 15px; } .s-author { font-size: 13px; } .s-sub { font-size: 13px; }
  .s-btns { margin-top: 14px; } .s-go { padding: 9px 26px; font-size: 14px; }
  .s-title { font-size: clamp(38px, 15vh, 96px); }
}
/* 竖屏手机：宽度窄，对白框的「继续」放到文字下面 */
@media (max-width: 520px) {
  /* 章节大标题不折行：按屏宽缩小；放到画框下方的空处，不压在画面上 */
  .titlecard { top: 72%; }
  .t-name { font-size: clamp(30px, 12vw, 56px); white-space: nowrap; }
  .t-meta { font-size: 11px; letter-spacing: .1em; }
  /* 诗句改横排，放在画框下方的空处；按字数缩小，太长就折行 */
  .poemline { left: var(--gutter); right: var(--gutter); top: auto; bottom: 22%; transform: none; flex-direction: column; align-items: center; gap: 6px; }
  .p-label { writing-mode: horizontal-tb; border-left: 0; padding-left: 0; letter-spacing: .3em; }
  .p-text { writing-mode: horizontal-tb; text-align: center; max-height: none; font-size: max(20px, min(11vw, calc(86vw / (var(--n, 7) * 1.12)))); }
  .p-text span { transform: translateX(-8px); }
  .tray { left: var(--gutter); right: var(--gutter); transform: none; bottom: max(16px, env(safe-area-inset-bottom)); gap: 5px; padding: 8px; }
  .tray .chip { flex: 0 0 calc(20% - 4px); min-width: 0; padding: 3px 0; }
  .scroll-shade, .shade { padding-top: 58px; }
  .dialog .text { padding-right: 0; }
  .dialog .next { position: static; display: block; margin: 6px 0 0 auto; }
  .actionbar { left: var(--gutter); justify-content: center; }
  .layer-dialog:has(.dialog) ~ .layer-actions .actionbar { top: 50px; }
  .sc-row { padding: 4px 12vw; }
  .pane { height: auto; width: 76vw; max-height: none; }
  .s-bins { grid-template-columns: 1fr; }
}
