/**
 * Main CSS - 客製化樣式
 * 處理 Tailwind 無法覆蓋的特效與動畫
 */

:root {
  --primary-navy: #0f172a;
  --accent-gold: #d97706;
  --bg-light: #f1f5f9;
}

* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: "Noto Sans TC", sans-serif;
  background-color: var(--bg-light);
  padding-bottom: 90px;
}

/* ==================== Google 登入按鈕 ==================== */
.google-btn {
  display: flex;
  align-items: center;
  background-color: white;
  border: 1px solid #dadce0;
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  transition:
    background-color 0.3s,
    box-shadow 0.3s;
  font-family: "Roboto", sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: #3c4043;
}

.google-btn:hover {
  background-color: #f7fafe;
  border-color: #d2e3fc;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3);
}

.google-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}

/* ==================== 分頁切換動畫 ==================== */
.view-section {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.view-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== 導航列 Active 狀態 ==================== */
.nav-item {
  transition: all 0.2s ease;
}

.nav-item.active {
  color: var(--accent-gold);
  font-weight: 700;
}

.nav-item.active svg {
  fill: currentColor;
}

/* ==================== 快速情境按鈕 ==================== */
.quick-btn {
  text-align: left;
  transition: all 0.2s;
}

.quick-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border-color: #d97706;
}

.quick-btn:active {
  transform: translateY(0);
}

/* ==================== Toast 通知 ==================== */
/* ==================== Toast 通知 (舊版系統：用於系統警告) ==================== */
/* 修改說明：強制置中 + 最高層級，避免被視窗擋住 */
.toast {
  position: fixed;
  top: 50% !important;
  /* 強制垂直置中 */
  left: 50% !important;
  /* 強制水平置中 */
  transform: translate(-50%, -50%) !important;
  /* 精準校正中心點 */

  padding: 16px 32px;
  /* 加大內距，讓警告更明顯 */
  border-radius: 50px;
  font-size: 16px;
  /* 加大字體 */
  font-weight: 700;
  color: white;

  /* 🔥 關鍵：層級設為瀏覽器最大值，保證浮在所有視窗(Modal)之上 */
  z-index: 2147483647 !important;

  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  /* 加入彈跳動畫 */
  pointer-events: none;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  /* 加深陰影 */

  width: max-content;
  /* 寬度依照文字長度自動調整 */
  max-width: 90vw;
  /* 手機版不要超出螢幕寬度 */
  text-align: center;
  white-space: nowrap;
  /* 避免文字不正常換行 */
}

/* 顏色設定保持不變 */
.toast-success {
  background-color: #10b981;
}

.toast-error {
  background-color: #ef4444;
}

.toast-warning {
  background-color: #f59e0b;
}

/* 您的等級警告會用這個顏色 */
.toast-info {
  background-color: #3b82f6;
}

.toast-success {
  background-color: #10b981;
}

.toast-error {
  background-color: #ef4444;
}

.toast-warning {
  background-color: #f59e0b;
}

.toast-info {
  background-color: #3b82f6;
}

/* ==================== Modal 彈窗 ==================== */

/* Modal 開啟時鎖定背景滾動 (跨平台相容) */
body.modal-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

/* iOS Safari 額外修正 */
@supports (-webkit-touch-callout: none) {
  body.modal-open {
    -webkit-overflow-scrolling: auto;
  }
}

.modal-overlay {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 99999 !important;
  display: flex !important;
  align-items: flex-start !important;
  justify-content: center !important;
  padding: 60px 16px 120px 16px;
  background-color: rgba(0, 0, 0, 0.8) !important;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s ease;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-content {
  background-color: white;
  width: 100%;
  max-width: 28rem;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  transform: scale(1);
  transition: transform 0.3s ease;
  margin: 0 auto;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .modal-overlay {
    padding: 20px 12px 120px 12px;
    align-items: flex-start;
  }

  .modal-content {
    max-width: 100%;
    border-radius: 16px;
    margin: 0 auto;
    padding: 20px 16px;
  }
}

/* ==================== 知識卡片 Hover ==================== */
.knowledge-card {
  transition: all 0.2s ease;
  cursor: pointer;
}

.knowledge-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* ==================== 捲軸美化 ==================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ==================== 響應式修正 ==================== */
/* 移除大螢幕隱藏導航的設定，讓導航在所有螢幕都顯示 */
@media (min-width: 1024px) {
  body {
    padding-bottom: 90px;
    /* 確保內容不被導航遮住 */
  }

  .view-section {
    min-height: 400px;
  }
}

/* 桌面版導航樣式優化 */
@media (min-width: 1024px) {
  nav {
    justify-content: center;
    gap: 2rem;
  }

  .nav-item {
    flex-direction: row;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
  }

  .nav-item svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .nav-item span {
    font-size: 0.875rem;
  }
}

/* ==================== 表單元素美化 ==================== */
select:focus,
textarea:focus,
input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ==================== 載入動畫 ==================== */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

.animate-pulse {
  animation: pulse 2s infinite;
}

/* ==================== 按鈕按壓效果 ==================== */
button:active {
  transform: scale(0.98);
}

/* ==================== 漸層背景動畫 ==================== */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.bg-gradient-animated {
  background-size: 200% 200%;
  animation: gradientShift 15s ease infinite;
}

/* ==================== 卡片陰影層次 ==================== */
.card-shadow {
  box-shadow:
    0 1px 3px 0 rgba(0, 0, 0, 0.1),
    0 1px 2px 0 rgba(0, 0, 0, 0.06);
}

.card-shadow-lg {
  box-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* ==================== 文字選取顏色 ==================== */
::selection {
  background-color: #fbbf24;
  color: #1f2937;
}

/* ==================== 防止文字被選取 (特定元素) ==================== */
.nav-item,
.quick-btn,
.knowledge-card {
  user-select: none;
  -webkit-user-select: none;
}

/* ==================== Safe Area (iOS) ==================== */
@supports (padding: env(safe-area-inset-bottom)) {
  nav {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}

/* ==================== 載入骨架屏 ==================== */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ==================== 打字機效果 (備用) ==================== */
@keyframes typing {
  from {
    width: 0;
  }

  to {
    width: 100%;
  }
}

.typewriter {
  overflow: hidden;
  white-space: nowrap;
  animation: typing 3s steps(40, end);
}

/* ==================== 淡入淡出通用 ==================== */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

.fade-out {
  animation: fadeOut 0.5s ease-out;
}

.animate-fadeIn {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

/* ==================== 文字截斷 ==================== */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ==================== Toggle Switch (趕時間模式) ==================== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: #d97706;
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* ==================== 按鈕 disabled 狀態 ==================== */
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button:disabled:hover {
  transform: none;
}

/* ==================== 筆記卡片樣式 ==================== */
.note-card {
  transition: all 0.2s ease;
  position: relative;
}

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.note-card:active {
  transform: translateY(0);
}

/* 收藏按鈕 */
.note-card .favorite-btn {
  opacity: 0.6;
  transition: all 0.2s;
}

.note-card:hover .favorite-btn {
  opacity: 1;
}

.note-card .favorite-btn:hover {
  transform: scale(1.2);
}

/* ==================== 語音輸入按鈕 ==================== */
.voice-input-btn {
  transition: all 0.2s ease;
}

.voice-input-btn:hover {
  background-color: #eff6ff;
  color: #2563eb;
}

.voice-input-btn.recording {
  animation: pulse-recording 1s infinite;
  background-color: #fef2f2;
  color: #dc2626;
}

@keyframes pulse-recording {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
  }
}

/* ==================== 筆記篩選標籤 ==================== */
#notesActiveFilters .inline-flex {
  animation: fadeIn 0.2s ease-out;
}

#notesActiveFilters button {
  font-size: 14px;
  line-height: 1;
  padding: 0;
  margin-left: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

#notesActiveFilters button:hover {
  opacity: 1;
}

/* ==================== 筆記空狀態 ==================== */
.empty-state {
  animation: fadeIn 0.3s ease-out;
}

.empty-state svg {
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-10px);
  }
}

