/* =========================================================
   上书房夜变 · v2 skin
   ink, snow, lacquer, candlelight
   ========================================================= */

:root {
  --v2-ink: #080c0e;
  --v2-ink-soft: #11181b;
  --v2-panel: rgba(12, 18, 20, .94);
  --v2-panel-soft: rgba(18, 25, 27, .88);
  --v2-ivory: #f1e7d2;
  --v2-ivory-dim: rgba(236, 225, 205, .7);
  --v2-gold: #d2b06a;
  --v2-gold-bright: #f0d79b;
  --v2-gold-dim: rgba(210, 176, 106, .45);
  --v2-red: #a74135;
  --v2-red-bright: #c85b48;
  --v2-teal: #6fa9a4;
  --v2-shadow: rgba(0, 0, 0, .56);
}

body {
  background: var(--v2-ink);
}

#app {
  background: #070b0d;
}

/* ---------- shared atmosphere ---------- */

#scene-bg,
.title-art,
.ending-art {
  filter: saturate(.92) contrast(1.04);
}

.wash {
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 214, 142, .075), transparent 47%),
    radial-gradient(ellipse at 50% 120%, rgba(0, 0, 0, .72), transparent 56%),
    linear-gradient(180deg, rgba(4, 9, 12, .4), transparent 18%, transparent 72%, rgba(4, 8, 10, .82));
}

.grain {
  opacity: .08;
  mix-blend-mode: soft-light;
}

.title-shade {
  background:
    linear-gradient(90deg, rgba(4, 8, 10, .95) 0%, rgba(4, 8, 10, .8) 28%, rgba(4, 8, 10, .18) 62%, rgba(4, 8, 10, .32) 100%),
    linear-gradient(180deg, rgba(3, 7, 9, .6) 0%, transparent 22%, transparent 60%, rgba(3, 7, 9, .92) 100%);
}

.title-art {
  background-position: 58% center;
}

.title-content {
  width: min(700px, 56vw);
}

.title-kicker {
  color: rgba(239, 215, 164, .66);
  letter-spacing: .4em;
}

.title-main {
  color: #f5ead4;
  text-shadow: 0 10px 42px rgba(0, 0, 0, .62);
}

.title-seal {
  border-color: rgba(226, 193, 127, .66);
  background: rgba(122, 36, 28, .18);
  box-shadow: inset 0 0 24px rgba(167, 65, 53, .2);
}

.title-sub {
  color: var(--v2-gold-bright);
  letter-spacing: .62em;
}

.title-poem {
  color: rgba(238, 225, 201, .78);
  border-left: 1px solid rgba(210, 176, 106, .34);
  padding-left: 18px;
}

.title-meta {
  color: rgba(230, 211, 172, .42);
}

.title-flower {
  color: rgba(226, 193, 127, .24);
}

.title-scroll-hint {
  color: rgba(230, 211, 172, .35);
}

/* ---------- HUD ---------- */

#hud.hud {
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 15px clamp(16px, 3.5vw, 54px);
  background:
    linear-gradient(180deg, rgba(4, 8, 10, .88), rgba(4, 8, 10, .35) 74%, transparent);
  border-bottom: 1px solid rgba(210, 176, 106, .12);
  backdrop-filter: blur(8px);
}

.hud-brand {
  min-width: 154px;
}

#hud .seal-small {
  background: var(--v2-red);
  border-color: rgba(240, 215, 155, .28);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, .28);
}

.brand-name {
  color: #f1e5cd;
  letter-spacing: .26em;
  font-size: 21px;
}

.hud-chapter {
  min-width: 150px;
  color: rgba(232, 218, 191, .62);
}

.night-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 26px);
  flex: 1;
  min-width: 0;
  font-family: var(--sans);
}

.status-label {
  display: block;
  margin-bottom: 5px;
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: .2em;
  color: rgba(222, 207, 178, .52);
  white-space: nowrap;
}

