* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: "微軟正黑體", sans-serif;
  background-color: #222;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

#game-container {
  width: 1920px;
  height: 1080px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  overflow: hidden;
}

/* ==========================================
   🌀 讀取畫面 (Loading Screen) — 共用系統元件
   固定於視窗座標 (fixed)，不受 #game-container 的縮放影響
   ========================================== */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: black;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: white;
  font-family: sans-serif;
  transition: opacity 0.5s ease;
  padding: 20px;
  box-sizing: border-box;
}

/* 白色圓圈：響應式縮放，最大 250px */
.loading-circle {
  width: 40vw;
  max-width: 250px;
  height: 40vw;
  max-height: 250px;
  background-color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 25px;
  overflow: hidden;
}

/* 讀取主角 */
#loading-deer {
  width: 60%;
  animation: deerRun 0.4s infinite alternate ease-in-out;
}

/* 主角左右晃動動畫 */
@keyframes deerRun {
  0% {
    transform: rotate(-12deg);
  }
  100% {
    transform: rotate(12deg);
  }
}

/* 遊戲讀取中文字：字體大小自動縮放 */
.loading-text {
  font-size: clamp(20px, 5vw, 32px);
  font-weight: bold;
  margin-bottom: 20px;
  letter-spacing: 2px;
}

/* 「...」點點動畫 */
.dot {
  opacity: 0;
  animation: blinkDots 1.5s infinite;
}
.dot-1 {
  animation-delay: 0s;
}
.dot-2 {
  animation-delay: 0.3s;
}
.dot-3 {
  animation-delay: 0.6s;
}

@keyframes blinkDots {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* 讀取條外框：寬度改用百分比適應手機螢幕 */
.progress-bar-container {
  width: 80%;
  max-width: 400px;
  height: 24px;
  border: 3px solid white;
  border-radius: 12px;
  padding: 2px;
  margin-bottom: 15px;
}

/* 讀取條填充 */
#progress-fill {
  height: 100%;
  background-color: white;
  width: 0%;
  border-radius: 6px;
  transition: width 0.1s linear;
}

/* 讀取百分比：字體大小自動縮放 */
#progress-percent {
  font-size: clamp(16px, 4vw, 24px);
  font-weight: bold;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
  display: none;
}

#cheat-zone {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 150px;
  height: 150px;
  z-index: 9999;
}

/* 靜音按鈕 */
#mute-btn {
  position: absolute;
  bottom: 40px;
  right: 40px;
  width: 100px;
  height: 100px;
  z-index: 99999;
  cursor: pointer;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"/></svg>');
  transition: transform 0.1s;
}

#mute-btn.muted {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="gray"><path d="M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.21.05-.42.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"/></svg>');
}

#mute-btn:active {
  transform: scale(0.9);
}

#confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  width: 15px;
  height: 15px;
  animation: fall linear infinite;
}

@keyframes fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(1100px) rotate(720deg);
    opacity: 0;
  }
}

/* 通用 UI */
#title-screen {
  background-image: url("./assets/02.主背景.png");
  z-index: 20;
  display: block;
}

#title-image {
  position: absolute;
  width: 1000px;
  height: 400px;
  background-image: url("./assets/02.遊戲標題.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center top;
  top: 22%;
  left: 50%;
  transform: translateX(-50%) scale(1.5);
}

#start-btn {
  position: absolute;
  width: 500px;
  height: 140px;
  background-image: url("./assets/01.btn_start_normal.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%) scale(1.3);
  cursor: pointer;
  border: none;
  background-color: transparent;
}

#title-character {
  position: absolute;
  width: 400px;
  height: 500px;
  background-image: url("./assets/02.主角_雀躍.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom center;
  bottom: 5%;
  left: 10%;
  transform: scale(1.3);
}

#instruction-screen {
  background-image: url("./assets/02.主背景.png");
  z-index: 15;
  cursor: pointer;
}

#instruction-frame {
  position: absolute;
  width: 1600px;
  height: 900px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.click-to-continue {
  position: absolute;
  bottom: 6%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 36px;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.8);
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

#victory-screen {
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 100;
  cursor: pointer;
}

#victory-image {
  position: absolute;
  width: 800px;
  height: 400px;
  background-image: url("./assets/01.ui_victory.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.5s;
}

