/* 控制遊戲主要外觀與版面 */

:root {
  /* 成醫品牌主色 */
  /* 成醫藍：主要按鈕、工具列、角色名稱、進度條 */
  --primary-color: #005bac;

  /* 深成醫藍：按鈕漸層、陰影、hover 狀態 */
  --primary-dark: #003f78;

  /* 淺成醫藍：選取背景、提示框、淡色裝飾 */
  --primary-light: #dceeff;


  /* 獎勵與永續之星輔助色 */
  /* 金黃色：徽章、永續之星、重要亮點 */
  --secondary-color: #f3bb3f;

  /* 深金色：徽章名稱、黃色區塊文字與邊框 */
  --secondary-dark: #8a6100;

  /* 淡黃色：對話框、徽章卡片、成就區塊背景 */
  --secondary-light: #fff4cf;


  /* 永續與自然輔助色 */
  /* 永續綠：減碳、花園、環境類裝飾 */
  --sustainability-color: #2f8f68;

  /* 深綠色：永續區塊文字、邊框 */
  --sustainability-dark: #21664b;

  /* 淺綠色：永續提示與完成區塊背景 */
  --sustainability-light: #e3f4ed;


  /* 答題與系統狀態色 */
  /* 正確、成功、任務完成 */
  --success-color: #2d8a52;

  /* 正確答案背景 */
  --success-light: #e5f7eb;

  /* 答錯、錯誤訊息 */
  --error-color: #bd4b45;

  /* 錯誤答案背景 */
  --error-light: #fce9e7;

  /* 提醒、尚未完成、注意事項 */
  --warning-color: #b7791f;

  /* 提醒訊息背景 */
  --warning-light: #fff4de;

  /* 鎖定、停用、尚未取得 */
  --disabled-color: #8a969e;

  /* 停用背景 */
  --disabled-light: #edf1f3;


  /* 頁面與面板背景 */
  /* 整個網頁最外層背景 */
  --page-background: #eaf3f9;

  /* 遊戲主要容器背景 */
  --game-background: #ffffff;

  /* 一般卡片與內容面板背景 */
  --card-background: #ffffff;

  /* 浮在場景上方的半透明白色面板 */
  --panel-background: rgba(255, 255, 255, 0.96);

  /* 對話框背景 */
  --dialogue-background: #fffaf0;

  /* 工具列背景 */
  --toolbar-background: #005bac;

  /* 底部狀態列背景 */
  --status-background: rgba(255, 255, 255, 0.97);

  /* 圖片尚未載入時的底色 */
  --image-placeholder-background: #dce8f0;


  /* 文字顏色 */
  /* 主要標題、題目及正文 */
  --text-color: #26343f;

  /* 次要文字、說明及提示 */
  --muted-text: #657481;

  /* 更淡的輔助文字 */
  --subtle-text: #87949e;

  /* 深色背景上的白色文字 */
  --text-on-primary: #ffffff;

  /* 黃色背景上的深色文字 */
  --text-on-secondary: #604600;

  /* 連結文字 */
  --link-color: #005bac;

  /* 連結 hover */
  --link-hover-color: #003f78;


  /* 邊框與分隔線 */
  /* 一般卡片及選項邊框 */
  --border-color: #cedce7;

  /* 較深的強調邊框 */
  --border-strong: #9db9ce;

  /* 淡色分隔線 */
  --divider-color: #dce6ed;

  /* 半透明白色圖片邊框 */
  --image-border-color: rgba(255, 255, 255, 0.92);


  /* 圓角 */
  /* 小標籤、小圖示框 */
  --radius-small: 10px;

  /* 答案選項、一般卡片 */
  --radius-medium: 16px;

  /* 對話框、任務面板 */
  --radius-large: 26px;

  /* 大型地圖、結局面板 */
  --radius-extra-large: 34px;

  /* 膠囊形按鈕及標籤 */
  --radius-pill: 999px;


  /* 陰影 */
  /* 小按鈕、標籤與小卡片 */
  --shadow-small:
    0 4px 12px rgba(0, 67, 124, 0.1);

  /* 題目卡、對話框、場景圖片 */
  --shadow-medium:
    0 12px 28px rgba(0, 67, 124, 0.14);

  /* 結局面板、證書與重要畫面 */
  --shadow-large:
    0 22px 52px rgba(0, 67, 124, 0.18);

  /* 按鈕立體下緣 */
  --button-shadow:
    0 7px 0 #003f78,
    0 12px 22px rgba(0, 67, 124, 0.22);

  /* 圖片與人物柔和陰影 */
  --image-shadow:
    0 14px 32px rgba(24, 52, 72, 0.16);

  /* 徽章金色光暈 */
  --badge-glow:
    0 0 20px rgba(243, 187, 63, 0.55);

  /* 永續之星光暈 */
  --star-glow:
    0 0 14px rgba(255, 216, 90, 0.85),
    0 0 36px rgba(243, 187, 63, 0.55);


  /* 共用間距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 48px;
  --space-10: 64px;


  /* 字體大小 */
  /* 小型說明文字 */
  --font-size-small: 0.875rem;

  /* 一般輔助文字 */
  --font-size-body-small: 0.95rem;

  /* 一般正文 */
  --font-size-body: 1rem;

  /* 稍大的對話及選項文字 */
  --font-size-medium: 1.125rem;

  /* 小標題 */
  --font-size-large: 1.375rem;

  /* 場景標題 */
  --font-size-title:
    clamp(1.8rem, 3vw, 2.8rem);

  /* 開場與結局主標題 */
  --font-size-hero:
    clamp(2.2rem, 4vw, 3.8rem);


  /* 字重 */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-extra-bold: 800;


  /* 行距 */
  --line-height-tight: 1.3;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.85;


  /* 動畫速度 */
  /* 按鈕 hover、選項變色 */
  --transition-fast: 160ms;

  /* 卡片、對話框及一般切換 */
  --transition-normal: 280ms;

  /* 徽章出現、場景進場 */
  --transition-slow: 600ms;

  /* 地圖點亮及最終動畫 */
  --transition-extra-slow: 900ms;


  /* 動畫曲線 */
  /* 一般柔和切換 */
  --ease-standard: ease;

  /* 畫面進場 */
  --ease-out: ease-out;

  /* 按鈕及徽章彈跳 */
  --ease-bounce:
    cubic-bezier(0.34, 1.56, 0.64, 1);


  /* 版面寬度 */
  /* 遊戲主要內容最大寬度 */
  --content-max-width: 1200px;

  /* 文字及題目內容最大寬度 */
  --reading-max-width: 860px;

  /* 對話框最大寬度 */
  --dialogue-max-width: 1000px;


  /* 圖片比例 */
  /* 場景與地圖統一使用16:9 */
  --scene-aspect-ratio: 16 / 9;

  /* 角色圖片最大寬度 */
  --character-max-width: 220px;

  /* 徽章一般顯示尺寸 */
  --badge-size: 96px;

  /* 徽章大型顯示尺寸 */
  --badge-size-large: 160px;


  /* 圖層順序 */
  /* 一般內容 */
  --z-content: 1;

  /* 場景人物 */
  --z-character: 15;

  /* 對話框及題目面板 */
  --z-panel: 10;

  /* 上方工具列 */
  --z-toolbar: 20;

  /* 彈出提示或全螢幕控制 */
  --z-overlay: 100;
}

