:root {
  --anim-fast: 180ms;
  --anim-normal: 320ms;
  --anim-slow: 550ms;
  --ink: #243246;
  --paper: #fffaf1;
  --wall: #f4e3c4;
  --wall-deep: #e7cda3;
  --floor: #d7b07a;
  --aqua: #7ee0d0;
  --aqua-deep: #2fb7b0;
  --magic: #b197fc;
  --robot: #5ec8ff;
  --robot-line: #2a4d6e;
}

html,
body,
#game-root,
.game-viewport {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #241c16;
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.game-viewport {
  position: relative;
  overflow: hidden;
}

.game-chrome {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.game-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  overflow: hidden;
  background: var(--wall);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  isolation: isolate;
}

.layer-background { z-index: 1; }
.layer-environment { z-index: 2; }
.layer-character { z-index: 3; }
.layer-effect { z-index: 4; }
.layer-dialogue { z-index: 5; }
.layer-interaction { z-index: 6; }
.layer-hud { z-index: 7; }

.scene-background,
.bg-ai-lab {
  position: absolute;
  inset: 0;
}

.lab-wall {
  position: absolute;
  inset: 0 0 400px 0;
  background:
    linear-gradient(180deg, #f8ead0 0%, var(--wall) 58%, var(--wall-deep) 100%);
}

.lab-wall::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.35), transparent 22%),
    radial-gradient(circle at 78% 18%, rgba(177, 151, 252, 0.16), transparent 26%);
}

.lab-floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 400px;
  background:
    linear-gradient(180deg, #e8c58d 0%, var(--floor) 32%, #c49255 100%);
}

.lab-floor-grid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 400px;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 86px,
      rgba(120, 72, 28, 0.08) 86px 88px
    );
  opacity: 0.7;
}

.lab-strip {
  position: absolute;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--aqua), var(--magic), var(--aqua), transparent);
  box-shadow: 0 0 18px rgba(126, 224, 208, 0.8);
}

.lab-strip-top {
  top: 110px;
  left: 48px;
  right: 48px;
}

.lab-strip-mid {
  top: 210px;
  left: 72px;
  width: 220px;
  opacity: 0.7;
}

.lab-window {
  position: absolute;
  left: 56px;
  top: 170px;
  width: 300px;
  height: 240px;
  border-radius: 36px;
  overflow: hidden;
  box-shadow:
    0 0 0 14px #f7efe0,
    0 0 0 20px #c9a36a,
    0 18px 30px rgba(80, 50, 20, 0.18);
}

.lab-sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #8fd4f2 0%, #ffe7b3 100%);
}

.lab-hill {
  position: absolute;
  left: -20px;
  right: -20px;
  bottom: 0;
  height: 70px;
  background: #8ec07c;
  border-radius: 80% 80% 0 0;
}

.lab-window-bars {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(#d7b48a, #d7b48a) center / 12px 100% no-repeat,
    linear-gradient(#d7b48a, #d7b48a) center / 100% 12px no-repeat;
  opacity: 0.85;
}

.lab-cable {
  position: absolute;
  border: 8px solid #f09f9c;
  border-radius: 80px;
  border-bottom: none;
  border-left: none;
  opacity: 0.8;
}

.lab-cable-a {
  width: 160px;
  height: 110px;
  right: 90px;
  top: 96px;
  border-color: #86c5ff;
}

.lab-cable-b {
  width: 110px;
  height: 80px;
  right: 36px;
  top: 160px;
  border-color: #ffb3c7;
}

.lab-machine {
  position: absolute;
  background: #f6eee0;
  border: 6px solid #c9a36a;
  box-shadow: 0 10px 0 #e7cda3;
}

.lab-machine-a {
  right: 48px;
  bottom: 1180px;
  width: 86px;
  height: 112px;
  border-radius: 28px 28px 18px 18px;
  opacity: 0.82;
}

.lab-machine-b {
  right: 150px;
  bottom: 1210px;
  width: 72px;
  height: 86px;
  border-radius: 24px;
  opacity: 0.78;
}

.lab-machine-head,
.lab-machine-dish {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: #d7eeff;
  border: 5px solid #c9a36a;
}

.lab-machine-head {
  top: -28px;
  width: 54px;
  height: 36px;
  border-radius: 18px;
}

.lab-machine-dish {
  top: -34px;
  width: 70px;
  height: 24px;
  border-radius: 50%;
}

.lab-machine-light {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  left: 18px;
  bottom: 18px;
  background: var(--aqua);
  box-shadow: 0 0 12px var(--aqua);
}

.lab-shelf {
  position: absolute;
  left: 80px;
  right: 80px;
  bottom: 400px;
  height: 18px;
  background: #c9a36a;
  border-radius: 10px;
  opacity: 0.55;
}

.lab-lamp-glow {
  position: absolute;
  left: 50%;
  top: 0;
  width: 640px;
  height: 220px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at top, rgba(255, 249, 220, 0.55), transparent 70%);
  pointer-events: none;
}

.env-item {
  position: absolute;
  transform: translateX(-50%);
}

.env-lab-lamp {
  width: 120px;
  height: 140px;
}

.lamp-fixture {
  width: 84px;
  height: 28px;
  margin: 0 auto;
  background: #d7b07a;
  border-radius: 0 0 18px 18px;
}

.lamp-beam {
  width: 120px;
  height: 90px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(255, 244, 180, 0.35), transparent);
  clip-path: polygon(30% 0, 70% 0, 100% 100%, 0 100%);
}

