/* ============================================================
   style.css  ── 基礎樣式
   ============================================================ */

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

body {
  background-color: #1a1a2e;
  color: #e0e0e0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

#screen-map {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100vw;
  min-height: 100vh;
  padding: 16px;
}

#screen-combat,
#screen-shop,
#screen-minigame,
#screen-gameover,
#screen-clear {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100vw;
  height: 100vh;
  padding: 16px;
  overflow: hidden;
}


/* ══════════════════════════════════════════════════════════════
   迷宮地圖畫面 — 左右佈局（全高）
   ══════════════════════════════════════════════════════════════ */

#screen-map {
  padding: 0;
  justify-content: center;
  height: 100vh;
  align-self: stretch;
}

/* 整體左右容器：填滿螢幕高度 */
#map-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 14px;
  height: 100vh;
  padding: 16px 24px;
  box-sizing: border-box;
}

/* 左側地圖欄：垂直置中 viewport */
#map-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 8px;
}

/* viewport wrap：相對定位，讓 map-message 可以浮蓋 */
#map-viewport-wrap {
  position: relative;
  width: 540px;
  flex-shrink: 0;
}

/* 視窗容器（9 格 × 60px = 540px） */
#viewport {
  width: 540px;
  height: 540px;
  border: 3px solid #0f3460;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

/* 提示訊息：絕對定位浮蓋在 viewport 上方 */
#map-message {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background-color: rgba(10, 20, 50, 0.92);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.6);
  border-radius: 8px;
  padding: 6px 18px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

/* 右側面板：全高、column flex */
#map-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
  min-height: 0;
}

/* ── 右側：資源 + 按鈕 + 隊伍 ───────────────────────── */
#side-stats {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 10px;
  padding: 10px 12px;
  flex-shrink: 0;
  overflow-y: auto;
}

.side-section-title {
  display: block;
  font-size: 11px;
  color: #7a8aaa;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 7px;
  padding-bottom: 4px;
  border-bottom: 1px solid #1e3560;
}

.side-resource-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 5px;
  padding: 3%;
}

.side-resource-label {
  color: #a0a8c0;
  font-size: 12px;
  flex-shrink: 0;
}

/* 資源區左右分欄 */
#side-stats-top {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 6px;
  width: 220px;
}
#side-resources {
  align-items: space-around;
  flex: 1;
  min-width: 0;
}
#side-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