body {
  min-height: 100vh;
  background: var(--page-background);
  color: var(--text-color);
}

button {
  cursor: pointer;
}

button:focus-visible {
  outline: 4px solid rgba(244, 185, 66, 0.7);
  outline-offset: 3px;
}

.game {
  width: min(100%, 1600px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: var(--game-background);
}

.game-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;

  min-height: 72px;
  padding: 12px 24px;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;

  border-bottom: 1px solid rgba(255, 255, 255, 0.18);

  background:
    linear-gradient(
      135deg,
      var(--primary-dark),
      var(--primary-color)
    );

  color: #ffffff;

  box-shadow: var(--shadow-small);
}

.game-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.toolbar-actions {
  display: flex;
  gap: 12px;
}

.toolbar-button {
  min-height: 44px;
  padding: 8px 16px;

  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;

  font-weight: 700;

  backdrop-filter: blur(8px);

  transition:
    background-color var(--transition-fast),
    transform var(--transition-fast);
}

.toolbar-button:hover {
  background: rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

.game-scene {
  min-height: 0;
  padding: 32px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    linear-gradient(
      rgba(239, 247, 244, 0.9),
      rgba(239, 247, 244, 0.9)
    );
}

.opening-panel {
  width: min(100%, var(--content-max-width));
  padding: 36px;
  margin: 0 auto;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--panel-background);
  box-shadow: 0 18px 45px rgba(29, 73, 61, 0.12);
  text-align: center;
}

.scene-label {
  margin: 0 0 8px;
  color: var(--primary-color);
  font-weight: 700;
}

