/* ==========================================================================
   長安二十 夢想奔馳｜3D 島嶼網站樣式表
   視覺風格：卡通童趣、黑體（清楚大字體）、低多邊形活力感
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS 變數與三組主題色（晴空、雲朵、星夜）
   -------------------------------------------------------------------------- */
:root {
  /* 基礎字體大小：適中優雅、清晰易讀 */
  --font-base: 15px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.18);

  --transition-fast: 0.18s ease;
  --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 主題 1：晴空 (Sky) - 預設 */
html[data-theme="sky"] {
  --bg: #eaf4fb;
  --surface: #ffffff;
  --surface-trans: rgba(255, 255, 255, 0.92);
  --ink: #19324d;
  --ink-secondary: #4a6582;
  --line: #cde2f2;
  --primary: #2c6db5;
  --primary-hover: #1e5594;
  --primary-light: #e3effa;
  --accent: #f29c20;
  --accent-light: #fff3dc;
  --card-bg: #f5f9fc;
  --badge-bg: #e1effc;
  --bubble-bg: #ffffff;
}

/* 主題 2：雲朵 (Cloud) */
html[data-theme="cloud"] {
  --bg: #f7f9fb;
  --surface: #ffffff;
  --surface-trans: rgba(255, 255, 255, 0.94);
  --ink: #223344;
  --ink-secondary: #566879;
  --line: #dbe4ec;
  --primary: #3b7cb8;
  --primary-hover: #2b6294;
  --primary-light: #eaf2f8;
  --accent: #ea9b24;
  --accent-light: #fef5e7;
  --card-bg: #f9fbfd;
  --badge-bg: #eaf1f7;
  --bubble-bg: #ffffff;
}

/* 主題 3：星夜 (Night) */
html[data-theme="night"] {
  --bg: #121c2e;
  --surface: #1a273e;
  --surface-trans: rgba(26, 39, 62, 0.92);
  --ink: #eaf2fb;
  --ink-secondary: #a4b9cf;
  --line: #2b3e5e;
  --primary: #4e94e0;
  --primary-hover: #69a8ee;
  --primary-light: #203554;
  --accent: #f8c35d;
  --accent-light: #3d3420;
  --card-bg: #152033;
  --badge-bg: #233654;
  --bubble-bg: #1c2b44;
}

/* --------------------------------------------------------------------------
   全域基礎重設
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 全域隱藏規則，防止被 class 的 display 覆蓋 */
[hidden] {
  display: none !important;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  font-size: var(--font-base);
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* 無障礙跳過連結 */
.skip-link {
  position: absolute;
  top: -100px;
  left: 20px;
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  z-index: 99999;
  text-decoration: none;
  font-weight: 700;
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: 20px;
}

/* --------------------------------------------------------------------------
   3D 畫布與全螢幕容器
   -------------------------------------------------------------------------- */
#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
}

/* --------------------------------------------------------------------------
   頂部工具導航列（高質感、緊湊防擠壓、適中字體）
   -------------------------------------------------------------------------- */
.top-nav {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 8px 16px;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none; /* 穿透點擊，內部元件個別啟用 pointer-events */
  box-sizing: border-box;
}

.top-nav > * {
  pointer-events: auto;
}

/* 左側：校名與活動標題（嚴禁擠壓換行） */
.nav-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-trans);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  white-space: nowrap;
}

.brand-mascot {
  font-size: 1.5rem;
  cursor: pointer;
  display: inline-block;
  transition: transform var(--transition-fast);
}
.brand-mascot:hover {
  transform: scale(1.15) rotate(8deg);
}

.brand-text {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--ink-secondary);
  font-weight: 500;
  white-space: nowrap;
}

/* 中間控制列：時鐘、晝夜、主題 */
.nav-center {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-trans);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  white-space: nowrap;
}

.clock-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  padding-right: 8px;
  border-right: 1px solid var(--line);
  white-space: nowrap;
}

.daynight-controls, .theme-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.daynight-controls {
  padding-right: 8px;
  border-right: 1px solid var(--line);
}