/* 背包 / 商店 / 程式碼 按鈕 */
.btn-side-action {
  display: block;
  width: auto;
  text-align: center;
  padding: 3px 6px;
  font-size: 10px;
  background: #1e3560;
  color: #c8d8f8;
  border: 1px solid #2a4880;
  border-radius: 6px;
  margin-bottom: 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-side-action:hover { background: #2a4880; }
.btn-side-action.btn-side-shop { background: #1a3a20; border-color: #2a6030; color: #80c898; }
.btn-side-action.btn-side-shop:hover { background: #2a5030; }
.btn-side-action.btn-side-code { background: #3a3000; border-color: #806010; color: #ffd700; }
.btn-side-action.btn-side-code:hover { background: #504010; }

/* 隊伍成員卡片 */
.side-member-card {
  background: #1a2a45;
  border: 1px solid #243860;
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 5px;
  font-size: 12px;
}
.side-member-card:last-child { margin-bottom: 0; }

.side-member-name {
  font-size: 12px;
  font-weight: bold;
  color: #c8d8f0;
  margin-bottom: 4px;
}

.side-member-bar-wrap {
  background: #0d1a30;
  border-radius: 3px;
  height: 4px;
  margin-bottom: 4px;
  overflow: hidden;
}

.side-member-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.side-member-bar-fill.bar--player { background: linear-gradient(90deg, #2e7d32, #4caf50); }
.side-member-bar-fill.bar--ally   { background: linear-gradient(90deg, #1565c0, #42a5f5); }
.side-member-bar-fill.bar--low    { background: linear-gradient(90deg, #b71c1c, #ef5350); }

.side-member-stats { display: flex; gap: 8px; color: #7090b8; font-size: 11px; }
.side-member-ko    { opacity: 0.45; }

/* ── 右側：小地圖（自然高度）──────────────────────── */
#side-minimap {
  background: #16213e;
  border: 2px solid #0f3460;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 小地圖標題列（標題 + 放大按鈕同行） */
.side-minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.btn-minimap-expand {
  max-width: 50px;
  background: transparent;
  border: 1px solid #2a4880;
  border-radius: 4px;
  color: #7a9ac0;
  font-size: 10px;
  padding: 1px 4px;
  cursor: pointer;
  line-height: 1.2;
  flex: 0 0 auto;
  align-self: center;
  transition: background 0.15s, color 0.15s;
}
.btn-minimap-expand:hover { background: #1e3560; color: #c8d8f8; }

#minimap-canvas {
  display: block;
  width:auto;
  height: auto;
  border: 1px solid #1e3560;
  border-radius: 3px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex-shrink: 0;
}

/* ── 小地圖全螢幕 Overlay ────────────────────────────── */
#minimap-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#minimap-overlay-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.88);
  cursor: pointer;
}

#minimap-overlay-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 24px;
}

#minimap-overlay-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#minimap-legend {
  background: rgba(16, 24, 48, 0.92);
  border: 1px solid #1e3560;
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 120px;
  align-self: center;
}

.legend-title {
  font-size: 13px;
  font-weight: bold;
  color: #a0b8d8;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 8px;
  border-bottom: 1px solid #1e3560;
  margin-bottom: 2px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #c8d8f0;
}

.legend-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

#minimap-viewport {
  position: relative;
  width:  min(68vw, 680px);
  height: min(68vh, 560px);
  overflow: hidden;
  border: 2px solid #0f3460;
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(15, 52, 96, 0.8);
  background: #050810;
  cursor: grab;
}

#minimap-canvas-large {
  display: block;
  position: absolute;
  top: 0; left: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#minimap-pan-hint {
  font-size: 12px;
  color: #6888b8;
  text-align: center;
  letter-spacing: 0.5px;
}
#minimap-pan-hint kbd {
  background: #1e3560;
  border: 1px solid #0f3460;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  color: #a0c0e8;
}

.btn-minimap-close {
  background: #1e3560;
  border: 1px solid #0f3460;
  color: #c8d8f8;
  border-radius: 8px;
  padding: 8px 28px;
  font-size: 14px;
  cursor: pointer;
}
.btn-minimap-close:hover { background: #2a4880; }

/* ── 背包 Overlay ────────────────────────────────────────── */
#inventory-overlay {
  position: absolute; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
#inventory-overlay-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(2px);
}
#inventory-overlay-content {
  position: relative; z-index: 1;
  background: #0a1020; border: 2px solid #1e3560;
  border-radius: 12px; padding: 24px 28px;
  min-width: 280px; max-width: 420px; width: 90%;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 0 40px rgba(15,52,96,0.8);
}
#inventory-overlay-title {
  font-size: 18px; font-weight: bold; color: #c8d8f8;
  border-bottom: 1px solid #1e3560; padding-bottom: 10px;
}
#inventory-overlay-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 50vh; overflow-y: auto;
}
.inventory-overlay-empty {
  color: #5a7a9a; font-size: 13px; text-align: center; padding: 16px 0;
}
.inventory-overlay-row {
  display: flex; align-items: baseline; gap: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid #1e3560;
  border-radius: 8px; padding: 8px 12px;
}
.inv-row-name  { font-size: 13px; color: #e0e8ff; font-weight: bold; flex-shrink: 0; }
.inv-row-desc  { font-size: 11px; color: #7a9ac0; flex: 1; }
.inv-row-qty   { font-size: 13px; color: #ffd700; font-weight: bold; flex-shrink: 0; }

#game-board {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0;  /* scale 從左上角展開 */
  transition: transform 0.12s ease;
}

/* ── 單個格子 ────────────────────────────────────────────── */
.tile {
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s, opacity 0.3s;
}

/* 走廊縮窄效果：在可走格子內側加暗色陰影，模擬厚牆走廊感 */
.tile--empty,
.tile--player,
.tile--chest,
.tile--enemy,
.tile--shop,
.tile--minigame,
.tile--door,
.tile--boss,
.tile--portal {
  box-shadow: inset 0 0 0 4px rgba(6, 10, 21, 0.75);
}

.tile--empty    { background-color: #1e2a45; }
.tile--wall     { background-color: #0a0f1e; border: 1px solid #0d1526; }
.tile--chest    { background-color: #1e2a45; }
.tile--enemy    { background-color: #2a1e1e; }
.tile--door     { background-color: #1e1a2a; }
.tile--minigame { background-color: #1a2240; }
.tile--shop     { background-color: #1a2a1e; }
.tile--boss     { background-color: #2a0a0a; }
.tile--portal   { background-color: #2a1a0a; }

.tile--player {
  background-color: #1e2a45;
  outline: 2px solid #4fc3f7;
  z-index: 1;
}

.tile--hidden   { background-color: #050810; }
.tile--explored { opacity: 0.35; }

.sprite {
  width: 48px; height: 48px;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 0.15s;
}

.tile-emoji {
  font-size: 28px; line-height: 1;
  transition: transform 0.15s;
  user-select: none;
}

#game-board { cursor: default; }
#game-board * { cursor: default !important; }

#controls-hint {
  margin-top: 10px;
  color: #5a6a8a;
  font-size: 13px;
}


/* ══════════════════════════════════════════════════════════════
   戰鬥畫面
   ══════════════════════════════════════════════════════════════ */

/* ── 戰鬥過場動畫 ────────────────────────────────────────── */
@keyframes combatSlideIn {
  0%   { opacity: 0; transform: translateY(20px) scale(0.97); }
  100% { opacity: 1; transform: translateY(0)    scale(1);    }
}
#screen-combat.combat-enter {
  animation: combatSlideIn 0.38s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

#screen-combat {
  justify-content: flex-start;
  align-items: center;
  background-color: #0d0d1a;
  padding: 0; gap: 0;
  position: relative;
  height: 100vh; overflow: hidden;
}

#combat-field {
  width: 100%; max-width: 860px; height: clamp(260px, 42vh, 380px);
  position: relative; flex-shrink: 1;
  background: linear-gradient(180deg,
    #1a2a4a 0%, #243555 40%,
    #3d2e1a 60%, #2a1e0a 100%);
  border-bottom: 4px solid #050810;
  overflow: hidden;
}

#combat-field::before {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 38%;
  background: linear-gradient(180deg, transparent 0%, rgba(50,35,10,0.5) 100%);
  pointer-events: none;
}

.battle-info-card {
  position: absolute;
  background: rgba(235, 232, 215, 0.97);
  border: 3px solid #333;
  border-radius: 10px;
  padding: 8px 14px 6px;
  min-width: 195px;
  color: #111;
  z-index: 10;
  box-shadow: 4px 4px 0 #666;
}

#combat-enemy-card  { top: 8px; right: 10px; left: auto; min-width: 130px; text-align: center; }
#combat-boss-status-card { top: 70px; left: 10px; }

.battle-card-name { font-size: 15px; font-weight: bold; color: #111; margin-bottom: 5px; }
#combat-enemy-card .battle-card-name { color: #8b0000; }

/* ── 己方隊伍區（玩家 + 同伴統一排列） ──────────────────── */
#combat-party-area {
  position: absolute; bottom: 20px; left: 10px;
  display: flex; flex-direction: row; align-items: flex-end; gap: 14px;
  z-index: 5; pointer-events: none;
}

.party-unit {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0;
  position: relative; overflow: visible;
  transition: transform 0.15s ease, opacity 0.3s ease, filter 0.3s ease;
}

.party-unit-sprite {
  width: 140px; height: 140px;
  display: flex; align-items: center; justify-content: center;
}

.party-sprite-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(2px 5px 3px rgba(0,0,0,0.7));
}

.party-unit-name {
  font-size: 11px; color: #a8c8f0; text-align: center;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
}

.party-unit--knocked-out {
  opacity: 0.3; filter: grayscale(1);
}

/* 輪到該成員行動：精靈發光 + 上移 */
.party-unit.active-turn {
  transform: translateY(-4px);
}
.party-unit.active-turn .party-sprite-img,
.party-unit.active-turn .battle-fallback-emoji {
  filter: drop-shadow(0 0 10px #4caf50) drop-shadow(2px 5px 3px rgba(0,0,0,0.7));
}
.party-unit[data-party-type="ally"].active-turn .party-sprite-img,
.party-unit[data-party-type="ally"].active-turn .battle-fallback-emoji {
  filter: drop-shadow(0 0 10px #42a5f5) drop-shadow(2px 5px 3px rgba(0,0,0,0.7));
}

.battle-hp-row { display: flex; align-items: center; gap: 6px; }
.battle-hp-label { font-size: 11px; font-weight: bold; color: #444; width: 18px; }

.battle-info-card .hp-bar-wrap {
  flex: 1; background-color: #888; border-radius: 4px;
  height: 12px; overflow: hidden; border: 1px solid #555;
}

.battle-info-card .hp-bar-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.35s ease; min-width: 0;
}

.enemy-bar  { background: linear-gradient(90deg, #d32f2f, #ff5252); width: 100%; }
.player-bar { background: linear-gradient(90deg, #2e7d32, #4caf50); width: 100%; }
.battle-hp-num { font-size: 11px; color: #333; text-align: right; margin-top: 3px; }

/* ── 動態敵人排列區（由右向左：array[0]=最右） ─────────────── */
#combat-enemies-area {
  position: absolute; top: 10px; right: 10px;
  width: 60%; height: 240px;
  display: flex; flex-direction: row;
  align-items: flex-end; justify-content: flex-end;
  gap: 10px; z-index: 5; pointer-events: none;
}

/* 單一敵人單位（精靈 + 血條） */
.enemy-unit {
  display: flex; flex-direction: column;
  align-items: center; gap: 4px;
  flex-shrink: 0;
}

/* 受擊晃動 */
@keyframes hit-shake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-6px); }
  35%  { transform: translateX(6px); }
  55%  { transform: translateX(-4px); }
  75%  { transform: translateX(4px); }
  90%  { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}
.hit-shake {
  animation: hit-shake 0.5s ease-out;
}

/* 死亡淡出轉場 */
.enemy-unit.dying {
  animation: enemy-unit-die 0.58s ease-out forwards;
  pointer-events: none;
}
@keyframes enemy-unit-die {
  0%   { opacity: 1;   transform: scale(1)    translateY(0);    filter: brightness(1); }
  18%  { opacity: 1;   transform: scale(1.1)  translateY(-7px); filter: brightness(2.2) saturate(0); }
  100% { opacity: 0;   transform: scale(0.55) translateY(14px); filter: brightness(0.4); }
}

/* 精靈容器 */
.enemy-unit-sprite {
  display: flex; align-items: center; justify-content: center;
}

/* 血條區 */
.enemy-unit-hpbar {
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
}
.enemy-unit-bar-wrap {
  background-color: #444; border-radius: 3px; height: 6px;
  overflow: hidden; border: 1px solid #222;
}
.enemy-unit-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #d32f2f, #ff5252);
  transition: width 0.35s ease; min-width: 0;
}
.enemy-unit-hp-num {
  font-size: 9px; color: #bbb; text-align: center; white-space: nowrap;
}

#combat-hint {
  position: absolute;
  bottom: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 20, 0.78);
  color: #ffe082;
  font-size: 12px; font-weight: bold;
  padding: 4px 14px; border-radius: 12px;
  white-space: nowrap; pointer-events: none;
  display: none; z-index: 15;
  border: 1px solid rgba(255, 224, 130, 0.35);
}

#combat-player-sprite {
  position: absolute; bottom: 95px; left: 56px;
  width: 115px; height: 115px;
  display: flex; align-items: center; justify-content: center; z-index: 5;
}

.battle-sprite {
  width: 100%; height: 100%; object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(2px 6px 4px rgba(0,0,0,0.6));
}

.enemy-sprite-img { animation: enemy-float 2.4s ease-in-out infinite; }

@keyframes enemy-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-10px); }
}

.battle-fallback-emoji { font-size: 64px; line-height: 1; }

/* ── 玩家精靈：輪到自己時發光 ───────────────────────────── */
#combat-player-sprite.active-turn img,
#combat-player-sprite.active-turn .battle-fallback-emoji {
  filter: drop-shadow(0 0 10px #4caf50) drop-shadow(2px 6px 4px rgba(0,0,0,0.6));
}

/* ── 同伴戰場精靈區 ──────────────────────────────────────── */
#combat-allies-area {
  position: absolute; bottom: 55px; left: 185px;
  display: flex; flex-direction: row;
  align-items: flex-end; gap: 14px;
  z-index: 5; pointer-events: none;
}

.ally-unit {
  display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  flex-shrink: 0;
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.ally-unit-sprite {
  display: flex; align-items: center; justify-content: center;
  width: 80px; height: 80px;
}

/* ally 精靈圖片：不晃動（靜止待機） */
.ally-sprite-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(2px 5px 3px rgba(0,0,0,0.7));
}

.ally-unit-name {
  font-size: 11px; color: #a8c8f0; text-align: center;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
}

/* 血條：統一成敵人樣式 */
.ally-unit-hpbar { display: none; }

.ally-unit-bar-wrap {
  background-color: #444; border-radius: 3px; overflow: hidden;
  height: 6px; border: 1px solid #222;
}

.ally-unit-bar-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #1565c0, #42a5f5);
  transition: width 0.35s ease; min-width: 0;
}

.ally-unit-hp-num {
  font-size: 9px; color: #bbb; text-align: center; white-space: nowrap;
}

.ally-unit--knocked-out {
  opacity: 0.3; filter: grayscale(1);
}

/* 輪到同伴時：藍色發光 */
.ally-unit.active-turn .ally-sprite-img,
.ally-unit.active-turn .battle-fallback-emoji {
  filter: drop-shadow(0 0 10px #42a5f5) drop-shadow(2px 5px 3px rgba(0,0,0,0.7));
}
.ally-unit.active-turn {
  transform: translateY(-4px);
}

/* ── 查看按鈕列 ──────────────────────────────────────────── */
/* ── 己方全員 HP 列 + 查看按鈕 ──────────────────────────── */
#party-hp-row {
  display: flex; flex-direction: row; align-items: flex-start; gap: 8px;
}

#party-hp-area {
  display: flex; flex-direction: row; align-items: center;
  gap: 8px; flex-wrap: wrap; flex: 1;
  padding: 5px 2px 18px;
  border-top: 1px solid #1e3560;
  min-height: 30px;
}

/* 卡片：直向排列（名字→血量→效果） */
.party-hp-card {
  display: flex; flex-direction: column; gap: 3px;
  background: rgba(255,255,255,0.05);
  border: 1px solid #1e3560; border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: #c8d8f0;
  position: relative; min-width: 180px;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
              border-color 0.15s ease, background 0.15s ease;
}
.party-hp-card--player { border-color: #2a6090; background: rgba(25,65,120,0.18); }
.party-hp-card.party-knocked-out { opacity: 0.4; border-color: #555; }

/* 1. 名字列 */
.phc-name {
  font-size: 13px; font-weight: bold; color: #d8eaff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 2. 血量列 */
.phc-hp-row {
  display: flex; align-items: center; gap: 5px;
}

/* 3. 效果列 */
.phc-effects {
  display: flex; flex-direction: column; gap: 2px; margin-top: 1px;
}
.phc-effect {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: bold;
  border-radius: 4px; padding: 1px 5px;
  border: 1px solid transparent;
  white-space: nowrap;
}
/* 攻擊 */
.phc-effect--atk-up { color: #ff8a80; border-color: #b71c1c; background: rgba(183,28,28,0.18); }
.phc-effect--atk-dn { color: #ff8a80; border-color: #7f0000; background: rgba(100,0,0,0.22); }
/* 防禦 */
.phc-effect--def-up { color: #82b1ff; border-color: #1565c0; background: rgba(21,101,192,0.18); }
.phc-effect--def-dn { color: #82b1ff; border-color: #0d47a1; background: rgba(13,71,161,0.22); }
/* 速度 */
.phc-effect--spd-up { color: #b9f6ca; border-color: #2e7d32; background: rgba(46,125,50,0.18); }
.phc-effect--spd-dn { color: #b9f6ca; border-color: #1b5e20; background: rgba(27,94,32,0.22); }

.party-hp-card--active-player {
  border-color: #4caf50; background: rgba(46,125,50,0.28);
  box-shadow: 0 0 12px rgba(76,175,80,0.5);
  transform: translateY(-2px); z-index: 2;
}
.party-hp-card--active-player::after {
  content: '▼'; position: absolute; bottom: -15px; left: 50%;
  transform: translateX(-50%); color: #4caf50; font-size: 9px; opacity: 0.85;
}
.party-hp-card--active-ally {
  border-color: #42a5f5; background: rgba(21,101,192,0.28);
  box-shadow: 0 0 12px rgba(66,165,245,0.5);
  transform: translateY(-2px); z-index: 2;
}
.party-hp-card--active-ally::after {
  content: '▼'; position: absolute; bottom: -15px; left: 50%;
  transform: translateX(-50%); color: #42a5f5; font-size: 9px; opacity: 0.85;
}

.party-mini-bar-wrap {
  display: inline-block; width: 70%; height: 6px;
  background: #2a3a5a; border-radius: 3px; overflow: hidden; vertical-align: middle;
  flex-shrink: 0;
}
.party-mini-bar-fill {
  display: block; height: 100%;
  background: linear-gradient(90deg, #1565c0, #42a5f5);
  border-radius: 3px; transition: width 0.3s ease;
}
.party-mini-bar-fill.player-mini-bar { background: linear-gradient(90deg, #2e7d32, #4caf50); }
.party-hp-num-small { font-size: 10px; color: #7a9ac0; }

/* ── Press Turn ─────────────────────────────────────────── */
#press-turn-display {
  display: flex; flex-direction: row; justify-content: space-between;
  width: 100%; max-width: 860px;
  background-color: #0a0f1e; border-bottom: 1px solid #0f3460;
  padding: 6px 20px; font-size: 14px; flex-shrink: 0;
}

#pt-player-tokens { color: #4fc3f7; letter-spacing: 2px; }
#pt-enemy-tokens  { color: #ff6b6b; letter-spacing: 2px; }

.pt-token          { font-size: 16px; margin: 0 2px; }
.pt-token--full    { color: #f9e2af; }
.pt-token--flash   { color: #f9e2af; animation: pt-blink 0.8s infinite; }
.pt-token--empty   { color: #45475a; }

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

/* 行動點消耗轉場：先膨脹發光，再旋轉縮小消失 */
@keyframes pt-token-consume {
  0%   { transform: scale(1)   rotate(0deg);   opacity: 1; filter: brightness(1); }
  25%  { transform: scale(1.6) rotate(-20deg); opacity: 1; filter: brightness(2.5); }
  100% { transform: scale(0)   rotate(30deg);  opacity: 0; filter: brightness(1); }
}
/* Pass 轉場：◆ 閃白光後變色成 ◈ */
@keyframes pt-token-convert {
  0%   { transform: scale(1);   filter: brightness(1); }
  40%  { transform: scale(1.4); filter: brightness(3) saturate(0); }
  100% { transform: scale(1);   filter: brightness(1); }
}
.pt-token--consumed { display: inline-block; animation: pt-token-consume 0.32s ease-in forwards; }
.pt-token--convert  { display: inline-block; animation: pt-token-convert 0.28s ease-out forwards; }

.btn-pass { background: linear-gradient(135deg, #6c5ce7, #a29bfe); color: #fff; }

/* ── 戰鬥面板 ─────────────────────────────────────────── */
#combat-panel {
  width: 100%; max-width: 860px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 16px;
  background-color: #16213e;
  border-top: 3px solid #0f3460;
  flex: 1; min-height: 0; overflow-y: auto;
}

#combat-log {
  width: 100%;
  background-color: #0a0f1e;
  border: 2px solid #0f3460; border-radius: 8px;
  padding: 10px 14px; height: clamp(80px, 15vh, 160px); overflow-y: auto; flex-shrink: 1;
  font-size: 13px; color: #b0c4de; line-height: 1.6;
}

#combat-log p { margin-bottom: 4px; }

#combat-buttons {
  display: flex; flex-direction: row; gap: 10px; width: 100%;
}

/* 技能按鈕列 */
#combat-skills {
  display: flex; flex-direction: row; gap: 8px; width: 100%;
  flex-wrap: wrap;
}

.btn:disabled {
  opacity: 0.4; cursor: not-allowed; transform: none;
}

/* ── 金幣掉落動畫 ─────────────────────────────────────── */
.coin-drop {
  position: absolute;
  color: #ffd700;
  font-size: 18px;
  font-weight: bold;
  z-index: 20;
  pointer-events: none;
  animation: coin-float-up 1.1s ease-out forwards;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.9);
}

@keyframes coin-float-up {
  0%   { transform: translateY(0px) scale(1);   opacity: 1; }
  60%  { transform: translateY(-50px) scale(1.2); opacity: 1; }
  100% { transform: translateY(-90px) scale(0.9); opacity: 0; }
}

/* ── 傷害飄字提示 ─────────────────────────────────────── */
.damage-popup {
  position: absolute;
  font-size: 15px;
  font-weight: bold;
  pointer-events: none;
  z-index: 25;
  animation: damage-float-up 1.3s ease-out forwards;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
  white-space: nowrap;
  background: rgba(0,0,0,0.5);
  border-radius: 6px;
  padding: 2px 8px;
}

.damage-popup--enemy  { color: #ff5555; }
.damage-popup--player { color: #ffaa33; }

@keyframes damage-float-up {
  0%   { transform: translateY(0)     scale(1);    opacity: 1; }
  20%  { transform: translateY(-14px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-72px) scale(0.85); opacity: 0; }
}


/* ══════════════════════════════════════════════════════════════
   商店畫面
   ══════════════════════════════════════════════════════════════ */

#screen-shop { justify-content: center; background-color: #0a1a0a; }

#shop-layout {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
  max-height: 90vh;
}

#shop-box {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  background-color: #102010;
  border: 2px solid #2e7d32; border-radius: 16px;
  padding: 24px 28px;
  width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
}

/* 右側欄：金幣 + 隊伍 */
#shop-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: #102010;
  border: 2px solid #2e7d32;
  border-radius: 16px;
  padding: 18px 16px;
  width: 180px;
  flex-shrink: 0;
  max-height: 90vh;
  overflow-y: auto;
}

#shop-money-display { color: #ffd700; font-size: 15px; font-weight: bold; }

.shop-sidebar-title {
  font-size: 11px;
  color: #66bb6a;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1e4020;
}

#shop-party-list { display: flex; flex-direction: column; gap: 8px; }

.shop-party-card {
  background: #0d2010;
  border: 1px solid #1e4020;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
}
.shop-party-ko { opacity: 0.45; }
.shop-party-name { font-weight: bold; color: #a5d6a7; margin-bottom: 5px; }
.shop-party-bar-wrap {
  background: #0a1a0a;
  border-radius: 3px;
  height: 4px;
  margin-bottom: 5px;
  overflow: hidden;
}
.shop-party-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.shop-party-stats { color: #7aaa88; font-size: 11px; line-height: 1.6; }

.shop-inv-empty { color: #4a6a50; font-size: 12px; font-style: italic; }
.shop-inv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #a5d6a7;
  padding: 3px 0;
  border-bottom: 1px solid #1a3a1a;
}
.shop-inv-row:last-child { border-bottom: none; }
.shop-inv-name { flex: 1; }
.shop-inv-qty  { color: #ffd700; font-weight: bold; margin-left: 8px; }

#shop-title     { color: #81c784; font-size: 22px; }
#shop-message   { color: #a5d6a7; font-size: 14px; min-height: 20px; }

#shop-item-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }

/* 商店分區標題 */
.shop-section-title {
  font-size: 13px; font-weight: bold;
  color: #66bb6a; letter-spacing: 0.5px;
  margin-top: 10px; margin-bottom: 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid #2e7d32;
}

.shop-card {
  display: flex; flex-direction: row; align-items: center;
  justify-content: space-between;
  background-color: #1b3a1b;
  border: 1px solid #388e3c; border-radius: 10px;
  padding: 8px 14px; gap: 10px;
  transition: transform 0.15s;
}

.shop-card:hover { transform: scale(1.01); }

/* 消耗品卡片：稍微不同邊框色 */
.shop-card--consumable {
  border-color: #ffd700;
  background-color: #1e2a10;
}

/* 技能購買卡片 */
.shop-card--skill {
  border-color: #7e57c2;
  background-color: #1a1a2e;
}

/* 技能合成卡片 */
.shop-card--craft {
  border-color: #ef6c00;
  background-color: #1e1200;
}

.shop-card-left  { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.shop-card-right { display: flex; flex-direction: row; align-items: center; gap: 8px; flex-shrink: 0; }

.shop-card-name  { font-size: 14px; font-weight: bold; color: #c8e6c9; }
.shop-card-desc  { font-size: 12px; color: #81c784; }
.shop-card-recipe { font-size: 11px; color: #ffb74d; margin-top: 2px; }
.shop-card-price { font-size: 13px; color: #ffd700; }


/* ══════════════════════════════════════════════════════════════
   射擊小遊戲畫面
   ══════════════════════════════════════════════════════════════ */

#screen-minigame { justify-content: center; background-color: #000a1a; }

#minigame-box {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; width: 100%; max-width: 660px;
}

#minigame-box h2 { font-size: 22px; color: #4fc3f7; }

#mg-hud { display: flex; flex-direction: row; gap: 30px; font-size: 16px; color: #e0e0e0; }

#mg-area {
  width: 600px; height: 380px;
  background-color: #0a1428;
  border: 2px solid #1565c0; border-radius: 10px;
  position: relative; overflow: hidden;
  cursor: none;
}

#mg-crosshair {
  position: absolute;
  font-size: 28px; color: #f44336;
  pointer-events: none; display: none;
  line-height: 1; user-select: none;
}

.mg-enemy {
  position: absolute;
  width: 50px; height: 50px;
  object-fit: contain; cursor: none;
  transition: opacity 0.2s;
}

.mg-enemy:hover { transform: scale(1.1); }
#mg-hint { color: #5a6a8a; font-size: 13px; }


/* ══════════════════════════════════════════════════════════════
   對話框畫面
   ══════════════════════════════════════════════════════════════ */

#screen-dialogue {
  display: flex; flex-direction: column;
  width: 100vw; min-height: 100vh;
  justify-content: flex-end; align-items: center;
  background-color: rgba(5, 8, 16, 0.85);
}

#dialogue-box {
  display: flex; flex-direction: column; gap: 14px;
  background-color: #0d1b2a;
  border: 3px solid #4a90d9; border-radius: 12px;
  padding: 24px 32px;
  width: 100%; max-width: 640px; margin-bottom: 48px;
}

#dialogue-speaker-name { color: #ffd700; font-size: 16px; font-weight: bold; min-height: 22px; }
#dialogue-text-content { color: #e8e8e8; font-size: 17px; line-height: 1.8; min-height: 60px; }

.btn-dialogue-next {
  background-color: #1565c0; color: #fff;
  flex: none; align-self: flex-end; padding: 10px 28px;
}


/* ══════════════════════════════════════════════════════════════
   Game Over & 通關畫面
   ══════════════════════════════════════════════════════════════ */

#screen-gameover { justify-content: center; background-color: #0d0000; }
#screen-clear    { justify-content: center; background-color: #0a0d00; }

#gameover-box, #clear-box {
  display: flex; flex-direction: column;
  align-items: center; gap: 18px; text-align: center; padding: 40px;
}

#gameover-box h1 { font-size: 48px; color: #ef5350; }
#clear-box h1    { font-size: 48px; color: #ffd700; }
#gameover-box p, #clear-box p { font-size: 18px; color: #b0b0b0; }


/* ══════════════════════════════════════════════════════════════
   通用按鈕樣式
   ══════════════════════════════════════════════════════════════ */

.btn {
  padding: 10px 18px;
  border: none; border-radius: 8px;
  font-size: 14px; font-weight: bold;
  cursor: pointer;
  transition: transform 0.12s, opacity 0.12s;
  flex: 1;
}

.btn:hover  { transform: scale(1.06); opacity: 0.9; }
.btn:active { transform: scale(0.97); }

.btn-attack { background-color: #c62828; color: #fff; }
.btn-defend { background-color: #1565c0; color: #fff; }
.btn-flee   { background-color: #4a4a4a; color: #fff; }

.btn-close {
  background-color: #333; color: #ccc;
  flex: none; padding: 10px 28px;
}

.btn-shop {
  background-color: #2e7d32; color: #fff;
  flex: none; padding: 7px 14px; font-size: 13px;
}

.btn-restart {
  background-color: #1565c0; color: #fff;
  flex: none; font-size: 18px; padding: 14px 36px;
}

.btn-hud {
  background-color: #2e7d32; color: #fff;
  flex: none; padding: 4px 8px; font-size: 11px;
  border-radius: 6px; margin-left: auto;
  white-space: nowrap;
}

/* ── 技能按鈕 ─────────────────────────────────────────── */
.btn-skill {
  background-color: #4a148c;
  color: #fff;
  flex: none;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-skill:hover:not(:disabled) { background-color: #6a1fb5; }

.btn-skill--cd {
  background-color: #2d2d2d;
  color: #888;
}

/* ── 戰鬥背包道具欄 ───────────────────────────────────── */
#combat-items {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
  border-top: 1px solid #1e3560;
}

.combat-items-label {
  font-size: 16px;
  flex-shrink: 0;
}

.btn-item {
  background-color: #1a4a2a;
  color: #a5d6a7;
  border: 1px solid #2e7d32;
  flex: none;
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-item:hover:not(:disabled) {
  background-color: #2e7d32;
  color: #fff;
}


/* ══════════════════════════════════════════════════════════════
   同伴行動面板
   ══════════════════════════════════════════════════════════════ */

/* （己方HP列已移至戰場精靈區，#party-hp-row 已移除） */

/* ── 統一行動區（原同伴HP位置） ────────────────────────── */
#party-action-area {
  position: relative;
  border-top: 1px solid #1e3560;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 8px;
  padding: 6px 0 0 0;
  transition: border-left-color 0.18s ease, padding-left 0.18s ease;
  overflow-y: auto;
  max-height: min(30vh, 260px);
}
#party-action-area.active--player {
  border-left-color: #4caf50;
  padding-left: 10px;
}
#party-action-area.active--ally {
  border-left-color: #42a5f5;
  padding-left: 10px;
}

/* 玩家行動區 */
#player-action-zone {
  display: flex; flex-direction: column; gap: 8px;
}

/* 同伴行動區 */
#ally-action-zone {
  background: linear-gradient(90deg, #0d1f3c, #162040);
  border: 1px solid #2a4a8a; border-radius: 10px;
  padding: 8px 14px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
#ally-action-title {
  font-size: 13px; font-weight: bold;
  color: #90caf9; letter-spacing: 0.3px;
}
#ally-action-buttons {
  display: flex; flex-direction: column; gap: 6px;
}
.ally-btn-row {
  display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap;
}

/* ── 同伴商店卡片 ─────────────────────────────────────── */
.shop-card--ally {
  border-color: #1565c0;
  background-color: #0d1a2e;
}

.ally-upgrade-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.btn-upgrade {
  background: linear-gradient(135deg, #1a3a6a, #1e4d8c);
  color: #a8d4ff;
  border: 1px solid #2a5a9a;
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-upgrade:hover:not(:disabled) {
  background: linear-gradient(135deg, #1e4d8c, #2060b0);
  color: #d0eaff;
}

.btn-upgrade:disabled {
  opacity: 0.45;
  cursor: default;
}


/* ══════════════════════════════════════════════════════════════
   目標選擇面板
   ══════════════════════════════════════════════════════════════ */

#target-select-panel {
  display: flex; flex-direction: column; gap: 8px;
  background: linear-gradient(90deg, #1a200a, #202800);
  border: 1px solid #6a8a00; border-radius: 10px;
  padding: 8px 14px 10px;
}

#target-select-title {
  font-size: 13px; font-weight: bold; color: #c8e080; letter-spacing: 0.3px;
}

#target-select-buttons {
  display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap;
}

/* ══════════════════════════════════════════════════════════════
   查看敵人面板
   ══════════════════════════════════════════════════════════════ */

#inspect-panel {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(5, 8, 20, 0.97);
  border: 1px solid #3a4a6a; border-radius: 10px;
  padding: 10px 16px 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}

#inspect-title {
  font-size: 14px; font-weight: bold; color: #ffd700;
}

#inspect-content {
  font-size: 12px; color: #b0c4de; line-height: 1.8;
}

#inspect-content .inspect-stat   { color: #90caf9; }
#inspect-content .inspect-skill  { color: #fff59d; margin-top: 4px; }
#inspect-content .inspect-desc   { color: #b0bec5; padding-left: 10px; }
#inspect-content .inspect-sep    { color: #3a4a6a; }

/* 查看按鈕 */
.btn-inspect {
  background-color: #2d3a5a;
  color: #90caf9;
  flex: none;
  padding: 6px 12px;
  font-size: 13px;
  align-self: center;
  white-space: nowrap;
}

.btn-inspect:hover { background-color: #3a4f7a; }


/* ══════════════════════════════════════════════════════════════
   設定按鈕 & 設定 Overlay
   ══════════════════════════════════════════════════════════════ */

.settings-btn {
  position: absolute; top: 8px; left: 8px; z-index: 500;
  width: 40px; height: 40px; padding: 0;
  background: rgba(0,0,0,0.55);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex: none;               /* 不被外層 flex 拉伸 */
  transition: background 0.2s;
}
.settings-btn:hover  { background: rgba(0,0,0,0.85); transform: none; }
.settings-btn:active { transform: scale(0.92); }
.settings-btn img {
  width: 26px; height: 26px; object-fit: contain;
  mix-blend-mode: screen;   /* 讓黑色底圖透明 */
}

/* ── Overlay 背景 ────────────────────────────────────────── */
#settings-overlay {
  position: fixed; inset: 0; z-index: 1500;
  display: flex; align-items: center; justify-content: center;
}
#settings-overlay-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
}

/* ── 設定面板 ────────────────────────────────────────────── */
#settings-panel {
  position: relative; z-index: 1;
  background: #0a1020; border: 2px solid #1e3560;
  border-radius: 14px; padding: 28px 36px;
  min-width: 360px;
  display: flex; flex-direction: column; gap: 22px;
  box-shadow: 0 0 40px rgba(15,52,96,0.9);
}
#settings-title {
  font-size: 18px; font-weight: bold; color: #c8d8f8;
  text-align: center;
  border-bottom: 1px solid #1e3560; padding-bottom: 12px;
}

/* ── 每一個設定行 ─────────────────────────────────────────── */
.settings-block {
  display: flex; align-items: center; gap: 16px;
}
.settings-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  object-fit: contain;
  mix-blend-mode: screen;   /* 黑色底圖透明 */
}

/* ── 音量滑桿 ────────────────────────────────────────────── */
.vol-track {
  flex: 1; height: 8px;
  background: #3a3a3a; border-radius: 4px;
  position: relative; cursor: pointer;
  user-select: none;
}
.vol-fill {
  position: absolute; left: 0; top: 0; height: 100%;
  background: linear-gradient(90deg, #2e7d32, #4caf50);
  border-radius: 4px; pointer-events: none;
  transition: width 0.04s linear;
}
.vol-thumb {
  position: absolute; top: 50%;
  width: 20px; height: 20px; border-radius: 50%;
  background: #ddeeff; border: 2px solid #4caf50;
  transform: translate(-50%, -50%);
  cursor: grab; pointer-events: all;
  box-shadow: 0 1px 6px rgba(0,0,0,0.6);
  transition: border-color 0.15s, background 0.15s;
}
.vol-thumb:active { cursor: grabbing; }
.vol-thumb.muted  { border-color: #555; background: #888; }

/* ── 戰鬥過場動畫 ─────────────────────────────────────── */
#encounter-transition {
  position: fixed; inset: 0; z-index: 5000;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  animation: encounter-bg 1.1s ease-out forwards;
}
@keyframes encounter-bg {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}
.encounter-slash {
  position: absolute;
  width: 180%; height: 6px;
  background: linear-gradient(90deg, transparent 0%, #fff 30%, #ff4444 50%, #fff 70%, transparent 100%);
  box-shadow: 0 0 30px 8px rgba(255,80,80,0.7), 0 0 60px 16px rgba(255,40,40,0.3);
  transform: rotate(-30deg) scaleX(0);
  animation: slash-swipe 0.5s 0.1s cubic-bezier(0.22,0.61,0.36,1) forwards;
}
@keyframes slash-swipe {
  0%   { transform: rotate(-30deg) scaleX(0); opacity: 1; }
  50%  { transform: rotate(-30deg) scaleX(1); opacity: 1; }
  100% { transform: rotate(-30deg) scaleX(1.2); opacity: 0; }
}

/* ══════════════════════════════════════════════════════════
   教學 Overlay
   ══════════════════════════════════════════════════════════ */
#tutorial-overlay {
  position: fixed; inset: 0;
  z-index: 3000;
  display: flex; align-items: center; justify-content: center;
}
#tutorial-mask {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.75);
}
#tutorial-card {
  position: relative; z-index: 1;
  background: #0e1a2e;
  border: 2px solid #2a4a7a;
  border-radius: 14px;
  padding: 36px 40px 28px;
  width: min(480px, 88vw);
  display: flex; flex-direction: column; align-items: center;
  gap: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
#tutorial-skip-btn {
  position: absolute; top: 12px; right: 14px;
  background: transparent; border: 1px solid #445;
  color: #778; border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#tutorial-skip-btn:hover { background: #1e2a3a; color: #aab; }

#tutorial-img-wrap {
  width: 100%; display: flex; justify-content: center;
}
#tutorial-img {
  width: 220px; height: 160px;
  object-fit: contain; border-radius: 8px;
  image-rendering: pixelated;
}
#tutorial-text {
  color: #d8e4f0; font-size: 18px; line-height: 1.7;
  text-align: center; white-space: pre-line;
  min-height: 56px;
}
#tutorial-footer {
  width: 100%; display: flex;
  align-items: center; justify-content: space-between;
}
#tutorial-dots {
  display: flex; gap: 7px;
}
.tutorial-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #2a4a7a; transition: background 0.2s;
}
.tutorial-dot.active { background: #5090e0; }
#tutorial-next-btn {
  background: #1a4080; border: none; color: #cde;
  border-radius: 8px; padding: 8px 20px; font-size: 15px;
  cursor: pointer; transition: background 0.15s;
}
#tutorial-next-btn:hover { background: #2255a0; }

/* ── 設定開關 ────────────────────────────────────────────── */
.settings-toggle-block {
  justify-content: space-between; align-items: center;
}
.settings-toggle-label {
  color: #ccd; font-size: 15px; flex: 1;
}
.settings-toggle-btn {
  width: 52px; height: 28px;
  border-radius: 14px; border: none; cursor: pointer;
  font-size: 12px; font-weight: bold; letter-spacing: 1px;
  background: #1a6b2a; color: #8ef5a0;
  transition: background 0.2s, color 0.2s;
}
.settings-toggle-btn.off {
  background: #3a2222; color: #a05050;
}

/* ── 隊伍 Overlay ────────────────────────────────────────────── */
#party-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
#party-overlay-bg {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
}
#party-overlay-content {
  position: relative; z-index: 1;
  background: #0e1a2e;
  border: 2px solid #2a4a7a;
  border-radius: 12px;
  padding: 20px 24px 16px;
  min-width: 280px; max-width: 360px; width: 90vw;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#party-overlay-title {
  font-size: 16px; font-weight: bold;
  color: #c8d8f8; border-bottom: 1px solid #2a4a7a;
  padding-bottom: 8px;
}

/* ── 等級 / EXP 顯示 ──────────────────────────────────────────── */
.side-member-lv {
  font-size: 10px; font-weight: bold;
  color: #ffd700; margin-left: 4px;
  background: rgba(255,215,0,0.12); border-radius: 3px;
  padding: 1px 4px;
}
.side-member-exp-wrap {
  background: #1a1a2a; border-radius: 3px;
  height: 5px; overflow: hidden; margin-top: 2px;
}
.side-member-exp-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #b8860b, #ffd700);
  transition: width 0.4s ease;
}
.side-member-exp-text {
  font-size: 10px; color: #b8a000; text-align: right;
  margin-top: 1px;
}

/* ── 升級光圈動畫 ─────────────────────────────────────────────── */
@keyframes levelup-ring-rise {
  0%   { opacity: 0.95; transform: translate(-50%, -50%) scale(0.25); }
  60%  { opacity: 0.55; }
  100% { opacity: 0;    transform: translate(-50%, calc(-50% - var(--rise, 65px))) scale(2.2); }
}

.levelup-ring {
  position: absolute;
  left: 50%; top: 40%;        /* 稍微偏上，對準角色中心 */
  border-radius: 50%;
  border: 2px solid gold;
  box-shadow: 0 0 8px 3px rgba(255, 215, 0, 0.7),
              inset 0 0 6px 1px rgba(255, 215, 0, 0.25);
  pointer-events: none;
  z-index: 20;
  animation: levelup-ring-rise var(--dur, 900ms) ease-out forwards;
}