#victory-screen.show #victory-image {
  transform: translate(-50%, -50%) scale(1);
}

/* ==========================================
   💀 挑戰失敗畫面 (參考分享畫面的版面形式製作)
   ========================================== */
#gameover-screen {
  background-image: url("./assets/02.遊戲背景.png");
  z-index: 100;
}

#gameover-frame {
  position: absolute;
  width: 1400px;
  height: 800px;
  background-image: url("./assets/02.遊戲說明外框_無字.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#gameover-title {
  position: absolute;
  width: 900px;
  height: 360px;
  background-image: url("./assets/01.ui_gameover.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
}

#gameover-text {
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88%;
  margin: 0;
  text-align: center;
  font-size: 90px;
  line-height: 1.4;
  font-weight: bold;
  color: #4a2e15;
}

#gameover-buttons-container {
  position: absolute;
  bottom: -15%;
  left: 50%;
  transform: translateX(-50%);
}

.gameover-btn {
  width: 520px;
  height: 173px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  border: none;
  background-color: transparent;
  transition: transform 0.1s;
}

.gameover-btn:active {
  transform: scale(0.95);
}

#btn-retry {
  background-image: url("./assets/01.btn_restart_normal.png");
}

#gameover-character {
  position: absolute;
  width: 450px;
  height: 550px;
  background-image: url("./assets/02.主角_懊惱.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom left;
  bottom: 2%;
  left: 5%;
  transform-origin: bottom center;
  animation: sway 3s ease-in-out infinite;
}

/* ==========================================
   🎮 第一關 (器官透視圖 + 對話框) 動畫設定區
   ========================================== */
/* 卡片待命時的上下浮動特效 */
@keyframes card-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

/* 🌟 增強版：卡片答對放上去時的「強烈發光彈跳」特效 */
@keyframes success-pop {
  0% {
    transform: scale(1);
    filter: brightness(1);
    box-shadow: 0 0 0 rgba(255, 215, 0, 0);
  }
  20% {
    transform: scale(1.15);
    filter: brightness(1.2);
    box-shadow:
      0 0 40px rgba(255, 215, 0, 1),
      0 0 20px rgba(255, 255, 255, 1) inset;
    border-color: #fff;
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
    box-shadow: none;
    border: none;
  }
}

/* 🌟 新增：放置位置周圍的「光波擴散」特效 */
@keyframes light-burst {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* 小鹿待命時的「呼吸/微微搖擺」動畫 */
@keyframes char-breathe {
  0%,
  100% {
    transform: scaleY(1) translateY(0);
  }
  50% {
    transform: scaleY(1.02) translateY(-3px);
  }
}

/* 小鹿答對時的「開心跳躍」動畫 */
@keyframes char-jump {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  30% {
    transform: translateY(-30px) scale(1.05);
  }
  50% {
    transform: translateY(0) scale(0.95);
  }
  70% {
    transform: translateY(-15px) scale(1.02);
  }
  80% {
    transform: translateY(0) scale(0.98);
  }
}

/* 小鹿答錯時的「懊惱搖頭」動畫 */
@keyframes char-shake-head {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  20%,
  60% {
    transform: translateX(-15px) rotate(-5deg);
  }
  40%,
  80% {
    transform: translateX(15px) rotate(5deg);
  }
}

/* 定義對話框的「浮動與呼吸光暈」特效 */
@keyframes dialog-float {
  0%,
  100% {
    transform: translateY(0);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  }
  50% {
    transform: translateY(-6px); /* 微微往上浮 */
    box-shadow: 0 12px 25px rgba(255, 204, 0, 0.4); /* 陰影變大，並帶有微微的金黃色光暈 */
  }
}

/* ==========================================
   🎮 第一關 (器官透視圖 + 對話框)
   ========================================== */
#level1-screen {
  background-image: url("./assets/02.遊戲背景.png");
  z-index: 10;
}

#l1-body-overlay {
  position: absolute;
  width: 1900px;
  height: auto;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1;
}

#card-area {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  width: 1700px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
  z-index: 10;
}

.card {
  width: 400px;
  height: 140px;
  background-size: 100% 100%;
  cursor: pointer;
  box-shadow: 2px 4px 8px rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  transition: 0.2s;
  user-select: none;
  touch-action: none;
  animation: card-float 3s ease-in-out infinite;
  opacity: 1 !important; /* 強制不透明 */
  background-size: contain; /* 確保圖檔完整呈現不被切掉 */
  background-repeat: no-repeat;
  background-position: center;
}