.turn-status {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.turn-pips {
  display: flex;
  align-items: center;
  gap: 4px;
}

.turn-pips i {
  display: block;
  width: 15px;
  height: 4px;
  background: var(--v2-gold);
  box-shadow: 0 0 10px rgba(210, 176, 106, .36);
  transition: background .35s var(--ease), opacity .35s var(--ease);
}

.turn-pips i.is-spent {
  background: rgba(210, 176, 106, .16);
  box-shadow: none;
}

.turn-count {
  margin-top: 4px;
  font-family: var(--serif);
  font-size: 12px;
  color: rgba(240, 215, 155, .8);
}

.suspicion-status {
  width: min(190px, 18vw);
}

.suspicion-track {
  height: 4px;
  background: rgba(240, 227, 207, .12);
  overflow: hidden;
}

.suspicion-track i {
  display: block;
  width: 8%;
  height: 100%;
  background: linear-gradient(90deg, #8f9f82, #d2b06a 58%, #b44738);
  box-shadow: 0 0 12px rgba(180, 71, 56, .3);
  transition: width .55s var(--ease), background .4s var(--ease);
}

body.is-danger .suspicion-track i {
  background: linear-gradient(90deg, #b44738, #e56c50);
  box-shadow: 0 0 16px rgba(229, 108, 80, .7);
  animation: danger-pulse 1.5s ease-in-out infinite;
}

.objective-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.objective {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border: 1px solid rgba(232, 218, 191, .13);
  font-size: 8px;
  letter-spacing: .1em;
  color: rgba(232, 218, 191, .42);
  white-space: nowrap;
  transition: color .3s var(--ease), border-color .3s var(--ease), background .3s var(--ease);
}

.objective i {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  font-style: normal;
  font-family: var(--serif);
  font-size: 9px;
  color: rgba(240, 215, 155, .55);
  border: 1px solid rgba(240, 215, 155, .18);
}

.objective.is-done {
  color: var(--v2-gold-bright);
  border-color: rgba(210, 176, 106, .45);
  background: rgba(210, 176, 106, .08);
}

.objective.is-done i {
  background: var(--v2-red);
  color: #fff0d1;
  border-color: rgba(240, 215, 155, .35);
}

/* ---------- scene caption ---------- */

.scene-caption {
  z-index: 8;
  color: rgba(240, 226, 202, .7);
}

.caption-cn {
  letter-spacing: .22em;
}

.caption-en {
  color: rgba(210, 176, 106, .5);
}

/* ---------- actors ---------- */

#actor-layer {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity .9s var(--ease), visibility .9s;
}

#actor-layer.is-visible {
  visibility: visible;
  opacity: 1;
}

.actor.is-absent {
  opacity: 0;
  visibility: hidden;
  pointer-events: none !important;
}

#actor-layer.location-corridor .actor-shuanger {
  left: 70%;
  bottom: 16vh;
  height: 58vh;
}

#actor-layer.location-sidehall .actor-haidafu {
  left: 55%;
  bottom: 18vh;
  height: 56vh;
}

#actor-layer.location-desk .actor-kangxi {
  left: 55%;
  bottom: 22vh;
  height: 51vh;
}

.actor {
  position: absolute;
  left: var(--x);
  bottom: var(--b);
  z-index: var(--z);
  height: var(--h);
  width: auto;
  padding: 0;
  margin: 0;
  background: none;
  border: 0;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  pointer-events: none;
  transition: opacity .55s var(--ease), filter .55s var(--ease), transform .55s var(--ease);
  filter: drop-shadow(0 24px 24px rgba(0, 0, 0, .42));
}

#actor-layer.is-interactive .actor {
  pointer-events: auto;
  cursor: pointer;
}

.actor-img {
  display: block;
  height: 100%;
  width: auto;
  max-width: none;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.actor-shade {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: -2%;
  height: 10%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, .62), transparent 70%);
  filter: blur(5px);
  z-index: -1;
}

.actor-name {
  position: absolute;
  left: 50%;
  bottom: 2.5%;
  display: flex;
  align-items: center;
  gap: 7px;
  transform: translateX(-50%);
  padding: 4px 8px 4px 10px;
  background: rgba(5, 9, 11, .78);
  border: 1px solid rgba(210, 176, 106, .25);
  color: rgba(241, 229, 205, .85);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .12em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}

.actor-name i {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  font-style: normal;
  font-size: 9px;
  color: #f3d9a5;
  background: var(--v2-red);
  border: 1px solid rgba(240, 215, 155, .3);
}

.actor-action {
  position: absolute;
  left: 50%;
  bottom: 11%;
  padding: 3px 8px;
  transform: translateX(-50%);
  color: rgba(240, 215, 155, .85);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: .18em;
  white-space: nowrap;
  background: rgba(5, 9, 11, .62);
  border: 1px solid rgba(210, 176, 106, .22);
  opacity: 0;
  transition: opacity .35s var(--ease), transform .35s var(--ease);
}

#actor-layer.is-interactive .actor-name,
#actor-layer.is-interactive .actor-action {
  opacity: 1;
}

#actor-layer.is-interactive .actor:hover .actor-img,
#actor-layer.is-interactive .actor:focus-visible .actor-img {
  filter: brightness(1.08) drop-shadow(0 0 18px rgba(240, 215, 155, .18));
}

#actor-layer.is-interactive .actor:hover .actor-name,
#actor-layer.is-interactive .actor:focus-visible .actor-name {
  border-color: rgba(240, 215, 155, .58);
}

.actor.is-speaking {
  transform: translateX(-50%) translateY(-5px) scale(1.015);
  filter: drop-shadow(0 26px 26px rgba(0, 0, 0, .5)) drop-shadow(0 0 26px rgba(240, 215, 155, .14));
  z-index: 12 !important;
}

.actor.is-dim {
  opacity: .42;
  filter: saturate(.72) brightness(.72) drop-shadow(0 18px 18px rgba(0, 0, 0, .38));
}

.actor.is-high-suspicion .actor-img {
  filter: sepia(.2) saturate(1.18) drop-shadow(0 0 20px rgba(180, 71, 56, .26));
}

.actor.is-angry .actor-img {
  filter: brightness(.93) saturate(1.18) drop-shadow(0 0 18px rgba(180, 71, 56, .34));
}