/* ==================== 儲存為筆記按鈕動畫 ==================== */
#saveToNotesBtn {
  animation: pulse-attention 2s infinite;
}

@keyframes pulse-attention {
  0%,
  100% {
    box-shadow: 0 4px 14px -1px rgba(245, 158, 11, 0.3);
  }

  50% {
    box-shadow: 0 6px 20px -1px rgba(245, 158, 11, 0.5);
  }
}

#saveToNotesBtn:hover {
  animation: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -1px rgba(245, 158, 11, 0.4);
}

/* ==================== 使用提示詞按鈕 ==================== */
#usePromptInEditBtn,
#usePromptFromDetailBtn {
  transition: all 0.2s;
}

#usePromptInEditBtn:hover,
#usePromptFromDetailBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px -1px rgba(16, 185, 129, 0.3);
}

/* ==================== 筆記 Modal 左對齊文字 ==================== */
#noteEditModal .modal-content,
#noteDetailModal .modal-content {
  text-align: left;
}

/* ==================== 筆記表單 textarea 焦點樣式 ==================== */
#noteDialogueInput:focus,
#noteRemarksInput:focus {
  background-color: white;
  border-color: #3b82f6;
}

/* ==================== 隱私提醒區塊樣式 ==================== */
.bg-amber-50 {
  background-color: #fffbeb;
}

/* ==================== 每日挑戰里程碑 ==================== */
.streak-milestone {
  text-align: center;
  padding: 12px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  transition: all 0.3s;
  opacity: 0.5;
}

.streak-milestone.achieved {
  opacity: 1;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: #fbbf24;
  box-shadow: 0 4px 6px -1px rgba(251, 191, 36, 0.2);
}

.streak-milestone.achieved .text-2xl {
  animation: bounce 2s infinite;
}

/* ==================== 挑戰歷史日曆 ==================== */
.day-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  min-height: 70px;
  transition: all 0.2s;
}

.day-cell.completed {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border-color: #22c55e;
}

.day-cell.completed .text-lg {
  color: #16a34a;
}

.day-cell.today {
  border-color: #3b82f6;
  border-width: 3px;
}

.day-cell.missed {
  background: #fef2f2;
  border-color: #fecaca;
}

/* ==================== V3.9 Enhanced: 電玩風格經驗值進度條 ==================== */

/* 進度條容器（外框） */
.xp-bar-container {
  position: relative;
  width: 100%;
  background: linear-gradient(to bottom, #e2e8f0, #cbd5e1);
  border-radius: 9999px;
  height: 16px;
  overflow: hidden;
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.1),
    0 1px 2px rgba(0, 0, 0, 0.05);
  border: 2px solid #94a3b8;
}

/* 進度條本體（內填充） */
.xp-bar {
  height: 100%;
  border-radius: 9999px;
  transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  overflow: hidden;
}

/* 進度條閃爍動畫（電玩感） */
.xp-bar::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

