:root {
  --bg-deep: #0c0c10;
  --surface: #15151c;
  --surface-strong: rgba(10, 10, 16, 0.9);
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.28);
  --text: #f2f2f2;
  --text-soft: rgba(255, 255, 255, 0.64);
  --text-faint: rgba(255, 255, 255, 0.38);
  --gold: #ffd479;
  --pink: #ff4d8f;
  --mint: #5eead4;
  --blue: #91bdf2;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

body {
  color: var(--text);
  font-family: var(--serif);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  background: none;
  cursor: pointer;
}

#game-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.scene,
.void-space,
.heart-lobby,
.world-sea {
  position: absolute;
  inset: 0;
}

.scene {
  background: #000;
  transition: filter 600ms var(--ease);
}

.void-space,
.heart-lobby,
.world-sea,
.world-route,
.contract-file,
.mission-brief,
.memory-stream,
.zero-bot,
.shenyan-portrait {
  opacity: 0;
  pointer-events: none;
  transition: opacity 480ms var(--ease), transform 720ms var(--ease), filter 720ms var(--ease);
}

/* 空白意识空间 */
.void-space {
  overflow: hidden;
  background:
    linear-gradient(rgba(120, 154, 196, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 154, 196, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, #101923 0%, #070b10 42%, #000 76%);
  background-size: 48px 48px, 48px 48px, auto;
}

.void-space::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(151, 194, 235, 0.1), transparent);
  opacity: 0.45;
  transform: translateX(-100%);
  animation: scan 4.8s ease-in-out infinite;
}

.scan-ring,
.scan-core,
.signal-line {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.scan-ring {
  border: 1px solid rgba(151, 194, 235, 0.24);
}

.ring-a {
  width: min(42vw, 420px);
  aspect-ratio: 1;
  animation: pulseRing 3.6s ease-in-out infinite;
}

.ring-b {
  width: min(22vw, 220px);
  aspect-ratio: 1;
  border-color: rgba(255, 212, 121, 0.32);
  animation: pulseRing 3.6s 0.5s ease-in-out infinite reverse;
}

.scan-core {
  width: 10px;
  height: 10px;
  background: #d9eeff;
  box-shadow: 0 0 18px #8ac8ff, 0 0 44px rgba(138, 200, 255, 0.5);
}

.signal-line {
  width: min(70vw, 820px);
  height: 1px;
  border-radius: 0;
  background: linear-gradient(90deg, transparent, rgba(145, 189, 242, 0.36), var(--gold), rgba(145, 189, 242, 0.36), transparent);
}

#game-container[data-scene="void"] .void-space,
#game-container[data-scene="scan"] .void-space {
  opacity: 1;
}

#game-container[data-scene="scan"] .void-space {
  filter: brightness(1.28);
}

/* 心域大厅 */
.heart-lobby {
  overflow: hidden;
  transform: scale(1.025);
}

.hall-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.78) contrast(1.02) brightness(0.86);
}

.heart-lobby::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    radial-gradient(circle at 51% 45%, transparent 0 24%, rgba(4, 5, 8, 0.18) 55%, rgba(4, 5, 8, 0.72) 100%),
    linear-gradient(180deg, rgba(2, 2, 4, 0.16), transparent 38%, rgba(2, 2, 4, 0.72));
}

#game-container[data-scene="lobby"] .heart-lobby,
#game-container[data-scene="contract"] .heart-lobby,
#game-container[data-scene="contract-auth"] .heart-lobby,
#game-container[data-scene="shenyan"] .heart-lobby,
#game-container[data-scene="mission"] .heart-lobby,
#game-container[data-scene="inject"] .heart-lobby {
  opacity: 1;
  transform: scale(1);
}

#game-container[data-scene="contract"] .heart-lobby,
#game-container[data-scene="contract-auth"] .heart-lobby,
#game-container[data-scene="mission"] .heart-lobby {
  filter: brightness(0.56) blur(1px);
}

/* 世界海 */
.world-sea {
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(23, 34, 59, 0.3), transparent 44%),
    radial-gradient(ellipse at 50% 44%, #101b32 0%, #060b16 48%, #020408 100%);
}

.world-sea::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.88) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255, 212, 121, 0.72) 0 1px, transparent 1.5px);
  background-position: 0 0, 39px 31px;
  background-size: 86px 76px, 128px 110px;
  opacity: 0.45;
}