.actor.is-angry {
  animation: actor-breathe-red 2.8s ease-in-out infinite;
}

.actor.is-warm .actor-img {
  filter: brightness(1.05) saturate(1.02) drop-shadow(0 0 22px rgba(240, 215, 155, .2));
}

.actor.is-worried {
  transform: translateX(-50%) rotate(-.4deg);
}

.actor.is-dizzy .actor-img {
  filter: blur(.4px) saturate(.8) brightness(.88);
}

.actor.is-afraid {
  transform: translateX(-50%) translateY(4px) scale(.99);
}

/* ---------- hub prompt ---------- */

.hub-prompt {
  position: fixed;
  left: 50%;
  bottom: 220px;
  z-index: 29;
  width: min(760px, calc(100vw - 44px));
  transform: translateX(-50%) translateY(6px);
  padding: 10px 18px 11px;
  color: var(--v2-ivory);
  background: linear-gradient(90deg, rgba(8, 13, 15, .88), rgba(15, 20, 21, .78), rgba(8, 13, 15, .88));
  border-left: 2px solid var(--v2-red);
  border-top: 1px solid rgba(210, 176, 106, .18);
  border-bottom: 1px solid rgba(210, 176, 106, .08);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .24);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .35s var(--ease), transform .35s var(--ease), visibility .35s;
}

.hub-prompt.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.hub-kicker {
  display: block;
  color: var(--v2-gold);
  font-family: var(--sans);
  font-size: 7px;
  letter-spacing: .24em;
  margin-bottom: 3px;
}

.hub-prompt p {
  margin: 0;
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.6;
  letter-spacing: .08em;
  color: rgba(241, 231, 212, .82);
}

.hub-finale {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 7px;
  padding: 5px 10px;
  background: rgba(167, 65, 53, .18);
  border: 1px solid rgba(200, 91, 72, .42);
  color: #f2d0aa;
  font-family: var(--serif);
  font-size: 12px;
  letter-spacing: .1em;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}

.hub-finale i {
  font-family: var(--sans);
  font-size: 8px;
  font-style: normal;
  color: rgba(240, 215, 155, .55);
  letter-spacing: .06em;
}

.hub-finale:hover {
  background: rgba(167, 65, 53, .35);
  border-color: rgba(240, 160, 130, .7);
}

/* ---------- scene spots ---------- */

#scene-spots {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity .5s var(--ease), visibility .5s;
}

#scene-spots.is-visible {
  visibility: visible;
  opacity: 1;
}

.spot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0;
  pointer-events: auto;
  color: var(--v2-gold-bright);
  background: none;
  border: 0;
  cursor: pointer;
}

.spot-core {
  position: relative;
  display: block;
  width: 15px;
  height: 15px;
  border: 1px solid rgba(240, 215, 155, .72);
  border-radius: 50%;
  background: rgba(210, 176, 106, .12);
  box-shadow: 0 0 0 5px rgba(210, 176, 106, .06), 0 0 22px rgba(240, 215, 155, .32);
  animation: spot-breathe 2.8s ease-in-out infinite;
}

.spot-core::before,
.spot-core::after {
  content: "";
  position: absolute;
  background: rgba(240, 215, 155, .75);
}

.spot-core::before {
  left: 6px;
  top: 2px;
  width: 1px;
  height: 9px;
}

.spot-core::after {
  top: 6px;
  left: 2px;
  width: 9px;
  height: 1px;
}

.spot-label {
  padding: 3px 7px;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: .12em;
  color: rgba(247, 229, 194, .92);
  background: rgba(5, 9, 10, .72);
  border: 1px solid rgba(210, 176, 106, .22);
  white-space: nowrap;
  transition: background .25s var(--ease), border-color .25s var(--ease);
}

.spot:hover .spot-label,
.spot:focus-visible .spot-label {
  background: rgba(167, 65, 53, .7);
  border-color: rgba(240, 215, 155, .62);
}

.spot:hover .spot-core {
  background: rgba(240, 215, 155, .32);
  box-shadow: 0 0 0 8px rgba(210, 176, 106, .09), 0 0 26px rgba(240, 215, 155, .58);
}

/* ---------- actor action menu ---------- */

#actor-menu {
  position: fixed;
  inset: 0;
  z-index: 44;
  display: none;
  place-items: start center;
  padding: clamp(78px, 11vh, 118px) 24px 24px;
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
}

#actor-menu.is-open {
  display: grid;
}

.actor-menu-card {
  width: min(520px, 94vw);
  max-height: min(46vh, 430px);
  overflow: auto;
  pointer-events: auto;
  background: linear-gradient(145deg, rgba(15, 22, 24, .98), rgba(8, 13, 15, .98));
  border: 1px solid rgba(210, 176, 106, .42);
  box-shadow: 0 34px 90px rgba(0, 0, 0, .65), inset 0 0 0 1px rgba(255, 245, 225, .04);
  animation: menu-rise .32s var(--ease) both;
}