/* 進度條顏色變化（根據進度百分比動態調整 class） */
.xp-bar-low {
  background: linear-gradient(to right, #9ca3af, #6b7280);
}

.xp-bar-medium {
  background: linear-gradient(to right, #3b82f6, #2563eb);
}

.xp-bar-high {
  background: linear-gradient(to right, #fbbf24, #f59e0b);
}

.xp-bar-nearly-max {
  background: linear-gradient(to right, #10b981, #059669);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* 進度條上的百分比文字（內嵌在進度條上） */
.xp-bar span {
  font-size: 10px;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 10;
  white-space: nowrap;
}

/* 進度條脈衝效果（接近升級時） */
.xp-bar.near-levelup {
  animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(16, 185, 129, 0.5);
  }

  50% {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.8);
  }
}

/* 等級顯示文字（電玩風格標題） */
#userLevel {
  font-family: "Noto Sans TC", sans-serif;
  font-weight: 700;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: -0.5px;
}

/* 升級進度資訊文字 */
#xpProgressInfo {
  font-size: 11px;
  line-height: 1.6;
  padding: 8px 12px;
  background: linear-gradient(to right, #f8fafc, #f1f5f9);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

#xpProgressInfo .font-bold {
  font-family: "Roboto Mono", monospace;
}

/* 進度徽章（可選，顯示在進度條右上角） */
#xpProgressBadge {
  animation: badge-bounce 2s infinite;
}

@keyframes badge-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-4px) scale(1.1);
  }
}

/* 會員徽章優化（電玩風格） */
#memberTier {
  font-size: 12px;
  padding: 6px 16px;
  border-radius: 9999px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

#memberTier:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* 響應式設計：手機版調整 */
@media (max-width: 640px) {
  .xp-bar-container {
    height: 14px;
  }

  #xpProgressInfo {
    font-size: 10px;
    padding: 6px 10px;
  }

  #userLevel {
    font-size: 16px;
  }
}

/* ==================== 等級色彩系統（10 級） ==================== */

/* Lv.1 - 實習新人 */
.level-1 {
  color: #9ca3af;
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
}

/* Lv.2 - 潛力新秀 */
.level-2 {
  color: #60a5fa;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
}

/* Lv.3 - 業務尖兵 */
.level-3 {
  color: #06b6d4;
  background: linear-gradient(135deg, #cffafe, #a5f3fc);
}

/* Lv.4 - 銷售菁英 */
.level-4 {
  color: #f97316;
  background: linear-gradient(135deg, #fed7aa, #fdba74);
}

/* Lv.5 - 金牌業務 */
.level-5 {
  color: #eab308;
  background: linear-gradient(135deg, #fef3c7, #fde047);
}

/* Lv.6 - 專業顧問 */
.level-6 {
  color: #6366f1;
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
}

/* Lv.7 - 榮耀顧問 */
.level-7 {
  color: #a855f7;
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
}

/* Lv.8 - 鑽石會員 */
.level-8 {
  color: #ec4899;
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
}

/* Lv.9 - 巔峰領袖 */
.level-9 {
  color: #dc2626;
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  animation: prestige-glow 3s infinite;
}

/* Lv.10 - 殿堂傳奇 */
.level-10 {
  color: #7c3aed;
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  animation: legendary-shine 4s infinite;
}

/* 高階等級發光效果 */
@keyframes prestige-glow {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(220, 38, 38, 0.3);
  }

  50% {
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.6);
  }
}

@keyframes legendary-shine {
  0%,
  100% {
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.4);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 30px rgba(124, 58, 237, 0.8);
    transform: scale(1.05);
  }
}

/* ==================== 升級動畫（可選，當經驗值更新時觸發） ==================== */
@keyframes levelup-celebration {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.levelup-animation {
  animation: levelup-celebration 0.6s ease-out;
}

/* 經驗值增加時的數字跳動效果 */
@keyframes xp-bounce {
  0%,
  100% {
    transform: translateY(0);
  }

  25% {
    transform: translateY(-8px);
  }

  75% {
    transform: translateY(-4px);
  }
}

.xp-gain-animation {
  animation: xp-bounce 0.5s ease-out;
  color: #10b981;
  font-weight: bold;
}

/* ==================== 用戶下拉選單 ==================== */
#userDropdownMenu {
  animation: dropdown-slide 0.2s ease-out;
}

@keyframes dropdown-slide {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#userDropdownMenu.hidden {
  animation: dropdown-slide-out 0.15s ease-in;
}

@keyframes dropdown-slide-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* 下拉選單按鈕懸停效果 */
#userDropdownMenu button:hover {
  background-color: #f8fafc;
}

#userDropdownMenu button:active {
  transform: scale(0.98);
}

/* ==================== 社群分享按鈕 ==================== */
.share-social-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border-radius: 16px;
  color: white;
  font-weight: bold;
  font-size: 14px;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

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

.share-social-btn svg {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

/* ==================== 歡迎畫面關閉按鈕 ==================== */
.modal-content {
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #94a3b8;
  transition: all 0.2s;
  line-height: 1;
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #475569;
  transform: scale(1.1);
}

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

/* ==================== 下拉選單高優先級樣式 ==================== */
#userDropdownMenu {
  z-index: 99999 !important;
  position: fixed !important;
}

/* ==================== 手機版底部導航優化 ==================== */
nav {
  position: fixed !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  z-index: 1000 !important;
  /* 確保在大部分內容之上，但低於下拉選單 */
}

/* 確保內容不被底部導航遮擋 */
main {
  padding-bottom: 80px !important;
  /* 為底部導航留出空間 */
}

/* iOS Safari 安全區域支持 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  nav {
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom)) !important;
  }

  main {
    padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }
}

/* ==================== 管理員面板樣式 ==================== */
.admin-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  transition: all 0.2s;
  cursor: pointer;
}

.admin-tab-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.admin-tab-btn.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #2563eb;
  color: white;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2);
}

.admin-tab-btn svg {
  transition: transform 0.2s;
}

.admin-tab-btn.active svg {
  transform: scale(1.1);
}

.admin-panel {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.admin-panel.active {
  display: block;
}

.backup-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  transition: all 0.2s;
  cursor: pointer;
}

.backup-btn:hover {
  background: #f8fafc;
  border-color: #3b82f6;
  color: #3b82f6;
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.backup-btn:active {
  transform: translateY(0);
}

.backup-btn svg {
  flex-shrink: 0;
}

/* 預覽區域樣式 */
#importPreviewContent {
  font-family: "Courier New", monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 格式提示樣式 */
#formatHint {
  animation: fadeIn 0.3s ease-out;
}