.continuum-line {
  position: absolute;
  left: -8%;
  top: 55%;
  width: 116%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(145, 189, 242, 0.45), rgba(255, 212, 121, 0.85), rgba(145, 189, 242, 0.45), transparent);
  transform: rotate(-8deg);
  box-shadow: 0 0 18px rgba(145, 189, 242, 0.3);
}

.world-orb {
  position: absolute;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.72), transparent 10%),
    radial-gradient(circle at 50% 60%, rgba(255, 212, 121, 0.22), transparent 58%),
    rgba(78, 112, 157, 0.12);
  box-shadow: inset 0 0 28px rgba(255, 255, 255, 0.12), 0 0 28px rgba(92, 143, 211, 0.2);
  animation: drift 5s ease-in-out infinite;
}

.world-orb i {
  width: 46%;
  height: 46%;
  border: 1px solid rgba(255, 212, 121, 0.42);
  border-radius: 50%;
  box-shadow: 0 0 16px rgba(255, 212, 121, 0.2);
}

.orb-a { left: 8%; bottom: 8%; width: clamp(120px, 24vw, 340px); }
.orb-b { left: 42%; top: 30%; width: clamp(92px, 15vw, 230px); animation-delay: -1s; }
.orb-c { right: 18%; top: 15%; width: clamp(74px, 11vw, 170px); animation-delay: -2s; }
.orb-d { right: 5%; top: 8%; width: clamp(48px, 6vw, 94px); animation-delay: -3s; }
.orb-e { left: 28%; top: 13%; width: clamp(38px, 4.5vw, 70px); animation-delay: -4s; }

.entropy-rift {
  position: absolute;
  left: 48%;
  top: 13%;
  width: 2px;
  height: 66%;
  background: linear-gradient(transparent, rgba(255, 142, 156, 0.8), rgba(145, 189, 242, 0.5), transparent);
  box-shadow: 0 0 18px rgba(255, 142, 156, 0.5);
  transform: rotate(17deg) scaleY(0);
  transform-origin: top;
  transition: transform 900ms var(--ease);
}

#game-container[data-scene="world-sea"] .world-sea {
  opacity: 1;
}

#game-container[data-scene="world-sea"] .entropy-rift {
  transform: rotate(17deg) scaleY(1);
}

/* 零号 */
.zero-bot {
  position: absolute;
  z-index: 12;
  right: clamp(7%, 13vw, 18%);
  top: 20%;
  width: clamp(112px, 13vw, 195px);
  height: clamp(170px, 23vw, 300px);
  animation: float 3.6s ease-in-out infinite;
}

.zero-image {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.52));
}

.zero-glow {
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: 2%;
  height: 12%;
  border-radius: 50%;
  background: rgba(88, 177, 255, 0.52);
  filter: blur(12px);
}

#game-container[data-scene="lobby"] .zero-bot,
#game-container[data-scene="contract"] .zero-bot,
#game-container[data-scene="mission"] .zero-bot,
#game-container[data-scene="inject"] .zero-bot {
  opacity: 1;
}

/* 沈言首次出场：复用心域大厅，只增加角色视觉层。 */
.shenyan-portrait {
  position: absolute;
  z-index: 14;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(52vw, 760px);
  overflow: hidden;
  background: linear-gradient(90deg, transparent, rgba(8, 12, 20, 0.42) 28%, rgba(8, 12, 20, 0.78));
}

.shenyan-portrait::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(90deg, rgba(5, 7, 11, 0.9), transparent 28%, transparent 72%, rgba(5, 7, 11, 0.3));
}

.shenyan-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 54% 34%;
  filter: saturate(0.72) contrast(1.04) brightness(0.76);
}

.shenyan-portrait > span {
  position: absolute;
  z-index: 2;
  top: max(58px, calc(env(safe-area-inset-top) + 52px));
  right: max(20px, calc(env(safe-area-inset-right) + 16px));
  color: rgba(255, 255, 255, 0.34);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.28em;
  writing-mode: vertical-rl;
}

#game-container[data-scene="shenyan"] .shenyan-portrait {
  opacity: 1;
}

#game-container[data-scene="shenyan"] .heart-lobby {
  filter: brightness(0.54) saturate(0.72);
}

#game-container[data-scene="contract"] .zero-bot {
  right: 8%;
  top: 25%;
  width: clamp(94px, 10.5vw, 156px);
}

#game-container[data-scene="mission"] .zero-bot {
  right: 4%;
  top: 30%;
  width: clamp(78px, 8.5vw, 126px);
}

