*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* base（既有，沿用） */
  --bg: #14121b;
  --card: #1e1b2b;
  --line: #3f3a52;
  --text: #f5f3ff;
  --muted: #d7d1ff;
  --accent: #ffb24f;
  --good: #79d7a3;
  --bad: #ff7e92;

  /* ── 主題「霓虹夜市」一致性 token（批次①打底；未被引用前視覺不變） ── */
  /* 表面三階（收斂散落的近似深紫底） */
  --surface-1: #1e1b2b;
  --surface-2: #171327;
  --surface-inset: #120f1f;
  --line-soft: rgba(255, 255, 255, 0.12);
  /* 主色：單一橘 + 單一漸層 + 單一前景色 */
  --primary: #ffb24f;
  --primary-2: #f6913c;
  --grad-primary: linear-gradient(180deg, var(--primary), var(--primary-2));
  --on-primary: #2a1500;
  /* 語意色前景 */
  --on-good: #03301a;
  --on-bad: #4a0f1a;
  /* 聊天隱喻（LINE） */
  --chat-player: #06c755;
  --chat-player-soft: rgba(6, 199, 85, 0.12);
  --chat-npc: #eceaf1;
  --chat-npc-text: #241c3a;
  /* 賽評霓虹（限定使用） */
  --neon-violet: #7c5cff;
  --neon-cyan: #38e1d6;
  /* 圓角尺規 */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  /* 間距尺規 */
  --sp-1: 6px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  /* 陰影 */
  --shadow-1: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, 0.45);
  /* 字體配對（批次④才載入字檔並套用） */
  --font-display: "Zen Maru Gothic", "Noto Sans TC", system-ui, sans-serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Segoe UI", sans-serif;

  /* == B6 新增 token（只增不改既有值）== */
  /* 背景霓虹暈 — 四角色光，以既有霓虹色系 */
  --b6-glow-violet: rgba(124, 92, 255, 0.18);
  --b6-glow-cyan: rgba(56, 225, 214, 0.12);
  --b6-glow-amber: rgba(255, 178, 79, 0.10);
  /* 數字儀表字體：等寬，無字體則退回 monospace */
  --font-dashboard: "Courier New", "Lucida Console", ui-monospace, monospace;
  /* 儀表數字發光（沿用既有 --primary 橘色調） */
  --b6-digit-glow: 0 0 8px rgba(255, 178, 79, 0.55), 0 0 2px rgba(255, 210, 130, 0.45);
  /* 儀表底板（深色嵌入感，不新增顏色，組合既有 --surface-inset） */
  --b6-pill-inset: inset 0 1px 3px rgba(0, 0, 0, 0.55);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #2a2440 0%, var(--bg) 48%, #0d0d17 100%);
  color: var(--text);
  font-family: var(--font-body);
}

body {
  padding: 20px;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.card {
  background: linear-gradient(165deg, rgba(39, 33, 61, 0.98), rgba(27, 23, 45, 0.95));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.opening-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: linear-gradient(180deg, rgba(13, 12, 20, 0.95), rgba(8, 7, 14, 0.97));
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 18px;
  transition: opacity 0.4s ease;
  opacity: 1;
}

.opening-overlay video {
  width: min(100%, 960px);
  max-height: 80vh;
  max-width: 100%;
  object-fit: contain;
  border: 1px solid rgba(255, 193, 129, 0.2);
  border-radius: var(--r-md);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.45);
  background: #000;
}

.opening-overlay--closing {
  opacity: 0;
  pointer-events: none;
}

/* 開始＝主要動作（主色膠囊，置中、不撐滿） */
.opening-start {
  width: auto;
  border-radius: var(--r-pill);
  border: none;
  background: var(--grad-primary);
  color: var(--on-primary);
  font-weight: 800;
  min-width: 160px;
  min-height: 52px;
  padding: 12px 30px;
  box-shadow: var(--shadow-1);
}

/* 跳過＝次要鍵（與主色明確區隔；右上角為慣例 skip 位，不再像主鍵的雙胞胎） */
.opening-skip {
  position: absolute;
  top: 12px;
  right: 12px;
  width: auto;
  min-width: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: rgba(20, 18, 27, 0.72);
  color: var(--muted);
  font-weight: 600;
  padding: 8px 14px;
  font-size: 0.95rem;
  box-shadow: none;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-family: var(--font-display);
}

form {
  display: grid;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select,
button {
  width: 100%;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 1rem;
  background: var(--surface-inset);
  color: var(--text);
}

select#scenario-id {
  cursor: pointer;
}

button {
  cursor: pointer;
  background: var(--grad-primary);
  color: var(--on-primary);
  font-weight: 700;
  border: none;
  border-radius: var(--r-pill);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.coach-hint {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.92rem;
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  object-fit: contain;
  image-rendering: pixelated;
}

/* 選角畫面 */
.charselect {
  display: grid;
  gap: 6px;
}

.charselect-label {
  font-size: 0.95rem;
  color: var(--muted);
}

.avatar-carousel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
}

.avatar-nav {
  min-width: 54px;
  min-height: 54px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1;
}

.avatar-preview-wrap {
  display: grid;
  gap: 6px;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  padding: 6px;
}

.avatar-preview {
  width: min(180px, 52vw);
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  object-fit: contain;
  image-rendering: pixelated;
  padding: 6px;
}