.opening-panel h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.2;
}

.opening-description {
  max-width: 800px;
  margin: 18px 10vw 24px;
  color: var(--muted-text);
  font-size: 1.125rem;
  line-height: 1.8;
}

.dialogue-box {
  position: relative;

  margin: 26px 0;
  padding: 16px 30px;

  border: 2px solid #d8c184;
  border-radius:var(--radius-large);

  background:
    linear-gradient(
      135deg,
      #fffdf6,
      #fff8df
    );

  box-shadow: var(--shadow-small);

  text-align: left;
  line-height: 1.85;
}

.opening-dialogue::before {
  content: "";

  position: absolute;

  top: -14px;
  right: 55px;
  bottom: auto;
  left: auto;

  width: 24px;
  height: 24px;

  border-top: 2px solid #d8c184;
  border-left: 2px solid #d8c184;

  background: var(
    --dialogue-background,
    #fffaf0
  );

  transform: rotate(45deg);

  z-index: 1;
}

.speaker-name {
  width: fit-content;
  margin: -42px 0 16px;
  padding: 7px 18px;

  border-radius: 999px;

  background: var(--primary-color);
  color: #ffffff;

  box-shadow: var(--shadow-small);

  font-size: 1rem;
  font-weight: 700;
}

.primary-button {
  min-width: 220px;
  min-height: 56px;
  padding: 12px 30px;

  border: 0;
  border-radius: 999px;

  background:
    linear-gradient(
      135deg,
      var(--primary-color),
      var(--primary-dark)
    );

  color: #ffffff;

  font-size: 1.08rem;
  font-weight: 700;

  box-shadow:
    0 9px 0 #06483f,
    0 14px 24px rgba(23, 107, 91, 0.23);

  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.primary-button:hover {
  transform: translateY(-2px);

  box-shadow:
    0 11px 0 #06483f,
    0 17px 28px rgba(23, 107, 91, 0.26);
}

.primary-button:active {
  transform: translateY(5px);

  box-shadow:
    0 3px 0 #06483f,
    0 8px 14px rgba(23, 107, 91, 0.2);
}

.game-status {
  min-height: 70px;
  padding: 12px 24px;

  display: grid;
  grid-template-columns: minmax(280px, 520px) auto;
  align-items: center;
  justify-content: center;
  gap: 36px;

  border-top: 1px solid var(--border-color);
  background: #ffffff;

  box-shadow:
    0 -6px 20px rgba(24, 73, 62, 0.07);
}

.status-heading {
  margin-bottom: 7px;

  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-track {
  width: 100%;
  height: 12px;

  overflow: hidden;

  border-radius: 999px;
  background: #dce8e4;
}

.progress-bar {
  width: 0%;
  height: 100%;

  border-radius: inherit;

  background:
    linear-gradient(
      90deg,
      var(--primary-color),
      var(--secondary-color)
    );

  transition: width 500ms ease;
}

.game-status strong {
  color: var(--primary-color);
}

/* 任務嚮導 */
.guide-layout {
  margin: 24px 0;
  display: grid;
  grid-template-columns: 230px 1fr;   /*左欄人物：230px 右欄對話框：剩餘空間*/
  align-items: center;
  gap: 0px;
}

.character-placeholder {
  min-height: 250px;
  padding: 5px;
  display: grid;
  place-content: center;
  gap: 10px;
}

.character-image {
  display: block;

  width: 220px;
  height: 230px;

  object-fit: contain;
  object-position: center bottom;

  filter:
    drop-shadow(
      0 8px 12px
      rgba(33, 55, 70, 0.18)
    );
}

/* 守護手冊 */

.badge-book {
  width: min(100%, var(--dialogue-max-width));

  margin: var(--space-7) auto;

  padding: var(--space-6);

  border:
    2px solid
    var(--border-color);

  border-radius: var(--radius-large);

  background: var(--card-background);

  box-shadow: var(--shadow-medium);
}

.badge-book-heading {
  margin-bottom: var(--space-5);

  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);

  text-align: left;
}

.badge-book-label {
  margin: 0 0 var(--space-1);

  color:
    var(--primary-color);

  font-size:
    var(--font-size-small);

  font-weight:
    var(--font-weight-bold);

  letter-spacing: 0.08em;
}

.badge-book-heading h2 {
  margin: 0;

  color:
    var(--primary-dark);

  font-size:
    var(--font-size-large);
}

.badge-book-progress {
  margin: 0;

  color:
    var(--muted-text);

  font-size:
    var(--font-size-body);
}

.badge-book-progress strong {
  color:
    var(--primary-color);

  font-size:
    var(--font-size-medium);
}

.badge-book-stage {
  position: relative;
  width: 100%;
  overflow: visible;
  background: transparent;
}

.badge-book-background {
  display: block;

  width: 100%;
  height: auto;

  object-fit: contain;
  pointer-events: none;
}

.badge-book-slots {
  position: absolute;
  inset: 0;

  pointer-events: none;
}

.badge-book-slot {
  position: absolute;

  width: clamp(
    70px,
    13vw,
    145px
  );

  display: flex;
  align-items: center;
  flex-direction: column;

  gap: 4px;

  transform: translate(
    -50%,
    -50%
  );

  text-align: center;
}

.badge-book-slot:nth-child(1) {
  left: 30.25%;
  top: 35%;
}

.badge-book-slot:nth-child(2) {
  left: 50%;
  top: 35%;
}

.badge-book-slot:nth-child(3) {
  left: 69.7%;
  top: 35%;
}

.badge-book-slot:nth-child(4) {
  left: 39.9%;
  top: 67%;
}

.badge-book-slot:nth-child(5) {
  left: 60%;
  top: 67%;
}

.badge-book-image-frame {
  width: clamp(
    58px,
    9vw,
    105px
  );

  aspect-ratio: 1;

  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-book-image {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: contain;
}

.badge-book-slot.is-unlocked
.badge-book-image {
  filter:
    drop-shadow(
      0 8px 10px
      rgba(33, 55, 70, 0.18)
    )
    drop-shadow(
      0 0 10px
      rgba(243, 187, 63, 0.38)
    );

  animation:
    unlockedBadgeAppear
    var(--transition-slow)
    var(--ease-bounce)
    both;
}

.badge-book-slot.is-unlocked:hover
.badge-book-image {
  transform:
    translateY(-5px)
    scale(1.06);
}

.badge-book-slot.is-locked
.badge-book-image {
  opacity: 0.7;

  filter:
    grayscale(0.45)
    drop-shadow(
      0 5px 8px
      rgba(33, 55, 70, 0.12)
    );
}

@keyframes unlockedBadgeAppear {
  from {
    opacity: 0;

    transform:
      translateY(12px)
      scale(0.72);
  }

  to {
    opacity: 1;

    transform:
      translateY(0)
      scale(1);
  }
}

.mission-complete-badge-image {
  position: relative;
  z-index: 1;

  display: block;

  width: 300px;
  height: 300px;

  object-fit: contain;

  filter:
    drop-shadow(
      0 14px 18px
      rgba(33, 55, 70, 0.24)
    );
}

/* 任務場景 */

.mission-panel {
  width: min(100%, 1180px);
  padding: 32px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--panel-background);
  box-shadow: 0 18px 45px rgba(29, 73, 61, 0.12);
}

.mission-heading {
  text-align: center;
}

.mission-heading h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3rem);
}

