/* 
 * 引用外部 Google Fonts 線上字型
 * 來源：https://fonts.google.com/
 * 原因用途：為遊戲提供 Fredoka (英文) 與 Noto Sans TC (中文) 的美觀字體，改善 HUD 與選單 UI 的視覺質感與字體可讀性。
 * 離線後備：由於 Noto Sans TC 中文字型體積巨大，為免專案體積膨脹，採用線上加載。
 *           在完全離線（斷網）遊玩時，瀏覽器會自動回退至本機系統內建字型（如 Windows 下的微軟正黑體 'Microsoft JhengHei'），遊戲功能與排版依然 100% 正常運行。
 */
@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&family=Noto+Sans+TC:wght@400;700;900&display=swap');

:root {
  --font-primary: 'Fredoka', 'Noto Sans TC', sans-serif;
  --color-bg: #e0f2fe; /* 天空藍底色 */
  --color-chalkboard: #1e3f20; /* 黑板深綠 */
  --color-board-border: #8b5a2b; /* 木質邊框 */
  --color-accent-yellow: #fef08a; /* 亮黃 */
  --color-accent-pink: #fbcfe8; /* 粉紅 */
  --color-p1: #3b82f6; /* 1P 藍 */
  --color-p2: #ef4444; /* 2P 紅 */
  --color-text-light: #ffffff;
  --color-text-dark: #1e293b;
  --shadow-wood: 0 8px 0 #5c3a1a, 0 15px 20px rgba(0, 0, 0, 0.3);
  --shadow-btn-p1: 0 6px 0 #1d4ed8, 0 10px 15px rgba(59, 130, 246, 0.4);
  --shadow-btn-p2: 0 6px 0 #b91c1c, 0 10px 15px rgba(239, 68, 68, 0.4);
  --shadow-btn-yellow: 0 6px 0 #ca8a04, 0 10px 15px rgba(234, 179, 8, 0.4);
  --shadow-btn-gray: 0 6px 0 #4b5563, 0 10px 15px rgba(75, 85, 99, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: var(--font-primary);
  background: radial-gradient(circle at center, #bae6fd 0%, #0284c7 100%);
  color: var(--color-text-dark);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* 遊戲容器限制 16:9，在大螢幕下自動拉大，最大化利用空間並維持黃金比例 */
#game-container {
  position: relative;
  width: 98vw;
  height: calc(98vw / (16 / 9));
  background-color: var(--color-chalkboard);
  border: 24px solid var(--color-board-border);
  border-radius: 24px;
  box-shadow: var(--shadow-wood);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: auto; /* 在螢幕正中央對齊 */
  container-type: size; /* 啟用容器查詢，以利 HUD 等比例自適應縮放 */
}

/* 當螢幕高寬比限制時 (例如偏寬的螢幕)，以高度為準計算寬度，防止高度超出 Viewport */
@media (min-aspect-ratio: 16/9) {
  #game-container {
    height: 96vh;
    width: calc(96vh * (16 / 9));
  }
}

/* 畫布 */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  background: transparent;
  cursor: none; /* 隱藏預設滑鼠指針，使用遊戲自訂準星 */
}

/* 場景覆蓋層 (全螢幕 DOM) */
.scene {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(30, 63, 32, 0.95); /* 黑板綠半透明 */
  color: var(--color-text-light);
  padding: 40px;
  transition: opacity 0.3s ease;
}

.scene.hidden {
  opacity: 0;
  pointer-events: none;
  z-index: -1;
}

/* 首頁特有樣式 */
#home-scene {
  background: linear-gradient(135deg, rgba(30, 63, 32, 0.98) 0%, rgba(15, 32, 16, 0.98) 100%);
}

/* 首頁左下角授權小字 */
.home-footer-license {
  position: absolute;
  bottom: 3.5cqh;
  left: 2.5cqw;
  text-align: left;
  font-size: 1.15cqw;
  color: rgba(255, 255, 255, 0.35);
  line-height: 1.5;
  pointer-events: auto;
  z-index: 15;
}

.home-footer-license p {
  margin: 0;
}

.home-footer-license a {
  color: rgba(255, 255, 255, 0.4);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.home-footer-license a:hover {
  color: var(--color-accent-yellow);
}

#home-scene::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 2px, transparent 2px);
  background-size: 30px 30px;
  pointer-events: none;
}

