/* ==========================================================================
   社交小超人群島大冒險 (IsleForge 3D Island Game) 樣式表
   通用學習設計 (UDL) · 特教無障礙 · 柔和低刺激配色 · RPG 冒險架構
   ========================================================================== */

:root {
  --primary: #06b6d4;
  --primary-dark: #0891b2;
  --primary-light: #cffafe;
  --secondary: #3b82f6;
  --secondary-dark: #1d4ed8;
  --accent: #f59e0b;
  --accent-gold: #fbbf24;
  --success: #10b981;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --bg-cream: #f6f0e4;
  --bg-sea: #dcebee;
  --bg-night: #0f172a;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --card-bg: rgba(255, 255, 255, 0.95);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
  --radius-full: 9999px;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Chalkboard SE", "Comic Sans MS", "PingFang TC", "Noto Sans TC", system-ui, -apple-system, sans-serif;
  color: var(--text-dark);
  background-color: var(--bg-cream);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  user-select: none;
  transition: background-color 0.4s ease;
}

body.theme-cream { background-color: #f6f0e4; }
body.theme-sea { background-color: #dcebee; }
body.theme-night { background-color: #0f172a; color: #f8fafc; }

/* 頂部導覽列 */
.game-topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
  border-bottom: 2px solid #fde68a;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.08);
  gap: 12px;
}

body.theme-night .game-topbar {
  background: rgba(15, 23, 42, 0.95);
  border-bottom-color: #334155;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  min-width: 0;
}

.brand-logo {
  font-size: 1.8rem;
  line-height: 1;
  animation: floatEmoji 3s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes floatEmoji {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.brand-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.brand-info h1 {
  font-size: 1.05rem;
  font-weight: 900;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}

body.theme-night .brand-info h1 {
  color: #f8fafc;
}

.brand-info h1 .badge-isleforge {
  font-size: 0.72rem;
  background: #cffafe;
  color: #0891b2;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 800;
  border: 1px solid #67e8f9;
  white-space: nowrap;
}

.brand-info p {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 2px 0 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-night .brand-info p {
  color: #94a3b8;
}

.top-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

/* 晝夜主題切換鈕 */
.theme-switch-group {
  display: flex;
  background: rgba(0,0,0,0.06);
  padding: 3px;
  border-radius: var(--radius-full);
  gap: 2px;
}

body.theme-night .theme-switch-group {
  background: rgba(255,255,255,0.1);
}

.btn-theme-pill {
  padding: 5px 10px;
  border-radius: var(--radius-full);
  border: none;
  font-size: 0.78rem;
  font-weight: 800;
  background: transparent;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

body.theme-night .btn-theme-pill {
  color: #cbd5e1;
}

.btn-theme-pill.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body.theme-night .btn-theme-pill.active {
  background: #3b82f6;
  color: #ffffff;
}

/* 遊戲通用按鈕 */
.c-game-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 800;
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 0 #cbd5e1;
  white-space: nowrap;
  flex-shrink: 0;
}

.c-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 0 #94a3b8;
}

.c-game-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

body.theme-night .c-game-btn {
  background: #1e293b;
  color: #f8fafc;
  border-color: #475569;
  box-shadow: 0 2px 0 #334155;
}

.c-game-btn.btn-passport {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #ffffff;
  border-color: #0284c7;
  box-shadow: 0 2px 0 #075985;
}

.c-game-btn.btn-savecode {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border-color: #f59e0b;
  box-shadow: 0 2px 0 #b45309;
}

.c-game-btn.btn-citadel {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #ffffff;
  border-color: #8b5cf6;
  box-shadow: 0 2px 0 #5b21b6;
}

.c-game-btn.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #ffffff;
  border-color: #06b6d4;
  box-shadow: 0 2px 0 #0e7490;
}

.c-game-btn.btn-accent {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border-color: #10b981;
  box-shadow: 0 2px 0 #047857;
}

/* ==========================================================================
   RPG 頂部 HUD 狀態列 (HUD Bar)
   ========================================================================== */
.rpg-hud-bar {
  position: absolute;
  top: 76px;
  left: 20px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: var(--radius-xl);
  border: 2px solid #fde68a;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
  pointer-events: auto;
}

body.theme-night .rpg-hud-bar {
  background: rgba(15, 23, 42, 0.92);
  border-color: #334155;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.hud-hero-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding-right: 12px;
  border-right: 1.5px solid #e2e8f0;
}

body.theme-night .hud-hero-badge {
  border-right-color: #334155;
}

.hud-avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #fef3c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  border: 2px solid #f59e0b;
  box-shadow: 0 3px 8px rgba(245, 158, 11, 0.25);
}

.hud-hero-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-name {
  font-size: 0.98rem;
  font-weight: 900;
  color: #0f172a;
}

body.theme-night .hud-name {
  color: #f8fafc;
}

.hud-lv-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 1px 8px;
  border-radius: var(--radius-full);
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #c4b5fd;
}

.hud-exp-track {
  width: 120px;
  height: 6px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  overflow: hidden;
}

body.theme-night .hud-exp-track {
  background: #334155;
}

.hud-exp-fill {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.hud-exp-text {
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 700;
}

.hud-stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-full);
  font-size: 0.86rem;
  font-weight: 800;
  color: #1e293b;
  transition: transform 0.2s ease;
}