#game-container[data-scene="inject"] .zero-bot {
  right: 50%;
  top: 24%;
  transform: translateX(50%);
}

/* 契约 */
.contract-file {
  position: absolute;
  z-index: 10;
  left: clamp(18px, 5vw, 76px);
  top: clamp(62px, 10vh, 98px);
  width: min(720px, 66vw);
  max-height: calc(100vh - 150px);
  padding: clamp(16px, 2.2vw, 28px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(10, 10, 16, 0.9);
  backdrop-filter: blur(12px);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
  transform: translateY(12px);
}

#game-container[data-scene="contract"] .contract-file {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

#game-container[data-scene="contract-auth"] .contract-file {
  opacity: 0.42;
  pointer-events: none;
  transform: none;
  filter: brightness(0.55);
}

#game-container[data-scene="contract"][data-mode="action"] .contract-file {
  max-height: calc(100vh - 124px - env(safe-area-inset-bottom));
}

#game-container[data-scene="contract"][data-mode="narration"] .contract-file,
#game-container[data-scene="contract"][data-mode="dialogue"] .contract-file {
  max-height: calc(100vh - 176px - env(safe-area-inset-bottom));
}

.panel-kicker,
.route-head span {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: clamp(8px, 0.75vw, 11px);
  letter-spacing: 0.36em;
}

.contract-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--line);
}

.contract-title-row span {
  color: var(--gold);
  font-size: clamp(10px, 1vw, 13px);
  letter-spacing: 0.18em;
}

.contract-title-row h2 {
  margin: 4px 0 0;
  font-size: clamp(20px, 2.4vw, 34px);
  letter-spacing: 0.1em;
}

.contract-title-row > b {
  flex-shrink: 0;
  padding: 5px 10px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: 0.14em;
  border: 1px solid rgba(255, 212, 121, 0.42);
  border-radius: 6px;
}

.contract-clauses {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.contract-clauses li {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  color: var(--text-soft);
  font-size: clamp(11px, 1.08vw, 15px);
  line-height: 1.65;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.contract-clauses li b {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 11px;
}

.name-registration {
  display: none;
  margin-top: 18px;
  padding: clamp(14px, 1.8vw, 22px);
  border: 1px solid rgba(255, 212, 121, 0.24);
  border-radius: 10px;
  background: rgba(255, 212, 121, 0.035);
}

.contract-file.is-name-entry .name-registration,
.contract-file.is-signing .name-registration {
  display: block;
  animation: choiceIn 360ms var(--ease) both;
}

.contract-file.is-name-entry .contract-clauses,
.contract-file.is-signing .contract-clauses {
  display: none;
}

.contract-file.is-signing .name-input-row {
  border-color: rgba(94, 234, 212, 0.42);
  background: rgba(94, 234, 212, 0.04);
}

.contract-file.is-signing .name-input-row > span,
.contract-file.is-signing #walker-name {
  color: var(--mint);
}

.name-registration > label {
  display: block;
  margin-bottom: 14px;
  color: #fff;
  font-size: clamp(15px, 1.55vw, 21px);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.name-input-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.name-input-row:focus-within {
  border-color: rgba(255, 212, 121, 0.72);
  box-shadow: 0 0 0 2px rgba(255, 212, 121, 0.08);
}

.name-input-row > span {
  color: var(--gold);
  font-family: var(--mono);
  font-size: clamp(8px, 0.75vw, 10px);
  letter-spacing: 0.18em;
  white-space: nowrap;
}

#walker-name {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0;
  border: 0;
  outline: 0;
  color: #fff;
  font-family: var(--serif);
  font-size: clamp(16px, 1.8vw, 24px);
  letter-spacing: 0.12em;
  background: transparent;
  user-select: text;
}

#walker-name::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

#name-note {
  margin: 9px 0 0;
  color: var(--text-faint);
  font-size: clamp(9px, 0.85vw, 11px);
  letter-spacing: 0.05em;
}