.avatar-counter {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.pill {
  padding: 6px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  flex-shrink: 0;
  white-space: nowrap;
}

.pill.practice-mode-pill {
  border-color: rgba(92, 214, 160, 0.62);
  background: rgba(92, 214, 160, 0.18);
  color: #dfffee;
}

.scene {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9; /* 對齊 1280x720 圖層，百分比座標一比一對應 */
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  margin-bottom: 12px;
  background: var(--surface-1);
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

#bg {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 老闆：座標反算自 ART/Layers/5.png */
.npc-layer {
  position: absolute;
  left: 46.7%;
  top: 22.3%;
  width: 43.8%;
}

#npc {
  display: block;
  width: 100%;
  height: auto;
  transform-origin: center 82%;
  animation: npc-breath 2.6s ease-in-out infinite;
}

@keyframes npc-breath {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-0.45%) scale(1.01);
  }
}

/* 前景桌子：直接用 ART/Layers/4.png（已置中定位的整版前景），鋪滿 16:9 畫布 */
.table-fg {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.scene-prop {
  position: absolute;
  pointer-events: auto;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 0.18s ease;
  cursor: pointer;
}

.scene-prop:hover {
  transform: translateY(-1px) scale(1.01);
}

#prop-mascot {
  left: 5%;
  top: 7%;
  width: 17%;
  z-index: 4;
}

#prop-maneki {
  right: 4%;
  top: 6%;
  width: 13%;
  z-index: 4;
}

/* 立牌：座標反算自 ART/Layers/2.png */
.desk-layer {
  position: absolute;
  left: 77.3%;
  top: 69.8%;
  width: 26.8%;
}

#desk {
  display: block;
  width: 100%;
}

#desk-text {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  width: 86%;
  text-align: center;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  line-height: 1.15;
  font-weight: 700;
  color: #311b00;
  white-space: pre-line;
  word-break: break-word;
  overflow: hidden;
  max-height: 2.6em;
  pointer-events: none;
  text-shadow: 0 0 4px #fff8e8;
}

.obj {
  position: absolute;
  height: auto;
}

/* 茶杯（mood 指示）：座標反算自 ART/Layers/3.png */
#obj-mood {
  left: 59.3%;
  top: 73.8%;
  width: 11.1%;
}

/* 合約（deal 指示）：座標反算自 ART/Layers/1.png */
#obj-deal {
  left: 3.1%;
  top: 51.9%;
  width: 28.1%;
}

/* P2-D 三關疊圖微調（見 ART/三關疊圖座標對照表.md）
   drink_shop 用 Layers 基準；gear/boba 已於 2026-06-04 用 tools/preview_scene.py
   合成驗收（立牌移入桌面、道具貼桌不浮空），啟用以下覆寫。
   需 .scene 已有 data-scenario（app.js setScenarioScene 已設）。
*/
.scene[data-scenario="gear_chain"] .npc-layer { left: 44%; top: 20%; width: 46%; }
.scene[data-scenario="gear_chain"] .desk-layer { left: 72%; top: 68%; width: 28%; }
.scene[data-scenario="gear_chain"] #obj-mood { left: 62%; top: 72%; width: 10%; }
.scene[data-scenario="gear_chain"] #obj-deal { left: 8%; top: 55%; width: 26%; }

/* ai_boss 真人場景(2026-06-07):無桌面圖層,且 boss 分數在 server、mood/deal 道具只是
   靜態 state0 裝飾 → 隱藏,免得茶杯/合約浮空。立牌與吉祥物不受影響。 */
.scene[data-scenario="ai_boss"] #obj-mood,
.scene[data-scenario="ai_boss"] #obj-deal { display: none; }

.scene[data-scenario="boba_chain"] .npc-layer { left: 47%; top: 23%; width: 42%; }
.scene[data-scenario="boba_chain"] .desk-layer { left: 68%; top: 71%; width: 30%; }
.scene[data-scenario="boba_chain"] #obj-mood { left: 55%; top: 74%; width: 12%; }
.scene[data-scenario="boba_chain"] #obj-deal { left: 12%; top: 53%; width: 25%; }

#bg.is-missing,
#npc.is-missing,
#table.is-missing,
#desk.is-missing,
#obj-mood.is-missing,
#obj-deal.is-missing {
  background: linear-gradient(120deg, #2e2a42, #17132a);
  object-fit: none;
  border: 1px dashed #5f5a7f;
  min-height: 80px;
}

.history {
  max-height: 140px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
  min-height: 48px;
}

.bubble-row {
  max-width: 84%;
  padding: 8px 10px;
  border-radius: var(--r-md);
  line-height: 1.4;
}

/* LINE 模式：對方(NPC)靠左·淺色氣泡；自己(玩家)靠右·LINE 綠氣泡 */
.bubble-row.npc {
  align-self: flex-start;
  background: #ECEAF1;
  color: #241c3a;
  border-top-left-radius: 0;
}

.bubble-row.player {
  align-self: flex-end;
  background: #06C755; /* LINE 綠 */
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); /* 提升白字在綠底可讀性(投影/強光) */
  border-top-right-radius: 0;
}

.history-toggle {
  display: none;
  align-self: center;
  width: auto;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  border: 1px solid rgba(236, 234, 241, 0.22);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.85rem;
}

/* NPC 當前台詞＝靠左的淺色 NPC 氣泡 */
.prompt-card {
  max-width: 85%;
  margin-right: auto; /* 推到左側 */
  border-radius: var(--r-md);
  border-top-left-radius: 0;
  border: 1px solid var(--line);
  padding: 10px;
  background: #ECEAF1;
  color: #241c3a;
  margin-bottom: 10px;
}

#prompt-text {
  margin: 0;
  color: #241c3a;
}

