/* ============================================================
   main.css — RPG 明亮主題
   ============================================================ */

/* ─── CSS 變數 ─────────────────────────────────────────────── */
:root {
  --bg-deep:     #f0f4f8;
  --bg-dark:     #e2e8f0;
  --bg-panel:    #ffffff;
  --bg-card:     #f8fafc;
  --bg-hover:    #e8eef5;
  --border:      #cbd5e1;
  --border-glow: #6366f1;

  --gold:        #d97706;
  --gold-dim:    #b45309;
  --silver:      #64748b;
  --purple-glow: #7c3aed;
  --blue-glow:   #2563eb;
  --green-glow:  #16a34a;
  --red-glow:    #dc2626;
  --orange:      #ea580c;

  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-dim:       #94a3b8;

  --hp-bar:   #ef4444;
  --hp-bg:    #fee2e2;
  --xp-bar:   #22c55e;
  --xp-bg:    #dcfce7;
  --mp-bar:   #3b82f6;

  --rarity-white:  #64748b;
  --rarity-green:  #16a34a;
  --rarity-blue:   #2563eb;
  --rarity-purple: #7c3aed;
  --rarity-gold:   #d97706;

  --font-main: 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
  --font-rpg:  'Georgia', serif;

  --radius:   12px;
  --radius-sm: 6px;
  --shadow:   0 2px 12px rgba(0,0,0,0.1);
  --glow-purple: 0 0 16px rgba(124,58,237,0.2);
  --glow-gold:   0 0 16px rgba(217,119,6,0.2);
}

/* ─── 全域重置 ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--gold); text-decoration: none; }
button { cursor: pointer; font-family: var(--font-main); border: none; outline: none; }
input, select, textarea { font-family: var(--font-main); }

/* ─── 捲軸美化 ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-glow); border-radius: 3px; }

/* ─── 背景裝飾 ───────────────────────────────────────── */
.starfield {
  position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(circle at 20% 30%, rgba(99,102,241,0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(124,58,237,0.05) 0%, transparent 50%),
    var(--bg-deep);
}

/* ═══════════════════════════════════════════════════════════
   登入 / 註冊 頁面
   ═══════════════════════════════════════════════════════════ */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
}
.auth-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow), var(--glow-purple);
  position: relative;
  z-index: 1;
}
.auth-logo {
  text-align: center;
  margin-bottom: 30px;
}
.auth-logo .logo-icon { font-size: 56px; display: block; margin-bottom: 8px; }
.auth-logo h1 {
  font-size: 26px;
  color: var(--gold);
  text-shadow: var(--glow-gold);
  letter-spacing: 2px;
}
.auth-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-dark);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.25s;
}
.auth-tab.active {
  background: var(--purple-glow);
  color: white;
  box-shadow: 0 0 12px rgba(168,85,247,0.5);
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: var(--purple-glow);
  box-shadow: 0 0 0 2px rgba(168,85,247,0.2);
  outline: none;
}

/* 職業選擇 */
.class-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}
.class-card {
  padding: 14px 10px;
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.class-card:hover { border-color: var(--purple-glow); transform: translateY(-2px); }
.class-card.selected {
  border-color: var(--gold);
  background: rgba(255,215,0,0.1);
  box-shadow: var(--glow-gold);
}
.class-card .class-icon { font-size: 28px; display: block; margin-bottom: 4px; }
.class-card .class-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.class-card .class-desc { font-size: 11px; color: var(--text-secondary); margin-top: 3px; line-height: 1.4; }

/* 屬性分配預覽 */
.stat-preview {
  background: var(--bg-dark);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12px;
  margin-top: 8px;
}
.stat-row { display: flex; justify-content: space-between; align-items: center; }
.stat-name { color: var(--text-secondary); }
.stat-val  { color: var(--gold); font-weight: 700; }

/* 表單錯誤訊息 */
.form-error {
  color: #f87171;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
  text-align: center;
}

/* ─── 存槽選擇畫面 ──────────────────────────────────────── */
.slot-card-outer {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 760px;
  box-shadow: var(--shadow), 0 0 30px rgba(139,92,246,0.15);
}
.slot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.slot-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}
.slot-header-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg,#7c3aed,#4f46e5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: white;
  border: 2px solid rgba(139,92,246,0.5);
}
.slot-header-email {
  font-size: 13px;
  color: var(--text-secondary);
}
.slot-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 600px) {
  .slot-grid { grid-template-columns: 1fr; }
}
.slot-card {
  border-radius: 14px;
  padding: 20px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.slot-card:hover { transform: translateY(-2px); }
.slot-used {
  border-color: rgba(139,92,246,0.6);
  box-shadow: 0 0 16px rgba(139,92,246,0.2);
}
.slot-used:hover { box-shadow: 0 0 24px rgba(139,92,246,0.4); }
.slot-empty {
  border-style: dashed;
  border-color: var(--border);
  align-items: center;
  justify-content: center;
  min-height: 180px;
}
.slot-empty:hover { border-color: rgba(139,92,246,0.5); background: rgba(139,92,246,0.05); }
.slot-number {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.slot-sprite {
  width: 80px;
  height: 80px;
  object-fit: contain;
  image-rendering: pixelated;
  margin: 0 auto;
  display: block;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.4));
}
.slot-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
}
.slot-meta {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}
.slot-last-played {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.slot-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}
.slot-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  transition: all 0.15s;
}
.slot-btn-play {
  background: linear-gradient(135deg,#7c3aed,#4f46e5);
  color: white;
  box-shadow: 0 2px 8px rgba(124,58,237,0.4);
}
.slot-btn-play:hover { filter: brightness(1.15); }
.slot-btn-del {
  background: rgba(239,68,68,0.12);
  color: #f87171;
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.slot-btn-del:hover { background: rgba(239,68,68,0.25); transform: scale(1.1); }
.slot-empty-icon {
  font-size: 40px;
  margin-bottom: 8px;
  opacity: 0.4;
}
.slot-empty-text {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 600;
}
.slot-empty-sub {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-top: 4px;
}

/* 按鈕 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}
.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: white;
  box-shadow: 0 4px 14px rgba(124,58,237,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,58,237,0.6); }
.btn-primary:active { transform: translateY(0); }
.btn-gold {
  background: linear-gradient(135deg, #b8860b, #ffd700);
  color: #1a1a00;
  box-shadow: 0 4px 14px rgba(255,215,0,0.3);
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: var(--glow-gold); }
.btn-danger {
  background: linear-gradient(135deg, #7f1d1d, #ef4444);
  color: white;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-ghost:hover { border-color: var(--purple-glow); color: var(--text-primary); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-sm); }

/* ═══════════════════════════════════════════════════════════
   主遊戲 Layout
   ═══════════════════════════════════════════════════════════ */
.game-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  background: var(--bg-deep);
}

/* ─── 頂部 HUD ──────────────────────────────────────────── */
.hud {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 8px rgba(0,0,0,0.08);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.hud-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--purple-glow);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.hud-info { flex: 1; min-width: 0; }
.hud-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud-title {
  font-size: 11px;
  color: var(--purple-glow);
  margin-top: 1px;
}

.hud-bars { flex: 2; min-width: 180px; }
.bar-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.bar-label { font-size: 10px; color: var(--text-secondary); width: 20px; }
.bar-track {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
.bar-hp-track  { background: var(--hp-bg); }
.bar-xp-track  { background: var(--xp-bg); }
.bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.5s ease;
  position: relative;
}
.bar-hp-fill  { background: linear-gradient(90deg, #991b1b, var(--hp-bar)); }
.bar-xp-fill  { background: linear-gradient(90deg, #14532d, var(--xp-bar)); }
.bar-text { font-size: 10px; color: var(--text-secondary); min-width: 60px; text-align: right; }

.hud-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.hud-stat {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  min-width: 52px;
}
.hud-stat-val { font-size: 16px; font-weight: 900; color: var(--gold); line-height: 1; }
.hud-stat-label { font-size: 10px; color: var(--text-secondary); }

.hud-nav { display: flex; gap: 4px; margin-left: auto; }
.hud-nav-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}
.hud-nav-btn:hover, .hud-nav-btn.active {
  border-color: var(--purple-glow);
  color: var(--text-primary);
  background: rgba(99,102,241,0.1);
}

/* 屬性點徽章（角色按鈕右上角） */
.attr-badge {
  position: absolute; top: -4px; right: -4px;
  background: #ef4444; color: white;
  font-size: 10px; font-weight: 800;
  min-width: 16px; height: 16px;
  border-radius: 99px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
  animation: attrBadgePulse 1.5s ease-in-out infinite;
  border: 1px solid var(--bg-deep);
  pointer-events: none;
}
@keyframes attrBadgePulse {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.2); }
}

/* ─── 主內容區 ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 20px 16px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  z-index: 1;
}

/* ─── 分頁視圖 ──────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ─── 面板卡片 ──────────────────────────────────────────── */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ═══════════════════════════════════════════════════════════
   地城選擇
   ═══════════════════════════════════════════════════════════ */
.dungeon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.dungeon-card {
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 2px solid transparent;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dungeon-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  transition: opacity 0.25s;
}
.dungeon-card:hover { transform: translateY(-4px); border-color: var(--gold); }
.dungeon-card:hover::before { opacity: 0; }
.dungeon-card.locked { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.7); }
.dungeon-card > * { position: relative; z-index: 1; }

.dungeon-icon { font-size: 36px; }
.dungeon-name { font-size: 17px; font-weight: 700; color: white; }
.dungeon-name-en { font-size: 11px; color: rgba(255,255,255,0.6); margin-top: -4px; }
.dungeon-desc { font-size: 12px; color: rgba(255,255,255,0.75); line-height: 1.5; }
.dungeon-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.dungeon-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.9);
}
.dungeon-tag.cleared { background: rgba(34,197,94,0.3); color: var(--green-glow); }
.dungeon-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}
.dungeon-progress-fill { height: 100%; background: var(--gold); transition: width 0.5s; }

/* ═══════════════════════════════════════════════════════════
   戰鬥介面
   ═══════════════════════════════════════════════════════════ */
#battle-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-deep);
  flex-direction: column;
  overflow-y: auto;
}
#battle-screen.show { display: flex; }

.battle-bg {
  position: absolute;
  inset: 0;
  opacity: 0.15;
  background-size: cover;
  background-position: center;
  filter: blur(2px);
}
.battle-content { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* 主體：左右分割 */
.battle-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.battle-left {
  flex: 0 0 45%;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0,0,0,0.08);
  min-height: 0;
}
.battle-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: rgba(248,250,252,0.95);
  min-height: 0;
}
.battle-right .question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-top: none;
  overflow: hidden;
}

/* 手機版：改回垂直排列，壓縮高度 */
@media (max-width: 640px) {
  .battle-main        { flex-direction: column; }
  .battle-left        { flex: 0 0 auto; border-right: none; border-bottom: 1px solid rgba(0,0,0,0.08); }
  .battle-right       { flex: 1; }
  .monster-area       { padding: 10px 16px; gap: 8px; }
  .monster-sprite     { width: 72px; height: 72px; }
  .monster-icon-wrap  { font-size: 60px; }
  .monster-hp-bar-wrap{ width: 240px; }
  .question-area      { padding: 10px 12px; }
  .option-btn         { padding: 10px 8px; font-size: 14px; }
}

/* 戰鬥頂部欄 */
.battle-top {
  padding: 12px 16px;
  background: rgba(255,255,255,0.9);
  display: flex;
  align-items: center;
  gap: 12px;
}
.battle-progress-text { font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.battle-progress-bar-wrap { flex: 1; height: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; overflow: hidden; }
.battle-progress-bar-fill { height: 100%; background: var(--gold); transition: width 0.4s; }
.battle-flee-btn {
  padding: 6px 14px;
  background: rgba(239,68,68,0.3);
  border: 1px solid var(--red-glow);
  color: var(--red-glow);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s;
}
.battle-flee-btn:hover { background: rgba(239,68,68,0.5); }

/* 怪獸區域 */
.monster-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px 20px;
  gap: 12px;
}
.monster-container {
  text-align: center;
  animation: monsterEntrance 0.5s ease-out;
}
@keyframes monsterEntrance {
  from { transform: translateX(200px) scale(0.5); opacity: 0; }
  to   { transform: translateX(0) scale(1); opacity: 1; }
}
.monster-icon-wrap {
  font-size: 90px;
  line-height: 1;
  filter: drop-shadow(0 0 20px rgba(239,68,68,0.5));
  transition: transform 0.15s;
  display: inline-block;
}
.monster-icon-wrap.shake {
  animation: monsterShake 0.4s ease;
}
@keyframes monsterShake {
  0%,100% { transform: translateX(0) rotate(0); }
  20%     { transform: translateX(-8px) rotate(-3deg); }
  40%     { transform: translateX(8px) rotate(3deg); }
  60%     { transform: translateX(-5px) rotate(-2deg); }
  80%     { transform: translateX(5px) rotate(2deg); }
}
.monster-icon-wrap.attack { animation: monsterAttack 0.4s ease; }
@keyframes monsterAttack {
  0%   { transform: translateX(0); }
  30%  { transform: translateX(-60px) scale(1.1); }
  100% { transform: translateX(0); }
}

