:root {
  --ink: #24373a;
  --gold: #d7bf85;
  --paper: #f5ecd8;
  --red: #a44436;
  --scale: 0.5;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background: #090b0a;
  color: var(--ink);
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

#viewport { width: 100vw; height: 100dvh; display: grid; place-items: center; position: relative; overflow: hidden; }
#game {
  position: absolute;
  width: 1080px;
  height: 1920px;
  left: 50%;
  top: 50%;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--scale));
  transform-origin: center;
  background: #efe5ce;
  box-shadow: 0 0 80px #000;
}
#backdrop { position: absolute; inset: 0; width: 1080px; height: 1920px; }

.plaque {
  position: absolute;
  left: 120px;
  top: 78px;
  width: 840px;
  height: 225px;
  filter: drop-shadow(9px 13px 7px #140b0790);
}
/* 牌匾是位图 assets/art/plaque.png（现为 2280×610，自带透明通道），等比摆到 840 宽＝高 225，可见内容高 209。
   left 取 (1080-840)/2＝120 横向居中；top 78 让可见内容落在画布 y 88..297，居中于「画布顶～标题板 top 385」
   这段空白（(385-209)/2＝88，再减掉图顶那 26 px 透明边按 840/2280 折算的 9.6）。
   早先那版 3226×1192 是 720 宽＝高 266、可见到 y 326；现在这张图更矮，所以要摆得更大才填得住这块空白。 */
.plaque-art { position: absolute; left: 0; top: 0; width: 840px; height: auto; }
/* 牌匾文案的可机读文案源：位图读不出文字，所以这里与 <img> 的 alt 各留一份副本，
   供 tools/test_cover_3x4.cjs 抽取牌匾文案，不要删改结构。 */
.plaque-inner { display: none; }

/* 标题不画任何底框：深绿底 + 金边那版太生硬，去掉后直接用墨色字压在木墙上，
   靠 text-shadow 的浅色高光（0 3px 0）+ 轻投影（0 6px 13px）做出「刻在墙上」的浮雕感。
   墙面实测约 RGB(200,170,120)，墨色 #24373a 对比度约 5.7:1，比原来的淡金 #ffe8ad（约 1.6:1）清楚得多。
   字号按反馈放大过一档（h1 62→70、p 31→35，约 +13%），阴影偏移同步等比放大以免浮雕变细。
   width/height 只为占位，不与其它元素联动。 */
.title-board {
  position: absolute;
  left: 150px;
  top: 385px;
  width: 780px;
  height: 160px;
  margin: 0;
  color: #24373a;
  text-align: center;
  text-shadow: 0 3px 0 #fbf4e2b3, 0 6px 13px #2b1a0f3d;
}
.title-board h1 { margin: 5px 0 0; font-size: 70px; line-height: 1.28; font-weight: 500; }
.title-board p { margin: 0; font-size: 35px; color: #5c4630; }

.timer-wrap { position: absolute; left: 150px; top: 557px; width: 780px; text-align: center; }
.timer-track { width: 100%; height: 30px; overflow: hidden; background: #d1c3a5; border: 2px solid #aa9872; border-radius: 15px; }
.timer-fill { width: 100%; height: 100%; transform-origin: left; background: #b74b3d; border-radius: inherit; }
#timerText { display: inline-block; margin-top: 2px; min-width: 120px; color: #71362f; font-size: 40px; }

/* 开关声音只是一个纯白图标：没有底色和边框，命中区放大到 112×112（隐形）方便点按，
   两态共用一个 <svg>：开＝喇叭＋两道声波，关＝喇叭＋叉，靠 .is-muted 切组，
   文案退成 aria-label/title（脚本里同步），画面上不再有可见文字。 */
.sound-button {
  position: absolute; top: 30px; right: 10px; width: 112px; height: 112px;
  display: grid; place-items: center; padding: 0;
  color: #f5ecd8; background: none; border: 0; cursor: pointer;
  filter: drop-shadow(0 2px 3px #00000099);
  transition: opacity .15s ease;
}
.sound-button:hover { opacity: .8; }
.sound-button.is-muted { opacity: .55; }
.sound-button.is-muted:hover { opacity: .8; }
.sound-icon { display: block; width: 56px; height: 56px; }
.sound-button.is-muted .sound-on { display: none; }
.sound-button:not(.is-muted) .sound-off { display: none; }

.hud { position: absolute; inset: 645px 0 auto; display: flex; gap: 20px; justify-content: center; }
.hud-slip {
  width: 440px; height: 70px; display: grid; place-items: center;
  color: #34251f; font-family: system-ui, "Microsoft YaHei", sans-serif; font-weight: 650; font-size: 30px;
  background: #f1e3c6eb; border: 2px solid #9d7446; border-radius: 18px; box-shadow: 5px 7px #1a0f0833;
}
.curtain-text { position: absolute; left: 180px; top: 805px; width: 720px; height: 80px; text-align: center; font-size: 52px; color: #f0e3c6; text-shadow: 0 3px 8px #273731; }

.actors { position: absolute; inset: 0; pointer-events: none; }
.actor {
  --slot-x: 95px;
  position: absolute; left: var(--slot-x); top: 975px; width: 270px; height: 440px; padding: 0;
  border: 0; background: transparent; color: var(--ink); pointer-events: none; cursor: default;
  transition-property: left, transform; transition-timing-function: ease-in-out;
}
.actor.selectable { pointer-events: auto; cursor: none; }
.actor.selectable:focus-visible { outline: 7px solid #d9b14c; outline-offset: 3px; border-radius: 22px; }
.actor-body { position: absolute; inset: 0; transform-origin: 50% 402px; animation: breathe 2.45s ease-in-out infinite; }
.actor-canvas { position: absolute; left: -15px; top: 4px; width: 300px; height: 398px; }
.demon-form {
  position: absolute; left: -90px; top: -249px; width: 450px; height: 597px; opacity: 0;
  pointer-events: none; transform-origin: 50% 88%;
}
.contact-shadow { position: absolute; left: 76px; top: 390px; width: 118px; height: 24px; border-radius: 50%; background: #1d1a141f; }
.demon-shadow { position: absolute; left: -30px; top: 388px; width: 330px; height: 420px; opacity: 0; pointer-events: none; transition: opacity .16s ease; }
.actor.revealed.target .demon-shadow { opacity: .94; }
.actor.transforming .demon-shadow, .actor.demon-revealed .demon-shadow { opacity: 0 !important; }
.actor.transforming .contact-shadow, .actor.demon-revealed .contact-shadow { opacity: 0; }
.actor .role-name { position: absolute; top: 420px; left: 0; width: 270px; font-size: 27px; text-align: center; }
.actor.revealed .role-name, .actor.transforming .role-name, .actor.demon-revealed .role-name { opacity: 0; }
.actor.correct::after, .actor.wrong::after { content: ""; position: absolute; left: 57px; top: 330px; width: 150px; height: 44px; border-radius: 50%; border: 6px solid #c69d43aa; }
.actor.wrong::after { border-color: #a9694caa; }
.actor.transforming::after, .actor.demon-revealed::after { display: none; }
.actor.swap-up { transform: translateY(-20px) rotate(3deg); z-index: 8; }
.actor.swap-down { transform: translateY(10px) rotate(-3deg); z-index: 7; }
.actor.hit .actor-body { animation: actor-hit 1.18s both; }
.actor.transforming, .actor.demon-revealed { z-index: 14; }
.actor.transforming .actor-body { animation: fog-swallow .62s cubic-bezier(.4,0,.3,1) both; }
.actor.transforming .actor-canvas { animation: disguise-fade .62s ease-in both; }
.actor.demon-revealed .actor-body { animation: demon-arrive .68s cubic-bezier(.16,.84,.24,1) both; }
.actor.demon-revealed .actor-canvas { opacity: 0; }
.actor.demon-revealed .demon-form {
  animation: demon-materialize .68s cubic-bezier(.12,.86,.2,1) both, demon-hover 1.8s .68s ease-in-out infinite alternate;
  filter: drop-shadow(0 8px 10px #111b) drop-shadow(0 0 16px #8d1e1e99);
}
.demon-fog {
  position: absolute; z-index: 16; left: -95px; top: -72px; width: 460px; height: 510px; opacity: 0;
  pointer-events: none; transform-origin: 50% 82%; mix-blend-mode: multiply; isolation: isolate;
}
.demon-fog::before {
  content: ""; position: absolute; inset: 26px 26px 2px; border-radius: 46%;
  background: radial-gradient(ellipse at 50% 62%, #020404fa 0 25%, #090e0df2 38%, #17201ee3 52%, #2b302bba 64%, transparent 78%);
  filter: blur(17px); transform: scale(.76);
}
.demon-fog::after {
  content: ""; position: absolute; left: 50px; top: 42px; width: 360px; height: 430px; border-radius: 48%; opacity: .86;
  background: radial-gradient(circle at 28% 28%, #0a0d0ce8 0 12%, transparent 34%), radial-gradient(circle at 72% 36%, #050808ed 0 14%, transparent 36%), radial-gradient(ellipse at 50% 76%, #0b100feb 0 24%, transparent 58%);
  filter: blur(13px);
}
.demon-fog i {
  --fog-x: 0px; --fog-y: -24px; --fog-in-x: 0px; --fog-in-y: 64px; --fog-scale: 1.3;
  position: absolute; width: 194px; height: 148px; border-radius: 50%; opacity: 0;
  background: radial-gradient(ellipse at 44% 52%, #010303fb 0 22%, #090d0cf2 40%, #202824dd 59%, transparent 78%);
  filter: blur(12px);
}
.demon-fog i:nth-child(1) { left: -4px; top: 252px; --fog-in-x: -82px; --fog-in-y: 76px; --fog-x: -92px; --fog-y: 38px; --fog-scale: 1.52; animation-delay: 0s; }
.demon-fog i:nth-child(2) { left: 264px; top: 238px; --fog-in-x: 88px; --fog-in-y: 70px; --fog-x: 102px; --fog-y: 28px; --fog-scale: 1.48; animation-delay: -.07s; }
.demon-fog i:nth-child(3) { left: 54px; top: 104px; --fog-in-x: -78px; --fog-in-y: -18px; --fog-x: -76px; --fog-y: -68px; --fog-scale: 1.38; animation-delay: -.13s; }
.demon-fog i:nth-child(4) { left: 214px; top: 66px; --fog-in-x: 74px; --fog-in-y: -28px; --fog-x: 78px; --fog-y: -82px; --fog-scale: 1.42; animation-delay: -.19s; }
.demon-fog i:nth-child(5) { left: 132px; top: 326px; --fog-in-x: -4px; --fog-in-y: 96px; --fog-x: -8px; --fog-y: 88px; --fog-scale: 1.58; animation-delay: -.1s; }
.demon-fog i:nth-child(6) { left: -18px; top: 26px; --fog-in-x: -96px; --fog-in-y: -42px; --fog-x: -108px; --fog-y: -92px; --fog-scale: 1.4; animation-delay: -.23s; }
.demon-fog i:nth-child(7) { left: 292px; top: 132px; --fog-in-x: 104px; --fog-in-y: -8px; --fog-x: 116px; --fog-y: -48px; --fog-scale: 1.44; animation-delay: -.15s; }
.demon-fog i:nth-child(8) { left: 116px; top: 8px; --fog-in-x: -16px; --fog-in-y: -76px; --fog-x: -22px; --fog-y: -112px; --fog-scale: 1.36; animation-delay: -.28s; }
.demon-fog i:nth-child(9) { left: 18px; top: 174px; --fog-in-x: -104px; --fog-in-y: 12px; --fog-x: -118px; --fog-y: -12px; --fog-scale: 1.5; animation-delay: -.17s; }
.demon-fog i:nth-child(10) { left: 246px; top: 12px; --fog-in-x: 92px; --fog-in-y: -68px; --fog-x: 108px; --fog-y: -104px; --fog-scale: 1.34; animation-delay: -.25s; }
.demon-fog i:nth-child(11) { left: 132px; top: 190px; --fog-in-x: 0px; --fog-in-y: 84px; --fog-x: 12px; --fog-y: -36px; --fog-scale: 1.62; animation-delay: -.12s; }
.actor.transforming .demon-fog { animation: fog-gather .7s ease-out both; }
.actor.transforming .demon-fog i { animation-name: fog-bloom; animation-duration: .7s; animation-timing-function: cubic-bezier(.16,.76,.22,1); animation-fill-mode: both; }
.actor.demon-revealed .demon-fog { animation: fog-release .86s ease-out both; }
.actor.demon-revealed .demon-fog i { animation-name: fog-scatter; animation-duration: .86s; animation-timing-function: ease-out; animation-fill-mode: both; }
.actor.demon-revealed::before {
  content: ""; position: absolute; z-index: -1; left: -54px; top: -18px; width: 378px; height: 440px; border-radius: 48%;
  background: radial-gradient(ellipse at center, #7b191f78 0 16%, #172b2875 38%, transparent 70%);
  filter: blur(11px); animation: demon-ink-burst .86s ease-out both; pointer-events: none;
}

.instruction {
  position: absolute; left: 110px; top: 1468px; width: 860px; height: 102px; display: grid; place-items: center;
  color: #f5ecd8; font-size: 36px; text-align: center; background: #24373ae0; border: 2px solid #d7bf85; border-radius: 22px;
  box-shadow: 0 4px 12px #130d0870; transition: top .2s ease;
}
#game.tutorial-mode .instruction { top: 1740px; }
#game.playing .instruction { top: 1798px; }
.start-panel {
  position: absolute; left: 120px; top: 1575px; width: 840px; height: 270px; padding: 27px 40px;
  background: #f5ecd8ed; border: 4px solid #9f684f; border-radius: 28px; text-align: center;
}
.start-panel[hidden] { display: none; }
.start-panel p { margin: 0; font-size: 31px; line-height: 1.5; }
.red-button, .light-button { border-radius: 18px; min-height: 76px; padding: 0 40px; font-size: 32px; cursor: pointer; }
.red-button { color: #f6ead1; background: var(--red); border: 3px solid #71362f; }
.red-button:hover { background: #bd5948; }
.start-panel .red-button { width: 410px; height: 88px; margin-top: 19px; }

.tutorial-skip {
  position: absolute; z-index: 24; right: 92px; top: 742px; min-height: 58px; padding: 0 24px;
  color: #f5ecd8; background: #24373ad9; border: 2px solid #d7bf85; border-radius: 16px;
  font-size: 25px; cursor: pointer; box-shadow: 0 4px 10px #130d0860;
}
.tutorial-skip[hidden] { display: none; }
.tutorial-skip:hover { background: #344d4a; }

.demo-pointer {
  position: absolute; z-index: 26; top: 1282px; width: 160px; height: 70px; display: grid; place-items: center;
  color: #f5ecd8; background: #a44436f2; border: 3px solid #f0d690; border-radius: 35px;
  font-family: system-ui, "Microsoft YaHei", sans-serif; font-size: 27px; font-weight: 700;
  box-shadow: 0 8px 20px #130d0875; pointer-events: none; animation: demo-pointer-bob .72s ease-in-out infinite alternate;
}
.demo-pointer[hidden] { display: none; }
.demo-pointer::after {
  content: ""; position: absolute; left: 65px; bottom: -27px; width: 0; height: 0;
  border-left: 15px solid transparent; border-right: 15px solid transparent; border-top: 28px solid #f0d690;
}
.demo-pointer span { position: relative; z-index: 1; }

.tutorial-panel {
  position: absolute; z-index: 25; left: 120px; top: 1575px; width: 840px; height: 270px; padding: 20px 36px;
  background: #f5ecd8f5; border: 4px solid #9f684f; border-radius: 28px; text-align: center;
  box-shadow: 0 12px 34px #130d0868;
}
.tutorial-panel[hidden] { display: none; }
.tutorial-panel h2 { margin: 0; color: #71362f; font-size: 42px; line-height: 1.2; }
.tutorial-panel p { margin: 7px 0 12px; font-size: 27px; line-height: 1.35; }
.tutorial-actions { display: flex; align-items: center; justify-content: center; gap: 18px; }
.tutorial-panel .light-button { width: 260px; height: 70px; margin: 0; color: #344b49; background: #ded3b9; border: 2px solid #9f684f; font-size: 27px; }
.tutorial-panel .red-button { width: 410px; height: 76px; font-size: 30px; }

.result-panel {
  position: absolute; z-index: 30; left: 100px; top: 600px; width: 880px; height: 790px; padding: 60px 80px;
  text-align: center; background: #f5ecd8fa; border: 6px solid #71362f; border-radius: 32px; box-shadow: 0 18px 60px #0b070690;
}
.result-panel[hidden] { display: none; }
.seal { width: 150px; height: 150px; margin: 0 auto 26px; display: grid; place-items: center; border-radius: 50%; color: #f5ecd8; background: #a94338; font-size: 76px; }
.result-panel h2 { margin: 0; color: #71362f; font-size: 60px; }
.result-panel p { height: 145px; margin: 30px 0; white-space: pre-line; font-size: 32px; line-height: 1.7; }
.result-panel .red-button { width: 560px; height: 92px; }
.result-panel .light-button { display: block; width: 300px; height: 72px; margin: 34px auto 0; color: #344b49; background: #ded3b9; border: 2px solid #9f684f; font-size: 28px; }

.staff { position: absolute; z-index: 50; width: 220px; height: 220px; object-fit: contain; pointer-events: none; opacity: 0; transform: translate(-56px,-56px) rotate(180deg); transform-origin: 56px 56px; filter: drop-shadow(5px 7px 4px #2a160885); }
#game.playing.pointer-fine, #game.playing.pointer-fine * { cursor: none !important; }
#game.playing.pointer-fine .staff { opacity: 1; }
.staff.swinging { opacity: 1 !important; animation: staff-strike .56s cubic-bezier(.2,.8,.3,1) both; }

.impact { position: absolute; z-index: 45; width: 180px; height: 180px; opacity: 0; pointer-events: none; }
.impact.success { background: repeating-conic-gradient(from 0deg,#fff0a6 0deg 4deg,transparent 4deg 49deg); border-radius: 50%; animation: impact .3s ease-out; }
.impact.failure { background: radial-gradient(circle at 45% 45%,#49625d99 0 24%,transparent 25%),radial-gradient(circle at 65% 60%,#49625d88 0 25%,transparent 26%),radial-gradient(circle at 30% 68%,#8f574777 0 23%,transparent 24%); animation: impact .34s ease-out; }

.loading { position: absolute; z-index: 100; inset: 0; display: grid; place-items: center; color: #ffe8ad; background: #172b28f7; font-size: 38px; transition: opacity .25s; }
.loading.hidden { opacity: 0; pointer-events: none; }
.orientation-tip { display: none; color: #f5ecd8; text-align: center; font-size: 26px; line-height: 1.6; }
.orientation-tip small { color: #d7bf85; }

@keyframes breathe { 0%,100% { transform: scaleY(1); } 50% { transform: rotate(.15deg) scaleY(1.004); } }
@keyframes actor-hit { 0% { transform: none; filter: none; } 8% { transform: translateX(10px) rotate(1.5deg) scale(1.04,.95); filter: sepia(.35) brightness(1.1); } 26% { transform: translateX(-16px) rotate(-3deg) scale(.97,.93); } 50% { transform: translateX(9px) rotate(2deg) scale(1.01,.97); } 76% { transform: translateX(-4px) rotate(-.7deg); } 100% { transform: none; } }
@keyframes fog-swallow { 0% { opacity: 1; transform: none; filter: none; } 38% { opacity: .9; transform: translateY(-5px) scale(1.025); filter: brightness(1.15) saturate(.72); } 100% { opacity: 0; transform: translateY(16px) scale(.88,1.04); filter: blur(11px) brightness(.42); } }
@keyframes disguise-fade { 0%,34% { opacity: 1; filter: none; } 70% { opacity: .62; filter: blur(3px) brightness(1.55) sepia(.7); } 100% { opacity: 0; filter: blur(9px) brightness(2); } }
@keyframes demon-arrive { 0% { opacity: 0; transform: translateY(72px) scale(.48); filter: blur(16px) brightness(.42); } 50% { opacity: 1; transform: translateY(-16px) scale(1.075,.96); filter: blur(3px) brightness(1.12); } 76% { transform: translateY(5px) scale(.985,1.018); } 100% { opacity: 1; transform: none; filter: none; } }
@keyframes demon-materialize { 0% { opacity: 0; transform: translateY(50px) scale(.34); filter: blur(20px) brightness(.42); } 28% { opacity: .72; } 62% { opacity: 1; transform: translateY(-12px) scale(1.09); filter: blur(1px) brightness(1.14); } 82% { transform: translateY(4px) scale(.985); } 100% { opacity: 1; transform: none; filter: drop-shadow(0 8px 10px #111b) drop-shadow(0 0 18px #66808a99); } }
@keyframes demon-hover { from { transform: translateY(0) rotate(-.35deg); } to { transform: translateY(-13px) rotate(.35deg); } }
@keyframes fog-gather { 0% { opacity: 0; transform: translateY(48px) scale(.5,.36); } 28% { opacity: .78; } 68% { transform: translateY(-5px) scale(1.05,.96); } 100% { opacity: 1; transform: none; } }
@keyframes fog-bloom { 0% { opacity: 0; transform: translate(var(--fog-in-x),var(--fog-in-y)) scale(.22); } 34% { opacity: .72; } 72% { opacity: 1; transform: translate(-5px,3px) scale(1.12); } 100% { opacity: 1; transform: none; } }
@keyframes fog-release { 0% { opacity: 1; transform: none; } 38% { opacity: .94; transform: translateY(-8px) scale(1.18); } 100% { opacity: 0; transform: translateY(-58px) scale(1.46,1.18); filter: blur(12px); } }
@keyframes fog-scatter { 0% { opacity: 1; transform: none; } 30% { opacity: .9; transform: translate(6px,-5px) scale(1.08); } 100% { opacity: 0; transform: translate(var(--fog-x),var(--fog-y)) scale(var(--fog-scale)); filter: blur(19px); } }
@keyframes demon-ink-burst { 0% { opacity: 0; transform: scale(.3) rotate(-8deg); } 38% { opacity: .95; } 100% { opacity: 0; transform: scale(1.35) rotate(8deg); } }
@keyframes staff-strike { 0% { transform: translate(-56px,-56px) rotate(142deg) scale(1.1); } 24% { transform: translate(-56px,-56px) rotate(222deg) scale(1.28); } 40% { transform: translate(-56px,-56px) rotate(180deg) scale(1.38); } 58% { transform: translate(-56px,-56px) rotate(174deg) scale(1.28); } 100% { transform: translate(-56px,-56px) rotate(180deg) scale(1); opacity: 0; } }
@keyframes impact { 0% { opacity: 0; transform: scale(.35) rotate(0); } 28% { opacity: 1; } 100% { opacity: 0; transform: scale(1.35) rotate(18deg); } }
@keyframes demo-pointer-bob { from { transform: translateY(-7px); } to { transform: translateY(7px); } }

@media (orientation: landscape) and (max-height: 720px) {
  #game { display: none; }
  .orientation-tip { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  .actor, .actor-body, .actor-canvas, .demon-form, .demon-fog, .demon-fog i, .staff, .impact, .instruction, .demo-pointer { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
