/* style.css */

/* 基礎設定 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  font-family: 'Outfit', sans-serif;
  background: radial-gradient(circle, #1a1528 0%, #0a0712 100%);
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.game-container {
  width: 100%;
  max-width: 1400px;
  height: 100vh;
  background: radial-gradient(circle, #1a1528 0%, #0a0712 100%);
  border: none;
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  padding: 12px 30px 12px;
  position: relative;
  overflow: visible;
}

/* ═══════════════════════════════════════════
   ★ 主選單畫面
   ═══════════════════════════════════════════ */

.main-menu {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.main-menu.hidden {
  display: none;
}

.menu-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(40, 20, 60, 0.6) 0%, rgba(10, 7, 18, 0.95) 70%);
  z-index: -1;
}

.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 40px;
}

.menu-title {
  font-family: 'Cinzel', serif;
  font-size: 3.5rem;
  font-weight: 700;
  color: #c9a227;
  letter-spacing: 6px;
  text-shadow:
    0 0 20px rgba(201, 162, 39, 0.4),
    0 0 60px rgba(201, 162, 39, 0.15),
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000;
}

.menu-subtitle {
  font-size: 1rem;
  color: #8c7db3;
  letter-spacing: 4px;
}

/* ═══════ 登入區域 ═══════ */
.login-section {
  width: 100%;
  max-width: 320px;
  min-height: 60px;
}

.login-prompt {
  display: flex;
  justify-content: center;
}

.discord-login-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #5865F2;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.discord-login-btn:hover {
  background: #4752C4;
  border-color: #7983F5;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(88, 101, 242, 0.4);
}

.discord-login-btn svg {
  flex-shrink: 0;
}

/* 已登入狀態 */
.login-user {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 20, 50, 0.7);
  border: 1px solid rgba(88, 101, 242, 0.4);
  border-radius: 10px;
  padding: 10px 16px;
}

.login-user.hidden {
  display: none;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #5865F2;
  object-fit: cover;
}

.user-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #e0e0e0;
}

.user-status {
  font-size: 0.7rem;
  color: #2ecc71;
}

.logout-btn {
  color: #8c7db3;
  text-decoration: none;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.logout-btn:hover {
  color: #e84545;
  background: rgba(232, 69, 69, 0.1);
}

/* 開始按鈕禁用狀態 */
.menu-start-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.menu-start-btn:disabled:hover {
  transform: none;
  box-shadow: 0 0 20px rgba(93, 63, 161, 0.3);
  border-color: #8c5fd4;
}

/* ═══════ 隊伍區域 ═══════ */
.team-section {
  width: 100%;
  max-width: 360px;
}

.team-section.hidden { display: none; }

.team-no-team {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.team-btn {
  background: rgba(30, 20, 50, 0.7);
  border: 1px solid rgba(93, 63, 161, 0.5);
  border-radius: 8px;
  color: #c5b5eb;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.team-btn:hover {
  background: rgba(50, 35, 80, 0.9);
  border-color: #c9a227;
  color: #ffd700;
}

.team-btn.leave-btn {
  border-color: rgba(232, 69, 69, 0.4);
  color: #e88;
  font-size: 0.75rem;
  padding: 5px 12px;
}

.team-btn.leave-btn:hover {
  background: rgba(232, 69, 69, 0.15);
  border-color: #e84545;
}

.team-join-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-code-input {
  width: 90px;
  padding: 8px 12px;
  background: rgba(20, 10, 35, 0.8);
  border: 1px solid rgba(93, 63, 161, 0.4);
  border-radius: 6px;
  color: #ffd700;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 3px;
  text-transform: uppercase;
  outline: none;
}

.invite-code-input:focus {
  border-color: #c9a227;
  box-shadow: 0 0 10px rgba(201, 162, 39, 0.2);
}

/* 有隊伍時 */
.team-has-team { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.team-has-team.hidden { display: none; }

.team-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #a496c4;
}

.team-label {
  font-family: 'Cinzel', serif;
  font-weight: 700;
  color: #c9a227;
  font-size: 0.9rem;
}

.team-code {
  color: #8c7db3;
}

.team-code strong {
  color: #ffd700;
  letter-spacing: 2px;
  font-size: 1rem;
}

.copy-code-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.copy-code-btn:hover { opacity: 1; }

.team-members-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.team-member-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.team-member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #5d3fa1;
  object-fit: cover;
}

.team-member-avatar.is-leader {
  border-color: #c9a227;
  box-shadow: 0 0 8px rgba(201, 162, 39, 0.4);
}

.team-member-name {
  font-size: 0.65rem;
  color: #a496c4;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.team-member-empty {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px dashed rgba(93, 63, 161, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(93, 63, 161, 0.4);
  font-size: 1.2rem;
}

/* 邀請彈窗 */
.invite-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}