.character,
.prop {
  position: absolute;
  transform: translateX(-50%) scale(var(--character-scale, var(--prop-scale, 1)));
  transform-origin: center bottom;
  pointer-events: auto;
}

.character.is-hidden,
.prop.is-hidden,
.speech-bubble.is-hidden {
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
}

.character-anim,
.character-body,
.q01-svg {
  width: 100%;
  height: 100%;
}

.character-body img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
}

.character-body {
  transform-origin: center bottom;
}

.q01-svg {
  overflow: visible;
}

.q01-pose {
  transform-origin: 110px 348px;
  transform: rotate(-2.4deg);
}

.q01-shadow {
  fill: rgba(72, 102, 128, 0.16);
}

.q01-head-shell,
.q01-body-shell,
.q01-arm rect,
.q01-leg rect,
.q01-arm circle {
  fill: var(--robot);
  stroke: var(--robot-line);
  stroke-width: 5;
}

.q01-face {
  fill: #fff7ea;
  stroke: none;
}

.q01-chest {
  fill: #3aa4e6;
  stroke: var(--robot-line);
  stroke-width: 5;
}

.q01-qring circle,
.q01-qring path {
  fill: none;
  stroke: #ffe56a;
  stroke-width: 5;
  stroke-linecap: round;
}

.q01-dot-pink {
  fill: #ff8fab;
  stroke: none;
}

.q01-antenna-stem {
  fill: none;
  stroke: #ff8fab;
  stroke-width: 8;
  stroke-linecap: round;
}

.q01-antenna {
  fill: #ff8fab;
  stroke: var(--robot-line);
  stroke-width: 4;
}

.q01-cheek {
  fill: #ffb3c1;
  opacity: 0;
}

.q01-eye {
  fill: #fff;
  stroke: var(--robot-line);
  stroke-width: 5;
}

.q01-pupil {
  fill: var(--robot-line);
}

.q01-shine {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
}

.q01-mouth,
.q01-eyes-happy path,
.q01-eyes-excited path,
.q01-eyes-proud path {
  fill: none;
  stroke: var(--robot-line);
  stroke-width: 6;
  stroke-linecap: round;
}

.q01-eyes-happy path,
.q01-eyes-excited path,
.q01-eyes-proud path {
  stroke-width: 7;
}

.q01-eyes,
.q01-mouth {
  display: none;
}

.character[data-emotion="normal"] .q01-eyes-normal,
.character[data-emotion="normal"] .q01-mouth-normal,
.character[data-emotion="happy"] .q01-eyes-happy,
.character[data-emotion="happy"] .q01-mouth-happy,
.character[data-emotion="proud"] .q01-eyes-proud,
.character[data-emotion="proud"] .q01-mouth-proud,
.character[data-emotion="confused"] .q01-eyes-confused,
.character[data-emotion="confused"] .q01-mouth-confused,
.character[data-emotion="surprised"] .q01-eyes-surprised,
.character[data-emotion="surprised"] .q01-mouth-surprised,
.character[data-emotion="excited"] .q01-eyes-excited,
.character[data-emotion="excited"] .q01-mouth-excited {
  display: block;
}