.registration-meta {
  display: flex;
  gap: 18px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.registration-meta span {
  color: var(--text-faint);
  font-size: clamp(9px, 0.9vw, 12px);
}

.registration-meta b {
  margin-left: 5px;
  color: var(--gold);
  font-family: var(--mono);
  font-weight: 400;
}

.chair-seal {
  position: absolute;
  right: 22px;
  bottom: 18px;
  display: none;
  place-items: center;
  width: 92px;
  aspect-ratio: 1;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 0.08em;
  border: 1px solid rgba(255, 212, 121, 0.55);
  border-radius: 50%;
  transform: rotate(-10deg);
  animation: sealIn 480ms var(--ease) both;
}

.chair-seal small {
  display: block;
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.16em;
}

.contract-file.is-signed .chair-seal {
  display: grid;
}

.contract-file.is-signed .contract-title-row > b {
  color: var(--mint);
  border-color: rgba(94, 234, 212, 0.5);
}

/* 位面链 */
.world-route {
  position: absolute;
  z-index: 8;
  left: max(18px, calc(env(safe-area-inset-left) + 12px));
  right: max(18px, calc(env(safe-area-inset-right) + 12px));
  top: max(56px, calc(env(safe-area-inset-top) + 52px));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  display: flex;
  flex-direction: column;
  transform: translateY(12px);
  transition: none;
}

#game-container[data-scene="world-route"] .world-route {
  left: 50%;
  right: auto;
  top: 50%;
  bottom: auto;
  width: min(100vw, 177.683vh);
  aspect-ratio: 1672 / 941;
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  background: #050912 url("../assets/world-route-final.jpg") center / 100% 100% no-repeat;
}

#game-container[data-scene="world-route"] .scene::before {
  position: absolute;
  z-index: 0;
  inset: -6%;
  content: "";
  background: #050912 url("../assets/world-route-final.jpg") center / cover no-repeat;
  filter: blur(22px) brightness(0.42) saturate(0.8);
  transform: scale(1.06);
}

#game-container[data-scene="world-route"] .route-head,
#game-container[data-scene="world-route"] .route-list {
  display: none;
}

.route-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 10px;
}

.route-head h2 {
  margin: 2px 0 0;
  font-size: clamp(21px, 2.6vw, 36px);
  letter-spacing: 0.18em;
}

.route-head p {
  margin: 0;
  color: var(--text-soft);
  font-size: clamp(9px, 0.9vw, 12px);
  line-height: 1.7;
  text-align: right;
}

.route-head p b {
  color: var(--gold);
  font-weight: 400;
}

.route-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(7px, 0.9vw, 13px);
  min-height: 0;
  flex: 1;
}

.route-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 10, 16, 0.86);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.36);
}

.route-visual {
  position: absolute;
  inset: 0;
  opacity: 0.7;
}

.route-visual::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 14%, rgba(4, 4, 8, 0.12) 46%, rgba(4, 4, 8, 0.96) 92%);
}

