/* =========================================================
   记忆大脑 3D · 头脑特工队总部风格
   紫罗兰夜空 + 奶油纸牌 + 糖果按钮 + 一颗会发光的记忆水晶球
   ========================================================= */

:root {
  /* 总部夜景：和记忆小地图同一套紫罗兰 */
  --sky-1: #140924;
  --sky-2: #22103d;
  --sky-3: #3b1e63;
  --sky-4: #6b3ba0;

  /* 纸牌 */
  --cream: #fffaf0;
  --cream-2: #ffeed6;
  --paper-edge: #ffffff;
  --paper-shade: #e2b57e;

  /* 字 */
  --ink: #4a2c33;
  --ink-soft: #82615a;

  /* 糖 */
  --coral: #ff7f8f;
  --coral-deep: #d8505f;
  --gold: #ffc53f;
  --gold-deep: #e09a1f;
  --mint: #5fd3a4;
  --blue: #58b6e8;
  --violet: #a98bfa;

  /* 水晶球内部 */
  --night-1: #7c60d6;
  --night-2: #563aa8;
  --night-3: #34205f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--sky-2);
  color: var(--ink);
  font-family: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body { overscroll-behavior: none; }
button { font-family: inherit; }

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(10px + env(safe-area-inset-bottom));
  overflow: hidden;
  background:
    radial-gradient(100% 62% at 50% -10%, rgba(255, 106, 190, .34), transparent 64%),
    radial-gradient(64% 46% at 88% 6%, rgba(112, 200, 255, .16), transparent 70%),
    radial-gradient(70% 44% at 6% 34%, rgba(160, 106, 255, .2), transparent 72%),
    linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 16%, var(--sky-2) 32%, var(--sky-3) 58%, var(--sky-4) 100%);
}

/* ---------- 天空装饰 ---------- */
.sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.sun {
  position: absolute;
  left: 50%;
  top: 6%;
  width: min(72vw, 900px);
  aspect-ratio: 1;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 220, .6) 0%, rgba(255, 120, 190, .24) 36%, rgba(255, 120, 190, 0) 68%);
  filter: blur(6px);
}
.cloud {
  position: absolute;
  border-radius: 999px;
  background: rgba(214, 196, 255, .16);
  filter: blur(16px);
  box-shadow: 0 16px 40px rgba(90, 40, 160, .22);
}
.sky::before,
.sky::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  pointer-events: none;
}
.sky::before {
  width: 46vw; height: 46vw;
  left: -8vw; top: -10vw;
  background: radial-gradient(circle, rgba(255, 214, 107, .3), rgba(255, 214, 107, 0) 68%);
}
.sky::after {
  width: 52vw; height: 52vw;
  right: -12vw; bottom: -18vw;
  background: radial-gradient(circle, rgba(255, 143, 190, .34), rgba(255, 143, 190, 0) 68%);
}
.cloud-a { width: 260px; height: 74px; left: -40px; top: 12%; }
.cloud-b { width: 200px; height: 60px; right: -30px; top: 30%; opacity: .8; }
.cloud-c { width: 320px; height: 84px; left: 62%; top: 4%; opacity: .55; }