/* 選項＝玩家要說的話 → 靠右排列（玩家側） */
.options {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.option-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  max-width: 85%;
  background: rgba(6, 199, 85, 0.12); /* 玩家綠·待送出（外框感，與已送出實心綠區隔）*/
  border: 1px solid #06C755;
  color: #ffffff;
  padding: 10px;
  border-radius: var(--r-md);
  border-top-right-radius: 0;
  cursor: pointer;
  white-space: normal;
}

.option-btn:hover {
  background: rgba(6, 199, 85, 0.22);
}

.option-text {
  display: block;
}

.option-failed-label {
  display: inline-block;
  font-size: 0.78rem;
  border-radius: var(--r-pill);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 2px 7px;
  line-height: 1.2;
  color: #3a1e00;
  background: rgba(255, 176, 64, 0.32);
  border-color: rgba(255, 176, 64, 0.5);
}

/* 回顧卡：各關切換 */
.review-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.review-tab {
  width: auto;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}
.review-tab.is-active {
  background: var(--grad-primary);
  color: var(--on-primary);
  font-weight: 700;
  border-color: transparent;
}
.review-sponsor {
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--accent);
}

.option-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.3;
}

.option-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.option-btn.is-failed {
  opacity: 0.75;
  filter: grayscale(1);
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.result-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}

.achievement-panel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 10px 0;
  padding: 10px;
  border: 1px solid rgba(255, 178, 79, 0.35);
  border-radius: var(--r-md);
  background: rgba(255, 178, 79, 0.08);
}

.achievement-avatar {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  object-fit: contain;
  image-rendering: pixelated;
}

.achievement-body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.achievement-title {
  margin: 0;
  color: var(--accent);
  font-weight: 700;
}

.achievement-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.achievement-badge {
  width: 84px;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--r-md);
  background: rgba(18, 15, 31, 0.68);
  animation: achievement-pop 0.26s ease-out both;
}

.achievement-badge img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  image-rendering: pixelated;
}

.achievement-badge-name {
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.25;
  text-align: center;
}

.achievement-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

#review-card {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 10px;
  background: var(--surface-inset);
}

.review-track-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.review-track-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  object-fit: contain;
  image-rendering: pixelated;
}

.review-track-title {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
}

/* F-2 敘事收尾旁白（賽事方口吻） */
.review-track-coda {
  flex-basis: 100%;
  margin: 8px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: rgba(255, 178, 79, 0.08);
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

#review-list {
  display: grid;
  gap: 8px;
  padding-left: 0;
  margin: 0;
  list-style: none;
}

.track-card {
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(30, 27, 43, 0.88);
}

.track-card.is-bad {
  background: rgba(160, 160, 170, 0.16);
  border-color: rgba(255, 126, 146, 0.35);
  filter: grayscale(0.35);
}

.track-card-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.track-card-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.track-card-label,
.track-card-speech {
  margin: 0;
}

.track-card-label {
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 700;
}

.track-card-speech {
  color: var(--text);
  line-height: 1.35;
}

.track-npc-face {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  object-fit: contain;
}

.track-card-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.track-hint-chip {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  color: #2a1c00;
  background: rgba(255, 176, 64, 0.85);
  font-size: 0.78rem;
  line-height: 1.25;
}

/* Boss 終局 recap chips(2026-06-07):命中=綠、關係加溫=💚 */
.track-hint-chip.is-good {
  color: #03301a;
  background: rgba(121, 215, 163, 0.85);
}
.track-hint-chip.is-heart {
  color: #dfffee;
  background: rgba(121, 215, 163, 0.22);
  border: 1px solid rgba(121, 215, 163, 0.7);
}

@keyframes achievement-pop {
  from {
    opacity: 0;
    transform: translateY(4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.hidden {
  display: none;
}

#result-feedback {
  white-space: pre-line;
}

.reflection-label {
  display: block;
  margin-top: 8px;
  margin-bottom: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.reflection-input {
  width: 100%;
  min-height: 86px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  padding: 8px;
  background: var(--surface-inset);
  color: var(--text);
}

.admin-toolbar {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-ops {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-op-btn {
  width: auto;
  min-width: 160px;
}

.admin-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.admin-link:hover {
  text-decoration: underline;
}

.admin-link-active {
  color: #ffd88d;
}

.admin-sep {
  color: var(--muted);
}

.admin-list {
  margin-top: 10px;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--line);
  padding: 10px 12px;
}

.admin-table th {
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.admin-table .admin-name {
  font-weight: 600;
  margin-bottom: 4px;
}

.admin-table .admin-muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.admin-table .admin-fail {
  background: rgba(255, 98, 128, 0.08);
}

.admin-table .admin-picked {
  background: rgba(255, 214, 102, 0.18);
}

.admin-table .admin-row {
  cursor: pointer;
}

.admin-result-fail {
  color: #ff93ad;
  font-weight: 700;
}

.admin-result-maybe {
  color: #ffd37c;
  font-weight: 700;
}

.admin-result-deal {
  color: #8effb7;
  font-weight: 700;
}

@media (max-width: 640px) {
  body {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .history {
    max-height: 100px;
    min-height: 36px;
  }

  .history.has-collapsed-history .history-toggle {
    display: block;
  }

  .history.has-collapsed-history:not(.is-expanded) .bubble-row.history-old {
    display: none;
  }

  .scene {
    min-height: 0;
    max-height: 52vw;
  }

  .prompt-card {
    max-height: 70px;
    overflow-y: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .opening-overlay {
    transition: opacity 0.1s linear;
  }

  #npc {
    animation: none;
  }

  .maneki-rare-fx {
    animation: none !important;
    transition: none !important;
  }

  .maneki-rare-particles {
    animation: none !important;
    transition: none !important;
    display: none;
  }

  .scene-prop {
    animation: none !important;
    transition: none !important;
  }

  .maneki-rare-glow {
    animation: none !important;
    display: none;
  }

  .achievement-badge {
    animation: none !important;
  }
}

@keyframes maneki-rare-motion {
  0% {
    transform: translateY(0px) rotate(-6deg);
  }
  25% {
    transform: translateY(-4px) rotate(-6deg);
  }
  50% {
    transform: translateY(0px) rotate(6deg);
  }
  75% {
    transform: translateY(-4px) rotate(6deg);
  }
  100% {
    transform: translateY(0px) rotate(-6deg);
  }
}

@keyframes maneki-rare-shimmer {
  0% {
    filter: hue-rotate(0deg) brightness(1) drop-shadow(0 0 6px rgba(255, 194, 94, 0.45));
  }
  50% {
    filter: hue-rotate(180deg) brightness(1.18) drop-shadow(0 0 14px rgba(255, 220, 120, 0.6));
  }
  100% {
    filter: hue-rotate(360deg) brightness(1) drop-shadow(0 0 6px rgba(255, 194, 94, 0.45));
  }
}

@keyframes maneki-rare-glow {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.92);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.08);
  }
}

@keyframes maneki-rare-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.95;
  }
  100% {
    transform: translateY(150px) rotate(360deg);
    opacity: 0;
  }
}

.maneki-rare-particles {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
  display: none;
}

.maneki-rare-particle {
  position: absolute;
  will-change: transform, opacity;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35));
  animation: maneki-rare-fall linear forwards;
}