/* ==================== 資料管理子選單樣式 ==================== */
.manage-subtab-btn {
  padding: 10px 12px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-weight: 600;
  color: #64748b;
  transition: all 0.2s;
  cursor: pointer;
  text-align: center;
}

.manage-subtab-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.manage-subtab-btn.active {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #059669;
  color: white;
  box-shadow: 0 2px 4px -1px rgba(5, 150, 105, 0.2);
}

.manage-content {
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.manage-content.active {
  display: block;
}

/* 資料管理表格樣式 */
.manage-content table {
  border-collapse: collapse;
  width: 100%;
}

.manage-content th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 10;
}

.manage-content tr:hover {
  background-color: #f8fafc;
}

/* 編輯/刪除按鈕樣式 */
.edit-quote-btn,
.edit-scenario-btn,
.edit-challenge-btn {
  transition: transform 0.2s;
  cursor: pointer;
}

.edit-quote-btn:hover,
.edit-scenario-btn:hover,
.edit-challenge-btn:hover {
  transform: scale(1.2);
}

.delete-quote-btn,
.delete-scenario-btn,
.delete-challenge-btn {
  transition: transform 0.2s;
  cursor: pointer;
}

.delete-quote-btn:hover,
.delete-scenario-btn:hover,
.delete-challenge-btn:hover {
  transform: scale(1.2);
}

/* ==================== 使用說明 Tab 樣式 ==================== */
.guide-tab-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background-color: #f1f5f9;
  /* slate-100 */
  color: #64748b;
  /* slate-500 */
}

.guide-tab-btn:hover {
  background-color: #e2e8f0;
  /* slate-200 */
  color: #475569;
  /* slate-600 */
}

.guide-tab-btn.bg-blue-500 {
  background-color: #3b82f6 !important;
  /* blue-500 */
  color: white !important;
  box-shadow: 0 2px 4px -1px rgba(59, 130, 246, 0.3);
}

.guide-tab-btn.bg-blue-500:hover {
  background-color: #2563eb !important;
  /* blue-600 */
}

/* 使用說明內容淡入動畫 */
.guide-content {
  animation: fadeIn 0.3s ease-out;
}

/* ==================== Toast 通知系統（XP & 金幣） ==================== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  /* 不阻擋點擊 */
}

/* 🔥 修正：加上 .toast-container 前綴，並強制重置定位，避免跟上方舊的 .toast 衝突 */
.toast-container .toast {
  position: relative;
  /* 強制改為相對定位，才能在容器內排隊 */
  top: auto;
  left: auto;
  transform: translateX(400px);
  /* 預設在右邊外面 */
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: all;
  width: auto;
  /* 讓寬度自適應 */
  margin: 0;
  /* 清除可能的外距 */
}

/* 顯示狀態 */
.toast-container .toast.toast-show {
  opacity: 1;
  transform: translateX(0);
  /* 滑進來 */
}

/* 隱藏狀態 */
.toast-container .toast.toast-hide {
  opacity: 0;
  transform: translateX(400px) scale(0.8);
}

.toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(10px);
  white-space: nowrap;
}

/* XP 通知樣式 */
.toast-xp .toast-content {
  background: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.toast-xp .toast-icon {
  font-size: 18px;
  animation: sparkle 1.5s infinite;
}

@keyframes sparkle {
  0%,
  100% {
    transform: scale(1) rotate(0deg);
  }

  50% {
    transform: scale(1.2) rotate(180deg);
  }
}

/* 金幣獲得通知樣式 */
.toast-coin-gain .toast-content {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.toast-coin-gain .toast-icon {
  font-size: 18px;
  animation: coin-bounce 0.6s ease-out;
}

@keyframes coin-bounce {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-8px) scale(1.15);
  }
}

/* 金幣消費通知樣式 */
.toast-coin-spend .toast-content {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.toast-coin-spend .toast-icon {
  font-size: 18px;
}

.toast-message {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 響應式設計 */
@media (max-width: 640px) {
  .toast-container {
    top: 60px;
    right: 10px;
    left: 10px;
    align-items: flex-end;
    /* 手機版靠右對齊 */
  }

  .toast-container .toast {
    max-width: 320px;
  }

  .toast-content {
    padding: 10px 16px;
    font-size: 13px;
    justify-content: center;
  }

  .toast-icon {
    font-size: 16px;
  }
}

/* ==================== 🛡️ 復活卡系統樣式 ==================== */

/* 復活卡容器動畫 */
.animate-pulse-subtle {
  animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.85;
    transform: scale(1.02);
  }
}

/* 補救倒數容器 */
#revivalCountdownContainer {
  animation: countdown-pulse 1.5s ease-in-out infinite;
}

@keyframes countdown-pulse {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.8;
  }
}

/* ==================== Battle Mode 緊急計時器效果 ==================== */

/* 巨型計時器基礎樣式 */
#challengeTimer {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  letter-spacing: 0.1em;
}

/* 緊急狀態 (<30秒) - 紅色脈衝效果 */
#challengeTimer.text-red-500 {
  animation: timer-urgency-pulse 0.5s ease-in-out infinite;
  text-shadow:
    0 0 20px rgba(239, 68, 68, 0.8),
    0 0 40px rgba(239, 68, 68, 0.4);
}

@keyframes timer-urgency-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.05);
    opacity: 0.9;
  }
}

/* 緊急容器震動效果 */
#challengeTimerContainer.bg-red-500\/20 {
  animation: timer-container-shake 0.3s ease-in-out infinite;
}

@keyframes timer-container-shake {
  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-2px);
  }

  75% {
    transform: translateX(2px);
  }
}

/* 復活卡彈窗動畫 */
#revivalCardModal .modal-content,
#revivalSuccessModal .modal-content,
#revivalCardAwardedModal .modal-content,
#revivalExpiredModal .modal-content {
  animation: modal-bounce-in 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modal-bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* 守護成功盾牌動畫 */