.orb {
  position: absolute;
  border-radius: 50%;
  opacity: .9;
  box-shadow: inset -4px -6px 12px rgba(120, 60, 90, .22), inset 3px 3px 8px rgba(255, 255, 255, .9), 0 10px 24px rgba(120, 90, 150, .18);
  animation: floatOrb 9s ease-in-out infinite;
}
.orb-a { width: 26px; height: 26px; left: 6%; bottom: 26%; background: radial-gradient(circle at 34% 30%, #fff6c9, var(--gold) 58%, #f09a2c); }
.orb-b { width: 18px; height: 18px; right: 7%; bottom: 34%; background: radial-gradient(circle at 34% 30%, #ffe3ea, var(--coral) 58%, #d8505f); animation-delay: -2.4s; }
.orb-c { width: 14px; height: 14px; left: 12%; top: 16%; background: radial-gradient(circle at 34% 30%, #dff6ff, var(--blue) 58%, #2f89bd); animation-delay: -5s; }
.orb-d { width: 22px; height: 22px; right: 12%; top: 10%; background: radial-gradient(circle at 34% 30%, #eae2ff, var(--violet) 58%, #7455d6); animation-delay: -7s; }
@keyframes floatOrb {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-14px) scale(1.06); }
}

/* ---------- 顶栏：电影片名牌 ---------- */
.top {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 16px 7px 9px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fffdf6, var(--cream-2));
  border: 3px solid var(--paper-edge);
  box-shadow: 0 6px 0 rgba(214, 162, 100, .32), 0 14px 26px rgba(60, 40, 90, .18);
}

.logo {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 22px;
  border-radius: 15px;
  background: radial-gradient(circle at 34% 28%, #fff3c6, var(--gold) 58%, #f39a2e);
  box-shadow: inset -2px -4px 8px rgba(180, 100, 20, .35), inset 2px 2px 6px rgba(255, 255, 255, .8), 0 4px 10px rgba(200, 130, 40, .3);
}

.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: clamp(18px, 2.3vw, 24px);
  font-weight: 900;
  letter-spacing: .01em;
  line-height: 1.15;
  color: var(--ink);
  white-space: nowrap;
}
.badge-3d {
  display: inline-block;
  padding: 1px 6px 2px;
  border-radius: 8px;
  font-size: .58em;
  font-weight: 900;
  letter-spacing: .04em;
  color: #fff8f0;
  background: linear-gradient(180deg, #ff9aa6, var(--coral-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .55), 0 2px 0 rgba(150, 40, 55, .35);
  transform: rotate(-4deg) translateY(-1px);
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.mode {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, #fffdf6, var(--cream-2));
  border: 3px solid var(--paper-edge);
  box-shadow: 0 5px 0 rgba(214, 162, 100, .28), 0 12px 22px rgba(60, 40, 90, .16);
}
.mode button {
  border: 0;
  background: transparent;
  color: #9a7668;
  font-size: 12.5px;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, color .2s, box-shadow .2s, transform .12s;
}
.mode button:active { transform: translateY(1px); }
.mode button[aria-pressed="true"] {
  background: linear-gradient(180deg, #ffe58d, #ffb84d);
  color: #5c3310;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .75), inset 0 -3px 0 rgba(200, 130, 30, .3), 0 3px 8px rgba(210, 140, 40, .3);
}
.mode button[data-mode="ai"][aria-pressed="true"] {
  background: linear-gradient(180deg, #b9ecff, #6bb9f0);
  color: #123a56;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .8), inset 0 -3px 0 rgba(40, 120, 180, .28), 0 3px 8px rgba(60, 140, 200, .3);
}

.icon-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 15px;
  border: 3px solid var(--paper-edge);
  background: linear-gradient(180deg, #fffdf6, var(--cream-2));
  color: #8a6550;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(214, 162, 100, .28), 0 12px 22px rgba(60, 40, 90, .16);
  transition: transform .12s;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(214, 162, 100, .28); }
.icon-btn svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-btn .fs-exit { display: none; }
.icon-btn.is-fs .fs-enter { display: none; }
.icon-btn.is-fs .fs-exit { display: block; }

/* ---------- 记忆水晶球 ---------- */
.stage {
  position: relative;
  z-index: 10;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  border-radius: 34px;
  overflow: hidden;
  background:
    radial-gradient(28% 24% at 18% 22%, rgba(255, 214, 107, .55), transparent 70%),
    radial-gradient(24% 22% at 82% 20%, rgba(120, 235, 255, .5), transparent 70%),
    radial-gradient(30% 26% at 78% 76%, rgba(255, 143, 158, .55), transparent 72%),
    radial-gradient(32% 28% at 20% 74%, rgba(186, 152, 255, .55), transparent 72%),
    radial-gradient(125% 100% at 50% 28%, var(--night-1) 0%, var(--night-2) 46%, var(--night-3) 100%);
  border: 4px solid #ffffff;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, .38),
    0 22px 50px rgba(52, 34, 82, .34),
    inset 0 0 80px rgba(30, 12, 60, .42);
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* 球面反光 */
.stage-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 28% at 30% 12%, rgba(255, 255, 255, .2), transparent 70%),
    radial-gradient(60% 40% at 50% 108%, rgba(255, 180, 120, .16), transparent 70%),
    radial-gradient(100% 100% at 50% 50%, transparent 58%, rgba(20, 6, 40, .34) 100%);
}
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .16), inset 0 18px 40px rgba(255, 255, 255, .07);
}

.deco {
  position: absolute;
  z-index: 13;
  pointer-events: none;
  color: #ffe6a0;
  text-shadow: 0 0 12px rgba(255, 210, 120, .9);
  animation: twinkle 3.4s ease-in-out infinite;
}
.star-a { left: 5%; top: 12%; font-size: 18px; }
.star-b { right: 6%; top: 22%; font-size: 14px; animation-delay: -1.2s; }
.star-c { right: 13%; bottom: 16%; font-size: 20px; animation-delay: -2.3s; }
@keyframes twinkle {
  0%, 100% { opacity: .35; transform: scale(.9) rotate(0deg); }
  50% { opacity: 1; transform: scale(1.12) rotate(12deg); }
}

/* ---------- 3D 标签：奶油小牌 ---------- */
.labels {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: hidden;
}
/* 标签用 left/top 定位，不要放进合成层（translate3d / will-change）：
   合成层会让浏览器放弃次像素抗锯齿（LCD text），DPR=1 的屏幕上字会发灰发糊；
   合成层还会按设备像素重采样，镜头一动字就抖。布局定位每次由排版直接画字。 */
.lbl {
  position: absolute;
  left: -999px;
  top: -999px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  /* 字号比原来的 11.5px 大一点、行高取整：标签叠在 canvas 上只有灰度抗锯齿，
     字太小会显得发虚；不要再靠 transform: scale 放大（会把字重栅格化一遍） */
  font-size: 12.5px;
  line-height: 16px;
  font-weight: 800;
  white-space: nowrap;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf7, #ffe9cd);
  border: 2px solid #fff;
  box-shadow: 0 3px 0 rgba(160, 100, 60, .28), 0 8px 16px rgba(10, 4, 20, .4);
  opacity: 0;
  /* 只过渡透明度；位置每帧跟着 3D 走，加过渡会追不上物体 */
  transition: opacity .35s ease;
}
.lbl::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: inset -1px -2px 3px rgba(120, 30, 45, .45), inset 1px 1px 2px rgba(255, 255, 255, .8);
}
.lbl.brain::before { background: var(--coral); }
.lbl.ai::before { background: var(--blue); }
.lbl.on { opacity: 1; }
.lbl.active {
  background: linear-gradient(180deg, #fff6c9, #ffd979);
  border-color: #fff6d8;
  /* 用外发光强调，不用 transform: scale —— 缩放会把字再栅格化一遍，反而糊 */
  box-shadow:
    0 0 0 3px rgba(255, 246, 200, .40),
    0 0 18px rgba(255, 214, 107, .55),
    0 3px 0 rgba(160, 100, 60, .28),
    0 8px 16px rgba(10, 4, 20, .4);
}
.lbl.active::before { background: #fff; box-shadow: 0 0 8px #fff; }

/* 候选词分数（小屏才出现，3D 卡片上的字太小） */
.lbl.cand {
  font-size: 10.5px;
  padding: 2px 8px;
  border-color: #ffd7dd;
  background: linear-gradient(180deg, #fff7f8, #ffdde3);
}
.lbl.cand::before { display: none; }

/* ---------- 提示 ---------- */
.hint {
  position: absolute;
  left: 16px;
  bottom: 10px;
  margin: 0;
  z-index: 14;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: rgba(255, 238, 220, .72);
  text-shadow: 0 2px 8px rgba(10, 4, 20, .8);
  white-space: nowrap;
  transition: opacity .4s ease;
  pointer-events: none;
}
.hint.off { opacity: 0; }
@media (max-width: 760px), (hover: none) {
  .hint-desk { display: none; }
}
.hint-mob { display: none; }
@media (max-width: 760px), (hover: none) {
  .hint-mob { display: inline; }
}

/* ---------- 点出来的小提示 ---------- */
.tip {
  position: absolute;
  z-index: 24;
  left: 16px;
  bottom: 34px;
  max-width: 230px;
  padding: 9px 12px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffdf7, #ffe9cd);
  border: 2px solid #fff;
  box-shadow: 0 4px 0 rgba(160, 100, 60, .3), 0 14px 28px rgba(10, 4, 20, .45);
  color: #5a3a44;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  pointer-events: auto;
  animation: tipIn .16s ease-out;
}
.tip[hidden] { display: none; }
.tip b {
  display: block;
  margin-bottom: 2px;
  font-size: 12.5px;
  font-weight: 900;
  color: #3a1f2a;
}
.tip .dotline {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 5px;
  border-radius: 50%;
  vertical-align: .1em;
}
.tip-more {
  display: none;
  margin-top: 6px;
  padding: 3px 10px;
  border: 2px solid #ffd9a0;
  border-radius: 999px;
  background: #fff6e6;
  color: #8a5a34;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  pointer-events: auto;
}
.tip-more.on { display: inline-block; }
.stage.tip-on .hint { opacity: 0; }

/* 矮屏（手机横屏 / 小手机）：提示收成一条，贴在底边，别压住情绪小队 */
.tip.mini {
  left: 8px;
  bottom: 4px;
  max-width: min(64%, 260px);
  padding: 5px 9px 6px;
  font-size: 10.5px;
  line-height: 1.45;
}
.tip.mini b {
  display: inline;
  margin-right: 4px;
  font-size: 10.5px;
}
.tip.mini .tip-more {
  margin-top: 2px;
  padding: 1px 8px;
  font-size: 10px;
}
@keyframes tipIn {
  from { opacity: 0; transform: translateY(4px) scale(.96); }
  to { opacity: 1; transform: none; }
}

/* ---------- 底部纸牌 ---------- */
.panel {
  position: relative;
  z-index: 25;
  flex: 0 0 auto;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 11px 20px 14px;
  border-radius: 28px;
  background: linear-gradient(180deg, #fffdf7 0%, var(--cream-2) 100%);
  border: 3px solid var(--paper-edge);
  box-shadow: 0 8px 0 rgba(214, 162, 100, .32), 0 20px 40px rgba(60, 40, 90, .22);
}

.stepbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}
.stepbar i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(226, 174, 108, .3);
  box-shadow: inset 0 1px 2px rgba(150, 90, 40, .2);
  transition: background .25s, box-shadow .25s, transform .25s;
}
.stepbar i.on {
  background: radial-gradient(circle at 34% 28%, #fff8d2, var(--gold) 58%, #f09a2c);
  box-shadow: 0 0 0 2px #fff, 0 0 12px rgba(255, 180, 70, .7);
  transform: scale(1.08);
}
body.ai-mode .stepbar i.on {
  background: radial-gradient(circle at 34% 28%, #e4f8ff, #6fc4f0 58%, #2f8ec4);
  box-shadow: 0 0 0 2px #fff, 0 0 12px rgba(90, 180, 240, .7);
}

.caption {
  margin: 0 auto 10px;
  max-width: 700px;
  min-height: 2.9em;
  text-align: center;
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.62;
  color: var(--ink);
  text-wrap: pretty;
}
.caption b { color: #3a1d24; font-weight: 900; }
.caption .hot {
  color: #b13c28;
  font-weight: 900;
  white-space: nowrap;
  padding: 0 2px;
  background: linear-gradient(transparent 60%, rgba(255, 205, 90, .85) 60%);
  border-radius: 3px;
}
body.ai-mode .caption .hot {
  color: #1d6a92;
  background: linear-gradient(transparent 60%, rgba(140, 215, 255, .8) 60%);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* 糖果按钮：底下有一层实心边，按下去会陷进去 */
.main-btn {
  border: 2px solid #ffb02e;
  border-radius: 999px;
  padding: 11px 38px 13px;
  font-size: 16.5px;
  font-weight: 900;
  letter-spacing: .02em;
  color: #5a3310;
  background: linear-gradient(180deg, #ffe98f 0%, #ffc945 52%, #ffab33 100%);
  box-shadow: 0 5px 0 #d98f1f, 0 12px 22px rgba(217, 143, 31, .36), inset 0 2px 0 rgba(255, 255, 255, .8);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, opacity .15s, filter .2s;
  white-space: nowrap;
}
.main-btn:hover { filter: brightness(1.05); }
.main-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #d98f1f, 0 4px 10px rgba(217, 143, 31, .3), inset 0 2px 0 rgba(255, 255, 255, .8);
}
.main-btn:disabled {
  opacity: .55;
  cursor: default;
  transform: none;
  box-shadow: 0 3px 0 #dfae6f;
  filter: saturate(.7);
}
body.ai-mode .main-btn {
  border-color: #4aa6dd;
  color: #10374f;
  background: linear-gradient(180deg, #d5f4ff 0%, #8ed4f6 52%, #63b8e8 100%);
  box-shadow: 0 5px 0 #3d8dbe, 0 12px 22px rgba(60, 140, 200, .32), inset 0 2px 0 rgba(255, 255, 255, .85);
}
body.ai-mode .main-btn:active {
  box-shadow: 0 1px 0 #3d8dbe, 0 4px 10px rgba(60, 140, 200, .3), inset 0 2px 0 rgba(255, 255, 255, .85);
}
body.ai-mode .main-btn:disabled { box-shadow: 0 3px 0 #7fb4d2; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chips button {
  display: inline-flex;
  align-items: center;
  border: 2px solid #ffe0b0;
  background: linear-gradient(180deg, #ffffff, #fff6e6);
  color: #8a5a34;
  font-size: 11.5px;
  font-weight: 900;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(226, 178, 118, .35);
  transition: transform .12s, box-shadow .12s, border-color .2s, color .2s;
  white-space: nowrap;
}
.chips button:hover { border-color: #ffc35e; color: #6d3f18; }
.chips button:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(226, 178, 118, .35); }
.chips button .k {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: inset -1px -1px 2px rgba(120, 30, 45, .4), inset 1px 1px 2px rgba(255, 255, 255, .7);
  vertical-align: .08em;
}
body.ai-mode .chips button .k { background: var(--blue); }

/* ---------- 开机 ---------- */
.boot {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: radial-gradient(70% 60% at 50% 45%, #6a51bd, #2c1a52 72%);
  transition: opacity .5s ease;
}
.boot.done { opacity: 0; pointer-events: none; }
.boot[hidden] { display: none; }
.boot p {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .06em;
  color: #ffe3b8;
}
.boot-orb {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff7d0, #ffd166 48%, #e08a26 100%);
  box-shadow: 0 0 36px rgba(255, 200, 110, .65), 0 0 90px rgba(255, 180, 90, .3), inset -6px -10px 18px rgba(180, 100, 20, .35);
  animation: bootPulse 1.5s ease-in-out infinite;
}
@keyframes bootPulse {
  0%, 100% { transform: scale(.92); filter: brightness(.92); }
  50% { transform: scale(1.05); filter: brightness(1.12); }
}

/* ---------- 兜底 ---------- */
.fallback {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 70;
  width: min(420px, calc(100% - 40px));
  padding: 26px 24px;
  text-align: center;
  border-radius: 26px;
  background: linear-gradient(180deg, #fffdf7, var(--cream-2));
  border: 3px solid #fff;
  box-shadow: 0 8px 0 rgba(214, 162, 100, .32), 0 24px 50px rgba(60, 40, 90, .28);
  color: var(--ink);
}
.fallback h2 { margin: 0 0 8px; font-size: 20px; font-weight: 900; }
.fallback p { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.7; }
.fallback a {
  display: inline-block;
  padding: 9px 20px 11px;
  border-radius: 999px;
  border: 2px solid #ffb02e;
  background: linear-gradient(180deg, #ffe98f, #ffc945);
  color: #5a3310;
  font-weight: 900;
  font-size: 13.5px;
  text-decoration: none;
  box-shadow: 0 4px 0 #d98f1f;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: grid;
  place-content: center;
  background: var(--sky-2);
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

/* ---------- 资料卡 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 20, 46, .58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.modal-card {
  position: relative;
  width: min(460px, 100%);
  max-height: 84dvh;
  overflow-y: auto;
  padding: 24px 24px 20px;
  border-radius: 28px;
  background: linear-gradient(180deg, #fffdf7, var(--cream-2));
  border: 3px solid #fff;
  box-shadow: 0 9px 0 rgba(214, 162, 100, .32), 0 28px 60px rgba(40, 20, 50, .45);
  color: var(--ink);
  animation: cardIn .22s cubic-bezier(.34, 1.4, .64, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #ffe0b0;
  background: #fff8ec;
  color: #9a6a44;
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}
.modal-kicker {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  color: #8a4a1a;
  background: #ffe3ad;
}
.modal-card h2 {
  margin: 8px 0 10px;
  font-size: 22px;
  font-weight: 900;
  color: #3a1f2a;
}
.modal-line { margin: 0 0 12px; font-size: 14.5px; line-height: 1.85; color: #5a3a44; }
.modal-example {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff3d9;
  border: 2px dashed #ffd08a;
  font-size: 13px;
  line-height: 1.8;
  color: #6a4436;
}
.modal-ok {
  width: 100%;
  border: 2px solid #ffb02e;
  border-radius: 999px;
  padding: 10px 10px 12px;
  font-size: 14.5px;
  font-weight: 900;
  color: #5a3310;
  background: linear-gradient(180deg, #ffe98f, #ffc945);
  box-shadow: 0 4px 0 #d98f1f, inset 0 2px 0 rgba(255, 255, 255, .8);
  cursor: pointer;
}
body.ai-mode .modal-ok {
  border-color: #4aa6dd;
  color: #10374f;
  background: linear-gradient(180deg, #d5f4ff, #8ed4f6);
  box-shadow: 0 4px 0 #3d8dbe, inset 0 2px 0 rgba(255, 255, 255, .85);
}

/* 情绪小队：弹层里的五个小牌 */
.modal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 18px;
}
.modal-list[hidden] { display: none; }
.mood-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 16px;
  border: 2px solid #ffe3bb;
  background: #fffdf6;
  color: #5a3a44;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: transform .12s, border-color .2s, background .2s, box-shadow .15s;
  box-shadow: 0 3px 0 rgba(226, 178, 118, .3);
}
.mood-row:hover { border-color: var(--c); background: #fff8e8; }
.mood-row:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(226, 178, 118, .3); }
.mood-row .dot {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #fff, var(--c) 55%, color-mix(in srgb, var(--c) 70%, #2a1020) 100%);
  box-shadow: inset -2px -3px 5px rgba(80, 30, 50, .25), 0 0 10px var(--c);
}
.mood-row b { color: #3a1f2a; font-weight: 900; white-space: nowrap; }
.mood-row .mtxt { color: #7a5a52; font-weight: 600; }

/* ---------- 窄屏 ---------- */
@media (max-width: 760px) {
  #app { gap: 8px; padding: calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom)); }
  .stage { border-radius: 26px; border-width: 3px; box-shadow: 0 0 0 4px rgba(255, 255, 255, .38), 0 16px 34px rgba(52, 34, 82, .3), inset 0 0 70px rgba(10, 4, 20, .5); }
  .logo { width: 38px; height: 38px; font-size: 19px; border-radius: 13px; }
  .brand { padding: 6px 12px 6px 7px; border-radius: 19px; }
  .brand-text h1 { font-size: 17.5px; }
  .brand-text p { font-size: 10.5px; max-width: 168px; }
  .mode { padding: 3px; }
  .mode button { font-size: 11.5px; padding: 5px 9px; }
  .icon-btn { width: 40px; height: 40px; border-radius: 13px; }
  .icon-btn svg { width: 17px; height: 17px; }
  .panel { padding: 9px 14px 12px; border-radius: 24px; box-shadow: 0 6px 0 rgba(214, 162, 100, .3), 0 16px 32px rgba(60, 40, 90, .2); }
  .caption { font-size: 13.5px; min-height: 3.1em; margin-bottom: 8px; }
  .main-btn { font-size: 14.5px; padding: 8px 24px 10px; }
  .chips button { font-size: 10.5px; padding: 4px 8px; }
  .lbl { font-size: 10px; padding: 3px 8px 3px 6px; border-width: 2px; }
  .hint {
    left: 12px;
    right: auto;
    bottom: 8px;
    text-align: left;
    font-size: 10px;
    max-width: 58%;
    white-space: normal;
  }
  .deco { display: none; }
}

@media (max-width: 430px) {
  .brand-text p { display: none; }
  .actions { gap: 8px; }
  .chips { order: 2; width: 100%; }
  .caption { font-size: 13px; }
  .stage { border-radius: 22px; }
}

@media (max-width: 380px) {
  .top { gap: 6px; }
  .brand { gap: 6px; padding: 4px 8px 4px 5px; border-width: 2px; }
  .logo { width: 30px; height: 30px; font-size: 16px; border-radius: 10px; }
  .brand-text h1 { font-size: 15px; gap: 3px; }
  .badge-3d { display: none; }
  .top-actions { gap: 4px; }
  .mode { padding: 2px; }
  .mode button { font-size: 10.5px; padding: 4px 6px; }
  .icon-btn { width: 34px; height: 34px; border-radius: 11px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .lbl { font-size: 9px; padding: 2px 6px 2px 5px; border-width: 2px; }
}

@media (max-height: 600px) and (orientation: landscape) {
  #app { gap: 6px; padding: 6px 10px; }
  .brand { padding: 4px 12px 4px 6px; box-shadow: 0 4px 0 rgba(214, 162, 100, .3); }
  .logo { width: 32px; height: 32px; font-size: 17px; border-radius: 11px; }
  .brand-text h1 { font-size: 16px; }
  .brand-text p { display: none; }
  .mode button { font-size: 11px; padding: 4px 8px; }
  .icon-btn { width: 34px; height: 34px; border-radius: 11px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .stage { border-radius: 22px; }
  .panel { padding: 7px 14px 9px; border-radius: 22px; }
  .stepbar { margin-bottom: 4px; }
  .stepbar i { width: 8px; height: 8px; }
  .caption { min-height: 0; margin-bottom: 6px; font-size: 12.5px; line-height: 1.5; }
  .main-btn { padding: 6px 20px 8px; font-size: 13.5px; box-shadow: 0 4px 0 #d98f1f, inset 0 2px 0 rgba(255, 255, 255, .8); }
  .chips button { padding: 3px 8px; font-size: 10px; }
  .hint, .deco { display: none; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .modal { padding: 8px; }
  .ag-card { padding: 9px 18px 8px; max-height: 98dvh; }
  .ag-card .modal-kicker { font-size: 9.5px; padding: 2px 8px; }
  .ag-card h2 { margin: 3px 0 5px; font-size: 17px; }
  .ag-card .modal-line { display: none; }
  .ag-desc { display: none; }
  .ag-sentence { margin: 0 0 5px; font-size: 13.5px; line-height: 1.5; }
  .ag-opt { min-width: 78px; padding: 4px 9px 5px; font-size: 12.5px; gap: 2px; }
  .ag-opt .meter i { min-width: 26px; }
  .ag-tabs { margin-bottom: 6px; padding: 3px; }
  .ag-tabs button { padding: 4px 8px 5px; font-size: 11px; }
  .ag-desc { margin: 0 0 7px; font-size: 11.5px; line-height: 1.5; }
  .ag-slot { min-width: 34px; min-height: 34px; font-size: 10.5px; }
  .ag-dump { margin-top: 6px; padding: 4px 8px; }
  .ag-actions { margin-top: 5px; gap: 7px; }
  .ag-btn { padding: 5px 13px 6px; font-size: 12px; }
  .ag-result { margin-top: 5px; font-size: 10.5px; line-height: 1.45; }
  .ag-result.show { padding: 3px 8px; }
  .ag-card .modal-actions { margin-top: 5px; gap: 7px; }
  .ag-card .modal-ok, .ag-card .modal-read { padding: 6px 11px 7px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-orb, .orb, .deco { animation: none; }
  .modal-card { animation: none; }
}

/* ---------- 🎮 你来当 AI ---------- */
.ai-play {
  display: none;
  border: 2px solid #a8ddf6;
  border-radius: 999px;
  padding: 8px 16px 10px;
  font-size: 13px;
  font-weight: 900;
  color: #1d5f82;
  background: linear-gradient(180deg, #eefaff, #c9ecff);
  box-shadow: 0 4px 0 rgba(110, 170, 205, .45), inset 0 2px 0 rgba(255, 255, 255, .9);
  cursor: pointer;
  white-space: nowrap;
  transition: transform .12s, box-shadow .12s, filter .2s;
}
body.ai-mode .ai-play { display: inline-flex; align-items: center; }
.ai-play:hover { filter: brightness(1.04); }
.ai-play:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(110, 170, 205, .45); }

.ag-card { width: min(560px, 100%); }
.ag-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 14px;
  padding: 4px;
  border-radius: 999px;
  background: #ffeed6;
  border: 2px solid #ffe0b0;
}
.ag-tabs button {
  flex: 1;
  padding: 7px 10px 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #9a6a44;
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
}
.ag-tabs button.on {
  color: #10374f;
  background: linear-gradient(180deg, #eefaff, #bfe8ff);
  box-shadow: 0 3px 0 rgba(110, 170, 205, .4), inset 0 1px 0 #fff;
}
.ag-desc { margin: 0 0 12px; font-size: 13px; line-height: 1.75; color: #6a4a52; }
.ag-slots { display: flex; flex-wrap: wrap; gap: 7px; }
.ag-slot {
  flex: 1 1 0;
  min-width: 48px;
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 4px 6px;
  font-size: 13px;
  font-weight: 900;
  color: #b9a9d2;
  background: repeating-linear-gradient(135deg, #fff3e0 0 6px, #ffe9cf 6px 12px);
  border: 2px dashed #e9c79c;
  border-radius: 13px;
  transition: background .2s, border-color .2s;
}
.ag-slot.filled {
  color: #10374f;
  background: linear-gradient(180deg, #ffffff, #e8f6ff);
  border: 2px solid #8ed4f6;
  box-shadow: 0 3px 0 rgba(80, 150, 190, .3);
  animation: cardIn .2s ease;
}
.ag-dump {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 7px 10px;
  border-radius: 13px;
  background: linear-gradient(180deg, #3a2440, #241428);
  border: 1px solid rgba(255, 255, 255, .16);
}
.ag-dump > span { flex: none; font-size: 10.5px; font-weight: 900; color: #c3a9d0; }
.ag-dump-items { display: flex; flex-wrap: wrap; gap: 5px; min-height: 20px; }
.ag-dump-items span {
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
  color: #f2e7ff;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
}
.ag-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 12px; }
.ag-btn {
  border: 2px solid #4aa6dd;
  border-radius: 999px;
  padding: 8px 18px 10px;
  font-size: 13.5px;
  font-weight: 900;
  color: #10374f;
  background: linear-gradient(180deg, #d5f4ff, #8ed4f6 52%, #63b8e8);
  box-shadow: 0 4px 0 #3d8dbe, inset 0 2px 0 rgba(255, 255, 255, .85);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s, filter .2s;
}
.ag-btn:hover { filter: brightness(1.04); }
.ag-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #3d8dbe; }
.ag-btn:disabled { opacity: .5; cursor: default; filter: saturate(.7); box-shadow: 0 3px 0 #7fb4d2; }
.ag-question { margin: 0 0 8px; font-size: 14.5px; font-weight: 900; color: #3a1f2a; }
.ag-result { margin: 10px 0 0; font-size: 12.5px; line-height: 1.7; color: #6a4a52; }
.ag-result.show {
  background: #fff3d9;
  border: 2px dashed #ffd08a;
  border-radius: 14px;
  padding: 9px 12px;
}
.ag-sentence {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.75;
  color: #3a1f2a;
}
.ag-options { display: flex; flex-wrap: wrap; gap: 8px; }
.ag-opt {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
  min-width: 96px;
  padding: 8px 12px 9px;
  font-size: 15px;
  font-weight: 900;
  color: #2f5568;
  background: linear-gradient(180deg, #ffffff, #eef8ff);
  border: 2px solid #c3e7f7;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(110, 170, 205, .35);
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.ag-opt:hover { transform: translateY(-1px); border-color: #8ccfe9; }
.ag-opt:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(110, 170, 205, .35); }
.ag-opt:disabled { cursor: default; }
.ag-opt .word { text-align: center; }
.ag-opt .meter { display: flex; align-items: center; gap: 5px; opacity: 0; transition: opacity .3s; }
.ag-opt.scored .meter { opacity: 1; }
.ag-opt .meter i {
  display: block;
  flex: 1;
  min-width: 30px;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #8ed4f6, #4aa6dd);
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
}
.ag-opt .meter b { font-size: 10.5px; font-weight: 900; color: #2f5568; }
.ag-opt.top { border-color: #4aa6dd; box-shadow: 0 0 0 2px rgba(111, 212, 255, .55), 0 3px 0 rgba(110, 170, 205, .35); }
.ag-opt.top .meter i { background: linear-gradient(90deg, #ffd75e, #f0a11f); }
.ag-opt.correct { border-color: #79c466; background: linear-gradient(180deg, #effce9, #d7f4cc); }
.ag-opt.wrong { border-color: #e08585; background: linear-gradient(180deg, #fff0f0, #ffdada); }


@media (max-width: 430px) {
  .ag-card { padding: 20px 16px 16px; }
  .ag-card .modal-line { display: none; }
  .ag-tabs { margin-bottom: 10px; }
  .ag-desc { margin-bottom: 9px; font-size: 12px; line-height: 1.6; }
  .ag-slot { min-width: 38px; min-height: 36px; font-size: 12px; }
  .ag-dump { margin-top: 7px; padding: 4px 8px; }
  .ag-actions { margin-top: 8px; }
  .ag-sentence { margin-bottom: 9px; font-size: 15.5px; }
  .ag-opt { min-width: 68px; padding: 6px 8px 7px; font-size: 13.5px; }
  .ag-opt .meter { gap: 4px; }
  .ag-opt .meter i { min-width: 22px; }
  .ag-result { font-size: 11.5px; line-height: 1.6; }
  .ag-card h2 { font-size: 20px; }
  #agScore .ag-desc { display: none; }
  .ag-card .modal-actions { flex-direction: row; gap: 7px; }
  .ag-card .modal-read { width: auto; flex: 0 0 auto; padding: 7px 11px 8px; }
  .ag-card .modal-ok { width: auto; flex: 1 1 auto; padding: 7px 11px 8px; }
  .ag-tabs button { padding: 5px 8px 6px; font-size: 11.5px; }
}

/* ---------- 声音按钮 / 朗读 ---------- */
.icon-btn .snd-off { display: none; }
.icon-btn.is-off .snd-on { display: none; }
.icon-btn.is-off .snd-off { display: block; }

.modal-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 2px;
}
.modal-actions .modal-ok { flex: 1 1 auto; width: auto; }
.modal-read {
  flex: 0 0 auto;
  border: 2px solid #ffd08a;
  border-radius: 999px;
  padding: 10px 16px 12px;
  font-size: 13.5px;
  font-weight: 900;
  color: #8a4a1a;
  background: #fff6e3;
  box-shadow: 0 4px 0 rgba(215, 160, 90, .35);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.modal-read:hover { background: #fff0d4; }
.modal-read:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(215, 160, 90, .35); }
body.ai-mode .modal-read {
  border-color: #a8ddf6;
  color: #1d5f82;
  background: #eefaff;
  box-shadow: 0 4px 0 rgba(110, 170, 205, .35);
}

@media (max-width: 380px) {
  .modal-actions { flex-direction: column; }
  .modal-actions .modal-ok { width: 100%; }
  .modal-read { width: 100%; }
}

/* ---------- 小电影入口 ---------- */
.movie-link {
  display: inline-flex;
  align-items: center;
  margin: 2px 0 0;
  padding: 7px 16px 8px;
  border-radius: 999px;
  border: 2px solid #ff9aae;
  background: #fff2f4;
  color: #c2455a;
  font-size: 12.5px;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 3px 0 #f3c3cc;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.movie-link:hover { background: #ffe6ea; }
.movie-link:active { transform: translateY(2px); box-shadow: 0 1px 0 #f3c3cc; }