.maneki-rare-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(circle, rgba(255, 212, 120, 0.68), rgba(255, 196, 80, 0.24) 40%, rgba(255, 196, 80, 0));
  animation: maneki-rare-glow 1.6s ease-in-out infinite;
  opacity: 0.7;
  transform-origin: center center;
  display: none;
}

.maneki-rare-glow.is-active {
  display: block;
}

.maneki-rare-particles.is-active {
  display: block;
}

.maneki-rare-fx {
  transform-origin: bottom center;
  animation:
    maneki-rare-motion 1.8s ease-in-out infinite,
    maneki-rare-shimmer 2.4s linear infinite;
  filter: drop-shadow(0 0 10px rgba(255, 214, 102, 0.55));
}

/* ── Boss 自由打字 / 填空輸入 ───────────────────────────────── */
.free-type-round {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 85%;
  margin-right: auto; /* 與玩家泡泡同側 */
}

/* 填空：固定文字 + 行內填空格組成一句話 */
.fill-sentence {
  background: rgba(6, 199, 85, 0.10);
  border: 1px solid #06C755;
  border-radius: var(--r-md);
  border-top-left-radius: 0;
  padding: 14px 14px 16px;
  color: var(--text);
  font-size: 1.02rem;
  line-height: 2.1; /* 留高度給行內輸入框 */
}

.fill-blank {
  display: inline-block;
  min-width: 64px;
  margin: 0 3px;
  padding: 3px 8px;
  font: inherit;
  color: #2a1c00;
  background: #ffe9c7;
  border: none;
  border-bottom: 2px solid var(--accent);
  border-radius: var(--r-xs);
  outline: none;
  transition: background 0.15s ease, box-shadow 0.15s ease;
  vertical-align: baseline;
}

.fill-blank::placeholder {
  color: #9a7b46;
  font-size: 0.9em;
}

.fill-blank:focus {
  background: #fff4e0;
  box-shadow: 0 0 0 3px rgba(255, 178, 79, 0.35);
}

.fill-blank.is-empty {
  background: rgba(255, 126, 146, 0.22);
  border-bottom-color: var(--bad);
  animation: fill-shake 0.32s ease;
}

@keyframes fill-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.fill-hint {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.fill-reminder {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bad);
}

.fill-reminder.hidden {
  display: none;
}

/* 自由模式 textarea */
.free-type-input {
  width: 100%;
  min-height: 96px;
  padding: 12px;
  font: inherit;
  line-height: 1.6;
  color: var(--text);
  background: rgba(6, 199, 85, 0.08);
  border: 1px solid #06C755;
  border-radius: var(--r-md);
  border-top-left-radius: 0;
  outline: none;
  resize: vertical;
  transition: box-shadow 0.15s ease;
}

.free-type-input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.free-type-input:focus {
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.25);
}

.free-type-submit {
  align-self: flex-end;
  max-width: none;
  width: auto;
  padding: 10px 28px;
  align-items: center;
  font-weight: 600;
}

/* 賽評精靈泡泡(賽後回顧卡內,display-only flavor) */
.sprite-bubble {
  margin: 10px 0 14px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 1px solid rgba(124, 92, 255, 0.45);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.16), rgba(56, 225, 214, 0.12));
  color: #eef0ff;
  font-size: 0.98rem;
  line-height: 1.5;
  position: relative;
}
.sprite-bubble.hidden { display: none; }

/* 帶入感批次(2026-06-07) */
/* 1-1 玩家氣泡頭像 */
.bubble-row.player {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.bubble-row.player .bubble-text { min-width: 0; }
.bubble-row.player .bubble-avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: var(--surface-2);
  object-fit: contain;
  image-rendering: pixelated;
}