.invite-modal.hidden { display: none; }

.invite-modal-content {
  background: linear-gradient(135deg, #1b0f33 0%, #0d061c 100%);
  border: 1px solid #5d3fa1;
  border-radius: 12px;
  padding: 20px 24px;
  width: 300px;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.invite-modal-title {
  font-family: 'Cinzel', serif;
  color: #ffd700;
  font-size: 1rem;
  text-align: center;
}

.invite-user-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.invite-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(30, 20, 50, 0.5);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.invite-user-item:hover {
  background: rgba(50, 35, 80, 0.8);
}

.invite-user-item img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.invite-user-item span {
  flex: 1;
  font-size: 0.85rem;
  color: #e0e0e0;
}

.invite-user-item .invite-send-btn {
  background: #5865F2;
  border: none;
  border-radius: 4px;
  color: white;
  font-size: 0.7rem;
  padding: 4px 8px;
  cursor: pointer;
}

.invite-close-btn {
  background: rgba(30, 20, 50, 0.6);
  border: 1px solid rgba(93, 63, 161, 0.4);
  border-radius: 6px;
  color: #a496c4;
  padding: 6px;
  cursor: pointer;
  font-size: 0.8rem;
}

.invite-close-btn:hover {
  background: rgba(50, 35, 80, 0.8);
}

/* 隊伍戰鬥列 */
.team-battle-bar {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 6px 0;
}

.team-battle-bar.hidden { display: none; }

.team-battle-member {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(20, 10, 35, 0.6);
  border: 1px solid rgba(93, 63, 161, 0.3);
  border-radius: 8px;
  padding: 4px 10px;
}

.team-battle-member.is-me {
  border-color: #c9a227;
}

.team-battle-member.is-dead {
  opacity: 0.4;
}

.team-battle-member img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
}

.team-battle-hp {
  font-size: 0.7rem;
  color: #2ecc71;
  font-weight: 600;
  min-width: 60px;
}

.team-battle-hp-bar {
  width: 50px;
  height: 4px;
  background: rgba(0,0,0,0.5);
  border-radius: 2px;
  overflow: hidden;
}

.team-battle-hp-fill {
  height: 100%;
  background: #2ecc71;
  transition: width 0.3s;
  border-radius: 2px;
}

.menu-boss-preview {
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(30, 15, 40, 0.6);
  border: 1px solid rgba(160, 40, 50, 0.3);
  border-radius: 12px;
  padding: 16px 28px;
}

.menu-boss-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(180, 50, 60, 0.7);
  box-shadow: 0 0 20px rgba(180, 50, 60, 0.3);
}

.menu-boss-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-boss-name {
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #e84545;
  letter-spacing: 2px;
}

.menu-boss-desc {
  font-size: 0.8rem;
  color: #8a5050;
}