.actor-menu-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 14px;
  border-bottom: 1px solid rgba(210, 176, 106, .18);
}

.actor-menu-title span {
  display: block;
  margin-bottom: 4px;
  color: var(--v2-gold);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: .2em;
}

.actor-menu-title b {
  display: block;
  color: var(--v2-ivory);
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  letter-spacing: .14em;
}

.actor-menu-close {
  width: 31px;
  height: 31px;
  color: rgba(241, 231, 212, .65);
  border: 1px solid rgba(210, 176, 106, .24);
  font-size: 20px;
  line-height: 1;
}

.actor-menu-list {
  padding: 9px;
}

.actor-menu-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 12px;
  text-align: left;
  color: var(--v2-ivory);
  border: 1px solid transparent;
  border-bottom-color: rgba(210, 176, 106, .1);
  transition: background .22s var(--ease), border-color .22s var(--ease), transform .22s var(--ease);
}

.actor-menu-row:hover:not(:disabled),
.actor-menu-row:focus-visible:not(:disabled) {
  background: rgba(210, 176, 106, .075);
  border-color: rgba(210, 176, 106, .28);
  transform: translateX(2px);
}

.actor-menu-row:disabled {
  opacity: .34;
  cursor: not-allowed;
}

.actor-menu-key {
  display: grid;
  place-items: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(210, 176, 106, .3);
  color: var(--v2-gold);
  font-family: var(--sans);
  font-size: 9px;
}

.actor-menu-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.actor-menu-copy b {
  font-family: var(--song);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: .06em;
  color: rgba(245, 235, 216, .94);
}

.actor-menu-copy i {
  font-family: var(--sans);
  font-size: 8px;
  font-style: normal;
  letter-spacing: .08em;
  color: rgba(225, 212, 187, .46);
}

.actor-menu-row em {
  flex: 0 0 auto;
  font-family: var(--sans);
  font-size: 7px;
  font-style: normal;
  letter-spacing: .08em;
  color: rgba(240, 215, 155, .52);
}

/* ---------- dialogue: ink lacquer ---------- */

.dialogue-wrap {
  z-index: 31;
}

.dialogue {
  color: var(--v2-ivory);
  background:
    linear-gradient(105deg, rgba(10, 16, 18, .985), rgba(19, 24, 25, .97) 56%, rgba(14, 20, 21, .975));
  border: 1px solid rgba(210, 176, 106, .42);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .58), inset 0 0 0 1px rgba(255, 246, 228, .035);
  backdrop-filter: blur(10px);
}

.dialogue::before {
  background: linear-gradient(180deg, var(--v2-red-bright), rgba(167, 65, 53, .12));
}

.dialogue::after {
  border-top-color: rgba(210, 176, 106, .45);
  border-right-color: rgba(210, 176, 106, .45);
}

.speaker-seal {
  background: var(--v2-red);
  border-color: rgba(240, 215, 155, .28);
  color: #f8e8c9;
}

.speaker-en {
  color: rgba(210, 176, 106, .62);
}

.dialogue-rule {
  background: linear-gradient(90deg, rgba(210, 176, 106, .34), transparent);
}

.dialogue-hint {
  color: rgba(210, 176, 106, .62);
}

.dialogue-text {
  color: rgba(244, 235, 217, .94);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .32);
}

.dialogue-text.is-narration {
  color: rgba(203, 198, 184, .8);
}

.dialogue-text.is-verse {
  color: var(--v2-gold-bright);
}

.dialogue-text .em {
  color: #e6a07a;
}

.dialogue-foot {
  border-top-color: rgba(210, 176, 106, .16);
  color: rgba(225, 211, 185, .34);
}

.key-hint kbd {
  border-color: rgba(225, 211, 185, .22);
}

.choices {
  margin-top: 13px;
}

.choice-btn {
  color: rgba(244, 234, 214, .9);
  background: rgba(238, 226, 201, .035);
  border: 1px solid rgba(210, 176, 106, .22);
}

.choice-btn:hover {
  color: #fff4dc;
  background: rgba(210, 176, 106, .1);
  border-color: rgba(210, 176, 106, .56);
}

.choice-key {
  border-color: rgba(210, 176, 106, .34);
  color: var(--v2-gold);
}

.choice-label {
  color: inherit;
}

.choice-hint {
  color: rgba(225, 211, 185, .42);
}

/* ---------- portrait ---------- */

.portrait-medallion {
  width: 138px;
  height: 138px;
}

.portrait-inner {
  background-color: #121a1b;
  background-position: center 12%;
  background-size: cover;
  border: 1px solid rgba(210, 176, 106, .5);
  box-shadow: 0 0 0 5px rgba(8, 12, 14, .7), 0 20px 46px rgba(0, 0, 0, .5);
}

.portrait-ring {
  border-color: rgba(210, 176, 106, .28);
}

.portrait-ring::before {
  content: "夜";
  background: var(--v2-red);
  color: #f8e6c5;
  border-color: rgba(240, 215, 155, .3);
}

/* ---------- mini-games ---------- */

#mini-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(3, 7, 9, .72);
  backdrop-filter: blur(6px);
}