/* 1-3 進場過場:整個遊戲面板淡入上浮 */
.scene-enter { animation: scene-enter-fade 0.7s ease-out both; }
@keyframes scene-enter-fade {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 1-4 K總終局儀式 */
.boss-finale {
  margin: 10px 0;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 210, 106, 0.55);
  background: linear-gradient(135deg, rgba(255, 178, 79, 0.16), rgba(255, 210, 106, 0.08));
  color: #ffe9c7;
  line-height: 1.7;
  font-size: 1rem;
}
.boss-finale.hidden { display: none; }

/* 1-5 賽評開場引言:遊戲區頂部短暫泡泡 */
.sprite-bubble-flash { animation: sprite-flash 8s ease-in-out both; }
@keyframes sprite-flash {
  0% { opacity: 0; transform: translateY(-6px); }
  6%, 88% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .scene-enter { animation: none; }
  .sprite-bubble-flash { animation: none; }
}

/* ===== 第三輪迭代 DW 區段：各軌只在自己的 ==Bx== 標記之間動；:root 只有 B6 可增 ===== */
/* == B1:roundFeedback == */

/* ── 全屏閃光層 ─────────────────────────────────────────────────── */
.rf-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}
.rf-flash--active {
  opacity: 1;
  animation: rf-flash-fade var(--b1-flash-dur, 0.7s) ease-out forwards;
}
.rf-flash--hit  { background: var(--b1-hit-color,  rgba(121,215,163,0.28)); }
.rf-flash--miss { background: var(--b1-miss-color, rgba(255,126,146,0.28)); }

@keyframes rf-flash-fade {
  0%   { opacity: 1; }
  40%  { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ── 短評氣泡 ───────────────────────────────────────────────────── */
.rf-verdict {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.3em 0.75em;
  border-radius: var(--radius-sm, 6px);
  margin: 0.25rem 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  max-width: 100%;
  text-align: center;
}
.rf-verdict--visible {
  opacity: 1;
  transform: translateY(0);
}
.rf-verdict--hit  {
  color: var(--good);
  border: 1px solid color-mix(in srgb, var(--good) 40%, transparent);
  background: color-mix(in srgb, var(--good) 10%, transparent);
}
.rf-verdict--miss {
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
}

/* ── #round-progress 容器 ───────────────────────────────────────── */
.round-progress {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem 0.3rem;
}

/* ── 單行條 ─────────────────────────────────────────────────────── */
.rf-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.rf-bar-label {
  font-size: 0.7rem;
  color: var(--text-muted, rgba(255,255,255,0.5));
  width: 2.4rem;
  flex-shrink: 0;
  text-align: right;
}
.rf-bar-track {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--b1-bar-bg, rgba(255,255,255,0.12));
  overflow: hidden;
}
.rf-bar-fill {
  height: 100%;
  border-radius: 3px;
  width: 0%;
  transition: width 0.45s cubic-bezier(0.4,0,0.2,1);
}
.rf-bar-fill--mood { background: var(--primary); }
.rf-bar-fill--deal { background: var(--good); }

/* reduced-motion: 關掉所有動畫 */
@media (prefers-reduced-motion: reduce) {
  .rf-flash--active    { animation: none; opacity: 0; }
  .rf-verdict          { transition: none; }
  .rf-bar-fill         { transition: none; }
}

/* == /B1 == */

/* == B2:resultScreen == */
/* == /B2 == */

/* == B3:playerCard == */

/* 玩家卡容器 — 共用三處（入場/遊戲/結果） */
.player-card-slot {
  min-height: 0; /* slot 本身不占空間，卡片出現才撐開 */
}

.pc-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid rgba(255, 178, 79, 0.35);
  border-radius: var(--r-md);
  background: rgba(255, 178, 79, 0.07);
  margin-bottom: var(--sp-3);
  /* 入場淡入 */
  animation: pc-enter 0.45s ease-out both;
}

@keyframes pc-enter {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .pc-card { animation: none; }
}

.pc-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  border: 1px solid rgba(255, 178, 79, 0.45);
  background: var(--surface-2);
  object-fit: contain;
  image-rendering: pixelated;
}

.pc-body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pc-title {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);   /* --primary 橘，=賽事/命中色 */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-record {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--font-dashboard);
  letter-spacing: 0.03em;
}

/* == /B3 == */

/* == P3:playerCard 反應放大（依回合結果換臉）== */

/* 遊戲中玩家卡放大，讓表情看得見（原 44px 角落太小） */
#player-card-game .pc-card {
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
}
#player-card-game .pc-avatar {
  width: 96px;
  height: 96px;
  border-radius: var(--r-md);
  transition: box-shadow 0.2s ease;
}
#player-card-game .pc-title { font-size: 1.05rem; }

/* 反應 pop（換臉瞬間放大回彈） */
.pc-avatar--react { animation: pc-react-pop 0.42s ease-out; }
@keyframes pc-react-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* 情緒光暈 */
.pc-react-love       { box-shadow: 0 0 0 2px #ff7eb6, 0 0 14px 2px rgba(255, 126, 182, 0.7); border-color: #ff7eb6; }
.pc-react-money      { box-shadow: 0 0 0 2px #ffcf33, 0 0 14px 2px rgba(255, 207, 51, 0.75); border-color: #ffcf33; }
.pc-react-awkward    { box-shadow: 0 0 0 2px #8fb7ff, 0 0 12px 2px rgba(143, 183, 255, 0.6); border-color: #8fb7ff; }
.pc-react-disappoint { box-shadow: 0 0 0 2px #9aa3b2, 0 0 12px 2px rgba(154, 163, 178, 0.55); border-color: #9aa3b2; }

@media (prefers-reduced-motion: reduce) {
  .pc-avatar--react { animation: none; }
}

/* == /P3 == */

/* == B4:charselect == */

/* ── 網格容器 ─────────────────────────────────────────────────────────────── */
.b4-grid-container {
  /* 捲動框：限高讓玩家一眼看到全部或捲動瀏覽 */
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  padding: var(--sp-2);
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.b4-grid-container::-webkit-scrollbar {
  width: 6px;
}
.b4-grid-container::-webkit-scrollbar-track {
  background: transparent;
}
.b4-grid-container::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--r-pill);
}

/* ── 網格本體：5 欄 × 12 列（20 個角色 × 3 色違 = 60 cell） ───────────────── */
.b4-avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-2);
}

/* ── 每個角色格 ───────────────────────────────────────────────────────────── */
.b4-avatar-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 3px 4px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-soft);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  min-height: 72px;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.2;
}