.menu-start-btn {
  width: 240px;
  height: 56px;
  background: linear-gradient(180deg, #5d3fa1 0%, #3a1f6e 100%);
  border: 2px solid #8c5fd4;
  border-radius: 12px;
  cursor: pointer;
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 4px;
  transition: all 0.3s ease;
  box-shadow: 0 0 20px rgba(93, 63, 161, 0.3);
}

.menu-start-btn:hover {
  background: linear-gradient(180deg, #7b52c9 0%, #5d3fa1 100%);
  border-color: #c9a227;
  box-shadow: 0 0 30px rgba(201, 162, 39, 0.4);
  transform: translateY(-2px);
}

.menu-controls {
  display: flex;
  gap: 12px;
}

.menu-ctrl-btn {
  background: rgba(30, 20, 50, 0.6);
  border: 1px solid rgba(93, 63, 161, 0.4);
  border-radius: 8px;
  color: #a496c4;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.menu-ctrl-btn:hover {
  background: rgba(50, 35, 80, 0.8);
  border-color: #8c7db3;
}

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

.battle-screen {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.battle-screen.hidden {
  display: none;
}

/* 血條上的重新戰鬥按鈕 */
.banner-restart-btn {
  background: rgba(30, 15, 40, 0.6);
  border: 1px solid rgba(160, 40, 50, 0.4);
  border-radius: 6px;
  font-size: 1.1rem;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.banner-restart-btn:hover {
  background: rgba(180, 50, 60, 0.3);
  border-color: #e84545;
}

/* 戰鬥舞台 */
.battle-stage {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  padding: 0 20px;
  position: relative;
  gap: 20px;
  overflow: visible;
}

/* === 站位格子系統 (4行x2列 = 8格) === */
.position-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  flex: 1;
  max-width: 520px;
  height: 100%;
  padding: 10px;
  position: relative;
  border-radius: 12px;
  background: rgba(20, 15, 35, 0.4);
  border: 1px solid rgba(93, 63, 161, 0.15);
  overflow: visible;
}

.grid-cell {
  background: rgba(40, 30, 70, 0.25);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: all 0.3s ease;
  min-height: 60px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px 6px;
}

/* 格子位置編號 */
.grid-cell::after {
  content: attr(data-pos);
  font-size: 0.6rem;
  color: rgba(160, 140, 200, 0.3);
  font-weight: 600;
  pointer-events: none;
}

/* 玩家格子區域色調 */
.player-grid {
  border-color: rgba(180, 145, 40, 0.2);
  background: rgba(30, 25, 15, 0.3);
}

.player-grid::before {
  content: 'PLAYER';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(180, 145, 40, 0.5);
  letter-spacing: 2px;
  font-family: 'Cinzel', serif;
  z-index: 5;
  background: rgba(30, 25, 15, 0.8);
  padding: 0 8px;
  border-radius: 0 0 4px 4px;
}

.player-grid .grid-cell {
  border-color: transparent;
  background: rgba(180, 145, 40, 0.04);
}

/* Boss 格子區域色調 */
.boss-grid {
  border-color: rgba(160, 40, 50, 0.2);
  background: rgba(30, 10, 15, 0.3);
}

.boss-grid::before {
  content: 'BOSS';
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(160, 40, 50, 0.5);
  letter-spacing: 2px;
  font-family: 'Cinzel', serif;
  z-index: 5;
  background: rgba(30, 10, 15, 0.8);
  padding: 0 8px;
  border-radius: 0 0 4px 4px;
}

.boss-grid .grid-cell {
  border-color: transparent;
  background: rgba(160, 40, 50, 0.04);
}

/* 佔用格子高亮效果 */
.grid-cell.occupied-player {
  background: rgba(180, 145, 40, 0.12);
  border-color: rgba(180, 145, 40, 0.35);
  box-shadow: inset 0 0 15px rgba(180, 145, 40, 0.1);
}

.grid-cell.occupied-boss {
  background: rgba(160, 40, 50, 0.12);
  border-color: rgba(160, 40, 50, 0.35);
  box-shadow: inset 0 0 15px rgba(160, 40, 50, 0.1);
}

/* 卡牌在格子中的定位 */
.grid-unit {
  position: absolute;
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 10;
}

/* 卡牌設計 */
.battle-card {
  transition: transform 0.1s ease, left 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), top 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* 精簡卡牌：僅頭像 + 血條 */
.compact-card {
  width: 100px;
  height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: transparent;
  padding: 0;
}

.compact-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(180, 145, 40, 0.7);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  background: #1a1a2e;
}

.compact-avatar .avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Boss 頭像邊框 */
.boss-grid .compact-avatar {
  border-color: rgba(180, 50, 60, 0.8);
}

/* 精簡血條 */
.compact-hp-bar {
  width: 90px;
  height: 10px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 5px;
  margin-top: 8px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.compact-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #22cc44 0%, #44ee66 100%);
  border-radius: 5px;
  transition: width 0.2s ease-out;
  box-shadow: 0 0 6px rgba(34, 204, 68, 0.4);
}

.compact-hp-bar.boss-hp .compact-hp-fill {
  background: linear-gradient(90deg, #cc2222 0%, #ee4444 100%);
  box-shadow: 0 0 6px rgba(204, 34, 34, 0.4);
}

.compact-hp-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
  white-space: nowrap;
  pointer-events: none;
}

/* 護盾條（HP 條下方） */
.compact-shield-bar {
  width: 90px;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 3px;
  margin-top: 2px;
  position: relative;
  overflow: hidden;
  display: none;
}
.compact-shield-bar.active { display: block; }
.compact-shield-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #4fc3f7 0%, #81d4fa 100%);
  border-radius: 3px;
  transition: width 0.3s ease-out;
  box-shadow: 0 0 4px rgba(79, 195, 247, 0.5);
}
.compact-shield-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.4rem;
  font-weight: 700;
  color: #fff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000;
  white-space: nowrap;
  pointer-events: none;
}