.hud-stat-pill:hover {
  transform: scale(1.04);
}

body.theme-night .hud-stat-pill {
  background: #1e293b;
  border-color: #475569;
  color: #f8fafc;
}

/* 3D 畫布主舞台 */
#stage {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  cursor: grab;
}

#stage:active {
  cursor: grabbing;
}

#threeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* 3D 浮動標籤圖層 */
#labelLayer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  transition: opacity 0.25s ease;
}

body.modal-open #labelLayer,
body.modal-open #moveHint,
body.modal-open #virtualDpad {
  opacity: 0 !important;
  pointer-events: none !important;
  display: none !important;
}

.island-3d-label {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 900;
  color: #0f172a;
  border: 2px solid #fde68a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.island-3d-label:hover {
  transform: translate(-50%, -55%) scale(1.08);
  border-color: #06b6d4;
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
}

.island-3d-label.center {
  background: linear-gradient(135deg, #ede9fe, #ffffff);
  border-color: #a78bfa;
  color: #5b21b6;
}

/* 操作指示提示條 */
.view-hints {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.84rem;
  font-weight: 800;
  color: #334155;
  border: 1.5px solid #cbd5e1;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  pointer-events: none;
  z-index: 30;
}

body.theme-night .view-hints {
  background: rgba(15, 23, 42, 0.9);
  color: #cbd5e1;
  border-color: #334155;
}

/* 虛擬方向鍵 (Virtual D-Pad for Mobile & Touch Screen) */
.virtual-dpad {
  position: absolute;
  bottom: 30px;
  left: 24px;
  width: 140px;
  height: 140px;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .virtual-dpad {
    display: none; /* 大螢幕桌機自動隱藏，使用 WASD / 點擊 */
  }
}

.dpad-btn {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 900;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: all 0.1s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.dpad-btn:active {
  background: #06b6d4;
  color: #ffffff;
  border-color: #0891b2;
  transform: scale(0.92);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; font-size: 0.8rem; background: #e2e8f0; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* 底部島嶼資訊 HUD 卡片 */
.game-hud {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 35;
  pointer-events: none;
}

.hud-card {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 2px solid #fde68a;
  border-radius: var(--radius-xl);
  padding: 16px 24px;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.15);
  display: flex;
  align-items: center;
  gap: 20px;
  animation: slideUp 0.3s ease;
}

body.theme-night .hud-card {
  background: rgba(15, 23, 42, 0.95);
  border-color: #334155;
}

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

.hud-island-title h2 {
  font-size: 1.25rem;
  font-weight: 900;
  color: #0f172a;
}

body.theme-night .hud-island-title h2 {
  color: #f8fafc;
}

.hud-mascot-pill {
  font-size: 0.78rem;
  font-weight: 800;
  color: #0891b2;
  background: #cffafe;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.hud-island-desc {
  font-size: 0.85rem;
  color: #475569;
  max-width: 380px;
  line-height: 1.45;
}

body.theme-night .hud-island-desc {
  color: #94a3b8;
}

.hud-actions {
  display: flex;
  gap: 10px;
}

/* ==========================================================================
   關卡冒險抽屜 (Quest Drawer Modal)
   ========================================================================== */
.quest-drawer-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  z-index: 200;
  display: none;
}

.quest-drawer-overlay.active {
  display: block !important;
}

.quest-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(680px, 100vw);
  background: #ffffff !important;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: drawerSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerSlideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  padding: 16px 24px;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-island-badge {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0891b2;
  background: #cffafe;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  display: inline-block;
  margin-bottom: 4px;
}

.drawer-title {
  font-size: 1.35rem;
  font-weight: 900;
  color: #0f172a;
}

.drawer-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #e2e8f0;
  color: #475569;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.drawer-close-btn:hover {
  background: #ef4444;
  color: #ffffff;
}

.weeks-carousel {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: thin;
}

.week-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s ease;
}