.card:nth-child(even) {
  animation-delay: 0.5s;
}
.card:nth-child(3n) {
  animation-delay: 1s;
}

.card.dragging {
  opacity: 0.9;
  z-index: 9999;
  transform: scale(1.05);
  pointer-events: none;
  animation: none;
}

.card:hover,
.card.selected-touch {
  transform: translateY(-5px) scale(1.05);
  border: 4px solid #ffcc00;
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.9);
  animation: none;
}

.card.placed {
  position: relative; /* 🌟 設定相對定位，讓光芒特效能對齊卡片 */
  width: 330px;
  height: 100px;
  cursor: default;
  filter: brightness(1);
  box-shadow: none;
  border: none;
  animation: success-pop 0.6s ease-out forwards;
}

/* 🌟 新增：產生一道擴散的金色/白色光芒 */
.card.placed::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  box-shadow: 0 0 30px 15px rgba(255, 235, 100, 0.9); /* 金黃色光芒 */
  background-color: rgba(255, 255, 255, 0.6); /* 卡片中心閃現白光 */
  pointer-events: none;
  animation: light-burst 0.7s ease-out forwards; /* 播放光波擴散並消失的動畫 */
}

.card.placed:hover {
  transform: none;
}

/* 對應圖片上的金屬方塊位置 */
.drop-zone {
  position: absolute;
  width: 330px;
  height: 100px;
  z-index: 5;
  border-radius: 12px;
  transition: 0.2s;
}

.drop-zone.hovered {
  background-color: rgba(50, 205, 50, 0.5);
  border-color: #32cd32;
  transform: scale(1.05);
}

.drop-zone.filled {
  border: none;
  background-color: transparent;
}

#zone-oral {
  top: 42%;
  left: 29.67%;
}
#zone-lung {
  top: 55.6%;
  left: 29.67%;
}
#zone-liver {
  top: 69.3%;
  left: 29.67%;
}
#zone-fecal {
  top: 83%;
  left: 29.67%;
}
#zone-breast {
  top: 57.1%;
  left: 80.3%;
}
#zone-stomach {
  top: 71%;
  left: 80.3%;
}
#zone-cervical {
  top: 84.5%;
  left: 80.3%;
}

#l1-character-area {
  position: absolute;
  bottom: 0px;
  left: 20px;
  width: 450px;
  height: 400px;
  z-index: 15;
}

/* 主角預設狀態 */
#l1-character {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 400px;
  height: 400px;
  background-image: url("./assets/02.主角_讚.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom left;
  transform-origin: bottom center;
  animation: char-breathe 2.5s ease-in-out infinite;
}

/* 答對時的主角 */
#l1-character.happy {
  background-image: url("./assets/02.主角_雀躍.png");
  animation: char-jump 0.8s ease-in-out;
}

/* 答錯時的主角 */
#l1-character.annoyed {
  background-image: url("./assets/02.主角_懊惱.png");
  animation: char-shake-head 0.5s ease-in-out;
}

/* 文字對話框 */
#l1-dialog {
  position: absolute;
  bottom: 400px;
  left: 20px;
  width: 500px;
  max-width: 500px;
  height: auto;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  z-index: 20;
}

#l1-dialog-text {
  font-size: 32px;
  font-weight: bold;
  color: #333;
  line-height: 1.5;
  text-align: left;
  background-color: rgba(255, 255, 255, 0.85);
  padding: 20px 30px;
  border-radius: 20px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  /* 🌟 已經把無限浮動的 animation 刪除了！ */
}

/* --- 👇 新增以下對話框專用特效 👇 --- */

/* 答對時：文字框瞬間放大並閃耀金光 */
@keyframes dialog-success {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 10px 25px rgba(255, 204, 0, 0.8);
  }
}

/* 答錯時：文字框左右搖晃並閃爍紅光 */
@keyframes dialog-error {
  0%,
  100% {
    transform: translateX(0);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  }
  25%,
  75% {
    transform: translateX(-10px);
    box-shadow: 0 5px 15px rgba(255, 50, 50, 0.6);
  }
  50% {
    transform: translateX(10px);
    box-shadow: 0 5px 15px rgba(255, 50, 50, 0.6);
  }
}