/* 傷害彈出系統 (星曲風格) */
.damage-container {
  position: absolute;
  top: -45px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 120px;
  pointer-events: none;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  z-index: 100;
}

.damage-pop {
  font-family: 'Cinzel', serif;
  font-weight: 900;
  color: #ffffff;
  text-align: center;
  position: absolute;
  animation: damage-float 1s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

/* 普通傷害：黃色/橘色描黑邊，富含星曲/神曲風格 */
.damage-pop.normal {
  color: #ffd200;
  font-size: 2.3rem;
  text-shadow: 
    -2px -2px 0 #000,  
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0px  4px 8px rgba(255, 210, 0, 0.7);
}

/* 暴擊傷害：超大、紅金漸變、左右震動且急速彈跳 */
.damage-pop.critical {
  color: #ff3838;
  font-size: 3.4rem;
  text-shadow: 
    -3px -3px 0 #000,  
     3px -3px 0 #000,
    -3px  3px 0 #000,
     3px  3px 0 #000,
     0px  0px 15px rgba(255, 56, 56, 0.8),
     0px  6px 12px rgba(255, 215, 0, 0.8);
  animation: crit-shake-pop 1.1s cubic-bezier(0.175, 0.885, 0.32, 1.3) forwards;
}

/* Critical 橫幅標籤 */
.damage-pop.critical::before {
  content: 'CRITICAL!';
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: #ffd700;
  letter-spacing: 2px;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

/* 治癒：綠色彈出 */
.damage-pop.heal {
  color: #00ff66;
  font-size: 2.2rem;
  text-shadow: 
    -2px -2px 0 #000,  
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0px  4px 8px rgba(0, 255, 102, 0.6);
}

.damage-pop.dodge {
  color: #38b6ff;
  font-size: 1.8rem;
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
}

/* 護盾：藍色光盾 */
.damage-pop.shield {
  color: #4fc3f7;
  font-size: 2rem;
  text-shadow: 
    -2px -2px 0 #000,  
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0px  0px 12px rgba(79, 195, 247, 0.8);
}

/* 護盾吸收：暗藍 */
.damage-pop.shield_absorb {
  color: #81d4fa;
  font-size: 1.8rem;
  text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000;
}

/* 傷害漂移與暴擊抖動動畫 */
@keyframes damage-float {
  0% {
    transform: translateY(20px) scale(0.6);
    opacity: 0;
  }
  20% {
    transform: translateY(-5px) scale(1.1);
    opacity: 1;
  }
  40% {
    transform: translateY(-10px) scale(1);
  }
  100% {
    transform: translateY(-50px) scale(0.85);
    opacity: 0;
  }
}

@keyframes crit-shake-pop {
  0% {
    transform: translateY(25px) scale(0.4) rotate(-5deg);
    opacity: 0;
  }
  15% {
    transform: translateY(-15px) scale(1.3) rotate(5deg);
    opacity: 1;
  }
  25% { transform: translateY(-15px) scale(1.2) rotate(-5deg); }
  35% { transform: translateY(-15px) scale(1.25) rotate(3deg); }
  45% { transform: translateY(-18px) scale(1.2) rotate(-2deg); }
  60% { transform: translateY(-22px) scale(1.15) rotate(0deg); opacity: 1;}
  100% {
    transform: translateY(-60px) scale(0.9);
    opacity: 0;
  }
}

/* 攻擊衝刺與受擊卡牌晃動 */
.player-attack {
  animation: player-charge 0.4s ease-in-out;
}

.boss-attack {
  animation: boss-charge 0.4s ease-in-out;
}

.card-shake {
  animation: card-shake-anim 0.3s ease-in-out;
}

@keyframes player-charge {
  0% { transform: translateX(0) scale(1); }
  30% { transform: translateX(-15px) scale(0.95); }
  50% { transform: translateX(50px) scale(1.05); } /* 向右衝刺 */
  100% { transform: translateX(0) scale(1); }
}

@keyframes boss-charge {
  0% { transform: translateX(0) scale(1); }
  30% { transform: translateX(15px) scale(0.95); }
  50% { transform: translateX(-50px) scale(1.05); } /* 向左衝刺 */
  100% { transform: translateX(0) scale(1); }
}

@keyframes card-shake-anim {
  0% { transform: translate(0, 0); }
  15% { transform: translate(-12px, 2px) rotate(-2deg); }
  30% { transform: translate(10px, -2px) rotate(2deg); }
  45% { transform: translate(-8px, 1px) rotate(-1deg); }
  60% { transform: translate(6px, -1px) rotate(1deg); }
  75% { transform: translate(-4px, 0); }
  100% { transform: translate(0, 0); }
}

/* QTE 遮罩與挑戰 */
.qte-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(6, 4, 12, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
}

.qte-overlay.hidden {
  display: none;
  pointer-events: none;
  opacity: 0;
}

.qte-box {
  width: 480px;
  background: linear-gradient(135deg, #1b0f33 0%, #0d061c 100%);
  border: 3px solid #ffcc00;
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 0 35px rgba(255, 204, 0, 0.4);
  animation: qte-zoom-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes qte-zoom-in {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.qte-title {
  font-family: 'Cinzel', serif;
  font-size: 1.3rem;
  color: #ffcc00;
  margin-bottom: 25px;
  text-shadow: 0 0 8px rgba(255, 204, 0, 0.5);
}

.qte-keys-container {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 25px;
}

.qte-key {
  width: 55px;
  height: 55px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid #5d3fa1;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.6rem;
  font-weight: 800;
  color: #a496c4;
  text-transform: uppercase;
  transition: all 0.15s ease;
  position: relative;
}

/* QTE 按鍵狀態 */
.qte-key.success {
  background: rgba(46, 204, 113, 0.15);
  border-color: #2ecc71;
  color: #2ecc71;
  box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
  transform: scale(1.08);
}

.qte-key.active-target {
  border-color: #ffcc00;
  color: #ffcc00;
  box-shadow: 0 0 15px rgba(255, 204, 0, 0.4);
  animation: pulse-yellow-border 1s infinite;
}

@keyframes pulse-yellow-border {
  0% { border-color: #ffcc00; }
  50% { border-color: #fff; }
  100% { border-color: #ffcc00; }
}

.qte-timer-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 15px;
}

.qte-timer-fill {
  width: 100%;
  height: 100%;
  background: #ff3333;
  transition: width 0.016s linear;
}

.qte-tip {
  font-size: 0.8rem;
  color: #a496c4;
}

.highlight {
  color: #ffcc00;
  font-weight: 600;
}

/* 底部技能面板 */
.control-section {
  padding: 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ═══════════════════════════════════════════════
   ★ 星曲風格狀態欄 —— 左圓圈HP + 技能 + 右圓圈怒氣
   ═══════════════════════════════════════════════ */

.wartune-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 700px;
}

/* 圓圈狀態指示器 */
.wartune-circle {
  width: 70px;
  height: 70px;
  position: relative;
  flex-shrink: 0;
}

.wartune-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.circle-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 6;
}

.circle-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

/* HP 圓圈 - 綠色 */
.hp-fill-circle {
  stroke: #22cc44;
  stroke-dasharray: 264;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 4px rgba(34, 204, 68, 0.5));
}

/* 怒氣圓圈 - 橘金色 */
.rage-fill-circle {
  stroke: #ffaa00;
  stroke-dasharray: 264;
  stroke-dashoffset: 264;
  filter: drop-shadow(0 0 4px rgba(255, 170, 0, 0.5));
}

.circle-icon {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
}

.circle-value {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

/* 中間技能區 */
.wartune-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 480px;
}

/* ATB 倒數條 */
.atb-countdown-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  transition: opacity 0.3s;
}

.atb-countdown-bar.active {
  opacity: 1;
}

.atb-countdown-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00d2ff 0%, #0088ff 100%);
  border-radius: 4px;
  transition: width 0.05s linear;
}

.atb-countdown-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.55rem;
  font-weight: 700;
  color: #fff;
  text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000;
}

/* 技能按鈕組 */
.wartune-skills {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.skill-btn {
  width: 52px;
  height: 52px;
  background: linear-gradient(180deg, #2b1f48 0%, #170f2a 100%);
  border: 1px solid #5d3fa1;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  flex: none;
}

.skill-btn:hover:not(:disabled) {
  border-color: #d4af37;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(212, 175, 55, 0.15);
}

.skill-btn:active:not(:disabled) {
  transform: translateY(0);
}

.skill-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(1);
}

/* 技能鎖定狀態 */
.skill-btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #00d2ff;
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

.skill-btn.locked::after {
  content: '🔒';
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.6rem;
}

/* 已選技能高亮 */
.skill-btn.selected {
  opacity: 1 !important;
  border-color: #ffd700 !important;
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.5) !important;
  filter: none !important;
  animation: selected-pulse 1s ease-in-out infinite;
}

@keyframes selected-pulse {
  0%   { box-shadow: 0 0 12px rgba(255, 215, 0, 0.4); }
  50%  { box-shadow: 0 0 22px rgba(255, 215, 0, 0.7); }
  100% { box-shadow: 0 0 12px rgba(255, 215, 0, 0.4); }
}

/* 奧義技能風格 */
.skill-btn.ultimate {
  background: linear-gradient(180deg, #a13f84 0%, #5a1144 100%);
  border-color: #ff38b6;
  box-shadow: 0 0 10px rgba(255, 56, 182, 0.15);
}

.skill-btn.ultimate:hover:not(:disabled) {
  border-color: #ffcc00;
  box-shadow: 0 0 20px rgba(255, 204, 0, 0.4);
}

.skill-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.skill-label {
  display: none;
}

/* ═══════════════════════════════════════════
   ★ 通用 Tooltip
   ═══════════════════════════════════════════ */

.game-tooltip {
  position: fixed;
  z-index: 500;
  background: linear-gradient(135deg, #1b0f33 0%, #0d061c 100%);
  border: 1px solid #5d3fa1;
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 260px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.game-tooltip.hidden {
  display: none;
}

.game-tooltip.visible {
  display: block;
}

.tooltip-title {
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffd700;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.tooltip-line {
  font-size: 0.75rem;
  color: #c5b5eb;
  line-height: 1.5;
}

/* 閃屏特效 (QTE 成功) */
.flash-white {
  animation: flash-white-anim 0.3s ease-out;
}

@keyframes flash-white-anim {
  0% { box-shadow: inset 0 0 100px rgba(255,255,255,1); background: rgba(255,255,255,0.8); }
  100% { box-shadow: inset 0 0 0 rgba(255,255,255,0); background: rgba(13, 9, 23, 0.95); }
}

/* ═══════════════════════════════════════════════
   ★ 技能名稱顯示 —— 星曲風格淡入淡出
   ═══════════════════════════════════════════════ */

.skill-name-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 150;
  pointer-events: none;
  text-align: center;
}

.skill-name-display.hidden {
  display: none;
}

.skill-name-display.show {
  display: block;
  animation: skill-name-fade 1.5s ease-in-out forwards;
}

#skill-name-text {
  font-family: 'Cinzel', serif;
  font-size: 2.4rem;
  font-weight: 700;
  color: #ffd700;
  letter-spacing: 4px;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0 0 20px rgba(255, 215, 0, 0.6),
     0 0 40px rgba(255, 180, 0, 0.3);
  white-space: nowrap;
}

/* 奧義專用樣式 */
.skill-name-display.ultimate-skill #skill-name-text {
  font-size: 2.8rem;
  color: #ff38b6;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0 0 25px rgba(255, 56, 182, 0.7),
     0 0 50px rgba(255, 56, 182, 0.3);
}

/* Boss 技能專用樣式 */
.skill-name-display.boss-skill #skill-name-text {
  color: #ff4444;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0 0 20px rgba(255, 68, 68, 0.6),
     0 0 40px rgba(200, 30, 30, 0.3);
}

@keyframes skill-name-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.05);
  }
  30% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  70% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* 技能施放者頭像 */