.entertainment { background: linear-gradient(150deg, #111627, #56401b 45%, #171018 72%); }
.entertainment::before { position: absolute; inset: 16% 14% auto; height: 3px; content: ""; background: #ffe6a7; box-shadow: 20px 24px 0 #ffcf73, 48px 6px 0 #fff, 72px 34px 0 #ffdf98, 22px 58px 0 #fff; }
.palace { background: linear-gradient(145deg, #251313, #57311d 55%, #120b0c); }
.fantasy { background: linear-gradient(145deg, #10182e, #253f62 55%, #0b0c18); }
.republic { background: linear-gradient(145deg, #1e2024, #3d332b 55%, #101114); }
.immortal { background: linear-gradient(145deg, #10201f, #294341 50%, #0a1113); }
.doomsday { background: linear-gradient(145deg, #24201a, #353f42 55%, #0d1012); }

.route-card > i,
.route-card > b,
.route-card > em,
.route-card > small {
  position: absolute;
  z-index: 2;
  left: clamp(10px, 1vw, 15px);
  right: clamp(10px, 1vw, 15px);
}

.route-card > i {
  top: 12px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 0.2em;
}

.route-card > b {
  top: 25%;
  right: auto;
  font-size: clamp(22px, 2.6vw, 38px);
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
}

.route-card > em {
  bottom: 54px;
  color: var(--text-soft);
  font-size: clamp(9px, 0.88vw, 12px);
  font-style: normal;
  line-height: 1.5;
}

.route-card > small {
  bottom: 12px;
  padding: 6px 5px;
  color: var(--text-soft);
  font-size: clamp(8px, 0.76vw, 10px);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.42);
}

.route-card.is-open {
  border-color: rgba(255, 212, 121, 0.64);
  box-shadow: 0 0 0 1px rgba(255, 212, 121, 0.12), 0 18px 48px rgba(0, 0, 0, 0.46);
}

.route-card.is-open > small {
  color: #17130a;
  border-color: var(--gold);
  background: var(--gold);
}

.route-card.is-locked {
  opacity: 0.58;
  filter: saturate(0.48);
}

/* 任务简报 */
.mission-brief {
  position: absolute;
  z-index: 10;
  left: 50%;
  top: 50%;
  width: min(760px, 78vw);
  padding: clamp(16px, 2vw, 26px);
  border: 1px solid rgba(255, 212, 121, 0.28);
  border-radius: 12px;
  background: rgba(10, 10, 16, 0.9);
  backdrop-filter: blur(14px);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.56);
  transform: translate(-50%, -46%);
}

#game-container[data-scene="mission"] .mission-brief {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.mission-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: clamp(16px, 2.4vw, 30px);
  margin-top: 12px;
}

.mission-main {
  padding-right: clamp(12px, 2vw, 28px);
  border-right: 1px solid var(--line);
}

.mission-main > span {
  color: var(--gold);
  font-size: clamp(9px, 0.9vw, 12px);
  letter-spacing: 0.18em;
}

.mission-main h2 {
  margin: 8px 0 12px;
  font-size: clamp(22px, 2.6vw, 36px);
  line-height: 1.35;
  letter-spacing: 0.08em;
}

.mission-main p {
  margin: 0;
  color: var(--text-soft);
  font-size: clamp(11px, 1.05vw, 14px);
  line-height: 1.9;
}

.mission-brief dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.mission-brief dl div {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mission-brief dt {
  color: var(--text-faint);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.mission-brief dd {
  margin: 3px 0 0;
  color: #fff;
  font-size: clamp(11px, 1.05vw, 14px);
}

.memory-stream {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(20px, 5vw, 74px);
  background: rgba(4, 6, 12, 0.58);
  backdrop-filter: blur(4px);
}

.memory-stream span {
  color: rgba(255, 255, 255, 0.3);
  font-size: clamp(18px, 3vw, 42px);
  letter-spacing: 0.18em;
  animation: memoryFlash 2.2s ease-in-out infinite;
}

.memory-stream span:nth-child(2) { animation-delay: -0.45s; }
.memory-stream span:nth-child(3) { animation-delay: -0.9s; }
.memory-stream span:nth-child(4) { animation-delay: -1.35s; color: rgba(255, 212, 121, 0.52); }

#game-container[data-scene="inject"] .memory-stream {
  opacity: 1;
}

/* HUD */
#hud {
  position: absolute;
  z-index: 60;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: calc(7px + env(safe-area-inset-top)) max(14px, calc(env(safe-area-inset-right) + 10px)) 7px max(14px, calc(env(safe-area-inset-left) + 10px));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.66), transparent);
  transition: opacity 260ms ease;
}

#hud.hide {
  opacity: 0;
  pointer-events: none;
}

.hud-left {
  display: flex;
  align-items: center;
}

.hud-left {
  gap: 9px;
  flex-shrink: 0;
}

.hday {
  color: #fff;
  font-size: clamp(11px, 1.15vw, 15px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 4px #000;
}

.hphase {
  padding: 3px 10px;
  color: var(--gold);
  font-size: clamp(9px, 0.9vw, 12px);
  letter-spacing: 0.1em;
  white-space: nowrap;
  border: 1px solid rgba(255, 212, 121, 0.42);
  border-radius: 10px;
}

.hud-spacer {
  flex: 1;
}

#guide {
  position: absolute;
  z-index: 58;
  top: calc(48px + env(safe-area-inset-top));
  left: 50%;
  max-width: 82vw;
  padding: 4px 13px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-align: center;
  white-space: nowrap;
  border: 1px solid rgba(255, 212, 121, 0.38);
  border-radius: 12px;
  background: rgba(20, 17, 10, 0.7);
  transform: translateX(-50%);
  transition: opacity 220ms ease;
}

#guide.hide {
  display: none;
}

#toasts {
  position: absolute;
  z-index: 86;
  top: calc(50px + env(safe-area-inset-top));
  right: max(14px, calc(env(safe-area-inset-right) + 10px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

.toast {
  padding: 4px 12px;
  color: var(--gold);
  font-size: 9px;
  letter-spacing: 0.1em;
  border: 1px solid rgba(255, 212, 121, 0.45);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.72);
  animation: toastUp 2.2s ease forwards;
}

/* 系统信号 */
.system-panel {
  position: absolute;
  z-index: 52;
  left: max(24px, calc(env(safe-area-inset-left) + 18px));
  top: 50%;
  display: grid;
  gap: 8px;
  width: min(520px, 72vw);
  padding-left: 22px;
  opacity: 0;
  transform: translateY(-45%);
  transition: opacity 300ms var(--ease), transform 400ms var(--ease);
}

.system-panel[hidden] {
  display: none !important;
}

.system-panel::before {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  content: "";
  background: linear-gradient(transparent, var(--gold), var(--blue), transparent);
  box-shadow: 0 0 10px rgba(145, 189, 242, 0.46);
}

.system-panel.show {
  opacity: 1;
  transform: translateY(-50%);
}

#game-container[data-scene="contract"] .system-panel {
  display: none !important;
  visibility: hidden;
}


#game-container[data-scene="contract-auth"] .system-panel {
  left: 50%;
  top: 50%;
  width: min(580px, 76vw);
  padding: 22px 24px 22px 32px;
  border: 1px solid rgba(255, 212, 121, 0.24);
  border-radius: 10px;
  background: rgba(7, 9, 14, 0.92);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.56);
  transform: translate(-50%, -50%);
}

#game-container[data-scene="contract-auth"] .system-panel.show {
  transform: translate(-50%, -50%);
}

.system-kicker {
  color: var(--blue);
  font-family: var(--mono);
  font-size: clamp(8px, 0.8vw, 11px);
  letter-spacing: 0.34em;
}

.system-panel strong {
  font-size: clamp(22px, 3.1vw, 42px);
  line-height: 1.35;
  letter-spacing: 0.08em;
}

.system-panel p {
  margin: 0;
  color: var(--text-soft);
  font-size: clamp(11px, 1.2vw, 16px);
  line-height: 1.8;
  letter-spacing: 0.06em;
}

/* ADV，与娱乐圈 Demo 同构 */
.adv-wrap {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 max(16px, calc(env(safe-area-inset-right) + 12px)) max(12px, calc(env(safe-area-inset-bottom) + 8px)) max(16px, calc(env(safe-area-inset-left) + 12px));
  transition: opacity 260ms ease, transform 260ms ease;
}

.adv-wrap.hide {
  display: none;
}

.adv-wrap[hidden],
.transition-card[hidden],
.primary-action[hidden],
#guide[hidden] {
  display: none !important;
}

.speaker-tab {
  display: inline-block;
  min-width: 82px;
  margin-left: 10px;
  padding: 4px 16px;
  color: #111;
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-align: center;
  border-radius: 7px 7px 0 0;
  background: var(--gold);
}

.adv-wrap.narration .speaker-tab {
  visibility: hidden;
}

.adv-wrap.zero .speaker-tab {
  color: #071323;
  background: var(--blue);
}

.adv-wrap.hero .speaker-tab {
  color: #111;
  background: #f1f1f1;
}

.adv-wrap.shenyan .speaker-tab {
  color: #14110b;
  background: linear-gradient(135deg, #e7d5a3, var(--gold));
}

#adv-box {
  position: relative;
  min-height: 96px;
  padding: 14px 18px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(10, 10, 16, 0.84);
  backdrop-filter: blur(10px);
  cursor: pointer;
}

#line-text {
  min-height: 54px;
  margin: 0;
  color: var(--text);
  font-size: clamp(13px, 1.25vw, 16px);
  line-height: 1.9;
  letter-spacing: 0.04em;
}

.adv-wrap.narration #line-text {
  color: rgba(255, 255, 255, 0.72);
  font-style: italic;
}