/* 準備給 JS 呼叫的 class */
.dialog-correct-anim {
  animation: dialog-success 0.5s ease-out;
}
.dialog-error-anim {
  animation: dialog-error 0.4s ease-out;
}

.wrong-shake {
  animation: shake 0.4s !important;
  border-color: #ff3333 !important;
}

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

/* ==========================================
   🧩 第二關 (抓物機/夾娃娃機)
   ========================================== */
#level2-screen {
  background-image: url("./assets/02.遊戲背景.png"); /* 修改這裡的檔名 */
  z-index: 10;
  cursor: crosshair;
  overflow: hidden;
}

/* 💖 生命值顯示區 (左上角) */
#l2-health-bar {
  position: absolute;
  top: 30px;
  left: 30px;
  display: flex;
  gap: 15px;
  z-index: 30;
}

.heart {
  width: 70px;
  height: 70px;
  background-image: url("./assets/生命值愛心_正常.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transition:
    transform 0.3s,
    filter 0.3s;
}

.heart.lost {
  background-image: url("./assets/生命值愛心_缺少.png");
  transform: scale(0.9);
  filter: grayscale(0.5);
}

/* 🎯 左下角：篩檢資格字卡 (目標區) */
#l2-target-area {
  position: absolute;
  left: 30px;
  bottom: 30px;
  width: 500px; /* 加寬以容納往右堆疊的卡片 */
  height: 250px;
  z-index: 15;
}

#l2-card-stack {
  position: relative;
  width: 100%;
  height: 100%;
}

.l2-target-card {
  position: absolute;
  width: 550px; /* 字卡的大小 */
  height: 450px;
  bottom: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom left;
  transition: all 0.4s ease-out; /* 消失與出現的轉場動畫 */
  border-radius: 10px;
}

/* 完成該題時消失的特效 (向上飛起並透明) */
.l2-target-card.completed {
  opacity: 0;
  transform: translateY(-40px) scale(0.9);
  pointer-events: none;
}

#l2-current-target {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom left;
  animation: dialog-float 3s ease-in-out infinite; /* 沿用之前的浮動特效 */
}

/* 📖 右下角：收集冊 (預設收起，滑鼠移入展開) */
#l2-collection-area {
  position: absolute;
  right: 30px;
  bottom: 0px;
  width: 400px;
  height: 800px;
  background-image: url("./assets/02.收集冊.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom right;
  z-index: 15;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer; /* 讓滑鼠移過去變成手指頭，提示玩家可以互動 */

  /* 🌟 關鍵修改 1：預設將收集冊往下藏，只露出最上面 80px */
  transform: translateY(700px);

  /* 🌟 關鍵修改 2：設定滑入/滑出的平滑轉場動畫 */
  transition: transform 0.4s ease-out;
}

/* 🌟 新增這段：當滑鼠移上去時，收集冊伸回原本的位置 */
#l2-collection-area:hover {
  transform: translateY(0);
}

/* 收集冊內部擺放卡片的網格 */
#l2-collection-grid {
  display: flex;
  flex-direction: column; /* 🌟 關鍵修改：強制由上到下垂直排列 */
  align-items: center; /* 讓卡片在書頁中水平置中 */
  gap: 4px; /* 卡片上下的間距，可依需求調大或調小 */
  width: 380px;
  height: 520px;
  margin-top: -67px;
}

/* 收集冊內的卡片大小，如果您覺得上下排太擠，可以把高度(height)稍微調小 */
.l2-collected-item {
  width: 280px; /* 稍微調寬一點讓字好看些 */
  height: 85px;
  background-size: 100% 100%;
  border-radius: 5px;
  box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.5);
}

/* 🦌 正下方：主角與底座 */
#l2-player-base {
  position: absolute;
  bottom: -40px;
  left: 55%;
  transform: translateX(-50%);
  width: 550px;
  height: 550px;
  background-image: url("./assets/02.底座x小鹿_一般.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom center;
  z-index: 25;
  transition: background-image 0.1s;
}

/* 發射爪子時的主角狀態 */
#l2-player-base.shooting {
  background-image: url("./assets/02.底座x小鹿_按下.png");
}