/* 遊戲標題 */
.game-title {
  font-size: 5rem;
  font-weight: 900;
  color: var(--color-accent-yellow);
  text-shadow: 0 4px 0 #ca8a04, 0 8px 16px rgba(0,0,0,0.5);
  margin-bottom: 5px;
  letter-spacing: 4px;
  animation: float 3s ease-in-out infinite;
}

.game-subtitle {
  font-size: 1.8rem;
  color: var(--color-accent-pink);
  margin-bottom: 40px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  font-weight: 700;
}

/* 按鈕群組 */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 320px;
}

.btn-row {
  display: flex;
  gap: 15px;
  width: 100%;
}

.btn-row .btn {
  flex: 1;
}

/* 通用按鈕 */
.btn {
  font-family: var(--font-primary);
  font-size: 1.4rem;
  font-weight: 700;
  padding: 14px 28px;
  border: none;
  border-radius: 16px;
  color: var(--color-text-light);
  cursor: pointer;
  transition: all 0.1s ease, transform 0.2s ease;
  position: relative;
  top: 0;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  white-space: nowrap; /* 確保中文字絕對不換行，解決跑版問題 */
}

.btn:active {
  top: 6px;
}

/* 按鈕顏色變體 */
.btn-primary {
  background-color: var(--color-p1);
  box-shadow: var(--shadow-btn-p1);
}
.btn-primary:active {
  box-shadow: 0 0px 0 #1d4ed8, 0 4px 6px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
  background-color: var(--color-p2);
  box-shadow: var(--shadow-btn-p2);
}
.btn-secondary:active {
  box-shadow: 0 0px 0 #b91c1c, 0 4px 6px rgba(239, 68, 68, 0.4);
}

.btn-accent {
  background-color: #eab308;
  color: #422006;
  box-shadow: var(--shadow-btn-yellow);
}
.btn-accent:active {
  box-shadow: 0 0px 0 #ca8a04, 0 4px 6px rgba(234, 179, 8, 0.4);
}

.btn-gray {
  background-color: #6b7280;
  box-shadow: var(--shadow-btn-gray);
}
.btn-gray:active {
  box-shadow: 0 0px 0 #4b5563, 0 4px 6px rgba(75, 85, 99, 0.4);
}

/* Hover 特效 */
.btn:hover {
  transform: scale(1.03);
  filter: brightness(1.08);
}

/* 模式選擇與難度選擇 */
.panel-title {
  font-size: 2.2rem;
  color: var(--color-accent-yellow);
  margin-bottom: 25px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
  font-weight: 700;
}

.grid-select {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  width: 560px;
  margin-bottom: 30px;
}

.difficulty-card {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.difficulty-card:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: var(--color-accent-yellow);
  transform: translateY(-2px);
}

.difficulty-card.selected {
  background: rgba(234, 179, 8, 0.2);
  border-color: var(--color-accent-yellow);
  box-shadow: 0 0 15px rgba(234, 179, 8, 0.3);
}

.diff-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-accent-yellow);
  margin-bottom: 5px;
}

.diff-desc {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.3;
}

/* 教學畫面 */
.tutorial-box {
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 20px;
  padding: 2.5vh 4vh;
  width: 92%;
  max-width: 1300px; /* 加寬以善用空間 */
  max-height: 48vh;  /* 提升高度，並預留返回按鈕空間 */
  overflow-y: auto;  /* 當內容過多時顯示垂直滾動條 */
  margin-bottom: 2.5vh;
  text-align: left;  /* 強制靠左對齊，防範 justify 大空白問題 */
  
  /* 融入黑板風格的自訂捲軸 */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(0, 0, 0, 0.2);
}

.tutorial-box::-webkit-scrollbar {
  width: 8px;
}

.tutorial-box::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.tutorial-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.tutorial-box::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