/* 怪獸稀有度光環 */
.monster-icon-wrap.rarity-common    { filter: drop-shadow(0 0 6px rgba(156,163,175,0.5)); }
.monster-icon-wrap.rarity-uncommon  { filter: drop-shadow(0 0 10px rgba(34,197,94,0.7)); animation: rarityGlowGreen 2s ease-in-out infinite; }
.monster-icon-wrap.rarity-rare      { filter: drop-shadow(0 0 12px rgba(59,130,246,0.8)); animation: rarityGlowBlue 2s ease-in-out infinite; }
.monster-icon-wrap.rarity-epic      { filter: drop-shadow(0 0 16px rgba(168,85,247,0.9)); animation: rarityGlowPurple 1.5s ease-in-out infinite; }
.monster-icon-wrap.rarity-legendary { filter: drop-shadow(0 0 20px rgba(251,191,36,1.0)); animation: rarityGlowGold 1.2s ease-in-out infinite; }
@keyframes rarityGlowGreen  { 0%,100%{filter:drop-shadow(0 0 8px rgba(34,197,94,0.6))} 50%{filter:drop-shadow(0 0 18px rgba(34,197,94,1.0))} }
@keyframes rarityGlowBlue   { 0%,100%{filter:drop-shadow(0 0 10px rgba(59,130,246,0.7))} 50%{filter:drop-shadow(0 0 22px rgba(59,130,246,1.0))} }
@keyframes rarityGlowPurple { 0%,100%{filter:drop-shadow(0 0 14px rgba(168,85,247,0.8))} 50%{filter:drop-shadow(0 0 28px rgba(168,85,247,1.0))} }
@keyframes rarityGlowGold   { 0%,100%{filter:drop-shadow(0 0 16px rgba(251,191,36,0.9))} 50%{filter:drop-shadow(0 0 34px rgba(251,191,36,1.0)) drop-shadow(0 0 60px rgba(251,191,36,0.4))} }