#mini-overlay.is-open {
  display: grid;
}

.mini-card {
  width: min(480px, 95vw);
  padding: 25px 25px 20px;
  background:
    linear-gradient(145deg, rgba(20, 27, 28, .99), rgba(7, 12, 14, .99));
  border: 1px solid rgba(210, 176, 106, .46);
  box-shadow: 0 34px 100px rgba(0, 0, 0, .72), inset 0 0 0 1px rgba(255, 246, 228, .04);
  animation: menu-rise .32s var(--ease) both;
}

.mini-kicker {
  color: var(--v2-gold);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: .26em;
}

.mini-card h2 {
  margin: 9px 0 7px;
  color: #f6ead2;
  font-family: var(--serif);
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 400;
  letter-spacing: .1em;
}

.mini-sub {
  margin: 0 0 18px;
  color: rgba(224, 211, 188, .6);
  font-family: var(--song);
  font-size: 13px;
  line-height: 1.8;
  letter-spacing: .04em;
}

.mini-stake {
  margin: 15px 0 0;
  padding-top: 11px;
  border-top: 1px dashed rgba(210, 176, 106, .18);
  color: rgba(240, 215, 155, .52);
  font-family: var(--sans);
  font-size: 9px;
  line-height: 1.7;
  letter-spacing: .05em;
}

.mini-actions {
  display: flex;
  gap: 9px;
  margin-top: 18px;
}

.mini-btn {
  flex: 1;
  min-height: 44px;
  padding: 10px 14px;
  color: rgba(244, 234, 214, .82);
  background: rgba(238, 226, 201, .035);
  border: 1px solid rgba(210, 176, 106, .28);
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: .12em;
  transition: background .25s var(--ease), border-color .25s var(--ease), color .25s var(--ease);
}

.mini-btn:hover:not(:disabled) {
  background: rgba(210, 176, 106, .12);
  border-color: rgba(240, 215, 155, .6);
  color: #fff3dc;
}

.mini-btn:disabled {
  opacity: .32;
  cursor: not-allowed;
}

.mini-primary {
  background: #e8d4a9;
  color: #121a1b;
  border-color: #e8d4a9;
}

.mini-primary:hover:not(:disabled) {
  background: #f3e0b8;
  border-color: #f3e0b8;
  color: #121a1b;
}

.mini-hint {
  min-height: 1.5em;
  margin: 12px 0 0;
  color: rgba(225, 211, 185, .44);
  font-family: var(--song);
  font-size: 12px;
  letter-spacing: .05em;
}

.dice-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 4px;
}

.die {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  color: #f0dba9;
  background: linear-gradient(145deg, #192326, #0b1214);
  border: 1px solid rgba(210, 176, 106, .48);
  box-shadow: inset 0 0 18px rgba(210, 176, 106, .08), 0 9px 18px rgba(0, 0, 0, .35);
  font-family: var(--serif);
  font-size: 30px;
  transition: transform .25s var(--ease), border-color .25s var(--ease);
}

.die.is-final {
  border-color: rgba(240, 215, 155, .7);
}

.die:hover {
  transform: translateY(-2px) rotate(1deg);
}

.dice-row.is-caught .die {
  border-color: rgba(200, 91, 72, .8);
  box-shadow: inset 0 0 18px rgba(200, 91, 72, .18), 0 0 22px rgba(200, 91, 72, .25);
}

.timing-stage {
  padding: 12px 0 0;
}

.timing-track {
  position: relative;
  height: 23px;
  margin: 6px 2px 0;
  background: rgba(235, 222, 198, .08);
  border: 1px solid rgba(210, 176, 106, .17);
  overflow: hidden;
}

.timing-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, rgba(210, 176, 106, .08), rgba(210, 176, 106, .26), rgba(210, 176, 106, .08));
  border-left: 1px solid rgba(240, 215, 155, .48);
  border-right: 1px solid rgba(240, 215, 155, .48);
}

.timing-card.is-lantern .timing-zone {
  background: linear-gradient(90deg, rgba(111, 169, 164, .08), rgba(111, 169, 164, .28), rgba(111, 169, 164, .08));
  border-color: rgba(159, 220, 211, .58);
}

.timing-needle {
  position: absolute;
  top: -2px;
  bottom: -2px;
  left: 0;
  width: 2px;
  background: #f3dca8;
  box-shadow: 0 0 12px rgba(240, 215, 155, .8);
}

.timing-card.is-lantern .timing-needle {
  background: #a6e3d9;
  box-shadow: 0 0 12px rgba(166, 227, 217, .8);
}

.timing-track.is-success {
  border-color: rgba(166, 227, 217, .7);
  box-shadow: 0 0 18px rgba(166, 227, 217, .16);
}

.timing-track.is-fail {
  border-color: rgba(200, 91, 72, .7);
  box-shadow: 0 0 18px rgba(200, 91, 72, .18);
}

.timing-labels {
  display: flex;
  justify-content: space-between;
  margin: 7px 2px 0;
  color: rgba(225, 211, 185, .32);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: .12em;
}