.skill-caster-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #ffd700;
  vertical-align: middle;
  margin-right: 12px;
  object-fit: cover;
}

.skill-name-display.boss-skill .skill-caster-avatar {
  border-color: #ff4444;
}

.skill-name-display.ultimate-skill .skill-caster-avatar {
  border-color: #ff38b6;
}

/* ═══════════════════════════════════════════════
   ★ BOSS 頂部大血條 —— 星曲壓迫感風格
   ═══════════════════════════════════════════════ */

.boss-hp-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  margin-bottom: 10px;
  background: linear-gradient(90deg, #1a0808 0%, #100508 60%, rgba(10,4,12,0) 100%);
  border-top: 1px solid rgba(180, 30, 30, 0.35);
  border-bottom: 2px solid rgba(140, 20, 20, 0.5);
  position: relative;
  flex-shrink: 0;
}

.boss-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.boss-banner-avatar-wrap {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(160, 40, 40, 0.7);
  flex-shrink: 0;
}

.boss-banner-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.boss-banner-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
}

.boss-banner-name {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: #e84545;
  letter-spacing: 1px;
}

.boss-banner-title {
  font-size: 0.65rem;
  color: #8a5050;
  letter-spacing: 0.5px;
}

.boss-banner-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.boss-banner-bar-bg {
  position: relative;
  width: 100%;
  height: 22px;
  background: #0d0305;
  border-radius: 3px;
  border: 1px solid rgba(80, 10, 10, 0.8);
  overflow: hidden;
}