#revivalSuccessModal .text-8xl {
  animation: shield-protect 1s ease-in-out infinite;
}

@keyframes shield-protect {
  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 10px rgba(234, 179, 8, 0.5));
  }

  50% {
    transform: scale(1.1);
    filter: drop-shadow(0 0 20px rgba(234, 179, 8, 0.8));
  }
}

/* 獲得復活卡禮物動畫 */
#revivalCardAwardedModal .text-8xl {
  animation: gift-shake 0.5s ease-in-out infinite;
}

@keyframes gift-shake {
  0%,
  100% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-5deg);
  }

  75% {
    transform: rotate(5deg);
  }
}

/* 復活卡數量顯示 - 金色發光 */
#challengeRevivalCards,
#revivalCardsCount {
  text-shadow: 0 0 5px rgba(234, 179, 8, 0.5);
}

/* 挑戰頁面復活卡圖示 */
#view-challenge .text-lg.text-yellow-300 {
  transition: all 0.3s ease;
}

#view-challenge .text-lg.text-yellow-300:hover {
  transform: scale(1.1);
  text-shadow: 0 0 10px rgba(234, 179, 8, 0.8);
}

/* 補救按鈕樣式（當在補救期時，開始挑戰按鈕特殊樣式） */
.revival-mode #startChallengeBtn {
  background: linear-gradient(135deg, #f59e0b 0%, #dc2626 100%);
  animation: rescue-pulse 1.5s ease-in-out infinite;
}

@keyframes rescue-pulse {
  0%,
  100% {
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
  }

  50% {
    box-shadow: 0 4px 25px rgba(220, 38, 38, 0.6);
  }
}

/* ==================== 📈 成長曲線圖樣式 ==================== */

/* 圖表區塊 */
#growthChartSection {
  animation: fadeIn 0.3s ease-out;
}

/* 圖表容器 */
#growthChartSection .relative.h-64 {
  background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
  border-radius: 12px;
  padding: 8px;
}

/* 統計卡片動畫 */
#growthChartSection .grid > div {
  transition: all 0.2s ease;
}

#growthChartSection .grid > div:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 訪客遮罩 */
#growthChartGuestOverlay {
  animation: fadeIn 0.3s ease-out;
}

/* 統計數字動畫 */
#statTotalPractice,
#statLongestStreak,
#statCurrentLevel,
#statMonthlyXP {
  transition: all 0.3s ease;
}

/* 圖表 tooltip 樣式覆寫 */
.chartjs-tooltip {
  font-family: "Noto Sans TC", sans-serif !important;
}

/* 響應式調整 */
@media (max-width: 640px) {
  #growthChartSection {
    padding: 16px;
  }

  #growthChartSection .relative.h-64 {
    height: 200px;
  }

  #growthChartSection .grid {
    gap: 8px;
  }

  #growthChartSection .grid > div {
    padding: 8px;
  }

  #growthChartSection .grid > div .text-2xl {
    font-size: 1.25rem;
  }

  /* 圖例在手機版換行 */
  #growthChartSection .flex.flex-wrap.justify-center {
    gap: 8px;
  }
}

/* 圖表載入動畫 */
@keyframes chart-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#growthChart {
  animation: chart-fade-in 0.5s ease-out;
}

/* 里程碑標記閃爍效果 */
@keyframes milestone-glow {
  0%,
  100% {
    filter: drop-shadow(0 0 3px currentColor);
  }

  50% {
    filter: drop-shadow(0 0 8px currentColor);
  }
}

/* 本月成就摘要 */
#growthChartSection .bg-gradient-to-r.from-slate-50 {
  transition: all 0.2s ease;
}

#growthChartSection .bg-gradient-to-r.from-slate-50:hover {
  background: linear-gradient(to right, #f1f5f9, #e2e8f0);
}

/* ==================== 成就徽章系統 ==================== */

/* 徽章卡片基本樣式 */
.badge-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.badge-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 未解鎖徽章 */
.badge-card.locked {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  border-color: #cbd5e1;
}

.badge-card.locked .badge-icon {
  filter: grayscale(100%);
  opacity: 0.4;
}

.badge-card.locked .badge-name {
  color: #94a3b8;
}

/* 已解鎖徽章 */
.badge-card.unlocked {
  background: linear-gradient(135deg, #fef9c3, #fde68a);
  border-color: #fbbf24;
  box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.badge-card.unlocked::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 40%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 60%
  );
  animation: badge-shine 3s infinite;
}

@keyframes badge-shine {
  0% {
    transform: translateX(-100%) rotate(45deg);
  }

  100% {
    transform: translateX(100%) rotate(45deg);
  }
}

/* 徽章圖標 */
.badge-icon {
  font-size: 2rem;
  margin-bottom: 4px;
  transition: transform 0.3s ease;
}

.badge-card:hover .badge-icon {
  transform: scale(1.1);
}