.character[data-emotion="happy"] .q01-cheek,
.character[data-emotion="surprised"] .q01-cheek,
.character[data-emotion="excited"] .q01-cheek {
  opacity: 1;
}

.character[data-emotion="proud"] .q01-pose {
  transform: rotate(-8deg);
}

.speech-bubble {
  position: absolute;
  min-width: 220px;
  max-width: 780px;
  padding: 28px 34px 26px;
  background: var(--paper);
  border: 5px solid var(--ink);
  border-radius: 36px;
  color: var(--ink);
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 48px;
  line-height: 1.35;
  pointer-events: auto;
  filter: drop-shadow(0 10px 0 rgba(36, 50, 70, 0.08));
}

.speech-bubble-text {
  min-height: 1.35em;
  word-break: break-word;
}

.speech-bubble-tail {
  position: absolute;
  width: 20px;
  height: 20px;
  background: var(--paper);
  border-right: 4px solid var(--ink);
  border-bottom: 4px solid var(--ink);
  transform: rotate(45deg);
  bottom: -12px;
}

.speech-bubble[data-tail="left"] .speech-bubble-tail {
  left: 36px;
}

.speech-bubble[data-tail="right"] .speech-bubble-tail {
  right: 36px;
}

.speech-bubble[data-type="thought"] {
  border-radius: 46px;
}

.speech-bubble[data-type="thought"] .speech-bubble-tail {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  transform: none;
  bottom: -22px;
}

.speech-bubble[data-type="thought"] .speech-bubble-tail::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  left: -18px;
  bottom: -14px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 50%;
}

.speech-bubble[data-type="shout"] {
  border-radius: 10px;
  font-weight: 700;
  transform: rotate(-2deg);
}

.speech-bubble[data-type="whisper"] {
  border-style: dashed;
  font-size: 40px;
  opacity: 0.92;
}

.prop-ai-board {
  width: 860px;
  height: 680px;
  z-index: 0;
}

.board-base {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 260px;
  height: 40px;
  transform: translateX(-50%);
  background: #c9a36a;
  border-radius: 18px;
  box-shadow: 0 10px 0 #b1874e;
}

.board-column {
  position: absolute;
  left: 50%;
  bottom: 32px;
  width: 40px;
  height: 90px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #efe0c4, #c9a36a);
  border-radius: 18px;
}

.board-screen {
  position: absolute;
  left: 50%;
  bottom: 110px;
  width: 800px;
  height: 460px;
  transform: translateX(-50%);
}

.board-glow {
  position: absolute;
  inset: -18px;
  border-radius: 42px;
  background: radial-gradient(circle, rgba(126, 224, 208, 0.35), transparent 70%);
}

.board-glass {
  position: absolute;
  inset: 0;
  border-radius: 36px;
  background: linear-gradient(180deg, #f7fbff 0%, #d9ecff 100%);
  border: 10px solid #f4efe4;
  box-shadow:
    0 0 0 8px var(--aqua-deep),
    0 18px 0 rgba(43, 79, 110, 0.12),
    0 0 34px rgba(126, 224, 208, 0.45);
  overflow: hidden;
}

.board-icon {
  position: absolute;
  inset: 0;
  display: none;
}

.prop-ai-board[data-state="idle"] .board-icon-idle,
.prop-ai-board[data-state="listening"] .board-icon-listen,
.prop-ai-board[data-state="drawing"] .board-icon-draw,
.prop-ai-board[data-state="result"] .board-icon-result,
.prop-ai-board[data-state="error"] .board-icon-error {
  display: block;
}

.board-icon-idle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 84px;
  height: 84px;
  transform: translate(-50%, -50%);
  border: 8px solid #9ad8ff;
  border-radius: 24px;
  box-shadow: 12px 12px 0 #b197fc;
}

.board-icon-listen::before,
.board-icon-listen::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border: 6px solid #2fb7b0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.board-icon-listen::before {
  width: 70px;
  height: 70px;
}

.board-icon-listen::after {
  width: 110px;
  height: 110px;
  opacity: 0.45;
}

.board-icon-draw span {
  position: absolute;
  height: 10px;
  border-radius: 999px;
  background: #5ec8ff;
}

.board-icon-draw span:nth-child(1) {
  top: 130px;
  left: 90px;
  width: 360px;
  background: #5ec8ff;
}

.board-icon-draw span:nth-child(2) {
  top: 210px;
  left: 150px;
  width: 280px;
  background: #b197fc;
}