/* ---------- toast ---------- */

#toast.toast {
  left: auto;
  right: max(12px, env(safe-area-inset-right));
  top: calc(env(safe-area-inset-top) + 68px);
  bottom: auto;
  z-index: 90;
  max-width: min(360px, 52vw);
  transform: translateY(-6px);
  background: rgba(8, 13, 15, .94);
  border-color: rgba(210, 176, 106, .45);
  color: var(--v2-gold-bright);
  box-shadow: 0 14px 42px rgba(0, 0, 0, .5);
}

#toast.toast.is-visible {
  transform: translateY(0);
}

/* ---------- plan / route board ---------- */

.plan-card {
  position: relative;
  width: min(760px, calc(100vw - 36px));
  max-height: calc(100svh - 44px);
  overflow: auto;
  padding: 27px 29px 23px;
  color: var(--v2-ivory);
  background:
    linear-gradient(145deg, rgba(13, 20, 22, .985), rgba(22, 25, 25, .97));
  border: 1px solid rgba(210, 176, 106, .4);
  box-shadow: 0 34px 100px rgba(0, 0, 0, .65);
  animation: menu-rise .36s var(--ease) both;
}

.plan-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(210, 176, 106, .2);
}

.plan-head h2 {
  margin: 6px 0 0;
  color: #f5ead5;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
  letter-spacing: .14em;
}

.plan-head .close-btn {
  flex: 0 0 auto;
}

.plan-intro {
  margin: 15px 0 16px;
  color: rgba(231, 220, 199, .66);
  font-family: var(--song);
  font-size: 13px;
  line-height: 1.9;
  letter-spacing: .04em;
}

.plan-routes {
  display: grid;
  gap: 7px;
}

.plan-route {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(210, 176, 106, .16);
  background: rgba(240, 226, 201, .025);
  transition: border-color .3s var(--ease), background .3s var(--ease);
}

.plan-route.is-done {
  border-color: rgba(210, 176, 106, .5);
  background: rgba(210, 176, 106, .07);
}

.plan-seal {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  color: rgba(240, 215, 155, .65);
  border: 1px solid rgba(210, 176, 106, .34);
  font-family: var(--serif);
  font-size: 16px;
}

.plan-route.is-done .plan-seal {
  background: var(--v2-red);
  color: #f8e6c5;
  border-color: rgba(240, 215, 155, .35);
}

.plan-route-copy {
  flex: 1;
  min-width: 0;
}

.plan-route-copy h3 {
  margin: 0 0 2px;
  color: rgba(245, 235, 216, .94);
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: .14em;
}

.plan-route-copy p {
  margin: 0 0 3px;
  color: rgba(226, 214, 191, .62);
  font-family: var(--song);
  font-size: 11px;
  line-height: 1.6;
}

.plan-route-copy em {
  color: rgba(210, 176, 106, .56);
  font-family: var(--sans);
  font-size: 8px;
  font-style: normal;
  letter-spacing: .04em;
}

.plan-state {
  flex: 0 0 auto;
  color: rgba(226, 214, 191, .34);
  font-family: var(--sans);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: .08em;
}

.plan-route.is-done .plan-state {
  color: var(--v2-gold-bright);
}

.plan-endings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid rgba(210, 176, 106, .16);
}

.plan-ending {
  padding: 8px 9px;
  border-left: 1px solid rgba(210, 176, 106, .24);
}

.plan-ending-name {
  display: block;
  margin-bottom: 4px;
  color: var(--v2-gold-bright);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: .08em;
}

.plan-ending p {
  margin: 0;
  color: rgba(226, 214, 191, .5);
  font-family: var(--song);
  font-size: 10px;
  line-height: 1.7;
}

.plan-tip {
  margin: 14px 0 15px;
  padding: 9px 11px;
  color: rgba(240, 215, 155, .6);
  background: rgba(167, 65, 53, .1);
  border-left: 2px solid rgba(200, 91, 72, .55);
  font-family: var(--song);
  font-size: 11px;
  line-height: 1.8;
}

.plan-close {
  width: 100%;
  justify-content: center;
}

@media (max-width: 760px) {
  .plan-card {
    width: calc(100vw - 20px);
    max-height: calc(100svh - 22px);
    padding: 18px 14px 15px;
  }
  .plan-head h2 { font-size: 27px; }
  .plan-intro { margin: 11px 0 10px; font-size: 11px; line-height: 1.75; }
  .plan-route { gap: 8px; padding: 8px 8px; }
  .plan-seal { flex-basis: 27px; width: 27px; height: 27px; font-size: 13px; }
  .plan-route-copy h3 { font-size: 15px; }
  .plan-route-copy p { font-size: 10px; }
  .plan-route-copy em { font-size: 7px; }
  .plan-state { font-size: 7px; }
  .plan-endings { grid-template-columns: 1fr; gap: 2px; margin-top: 10px; padding-top: 9px; }
  .plan-ending { padding: 5px 8px; }
  .plan-ending-name { font-size: 12px; margin-bottom: 1px; }
  .plan-ending p { font-size: 9px; }
  .plan-tip { margin: 10px 0; font-size: 10px; padding: 7px 8px; }
  .plan-close { height: 42px; font-size: 14px; }
}