/* 徽章名稱 */
.badge-name {
  font-size: 0.7rem;
  font-weight: 600;
  color: #475569;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 徽章進度條 */
.badge-progress {
  width: 100%;
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.badge-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #6366f1);
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* 進度文字 */
.badge-progress-text {
  font-size: 0.6rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* 解鎖標記 */
.badge-unlocked-mark {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #22c55e;
  color: white;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* 最近徽章預覽 */
.recent-badge {
  flex-shrink: 0;
  width: 60px;
  text-align: center;
  padding: 8px;
  background: linear-gradient(135deg, #fef9c3, #fde68a);
  border-radius: 12px;
  border: 2px solid #fbbf24;
}

.recent-badge-icon {
  font-size: 1.5rem;
}

.recent-badge-name {
  font-size: 0.6rem;
  color: #92400e;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.1;
}

/* 解鎖動畫 */
@keyframes achievement-unlock-pop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

#achievementUnlockModal .modal-content {
  animation: achievement-unlock-pop 0.5s ease-out;
}

/* 星星閃爍 */
@keyframes star-twinkle {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

#achievementUnlockModal .animate-ping {
  animation: star-twinkle 1s ease-in-out infinite;
}

/* 分類標題下劃線 */
.achievement-category h4 {
  padding-bottom: 8px;
  border-bottom: 2px solid #e2e8f0;
}

/* 空徽章佔位 */
.badge-card.empty {
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  cursor: default;
}

.badge-card.empty:hover {
  transform: none;
  box-shadow: none;
}

/* ==================== Gacha Flip Card Effect ==================== */
.quote-card-container {
  perspective: 1000px;
  cursor: pointer;
  min-height: 200px;
  position: relative;
  margin-bottom: 2rem;
}

.quote-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 200px;
  text-align: center;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
}

.quote-card-container.flipped .quote-card-inner {
  transform: rotateY(180deg);
}

.quote-card-front,
.quote-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  top: 0;
  left: 0;
  padding: 1.5rem;
}

.quote-card-front {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fbbf24;
  transform: rotateY(0deg);
  z-index: 2;
}

.quote-card-back {
  background: linear-gradient(to bottom right, #fffbeb, #fef3c7);
  color: #1e293b;
  transform: rotateY(180deg);
  z-index: 1;
}

/* ==================== Hide Scrollbar Utility ==================== */
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* ==================== Quick Start Cards ==================== */
.quick-start-card {
  min-width: 160px;
  height: 120px;
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  border: 2px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.quick-start-card:hover {
  border-color: #3b82f6;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.quick-start-card:active {
  transform: translateY(0);
}

.quick-start-card .card-emoji {
  font-size: 2.5rem;
  text-align: center;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.quick-start-card .card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  text-align: center;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==================== DISC Selector Buttons ==================== */
.disc-btn {
  transition: all 0.2s ease;
}

.disc-btn:hover {
  border-color: #60a5fa;
}

.disc-btn.active {
  border-color: #3b82f6;
  background: linear-gradient(to bottom, #eff6ff, #dbeafe);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.disc-btn.active span:first-child {
  transform: scale(1.1);
}

/* ==================== Advanced Form Toggle ==================== */
#advancedPracticeForm {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== Profile Hero Card ==================== */
.profile-hero-card {
  position: relative;
}

.profile-hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 50%
  );
  pointer-events: none;
}

/* ==================== Profile Segmented Control ==================== */
.profile-segmented-control {
  background: #f1f5f9;
}

.profile-tab-btn {
  color: #64748b;
  background: transparent;
}

.profile-tab-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.5);
}

.profile-tab-btn.active {
  background: white;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ==================== Leaderboard Tabs ==================== */
.leaderboard-tab {
  color: #64748b;
  background: transparent;
}

.leaderboard-tab:hover:not(.active) {
  background: rgba(255, 255, 255, 0.5);
  color: #475569;
}

.leaderboard-tab.active {
  background: white;
  color: #4f46e5;
  border-bottom-color: #4f46e5;
  box-shadow: 0 -2px 8px rgba(79, 70, 229, 0.1);
}

/* ==================== Leaderboard Items ==================== */
.leaderboard-item {
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}

.leaderboard-item:hover {
  transform: translateX(4px);
}

.leaderboard-item.rank-1 {
  background: linear-gradient(to right, #fef9c3, #fef3c7);
  border-color: #fbbf24;
}

.leaderboard-item.rank-2 {
  background: linear-gradient(to right, #f1f5f9, #e2e8f0);
  border-color: #94a3b8;
}

.leaderboard-item.rank-3 {
  background: linear-gradient(to right, #fef3e2, #fed7aa);
  border-color: #fb923c;
}

/* Rank Change Indicators */
.rank-change-up {
  color: #22c55e;
  font-weight: bold;
}

.rank-change-down {
  color: #ef4444;
  font-weight: bold;
}

.rank-change-new {
  color: #f59e0b;
}

.rank-change-same {
  color: #cbd5e1;
}

/* ==================== Radar Chart Container ==================== */
#scoringRadarChart {
  max-height: 256px;
}

/* ==================== Admin Badge Button ==================== */
#adminBadgeBtn {
  font-weight: bold;
  letter-spacing: 0.05em;
}

/* ==================== Gamification & Juice Effects ==================== */

/* === Navigation Bounce Animation === */
@keyframes nav-bounce {
  0%,
  100% {
    transform: translateY(0);
  }

  20% {
    transform: translateY(-6px);
  }

  40% {
    transform: translateY(-3px);
  }

  60% {
    transform: translateY(-5px);
  }

  80% {
    transform: translateY(-2px);
  }
}

.nav-item.active svg {
  animation: nav-bounce 0.5s ease-out;
}

/* === Page Fade-In Enhancement === */
.view-section {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

.view-section.active {
  opacity: 1;
}

/* === Enhanced Button Interactions === */
button:not(:disabled):not(.nav-item):hover {
  transform: scale(1.02);
}

button:not(:disabled):not(.nav-item):active {
  transform: scale(0.95) !important;
}

button:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

/* === Reward Icon Pulse Animation === */
@keyframes reward-icon-pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.4);
  }

  100% {
    transform: scale(1);
  }
}

.reward-icon-animating {
  animation: reward-icon-pulse 0.4s ease-out;
  display: inline-block;
}

/* === Floating Reward Text Animation === */
@keyframes float-up-fade {
  0% {
    transform: translateY(0) translateX(-50%) scale(1);
    opacity: 1;
  }

  100% {
    transform: translateY(-80px) translateX(-50%) scale(0.8);
    opacity: 0;
  }
}

.floating-reward {
  position: fixed;
  font-weight: bold;
  font-size: 28px;
  pointer-events: none;
  z-index: 9999999;
  animation: float-up-fade 1.2s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.floating-reward.coins {
  color: #eab308;
  text-shadow: 0 2px 8px rgba(234, 179, 8, 0.5);
}

.floating-reward.xp {
  color: #8b5cf6;
  text-shadow: 0 2px 8px rgba(139, 92, 246, 0.5);
}

.floating-reward.streak {
  color: #f97316;
  text-shadow: 0 2px 8px rgba(249, 115, 22, 0.5);
}

/* === XP Bar Gold State (>90%) === */
@keyframes gold-pulse {
  0%,
  100% {
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
  }

  50% {
    box-shadow: 0 0 20px rgba(251, 191, 36, 0.8);
  }
}

.xp-bar-gold {
  background: linear-gradient(to right, #fbbf24, #f59e0b) !important;
  animation: gold-pulse 1.5s ease-in-out infinite;
}

/* === Leaderboard Enhancements === */
.leaderboard-item.current-user {
  background: linear-gradient(to right, #dbeafe, #bfdbfe) !important;
  border: 2px solid #3b82f6 !important;
  animation: highlight-pulse 2s ease-in-out infinite;
}

@keyframes highlight-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.15);
  }
}

/* Medal Styles */
.medal {
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.medal-glow {
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.6));
}

/* Rank Change Indicators */
.rank-change {
  font-size: 0.75rem;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.rank-up {
  color: #22c55e;
}

.rank-down {
  color: #ef4444;
}

.rank-same {
  color: #94a3b8;
}

/* === Streak Milestone Enhancements === */
.streak-milestone {
  position: relative;
  transition: all 0.3s ease;
}

.streak-milestone.achieved {
  transform: scale(1.05);
}

.streak-milestone.achieved::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: linear-gradient(45deg, #fbbf24, #f97316);
  opacity: 0.3;
  z-index: -1;
  animation: milestone-glow 2s ease-in-out infinite;
}

@keyframes milestone-glow {
  0%,
  100% {
    opacity: 0.2;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(1.05);
  }
}

/* 🎁 Gift Receive Overlay Animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Connecting Lines Between Milestones */
.streak-milestones-container {
  position: relative;
}

.streak-milestone-line {
  position: absolute;
  top: 50%;
  height: 3px;
  background: linear-gradient(to right, #d1d5db, #9ca3af);
  transform: translateY(-50%);
  z-index: 0;
}

.streak-milestone-line.achieved {
  background: linear-gradient(to right, #fbbf24, #f97316);
}

/* === CountUp Animation Helper === */
.countup-animating {
  display: inline-block;
  transition: transform 0.1s ease-out;
}

/* === Victory Confetti Enhancement === */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 99997;
}

/* canvas-confetti 動態產生的 canvas 不應攔截觸控事件 (iOS 修正) */
body > canvas {
  pointer-events: none !important;
}

/* === Performance Optimizations === */
.floating-reward,
.nav-item svg,
#xpBar,
.reward-icon-animating,
.streak-milestone {
  will-change: transform, opacity;
}

/* === Reduced Motion Support === */
@media (prefers-reduced-motion: reduce) {
  .nav-item.active svg,
  .floating-reward,
  .reward-icon-animating,
  .xp-bar-gold,
  .leaderboard-item.current-user,
  .streak-milestone.achieved::before {
    animation: none !important;
  }

  .view-section {
    transition: none !important;
  }

  button:not(:disabled):hover,
  button:not(:disabled):active {
    transform: none !important;
  }
}

/* ==================== 隱藏 Modal 捲軸 (美化行動版體驗) ==================== */
/* 隱藏 Chrome, Safari, Edge 的捲軸 */
.modal-overlay::-webkit-scrollbar,
.modal-content::-webkit-scrollbar,
.modal-content *::-webkit-scrollbar {
  display: none;
}

/* 隱藏 Firefox, IE 的捲軸 */
.modal-overlay,
.modal-content,
.modal-content * {
  -ms-overflow-style: none;
  /* IE and Edge */
  scrollbar-width: none;
  /* Firefox */
}

/* ─── PWA 安裝按鈕 tooltip 箭頭 ─── */
#pwaInstallBtn > span:last-child::after {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #1e293b;
}

/* 已安裝 (standalone) 模式下隱藏安裝按鈕 */
@media all and (display-mode: standalone) {
  #pwaInstallCard {
    display: none !important;
  }
}

/* ==================== PWA 安裝按鈕 (黑金流光特效) ==================== */

/* 定義流光動畫關鍵影格 (不變) */
@keyframes shine {
  0% {
    background-position: 200% center;
  }
  100% {
    background-position: -200% center;
  }
}

/* 按鈕本體樣式 */
.btn-shine-effect {
  /* 設定背景漸層：透明 -> 金色光芒 -> 透明 */
  background-image: linear-gradient(
    120deg,
    transparent 0%,
    transparent 40%,
    rgba(250, 204, 21, 0.8) 50%,
    /* 流光亮度增強 */ transparent 60%,
    transparent 100%
  );
  background-size: 200% auto;
  transition: all 0.3s ease;

  /* ★★★ 這裡改成黑色背景 ★★★ */
  background-color: rgba(0, 0, 0, 0.6); /* 半透明黑色，保留一點玻璃感 */
  /* 如果想要純黑不透明，請改成 background-color: #000000; */

  /* 邊框維持金色，對比黑色會很明顯 */
  border: 1px solid rgba(250, 204, 21, 0.5);
  color: #fde047; /* text-yellow-300 */
}

/* 滑鼠懸停 (Hover) 時的特效 */
.btn-shine-effect:hover {
  animation: shine 1.5s ease-in-out infinite; /* 啟動流光動畫 */

  /* ★★★ 懸停時加深為純黑 ★★★ */
  background-color: #000000;

  /* 金色外發光暈增強 */
  box-shadow: 0 0 15px rgba(250, 204, 21, 0.6);
  border-color: #facc15; /* 邊框變亮黃色 */
  transform: translateY(-1px);
}

/* 點擊時的效果 */
.btn-shine-effect:active {
  transform: scale(0.95);
  box-shadow: none;
}

/* ==================== 🔴 每日任務小紅點系統 ==================== */
/* 父元素定位基準 */
.red-dot-target {
  position: relative !important;
}

/* 紅點本體 */
.red-dot-badge {
  position: absolute;
  top: -2px; /* 稍微調整位置，掛在右上角 */
  right: -2px;
  width: 12px; /* 紅點大小 */
  height: 12px;
  background-color: #ef4444; /* 鮮紅色 */
  border: 2px solid white; /* 加個白邊，比較精緻 */
  border-radius: 50%; /* 圓形 */
  z-index: 50; /* 確保浮在最上面 */
  pointer-events: none; /* 讓紅點「穿透」，不會擋住你按按鈕 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  /* animation: red-dot-pulse 2s infinite; 已移除動畫，改為靜態顯示 */
}

/* 針對導覽列 (Nav) 的特殊微調 - 強制定位在圖示右上角 */
button.nav-item .red-dot-badge {
  top: 6px; /* 垂直：距離頂部一點點 */
  right: auto; /* 取消靠右對齊 (很重要！) */
  left: 50%; /* 水平：先移動到按鈕正中心 */
  margin-left: 6px; /* 水平：再往右推 6px (剛好掛在圖示肩膀上) */
}

/* 針對卡片 (Card) 的特殊微調 */
.quote-card-container .red-dot-badge,
#lobbyDailyChallengeCard .red-dot-badge {
  top: 10px;
  right: 10px;
  width: 14px;
  height: 14px;
}