.b4-avatar-cell:hover:not(.is-taken) {
  border-color: var(--primary);
  background: var(--surface-1);
  box-shadow: 0 0 0 1px var(--primary);
}

.b4-avatar-cell:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* 基底版（原色）稍微寬邊 */
.b4-avatar-cell.is-base {
  border-color: var(--line);
}

/* 選中狀態 */
.b4-avatar-cell.is-selected {
  border-color: var(--primary);
  background: rgba(255, 178, 79, 0.12);
  box-shadow: 0 0 0 2px var(--primary), var(--b6-digit-glow);
  color: var(--text);
}

/* 佔用狀態（同班已選，半透明遮蓋感） */
.b4-avatar-cell.is-taken {
  opacity: 0.55;
  cursor: not-allowed;
  border-color: var(--bad);
  background: rgba(255, 126, 146, 0.08);
}

/* 佔用 + 選中同時（自己選的，允許顯示）*/
.b4-avatar-cell.is-taken.is-selected {
  opacity: 1;
  cursor: pointer;
  border-color: var(--primary);
  background: rgba(255, 178, 79, 0.12);
  box-shadow: 0 0 0 2px var(--primary), var(--b6-digit-glow);
}

/* ── 頭像縮圖 ─────────────────────────────────────────────────────────────── */
.b4-avatar-thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: var(--r-xs);
  background: var(--surface-inset);
  border: 1px solid var(--line-soft);
  flex-shrink: 0;
}

/* ── 稱號文字 ─────────────────────────────────────────────────────────────── */
.b4-avatar-label {
  display: block;
  font-size: 0.68rem;
  line-height: 1.2;
  color: inherit;
  word-break: keep-all;
  overflow-wrap: anywhere;
  pointer-events: none;
}

/* ── 「佔用」角標 ─────────────────────────────────────────────────────────── */
.b4-taken-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  font-size: 0.6rem;
  line-height: 1;
  padding: 1px 4px;
  border-radius: var(--r-xs);
  background: var(--bad);
  color: #fff;
  pointer-events: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ── 響應式：行動裝置縮窄 ──────────────────────────────────────────────────── */
@media (max-width: 440px) {
  .b4-avatar-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-1);
  }
  .b4-avatar-thumb {
    width: 38px;
    height: 38px;
  }
  .b4-grid-container {
    max-height: 300px;
  }
}

/* ── coverflow 輪播（取代上方網格；grid 樣式已停用，僅 .b4-taken-badge 共用）── */
.b4-carousel { display: grid; gap: 6px; }
.b4-stage {
  position: relative;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  outline: none;
}
.b4-card {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.28s ease, opacity 0.28s ease;
  will-change: transform, opacity;
}
.b4-thumb {
  height: 180px;
  width: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.45));
}
.b4-center {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  z-index: 3;
}
.b4-frame {
  border: 2px solid var(--primary);
  border-radius: var(--r-md);
  padding: 8px 10px;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}
.b4-peek {
  opacity: 0.3;
  z-index: 1;
  cursor: pointer;
}
.b4-peek .b4-thumb { height: 128px; }
.b4-peek--l { transform: translate(calc(-50% - 168px), -50%) scale(0.9); }
.b4-peek--r { transform: translate(calc(-50% + 168px), -50%) scale(0.9); }
.b4-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--primary);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.b4-arrow:hover { background: var(--surface-1); }
.b4-arrow--l { left: 2px; }
.b4-arrow--r { right: 2px; }
.b4-label {
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
  margin: 6px 0 0;
  color: var(--text);
}
.b4-count {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 2px 0 0;
  font-variant-numeric: tabular-nums;
}
.b4-center .b4-taken-badge {
  position: absolute;
  top: 4px;
  right: 4px;
}
@media (max-width: 480px) {
  .b4-stage { height: 210px; }
  .b4-thumb { height: 150px; }
  .b4-peek .b4-thumb { height: 104px; }
  .b4-peek--l { transform: translate(calc(-50% - 132px), -50%) scale(0.88); }
  .b4-peek--r { transform: translate(calc(-50% + 132px), -50%) scale(0.88); }
}

/* == /B4 == */

/* == B5:notifications == */

/* ── Toast 容器 ── */
.toast-root {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-4);
  z-index: 9000;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: min(360px, calc(100vw - var(--sp-4) * 2));
}

/* ── Toast 單則 ── */
.b5-toast {
  position: relative;
  pointer-events: auto;
  padding: 10px 36px 10px 14px;
  border-radius: var(--r-md);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  word-break: break-word;
}

.b5-toast--visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes b5-toast-out {
  to { opacity: 0; transform: translateY(8px); }
}