.dn-btn {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 32px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dn-btn:hover {
  background: var(--primary-light);
}
.dn-btn.active {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm);
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-size: 0.8rem;
  font-weight: 700;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 30px;
}
.theme-btn:hover {
  background: var(--primary-light);
}
.theme-btn.active {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.theme-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.1);
}

/* 右側功能工具按鈕 */
.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

.nav-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  background: var(--surface-trans);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  min-height: 36px;
  white-space: nowrap;
}
.nav-tool-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.nav-tool-btn .badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: var(--radius-full);
}

.player-badge {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.player-badge .player-lvl {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

/* --------------------------------------------------------------------------
   視角控制浮動按鈕（改置於左下角，避開右下角 Netlify 徽章）
   -------------------------------------------------------------------------- */
.floating-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.float-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  background: var(--surface-trans);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
  min-height: 44px;
}
.float-btn:hover {
  background: var(--primary);
  color: #fff;
  transform: scale(1.04);
}

/* --------------------------------------------------------------------------
   3D 浮動島嶼標籤
   -------------------------------------------------------------------------- */
#labels-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 55; /* 高於 top-nav (50)，低於 side-panel (60) 與 modal (100) */
  overflow: hidden;
}

.island-3d-label {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-trans);
  backdrop-filter: blur(8px);
  border: 2px solid var(--primary);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  transition: transform var(--transition-fast), background var(--transition-fast);
  user-select: none;
}
.island-3d-label:hover {
  background: var(--primary);
  color: #ffffff;
  transform: translate(-50%, -115%) scale(1.1);
  z-index: 30;
}
.island-3d-label .label-order {
  background: var(--primary);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}
.island-3d-label:hover .label-order {
  background: #fff;
  color: var(--primary);
}
.island-3d-label.center-label {
  border-color: var(--accent);
  background: var(--accent-light);
  font-weight: 900;
}
.island-3d-label.center-label .label-order {
  background: var(--accent);
}

/* --------------------------------------------------------------------------
   對話泡泡 (NPC & 居民)
   -------------------------------------------------------------------------- */
#bubble-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 70;
}

.resident-bubble {
  position: absolute;
  transform: translate(-50%, -120%);
  pointer-events: auto;
  background: var(--bubble-bg);
  color: var(--ink);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  min-width: 260px;
  font-size: 1rem;
  line-height: 1.5;
  animation: bubblePop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.resident-bubble::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 10px 10px 0;
  border-style: solid;
  border-color: var(--primary) transparent;
  display: block;
  width: 0;
}

@keyframes bubblePop {
  0% { transform: translate(-50%, -90%) scale(0.7); opacity: 0; }
  100% { transform: translate(-50%, -120%) scale(1); opacity: 1; }
}

.bubble-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.bubble-name {
  font-weight: 900;
  color: var(--primary);
  font-size: 1.05rem;
}
.bubble-role {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  background: var(--card-bg);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.bubble-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--ink-secondary);
  padding: 2px 6px;
}
.bubble-text {
  margin-bottom: 12px;
  font-size: 1.05rem;
}
.bubble-actions {
  display: flex;
  gap: 8px;
}
.bubble-btn {
  flex: 1;
  padding: 8px 10px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--card-bg);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 42px;
}
.bubble-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.bubble-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.bubble-btn.primary:hover {
  background: var(--primary-hover);
}

#main-content {
  position: relative;
  z-index: 100; /* 高於 top-nav (70)，確保抽屜滑出時在最前層，絕不受頂部按鈕重疊或攔截點擊 */
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   側邊抽屜面板 (Side Panel)
   桌機右側覆蓋滑出（z-index 高於導航列，確保內容乾淨不重疊）/ 手機底部抽屜
   -------------------------------------------------------------------------- */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 440px;
  max-width: 100vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -6px 0 28px rgba(0, 0, 0, 0.16);
  z-index: 100; /* 高於頂部導覽列 (70)，確保抽屜滑出時絕不受頂部按鈕重疊干擾 */
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  overflow: hidden;
  pointer-events: auto;
}

.side-panel.open,
.side-panel:not([hidden]) {
  transform: translateX(0) !important;
}

.panel-header {
  padding: 12px 20px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card-bg);
  flex-shrink: 0;
}

.panel-badge-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-category {
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}
.badge-stamp-status {
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--card-bg);
  color: var(--ink-secondary);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}