/* 延遲殘影血條 */
.boss-banner-bar-delay {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #c97c00 0%, #e8a000 100%);
  border-radius: 2px;
  transition: width 1.2s ease-out;
  z-index: 1;
}

/* 主血條 */
.boss-banner-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7a0000 0%, #cc1111 50%, #ff2828 100%);
  border-radius: 2px;
  transition: width 0.25s ease-out;
  z-index: 2;
}

.boss-banner-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255, 100, 100, 0.35);
  border-radius: 2px 2px 0 0;
}

/* 分格線 (9 條分線 = 10 格) */
.boss-banner-segments {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  z-index: 3;
  pointer-events: none;
}

.boss-banner-segments .seg {
  flex: 1;
  border-right: 1px solid rgba(0, 0, 0, 0.55);
}

.boss-banner-segments .seg:last-child {
  border-right: none;
}

.boss-banner-hp-text {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: #c44040;
  text-align: right;
  letter-spacing: 1px;
}

/* 危急閃爍（HP 低於 30%） */
.boss-banner-bar-fill.danger {
  animation: bar-danger-pulse 0.8s ease-in-out infinite;
}

@keyframes bar-danger-pulse {
  0%   { filter: brightness(1); }
  50%  { filter: brightness(1.6); }
  100% { filter: brightness(1); }
}