#line-text em {
  color: var(--gold);
  font-style: normal;
}

.continue-caret {
  position: absolute;
  right: 14px;
  bottom: 8px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 11px;
  animation: cue 1.2s infinite;
}

/* 选项 */
.choices {
  position: absolute;
  z-index: 64;
  left: 50%;
  top: max(70px, calc(env(safe-area-inset-top) + 62px));
  bottom: max(28px, calc(env(safe-area-inset-bottom) + 18px));
  display: flex;
  flex-direction: column;
  justify-content: safe center;
  gap: 8px;
  width: min(560px, 88vw);
  overflow-y: auto;
  padding: 4px 2px;
  transform: translateX(-50%);
}

.choices.hide {
  opacity: 0;
  pointer-events: none;
}

.choice-prompt {
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: clamp(11px, 1.1vw, 14px);
  letter-spacing: 0.12em;
  text-align: center;
}

.choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 10px 14px;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 10px;
  background: rgba(10, 10, 16, 0.9);
  backdrop-filter: blur(10px);
  animation: choiceIn 320ms var(--ease) backwards;
}

.choice-card:nth-of-type(2) { animation-delay: 50ms; }
.choice-card:nth-of-type(3) { animation-delay: 100ms; }
.choice-card:nth-of-type(4) { animation-delay: 150ms; }