/* 🪝 爪子與繩索系統 */
#l2-claw-machine {
  position: absolute;
  bottom: 125px; /* 從底座上方一點的位置發射 */
  left: 59.87%;
  width: 0;
  height: 0;
  z-index: 20;
  overflow: visible;
}

#l2-rope-svg {
  position: absolute;
  top: -1080px;
  left: -960px;
  width: 1920px;
  height: 1080px;
  pointer-events: none;
  overflow: visible;
}

#l2-rope {
  stroke: #333;
  stroke-width: 6;
}

#l2-claw-head {
  position: absolute;
  width: 130px;
  height: 130px;
  top: 0;
  left: 0;

  /* 🌟 1. 新增這行：設定旋轉軸心為「底部正中央」 */
  transform-origin: bottom center;

  /* 🌟 2. 修改這行：Y軸改成 -100%，讓爪子的最底下剛好貼齊發射點 */
  transform: translate(-50%, -100%);

  background-image: url("./assets/02.爪子_開.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: transparent;
  border: none;
  z-index: 21;
}

/* 爪子抓取時的狀態 */
#l2-claw-head.closed {
  background-image: url("./assets/02.爪子_關.png");
}

/* 🎈 漂浮的檢查卡片與障礙物 */
#l2-floating-area {
  position: absolute;

  /* 這裡控制漂浮區域在畫面中的起點位置 */
  top: 0px; /* 數字越大，活動範圍越往下移 */
  left: 200px; /* 數字越大，活動範圍越往右移 */

  /* 這裡控制漂浮區域的大小 (隱形牆壁的範圍) */
  width: 1520px; /* 寬度越小，左右反彈的空間越窄 */
  height: 600px; /* 高度越小，上下反彈的空間越扁 */

  z-index: 5;
  pointer-events: none; /* 讓這層不要擋住滑鼠點擊 */
}

/* 🌟 2. 放大漂浮的卡片 */
.floating-item {
  position: absolute;
  width: 450px; /* 原本是 260px，放大一點 */
  height: 160px; /* 原本是 80px，放大一點 */
  background-size: 100% 100%;
  background-position: center;
  border-radius: 8px;
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.5);
}

/* 🌟 3. 放大漂浮的炸彈/障礙物 */
.floating-bomb {
  position: absolute;
  width: 150px; /* 原本是 120px，放大一點 */
  height: 150px; /* 原本是 120px，放大一點 */
  background-image: url("./assets/02.障礙物.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* ==========================================
   📢 宣導與分享畫面
   ========================================== */
#advocacy-screen {
  background-image: url("./assets/02.遊戲背景.png");
  z-index: 15;
  cursor: pointer;
}

#advocacy-frame {
  position: absolute;
  width: 1600px;
  height: 900px;
  background-image: url("./assets/game2_宣導內容.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#advocacy-character {
  position: absolute;
  width: 450px;
  height: 550px;
  background-image: url("./assets/02.主角_雀躍.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom left;
  bottom: 2%;
  left: 5%;
  transform: scale(1.1) scaleX(-1);
}

#share-screen {
  background-image: url("./assets/02.遊戲背景.png");
  z-index: 15;
}

#share-frame {
  position: absolute;
  width: 1400px;
  height: 800px;
  background-image: url("./assets/game2_分享畫面.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#share-title {
  position: absolute;
  width: 960px;
  height: 300px;
  background-image: url("./assets/01.通過考驗.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
}

#share-buttons-container {
  position: absolute;
  bottom: -15%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 50px;
}

.share-btn {
  width: 390px;
  height: 130px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  border: none;
  background-color: transparent;
  transition: transform 0.1s;
}

#btn-restart {
  background-image: url("./assets/01.btn_restart_normal.png");
}

#btn-restart:active {
  transform: scale(0.95);
}

#btn-share {
  background-image: url("./assets/01.btn_share_normal.png");
}

#btn-share:active {
  transform: scale(0.95);
}

#share-character {
  position: absolute;
  width: 450px;
  height: 550px;
  background-image: url("./assets/02.主角_讚.png");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom left;
  bottom: 2%;
  left: 5%;
  transform-origin: bottom center;
  animation: sway 3s ease-in-out infinite;
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-4deg);
  }
  50% {
    transform: rotate(4deg);
  }
}