.badge-stamp-status.stamped {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

.panel-close-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-secondary);
  border-radius: 50%;
  transition: all var(--transition-fast);
}
.panel-close-btn:hover {
  background: var(--line);
  color: var(--ink);
}

.panel-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.3;
}

.panel-intro {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink-secondary);
  line-height: 1.55;
}

.info-card {
  background: var(--card-bg);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}
.info-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-secondary);
  margin-bottom: 2px;
}
.info-card-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.content-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
}

.points-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.points-list li {
  position: relative;
  padding-left: 20px;
  font-size: 0.92rem;
  line-height: 1.55;
}
.points-list li::before {
  content: "✔";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary);
  font-weight: 900;
  font-size: 0.85rem;
}

/* NPC 區塊 */
.npc-section {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.npc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.npc-avatar {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}
.npc-meta {
  display: flex;
  flex-direction: column;
}
.npc-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}
.npc-role {
  font-size: 0.82rem;
  color: var(--ink-secondary);
}

.npc-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.npc-act-btn {
  flex: 1;
  min-width: 95px;
  padding: 7px 10px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 44px;
}
.npc-act-btn:hover {
  background: var(--primary-hover);
  color: #fff;
}
.npc-act-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.npc-act-btn.primary:hover {
  background: #d88612;
}

.npc-dialogue-box {
  margin-top: 14px;
  background: var(--surface);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  border: 1px dashed var(--primary);
  animation: fadeIn 0.2s ease;
}

/* 交易區塊 */
.trade-box {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.trade-flow {
  display: flex;
  align-items: center;
  justify-content: space-around;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 8px 0;
}
.trade-arrow {
  color: var(--accent);
  font-size: 1.4rem;
}
.trade-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
}
.trade-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
}
.trade-btn:disabled {
  background: var(--line);
  color: var(--ink-secondary);
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   地點清單面板
   -------------------------------------------------------------------------- */
.schedule-container {
  background: var(--card-bg);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}
.schedule-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
}
.schedule-timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.timeline-item {
  position: relative;
  padding-left: 20px;
  border-left: 3px solid var(--primary);
}
.timeline-time {
  font-size: 0.95rem;
  font-weight: 900;
  color: var(--accent);
}
.timeline-name {
  font-size: 1.1rem;
  font-weight: 700;
}
.timeline-desc {
  font-size: 0.95rem;
  color: var(--ink-secondary);
}

.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 6px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 40px;
}
.filter-btn:hover {
  background: var(--primary-light);
}
.filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.island-cards-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.island-card-item {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.island-card-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}
.card-desc {
  font-size: 1rem;
  color: var(--ink-secondary);
}

/* --------------------------------------------------------------------------
   背包面板
   -------------------------------------------------------------------------- */
.backpack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.backpack-slot {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.slot-icon {
  font-size: 2.2rem;
}
.slot-name {
  font-size: 0.95rem;
  font-weight: 700;
}
.slot-qty {
  font-size: 0.85rem;
  font-weight: 900;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.trade-chain-info {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.trade-chain-list {
  padding-left: 20px;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   護照面板與集章
   -------------------------------------------------------------------------- */
.adventurer-stat-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.adv-avatar {
  font-size: 2.6rem;
  width: 60px;
  height: 60px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.adv-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.adv-name {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--ink);
}
.adv-level-bar {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}
.exp-progress-track {
  width: 100%;
  height: 10px;
  background: var(--line);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 4px;
}
.exp-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.4s ease;
}

.stamps-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.stamps-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.stamps-progress-text {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent);
}

.stamps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stamp-slot {
  aspect-ratio: 1;
  background: var(--card-bg);
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  gap: 4px;
  transition: all var(--transition-fast);
}
.stamp-slot.stamped {
  border: 2px solid var(--accent);
  background: var(--accent-light);
}
.stamp-icon {
  font-size: 2rem;
  filter: grayscale(100%) opacity(0.35);
  transition: all var(--transition-fast);
}
.stamp-slot.stamped .stamp-icon {
  filter: none;
  transform: rotate(-8deg) scale(1.15);
}
.stamp-name {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.2;
}

.final-challenge-card {
  background: var(--card-bg);
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.final-challenge-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.final-icon {
  font-size: 2.2rem;
}
.final-meta h4 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}
.final-meta p {
  font-size: 0.95rem;
  color: var(--ink-secondary);
}

.code-transfer-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.code-row {
  display: flex;
  gap: 8px;
}
.code-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  background: var(--surface);
}
.code-actions {
  display: flex;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   通用按鈕樣式
   -------------------------------------------------------------------------- */
.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
}
.primary-btn:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}
.primary-btn:disabled {
  background: var(--line);
  color: var(--ink-secondary);
  cursor: not-allowed;
}