/* ═══════════════════════════════════════════════
   ★ 回合制選擇階段 —— 技能圖標氣泡 + 綠色格子
   ═══════════════════════════════════════════════ */

/* 技能圖標氣泡（卡牌上方） */
.skill-icon-bubble {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(20, 10, 35, 0.9);
  border: 2px solid #ffd700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 900;
  z-index: 20;
  animation: bubble-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

@keyframes bubble-pop {
  0% { transform: translateX(-50%) scale(0); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.2); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* 綠色格子高亮（已選擇技能的玩家格子） */
/* 卡片綠色高亮（已選擇技能） */
.compact-card.occupied-selected {
  outline: 2px solid rgba(46, 204, 113, 0.7);
  outline-offset: 2px;
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.4) !important;
}

/* ═══════════════════════════════════════════════
   ★ 共用 ATB 條 + Boss ATB 條
   ═══════════════════════════════════════════════ */

/* 團隊共用 ATB 條 */
.shared-atb-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.shared-atb-bar.hidden {
  display: none;
}

.shared-atb-label {
  font-size: 0.6rem;
  font-weight: 700;
  color: #00d2ff;
  letter-spacing: 1px;
  white-space: nowrap;
  min-width: 58px;
}

.shared-atb-track {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(0, 210, 255, 0.2);
}

.shared-atb-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00d2ff 0%, #0088ff 100%);
  border-radius: 4px;
  transition: width 0.05s linear;
  box-shadow: 0 0 6px rgba(0, 210, 255, 0.4);
}