/* ---------- ending ---------- */

.ending-art {
  filter: brightness(.76) saturate(.82) contrast(1.06);
}

.ending-shade {
  background:
    linear-gradient(90deg, rgba(4, 8, 10, .94) 0%, rgba(4, 8, 10, .62) 48%, rgba(4, 8, 10, .88) 100%),
    linear-gradient(180deg, rgba(4, 8, 10, .72), transparent 38%, rgba(4, 8, 10, .9));
}

.ending-card {
  color: var(--v2-ivory);
  background: linear-gradient(145deg, rgba(12, 18, 20, .95), rgba(22, 25, 25, .9));
  border: 1px solid rgba(210, 176, 106, .34);
  box-shadow: 0 34px 100px rgba(0, 0, 0, .55);
}

.ending-kicker {
  color: var(--v2-gold);
}

.ending-card h2 {
  color: #f5ead5;
}

.ending-quote {
  color: var(--v2-gold-bright);
}

.ending-text {
  color: rgba(231, 220, 199, .74);
}

.ending-stats {
  border-top-color: rgba(210, 176, 106, .18);
  border-bottom-color: rgba(210, 176, 106, .18);
}

.ending-stats div span {
  color: var(--v2-gold-bright);
}

.ending-stats div small,
.ending-credit {
  color: rgba(225, 211, 185, .38);
}

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .hud-chapter { display: none; }
  .hud-brand { min-width: 130px; }
  .night-status { justify-content: flex-start; }
  .suspicion-status { width: min(150px, 16vw); }
}

@media (max-width: 900px) {
  #hud.hud {
    gap: 10px;
    padding: 11px 14px;
    flex-wrap: wrap;
  }
  .hud-brand { min-width: auto; }
  .brand-name { font-size: 18px; }
  .night-status {
    order: 3;
    flex: 1 0 100%;
    justify-content: space-between;
    gap: 8px;
    padding-top: 2px;
  }
  .status-label { font-size: 6px; margin-bottom: 4px; }
  .suspicion-status { width: 30%; }
  .turn-pips i { width: 12px; }
  .objective { font-size: 7px; padding: 2px 4px; }
  .objective i { width: 12px; height: 12px; font-size: 8px; }
  .title-content { width: min(640px, 66vw); }
}