.secondary-btn {
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.secondary-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.danger-btn {
  background: #fbeae8;
  color: #d93829;
  border: 1px solid #f2b8b3;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 44px;
}
.danger-btn:hover {
  background: #d93829;
  color: #fff;
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--ink-secondary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 8px 12px;
}
.text-btn:hover {
  color: var(--ink);
  text-decoration: underline;
}

.full-btn {
  width: 100%;
}
.large-btn {
  font-size: 1.2rem;
  padding: 14px 28px;
}

/* --------------------------------------------------------------------------
   彈窗模態框 (Modals)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] {
  display: none !important;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  animation: modalEnter 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-mascot-pic {
  font-size: 3.5rem;
  text-align: center;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--primary);
  text-align: center;
  line-height: 1.3;
}
.modal-subtitle {
  font-size: 1.1rem;
  color: var(--ink-secondary);
  text-align: center;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--ink);
}
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 1.1rem;
  background: var(--card-bg);
  transition: border-color var(--transition-fast);
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.avatar-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.avatar-option {
  cursor: pointer;
  display: block;
}
.avatar-option input[type="radio"] {
  position: absolute;
  opacity: 0;
}
.avatar-card {
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition-fast);
  background: var(--card-bg);
}
.avatar-option input:checked + .avatar-card {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: var(--shadow-sm);
}
.avatar-preview-icon {
  font-size: 2.2rem;
}
.avatar-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
}
.avatar-desc {
  font-size: 0.9rem;
  color: var(--ink-secondary);
  margin-left: auto;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

/* --------------------------------------------------------------------------
   看展挑戰 (Quiz Modal)
   -------------------------------------------------------------------------- */
.quiz-card {
  max-width: 620px;
}
.quiz-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.quiz-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 900;
  padding: 4px 12px;
  border-radius: var(--radius-full);
}
.quiz-progress-text {
  font-weight: 800;
  color: var(--accent);
}
.modal-close-icon {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--ink-secondary);
  padding: 4px 8px;
}

.quiz-question-text {
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.4;
  margin-bottom: 20px;
  color: var(--ink);
}

.quiz-options-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.quiz-opt-btn {
  background: var(--card-bg);
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}
.quiz-opt-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.quiz-opt-btn.correct {
  border-color: #2e7d32;
  background: #e8f5e9;
  color: #1b5e20;
}
.quiz-opt-btn.wrong {
  border-color: #c62828;
  background: #ffebee;
  color: #b71c1c;
}
.quiz-opt-btn:disabled {
  cursor: default;
}

.quiz-feedback-box {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  border-left: 4px solid var(--primary);
  animation: fadeIn 0.2s ease;
}
.feedback-status {
  font-size: 1.2rem;
  font-weight: 900;
  margin-bottom: 4px;
}
.feedback-explain {
  font-size: 1.05rem;
  color: var(--ink-secondary);
}

.quiz-footer {
  display: flex;
  justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   獎勵氣泡提示 (Reward Toast)
   -------------------------------------------------------------------------- */
.reward-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-full);
  padding: 12px 24px;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: slideDownToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.reward-toast[hidden] {
  display: none !important;
}
@keyframes slideDownToast {
  0% { transform: translate(-50%, -30px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}
.reward-icon {
  font-size: 2rem;
}
.reward-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--accent);
}
.reward-desc {
  font-size: 0.95rem;
  color: var(--ink);
}

/* 撿貝殼小 Toast */
#toast-container {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pickup-toast {
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 700;
  animation: popFade 1.8s forwards;
}
@keyframes popFade {
  0% { transform: translateY(10px); opacity: 0; }
  20% { transform: translateY(0); opacity: 1; }
  80% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-20px); opacity: 0; }
}