.system-status {
  margin: 0 0 24px;
  color: var(--muted-text);
}

.system-status strong {
  color: #a85b16;
}

/* 題目區 */

.question-card {
  margin-top: 28px;
  padding: 28px;
  border: 2px solid #b8d3cb;
  border-radius: 18px;
  background: #f7fbfa;
}

.question-hint {
  margin: 0 0 8px;
  color: var(--primary-color);
  font-weight: 700;
}

.question-card h2 {
  margin: 0 0 24px;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  line-height: 1.5;
}

.answer-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.answer-option {
  min-height: 68px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 2px solid #b9cbc5;
  border-radius: 14px;
  background: #ffffff;
  color: var(--text-color);
  text-align: left;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background-color 150ms ease;
}

.answer-option:hover:not(:disabled) {
  border-color: var(--primary-color);
  background: #edf8f4;
  transform: translateY(-2px);
}

.answer-option:disabled {
  cursor: default;
}

.option-marker {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  background: #e2eeea;
  color: var(--primary-dark);
  font-weight: 700;
}

.option-text {
  line-height: 1.5;
}

.answer-option.is-selected {
  border-width: 3px;
}

.answer-option.is-correct {
  border-color: #278147;
  background: #e7f7eb;
}

.answer-option.is-correct .option-marker {
  background: #278147;
  color: #ffffff;
}

.answer-option.is-incorrect {
  border-color: #b94b43;
  background: #fce9e7;
}

.answer-option.is-incorrect .option-marker {
  background: #b94b43;
  color: #ffffff;
}

/* 作答回饋 */