.board-icon-draw span:nth-child(3) {
  top: 290px;
  left: 120px;
  width: 400px;
  background: #ffb3c7;
}

.board-icon-result i {
  position: absolute;
  border-radius: 24px;
}

.board-icon-result i:nth-child(1) {
  left: 80px;
  top: 70px;
  width: 120px;
  height: 90px;
  background: #8fd4f2;
}

.board-icon-result i:nth-child(2) {
  left: 210px;
  top: 90px;
  width: 90px;
  height: 120px;
  background: #ffe56a;
}

.board-icon-result i:nth-child(3) {
  left: 130px;
  top: 160px;
  width: 150px;
  height: 70px;
  background: #b197fc;
}

.board-icon-error::before,
.board-icon-error::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 140px;
  height: 14px;
  background: #ff6b7d;
  border-radius: 8px;
}

.board-icon-error::before { transform: translate(-50%, -50%) rotate(32deg); }
.board-icon-error::after { transform: translate(-50%, -50%) rotate(-32deg); }

.prop-ai-board[data-state="drawing"] .board-glass {
  box-shadow:
    0 0 0 8px #7ee0d0,
    0 0 42px rgba(126, 224, 208, 0.9);
}

.prop-ai-board[data-state="result"] .board-glass {
  box-shadow:
    0 0 0 8px #b197fc,
    0 0 42px rgba(177, 151, 252, 0.8);
}

.prop-ai-board[data-state="error"] .board-glass {
  box-shadow:
    0 0 0 8px #ff6b7d,
    0 0 42px rgba(255, 107, 125, 0.7);
}

.prop-ai-board[data-state="listening"] .board-glass {
  box-shadow:
    0 0 0 8px #5ec8ff,
    0 0 36px rgba(94, 200, 255, 0.8);
}

.prop-mission-note {
  width: 180px;
  height: 200px;
}

.note-magnet {
  position: absolute;
  left: 50%;
  top: -8px;
  width: 34px;
  height: 34px;
  transform: translateX(-50%);
  background: #ff6b7d;
  border-radius: 50%;
  box-shadow: 0 4px 0 #d94861;
  z-index: 2;
}

.note-paper {
  position: absolute;
  inset: 0;
  background: #fff3a0;
  border-radius: 6px 6px 18px 6px;
  transform: rotate(-8deg);
  box-shadow: 8px 10px 0 rgba(80, 50, 20, 0.12);
  padding: 28px 16px 16px;
}

.note-title,
.note-line {
  height: 10px;
  background: #e0c45a;
  border-radius: 999px;
  margin-bottom: 12px;
}

.note-title {
  width: 72%;
  height: 12px;
}

.note-line.short {
  width: 54%;
}

.note-star {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 18px;
  height: 18px;
  background: #ff8fab;
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.hud-volume,
.hud-debug {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  width: 44px;
  height: 44px;
  border: 2px solid rgba(36, 50, 70, 0.35);
  border-radius: 50%;
  background: rgba(255, 250, 241, 0.86);
  color: var(--ink);
  pointer-events: auto;
  cursor: pointer;
  z-index: 9;
  -webkit-tap-highlight-color: transparent;
}

.hud-volume {
  left: calc(12px + env(safe-area-inset-left, 0px));
}

.hud-debug {
  right: calc(12px + env(safe-area-inset-right, 0px));
  font: 700 16px/44px ui-monospace, Consolas, monospace;
}

.hud-debug.is-active {
  background: #2b241f;
  color: #f4efe4;
}

.hud-volume.is-muted {
  opacity: 0.45;
}

.interaction-hit {
  position: absolute;
  border: 4px dashed rgba(47, 183, 176, 0.9);
  background: rgba(126, 224, 208, 0.12);
  border-radius: 24px;
  pointer-events: auto;
  cursor: pointer;
}

.choice-list {
  position: absolute;
  left: 50%;
  bottom: 56px;
  width: 88%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 18px;
  pointer-events: auto;
}

.choice-button {
  min-height: 88px;
  padding: 20px 28px;
  border: 5px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  color: var(--ink);
  font-size: 42px;
  cursor: pointer;
}

.scene-veil {
  position: absolute;
  inset: 0;
  background: #1b1410;
  opacity: 0;
  pointer-events: none;
}

.effect {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