/* --------------------------------------------------------------------------
   榮譽證書彈窗 (Certificate)
   -------------------------------------------------------------------------- */
.cert-card {
  max-width: 860px;
}
.cert-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.cert-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.cert-canvas-wrap {
  width: 100%;
  background: #f0f0f0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
}
#cert-canvas {
  max-width: 100%;
  height: auto;
  display: block;
}
.cert-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.cert-disclaimer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-secondary);
  margin-top: 10px;
}

/* --------------------------------------------------------------------------
   小嚮導面板樣式
   -------------------------------------------------------------------------- */
.guide-intro-box {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.guide-mascot-pic {
  font-size: 2.6rem;
}
.guide-search-row {
  display: flex;
  gap: 8px;
}
.guide-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  background: var(--card-bg);
}
.guide-input:focus {
  outline: none;
  border-color: var(--primary);
}
.guide-quick-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.quick-tag {
  background: var(--card-bg);
  border: 1px solid var(--line);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.quick-tag:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}
.guide-results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.guide-qa-card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
}
.qa-answer {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--ink);
}
.qa-source {
  font-size: 0.9rem;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

/* --------------------------------------------------------------------------
   說明面板
   -------------------------------------------------------------------------- */
.help-item {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}
.help-item h4 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 8px;
}
.help-item p {
  font-size: 1rem;
  line-height: 1.6;
}

/* --------------------------------------------------------------------------
   WebGL 失敗降級備用版
   -------------------------------------------------------------------------- */
.webgl-fallback {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.fallback-card {
  max-width: 600px;
  background: var(--surface);
  padding: 36px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--primary);
  text-align: center;
}
.fallback-card h2 {
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 14px;
}
.fallback-card p {
  font-size: 1.1rem;
  margin-bottom: 24px;
}

/* --------------------------------------------------------------------------
   動態與動畫
   -------------------------------------------------------------------------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* 支援 prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   RWD 自適應排版（桌機、平板、手機）
   -------------------------------------------------------------------------- */
@media (max-width: 1150px) {
  .brand-subtitle {
    display: none; /* 中型螢幕隱藏副標題，確保頂部橫排清爽不擠壓 */
  }
  .nav-center .theme-controls {
    display: none; /* 中型螢幕簡化中間主題按鈕，改以日夜光影為主 */
  }
}

@media (max-width: 850px) {
  .clock-display {
    display: none; /* 小平板隱藏時鐘文字 */
  }
  .nav-tool-btn .label {
    display: none; /* 僅顯示圖示與數字徽章 */
  }
}

@media (max-width: 768px) {
  :root {
    --font-base: 14px;
  }

  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  .top-nav {
    flex-wrap: wrap;
    align-items: center;
    padding: 6px 10px;
    gap: 6px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow: hidden;
  }
  
  .nav-left {
    display: flex;
    align-items: center;
  }

  .brand {
    padding: 4px 8px;
    gap: 6px;
  }
  .brand-title {
    font-size: 0.95rem;
  }
  .brand-subtitle {
    display: none;
  }

  .nav-right {
    display: flex;
    margin-left: auto;
    align-items: center;
    gap: 4px;
  }

  .player-badge #player-name-display {
    display: none; /* 手機端隱藏暱稱文字，保留圖示與等級 */
  }

  .nav-tool-btn .label {
    display: none; /* 手機端只顯示圖示與數字 */
  }
  .nav-tool-btn {
    padding: 6px 8px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  .nav-center {
    order: 3;
    width: 100%;
    justify-content: center;
    padding: 3px 8px;
    gap: 4px;
  }

  /* 手機端側邊面板改成「底部抽屜面板」 */
  .side-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 80vh;
    border-left: none;
    border-top: 2px solid var(--line);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    z-index: 100;
  }
  .side-panel.open,
  .side-panel:not([hidden]) {
    transform: translateY(0) !important;
  }

  .floating-controls {
    bottom: 16px;
    left: 16px;
  }

  .stamps-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .resident-bubble {
    max-width: 88vw;
    min-width: 240px;
  }
}