/* 呼吸燈動畫：讓紅點像心跳一樣收縮，吸引注意力 */
@keyframes red-dot-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    transform: scale(1.2); /* 稍微變大 */
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); /* 散開的光暈 */
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

/* ==================== 🔴 紅點位置微調 (針對投餵紅包) ==================== */
#giftMenuBtn .red-dot-badge {
  right: auto !important; /* 取消預設的「靠右對齊」 */
  left: 36px !important; /* 強制「靠左」 (36px 大約是禮物圖示的右上角) */
  top: 10px !important; /* 稍微往上調整 */
}

/* ==================== 📚 精選好文卡片 ==================== */
.article-card {
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 8px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* ============ 🎮 手遊風召喚按鈕 (Royal Blue Style - 皇家藍版) ============= */
.gacha-btn {
  position: relative;
  /* 背景：皇家藍漸層 (從亮寶藍 -> 深海藍) */
  /* 這種藍色非常襯托黃色/金色的 Emoji */
  background: linear-gradient(to bottom, #3b82f6 0%, #1d4ed8 50%, #172554 100%);

  /* 邊框：冰藍色光暈，增加層次感 */
  border: 2px solid #bfdbfe;
  border-bottom-width: 4px; /* 3D 厚度 */

  /* 陰影：深海軍藍底座 + 藍色發光 */
  box-shadow:
    0 4px 0px #0f172a,
    /* 深色立體底座 */ 0 6px 15px rgba(37, 99, 235, 0.5),
    /* 藍色光暈 */ inset 0 1px 0 rgba(255, 255, 255, 0.3); /* 頂部高光 */

  border-radius: 50px;

  /* 文字顏色：純白 */
  color: #ffffff;
  font-weight: 800;
  text-shadow: 0 2px 0px rgba(0, 0, 0, 0.3);

  padding: 12px 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  cursor: pointer;
  overflow: hidden;

  /* 寬度控制 (維持您覺得剛好的寬度) */
  width: auto;
  min-width: 260px;
  margin: 0 auto;
}

/* 滑鼠移過：提亮 */
.gacha-btn:hover {
  /* 變成更亮的寶藍色 */
  background: linear-gradient(to bottom, #60a5fa 0%, #2563eb 50%, #1e40af 100%);
  transform: translateY(-2px);
  box-shadow:
    0 6px 0px #0f172a,
    0 8px 25px rgba(59, 130, 246, 0.6),
    /* 光暈變強 */ inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

/* 按下時：下沉 */
.gacha-btn:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
  box-shadow:
    0 2px 0px #0f172a,
    0 4px 10px rgba(30, 64, 175, 0.4),
    inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 讓裡面的 Emoji 稍微放大 */
.gacha-btn span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ==================== 企業儀表板分頁 (Phase 8) ==================== */
.dashboard-tab-btn {
  color: #64748b;
  background-color: transparent;
  cursor: pointer;
}

.dashboard-tab-btn:hover {
  color: #334155;
}

.dashboard-tab-btn.active {
  background-color: white;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dashboard-panel {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 時間熱力圖樣式 */
.heatmap-cell {
  transition: all 0.2s ease;
  cursor: pointer;
}

.heatmap-cell:hover {
  transform: scale(1.1);
  z-index: 10;
}

.heatmap-level-0 {
  background-color: #f1f5f9;
}

.heatmap-level-1 {
  background-color: #dbeafe;
}

.heatmap-level-2 {
  background-color: #93c5fd;
}

.heatmap-level-3 {
  background-color: #3b82f6;
  color: white;
}

.heatmap-level-4 {
  background-color: #1e40af;
  color: white;
}

.heatmap-level-5 {
  background-color: #1e3a8a;
  color: white;
}

/* 成員選擇器 */
.member-selector-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 9999px;
  background-color: white;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.member-selector-chip:hover {
  border-color: #cbd5e1;
  background-color: #f8fafc;
}

.member-selector-chip.selected {
  border-color: #6366f1;
  background-color: #eef2ff;
  color: #4f46e5;
}

.member-selector-chip.selected .checkmark {
  display: inline-block;
}