.feedback-area {
  margin-top: 24px;
}

.answer-feedback {
  padding: 26px;
  border-radius: 18px;
  text-align: center;
}

.feedback-correct {
  border: 2px solid #65a879;
  background: #eff9f2;
}

.feedback-incorrect {
  border: 2px solid #d19c54;
  background: #fff7e9;
}

.feedback-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.feedback-heading h2 {
  margin: 0;
}

.feedback-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  background: var(--primary-color);
  color: #ffffff;
  font-size: 1.5rem;
  font-weight: 700;
}

.feedback-dialogue {
  margin-top: 36px;
  margin-bottom: 5px;
  text-align: left;
}

.badge-earned {
  width: min(100%, 270px);
  margin: 22px auto;
  padding: 20px;
  border: 2px dashed var(--primary-color);
  border-radius: 20px;
  background: #ffffff;
  animation: badgeAppear 600ms ease-out;
}

.badge-earned-label {
  margin: 0 0 8px;
  color: #755213;
  font-weight: 700;
}

.earned-badge-icon {
  margin-bottom: 6px;
  font-size: 4rem;
}

.answer-result-reward {
  width: min(100%, 500px);      /* 螢幕小時，寬度最多用 100% 螢幕大時，最大不超過 900px */
  margin: 10px auto;

  display: grid;
  grid-template-columns:
    minmax(300px, 500px)
    minmax(300px, 500px);

  align-items: center;
  justify-content: center;

  gap: 0px;
}

.answer-result-badge-image {
  display: block;

  width: clamp(
    200px,
    20vw,
    240px
  );

  height: auto;

  margin: 0 auto;

  object-fit: contain;

  filter:
    drop-shadow(
      0 10px 14px
      rgba(33, 55, 70, 0.22)
    );

  animation:
    badgeAppear
    550ms
    var(--ease-bounce)
    both;
}

.answer-result-badge-name {
  margin: var(--space-2) 0 0;

  color: var(--primary-color);

  font-size: var(--font-size-large);
  font-weight: var(--font-weight-bold);

  line-height: var(--line-height-tight);
  text-align: center;
}

.answer-result-guide {
  position: relative;
  top: 0px;
}

.answer-result-guide img {
  width: clamp(
    280px,
    24vw,
    400px
  );

  height: auto;

  object-fit: contain;
  object-position: center bottom;

  filter:
    drop-shadow(
      0 12px 16px
      rgba(33, 55, 70, 0.22)
    );
}

/* 第一個系統恢復 */

.system-restored-animation {
  min-height: 210px;
  margin: 28px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  border-radius: 24px;
  background:
    radial-gradient(
      circle at center
    );
  font-size: 2.8rem;
}

.restored-center {
  font-size: 5rem;
  animation: centerPulse 1.4s ease-in-out infinite;
}

@keyframes badgeAppear {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
  }

  70% {
    transform: scale(1.08) rotate(3deg);
  }

  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes centerPulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }
}

/* 永續研究室 */

.completed-scene-symbol {
  font-size: 6rem;
  animation: centerPulse 1.4s ease-in-out infinite;
}

/* 第三題完成資訊 */

.completion-details {
  margin: 24px 0;
  padding: 24px;
  border: 2px solid #8ab77f;
  border-radius: 18px;
  background: #f1faed;
  text-align: left;
}

.completion-details h2 {
  margin: 0 0 18px;
  color: #356530;
  font-size: 1.3rem;
  text-align: center;
}

.completion-details ul {
  max-width: 620px;
  margin: 0 auto;
  padding: 0;
  display: grid;
  gap: 12px;
  list-style: none;
}

.completion-details li {
  min-height: 52px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  background: #ffffff;
  font-weight: 700;
}

.completion-details li > span:first-child {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  background: #4d9450;
  color: #ffffff;
}

/* 結局 */

.final-panel {
  width: min(100%, 1180px);
  padding: 36px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--panel-background);
  box-shadow: 0 18px 45px rgba(29, 73, 61, 0.12);
  text-align: center;
}

.final-panel h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3.6rem);
}

.final-introduction {
  color: var(--muted-text);
  font-size: 1.15rem;
}

.all-characters {
  margin: 24px 0;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  
  border-radius: 18px;
  background: #eef8f4;
}

.all-characters span {
  padding: 7px 12px;
  border-radius: 999px;
  background: #ffffff;
}

.all-characters strong {
  width: 100%;
  margin-top: 18px;
  color: var(--sustainability-dark);
  font-size: 1.5rem;
}