.b5-toast--out {
  animation: b5-toast-out 0.2s ease forwards;
}

/* type 色邊 */
.b5-toast--info    { border-left: 4px solid var(--neon-cyan); }
.b5-toast--success { border-left: 4px solid var(--good); }
.b5-toast--warn    { border-left: 4px solid var(--accent); }
.b5-toast--error   { border-left: 4px solid var(--bad); }

/* 關閉按鈕 */
.b5-toast-close {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 0 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.b5-toast-close:hover { opacity: 1; }

/* ── 成就陳列館 ── */
.b5-gallery {
  margin: 16px 0 0;
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.b5-gallery-heading {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
}

.b5-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--sp-3);
}

.b5-gallery-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--line-soft);
  background: var(--surface-inset);
  transition: border-color 0.2s;
}

.b5-gallery-card--unlocked {
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
  background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.b5-gallery-card--locked {
  opacity: 0.5;
  filter: grayscale(0.7);
}

.b5-gallery-img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  image-rendering: pixelated;
}

.b5-gallery-name {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.b5-gallery-how {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
  text-align: center;
}

.b5-gallery-card--unlocked .b5-gallery-how {
  color: var(--good);
}

/* 手機適配 */
@media (max-width: 500px) {
  .toast-root {
    right: var(--sp-2);
    bottom: var(--sp-3);
    max-width: calc(100vw - var(--sp-2) * 2);
  }

  .b5-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }
}

/* == /B5 == */

/* == B6:theme-ambiance（可動 :root，只增不改既有值） == */

/* ── B6-1 body 背景霓虹暈 ───────────────────────────────────────
   在原有 radial-gradient 之上疊多層固定色光，
   只補 background-image（不改 background-color 或已有漸層）。
   使用 ::before 偽元素以免蓋掉 html/body 已有的 radial-gradient。
────────────────────────────────────────────────────────────────── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    /* 左上：violet 暈 */
    radial-gradient(ellipse 55% 38% at 8% 12%, var(--b6-glow-violet) 0%, transparent 70%),
    /* 右下：cyan 暈 */
    radial-gradient(ellipse 50% 35% at 92% 88%, var(--b6-glow-cyan) 0%, transparent 70%),
    /* 右上：amber 微暈（主色回聲） */
    radial-gradient(ellipse 35% 28% at 88% 10%, var(--b6-glow-amber) 0%, transparent 65%),
    /* 左下：violet 副暈 */
    radial-gradient(ellipse 40% 30% at 6% 90%, var(--b6-glow-violet) 0%, transparent 60%);
}

/* 確保 .app 在霓虹暈之上顯示 */
.app {
  position: relative;
  z-index: 1;
}

/* ── B6-2 數字/計數儀表化 ────────────────────────────────────────
   目標元素：
     #round-pill        第 X 輪 / 10（回合計數）
     #status-pill       狀態標籤（含數值文字）
     .avatar-counter    01 / 20（角色選擇計數）
     #result-stats      談成項目：X 項
   只改字體與裝飾，不動顏色 token 值、不動 layout。
────────────────────────────────────────────────────────────────── */

/* 回合計數 pill — 等寬儀表感 */
#round-pill {
  font-family: var(--font-dashboard);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  font-weight: 700;
  box-shadow: var(--b6-pill-inset), var(--b6-digit-glow);
  border-color: rgba(255, 178, 79, 0.45);
  color: var(--accent);
  background: var(--surface-inset);
  text-shadow: var(--b6-digit-glow);
}

/* 角色輪播計數 — 等寬小儀表 */
.avatar-counter {
  font-family: var(--font-dashboard);
  letter-spacing: 0.06em;
  font-size: 0.82rem;
}

/* 結果頁「談成項目」數字 — 等寬顯示 */
#result-stats {
  font-family: var(--font-dashboard);
  letter-spacing: 0.05em;
  font-size: 1rem;
  color: var(--good);
  text-shadow: 0 0 6px rgba(121, 215, 163, 0.45);
}

/* 儀表文字在 prefers-reduced-motion 下不顯示發光（text-shadow 保留，animate 無 → 無影響） */
@media (prefers-reduced-motion: reduce) {
  #round-pill {
    text-shadow: none;
    box-shadow: var(--b6-pill-inset);
  }
  #result-stats {
    text-shadow: none;
  }
}

/* == /B6 == */

/* == B2:resultScreen == */
/*
   B2 結果頁重構：大狀態徽章 + 分組層級 + 語意色分流
   擁有：所有以 .result-badge、.result-group、#result-wrap variant class 開頭的規則
   消費：:root token（--good/--bad/--primary/--r-*/--sp-*/--surface-*/--line/--text/--muted）
   硬規則：不動 :root、不動他軌 CSS 區段、不硬編碼顏色/圓角/間距
*/

/* ────────────────────────────────────────────
   0. 收掉「橘海」：把 result-wrap 的 h2 標題縮小為副標，
      視覺焦點交給 .result-badge
   ──────────────────────────────────────────── */
#result-wrap > h2 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 var(--sp-3);
  opacity: 0.7;
}

/* ────────────────────────────────────────────
   1. 大狀態徽章
   ──────────────────────────────────────────── */
.result-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg);
  border: 2px solid transparent;
  margin-bottom: var(--sp-4);
  /* 預設（fallback）：中性 */
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--line);
}

.result-badge__icon {
  font-size: 2.2rem;
  line-height: 1;
  flex: 0 0 auto;
}