.monster-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--red-glow);
  margin-top: 8px;
  text-shadow: 0 0 10px rgba(239,68,68,0.5);
}
.monster-boss-badge {
  display: inline-block;
  background: linear-gradient(90deg, var(--gold), var(--orange));
  color: #1a1a00;
  font-size: 11px;
  font-weight: 900;
  padding: 2px 10px;
  border-radius: 99px;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.monster-hp-bar-wrap { width: 280px; max-width: 80vw; }
.monster-hp-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.monster-hp-track { height: 14px; background: var(--hp-bg); border-radius: 7px; overflow: hidden; border: 1px solid rgba(239,68,68,0.3); }
.monster-hp-fill  { height: 100%; background: linear-gradient(90deg, #991b1b, #ef4444); transition: width 0.4s ease; border-radius: 7px; position: relative; }
.monster-hp-fill::after {
  content: '';
  position: absolute;
  top: 2px; left: 4px; right: 4px; height: 3px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
}

/* 玩家狀態 */
.player-status {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255,255,255,0.9);
  border-top: 1px solid rgba(0,0,0,0.08);
}
.player-avatar { font-size: 28px; }
.player-hp-wrap { flex: 1; }
.player-hp-track { height: 10px; background: var(--hp-bg); border-radius: 5px; overflow: hidden; }
.player-hp-fill  { height: 100%; background: linear-gradient(90deg, #991b1b, #ef4444); transition: width 0.4s; }
.player-hp-text  { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.combo-badge {
  padding: 4px 12px;
  background: linear-gradient(135deg, #f97316, #fbbf24);
  border-radius: 99px;
  font-size: 13px;
  font-weight: 900;
  color: #1a1a00;
  display: none;
}
.combo-badge.show { display: block; }

/* 問題區域 */
.question-area {
  padding: 20px 24px;
  background: transparent;
}
.question-word {
  text-align: center;
  margin-bottom: 12px;
}
.question-word-text {
  font-size: 36px;
  font-weight: 900;
  color: #1e293b;
  letter-spacing: 2px;
  text-shadow: none;
  transition: font-size 0.2s;
}
.question-word-text.sentence-mode {
  font-size: 20px;
  letter-spacing: 0;
  text-shadow: none;
  line-height: 1.5;
}
.question-example { font-size: 13px; color: var(--text-secondary); margin-top: 4px; font-style: italic; }

/* 發音按鈕 */
.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px auto 0;
  padding: 5px 16px;
  background: rgba(37,99,235,0.08);
  border: 1px solid rgba(37,99,235,0.4);
  border-radius: 99px;
  color: #2563eb;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.speak-btn:hover {
  background: rgba(37,99,235,0.15);
  border-color: #2563eb;
  color: #1e40af;
  transform: scale(1.05);
}
.speak-btn:active { transform: scale(0.97); }

/* 計時器 */
.timer-bar-wrap { height: 4px; background: rgba(0,0,0,0.08); border-radius: 2px; margin-bottom: 12px; overflow: hidden; }
.timer-bar-fill { height: 100%; background: var(--green-glow); transition: width 0.1s linear; }
.timer-bar-fill.warning { background: var(--orange); }
.timer-bar-fill.danger  { background: var(--red-glow); }

/* 選項按鈕 */
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-btn {
  padding: 14px 12px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--purple-glow);
  background: var(--bg-hover);
  transform: scale(1.02);
}
.option-btn:active:not(:disabled) { transform: scale(0.98); }
.option-btn.correct {
  border-color: var(--green-glow);
  background: rgba(34,197,94,0.2);
  color: var(--green-glow);
  animation: correctPulse 0.4s ease;
}
.option-btn.wrong {
  border-color: var(--red-glow);
  background: rgba(239,68,68,0.2);
  color: var(--red-glow);
}
@keyframes correctPulse {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* 聽發音題型：大喇叭顯示 */
.question-word-text.listen-mode {
  font-size: 56px;
  letter-spacing: 0;
  text-shadow: 0 0 30px rgba(59,130,246,0.6);
  cursor: pointer;
  line-height: 1;
}
.question-word-text.listen-mode:hover { transform: scale(1.08); }
.listen-icon {
  display: inline-block;
  animation: listenPulse 1s ease-in-out infinite;
}
@keyframes listenPulse {
  0%,100% { transform: scale(1);    filter: drop-shadow(0 0 6px rgba(59,130,246,0.5)); }
  50%      { transform: scale(1.12); filter: drop-shadow(0 0 16px rgba(59,130,246,0.9)); }
}

/* 填字題型：大字母帶底線空格 */
.question-word-text.spellfill-mode {
  font-size: 42px;
  letter-spacing: 6px;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255,215,0,0.4);
}

/* 字母選項按鈕（Boss / 小Boss 用） */
.options-grid-letter { grid-template-columns: repeat(4, 1fr); gap: 10px; }
.option-letter {
  padding: 18px 8px !important;
  font-size: 22px !important;
  font-weight: 900 !important;
  letter-spacing: 1px;
  background: rgba(168,85,247,0.1) !important;
  border-color: var(--purple-glow) !important;
  color: var(--purple-glow) !important;
}
.option-letter:hover:not(:disabled) {
  background: rgba(99,102,241,0.15) !important;
  color: #4f46e5 !important;
  transform: scale(1.05);
}

/* ─── 浮動數字效果 ─────────────────────────────────────── */
.floating-text {
  position: fixed;
  pointer-events: none;
  font-weight: 900;
  font-size: 22px;
  z-index: 9999;
  animation: floatUp 1.2s ease-out forwards;
}
.floating-text.damage  { color: var(--red-glow);   text-shadow: 0 0 10px rgba(239,68,68,0.8); }
.floating-text.heal    { color: var(--green-glow); text-shadow: 0 0 10px rgba(34,197,94,0.8); }
.floating-text.xp      { color: var(--xp-bar);     font-size: 16px; }
.floating-text.gold    { color: var(--gold);        font-size: 16px; }
.floating-text.dodge   { color: var(--blue-glow);  font-size: 18px; }
.floating-text.correct { color: var(--green-glow); font-size: 28px; }
@keyframes floatUp {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-80px) scale(0.5); opacity: 0; }
}

/* ═══════════════════════════════════════════════════════════
   角色頁面
   ═══════════════════════════════════════════════════════════ */
.char-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
@media (max-width: 640px) { .char-layout { grid-template-columns: 1fr; } }

.char-portrait {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.char-avatar-big { font-size: 64px; margin-bottom: 10px; display: block; }
.char-name-big { font-size: 18px; font-weight: 700; color: var(--gold); }
.char-class-badge {
  display: inline-block;
  margin: 6px 0;
  padding: 3px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(168,85,247,0.25);
  border: 1px solid var(--purple-glow);
  color: var(--purple-glow);
}
.char-level-text { font-size: 28px; font-weight: 900; color: var(--text-primary); }
.char-level-label { font-size: 11px; color: var(--text-secondary); }
.char-cp { color: var(--orange); font-size: 14px; font-weight: 700; margin-top: 8px; }
.char-title-badge {
  margin-top: 10px;
  padding: 8px 12px;
  background: linear-gradient(135deg, rgba(255,215,0,0.12), rgba(168,85,247,0.10));
  border: 1px solid var(--gold);
  border-radius: 10px;
  color: var(--gold);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.char-title-badge:hover {
  border-color: var(--purple-glow);
  box-shadow: 0 0 12px rgba(168,85,247,0.35);
}

/* 屬性面板 */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; position: relative; z-index: 1; }
.stat-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.stat-icon  { font-size: 22px; width: 32px; text-align: center; }
.stat-info  { flex: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); }
.stat-value { font-size: 20px; font-weight: 900; color: var(--text-primary); line-height: 1; }
.stat-bonus { font-size: 11px; color: var(--green-glow); }
.stat-plus-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(168,85,247,0.3);
  border: 1px solid var(--purple-glow);
  color: var(--text-primary);
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.stat-plus-btn:hover:not(:disabled) { background: var(--purple-glow); }
.stat-plus-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.attr-points-banner {
  background: linear-gradient(90deg, rgba(168,85,247,0.2), rgba(255,215,0,0.1));
  border: 1px solid var(--purple-glow);
  border-radius: var(--radius);
  padding: 10px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 14px;
  display: none;
}
.attr-points-banner.show { display: block; }

/* 裝備欄位 */
.equipment-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 480px) { .equipment-grid { grid-template-columns: repeat(3, 1fr); } }
.equip-slot {
  aspect-ratio: 1;
  background: var(--bg-dark);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  min-height: 72px;
}
.equip-slot:hover { border-color: var(--purple-glow); background: var(--bg-hover); }
.equip-slot.has-item { border-style: solid; }
.equip-slot.has-item.white  { border-color: var(--rarity-white); }
.equip-slot.has-item.green  { border-color: var(--rarity-green); }
.equip-slot.has-item.blue   { border-color: var(--rarity-blue); }
.equip-slot.has-item.purple { border-color: var(--rarity-purple); box-shadow: 0 0 8px rgba(163,53,238,0.4); }
.equip-slot.has-item.gold   { border-color: var(--rarity-gold);   box-shadow: 0 0 8px rgba(255,128,0,0.5); }
.equip-slot-icon { font-size: 24px; }
.equip-slot-name { font-size: 10px; color: var(--text-secondary); text-align: center; margin-top: 3px; }
.equip-slot-label { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════
   背包 / 鑄造頁面
   ═══════════════════════════════════════════════════════════ */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
}
.item-cell {
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  padding: 4px;
}
.item-cell:hover { transform: scale(1.05); }
.item-cell.white  { border-color: var(--rarity-white); }
.item-cell.green  { border-color: var(--rarity-green); }
.item-cell.blue   { border-color: var(--rarity-blue); }
.item-cell.purple { border-color: var(--rarity-purple); box-shadow: 0 0 6px rgba(163,53,238,0.4); }
.item-cell.gold   { border-color: var(--rarity-gold);   box-shadow: 0 0 8px rgba(255,128,0,0.5); animation: goldGlow 2s ease-in-out infinite; }
@keyframes goldGlow {
  0%,100% { box-shadow: 0 0 8px rgba(255,128,0,0.5); }
  50%     { box-shadow: 0 0 18px rgba(255,128,0,0.9); }
}
.item-cell-icon { font-size: 26px; }
.item-cell-name { font-size: 9px; color: var(--text-secondary); text-align: center; line-height: 1.2; margin-top: 2px; overflow: hidden; max-height: 24px; }

/* 背包分頁 */
.inv-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.inv-tab {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.inv-tab.active {
  background: rgba(168,85,247,0.2);
  border-color: var(--purple-glow);
  color: var(--text-primary);
  box-shadow: 0 0 10px rgba(168,85,247,0.2);
}
.inv-tab-badge {
  background: var(--purple-glow);
  color: #ffffff;
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 700;
}
.inv-tab.active .inv-tab-badge { background: var(--gold); color: #000; }

/* 背包：左右並排 */
.inv-layout { display: grid; grid-template-columns: 1fr 260px; gap: 16px; align-items: start; }
@media (max-width: 640px) { .inv-layout { grid-template-columns: 1fr; } }

/* 字母倉庫 */
.letters-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.letter-chip {
  min-width: 44px;
  padding: 6px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  text-align: center;
}
.letter-char { font-size: 18px; font-weight: 900; color: var(--gold); }
.letter-count { font-size: 11px; color: var(--text-secondary); }

/* ═══════════════════════════════════════════════════════════
   成就頁面
   ═══════════════════════════════════════════════════════════ */
.achievement-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.achievement-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: all 0.3s;
  position: relative;
}
/* 已達成：金色發光邊框＋溫暖底色 */
.achievement-card.unlocked {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(255,215,0,0.12), rgba(255,180,0,0.06));
  box-shadow: 0 0 14px rgba(255,215,0,0.25), inset 0 0 20px rgba(255,215,0,0.05);
}
.achievement-card.unlocked .achievement-icon { filter: drop-shadow(0 0 6px rgba(255,215,0,0.7)); }
.achievement-card.unlocked .achievement-name { color: var(--gold); text-shadow: 0 0 8px rgba(255,215,0,0.5); }
/* 未達成：較暗，去色 */
.achievement-card.locked {
  opacity: 0.5;
  filter: grayscale(0.6);
}
.achievement-card.locked .achievement-name { color: var(--text-secondary); }
.achievement-icon { font-size: 28px; flex-shrink: 0; }
.achievement-name { font-size: 13px; font-weight: 700; color: var(--gold); }
.achievement-desc { font-size: 11px; color: var(--text-secondary); margin-top: 3px; line-height: 1.4; }
.achievement-reward { font-size: 11px; color: var(--xp-bar); margin-top: 4px; }
.ach-badge-done {
  position: absolute;
  top: 8px; right: 10px;
  width: 20px; height: 20px;
  background: var(--green-glow);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 900; color: #000;
  box-shadow: 0 0 8px rgba(74,222,128,0.6);
}

/* ═══════════════════════════════════════════════════════════
   排行榜
   ═══════════════════════════════════════════════════════════ */
.leaderboard-table { width: 100%; border-collapse: collapse; }
.leaderboard-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  font-size: 14px;
}
.leaderboard-table tr:hover td { background: var(--bg-hover); }
.leaderboard-rank { font-weight: 900; color: var(--text-secondary); }
.rank-1 .leaderboard-rank { color: var(--gold);       font-size: 18px; }
.rank-2 .leaderboard-rank { color: var(--silver);     font-size: 16px; }
.rank-3 .leaderboard-rank { color: #cd7f32;            font-size: 15px; }
.leaderboard-name { font-weight: 700; }
.leaderboard-title { font-size: 11px; color: var(--purple-glow); }
.leaderboard-cp { color: var(--orange); font-weight: 700; }
/* 舊 lb-tab（兼容保留） */
.leaderboard-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.lb-tab {
  padding: 7px 16px; border-radius: 99px; background: var(--bg-card);
  border: 1px solid var(--border); color: var(--text-secondary);
  font-size: 13px; transition: all 0.2s;
}
.lb-tab.active { background: var(--purple-glow); border-color: var(--purple-glow); color: #ffffff; }
.leaderboard-self { background: rgba(168,85,247,0.1) !important; }

/* ─── 新排行榜 UI ──────────────────────────────────────────── */
.lb-category-tabs {
  display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.lb-cat-btn {
  flex: 1; min-width: 100px; padding: 12px 10px;
  border-radius: 14px; border: 2px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all 0.2s; cursor: pointer;
}
.lb-cat-btn.active {
  border-color: var(--purple-glow);
  background: rgba(139,92,246,0.12);
  color: var(--text-primary);
  box-shadow: 0 0 16px rgba(139,92,246,0.25);
}
.lb-cat-icon  { font-size: 22px; }
.lb-cat-label { font-size: 12px; font-weight: 700; }

.lb-desc-bar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 8px; flex-wrap: wrap;
}
#lb-desc-text { font-size: 13px; color: var(--text-secondary); }
.lb-refresh-btn {
  padding: 6px 14px; border-radius: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 12px;
  transition: all 0.2s; cursor: pointer;
}
.lb-refresh-btn:hover { border-color: var(--purple-glow); color: var(--text-primary); }

/* Podium 前三名 */
.lb-podium {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 8px; margin-bottom: 18px; padding: 0 10px;
}
.lb-podium-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex: 1; max-width: 140px;
}
.lb-podium-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--bg-card); border: 3px solid;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
}
.lb-podium-name {
  font-size: 12px; font-weight: 700; color: var(--text-primary);
  text-align: center; max-width: 100px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lb-self-name { color: var(--purple-glow); }
.lb-podium-score { font-size: 13px; font-weight: 800; }
.lb-podium-block {
  width: 100%; border-radius: 8px 8px 0 0;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 8px; min-width: 80px;
}
.lb-podium-medal { font-size: 22px; }
.lb-podium-1 .lb-podium-block { background: #fbbf24; }
.lb-podium-2 .lb-podium-block { background: #94a3b8; }
.lb-podium-3 .lb-podium-block { background: #cd7c2f; }

/* 4~20 名行 */
.lb-list-panel { padding: 12px !important; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  transition: background 0.15s;
}
.lb-row:hover { background: var(--bg-hover); }
.lb-row-self  { background: rgba(139,92,246,0.1); border: 1px solid rgba(139,92,246,0.3); }
.lb-row-rank  { font-size: 15px; font-weight: 800; color: var(--text-secondary); min-width: 28px; }
.lb-row-avatar { font-size: 22px; }
.lb-row-info  { flex: 1; }
.lb-row-name  { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.lb-row-sub   { font-size: 11px; color: var(--text-secondary); }
.lb-you {
  display: inline-block; background: var(--purple-glow); color: #ffffff;
  font-size: 10px; padding: 1px 6px; border-radius: 99px; margin-left: 6px;
}
.lb-row-score { text-align: right; }
.lb-row-score-val   { font-size: 16px; font-weight: 800; color: var(--gold); }
.lb-row-score-label { font-size: 11px; color: var(--text-secondary); }

/* 我的排名條 */
.lb-my-rank-bar {
  margin-top: 10px; padding: 12px 18px;
  background: rgba(139,92,246,0.1);
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: 12px; text-align: center;
  font-size: 13px; color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════
   彈窗 / Modal
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow), var(--glow-purple);
  animation: modalIn 0.25s ease-out;
}
@keyframes modalIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  margin-left: auto;
  width: 28px; height: 28px;
  background: rgba(239,68,68,0.2);
  border: 1px solid var(--red-glow);
  border-radius: 50%;
  color: var(--red-glow);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--red-glow); color: #ffffff; }

/* ─── 勝利 / 死亡畫面 ────────────────────────────────────── */
.result-screen {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
}
.result-screen.victory { background: radial-gradient(ellipse at center, rgba(255,215,0,0.2) 0%, rgba(0,0,0,0.9) 70%); }
.result-screen.defeat  { background: radial-gradient(ellipse at center, rgba(239,68,68,0.2) 0%, rgba(0,0,0,0.95) 70%); }
.result-icon { font-size: 80px; margin-bottom: 16px; animation: resultBounce 0.6s ease-out; }
@keyframes resultBounce {
  0%   { transform: scale(0); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.result-title { font-size: 36px; font-weight: 900; margin-bottom: 8px; }
.result-screen.victory .result-title { color: var(--gold); text-shadow: var(--glow-gold); }
.result-screen.defeat  .result-title { color: var(--red-glow); }
.result-rewards { background: rgba(255,255,255,0.8); border-radius: var(--radius); padding: 16px 24px; margin: 16px 0; width: 100%; max-width: 340px; }
.result-reward-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 15px; }
.result-drops { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 8px 0; }
.result-drop-item { font-size: 24px; background: var(--bg-card); border-radius: var(--radius-sm); padding: 4px 8px; }
.result-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ─── 成就彈出通知 ────────────────────────────────────────── */
.achievement-toast {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: var(--bg-panel);
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 9000;
  max-width: 320px;
  box-shadow: var(--shadow), var(--glow-gold);
  transform: translateX(400px);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.achievement-toast.show { transform: translateX(0); }
.ach-toast-icon { font-size: 32px; }
.ach-toast-title { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 1px; }
.ach-toast-name  { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.ach-toast-desc  { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ─── 等級提升特效 ───────────────────────────────────────── */
.level-up-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 9000;
  text-align: center;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.5);
}
.level-up-banner.show { transform: translate(-50%, -50%) scale(1); }
.level-up-text { font-size: 48px; font-weight: 900; color: var(--gold); text-shadow: 0 0 30px rgba(255,215,0,0.8), 0 0 60px rgba(255,215,0,0.4); letter-spacing: 4px; }
.level-up-sub  { font-size: 18px; color: var(--text-primary); margin-top: 4px; }

/* ─── Toast 通知 ─────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  max-width: 280px;
  animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
}
.toast.success { background: rgba(34,197,94,0.9);  color: #ffffff; }
.toast.error   { background: rgba(239,68,68,0.9);   color: #ffffff; }
.toast.info    { background: rgba(59,130,246,0.9);  color: #ffffff; }
.toast.gold    { background: rgba(255,215,0,0.9);   color: #1a1a00; }
@keyframes toastIn  { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(120%); } }

/* ─── 物品詳情 Tooltip ───────────────────────────────────── */
.item-tooltip {
  position: absolute;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 200px;
  max-width: 280px;
  z-index: 9999;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.item-tooltip-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.item-tooltip-rarity { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.item-tooltip-stat { font-size: 12px; color: var(--green-glow); margin-bottom: 2px; }
.item-tooltip-socket {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-dark);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  margin-top: 4px;
  font-size: 12px;
}
.socket-circle { width: 14px; height: 14px; border-radius: 50%; border: 1px solid; flex-shrink: 0; }
.socket-empty  { border-color: var(--text-dim); }
.socket-filled { background: var(--gold); border-color: var(--gold); }

/* ─── 響應式 ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .hud { padding: 6px 10px; gap: 8px; }
  .hud-nav-btn span { display: none; }
  .options-grid { grid-template-columns: 1fr; }
  .monster-icon-wrap { font-size: 72px; }
  .dungeon-grid { grid-template-columns: 1fr; }
  .achievement-grid { grid-template-columns: 1fr; }
  .main-content { padding: 12px 10px; }
}

/* ═══════════════════════════════════════════════════════════
   Kenney 角色 Sprite 系統
   ═══════════════════════════════════════════════════════════ */

/* 職業選擇卡 sprite 預覽 */
.class-card .class-sprite {
  width: 96px;
  height: 96px;
  object-fit: contain;
  display: block;
  margin: 0 auto 6px;
  transition: transform 0.3s ease;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}
.class-card:hover .class-sprite { transform: scale(1.12) translateY(-4px); }
.class-card.selected .class-sprite { transform: scale(1.15) translateY(-6px); filter: drop-shadow(0 6px 14px rgba(255,215,0,0.6)); }

/* HUD 角色小頭像 sprite */
.hud-avatar-sprite {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

/* 角色詳情頁大肖像 sprite */
.char-portrait-sprite {
  width: 128px;
  height: 128px;
  object-fit: contain;
  image-rendering: pixelated;
  display: block;
  margin: 0 auto 10px;
  filter: drop-shadow(0 6px 18px rgba(139,92,246,0.5));
  transition: transform 0.2s;
}
.char-portrait-sprite:hover { transform: scale(1.06) translateY(-4px); }

/* 戰鬥畫面：玩家角色 sprite */
.battle-player-sprite-wrap {
  position: relative;
  width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.battle-player-sprite {
  width: 88px;
  height: 88px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 12px rgba(168,85,247,0.4));
  transition: transform 0.15s;
}
.battle-player-sprite.attacking {
  animation: playerAttack 0.5s ease-out;
}
.battle-player-sprite.hurting {
  animation: playerHurt 0.4s ease;
}
.battle-player-sprite.cheering {
  animation: playerCheer 0.6s ease;
}
@keyframes playerAttack {
  0%   { transform: translateX(0) rotate(0); }
  25%  { transform: translateX(30px) rotate(-8deg) scale(1.15); }
  60%  { transform: translateX(5px) rotate(-3deg); }
  100% { transform: translateX(0) rotate(0); }
}
@keyframes playerHurt {
  0%,100% { transform: translateX(0); filter: drop-shadow(0 4px 12px rgba(168,85,247,0.4)); }
  30%     { transform: translateX(-12px); filter: drop-shadow(0 0 12px rgba(239,68,68,0.9)) brightness(1.5); }
  60%     { transform: translateX(6px); }
}
@keyframes playerCheer {
  0%   { transform: translateY(0) scale(1); }
  40%  { transform: translateY(-12px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

/* 戰鬥畫面：怪獸 sprite */
.monster-sprite {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(239,68,68,0.5));
  transition: all 0.15s;
}
.monster-sprite.shake {
  animation: monsterShake 0.4s ease;
}
.monster-sprite.attacking {
  animation: monsterAttackSprite 0.4s ease;
}
@keyframes monsterAttackSprite {
  0%   { transform: translateX(0); }
  30%  { transform: translateX(-50px) scale(1.1); }
  100% { transform: translateX(0); }
}

/* 角色頁面大頭像 sprite */
.char-portrait-sprite {
  width: 120px;
  height: 120px;
  object-fit: contain;
  display: block;
  margin: 0 auto 10px;
  filter: drop-shadow(0 6px 16px rgba(168,85,247,0.4));
  transition: transform 0.3s;
}
.char-portrait-sprite:hover { transform: scale(1.05) translateY(-4px); }

/* ─── 載入動畫 ───────────────────────────────────────────── */
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--purple-glow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── 選擇稱號 modal ─────────────────────────────────────── */
.title-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.title-chip {
  padding: 6px 14px;
  border-radius: 99px;
  border: 1px solid var(--border-glow);
  color: var(--text-secondary);
  background: var(--bg-dark);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.title-chip:hover { border-color: var(--gold); color: var(--gold); }
.title-chip.active { background: rgba(255,215,0,0.15); border-color: var(--gold); color: var(--gold); }

/* ─── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; display: block; opacity: 0.5; }
.empty-state p { font-size: 14px; }

/* ─── 鑲嵌 Modal ───────────────────────────────────────── */
.forge-modal-box { min-width: 340px; max-width: 520px; width: 92vw; }

/* 單字列表 */
.forge-word-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 6px;
  transition: all 0.2s;
}
.forge-word-row.craftable {
  border-color: var(--gold);
  background: rgba(255,215,0,0.07);
}
.forge-word-row.uncraftable {
  opacity: 0.5;
  filter: grayscale(0.4);
}
.forge-word-main { flex: 1; min-width: 0; }
.forge-word-text  { font-size: 16px; font-weight: 700; letter-spacing: 1px; text-transform: lowercase; color: var(--text-primary); }
.forge-word-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.forge-letter-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 900;
  border: 1px solid;
}
.forge-letter-chip.ok      { color: var(--green-glow); border-color: var(--green-glow); background: rgba(74,222,128,0.1); }
.forge-letter-chip.missing { color: var(--text-dim);   border-color: var(--border);     background: rgba(255,255,255,0.03); }
.forge-word-bonus {
  font-size: 12px;
  white-space: nowrap;
  color: var(--xp-bar);
  text-align: center;
  min-width: 64px;
}
.forge-word-row.craftable .forge-word-bonus { color: var(--gold); font-weight: 700; }
.forge-socket-btn { white-space: nowrap; }

/* ─── 裝備槽位物品選擇器 ────────────────────────────────── */
.picker-item-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.picker-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.picker-item-row:hover { border-color: var(--purple-glow); background: var(--bg-hover); }
.picker-item-row.white  { border-left: 3px solid var(--rarity-white); }
.picker-item-row.green  { border-left: 3px solid var(--rarity-green); }
.picker-item-row.blue   { border-left: 3px solid var(--rarity-blue); }
.picker-item-row.purple { border-left: 3px solid var(--rarity-purple); }
.picker-item-row.gold   { border-left: 3px solid var(--rarity-gold); }
.picker-item-icon { font-size: 28px; flex-shrink: 0; }
.picker-item-info { flex: 1; }
.picker-item-name { font-size: 14px; font-weight: 700; }
.picker-item-stats { font-size: 11px; color: var(--green-glow); margin-top: 2px; }

/* ─── 句子重組題樣式 ────────────────────────────────────── */
.scramble-chip {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(168,85,247,0.18);
  border: 1px solid var(--border-glow);
  border-radius: 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  margin: 3px 2px;
}
.option-sentence {
  font-size: 13px;
  text-align: left;
  padding: 10px 14px;
  height: auto;
  min-height: 48px;
  white-space: normal;
  line-height: 1.4;
}

/* ─── 屬性點橫幅動畫（用 border-color 閃爍取代 opacity，避免 GPU layer 蓋掉下方元素）*/
@keyframes banner-glow {
  0%,100% { border-color: var(--purple-glow); box-shadow: 0 0 8px rgba(168,85,247,0.3); }
  50%      { border-color: var(--gold);        box-shadow: 0 0 16px rgba(255,215,0,0.4); }
}
.attr-points-banner.show { animation: banner-glow 2s infinite; }

/* ═══ 賣出模式 (Sell Mode) ══════════════════════════════════════ */
.sell-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.sell-mode-cell {
  position: relative;
  cursor: pointer !important;
  user-select: none;
}
.sell-mode-cell:hover { opacity: 0.85; transform: scale(1.04); }
.sell-mode-cell.sell-selected {
  border: 2px solid #ef4444 !important;
  box-shadow: 0 0 8px rgba(239,68,68,0.5);
  background: rgba(239,68,68,0.12) !important;
}
.sell-check {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  background: rgba(0,0,0,0.2);
  border: 1.5px solid rgba(0,0,0,0.3);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: #1e293b;
  line-height: 1;
}
.sell-mode-cell.sell-selected .sell-check {
  background: #ef4444;
  border-color: #ef4444;
}
.sell-price-tag {
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 9px;
  font-weight: 700;
  color: var(--gold);
  background: rgba(217,119,6,0.15);
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 1.4;
}
.sell-batch-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.sell-batch-btn {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0,0,0,0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s;
}
.sell-batch-btn:hover { background: rgba(0,0,0,0.08); border-color: var(--border-glow); }
.sell-batch-clear { color: var(--text-dim) !important; }
.sell-total { font-size: 13px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.sell-price-legend { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; font-weight: 700; }

/* ═══ 熔爐視圖 (Furnace / Forge) ═══════════════════════════════ */
/* 等級內嵌標籤 (tier-inline) */
.tier-inline {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  margin: 0 2px;
  border: 1.5px solid currentColor;
}
.tier-inline.tier-0 { color: #9ca3af; border-color: #9ca3af; }
.tier-inline.tier-1 { color: #22c55e; border-color: #22c55e; }
.tier-inline.tier-2 { color: #3b82f6; border-color: #3b82f6; }
.tier-inline.tier-3 { color: #a855f7; border-color: #a855f7; }
.tier-inline.tier-4 { color: #fbbf24; border-color: #fbbf24; }

/* 字母卡片格子 */
.forge-alphabet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 8px;
}

/* ── New letter tile design ── */
.forge-letter-tile {
  background: rgba(240,244,248,0.8);
  border: 2px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: default;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  position: relative;
  overflow: hidden;
}
.forge-letter-tile.has-letter {
  border-color: var(--tile-color, #6366f1);
  box-shadow: 0 0 8px var(--tile-glow, transparent),
              inset 0 0 20px var(--tile-glow, transparent)1a;
}
.forge-letter-tile.has-letter:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--tile-glow, #6366f1)60;
}
.forge-letter-tile.empty-letter {
  opacity: 0.28;
}

.forge-letter-char {
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  transition: color 0.2s;
}

.forge-letter-tiers {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  align-items: center;
}
.forge-tier-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

/* 等級 chip (tier-chip) */
.forge-tier-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1.5px solid;
  border-radius: 99px;
  font-size: 11px;
  line-height: 1.3;
}
.forge-tier-chip .tier-label { font-weight: 800; font-size: 10px; }
.forge-tier-chip .tier-count { font-weight: 700; font-size: 12px; color: var(--text-primary); }
.tier-combine-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  font-size: 13px;
  line-height: 1;
  opacity: 0.85;
  transition: all 0.15s;
}
.tier-combine-btn:hover { opacity: 1; transform: scale(1.3); }

/* 熔爐 Modal 單字列表中的等級選項 */
.forge-word-tier-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.forge-tier-socket-btn {
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  border: 1.5px solid;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  background: transparent;
}
.forge-tier-socket-btn:hover { filter: brightness(1.3); }
.forge-tier-socket-btn:disabled { opacity: 0.3; cursor: default; }
.forge-tier-socket-btn.tier-0 { color: #9ca3af; border-color: #9ca3af; }
.forge-tier-socket-btn.tier-1 { color: #22c55e; border-color: #22c55e; }
.forge-tier-socket-btn.tier-2 { color: #3b82f6; border-color: #3b82f6; }
.forge-tier-socket-btn.tier-3 { color: #a855f7; border-color: #a855f7; }
.forge-tier-socket-btn.tier-4 { color: #fbbf24; border-color: #fbbf24; }

/* 字母庫預覽（熔爐 Modal 中） */
.forge-letter-preview-chip {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 34px;
  gap: 2px;
}
.forge-letter-preview-char {
  font-size: 14px;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
}
.forge-letter-preview-tiers {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
}
.forge-letter-preview-tier-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* 裝備孔洞等級顏色 */
.socket-circle.st-0 { border-color: #9ca3af; }
.socket-circle.st-1 { border-color: #22c55e; box-shadow: 0 0 4px rgba(34,197,94,0.5); }
.socket-circle.st-2 { border-color: #3b82f6; box-shadow: 0 0 5px rgba(59,130,246,0.5); }
.socket-circle.st-3 { border-color: #a855f7; box-shadow: 0 0 6px rgba(168,85,247,0.6); }
.socket-circle.st-4 { border-color: #fbbf24; box-shadow: 0 0 8px rgba(251,191,36,0.7); }

/* ═══════════════════════════════════════════════════════
   PvP 競技場 Styles
   ═══════════════════════════════════════════════════════ */

/* ── Arena view layout ── */
#view-pvp-arena.active {
  display: flex !important;
  flex-direction: column;
  min-height: 70vh;
  padding: 0;
  background: var(--bg-panel);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ── HUD top bar ── */
.pvp-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 8px;
  background: #1e293b;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.pvp-player-hud {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.pvp-player-hud.me { align-items: flex-start; }
.pvp-player-hud.opp { align-items: flex-end; }
.pvp-player-name {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}
.pvp-hp-row {
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}
.pvp-player-hud.opp .pvp-hp-row { flex-direction: row-reverse; }
.pvp-hp-bar-bg {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  overflow: hidden;
}
.pvp-hp-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.pvp-player-hud.me .pvp-hp-bar-fill { background: linear-gradient(90deg, #22c55e, #4ade80); }
.pvp-player-hud.opp .pvp-hp-bar-fill { background: linear-gradient(90deg, #ef4444, #f87171); }
.pvp-hp-text {
  font-size: 11px;
  font-weight: 700;
  color: #cbd5e1;
  min-width: 36px;
  text-align: center;
}
.pvp-combo-badge {
  font-size: 11px;
  font-weight: 800;
  color: #fbbf24;
  min-width: 20px;
}
.pvp-player-hud.me .pvp-combo-badge { text-align: left; }
.pvp-player-hud.opp .pvp-combo-badge { text-align: right; }

/* ── VS center ── */
.pvp-vs-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 0 6px;
}
.pvp-vs-label {
  font-size: 16px;
  font-weight: 900;
  color: #f59e0b;
  text-shadow: 0 0 10px rgba(245,158,11,0.6);
  line-height: 1;
}
.pvp-round-label {
  font-size: 10px;
  color: #64748b;
}

/* ── Timer ── */
.pvp-timer-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 12px;
  flex-shrink: 0;
}
.pvp-timer-bar-bg {
  width: 100%;
  max-width: 340px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  position: relative;
}
.pvp-timer-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  transition: width 0.2s linear, background 0.5s;
}
.pvp-timer-bar-fill.danger { background: linear-gradient(90deg, #ef4444, #f87171); }
.pvp-timer-text {
  position: absolute;
  right: 0;
  top: -18px;
  font-size: 11px;
  font-weight: 800;
  color: #fbbf24;
}
.pvp-timer-text.danger { color: #ef4444; }

/* ── Progress dots ── */
.pvp-progress-row {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 2px 12px 4px;
  flex-shrink: 0;
}
.pvp-prog-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  transition: background 0.2s;
}
.pvp-prog-dot.correct { background: #22c55e; }
.pvp-prog-dot.wrong   { background: #ef4444; }
.pvp-prog-dot.current { background: #fbbf24; box-shadow: 0 0 5px rgba(251,191,36,0.7); }

/* ── Question area ── */
.pvp-question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 14px 10px;
  gap: 10px;
  overflow: hidden;
}
.pvp-q-type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(139,92,246,0.25);
  color: #c4b5fd;
  border: 1px solid rgba(139,92,246,0.4);
}
.pvp-q-word {
  font-size: 22px;
  font-weight: 900;
  color: #f1f5f9;
  text-align: center;
  letter-spacing: 1px;
}
.pvp-q-meaning {
  font-size: 14px;
  color: #fbbf24;
  font-weight: 700;
  text-align: center;
}
.pvp-listen-icon {
  font-size: 40px;
  cursor: pointer;
  animation: pvpPulse 1.5s ease-in-out infinite;
  line-height: 1;
}
@keyframes pvpPulse {
  0%,100% { transform: scale(1); filter: drop-shadow(0 0 4px rgba(251,191,36,0.5)); }
  50%      { transform: scale(1.1); filter: drop-shadow(0 0 10px rgba(251,191,36,0.9)); }
}
.pvp-prompt {
  font-size: 13px;
  color: #94a3b8;
  text-align: center;
}
.pvp-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  max-width: 340px;
}
.pvp-option-btn {
  background: rgba(30,27,75,0.7);
  border: 2px solid rgba(139,92,246,0.3);
  border-radius: 10px;
  color: #e2e8f0;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.pvp-option-btn:active { transform: scale(0.96); }
.pvp-option-btn:hover  { background: rgba(139,92,246,0.2); border-color: rgba(139,92,246,0.6); }
.pvp-option-btn.correct-flash {
  background: rgba(34,197,94,0.25) !important;
  border-color: #22c55e !important;
  color: #4ade80 !important;
}
.pvp-option-btn.wrong-flash {
  background: rgba(239,68,68,0.25) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
}
.pvp-spell-input {
  background: rgba(255,255,255,0.95);
  border: 2px solid rgba(139,92,246,0.4);
  border-radius: 10px;
  color: #1e293b;
  font-size: 18px;
  font-weight: 700;
  padding: 12px 16px;
  text-align: center;
  width: 100%;
  max-width: 300px;
  outline: none;
  letter-spacing: 2px;
}
.pvp-spell-input:focus { border-color: #8b5cf6; }
.pvp-spell-submit {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  padding: 11px 32px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.pvp-spell-submit:active { opacity: 0.8; }

/* ── Flash feedback overlay ── */
.pvp-answer-flash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 900;
  pointer-events: none;
  z-index: 200;
  animation: pvpFlashFade 0.5s ease forwards;
}
@keyframes pvpFlashFade {
  0%   { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(0.8); }
}

/* ── Connection status dot ── */
.pvp-conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 3px;
}
.pvp-conn-dot.online  { background: #22c55e; }
.pvp-conn-dot.offline { background: #ef4444; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── Round result overlay ── */
.pvp-round-result-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  animation: fadeIn 0.25s ease;
}
.pvp-round-result-box {
  background: var(--bg-panel);
  border: 2px solid rgba(124,58,237,0.5);
  border-radius: 18px;
  padding: 24px 28px;
  text-align: center;
  max-width: 300px;
  width: 90%;
  box-shadow: 0 0 40px rgba(139,92,246,0.3);
}
.pvp-round-result-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--purple-glow);
  margin-bottom: 12px;
}
.pvp-round-dmg-row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 8px;
}
.pvp-round-dmg-card {
  text-align: center;
}
.pvp-round-dmg-num {
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
}
.pvp-round-dmg-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.pvp-round-next-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 10px;
}

/* ── PvP Battle Animation Overlay ── */
.pvp-battle-anim-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 320;
  animation: fadeIn 0.3s ease;
}
.pvp-battle-anim-box {
  background: var(--bg-panel);
  border: 2px solid rgba(139,92,246,0.5);
  border-radius: 20px;
  padding: 18px 14px 14px;
  width: min(96vw, 440px);
  box-shadow: 0 0 48px rgba(139,92,246,0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pvp-battle-anim-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--purple-glow);
  text-align: center;
  letter-spacing: 1px;
}
.pvp-battle-anim-arena {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.pvp-anim-fighter {
  flex: 0 0 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pvp-anim-fighter-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100px;
}
.pvp-anim-you-tag {
  font-size: 9px;
  background: var(--purple-glow);
  color: #fff;
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.pvp-anim-hp-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pvp-anim-hp-track {
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  width: 100%;
}
.pvp-anim-hp-fill {
  height: 100%;
  border-radius: 4px;
  background: #22c55e;
  transition: width 0.6s ease, background 0.6s ease;
}
.pvp-anim-hp-text {
  font-size: 10px;
  color: var(--text-secondary);
  text-align: center;
}
.pvp-anim-char {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease;
}
.pvp-anim-char-side {
  transform: scaleX(-1);
}
.pvp-anim-char-img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
}
@keyframes pvpHitShake {
  0%   { transform: translateX(0) scaleX(var(--flip,1)); }
  20%  { transform: translateX(-6px) scaleX(var(--flip,1)); }
  40%  { transform: translateX(6px) scaleX(var(--flip,1)); }
  60%  { transform: translateX(-4px) scaleX(var(--flip,1)); }
  80%  { transform: translateX(4px) scaleX(var(--flip,1)); }
  100% { transform: translateX(0) scaleX(var(--flip,1)); }
}
.pvp-anim-hit {
  animation: pvpHitShake 0.45s ease;
  filter: brightness(1.8) saturate(0.2);
}
.pvp-anim-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.pvp-anim-vs {
  font-size: 20px;
  font-weight: 900;
  color: var(--text-secondary);
}
.pvp-anim-log {
  width: 100%;
  max-height: 130px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pvp-anim-log-row {
  font-size: 11px;
  line-height: 1.4;
  padding: 3px 6px;
  border-radius: 6px;
  animation: fadeIn 0.2s ease;
}
.pvp-log-my     { background: rgba(34,197,94,0.12);  color: #86efac; }
.pvp-log-opp    { background: rgba(239,68,68,0.12);  color: #fca5a5; }
.pvp-log-miss   { background: rgba(100,116,139,0.1); color: #94a3b8; }
.pvp-log-result { background: rgba(245,158,11,0.15); color: #fde68a; font-weight: 700; }
.pvp-dmg-num    { color: #f87171; font-weight: 900; }
.pvp-log-crit   { color: #fbbf24; font-weight: 900; font-size: 12px; }
.pvp-battle-anim-next {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.pvp-anim-next-show { opacity: 1 !important; }

/* ── 屬性說明 ? 按鈕 ── */
.stat-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
  transition: background 0.15s;
  padding: 0;
}
.stat-help-btn:hover { background: rgba(139,92,246,0.35); color: #fff; }

/* ── 屬性說明彈窗 ── */
.stat-help-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 400;
  animation: fadeIn 0.2s ease;
}
.stat-help-modal.hidden { display: none; }
.stat-help-box {
  background: var(--bg-panel);
  border: 2px solid rgba(139,92,246,0.4);
  border-radius: 16px;
  padding: 20px;
  width: min(90vw, 320px);
  box-shadow: 0 0 40px rgba(139,92,246,0.25);
}
.stat-help-header {
  font-size: 18px;
  font-weight: 900;
  margin-bottom: 12px;
}
.stat-help-list {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.stat-help-list li {
  font-size: 13px;
  color: var(--text-primary);
  padding-left: 18px;
  position: relative;
  line-height: 1.5;
}
.stat-help-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--purple-glow);
}
.stat-help-tip {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 6px;
}

/* 回合時間到提示 */
.pvp-time-up-tag {
  margin-top: 14px;
  padding: 8px 18px;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 20px;
  color: #fca5a5;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  animation: fadeIn 0.3s ease;
}

/* ── PvP Result view ── */
#view-pvp-result.active {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px 20px;
  background: var(--bg-panel);
  gap: 16px;
}
.pvp-result-banner {
  font-size: 52px;
  line-height: 1;
}
.pvp-result-title {
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}
.pvp-result-title.win  { color: #d97706; text-shadow: 0 0 12px rgba(217,119,6,0.3); }
.pvp-result-title.lose { color: #475569; }
.pvp-result-title.draw { color: #7c3aed; }
.pvp-result-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  text-align: center;
}
.pvp-result-hp-row {
  display: flex;
  gap: 24px;
  align-items: center;
}
.pvp-result-hp-card {
  text-align: center;
}
.pvp-result-hp-num {
  font-size: 22px;
  font-weight: 900;
  color: var(--text-primary);
}
.pvp-result-hp-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Loot modal ── */
.pvp-loot-modal-box {
  background: var(--bg-panel);
  border: 2px solid rgba(217,119,6,0.4);
  border-radius: 18px;
  padding: 20px;
  max-width: 340px;
  width: 95%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(251,191,36,0.2);
}
.pvp-loot-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold);
  text-align: center;
  margin-bottom: 4px;
}
.pvp-loot-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 14px;
}
.pvp-loot-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.pvp-gold-slider-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.pvp-gold-slider {
  width: 100%;
  accent-color: #f59e0b;
}
.pvp-gold-display {
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  color: #fbbf24;
}
.pvp-loot-item-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.pvp-loot-item-card {
  border: 2px solid rgba(139,92,246,0.3);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  background: rgba(30,27,75,0.5);
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.pvp-loot-item-card:hover { border-color: rgba(139,92,246,0.7); background: rgba(139,92,246,0.15); }
.pvp-loot-item-card.selected { border-color: #fbbf24; background: rgba(251,191,36,0.15); color: #fbbf24; }
.pvp-loot-letter-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.pvp-loot-letter-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid rgba(139,92,246,0.3);
  background: rgba(30,27,75,0.5);
  color: #e2e8f0;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}
.pvp-loot-letter-btn:hover { border-color: rgba(139,92,246,0.7); background: rgba(139,92,246,0.15); }
.pvp-loot-letter-btn.selected { border-color: #fbbf24; background: rgba(251,191,36,0.15); color: #fbbf24; }
.pvp-loot-confirm-btn {
  width: 100%;
  background: linear-gradient(135deg, #d97706, #f59e0b);
  border: none;
  border-radius: 12px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
  padding: 13px;
  cursor: pointer;
  letter-spacing: 0.5px;
}
.pvp-loot-confirm-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Incoming challenge modal ── */
.pvp-incoming-box {
  background: var(--bg-panel);
  border: 2px solid rgba(220,38,38,0.5);
  border-radius: 18px;
  padding: 24px 20px;
  max-width: 300px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 40px rgba(239,68,68,0.25);
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  60%      { transform: translateX(6px); }
}
.pvp-incoming-title {
  font-size: 15px;
  font-weight: 900;
  color: var(--red-glow);
  margin-bottom: 6px;
}
.pvp-incoming-name {
  font-size: 20px;
  font-weight: 900;
  color: var(--red-glow);
  margin-bottom: 4px;
}
.pvp-incoming-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}
.pvp-incoming-btns {
  display: flex;
  gap: 10px;
}
.pvp-accept-btn {
  flex: 1;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  padding: 11px;
  cursor: pointer;
}
.pvp-decline-btn {
  flex: 1;
  background: rgba(239,68,68,0.2);
  border: 1px solid rgba(239,68,68,0.4);
  border-radius: 10px;
  color: #f87171;
  font-size: 14px;
  font-weight: 800;
  padding: 11px;
  cursor: pointer;
}

/* ── Waiting / challenge modals ── */
.pvp-waiting-box {
  background: var(--bg-panel);
  border: 2px solid rgba(124,58,237,0.4);
  border-radius: 18px;
  padding: 28px 24px;
  max-width: 300px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 40px rgba(139,92,246,0.2);
}
.pvp-waiting-title {
  font-size: 15px;
  font-weight: 900;
  color: var(--purple-glow);
  margin-bottom: 8px;
}
.pvp-waiting-spinner {
  font-size: 36px;
  animation: spin 2s linear infinite;
  display: block;
  margin: 8px auto;
}
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.pvp-waiting-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 8px 0 4px;
}
.pvp-waiting-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.pvp-cancel-btn {
  background: rgba(220,38,38,0.1);
  border: 1px solid rgba(220,38,38,0.35);
  border-radius: 10px;
  color: var(--red-glow);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 20px;
  cursor: pointer;
  width: 100%;
}

/* ── Challenge input modal ── */
.pvp-challenge-box {
  background: var(--bg-panel);
  border: 2px solid rgba(124,58,237,0.4);
  border-radius: 18px;
  padding: 24px 20px;
  max-width: 300px;
  width: 90%;
  text-align: center;
  box-shadow: 0 0 40px rgba(139,92,246,0.25);
}
.pvp-challenge-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--purple-glow);
  margin-bottom: 6px;
}
.pvp-challenge-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}
.pvp-challenge-input {
  width: 100%;
  background: rgba(255,255,255,0.95);
  border: 2px solid rgba(139,92,246,0.4);
  border-radius: 10px;
  color: #1e293b;
  font-size: 15px;
  font-weight: 700;
  padding: 11px 14px;
  text-align: center;
  outline: none;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.pvp-challenge-input:focus { border-color: #8b5cf6; }
.pvp-challenge-btn {
  width: 100%;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  border: none;
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  padding: 12px;
  cursor: pointer;
  margin-bottom: 6px;
}
.pvp-challenge-err {
  font-size: 12px;
  color: #f87171;
  min-height: 18px;
  margin-top: 4px;
}

/* ── Loot notification toast ── */
.pvp-loot-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 2px solid rgba(220,38,38,0.4);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 700;
  color: #dc2626;
  text-align: center;
  z-index: 500;
  max-width: 280px;
  width: 90%;
  animation: slideUp 0.3s ease, fadeOut 0.4s ease 3.6s forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes fadeOut {
  from { opacity: 1; }
  to   { opacity: 0; pointer-events: none; }
}

/* ── Nav badge for pvp ── */
.nav-item .pvp-invite-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 1px solid #ffffff;
  animation: blink 1s step-end infinite;
}

/* ═══════════════════════════════════════════════════════════
   探秘系統（Exploration）
   ═══════════════════════════════════════════════════════════ */

/* ── 關卡大廳卡片 ─────────────────────────────────────────── */
#expl-lobby > #expl-lobby {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.expl-stage-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  min-height: 110px;
  background: var(--bg-card) var(--stage-bg) center/cover no-repeat;
  border: 2px solid rgba(255,255,255,0.1);
  transition: transform 0.15s, box-shadow 0.15s;
}
.expl-stage-card:hover:not(.locked) {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.expl-stage-card.locked { cursor: not-allowed; filter: brightness(0.5); }
.expl-stage-card.cleared { border-color: rgba(230,168,23,0.5); }

.expl-stage-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.3) 100%);
}
.expl-stage-body {
  position: relative;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.expl-stage-icon  { font-size: 28px; line-height: 1; }
.expl-stage-name  { font-size: 15px; font-weight: 800; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,0.8); }
.expl-stage-sub   { font-size: 11px; color: rgba(255,255,255,0.7); }
.expl-stage-best  { font-size: 11px; color: var(--gold); margin-top: 2px; }
.expl-stage-lock-tip { font-size: 10px; color: rgba(255,255,255,0.45); margin-top: 2px; }
.expl-start-btn   { margin-top: 8px; align-self: flex-start; font-size: 12px; padding: 6px 16px; }

/* ── 答題競技場 ───────────────────────────────────────────── */
.expl-arena {
  position: relative;
  width: 100%;
  min-height: 100%;
  background-size: cover;
  background-position: center top;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 14px 16px;
}
.expl-arena-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.25) 40%, rgba(0,0,0,0.65) 100%);
  pointer-events: none;
}
.expl-top-bar {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.expl-stage-title-bar {
  font-size: 14px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(0,0,0,0.8);
  text-align: center;
}
.expl-progress-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}
.expl-progress-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}
.expl-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.expl-progress-text { font-size: 11px; color: rgba(255,255,255,0.8); white-space: nowrap; }
.expl-acc-live      { font-size: 11px; color: #86efac; text-align: center; min-height: 14px; }

/* ── 題目框 ──────────────────────────────────────────────── */
.expl-question-box {
  position: relative;
  width: 100%;
  background: rgba(15, 15, 30, 0.88);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease;
}
.expl-tts-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.expl-tts-btn:hover { background: rgba(139,92,246,0.4); }

.expl-prompt        { font-size: 15px; color: #fff; line-height: 1.6; padding-right: 48px; }
.expl-prompt-line   { padding: 1px 0; }
.expl-prompt-line:first-child { color: rgba(255,255,255,0.7); font-size: 13px; }
.expl-prompt-line:last-child  { font-size: 16px; font-weight: 700; }

.expl-opts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.expl-opt-btn {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
  color: #fff;
  font-size: 13px;
}
.expl-opt-btn:hover:not(:disabled) {
  background: rgba(139,92,246,0.25);
  border-color: rgba(139,92,246,0.5);
  transform: scale(1.02);
}
.expl-opt-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.expl-opt-btn.correct-flash  { background: rgba(34,197,94,0.3);  border-color: #22c55e; }
.expl-opt-btn.wrong-flash    { background: rgba(239,68,68,0.3);   border-color: #ef4444; animation: shake 0.4s ease; }
.expl-eliminated             { opacity: 0.2 !important; pointer-events: none; transform: scale(0.95); }

.expl-flee-btn {
  position: relative;
  margin-top: auto;
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 6px 18px;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  cursor: pointer;
}
.expl-flee-btn:hover { color: #fff; border-color: rgba(255,255,255,0.5); }

/* ── 地球儀 ─────────────────────────────────────────────── */
.expl-globe-wrap {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  min-height: 100px;
  pointer-events: none;
}
.expl-globe-img {
  width: 140px;
  height: auto;
  filter: drop-shadow(0 0 18px rgba(100,180,255,0.7));
  animation: globeFloat 3s ease-in-out infinite, globeGlow 2s ease-in-out infinite alternate;
  transition: filter 0.2s;
}
@keyframes globeFloat {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-10px); }
}
@keyframes globeGlow {
  0%   { filter: drop-shadow(0 0 12px rgba(100,180,255,0.5)); }
  100% { filter: drop-shadow(0 0 28px rgba(140,210,255,0.95)); }
}
/* 答對：閃光 + 震動 */
.expl-globe-img.globe-hit {
  animation: globeHit 0.55s ease forwards;
  filter: drop-shadow(0 0 36px rgba(255,220,80,0.95)) brightness(1.6);
}
@keyframes globeHit {
  0%   { transform: translateY(0)   scale(1.0); filter: brightness(1.0); }
  15%  { transform: translateY(-6px) scale(1.12); filter: brightness(1.8) drop-shadow(0 0 40px #ffe066); }
  35%  { transform: translateY(4px)  scale(0.96); }
  55%  { transform: translateY(-3px) scale(1.06); }
  80%  { transform: translateY(2px)  scale(0.99); }
  100% { transform: translateY(0)   scale(1.0);  filter: brightness(1.0); }
}
/* 過關：裂開放大 */
.expl-globe-img.globe-open-anim {
  animation: globeCrack 1.2s ease forwards !important;
}
@keyframes globeCrack {
  0%   { transform: scale(1.0);  filter: drop-shadow(0 0 18px rgba(100,180,255,0.7)); }
  30%  { transform: scale(1.15); filter: drop-shadow(0 0 50px rgba(255,220,80,1)) brightness(1.6); }
  60%  { transform: scale(0.9);  filter: drop-shadow(0 0 20px rgba(255,100,100,0.8)); }
  80%  { transform: scale(1.25); filter: drop-shadow(0 0 60px rgba(255,180,80,1)) brightness(1.8); }
  100% { transform: scale(1.1);  filter: drop-shadow(0 0 30px rgba(255,200,100,0.9)); }
}

/* ── 通用全螢幕 overlay（fixed，覆蓋 HUD）────────────────── */
.expl-overlay-screen {
  position: fixed;
  inset: 0;
  background: rgba(10,8,20,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  overflow-y: auto;
  padding: 16px;
  animation: fadeIn 0.35s ease;
}

/* ── 統計結算頁 ──────────────────────────────────────────── */
.expl-stats-box {
  background: var(--bg-panel);
  border: 2px solid rgba(139,92,246,0.45);
  border-radius: 28px;
  padding: 32px 28px 28px;
  width: min(92vw, 380px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  box-shadow: 0 0 80px rgba(139,92,246,0.35);
}
.expl-stats-title { font-size: 22px; font-weight: 900; color: var(--gold); }

/* SVG 環形進度 */
.expl-stats-ring {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 4px 0;
}
.expl-ring-svg {
  width: 150px;
  height: 150px;
  transform: rotate(-90deg);
}
.expl-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 10;
}
.expl-ring-fill {
  fill: none;
  stroke: #a78bfa;
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 1.4s cubic-bezier(.4,0,.2,1), stroke 0.6s;
}
.expl-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.expl-ring-acc { font-size: 36px; font-weight: 900; color: #fff; line-height: 1; }
.expl-ring-sub { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

.expl-stats-row   { font-size: 15px; color: var(--text-secondary); }
.expl-stats-bar-wrap {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
}
.expl-stats-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #a78bfa);
  border-radius: 4px;
  transition: width 1.4s cubic-bezier(.4,0,.2,1);
}
.expl-stats-hint { font-size: 13px; color: rgba(255,255,255,0.35); margin-top: 4px; }

/* ── 寶箱結算頁 ──────────────────────────────────────────── */
.expl-result-box {
  background: var(--bg-panel);
  border: 2px solid rgba(139,92,246,0.4);
  border-radius: 24px;
  padding: 28px 24px;
  width: min(90vw, 360px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  box-shadow: 0 0 60px rgba(139,92,246,0.3);
}
.expl-result-title  { font-size: 20px; font-weight: 900; color: var(--gold); }
.expl-result-correct { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.expl-result-tier   { font-size: 16px; font-weight: 700; margin-top: 6px; }
.expl-open-btn      { width: 100%; margin-top: 10px; font-size: 16px; padding: 14px; }

/* ── 寶箱動畫 ────────────────────────────────────────────── */
.expl-chest-box {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
}
.expl-chest-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(230,168,23,0.5));
  transition: transform 0.3s ease;
}

@keyframes chestShake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  15%       { transform: rotate(-6deg) scale(1.05); }
  30%       { transform: rotate(6deg)  scale(1.05); }
  45%       { transform: rotate(-4deg) scale(1.08); }
  60%       { transform: rotate(4deg)  scale(1.08); }
  75%       { transform: rotate(-2deg) scale(1.05); }
}
.chest-shake .expl-chest-img {
  animation: chestShake 0.7s ease infinite;
  filter: drop-shadow(0 0 20px rgba(230,168,23,0.8));
}
@keyframes chestOpen {
  0%   { transform: scale(1) rotate(0deg); }
  30%  { transform: scale(1.3) rotate(-5deg); }
  50%  { transform: scale(0.8) rotate(5deg); }
  70%  { transform: scale(1.4) rotate(-2deg); }
  90%  { transform: scale(0.9) rotate(1deg); }
  100% { transform: scale(1.15) rotate(0deg); filter: brightness(3) saturate(2); }
}
.chest-open .expl-chest-img {
  animation: chestOpen 0.8s ease forwards;
}

/* ── 掉落物品展示 ─────────────────────────────────────────── */
/* (uses .expl-overlay-screen for base positioning) */
.expl-loot-screen-unused {
  display: none; /* legacy — replaced by .expl-overlay-screen */
  animation: fadeIn 0.3s ease;
}
.expl-loot-box {
  background: var(--bg-panel);
  border: 2px solid rgba(230,168,23,0.5);
  border-radius: 24px;
  padding: 24px;
  width: min(92vw, 380px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 60px rgba(230,168,23,0.4);
}
.expl-loot-title {
  font-size: 17px;
  font-weight: 900;
  color: var(--gold);
  text-align: center;
}
.expl-loot-grid {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  min-height: 100px;
}
.expl-loot-card {
  width: 100px;
  padding: 12px 8px;
  border-radius: 14px;
  text-align: center;
  opacity: 0;
  transform: scale(0) rotate(-10deg);
  transition: none;
  background: var(--bg-card);
}
.expl-loot-card.pop-in {
  animation: lootPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes lootPop {
  0%   { opacity: 0; transform: scale(0) rotate(-10deg); }
  60%  { opacity: 1; transform: scale(1.2) rotate(4deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}
.rarity-card-white  { border: 2px solid var(--rarity-white);  box-shadow: 0 0 10px rgba(192,192,192,0.25); }
.rarity-card-green  { border: 2px solid var(--rarity-green);  box-shadow: 0 0 10px rgba(30,170,85,0.35); }
.rarity-card-blue   { border: 2px solid var(--rarity-blue);   box-shadow: 0 0 10px rgba(41,121,204,0.4); }
.rarity-card-purple { border: 2px solid var(--rarity-purple); box-shadow: 0 0 14px rgba(155,89,182,0.5); }
.rarity-card-gold   { border: 2px solid var(--rarity-gold);   box-shadow: 0 0 18px rgba(230,168,23,0.6); }

.expl-loot-icon   { font-size: 34px; margin-bottom: 4px; }
.expl-loot-name   { font-size: 11px; font-weight: 700; line-height: 1.3; }
.expl-loot-rarity { font-size: 10px; color: var(--text-secondary); margin-top: 2px; }
.expl-loot-stats  { font-size: 10px; color: var(--text-dim); margin-top: 3px; line-height: 1.5; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-6px); }
  40%     { transform: translateX(6px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════
   廣告獎勵系統（Ad Reward）
   ═══════════════════════════════════════════════════════════ */

/* ── HUD 廣告按鈕 ─────────────────────────────────────────── */
.ad-reward-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin-left: 6px;
  flex-shrink: 0;
  animation: adPulse 2s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(245,158,11,0.5);
  transition: transform 0.1s;
}
.ad-reward-btn:hover { transform: scale(1.1); }
.ad-reward-btn:active { transform: scale(0.95); }
.ad-reward-btn.exhausted {
  background: rgba(100,116,139,0.4);
  animation: none;
  box-shadow: none;
  filter: grayscale(0.8);
}
@keyframes adPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(245,158,11,0.4); }
  50%       { box-shadow: 0 0 18px rgba(245,158,11,0.9); }
}
.ad-reward-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  background: #ef4444;
  color: #fff;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  border: 1.5px solid var(--bg-card);
}

/* ── 廣告 Modal ─────────────────────────────────────────── */
.ad-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: fadeIn 0.2s ease;
}
.ad-modal-box {
  background: var(--bg-panel);
  border: 2px solid rgba(245,158,11,0.4);
  border-radius: 24px;
  padding: 28px 24px 22px;
  width: min(88vw, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  box-shadow: 0 0 60px rgba(245,158,11,0.3);
}
.ad-modal-heart {
  font-size: 44px;
  animation: heartBeat 0.8s ease infinite alternate;
}
@keyframes heartBeat {
  from { transform: scale(1); }
  to   { transform: scale(1.15); }
}
.ad-modal-title   { font-size: 18px; font-weight: 900; color: var(--gold); }
.ad-modal-desc    { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.ad-modal-count   { font-size: 12px; color: var(--text-secondary); }
.ad-modal-count b { color: var(--gold); }

.ad-modal-steps {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
  padding: 6px 14px;
  margin: 4px 0;
}
.ad-modal-watch-btn {
  width: 100%;
  font-size: 16px;
  padding: 14px;
  margin-top: 6px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  border-color: transparent;
}
.ad-modal-watch-btn:hover {
  background: linear-gradient(135deg, #fbbf24, #f87171);
  transform: scale(1.02);
}

.ad-dev-badge {
  background: rgba(139,92,246,0.2);
  border: 1px solid rgba(139,92,246,0.4);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 10px;
  color: var(--purple-glow);
  margin-bottom: 4px;
}

/* ── 開發模式 Mock 廣告畫面 ──────────────────────────────── */
.ad-mock-screen {
  width: 100%;
  background: #0f172a;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 1px dashed rgba(255,255,255,0.2);
}
.ad-mock-icon   { font-size: 40px; }
.ad-mock-brand  { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.ad-mock-sub    { font-size: 10px; color: var(--text-secondary); }

.ad-mock-timer {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
.ad-mock-timer-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #22c55e);
  border-radius: 3px;
  transition: width 0.9s linear;
}
.ad-mock-secs {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}


/* ════════════════════════════════════════════════════════════
   探寶任務（Treasure Quest）樣式
   ════════════════════════════════════════════════════════════ */

/* ── 浮動按鈕（地城頁） ──────────────────────────────────── */
.tq-float-btn {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 1200;
  background: linear-gradient(135deg, #d97706, #92400e);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(217,119,6,0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: tq-float-pulse 2s ease-in-out infinite;
}
.tq-float-btn:hover { transform: scale(1.05); }
@keyframes tq-float-pulse {
  0%,100% { box-shadow: 0 4px 20px rgba(217,119,6,0.5); }
  50%      { box-shadow: 0 4px 30px rgba(217,119,6,0.9); }
}

/* ── 勝利畫面按鈕 ─────────────────────────────────────────── */
.tq-btn-victory {
  background: linear-gradient(135deg, #d97706, #b45309) !important;
  color: #fff !important;
  border: none !important;
}

/* ── 計時 badge ──────────────────────────────────────────── */
.tq-timer-badge {
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
}

/* ── 覆蓋層主體 ──────────────────────────────────────────── */
#tq-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tq-main {
  display: flex;
  width: 96vw;
  max-width: 900px;
  height: 90vh;
  max-height: 580px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}

/* ── 左：場景（石門） ──────────────────────────────────────── */
.tq-scene {
  flex: 1 1 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* 背景圖暗色遮罩（讓石門/UI 更清晰可讀） */
.tq-scene-bg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 0;
  pointer-events: none;
}

/* 場景內容（疊在遮罩上） */
.tq-scene-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  padding: 12px 0 0;
}

/* 頂部資訊列（標題 + 深度） */
.tq-scene-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 88%;
  margin-bottom: 4px;
}

.tq-scene-title {
  font-size: 12px;
  font-weight: 700;
  color: #fcd34d;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
}

.tq-depth-label {
  font-size: 12px;
  font-weight: 700;
  color: #e2e8f0;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  background: rgba(0,0,0,0.4);
  padding: 2px 8px;
  border-radius: 10px;
}

/* 進度條 */
.tq-progress-bar-wrap {
  width: 80%;
  height: 14px;
  background: rgba(0,0,0,0.4);
  border-radius: 7px;
  overflow: hidden;
  position: relative;
  margin-bottom: 10px;
}
.tq-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #d97706, #fbbf24);
  border-radius: 7px;
  transition: width 0.5s;
}
.tq-progress-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: #fff;
}

/* 石門 */
.tq-gate-wrap {
  display: flex;
  width: 88%;
  height: 300px;
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}

.tq-gate-left,
.tq-gate-right {
  flex: 1;
  background: linear-gradient(180deg, #3d2a1a 0%, #2a1a0a 100%);
  border: 3px solid #7c5c38;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 16px 8px;
  position: relative;
  z-index: 2;
}
.tq-gate-left  { border-right: 1px solid #7c5c38; }
.tq-gate-right { border-left:  1px solid #7c5c38; }

.tq-gate-runes {
  color: #d4a855;
  font-size: 13px;
  text-align: center;
  opacity: 0.7;
  letter-spacing: 4px;
}

/* 符文欄（新版，取代 tq-gate-runes） */
.tq-gate-rune-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  height: 100%;
  color: #d4a855;
  font-size: 14px;
  opacity: 0.75;
  gap: 4px;
}
.tq-gate-rune-col span {
  line-height: 1;
  text-shadow: 0 0 6px rgba(212,168,85,0.6);
}

.tq-gate-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}

.tq-gate-word {
  font-size: clamp(20px, 4.5vw, 32px);
  font-weight: 900;
  color: #fbbf24;
  text-shadow: 0 0 24px rgba(251,191,36,1), 0 0 8px rgba(251,191,36,0.6), 0 2px 4px rgba(0,0,0,0.9);
  letter-spacing: 6px;
  margin-bottom: 12px;
  transition: filter 0.6s ease;
  user-select: none;
}

.tq-gate-sparkles {
  display: flex;
  gap: 16px;
  font-size: 20px;
  color: #fbbf24;
  opacity: 0.4;
  transition: opacity 0.3s;
}
.tq-gate-sparkles.active {
  opacity: 1;
  animation: tq-sparkle-pop 0.6s ease;
}
@keyframes tq-sparkle-pop {
  0%   { transform: scale(0.8); opacity: 0.3; }
  50%  { transform: scale(1.4); opacity: 1; }
  100% { transform: scale(1);   opacity: 0.8; }
}

/* 人物 */
.tq-character {
  font-size: 40px;
  margin-top: 12px;
  animation: tq-char-bob 2s ease-in-out infinite;
}
@keyframes tq-char-bob {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ── 右：控制面板 ──────────────────────────────────────────── */
.tq-panel {
  width: 220px;
  min-width: 200px;
  background: #1e1b2e;
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 8px;
  overflow-y: auto;
}

.tq-panel-title {
  font-size: 12px;
  font-weight: 700;
  color: #a78bfa;
  text-align: center;
  border-bottom: 1px solid rgba(167,139,250,0.2);
  padding-bottom: 8px;
}

.tq-panel-section-label {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 600;
  margin-top: 2px;
}

/* 字母磚格（3 欄網格） */
.tq-tiles-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  min-height: 60px;
}

.tq-tile {
  width: 100%;
  aspect-ratio: 1;
  background: #374151;
  border: 2px solid #6b7280;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 900;
  color: #f3f4f6;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tq-tile:hover:not(.used):not(.wrong) {
  background: #4b5563;
  border-color: #d97706;
  transform: scale(1.1);
}
.tq-tile.used {
  background: #166534;
  border-color: #22c55e;
  color: #86efac;
  opacity: 0.6;
  cursor: default;
}
.tq-tile.wrong {
  background: #7f1d1d;
  border-color: #ef4444;
  color: #fca5a5;
  animation: tq-tile-shake 0.3s;
}
@keyframes tq-tile-shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* 目標單字 */
/* 目標拼字旁的狀態標籤 */
.tq-hint-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  transition: background 0.3s, color 0.3s;
}
.tq-hint-tag.listening {
  background: rgba(99,102,241,0.25);
  color: #a5b4fc;
  animation: tq-listen-pulse 1s ease-in-out infinite;
}
.tq-hint-tag.hidden-hint {
  background: rgba(217,119,6,0.25);
  color: #fbbf24;
}
.tq-hint-tag.correct-hint {
  background: rgba(22,163,74,0.25);
  color: #4ade80;
}
@keyframes tq-listen-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

.tq-target-word {
  font-size: 18px;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 4px;
  text-align: center;
  padding: 4px 0;
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: 8px;
  background: rgba(251,191,36,0.05);
  transition: filter 0.6s ease;
  user-select: none;
}

/* 拼寫槽 */
.tq-spelling-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.tq-spell-slot {
  width: 26px;
  height: 26px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  font-size: 13px;
  font-weight: 700;
  color: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tq-spell-slot.filled {
  background: rgba(34,197,94,0.2);
  border-color: #22c55e;
  color: #86efac;
}

/* 寶箱預覽 */
.tq-chest-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.tq-chest-preview-label {
  font-size: 9px;
  color: #94a3b8;
  text-align: center;
}

/* 離開按鈕 */
.tq-quit-btn {
  margin-top: auto;
  font-size: 11px;
  padding: 6px;
  color: var(--text-dim);
}

/* ── 結算畫面 ──────────────────────────────────────────────── */
.tq-result {
  background: #1e1b2e;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 440px;
  width: 90vw;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tq-result-title {
  font-size: 22px;
  font-weight: 900;
  color: #fbbf24;
}

.tq-result-acc {
  font-size: 16px;
  color: #f3f4f6;
}

.tq-result-prob-desc {
  font-size: 11px;
  color: #94a3b8;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 6px 12px;
}

.tq-result-chest-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.tq-result-chest-img {
  width: 100px;
  height: 100px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(251,191,36,0.6));
  transition: transform 0.2s;
  animation: tq-chest-pulse 1.5s ease-in-out infinite;
}
.tq-result-chest-img:hover { transform: scale(1.1); }
@keyframes tq-chest-pulse {
  0%,100% { filter: drop-shadow(0 0 12px rgba(251,191,36,0.5)); }
  50%      { filter: drop-shadow(0 0 24px rgba(251,191,36,0.9)); }
}
.tq-result-chest-img.tq-chest-open-anim {
  animation: tq-chest-open 0.6s forwards;
}
@keyframes tq-chest-open {
  0%   { transform: scale(1) rotate(0deg); }
  30%  { transform: scale(1.3) rotate(-5deg); }
  60%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1.0) rotate(0deg); opacity: 0.7; }
}
.tq-result-chest-hint {
  font-size: 12px;
  color: #fbbf24;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1}50%{opacity:0.3} }

.tq-result-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

.tq-reward-item {
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 70px;
  border: 1px solid rgba(255,255,255,0.1);
  opacity: 0;
}
.tq-reward-item.pop-in { animation: pop-in 0.4s forwards; }
@keyframes pop-in {
  0%   { transform: scale(0.3); opacity: 0; }
  70%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}
.tq-reward-item.gold   { border-color: #d97706; background: rgba(217,119,6,0.1); }
.tq-reward-item.purple { border-color: #7c3aed; background: rgba(124,58,237,0.1); }
.tq-reward-item.blue   { border-color: #2563eb; background: rgba(37,99,235,0.1); }
.tq-reward-item.green  { border-color: #16a34a; background: rgba(22,163,74,0.1); }
.tq-reward-item-icon { font-size: 24px; }
.tq-reward-item-name { font-size: 9px; color: #94a3b8; text-align: center; line-height: 1.2; }


/* ════════════════════════════════════════════════════════════
   交易系統（Trade）樣式
   ════════════════════════════════════════════════════════════ */

/* ── 等待畫面 ──────────────────────────────────────────────── */
.trade-waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #1e1b2e;
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 320px;
  text-align: center;
}
.trade-waiting-icon { font-size: 48px; animation: tq-char-bob 2s ease-in-out infinite; }
.trade-waiting-text { font-size: 16px; font-weight: 700; color: #f3f4f6; }
.trade-waiting-sub  { font-size: 13px; color: #94a3b8; }

/* ── 交易主介面 ───────────────────────────────────────────── */
.trade-ui {
  background: #1e1b2e;
  border-radius: 16px;
  width: 96vw;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
}

.trade-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding-bottom: 10px;
}
.trade-title { font-size: 18px; font-weight: 900; color: #fbbf24; flex: 1; }
.trade-cancel-btn { padding: 5px 14px !important; font-size: 12px !important; }
.trade-countdown-badge {
  background: #ef4444;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── 雙方區塊 ─────────────────────────────────────────────── */
.trade-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.trade-side {
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trade-side.my-side  { border: 1px solid rgba(99,102,241,0.4); }
.trade-side.op-side  { border: 1px solid rgba(148,163,184,0.2); }

.trade-side-label {
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
}

/* 道具格 */
.trade-items-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.trade-slot {
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px dashed rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  position: relative;
}
.trade-slot.filled { border-style: solid; }
.trade-slot.gold   { border-color: #d97706; background: rgba(217,119,6,0.1); }
.trade-slot.purple { border-color: #7c3aed; background: rgba(124,58,237,0.1); }
.trade-slot.blue   { border-color: #2563eb; background: rgba(37,99,235,0.1); }
.trade-slot.green  { border-color: #16a34a; background: rgba(22,163,74,0.1); }
.trade-slot.white  { border-color: #64748b; background: rgba(100,116,139,0.1); }

.trade-slot-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* 金幣 row */
.trade-gold-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #e2e8f0;
}
.trade-gold-input {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #fbbf24;
  font-size: 14px;
  font-weight: 700;
  padding: 4px 8px;
  text-align: right;
  min-width: 0;
}
.trade-gold-input:disabled { opacity: 0.5; cursor: default; }
.trade-gold-max   { font-size: 10px; color: #94a3b8; white-space: nowrap; }
.trade-op-gold    { font-size: 16px; font-weight: 700; color: #fbbf24; }

/* 對方確認狀態 */
.trade-op-status {
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
}
.trade-op-status.confirmed { color: #22c55e; background: rgba(34,197,94,0.08); }

/* 確認按鈕 */
.trade-confirm-btn {
  width: 100%;
  font-size: 14px;
  font-weight: 700;
  padding: 10px !important;
}
.btn-success {
  background: linear-gradient(135deg, #166534, #15803d) !important;
  color: #86efac !important;
  border: 1px solid #22c55e !important;
  cursor: default;
}

/* ── 背包選擇區 ──────────────────────────────────────────── */
.trade-bag-section {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 10px;
}
.trade-bag-label {
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 8px;
}
.trade-bag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}
.trade-bag-item {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}
.trade-bag-item:hover:not(.disabled) { background: rgba(255,255,255,0.12); transform: scale(1.03); }
.trade-bag-item.disabled { opacity: 0.4; cursor: default; }
.trade-bag-item.gold   { border-color: rgba(217,119,6,0.5); }
.trade-bag-item.purple { border-color: rgba(124,58,237,0.5); }
.trade-bag-item.blue   { border-color: rgba(37,99,235,0.5); }
.trade-bag-item.green  { border-color: rgba(22,163,74,0.5); }
.trade-bag-item-name   { color: #e2e8f0; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trade-bag-empty { font-size: 12px; color: #94a3b8; padding: 12px; text-align: center; width: 100%; }

/* ── 完成畫面 ──────────────────────────────────────────────── */
.trade-complete {
  background: #1e1b2e;
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.trade-complete-icon  { font-size: 52px; }
.trade-complete-title { font-size: 22px; font-weight: 900; color: #fbbf24; }
.trade-complete-sub   { font-size: 14px; color: #94a3b8; }

/* ── modal input ──────────────────────────────────────────── */
.modal-input {
  width: 100%;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  padding: 10px 12px;
  box-sizing: border-box;
}
.modal-input::placeholder { color: var(--text-dim); }
.modal-input:focus { outline: none; border-color: var(--border-glow); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }


/* ════════════════════════════════════════════════════════════
   Boss 挑戰系統
   ════════════════════════════════════════════════════════════ */

/* ── 大廳 ─────────────────────────────────────────────────── */
.boss-lobby-header {
  padding: 20px 16px 8px;
  text-align: center;
}
.boss-lobby-title {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
}
.boss-lobby-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.boss-select-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 80px;
}

.boss-loading {
  text-align: center;
  color: var(--text-dim);
  padding: 32px;
  font-size: 14px;
}
.boss-error { color: #ef4444; }

/* ── Boss 卡片 ──────────────────────────────────────────────── */
.boss-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.boss-card:hover {
  border-color: var(--boss-color, var(--border-glow));
  box-shadow: 0 0 0 2px rgba(var(--boss-color-rgb, 99,102,241), 0.12);
}
.boss-card-active {
  border-color: #ef4444;
  background: rgba(239,68,68,0.06);
}

.boss-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.boss-card-emoji {
  font-size: 36px;
  flex-shrink: 0;
}
.boss-card-info { flex: 1; }
.boss-card-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
}
.boss-card-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
.boss-card-status {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 10px;
}
.boss-card-status.waiting  { background: rgba(99,102,241,0.15); color: #a5b4fc; }
.boss-card-status.fighting { background: rgba(239,68,68,0.15);  color: #fca5a5; }

/* ── 冒險者槽位 ─────────────────────────────────────────────── */
.boss-card-slots {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.boss-slot {
  flex: 1;
  min-width: 0;
  background: var(--bg-panel);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
  min-height: 72px;
}
.boss-slot.empty           { border-style: dashed; justify-content: center; cursor: default; }
.boss-slot.empty.clickable { cursor: pointer; }
.boss-slot.empty.clickable:hover {
  border-color: var(--boss-color, #6366f1);
  background: rgba(99,102,241,0.06);
  transform: scale(1.04);
}
.boss-slot.occupied { cursor: default; }
.boss-slot.ready  { border-color: #22c55e; background: rgba(34,197,94,0.1); }
.boss-slot.mine   { border-color: var(--boss-color, #6366f1); box-shadow: 0 0 0 2px rgba(99,102,241,0.25); }
.boss-slot.mine.ready { border-color: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }

.boss-slot-plus   { font-size: 22px; color: var(--text-dim); }
.boss-slot-avatar { font-size: 22px; line-height: 1; }
.boss-slot-name   { font-size: 9px; color: var(--text-secondary); font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boss-slot-lv     { font-size: 9px; color: var(--text-dim); }
.boss-slot-ready-badge {
  position: absolute;
  top: 2px; right: 3px;
  font-size: 8px;
  background: #22c55e;
  color: #fff;
  border-radius: 4px;
  padding: 1px 4px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* ── 房間操作按鈕 ────────────────────────────────────────────── */
.boss-card-joined { border-color: var(--boss-color, #6366f1) !important; }
.boss-join-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0 2px;
}
.boss-room-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
}
/* 準備 OK！ */
.boss-ready-btn {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  font-weight: 800;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.boss-ready-btn:hover { filter: brightness(1.15); transform: scale(1.02); }

/* 已準備（取消）*/
.boss-ready-active {
  width: 100%;
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 12px;
  background: rgba(34,197,94,0.15);
  color: #22c55e;
  border: 2px solid #22c55e;
  cursor: pointer;
  transition: filter 0.15s;
}
.boss-ready-active:hover { filter: brightness(1.1); }

.boss-leave-btn {
  width: 100%;
  padding: 8px;
  font-size: 12px;
  border-radius: 10px;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}
.boss-leave-btn:hover { background: rgba(239,68,68,0.08); color: #ef4444; border-color: #ef4444; }

.boss-start-btn {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 900;
  border-radius: 12px;
  color: #fff !important;
  border: none !important;
  cursor: pointer;
  animation: boss-start-pulse 1.4s ease-in-out infinite;
  letter-spacing: 0.03em;
}
@keyframes boss-start-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5), 0 4px 20px rgba(220,38,38,0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(220,38,38,0), 0 4px 20px rgba(220,38,38,0.2); }
}

/* ── 戰鬥 HUD ──────────────────────────────────────────────── */
.boss-battle-hud {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  flex-shrink: 0;
}

.boss-hud-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.boss-hud-round {
  font-size: 10px;
  background: rgba(255,255,255,0.08);
  padding: 2px 8px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 600;
}

.boss-hp-bar-wrap {
  height: 10px;
  background: rgba(0,0,0,0.3);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 2px;
}
.boss-hp-bar-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.6s;
}
.boss-hp-text {
  font-size: 10px;
  color: var(--text-dim);
  text-align: right;
}

.boss-hud-players {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}
.boss-player-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.boss-player-bar.dead { opacity: 0.4; }
.boss-player-bar.mine .boss-player-name { color: #a5b4fc; }
.boss-player-emoji { font-size: 16px; flex-shrink: 0; }
.boss-player-info  { flex: 1; min-width: 0; }
.boss-player-name  { font-size: 10px; color: var(--text-secondary); font-weight: 600; }
.boss-player-hp-wrap {
  height: 5px;
  background: rgba(0,0,0,0.3);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 2px;
}
.boss-player-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  border-radius: 3px;
  transition: width 0.5s;
}
.boss-player-hp-num {
  font-size: 9px;
  color: var(--text-dim);
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
}

/* ── 問題面板 ───────────────────────────────────────────────── */
.boss-question-panel {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  position: relative;
}

.boss-round-timer-wrap {
  position: absolute;
  top: 8px; right: 12px;
  font-size: 11px;
  color: var(--text-dim);
  pointer-events: none;
}
.boss-round-timer {
  font-size: 18px;
  font-weight: 900;
  color: #f97316;
}

.boss-q-progress {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.boss-q-type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(99,102,241,0.15);
  color: #a5b4fc;
  margin-bottom: 8px;
}
.boss-q-prompt {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
  line-height: 1.5;
}
.boss-tts-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  padding: 4px 10px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 10px;
}
.boss-q-opts {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.boss-opt-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.boss-opt-btn:hover:not(:disabled) {
  border-color: var(--border-glow);
  background: rgba(99,102,241,0.08);
}
.boss-opt-num {
  flex-shrink: 0;
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.boss-opt-correct { border-color: #22c55e !important; background: rgba(34,197,94,0.12) !important; }
.boss-opt-wrong   { border-color: #ef4444 !important; background: rgba(239,68,68,0.12) !important; }
.boss-opt-eliminated { opacity: 0.35; pointer-events: none; }

/* ── 動畫階段 ───────────────────────────────────────────────── */
.boss-resolving-anim, .boss-attack-anim {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-radius: 12px;
  text-align: center;
}
.boss-resolving-anim {
  background: rgba(99,102,241,0.08);
  border: 1px solid rgba(99,102,241,0.3);
}
.boss-attack-anim {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.3);
  animation: boss-attack-shake 0.4s ease;
}
@keyframes boss-attack-shake {
  0%,100% { transform: translateX(0); }
  25%      { transform: translateX(-6px); }
  75%      { transform: translateX(6px); }
}
.boss-resolving-title, .boss-attack-title {
  font-size: 16px;
  font-weight: 900;
}
.boss-resolve-rows, .boss-attack-rows {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.boss-resolve-row, .boss-attack-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  font-size: 13px;
}
.boss-resolve-row.mine { background: rgba(99,102,241,0.12); }
.boss-combo-badge {
  font-weight: 800;
  color: #f97316;
}
.boss-dmg-badge {
  font-weight: 800;
  color: #ef4444;
}
.boss-attack-emoji { font-size: 48px; animation: boss-char-bob 0.6s ease-in-out 3; }
.boss-special-warning {
  font-size: 13px;
  font-weight: 800;
  color: #fbbf24;
  background: rgba(251,191,36,0.12);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(251,191,36,0.3);
  animation: boss-warn-pulse 0.8s ease infinite;
  margin-top: 8px;
}
@keyframes boss-warn-pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ── 特技解題 ───────────────────────────────────────────────── */
.boss-special-popup {
  background: rgba(251,191,36,0.06);
  border: 2px solid rgba(251,191,36,0.4);
  border-radius: 12px;
  padding: 14px;
  animation: boss-special-glow 1.5s ease-in-out infinite;
}
@keyframes boss-special-glow {
  0%,100% { box-shadow: 0 0 0 0 rgba(251,191,36,0.2); }
  50%      { box-shadow: 0 0 12px 4px rgba(251,191,36,0.15); }
}
.boss-special-header {
  font-size: 14px;
  font-weight: 800;
  color: #fbbf24;
  margin-bottom: 4px;
}
.boss-special-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* ── 旁觀 / 等待 ──────────────────────────────────────────── */
.boss-spectate, .boss-waiting-next {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
  gap: 12px;
}

/* ── 結算畫面 ─────────────────────────────────────────────── */
.boss-finish-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 10px;
  text-align: center;
}
.boss-finish-screen.win  { background: rgba(34,197,94,0.06); border-radius: 12px; }
.boss-finish-screen.lose { background: rgba(239,68,68,0.06); border-radius: 12px; }
.boss-finish-emoji  { font-size: 56px; }
.boss-finish-title  { font-size: 22px; font-weight: 900; color: var(--text-primary); }
.boss-finish-sub    { font-size: 13px; color: var(--text-dim); }
.boss-finish-rewards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.boss-reward-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1.5px solid var(--border);
}
.boss-reward-item.gold   { border-color: #d97706; color: #fbbf24; background: rgba(217,119,6,0.1); }
.boss-reward-item.purple { border-color: #7c3aed; color: #c4b5fd; background: rgba(124,58,237,0.1); }
.boss-reward-item.blue   { border-color: #2563eb; color: #93c5fd; background: rgba(37,99,235,0.1); }
.boss-reward-item.green  { border-color: #16a34a; color: #86efac; background: rgba(22,163,74,0.1); }
.boss-reward-item.white  { border-color: var(--border); color: var(--text-dim); }

/* ── Boss 圖片：大廳卡片 ─────────────────────────────────── */
.boss-card-lobby-img-wrap {
  width: 90px;
  height: 90px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.boss-card-lobby-img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  image-rendering: pixelated;
}
.boss-card-emoji-fallback {
  font-size: 48px;
  align-items: center;
  justify-content: center;
}

/* ── Boss 圖片：戰鬥 HUD ────────────────────────────────── */
.boss-hud-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 4px;
}
.boss-hud-sprite-wrap {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.boss-hud-sprite {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
}
.boss-hud-info { flex: 1; min-width: 0; }
.boss-sprite-fallback { font-size: 40px; }

/* ── Boss 圖片：resolving（Boss 受傷）────────────────────── */
.boss-hurt-sprite-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.boss-hurt-sprite {
  width: 100px;
  height: 100px;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ── Boss 圖片：攻擊動畫 ────────────────────────────────── */
.boss-attack-sprite-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.boss-attack-sprite {
  width: 110px;
  height: 110px;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ── Boss 圖片：特技 ────────────────────────────────────── */
.boss-special-sprite-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.boss-special-sprite {
  width: 120px;
  height: 120px;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ── Boss 圖片：結算 ────────────────────────────────────── */
.boss-finish-sprite-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
.boss-finish-sprite {
  width: 130px;
  height: 130px;
  object-fit: contain;
  image-rendering: pixelated;
}

/* ════════════════════════════════════════════════════════════
   Boss 圖片狀態動畫
   ════════════════════════════════════════════════════════════ */

/* idle：輕微上下漂浮 */
.boss-sprite-idle {
  animation: boss-float 2.5s ease-in-out infinite;
}
@keyframes boss-float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* attack：往前衝刺 */
.boss-sprite-attack {
  animation: boss-lunge 0.5s ease-out forwards;
  transform-origin: center;
}
@keyframes boss-lunge {
  0%   { transform: translateX(0) scale(1); }
  35%  { transform: translateX(-20px) scale(1.08); }
  70%  { transform: translateX(8px) scale(0.96); }
  100% { transform: translateX(0) scale(1); }
}

/* hurt：受傷搖晃 + 閃紅 */
.boss-sprite-hurt {
  animation: boss-hurt 0.5s ease-in-out infinite;
  filter: brightness(1) saturate(1);
}
@keyframes boss-hurt {
  0%,100% { transform: translateX(0); filter: brightness(1); }
  20%      { transform: translateX(-8px); filter: brightness(3) sepia(1) hue-rotate(-20deg); }
  40%      { transform: translateX(8px);  filter: brightness(1); }
  60%      { transform: translateX(-5px); filter: brightness(2) sepia(1) hue-rotate(-20deg); }
  80%      { transform: translateX(5px);  filter: brightness(1); }
}

/* charge：發光脈衝 */
.boss-sprite-charge {
  animation: boss-charge-glow 0.8s ease-in-out infinite;
}
@keyframes boss-charge-glow {
  0%,100% { filter: brightness(1) drop-shadow(0 0 4px currentColor); transform: scale(1); }
  50%      { filter: brightness(1.5) drop-shadow(0 0 16px rgba(99,232,255,0.9)); transform: scale(1.06); }
}

/* special：爆發放大 */
.boss-sprite-special {
  animation: boss-special-burst 1s ease-in-out infinite;
}
@keyframes boss-special-burst {
  0%   { transform: scale(1); filter: brightness(1); }
  30%  { transform: scale(1.15); filter: brightness(1.8) drop-shadow(0 0 20px rgba(255,200,0,0.8)); }
  60%  { transform: scale(0.95); filter: brightness(1); }
  100% { transform: scale(1); }
}

/* death：倒下淡出 */
.boss-sprite-death {
  animation: boss-death-fall 0.8s ease-out forwards;
}
@keyframes boss-death-fall {
  0%   { transform: rotate(0deg) scale(1); opacity: 1; }
  60%  { transform: rotate(12deg) scale(0.9); opacity: 0.7; }
  100% { transform: rotate(20deg) scale(0.85); opacity: 0.5; filter: grayscale(1); }
}