.ending-animation-panel {
  width: min(
    100%,
    var(--content-max-width)
  );

  margin: 0 auto;
  padding: var(--space-7);

  text-align: center;
}

.ending-animation-heading {
  margin-bottom: var(--space-6);
}

.ending-animation-heading h1 {
  margin:
    var(--space-2)
    0
    var(--space-3);

  color: var(--primary-dark);

  font-size: var(--font-size-title);
}

.ending-map-stage {
  position: relative;

  width: 100%;
  overflow: hidden;

  aspect-ratio: 16 / 9;

  border-radius: var(--radius-large);

  background:
    var(--image-placeholder-background);

  box-shadow: var(--shadow-large);
}

.ending-map-image {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: contain;

  opacity: 1;
  transform: scale(1);

  transition:
    opacity 300ms ease,
    transform 800ms ease;
}

.ending-map-image.is-changing {
  opacity: 0;
  transform: scale(1.02);
}

.ending-map-image.is-final-map {
  animation:
    finalMapGlow
    1800ms
    ease-out
    both;
}

@keyframes finalMapGlow {
  0% {
    filter:
      brightness(0.9)
      saturate(0.9);

    transform: scale(1);
  }

  50% {
    filter:
      brightness(1.2)
      saturate(1.2)
      drop-shadow(
        0 0 24px
        rgba(243, 187, 63, 0.65)
      );

    transform: scale(1.02);
  }

  100% {
    filter:
      brightness(1)
      saturate(1);

    transform: scale(1);
  }
}

/* 證書 */

.mission-certificate {
  margin-top: 30px;
  padding: 36px;
  border: 10px double #c39b44;
  border-radius: 16px;
  background:
    linear-gradient(
      135deg,
      #fffef7,
      #fff7d6
    );
  box-shadow: 0 16px 30px rgba(76, 57, 18, 0.18);
}

.certificate-subtitle {
  margin: 0 0 8px;
  color: #6e5726;
  font-weight: 700;
}

.mission-certificate h2 {
  margin: 0;
  color: #4f3c16;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
}

.certificate-star {
  margin: 18px 0;
  color: #d99c13;
  font-size: 5rem;
}

.certificate-results {
  width: min(100%, 680px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.certificate-results div {
  padding: 16px;
  border: 1px solid #d9c17d;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
}

.certificate-results dt {
  margin-bottom: 7px;
  color: #786432;
  font-weight: 700;
}

.certificate-results dd {
  margin: 0;
  color: var(--primary-dark);
  font-size: 1.35rem;
  font-weight: 700;
}

.certificate-message {
  color: #66552d;
}

.certificate-actions {
  margin-top: 26px;
  display: flex;
  justify-content: center;
  gap: 14px;
}

.secondary-button {
  min-width: 180px;
  min-height: 56px;
  padding: 12px 28px;
  border: 2px solid var(--primary-color);
  border-radius: 14px;
  background: #ffffff;
  color: var(--primary-dark);
  font-size: 1.1rem;
  font-weight: 700;
}

.secondary-button:hover {
  background: #eaf5f2;
}

/* 第一幕：地圖與院長 */

.opening-title {
  margin: 0 auto var(--space-4);

  color: var(--primary-dark);

  font-size: var(--font-size-hero);
  line-height: var(--line-height-tight);
}

.opening-visual {
  position: relative;
  overflow: visible;
  margin-bottom: 90px;
}

.opening-map {
  overflow: hidden;
}

.opening-map img {
  display: block;

  width: 100%;
  height: 100%;

  object-fit: contain;
}

.opening-character-area {
  position: absolute;
  right: -30px;
  bottom: -80px;
  z-index: var(--z-character);
  width: clamp(190px,24vw,320px);
  pointer-events: none;
}

.opening-character {
  display: block;

  width: 100%;
  height: auto;

  object-fit: contain;

  filter:
    drop-shadow(
      0 14px 16px
      rgba(25, 47, 66, 0.24)
    );

  animation:
    openingCharacterEnter
    var(--transition-slow)
    var(--ease-out)
    both;
}

.opening-dialogue {
  position: relative;
  z-index: var(--z-panel);

  width: 100%;
  max-width: var(--dialogue-max-width);
  margin:
    0
    auto
    var(--space-4);
}

@keyframes openingCharacterEnter {
  from {
    opacity: 0;

    transform:
      translateX(28px)
      translateY(12px);
  }

  to {
    opacity: 1;

    transform:
      translateX(0)
      translateY(0);
  }
}