.tutorial-box h3 {
  color: var(--color-accent-yellow);
  margin-bottom: 1.5vh;
  font-size: 1.45rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
  padding-bottom: 0.8vh;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.tutorial-box ul {
  list-style-type: none;
  text-align: left;
}

.tutorial-box li {
  margin-bottom: 1.5vh;
  font-size: 1.1rem;
  line-height: 1.6;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  position: relative;
  padding-left: 24px; /* 預留給星星的空間 */
}

.tutorial-box li::before {
  content: '★';
  color: var(--color-accent-pink);
  position: absolute;
  left: 0;
  top: 1px;
}

/* 黑板手繪粉筆質感標籤 */
.chalk-badge {
  background: rgba(254, 240, 138, 0.12); /* 黃色半透明 */
  border: 1.5px dashed rgba(254, 240, 138, 0.4);
  padding: 1px 8px;
  border-radius: 6px;
  color: var(--color-accent-yellow);
  font-family: monospace;
  font-weight: 700;
  margin: 0 4px;
  display: inline-block;
  font-size: 0.95rem;
}

.chalk-badge-pink {
  background: rgba(251, 207, 232, 0.12); /* 粉紅半透明 */
  border: 1.5px dashed rgba(251, 207, 232, 0.4);
  padding: 1px 8px;
  border-radius: 6px;
  color: var(--color-accent-pink);
  font-weight: 700;
  margin: 0 4px;
  display: inline-block;
  font-size: 0.95rem;
}

/* 右上角 ✕ 關閉按鈕樣式 */
#btn-tutorial-close, #btn-license-close {
  position: absolute;
  top: 30px;
  right: 45px;
  background: rgba(239, 68, 68, 0.9); /* 明亮顯眼的紅色，方便光槍與滑鼠瞄準 */
  border: 2px solid rgba(255, 255, 255, 0.4);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: white;
  font-size: 1.8rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: all 0.2s ease, transform 0.1s ease;
  z-index: 100;
}

#btn-tutorial-close:hover, #btn-license-close:hover {
  background: rgba(220, 38, 38, 1);
  transform: scale(1.08);
  border-color: white;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}

#btn-tutorial-close:active, #btn-license-close:active {
  transform: scale(0.95);
}

/* 右上角全螢幕切換按鈕樣式 */
.btn-fullscreen-top {
  position: absolute;
  top: 30px;
  right: 45px;
  background: rgba(234, 179, 8, 0.85); /* 黃色 */
  border: 2px solid rgba(255, 255, 255, 0.4);
  padding: 10px 22px;
  border-radius: 12px;
  color: #422006;
  font-size: 1.15rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: all 0.2s ease, transform 0.1s ease;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-fullscreen-top:hover {
  background: rgba(234, 179, 8, 1);
  transform: scale(1.06);
  border-color: white;
  box-shadow: 0 6px 16px rgba(0,0,0,0.5);
}

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

/* 配置設定畫面 */
.settings-box {
  background: rgba(255, 255, 255, 0.08);
  border: 3px dashed rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 24px 30px;
  width: 100%;
  max-width: 680px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
}

.settings-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-label {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text-light);
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.settings-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* 加減按鈕 - 優化以方便光槍與滑鼠操作 */
.btn-adjust {
  width: 60px; /* 從 48px 放大到 60px */
  height: 52px; /* 從 48px 放大到 52px */
  background-color: var(--color-p1);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  color: white;
  font-size: 2rem; /* 增大字型 */
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 0 #1d4ed8, 0 6px 12px rgba(0,0,0,0.3);
  transition: all 0.1s ease, transform 0.2s ease;
  position: relative;
  top: 0;
}

.btn-adjust:hover {
  transform: scale(1.08);
  filter: brightness(1.1);
  border-color: white;
}

.btn-adjust:active {
  top: 4px;
  box-shadow: 0 0px 0 #1d4ed8, 0 2px 4px rgba(0,0,0,0.3);
}

/* 減少按鈕採用灰色，增加按鈕用藍色做區分 */
#btn-setting-repeat-dec, #btn-setting-voice-dec, #btn-setting-sfx-dec {
  background-color: #6b7280; /* 灰色 */
  box-shadow: 0 4px 0 #4b5563, 0 6px 10px rgba(0,0,0,0.3);
}
#btn-setting-repeat-dec:active, #btn-setting-voice-dec:active, #btn-setting-sfx-dec:active {
  box-shadow: 0 0px 0 #4b5563, 0 2px 4px rgba(0,0,0,0.3);
}

#btn-setting-repeat-inc, #btn-setting-voice-inc, #btn-setting-sfx-inc {
  background-color: var(--color-p1); /* 藍色 */
}