.choice-card:active,
.choice-card:hover {
  color: var(--gold);
  border-color: rgba(255, 212, 121, 0.72);
  background: rgba(28, 24, 14, 0.92);
}

.choice-index {
  color: var(--gold);
  font-family: var(--mono);
  font-size: 10px;
}

.choice-copy {
  flex: 1;
}

.choice-copy b {
  display: block;
  font-size: clamp(12px, 1.18vw, 15px);
  letter-spacing: 0.08em;
}

.choice-copy small {
  display: block;
  margin-top: 3px;
  color: var(--text-soft);
  font-size: 9px;
  line-height: 1.5;
}

.choice-tag {
  flex-shrink: 0;
  padding: 2px 6px;
  color: var(--mint);
  font-size: 8px;
  border: 1px solid rgba(94, 234, 212, 0.42);
  border-radius: 4px;
}

/* 纯黑转场 */
.transition-card {
  position: absolute;
  z-index: 100;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 30px;
  color: #fff;
  text-align: center;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 520ms ease;
}

.transition-card.show {
  opacity: 1;
  pointer-events: auto;
}

.transition-card span {
  color: rgba(255, 255, 255, 0.4);
  font-family: var(--mono);
  font-size: clamp(8px, 0.8vw, 10px);
  letter-spacing: 0.58em;
}

.transition-card strong {
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0.3em;
}

.transition-card p {
  margin: 0;
  color: rgba(255, 255, 255, 0.5);
  font-size: clamp(10px, 1vw, 12px);
  line-height: 1.8;
  letter-spacing: 0.2em;
  white-space: pre-line;
}

.primary-action {
  position: absolute;
  z-index: 68;
  right: max(20px, calc(env(safe-area-inset-right) + 16px));
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  display: none;
  min-width: 174px;
  min-height: 46px;
  padding: 10px 20px;
  color: #15120b;
  font-size: clamp(12px, 1.2vw, 15px);
  font-weight: 700;
  letter-spacing: 0.18em;
  border-radius: 9px;
  background: var(--gold);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
}

.primary-action.show {
  display: block;
}

.primary-action:active {
  transform: scale(0.97);
}

@media (max-width: 900px) {
  #hud {
    gap: 7px;
  }

  .world-route {
    top: max(50px, calc(env(safe-area-inset-top) + 46px));
  }

  .route-head {
    margin-bottom: 6px;
  }

  .route-head h2 {
    font-size: 20px;
  }

  .route-list {
    gap: 6px;
  }

  .route-card > b {
    top: 18%;
    font-size: clamp(18px, 3vw, 24px);
  }

  .contract-file {
    width: min(650px, 76vw);
  }

  #game-container[data-scene="contract"][data-mode="action"] .contract-file {
    max-height: calc(100vh - 112px - env(safe-area-inset-bottom));
  }

  #game-container[data-scene="contract"][data-mode="narration"] .contract-file,
  #game-container[data-scene="contract"][data-mode="dialogue"] .contract-file {
    max-height: calc(100vh - 154px - env(safe-area-inset-bottom));
  }
}