@media (max-width: 760px) {
  .title-content {
    left: 22px;
    bottom: calc(68px + var(--safe-bottom));
    width: calc(100vw - 44px);
  }
  .title-main { font-size: clamp(54px, 16.5vw, 68px); letter-spacing: .04em; }
  .title-kicker { font-size: 8px; margin-bottom: 12px; }
  .title-lockup { gap: 10px; }
  .title-seal { width: 30px; height: 48px; margin-bottom: 10px; font-size: 11px; }
  .title-sub { font-size: 13px; margin: 10px 0 16px; }
  .title-poem { margin: 18px 0 20px; font-size: 12px; line-height: 2; padding-left: 12px; }
  .title-actions { gap: 7px; }
  .title-actions .btn { height: 43px; padding: 0 16px; font-size: 14px; gap: 10px; }
  .title-meta { margin-top: 24px; font-size: 8px; }
  .title-flower { width: 52px; height: 52px; right: 22px; bottom: 20px; }
  .title-scroll-hint { display: none; }

  #hud.hud { padding: 9px 11px; gap: 8px; }
  .hud-brand { gap: 6px; }
  #hud .seal-small { width: 23px; height: 29px; font-size: 10px; }
  .brand-name { font-size: 16px; letter-spacing: .18em; }
  #hud .icon-btn { width: 29px; height: 29px; font-size: 13px; }
  .night-status { gap: 6px; }
  .objective-row { gap: 3px; }
  .objective { padding: 2px 3px; letter-spacing: .03em; }
  .turn-pips { gap: 3px; }
  .turn-pips i { width: 10px; height: 3px; }
  .turn-count { font-size: 10px; margin-top: 2px; }
  .suspicion-track { height: 3px; }

  #actor-layer .actor {
    left: var(--mx);
    bottom: var(--mb);
    height: var(--mh);
  }
  #actor-layer.location-corridor .actor-shuanger {
    left: 66%;
    bottom: 25vh;
    height: 37vh;
  }
  #actor-layer.location-sidehall .actor-haidafu {
    left: 54%;
    bottom: 27vh;
    height: 35vh;
  }
  #actor-layer.location-desk .actor-kangxi {
    left: 56%;
    bottom: 13vh;
    height: 51vh;
  }
  .actor-name {
    bottom: 0;
    padding: 3px 5px 3px 7px;
    font-size: 10px;
    gap: 4px;
  }
  .actor-name i { width: 12px; height: 12px; font-size: 7px; }
  .actor-action { bottom: 8%; font-size: 7px; padding: 2px 5px; }
  .actor-shade { bottom: 0; height: 7%; }

  .scene-caption {
    top: 82px;
    left: 14px;
    font-size: 9px;
  }
  .scene-caption .caption-en { font-size: 7px; }

  .dialogue-wrap {
    width: calc(100vw - 20px);
    bottom: max(9px, var(--safe-bottom));
  }
  .dialogue {
    min-height: 0;
    padding: 14px 17px 11px 24px;
    border-color: rgba(210, 176, 106, .34);
  }
  .dialogue::before { left: 9px; top: 12px; bottom: 12px; }
  .dialogue::after { width: 17px; height: 17px; top: 6px; right: 6px; }
  .dialogue-head { gap: 7px; margin-bottom: 7px; }
  .speaker-seal { min-width: 30px; height: 24px; padding: 0 6px; font-size: 11px; }
  .speaker-en { font-size: 6px; letter-spacing: .14em; }
  .dialogue-hint { font-size: 8px; }
  .dialogue-text { font-size: 15.5px; line-height: 1.82; letter-spacing: .03em; }
  .dialogue-foot { margin-top: 8px; padding-top: 6px; font-size: 7px; }
  .dialogue-foot .key-hint { display: none; }
  .choices { gap: 6px; margin-top: 10px; }
  .choice-btn { min-height: 42px; padding: 8px 10px; gap: 9px; }
  .choice-key { width: 21px; height: 21px; flex-basis: 21px; font-size: 8px; }
  .choice-label { font-size: 13px; }
  .choice-hint { font-size: 7px; }
  .portrait-medallion {
    width: 84px;
    height: 84px;
    left: 3px;
    bottom: calc(100% - 8px);
  }
  .portrait-inner { inset: 5px; background-position: center 10%; }

  .hub-prompt {
    left: 13px;
    top: calc(env(safe-area-inset-top) + 94px);
    bottom: auto;
    width: min(320px, calc(100vw - 100px));
    padding: 6px 9px 7px;
    transform: translateY(6px);
    pointer-events: none;
  }
  .hub-prompt.is-visible { transform: translateY(0); pointer-events: none; }
  .hub-kicker { display: none; }
  .hub-prompt p { font-size: 10.5px; line-height: 1.45; letter-spacing: .05em; }
  .hub-finale { font-size: 9px; padding: 3px 7px; margin-top: 4px; gap: 0; pointer-events: auto; }
  .hub-finale i { display: none; }

  #scene-spots .spot-label { font-size: 9px; padding: 2px 5px; }
  .spot-core { width: 13px; height: 13px; }
  .spot-core::before { left: 5px; top: 2px; height: 7px; }
  .spot-core::after { top: 5px; left: 2px; width: 7px; }

  #actor-menu { padding: 88px 11px 12px; }
  .actor-menu-card { max-height: 42vh; }
  .actor-menu-head { padding: 15px 14px 10px; }
  .actor-menu-title b { font-size: 21px; }
  .actor-menu-list { padding: 6px; }
  .actor-menu-row { padding: 10px 8px; gap: 8px; }
  .actor-menu-copy b { font-size: 13px; }
  .actor-menu-row em { font-size: 6px; }

  .mini-card { padding: 19px 16px 15px; }
  .mini-card h2 { font-size: 25px; }
  .mini-sub { font-size: 12px; margin-bottom: 13px; }
  .die { width: 57px; height: 57px; font-size: 24px; }
  .dice-row { gap: 8px; }
  .mini-btn { min-height: 42px; font-size: 14px; }
  .mini-stake { font-size: 8px; }

  .ending-card {
    width: calc(100vw - 28px);
    max-height: calc(100svh - 34px);
    overflow: auto;
    padding: 26px 20px 22px;
  }
  .ending-card h2 { font-size: 43px; }
  .ending-text { font-size: 13px; line-height: 1.9; }
  .ending-quote { font-size: 16px; }
  .ending-actions { gap: 7px; }
  .ending-actions .btn { flex: 1; justify-content: center; height: 43px; padding: 0 10px; font-size: 13px; gap: 7px; }
  .ending-stats div span { font-size: 23px; }
  .ending-stats div small { font-size: 7px; }

  #toast.toast {
    top: calc(env(safe-area-inset-top) + 76px);
    bottom: auto;
    max-width: 70vw;
    padding: 8px 11px;
    font-size: 10px;
    line-height: 1.65;
  }
}

@media (max-width: 420px) {
  .title-meta { margin-top: 18px; gap: 7px; }
  .title-meta-line { width: 16px; }
  .night-status { flex-wrap: nowrap; }
  .suspicion-status { width: 26%; }
  .objective { font-size: 6px; }
  .objective i { width: 11px; height: 11px; }
  .dialogue-text { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  #actor-layer,
  .actor,
  .spot-core,
  .ambient {
    animation: none !important;
  }
}

@keyframes actor-breathe-red {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-2px); }
}

@keyframes spot-breathe {
  0%, 100% { transform: scale(1); opacity: .92; }
  50% { transform: scale(1.22); opacity: 1; }
}

@keyframes menu-rise {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes danger-pulse {
  0%, 100% { opacity: .8; }
  50% { opacity: 1; }
}