.settings-value {
  font-size: 1.35rem;
  font-weight: bold;
  color: var(--color-accent-yellow);
  min-width: 90px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 暫停選單與結算選單 */
.modal-box {
  background: linear-gradient(135deg, rgba(30, 50, 32, 0.98) 0%, rgba(10, 20, 10, 0.98) 100%);
  border: 8px solid var(--color-board-border);
  border-radius: 24px;
  padding: 40px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  max-width: 600px;
  width: 90%;
  z-index: 100;
}

.modal-title {
  font-size: 3rem;
  color: var(--color-accent-yellow);
  margin-bottom: 20px;
  font-weight: 900;
  text-shadow: 0 3px 0 #ca8a04;
}

.results-summary {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 30px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 20px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  font-size: 1.3rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.result-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.result-val {
  font-weight: 700;
  color: var(--color-accent-yellow);
}

.vs-results {
  display: flex;
  gap: 20px;
  margin-bottom: 25px;
}

.vs-player-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 15px;
}

.vs-player-card.p1-border {
  border-color: rgba(59, 130, 246, 0.6);
}

.vs-player-card.p2-border {
  border-color: rgba(239, 68, 68, 0.6);
}

.vs-player-card.winner {
  background: rgba(234, 179, 8, 0.1);
  border-color: var(--color-accent-yellow);
  animation: winPulse 2s infinite;
}

.vs-winner-banner {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--color-accent-yellow);
  margin-bottom: 10px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* 遊戲畫面上方的 HUD (非 Canvas 渲染，可提高文字清晰度與操作彈性) */
/* 雖然 Canvas 可以繪製，但以 DOM Overlay 做 HUD 更好調整並支援動畫 */
#hud-overlay {
  position: absolute;
  top: 14px;
  left: 0;
  width: 100%;
  height: 11cqh;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 3.5cqw;
  pointer-events: none; /* 讓點擊穿透到 Canvas */
  color: white;
  text-shadow: 0 0.2cqw 0.4cqw rgba(0,0,0,0.8);
}

/* SVG 通用圖示樣式 */
.icon-svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  display: inline-block;
  transition: transform 0.2s ease;
}

/* 填滿型 SVG 圖示 (如心形、皇冠) */
.icon-svg-fill {
  fill: currentColor;
  stroke: none;
}

/* 按鈕內圖示微調 */
.btn .icon-svg {
  margin-right: 8px;
}

/* 鍵盤或小標籤內圖示微調 */
.chalk-badge .icon-svg, .chalk-badge-pink .icon-svg {
  margin-right: 4px;
}

/* 愛心生命值樣式 */
.hud-heart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2cqw;
  height: 2.2cqw;
  margin: 0 0.1cqw;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
}

.hud-heart.active {
  color: #ef4444;
  filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.4));
  animation: heartPulse 1.5s infinite alternate ease-in-out;
}

.hud-heart.empty {
  color: rgba(255, 255, 255, 0.15);
  filter: grayscale(1);
}

@keyframes heartPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

.hud-panel {
  display: flex;
  align-items: center;
  gap: 1.2cqw;
  background: rgba(0, 0, 0, 0.4);
  padding: 0.6cqw 1.2cqw;
  border-radius: 1cqw;
  border: 0.1cqw solid rgba(255, 255, 255, 0.1);
  pointer-events: auto; /* 允許滑動或按鈕點擊 */
}

.hud-player {
  display: flex;
  flex-direction: column;
}

.hud-player span {
  font-size: 1.1cqw;
}

.hud-player.p1 {
  color: #93c5fd;
}

.hud-player.p2 {
  color: #fca5a5;
}

.hud-score {
  font-size: 1.6cqw;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  gap: 0.6cqw;
  margin-top: 0.2cqw;
}

#p1-score, #p2-score {
  font-size: 3.2cqw;
  color: var(--color-accent-yellow);
  line-height: 1;
}

.hud-combo {
  font-size: 1.2cqw;
  font-weight: 700;
  background: #ea580c;
  color: white;
  padding: 0.2cqw 0.6cqw;
  border-radius: 0.4cqw;
  margin-left: 0.5cqw;
  display: inline-block;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hud-combo.visible {
  opacity: 1;
}

/* 中央題目顯示 */
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4cqw;
}

.hud-question-container {
  display: flex;
  align-items: center;
  gap: 1cqw;
  background: rgba(0,0,0,0.5);
  padding: 0.5cqw 2cqw;
  border-radius: 2.5cqw;
  border: 0.2cqw solid var(--color-accent-yellow);
}