@media (max-height: 520px) {
  .heart-lobby::after {
    background: linear-gradient(180deg, rgba(2, 2, 4, 0.12), transparent 32%, rgba(2, 2, 4, 0.62));
  }

  .zero-bot {
    top: 17%;
    width: clamp(88px, 10vw, 132px);
    height: clamp(132px, 18vw, 210px);
  }

  .shenyan-portrait {
    width: 48vw;
  }

  .shenyan-portrait img {
    object-position: 52% 30%;
  }

  .contract-file {
    top: max(50px, calc(env(safe-area-inset-top) + 46px));
    max-height: calc(100vh - 58px - env(safe-area-inset-bottom));
    padding: 12px 16px;
  }

  #game-container[data-scene="contract"][data-mode="action"] .contract-file {
    max-height: calc(100vh - 112px - env(safe-area-inset-bottom));
  }

  #game-container[data-scene="contract"][data-mode="narration"] .contract-file,
  #game-container[data-scene="contract"][data-mode="dialogue"] .contract-file {
    max-height: calc(100vh - 154px - env(safe-area-inset-bottom));
  }

  .contract-title-row {
    padding: 6px 0 8px;
  }

  .contract-title-row h2 {
    font-size: 18px;
  }

  .contract-clauses {
    gap: 5px;
    margin: 8px 0;
  }

  .contract-clauses li {
    grid-template-columns: 28px 1fr;
    padding: 5px 8px;
    font-size: 10px;
    line-height: 1.45;
  }

  .name-registration {
    margin-top: 8px;
    padding: 10px 12px;
  }

  .name-registration > label {
    margin-bottom: 8px;
    font-size: 13px;
  }

  #walker-name {
    height: 38px;
    font-size: 15px;
  }

  .registration-meta {
    margin-top: 8px;
    padding-top: 7px;
  }

  .chair-seal {
    right: 16px;
    bottom: 12px;
    width: 68px;
    font-size: 10px;
  }

  .route-head span,
  .route-head p {
    display: none;
  }

  .route-card > i {
    top: 7px;
  }

  .route-card > b {
    top: 21%;
  }

  .route-card > em {
    bottom: 39px;
    font-size: 8px;
  }

  .route-card > small {
    bottom: 7px;
    padding: 4px 3px;
    font-size: 7px;
  }

  .mission-brief {
    width: min(700px, 84vw);
    padding: 14px 18px;
  }

  .mission-grid {
    gap: 18px;
    margin-top: 6px;
  }

  .mission-main h2 {
    margin: 4px 0 7px;
    font-size: 21px;
  }

  .mission-main p {
    font-size: 10px;
    line-height: 1.6;
  }

  .mission-brief dl {
    gap: 5px;
  }

  .mission-brief dl div {
    padding-bottom: 4px;
  }

  .mission-brief dd {
    font-size: 10px;
  }

  #guide {
    display: none;
  }

  .adv-wrap {
    padding-bottom: max(8px, calc(env(safe-area-inset-bottom) + 5px));
  }

  .speaker-tab {
    padding: 3px 14px;
    font-size: 11px;
  }

  #adv-box {
    min-height: 82px;
    padding: 10px 15px 8px;
  }

  #line-text {
    min-height: 45px;
    font-size: clamp(12px, 1.85vw, 14px);
    line-height: 1.72;
  }

  .choices {
    top: max(54px, calc(env(safe-area-inset-top) + 50px));
    bottom: max(12px, calc(env(safe-area-inset-bottom) + 8px));
    width: min(540px, 76vw);
  }

  .choice-prompt {
    margin-bottom: 1px;
    font-size: 10px;
  }

  .choice-card {
    min-height: 46px;
    padding: 7px 12px;
  }

  .choice-copy b {
    font-size: 11px;
  }

  .choice-copy small {
    font-size: 8px;
  }
}

@media (max-width: 760px) and (max-height: 420px) {
  .hphase {
    display: none;
  }

  .route-list {
    grid-template-columns: repeat(6, minmax(76px, 1fr));
    overflow-x: auto;
    scrollbar-width: none;
  }

  .route-card > em {
    display: none;
  }

  .contract-file {
    left: max(12px, calc(env(safe-area-inset-left) + 8px));
    width: calc(100vw - 214px);
  }

  .zero-bot {
    right: 6%;
  }


  .shenyan-portrait {
    width: 52vw;
  }

  .mission-brief {
    width: 88vw;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes scan {
  0%, 25% { transform: translateX(-100%); }
  70%, 100% { transform: translateX(100%); }
}

@keyframes pulseRing {
  0%, 100% { opacity: 0.34; transform: translate(-50%, -50%) scale(0.94); }
  50% { opacity: 0.9; transform: translate(-50%, -50%) scale(1.04); }
}

@keyframes drift {
  0%, 100% { transform: translateY(-5px); }
  50% { transform: translateY(7px); }
}

@keyframes float {
  0%, 100% { margin-top: -4px; }
  50% { margin-top: 6px; }
}

@keyframes memoryFlash {
  0%, 100% { opacity: 0.15; filter: blur(2px); transform: translateY(5px); }
  45%, 62% { opacity: 0.88; filter: none; transform: none; }
}

@keyframes sealIn {
  from { opacity: 0; transform: rotate(-10deg) scale(1.45); }
  to { opacity: 1; transform: rotate(-10deg) scale(1); }
}

@keyframes choiceIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes cue {
  0%, 100% { opacity: 0.4; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(3px); }
}

@keyframes toastUp {
  0% { opacity: 0; transform: translateY(8px); }
  12%, 78% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-10px); }
}