.shared-atb-text {
  font-size: 0.55rem;
  font-weight: 700;
  color: #00d2ff;
  min-width: 28px;
  text-align: right;
}

/* Boss ATB 條 */
.boss-atb-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 2px;
}

.boss-atb-bar.hidden {
  display: none;
}

.boss-atb-label {
  font-size: 0.5rem;
  font-weight: 700;
  color: #ff6b6b;
  letter-spacing: 1px;
  white-space: nowrap;
  min-width: 52px;
}

.boss-atb-track {
  flex: 1;
  height: 5px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid rgba(255, 60, 60, 0.2);
}

.boss-atb-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff4444 0%, #ff6b6b 100%);
  border-radius: 3px;
  transition: width 0.05s linear;
  box-shadow: 0 0 4px rgba(255, 68, 68, 0.4);
}

.boss-atb-text {
  font-size: 0.45rem;
  font-weight: 700;
  color: #ff6b6b;
  min-width: 24px;
  text-align: right;
}

/* ═══════════════════════════════════════════════
   ★ 多行技能同時顯示（團隊回合結算）
   ═══════════════════════════════════════════════ */

.multi-skill-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 150;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: multi-skill-appear 0.4s ease-out;
}

.multi-skill-display.fade-out {
  animation: multi-skill-fade 0.5s ease-out forwards;
}

@keyframes multi-skill-appear {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes multi-skill-fade {
  0% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.05); }
}

.multi-skill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 5, 20, 0.85);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  padding: 6px 16px;
  backdrop-filter: blur(4px);
}

.multi-skill-row.boss-row {
  border-color: rgba(255, 68, 68, 0.4);
}

.multi-skill-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #ffd700;
  object-fit: cover;
  flex-shrink: 0;
}

.multi-skill-row.boss-row .multi-skill-avatar {
  border-color: #ff4444;
}

.multi-skill-name {
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffd700;
  letter-spacing: 3px;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0 0 12px rgba(255, 215, 0, 0.4);
  white-space: nowrap;
}

.multi-skill-row.boss-row .multi-skill-name {
  color: #ff4444;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0 0 12px rgba(255, 68, 68, 0.4);
}