.hud-question-label {
  font-size: 1.5cqw;
  color: var(--color-accent-yellow);
}

.hud-question-char {
  font-size: 3cqw;
  font-weight: 900;
  color: white;
}

.btn-replay-audio {
  background: #ea580c;
  border: none;
  width: 3.5cqw;
  height: 3.5cqw;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.6cqw;
  transition: all 0.1s ease;
  box-shadow: 0 0.3cqw 0 #9a3412;
}

.btn-replay-audio:active {
  transform: translateY(0.3cqw);
  box-shadow: none;
}

.hud-lives {
  display: flex;
  gap: 0.4cqw;
  font-size: 2cqw;
  color: #ef4444;
}

.hud-timer {
  font-size: 2.2cqw;
  font-weight: 700;
  color: var(--color-accent-yellow);
}

/* 遊戲中鼓勵與提示文字 overlay */
#feedback-overlay {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 5cqw;
  font-weight: 900;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-shadow: 0 0.4cqw 0.8cqw rgba(0,0,0,0.5);
}

#feedback-overlay.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#feedback-overlay.correct {
  color: #4ade80; /* 綠色 */
}

#feedback-overlay.wrong {
  color: #f87171; /* 紅色 */
}

/* 暫停按鈕放置在右上角 */
#btn-pause-hud {
  background: rgba(255, 255, 255, 0.2);
  border: 0.1cqw solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1.5cqw;
  padding: 0.5cqw 1cqw;
  border-radius: 0.8cqw;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.1s ease;
}

#btn-pause-hud:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 滿血/扣血特效閃爍 */
.flash-red {
  animation: flashRedAnim 0.3s ease-out;
}

/* 動畫定義 */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

@keyframes winPulse {
  0% { box-shadow: 0 0 5px rgba(234, 179, 8, 0.4); }
  50% { box-shadow: 0 0 20px rgba(234, 179, 8, 0.8); }
  100% { box-shadow: 0 0 5px rgba(234, 179, 8, 0.4); }
}

@keyframes flashRedAnim {
  0% { box-shadow: inset 0 0 0px rgba(239, 68, 68, 0); }
  50% { box-shadow: inset 0 0 100px rgba(239, 68, 68, 0.8); }
  100% { box-shadow: inset 0 0 0px rgba(239, 68, 68, 0); }
}

/* 選單用光線槍 DOM 準星 */
.dom-crosshair {
  position: fixed; /* 改成 fixed，確保相對於視窗 Viewport 定位 */
  width: 44px;
  height: 44px;
  border: 4px dashed;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none; /* 穿透滑鼠事件 */
  z-index: 9999; /* 永遠在最上層，蓋過所有 scene overlay */
  transition: transform 0.05s ease-out; /* 微幅延遲讓移動更平滑 */
}

.dom-crosshair.p1 {
  border-color: #3b82f6;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
  color: #3b82f6;
}

.dom-crosshair.p2 {
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
  color: #ef4444;
}

/* 準星中心點 */
.dom-crosshair::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  background-color: currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

/* 全域隱藏類別 (解決場景重疊殘留與跑版之根本問題) */
.hidden {
  display: none !important;
}

/* 禁用按鈕樣式 */
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
  transform: none !important;
}

/* Webcam 體感預覽容器 */
#webcam-container {
  position: absolute;
  bottom: 25px;
  right: 25px;
  width: 160px;
  height: 120px;
  border-radius: 12px;
  border: 2px solid var(--color-accent-yellow);
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 15px rgba(234, 179, 8, 0.4);
  overflow: hidden;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: opacity 0.3s ease, border-color 0.1s ease, box-shadow 0.1s ease;
}

#webcam-container.hidden {
  opacity: 0;
  pointer-events: none;
}

/* 捏合射擊時的發光效果 */
#webcam-container.shooting {
  border-color: #ef4444;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.8);
}

#webcam-video {
  display: none; /* 隱藏原生影像，改用 canvas 繪製骨架 */
}

#webcam-preview-canvas {
  width: 100%;
  height: 100%;
  transform: scaleX(-1); /* 水平翻轉以提供鏡像體驗 */
  object-fit: cover;
  background-color: #111;
}

#webcam-status {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--color-accent-yellow);
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  font-family: var(--font-primary);
  border: 1px solid rgba(255, 255, 255, 0.1);
}