.result-badge__label {
  font-family: var(--font-display, var(--font-body));
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* 成交 ── 綠色系（--good） */
.result-badge--deal {
  background: rgba(121, 215, 163, 0.12);
  border-color: rgba(121, 215, 163, 0.55);
  box-shadow: 0 0 20px rgba(121, 215, 163, 0.18), inset 0 0 12px rgba(121, 215, 163, 0.07);
}
.result-badge--deal .result-badge__label {
  color: var(--good);
  text-shadow: 0 0 12px rgba(121, 215, 163, 0.5);
}

/* 再談 ── 橘色系（--primary，限徽章，不再蔓延全頁） */
.result-badge--maybe {
  background: rgba(255, 178, 79, 0.10);
  border-color: rgba(255, 178, 79, 0.45);
  box-shadow: 0 0 16px rgba(255, 178, 79, 0.14), inset 0 0 10px rgba(255, 178, 79, 0.06);
}
.result-badge--maybe .result-badge__label {
  color: var(--primary);
  text-shadow: 0 0 10px rgba(255, 178, 79, 0.45);
}

/* 破局 ── 紅色系（--bad） */
.result-badge--fail {
  background: rgba(255, 126, 146, 0.10);
  border-color: rgba(255, 126, 146, 0.45);
  box-shadow: 0 0 16px rgba(255, 126, 146, 0.14), inset 0 0 10px rgba(255, 126, 146, 0.06);
}
.result-badge--fail .result-badge__label {
  color: var(--bad);
  text-shadow: 0 0 10px rgba(255, 126, 146, 0.45);
}

/* ────────────────────────────────────────────
   2. 分組容器：result-group（通用底板）
   ──────────────────────────────────────────── */
.result-group {
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-inset);
  border: 1px solid var(--line-soft);
  margin-bottom: var(--sp-3);
}

/* 主要結果層（result-title + result-line） */
.result-group--outcome {
  background: rgba(30, 27, 43, 0.75);
  border-color: var(--line);
}

/* 統計/回饋層（result-stats + result-feedback） */
.result-group--stats {
  background: var(--surface-inset);
  border-color: var(--line-soft);
}

/* ────────────────────────────────────────────
   3. 語意色分流：result-wrap variant → 子元素顏色
      只改色，不改 app.js 已寫好的文字
   ──────────────────────────────────────────── */

/* result-title（粗體標籤行） */
#result-title {
  font-weight: 700;
  font-size: 1.05rem;
  margin: 0;
  color: var(--text);
}

/* result-line（NPC 台詞） */
#result-line {
  font-size: 0.95rem;
  color: var(--muted);
  margin: 0;
  font-style: italic;
  line-height: 1.55;
}

/* result-stats：由 B6 已定義等寬字體，B2 只補語意色分流 */
/* 成交 → 綠 */
.result-wrap--deal #result-stats {
  color: var(--good);
  text-shadow: 0 0 6px rgba(121, 215, 163, 0.35);
}
/* 再談 → 橘（與 B6 原預設色相近，但明確只在 .result-wrap--maybe 內） */
.result-wrap--maybe #result-stats {
  color: var(--primary);
  text-shadow: 0 0 6px rgba(255, 178, 79, 0.35);
}
/* 破局 → 紅 */
.result-wrap--fail #result-stats {
  color: var(--bad);
  text-shadow: 0 0 6px rgba(255, 126, 146, 0.30);
}

/* result-feedback 維持 muted，但 deal 時輕微提亮 */
.result-wrap--deal #result-feedback {
  color: var(--text);
  opacity: 0.85;
}

/* ────────────────────────────────────────────
   4. boss-finale 置於卡底部，獨立視覺
   ──────────────────────────────────────────── */
.boss-finale {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  background: rgba(124, 92, 255, 0.10);
  border: 1px solid rgba(124, 92, 255, 0.30);
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-line;
}

/* ────────────────────────────────────────────
   5. 動畫：徽章入場（沿用既有 achievement-pop 概念）
   ──────────────────────────────────────────── */
@keyframes b2-badge-in {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.result-badge {
  animation: b2-badge-in 0.28s ease-out both;
}

/* 降低動態：取消入場動畫，保留結構 */
@media (prefers-reduced-motion: reduce) {
  .result-badge {
    animation: none;
  }
}

/* == /B2 == */

/* == B7:transitions == */

/* ── B7-1 選項點擊 ripple ───────────────────────────────────────────
   .option-btn 需 overflow:hidden 才能剪裁 ripple 圓形。
   用相對定位包住 span.b7-ripple（絕對定位圓）。
────────────────────────────────────────────────────────────────── */
.option-btn {
  overflow: hidden;
  position: relative;
}

@keyframes b7-ripple-expand {
  from {
    transform: scale(0);
    opacity: 0.45;
  }
  to {
    transform: scale(1);
    opacity: 0;
  }
}

.b7-ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.28);
  transform: scale(0);
  animation: b7-ripple-expand 0.38s ease-out forwards;
}

/* 點擊瞬間的亮度提升（配合 pointerdown，比 :active 更即時） */
.option-btn.b7-btn-active {
  filter: brightness(1.15);
}

/* ── B7-2 #bootstrap 開場結束後的淡入 ─────────────────────────────── */
@keyframes b7-reveal-fade {
  from {
    opacity: 0.3;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.b7-reveal {
  animation: b7-reveal-fade 0.45s ease-out both;
}

/* ── B7-3 prefers-reduced-motion 覆寫 ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .b7-ripple {
    animation: none;
    display: none;
  }
  .b7-reveal {
    animation: none;
  }
}

/* == /B7 == */