/* 🌟 新增：第二關主角專用的搖頭動畫 (保留置中屬性避免跑位) */
@keyframes l2-char-shake {
  0%,
  100% {
    transform: translateX(-50%) rotate(0deg);
  }
  20%,
  60% {
    transform: translateX(calc(-50% - 15px)) rotate(-5deg);
  }
  40%,
  80% {
    transform: translateX(calc(-50% + 15px)) rotate(5deg);
  }
}

/* ❤️ 愛心平時的撲通跳動 */
@keyframes heartbeat {
  0%,
  100% {
    transform: scale(1);
  }
  15% {
    transform: scale(1.15);
  }
  30% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.15);
  }
  60% {
    transform: scale(1);
  }
}

.heart {
  animation: heartbeat 1.5s infinite ease-in-out;
  transform-origin: center;
}

/* 💔 扣血時的特效 (放大閃白後變灰縮小) */
@keyframes lose-heart {
  0% {
    transform: scale(1);
    filter: brightness(1) grayscale(0);
    opacity: 1;
  }
  30% {
    transform: scale(1.4) rotate(-15deg);
    filter: brightness(2);
  }
  100% {
    transform: scale(0.8);
    filter: grayscale(100%);
    opacity: 0.3;
  }
}

.heart.lost {
  /* 覆蓋掉平常的跳動，執行一次扣血動畫並停在最後的狀態 */
  animation: lose-heart 0.5s ease-out forwards;
}

/* 💥 畫面震動特效 (模擬爆炸衝擊波) */
@keyframes screen-shake {
  0% {
    transform: translate(1px, 1px) rotate(0deg);
  }
  10% {
    transform: translate(-2px, -3px) rotate(-1deg);
  }
  20% {
    transform: translate(-4px, 0px) rotate(1deg);
  }
  30% {
    transform: translate(4px, 3px) rotate(0deg);
  }
  40% {
    transform: translate(2px, -1px) rotate(1deg);
  }
  50% {
    transform: translate(-2px, 3px) rotate(-1deg);
  }
  60% {
    transform: translate(-4px, 2px) rotate(0deg);
  }
  70% {
    transform: translate(4px, 2px) rotate(-1deg);
  }
  80% {
    transform: translate(-2px, -2px) rotate(1deg);
  }
  90% {
    transform: translate(2px, 3px) rotate(0deg);
  }
  100% {
    transform: translate(0px, 0px) rotate(0deg);
  }
}

/* 用來觸發震動的 class */
.shake-active {
  animation: screen-shake 0.4s ease-in-out;
}

/* 💥 爆炸全螢幕閃紅光 */
#explosion-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 0, 0, 0.5); /* 半透明的紅色 */
  z-index: 9999; /* 確保蓋在最上層 */
  pointer-events: none; /* 讓閃光不會阻擋滑鼠點擊 */
  opacity: 0;
  transition: opacity 0.1s ease-out;
}

/* 用來觸發紅光的 class */
.flash-active {
  opacity: 1 !important;
}

/* 💣 炸彈平時的危險呼吸與紅光動畫 */
@keyframes bomb-breathing {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.5));
  }
  50% {
    transform: scale(1.1); /* 微微放大 */
    filter: drop-shadow(0 0 15px rgba(255, 0, 0, 1)); /* 紅光變強 */
  }
}

/* 綁定到畫面上漂浮的炸彈 */
.floating-bomb {
  animation: bomb-breathing 1.5s infinite ease-in-out;
}

/* 🌟 關鍵細節：當炸彈被爪子抓住時，停止呼吸動畫 */
/* 這樣才不會跟爪子收回時的「縮小特效」互相衝突 */
#l2-claw-head .floating-bomb {
  animation: none;
}

/* 🔗 分享連結複製成功提示 */
#share-toast {
  position: absolute;
  bottom: 12%;
  left: 50%;
  transform: translate(-50%, 20px);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 28px;
  font-weight: bold;
  padding: 18px 36px;
  border-radius: 50px;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease;
}

#share-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 🌟 第一關自訂拖曳卡片：100% 完全不透明、精準尺寸 */
.custom-drag-ghost {
  opacity: 1 !important;
  pointer-events: none !important; /* 避免擋住下方的判斷 */
  z-index: 9999 !important;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  transform: scale(1.05); /* 拖曳時微幅放大提升手感 */
  transition: transform 0.1s ease;
}