.week-chip:hover {
  border-color: #06b6d4;
  color: #0891b2;
}

.week-chip.active {
  background: #06b6d4;
  color: #ffffff;
  border-color: #0891b2;
  box-shadow: 0 3px 8px rgba(6, 182, 212, 0.35);
}

.week-chip.passed::after {
  content: " ⭐";
}

.drawer-body {
  background: #ffffff !important;
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.drawer-footer {
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quest-reward-hint {
  font-size: 0.88rem;
  font-weight: 800;
  color: #d97706;
}

/* NPC 對話卡 */
.npc-dialog-card {
  background: linear-gradient(135deg, #fefce8 0%, #fffbeb 100%);
  border: 2px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
}

.npc-avatar {
  font-size: 2.8rem;
  flex-shrink: 0;
  background: #ffffff;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fde68a;
}

.npc-content {
  flex: 1;
}

.npc-name-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.npc-name-tag span {
  font-size: 1rem;
  font-weight: 900;
  color: #b45309;
}

.tts-inline-btn {
  font-size: 0.78rem;
  font-weight: 800;
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tts-inline-btn:hover {
  background: #f59e0b;
  color: #ffffff;
}

.npc-speech {
  font-size: 1rem;
  line-height: 1.7;
  color: #334155;
  font-weight: 600;
}

/* CBT 抉擇卡 */
.cbt-choice-section {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 20px;
}

.cbt-choice-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 14px;
}

.cbt-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cbt-card {
  background: #ffffff;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cbt-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.cbt-card.card-impulsive:hover {
  border-color: #ef4444;
  background: #fef2f2;
}

.cbt-card.card-superskill:hover {
  border-color: #10b981;
  background: #f0fdf4;
}

.cbt-card-header {
  font-size: 0.95rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.card-impulsive .cbt-card-header { color: #dc2626; }
.card-superskill .cbt-card-header { color: #059669; }

.cbt-card-desc {
  font-size: 0.84rem;
  color: #64748b;
  line-height: 1.5;
}

.cbt-result-box {
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
  display: none;
}

.cbt-result-box.impulsive-active {
  display: block;
  background: #fee2e2;
  color: #991b1b;
  border: 1.5px solid #f87171;
}

.cbt-result-box.super-active {
  display: block;
  background: #dcfce7;
  color: #166534;
  border: 1.5px solid #4ade80;
}

/* 主題小遊戲區域 */
.minigame-container {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 20px;
}

.minigame-title {
  font-size: 1.05rem;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 14px;
}

.turtle-breathe-box {
  text-align: center;
  padding: 24px;
  background: #f0fdf4;
  border-radius: var(--radius-md);
  border: 2px solid #bbf7d0;
}

.breathe-circle {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: #22c55e;
  color: #ffffff;
  font-size: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
  transition: transform 3s ease-in-out;
}

.breathe-circle.inhale {
  transform: scale(1.6);
  background: #06b6d4;
  box-shadow: 0 0 30px rgba(6, 182, 212, 0.6);
}

.breathe-circle.exhale {
  transform: scale(0.9);
  background: #10b981;
}

.breathe-prompt {
  font-size: 1.05rem;
  font-weight: 900;
  color: #15803d;
  margin-bottom: 14px;
  min-height: 28px;
}

.imsg-puzzle-box {
  background: #eff6ff;
  border-radius: var(--radius-md);
  padding: 16px;
  border: 2px solid #bfdbfe;
}

.imsg-slot {
  padding: 10px 14px;
  background: #ffffff;
  border: 1.5px solid #93c5fd;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 800;
  color: #1e3a8a;
  cursor: pointer;
  transition: all 0.2s ease;
}

.imsg-slot.selected {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1d4ed8;
  transform: translateX(6px);
}

.highfive-game-box {
  text-align: center;
  padding: 20px;
  background: #fdf2f8;
  border-radius: var(--radius-md);
  border: 2px solid #fbcfe8;
}

.highfive-hand-btn {
  font-size: 4rem;
  cursor: pointer;
  display: inline-block;
  margin: 12px 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.highfive-hand-btn:hover {
  transform: scale(1.2) rotate(10deg);
}

.gear-game-box {
  text-align: center;
  padding: 20px;
  background: #faf5ff;
  border-radius: var(--radius-md);
  border: 2px solid #e9d5ff;
}

.gear-icon {
  font-size: 3.5rem;
  display: inline-block;
  margin: 10px 0;
  transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   冒險者護照 Modal (Passport Booklet)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.78);
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex !important;
}

.passport-book-card {
  width: min(720px, 100%);
  max-height: 90vh;
  background: #ffffff !important;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
  from { transform: scale(0.96); }
  to { transform: scale(1); }
}

.passport-header {
  padding: 18px 24px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.passport-header h3 {
  font-size: 1.3rem;
  font-weight: 900;
}

.passport-header p {
  font-size: 0.82rem;
  opacity: 0.9;
}

.passport-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: #fafaf9;
}

.passport-id-card {
  background: #ffffff;
  border: 2px solid #e7e5e4;
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  gap: 20px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.passport-photo-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.passport-avatar {
  width: 72px;
  height: 72px;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 18px;
  font-size: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.25);
}

.passport-level-tag {
  font-size: 0.78rem;
  font-weight: 900;
  background: #ede9fe;
  color: #6d28d9;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.passport-info-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.info-row {
  display: flex;
  flex-direction: column;
}

.info-label {
  font-size: 0.75rem;
  color: #78716c;
  font-weight: 700;
}

.info-val {
  font-size: 0.95rem;
  font-weight: 900;
  color: #1c1917;
}

.stamps-section {
  background: #ffffff;
  border: 2px solid #e7e5e4;
  border-radius: var(--radius-lg);
  padding: 18px;
}

.stamps-title {
  font-size: 1rem;
  font-weight: 900;
  color: #1c1917;
  margin-bottom: 14px;
}

.stamps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 640px) {
  .stamps-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.stamp-slot {
  aspect-ratio: 1;
  border: 2px dashed #d6d3d1;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f4;
  position: relative;
  overflow: hidden;
}

.stamp-seal {
  width: 90%;
  height: 90%;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  transition: all 0.3s ease;
  transform: rotate(-8deg);
}

.stamp-seal.unlocked {
  opacity: 1;
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.05);
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.2);
  transform: rotate(-12deg) scale(1.05);
}

.stamp-seal.seal-comm.unlocked {
  border-color: #3b82f6;
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.05);
  transform: rotate(8deg) scale(1.05);
}

.stamp-seal.seal-friend.unlocked {
  border-color: #10b981;
  color: #10b981;
  background: rgba(16, 185, 129, 0.05);
  transform: rotate(-5deg) scale(1.05);
}

.stamp-seal.seal-flex.unlocked {
  border-color: #8b5cf6;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.05);
  transform: rotate(10deg) scale(1.05);
}

.seal-icon { font-size: 1.8rem; }
.seal-name { font-size: 0.72rem; font-weight: 900; margin-top: 2px; }
.seal-status { font-size: 0.65rem; font-weight: 800; }

.passport-footer {
  padding: 14px 24px;
  background: #f5f5f4;
  border-top: 1px solid #e7e5e4;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   接關碼 Modal (Save Code Modal)
   ========================================================================== */
.savecode-card {
  width: min(520px, 100%);
  background: #ffffff !important;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0,0,0,0.25);
  animation: zoomIn 0.3s ease;
}

.savecode-header {
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1.5px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.savecode-header h3 {
  font-size: 1.15rem;
  font-weight: 900;
  color: #0f172a;
}

.savecode-body {
  padding: 20px;
}

/* ==========================================================================
   建立冒險者 Dialog (Start / Customization Dialog)
   ========================================================================== */
.start-dialog {
  margin: auto;
  border: none;
  border-radius: var(--radius-xl);
  padding: 0;
  width: min(560px, 94vw);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  background: #ffffff;
}

.start-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.start-dialog-content {
  padding: 28px 24px;
}

.start-dialog-header {
  text-align: center;
  margin-bottom: 20px;
}

.start-dialog-header h2 {
  font-size: 1.45rem;
  font-weight: 900;
  color: #0f172a;
  margin-top: 6px;
}

.start-dialog-header p {
  font-size: 0.88rem;
  color: #64748b;
  margin-top: 4px;
}

.start-form-group {
  margin-bottom: 20px;
}

.start-form-group label {
  font-size: 0.9rem;
  font-weight: 800;
  color: #334155;
  display: block;
  margin-bottom: 6px;
}

.preset-name-pill {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  font-size: 0.78rem;
  font-weight: 800;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-name-pill:hover {
  background: #06b6d4;
  color: #ffffff;
  border-color: #06b6d4;
}

.look-selection-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.look-card {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 2px solid #e2e8f0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.2s ease;
}

.look-card:hover {
  border-color: #06b6d4;
  transform: translateY(-2px);
}

.look-card.active {
  border-color: #06b6d4;
  background: #cffafe;
  box-shadow: 0 4px 12px rgba(6, 182, 212, 0.25);
}

.look-avatar { font-size: 2.2rem; margin-bottom: 4px; }
.look-name { font-size: 0.92rem; font-weight: 900; color: #0f172a; }
.look-desc { font-size: 0.72rem; color: #64748b; margin-top: 2px; }

.start-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ==========================================================================
   中央英豪總部與證書 Modal
   ========================================================================== */
.modal-citadel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 250;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-citadel-overlay.active {
  display: flex !important;
}

.citadel-card {
  width: min(740px, 100%);
  max-height: 92vh;
  background: #ffffff !important;
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  position: relative;
}

.citadel-header {
  padding: 18px 24px;
  background: linear-gradient(135deg, #7c3aed 0%, #4338ca 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.citadel-header h2 {
  font-size: 1.35rem;
  font-weight: 900;
}

.citadel-body {
  padding: 24px;
  overflow-y: auto;
  background: #ffffff;
}

.citadel-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-box {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
}

.stat-val {
  font-size: 1.5rem;
  font-weight: 900;
  color: #6d28d9;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: #64748b;
  margin-top: 4px;
}

.certificate-preview-box {
  border: 6px double #f59e0b;
  border-radius: 16px;
  padding: 28px 24px;
  background: #fffdf5;
  text-align: center;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
  position: relative;
}

.cert-emblem { font-size: 3rem; margin-bottom: 6px; }
.cert-title { font-size: 1.5rem; font-weight: 900; color: #b45309; margin-bottom: 12px; }

.cert-input-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.15rem;
  font-weight: 900;
  margin-bottom: 14px;
}

.cert-name-input {
  border: none;
  border-bottom: 2px solid #b45309;
  background: transparent;
  font-size: 1.25rem;
  font-weight: 900;
  color: #78350f;
  text-align: center;
  outline: none;
  padding: 2px 8px;
}

.cert-text {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #451a03;
  margin-bottom: 20px;
  font-weight: 600;
}

.cert-footer-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 800;
  color: #92400e;
  border-top: 1px dashed #fcd34d;
  padding-top: 14px;
}

/* ==========================================================================
   2D 全地圖模式
   ========================================================================== */
#map2DView {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: #f8fafc;
  z-index: 25;
  overflow-y: auto;
  padding: 32px 24px 80px;
  display: none;
}

#map2DView.active {
  display: block;
}

.islands-2d-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.island-2d-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-2d-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1.5px solid #f1f5f9;
}

.card-2d-icon { font-size: 2rem; }
.card-2d-title h3 { font-size: 1.15rem; font-weight: 900; color: #0f172a; }
.card-2d-title span { font-size: 0.78rem; color: #64748b; font-weight: 700; }

.weeks-2d-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
}

.week-2d-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 0.86rem;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}

.week-2d-item:hover {
  background: #06b6d4;
  color: #ffffff;
}

.week-2d-item.passed {
  border-left: 4px solid #10b981;
}

/* ==========================================================================
   特效圖層 (Confetti, Level Up, Toast)
   ========================================================================== */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 150;
}

.levelup-banner {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
  color: #ffffff;
  padding: 24px 44px;
  border-radius: var(--radius-xl);
  box-shadow: 0 15px 40px rgba(239, 68, 68, 0.4);
  text-align: center;
  z-index: 140;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 3px solid #ffffff;
}

.levelup-banner.active {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.levelup-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.levelup-sub {
  font-size: 1.15rem;
  font-weight: 800;
  margin-top: 6px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  padding: 10px 22px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 800;
  z-index: 130;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.toast.active {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* 響應式優化 */
@media (max-width: 900px) {
  .game-topbar { padding: 0 12px; }
  .brand-info h1 { font-size: 0.98rem; }
  .brand-info p { display: none; }
  .rpg-hud-bar { top: 70px; left: 12px; padding: 6px 12px; }
  .hud-avatar { width: 36px; height: 36px; font-size: 1.4rem; }
  .hud-exp-track { width: 80px; }
}

.quest-practice-step{display:block;width:100%;text-align:left;white-space:normal;background:#fffdf5;color:#254a3a;border:2px solid #adc29b;border-radius:10px;padding:12px;margin:8px 0;font:inherit;line-height:1.6;cursor:pointer}.quest-practice-step[aria-pressed=true]{background:#deefd2;border-color:#49823a}.minigame-container details{margin-top:16px}#completeLessonPractice{font:inherit;background:#326346;color:white;border:0;border-radius:10px;padding:12px;cursor:pointer;line-height:1.5}#completeLessonPractice:disabled{background:#d7ded1;color:#56604f;cursor:default}#questPracticeStatus{font-size:.9rem;line-height:1.6}
body.island-dialog-open{overflow:hidden}
