* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-main: #f4ecd8;
  --bg-paper: rgba(255, 248, 229, 0.92);
  --bg-accent: #8b6b45;
  --bg-accent-dark: #6f5437;
  --text-main: #3d2d1f;
  --text-soft: #6e5943;
  --border-color: rgba(74, 54, 37, 0.25);
  --shadow-soft: 0 8px 20px rgba(60, 40, 20, 0.12);
  --shadow-map-ui: 0 10px 28px rgba(60, 40, 20, 0.16);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(circle at top, rgba(255, 247, 227, 0.72), transparent 35%),
    linear-gradient(to bottom, #e9dcc1, #f6eedc);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

.app-shell {
  min-height: 100vh;
}

.main-content {
  width: 100%;
  padding: 16px 20px 24px;
}

/* 左上角按鈕 */
.menu-toggle {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--bg-accent);
  color: white;
  cursor: pointer;
  font-size: 1rem;
  transition: 0.25s;
}

.menu-toggle:hover {
  background: var(--bg-accent-dark);
  transform: scale(1.04);
}

/* 遮罩 */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(30, 20, 10, 0.16);
  backdrop-filter: blur(1px);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* 側邊欄 */
.sidebar {
  width: 300px;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  overflow: hidden;
  padding: 30px 22px 30px 34px;
  border-right: 1px solid rgba(98, 74, 48, 0.16);
  box-shadow: 18px 0 36px rgba(60, 40, 20, 0.16);
  background:
    linear-gradient(to bottom, rgba(231, 214, 182, 0.98), rgba(205, 178, 136, 0.97)),
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 2px,
      rgba(0, 0, 0, 0.012) 3px,
      rgba(0, 0, 0, 0.012) 5px
    );
  transform-origin: left top;
  transform: perspective(1200px) rotateY(-12deg) scaleX(0.16) scaleY(0.08) translateX(-26px);
  opacity: 0;
  clip-path: inset(0 0 100% 0 round 0 22px 22px 0);
  filter: saturate(0.88) brightness(0.96);
  transition:
    transform 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    clip-path 1.15s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.42s ease,
    filter 0.7s ease;
}

.sidebar.show {
  transform: perspective(1200px) rotateY(0deg) scaleX(1) scaleY(1) translateX(0);
  opacity: 1;
  clip-path: inset(0 0 0 0 round 0 22px 22px 0);
  filter: saturate(1) brightness(1);
}

.sidebar::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 100%;
  background: linear-gradient(
    to right,
    rgba(80, 55, 30, 0.18),
    rgba(80, 55, 30, 0.05),
    transparent
  );
  pointer-events: none;
  z-index: 1;
}

.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: -18px;
  width: 30px;
  height: 100%;
  background: radial-gradient(circle at left center, rgba(78, 51, 24, 0.18), transparent 72%);
  pointer-events: none;
  z-index: 1;
}

.sidebar-inner {
  position: relative;
  width: 100%;
  height: 100%;
  padding-top: 22px;
  padding-bottom: 26px;
}

.sidebar-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(89, 62, 34, 0.12), transparent 42%),
    linear-gradient(to bottom, rgba(255,255,255,0.05), transparent 18%, transparent 82%, rgba(80, 55, 30, 0.04));
  pointer-events: none;
  z-index: 0;
}

.sidebar-inner::after {
  content: "";
  position: absolute;
  top: 10px;
  left: -8px;
  right: -10px;
  bottom: 12px;
  border-radius: 22px 18px 18px 0;
  background:
    radial-gradient(circle at left center, rgba(92, 61, 31, 0.18), transparent 34%),
    linear-gradient(to right, rgba(255, 250, 237, 0.18), transparent 18%, transparent 82%, rgba(119, 84, 44, 0.08));
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 231, 0.35),
    inset 0 -1px 0 rgba(102, 70, 40, 0.12);
  pointer-events: none;
  z-index: 1;
}

.sidebar::before,
.sidebar::after {
  transition:
    transform 1.05s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.5s ease;
}

.sidebar .logo-box,
.sidebar .side-nav {
  opacity: 0;
  transform: translateY(-24px) scaleY(0.88);
  transform-origin: center top;
  transition:
    opacity 0.45s ease,
    transform 0.9s cubic-bezier(0.23, 1, 0.32, 1);
  position: relative;
  z-index: 3;
}

.sidebar.show .logo-box,
.sidebar.show .side-nav {
  opacity: 1;
  transform: translateY(0) scaleY(1);
}

.sidebar .logo-box {
  transition-delay: 0.22s;
}

.sidebar .side-nav {
  transition-delay: 0.34s;
}

.logo-box {
  margin-bottom: 34px;
}

.logo-title {
  font-size: 1.9rem;
  letter-spacing: 1px;
  margin-bottom: 6px;
  color: var(--text-main);
}

.logo-subtitle {
  color: var(--text-soft);
  font-size: 0.96rem;
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.side-nav::before,
.side-nav::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 6px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(to right, #8a6438, #c9a067, #7f5a31);
  box-shadow:
    0 3px 8px rgba(70, 46, 23, 0.16),
    inset 0 1px 0 rgba(255, 239, 207, 0.38);
  z-index: 4;
  transform: scaleX(0.4);
  opacity: 0;
  transition:
    transform 0.8s cubic-bezier(0.23, 1, 0.32, 1),
    opacity 0.35s ease;
}

.side-nav::before {
  top: -12px;
  transform-origin: left center;
}

.side-nav::after {
  bottom: -16px;
  transform-origin: left center;
}

.sidebar.show .side-nav::before,
.sidebar.show .side-nav::after {
  transform: scaleX(1);
  opacity: 1;
}

.nav-btn {
  border: none;
  background:
    linear-gradient(to right, rgba(252, 244, 224, 0.96), rgba(242, 229, 199, 0.9));
  color: var(--text-main);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  text-align: left;
  font-size: 1rem;
  cursor: pointer;
  transition:
    transform 0.3s ease,
    background 0.3s ease,
    box-shadow 0.3s ease,
    opacity 0.45s ease;
  box-shadow:
    inset 0 0 0 1px rgba(120, 90, 60, 0.08),
    inset 0 10px 16px rgba(255, 252, 242, 0.28),
    0 8px 18px rgba(80, 55, 30, 0.08);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-18px) scaleY(0.72);
  transform-origin: center top;
}

.nav-btn::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.18), transparent 24%, transparent 76%, rgba(126, 93, 57, 0.06)),
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.03) 0,
      rgba(255, 255, 255, 0.03) 2px,
      rgba(122, 84, 44, 0.02) 3px,
      rgba(122, 84, 44, 0.02) 5px
    );
  pointer-events: none;
}

.sidebar.show .nav-btn {
  opacity: 1;
  transform: translateY(0) scaleY(1);
}

.sidebar.show .nav-btn:nth-child(1) {
  transition-delay: 0.42s;
}

.sidebar.show .nav-btn:nth-child(2) {
  transition-delay: 0.5s;
}

.sidebar.show .nav-btn:nth-child(3) {
  transition-delay: 0.58s;
}

.sidebar.show .nav-btn:nth-child(4) {
  transition-delay: 0.66s;
}

.sidebar.show .nav-btn:nth-child(5) {
  transition-delay: 0.74s;
}

.sidebar.show .nav-btn:nth-child(6) {
  transition-delay: 0.82s;
}

.sidebar.show .nav-btn:nth-child(7) {
  transition-delay: 0.9s;
}

.nav-btn:hover {
  background: rgba(255, 248, 229, 0.78);
  transform: translateX(6px);
  box-shadow:
    inset 0 0 0 1px rgba(120, 90, 60, 0.08),
    inset 0 10px 16px rgba(255, 252, 242, 0.35),
    0 12px 22px rgba(80, 55, 30, 0.12);
}

.nav-btn.active {
  background: linear-gradient(to right, #8e6a40, #9c774a);
  color: #fff;
  box-shadow:
    inset 0 0 0 1px rgba(255, 234, 196, 0.08),
    inset 0 10px 18px rgba(255, 230, 184, 0.08),
    0 12px 20px rgba(80, 55, 30, 0.18);
}

.question-bank-layout {
  display: grid;
  gap: 22px;
}

/* 確保 hidden 屬性不被 display:grid 覆蓋 */
[hidden] {
  display: none !important;
}

.question-progress-panel,
.question-quiz-panel {
  padding: 22px;
}

.question-progress-head,
.question-quiz-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.question-quiz-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-color);
}

.question-progress-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.question-progress-title {
  display: block;
  font-size: 1.1rem;
}

.question-progress-text,
.question-current-count {
  color: var(--text-soft);
  font-size: 0.95rem;
}

.question-progress-track {
  width: 100%;
  height: 12px;
  margin-top: 16px;
  border-radius: 999px;
  background: rgba(139, 107, 69, 0.14);
  overflow: hidden;
}

.question-progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(to right, #8f6a3d, #c49b63);
  transition: width 0.35s ease;
}

.question-bank-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 22px;
}

.question-bank-stat {
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(to bottom right, rgba(255, 248, 230, 0.88), rgba(240, 226, 193, 0.74));
  border: 1px solid rgba(125, 93, 56, 0.14);
}

.question-bank-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

.question-bank-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.question-card {
  padding: 24px;
}

.question-card h3 {
  margin: 14px 0 10px;
  font-size: 1.18rem;
}

.question-card p {
  color: var(--text-soft);
  line-height: 1.7;
}

.question-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(139, 107, 69, 0.14);
  color: var(--bg-accent-dark);
  font-size: 0.88rem;
}

.question-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  color: var(--text-soft);
}

.question-start-btn {
  flex-shrink: 0;
}

.question-quiz-title {
  margin: 16px 0 10px;
  font-size: 1.3rem;
}

.question-quiz-desc {
  color: var(--text-soft);
  line-height: 1.7;
  margin-bottom: 18px;
}

.question-quiz-options {
  display: grid;
  gap: 12px;
}

.question-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(125, 93, 56, 0.14);
  background: linear-gradient(to bottom right, rgba(255, 248, 230, 0.9), rgba(240, 226, 193, 0.7));
  cursor: pointer;
}

.question-option input {
  margin-top: 4px;
  accent-color: var(--bg-accent);
}

.question-option span {
  line-height: 1.6;
}

.question-quiz-textarea {
  width: 100%;
  border: 1px solid rgba(125, 93, 56, 0.2);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 250, 239, 0.88);
  color: var(--text-main);
  resize: vertical;
  min-height: 150px;
  font: inherit;
}

.question-quiz-feedback {
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: 16px;
  line-height: 1.7;
}

.question-quiz-feedback strong {
  display: block;
  margin-bottom: 6px;
}

.question-quiz-feedback.is-correct {
  background: rgba(102, 145, 88, 0.14);
  border: 1px solid rgba(102, 145, 88, 0.24);
}

.question-quiz-feedback.is-review {
  background: rgba(173, 127, 68, 0.14);
  border: 1px solid rgba(173, 127, 68, 0.24);
}

.question-quiz-feedback.is-pending {
  background: rgba(139, 107, 69, 0.12);
  border: 1px solid rgba(139, 107, 69, 0.2);
}

/* 上方列 */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 20px;
  border-radius: 24px;
  background: rgba(255, 248, 229, 0.72);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-soft);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-right {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.profile-btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--bg-accent);
  color: white;
  cursor: pointer;
}

.page-path,
.user-name {
  color: var(--text-soft);
  font-size: 0.95rem;
}

.auth-entry-actions,
.auth-user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.is-hidden {
  display: none !important;
}

/* 分頁 */
.page-section {
  display: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.active-page {
  display: block;
  opacity: 1;
}

/* 共用 */
.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-soft);
}

.paper-panel {
  background: var(--bg-paper);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.paper-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, 0.018) 0px,
      rgba(255, 255, 255, 0.018) 2px,
      rgba(0, 0, 0, 0.01) 3px,
      rgba(0, 0, 0, 0.01) 4px
    );
  pointer-events: none;
}

/* 按鈕 */
.primary-btn,
.secondary-btn,
.favorite-btn,
.tab-btn {
  border: none;
  cursor: pointer;
  transition: 0.25s;
}

.primary-btn {
  background: var(--bg-accent);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
}

.primary-btn:hover {
  background: var(--bg-accent-dark);
}

.secondary-btn {
  background: rgba(139, 107, 69, 0.12);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(139, 107, 69, 0.25);
}

.secondary-btn:hover {
  background: rgba(139, 107, 69, 0.2);
}

.small-btn {
  padding: 10px 14px;
  font-size: 0.92rem;
}

/* 首頁地球主視覺 */
.home-globe-stage {
  position: relative;
  width: 100%;
  height: calc(100vh - 110px);
  min-height: 560px;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
}

#home-page .paper-panel {
  background: transparent;
  border: none;
  box-shadow: none;
}

#home-page .paper-panel::after {
  display: none;
}

#globeContainer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#globeContainer canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.home-globe-overlay {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  z-index: 5;
}

/* =========================
   開始探索按鈕：放大／透明／呼吸效果
========================= */

.home-explore-btn,
#startExploreBtn {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #574123;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 18px 28px;
  border-radius: 999px;
  text-shadow:
    0 0 10px rgba(255, 245, 225, 0.35),
    0 0 22px rgba(255, 230, 190, 0.22);
  animation: exploreBreathing 2.4s ease-in-out infinite;
  transition: transform 0.25s ease, opacity 0.25s ease, text-shadow 0.25s ease;
}

.home-explore-btn:hover,
#startExploreBtn:hover {
  background: transparent !important;
  transform: scale(1.06);
  text-shadow:
    0 0 14px rgba(255, 245, 225, 0.5),
    0 0 28px rgba(255, 230, 190, 0.32);
}

.home-explore-btn:active,
#startExploreBtn:active {
  transform: scale(0.98);
}

@keyframes exploreBreathing {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.82;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

/* 地圖頁 */
#map-page {
  height: calc(100vh - 120px);
  min-height: 620px;
}

.map-stage {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 30px;
  overflow: hidden;
  background: rgba(244, 236, 216, 0.55);
  box-shadow: inset 0 0 0 1px rgba(120, 90, 60, 0.08);
}

.map-stage::before,
.map-stage::after {
  content: "";
  position: absolute;
  inset: -8%;
  pointer-events: none;
  z-index: 1;
}

.map-stage::before {
  background:
    radial-gradient(circle at 22% 28%, rgba(255, 244, 210, 0.28), transparent 26%),
    radial-gradient(circle at 76% 34%, rgba(212, 182, 124, 0.18), transparent 28%),
    radial-gradient(circle at 58% 72%, rgba(255, 245, 220, 0.16), transparent 32%);
  animation: mapGlowShift 14s ease-in-out infinite alternate;
}

.map-stage::after {
  background:
    linear-gradient(to bottom, rgba(255, 249, 235, 0.12), transparent 28%, transparent 72%, rgba(92, 64, 34, 0.08)),
    radial-gradient(circle at center, transparent 48%, rgba(64, 42, 20, 0.08) 100%);
}

/* 可拖曳世界層 */
.map-world-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
}

.map-world-layer:active {
  cursor: grabbing;
}

/* 真正會移動的地圖容器 */
.map-world {
  --map-x: 0px;
  --map-y: 0px;
  --map-scale: 1;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2000px;
  height: 1000px;
  transform:
    translate(calc(-50% + var(--map-x)), calc(-50% + var(--map-y)))
    scale(var(--map-scale));
  transform-origin: center center;
  user-select: none;
  animation: mapWorldDrift 18s ease-in-out infinite;
}

.map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  filter: contrast(1.05) brightness(1.05) saturate(0.95);
}

.continent-layer-group {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.continent-layer {
  position: absolute;
  border: none;
  background:
    linear-gradient(135deg, rgba(190, 129, 72, 0.2), rgba(121, 82, 43, 0.46));
  opacity: 0;
  transform: scale(0.94);
  filter: drop-shadow(0 0 0 rgba(0, 0, 0, 0));
  transition:
    opacity 0.26s ease,
    transform 0.28s ease,
    filter 0.28s ease,
    box-shadow 0.28s ease;
  pointer-events: auto;
  cursor: pointer;
}

.continent-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid rgba(255, 244, 213, 0.5);
  opacity: 0;
  transition: opacity 0.24s ease;
}

.continent-layer:hover,
.continent-layer.active-continent {
  opacity: 1;
  transform: scale(1);
  filter: drop-shadow(0 12px 20px rgba(88, 50, 24, 0.26));
}

.continent-layer:hover::before,
.continent-layer.active-continent::before {
  opacity: 1;
}

.continent-layer.north-america {
  left: 5%;
  top: 11%;
  width: 27%;
  height: 22%;
  clip-path: polygon(3% 39%, 8% 24%, 18% 12%, 31% 6%, 45% 4%, 58% 7%, 68% 12%, 78% 20%, 87% 28%, 95% 40%, 98% 50%, 95% 58%, 88% 64%, 80% 66%, 73% 70%, 65% 73%, 55% 77%, 44% 83%, 33% 86%, 22% 83%, 14% 73%, 8% 61%, 5% 49%);
}

.continent-layer.europe {
  left: 46.3%;
  top: 18.4%;
  width: 10.8%;
  height: 8.4%;
  clip-path: polygon(4% 58%, 10% 39%, 18% 24%, 31% 12%, 46% 8%, 60% 10%, 72% 16%, 83% 26%, 91% 39%, 94% 50%, 90% 60%, 81% 67%, 71% 73%, 58% 77%, 45% 77%, 33% 73%, 22% 69%, 13% 65%, 7% 63%);
}

.continent-layer.asia {
  left: 53.2%;
  top: 10.8%;
  width: 35.8%;
  height: 25.5%;
  clip-path: polygon(2% 42%, 6% 27%, 13% 16%, 23% 9%, 35% 5%, 48% 4%, 60% 5%, 71% 8%, 81% 13%, 90% 20%, 96% 29%, 99% 39%, 98% 49%, 94% 57%, 89% 62%, 84% 66%, 81% 72%, 80% 79%, 74% 86%, 64% 90%, 55% 89%, 49% 83%, 42% 77%, 35% 73%, 28% 73%, 22% 76%, 15% 74%, 9% 66%, 5% 56%, 3% 48%);
}

.continent-layer.africa {
  left: 46.2%;
  top: 29.8%;
  width: 13.2%;
  height: 28.8%;
  clip-path: polygon(28% 4%, 41% 3%, 53% 6%, 64% 13%, 73% 24%, 79% 36%, 81% 48%, 79% 59%, 75% 68%, 69% 77%, 62% 86%, 54% 94%, 46% 100%, 37% 96%, 30% 88%, 24% 79%, 20% 67%, 17% 55%, 15% 43%, 16% 31%, 20% 18%);
}

.continent-layer.south-america {
  left: 22.1%;
  top: 43.5%;
  width: 9.4%;
  height: 31.5%;
  clip-path: polygon(31% 2%, 43% 5%, 55% 11%, 64% 19%, 71% 31%, 73% 42%, 70% 52%, 65% 61%, 60% 69%, 59% 77%, 61% 85%, 57% 93%, 49% 100%, 40% 97%, 33% 90%, 27% 80%, 23% 68%, 20% 56%, 19% 44%, 20% 31%, 17% 18%);
}

.continent-layer.oceania {
  left: 79.2%;
  top: 57.2%;
  width: 11.4%;
  height: 12.8%;
  clip-path: polygon(5% 48%, 12% 35%, 23% 25%, 37% 20%, 52% 19%, 67% 23%, 80% 30%, 91% 40%, 97% 50%, 97% 59%, 91% 66%, 81% 71%, 69% 75%, 56% 79%, 42% 80%, 29% 77%, 18% 71%, 10% 61%);
}

/* 淡霧感 */
.map-world::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at center, rgba(255, 250, 240, 0.15), rgba(255, 240, 220, 0.05) 60%, transparent 100%);
  pointer-events: none;
}

.map-world::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 35%, rgba(255, 255, 255, 0.08), transparent 18%),
    radial-gradient(circle at 68% 48%, rgba(255, 243, 211, 0.12), transparent 20%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: mapLightSweep 12s ease-in-out infinite;
}

/* 動畫層 */
.map-animation-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.war-path {
  fill: none;
  stroke: rgba(130, 50, 40, 0.78);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 12 10;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 8px rgba(147, 76, 56, 0.22));
  animation: warPathFlow 2.8s linear infinite;
  display: none;
}

.demo-hidden {
  opacity: 0;
}

.map-stage.is-animated .demo-hidden {
  opacity: 0;
}

/* 固定 UI 層*/
.map-ui-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
} 

.map-ui-layer > * {
  pointer-events: auto;
} 

/* 浮動卡 */
.map-top-ui,
.map-event-card,
.map-timeline-bar {
  box-shadow: var(--shadow-map-ui);
  backdrop-filter: blur(4px);
}

/* 左上卡片 */
.map-top-ui {
  position: absolute;
  top: 24px;
  left: 24px;
  padding: 18px 20px;
  min-width: 280px;
}

.map-top-ui h3 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.map-top-ui p {
  color: var(--text-soft);
  line-height: 1.5;
}

/* 左下事件卡 */
.map-event-card {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 300px;
  padding: 18px 20px;
  z-index: 12;
  transform: translateY(0);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.map-card-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--text-soft);
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}
.map-card-close:hover {
  color: var(--text-main);
  background: rgba(0,0,0,0.06);
}

.map-event-card h4 {
  font-size: 1.15rem;
  margin-bottom: 12px;
  padding-right: 20px;
}

.map-event-card p {
  margin-bottom: 8px;
  line-height: 1.55;
}

.map-stage.is-animated .map-event-card {
  animation: mapCardReveal 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.map-event-count {
  font-size: 0.78rem;
  color: var(--text-muted, #888);
  font-weight: 400;
}

.map-location-row {
  font-size: 0.88rem;
  color: var(--text-muted, #777);
}

.map-event-nav {
  display: flex;
  gap: 8px;
  margin: 10px 0 8px;
}

.map-event-nav .secondary-btn {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  padding: 4px 8px;
}


/* 下方時間線 */
.map-timeline-bar {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 48px));
  padding: 18px 24px 14px;
  z-index: 12;
}

.map-stage.is-animated .map-timeline-bar {
  animation: mapBarRise 0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.map-timeline-bar input[type="range"] {
  width: 100%;
  margin-bottom: 12px;
}

.year-display {
  font-size: 1.8rem;
  font-weight: bold;
  line-height: 1;
}

/* 洲別按鈕 */
.region-btn {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(120, 90, 60, 0.15);
  border-radius: 999px;
  padding: 10px 18px;
  min-width: 112px;
  background: rgba(255, 248, 229, 0.85);
  backdrop-filter: blur(2px);
  color: var(--text-main);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(60, 40, 20, 0.14);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  z-index: 3;
  animation: regionFloat 4.8s ease-in-out infinite;
}

.region-btn:hover {
  transform: translate(-50%, calc(-50% - 2px));
  background: rgba(255, 252, 245, 0.96);
  box-shadow: 0 12px 22px rgba(60, 40, 20, 0.18);
}

.region-btn.active-region {
  background: var(--bg-accent);
  color: #fff;
  box-shadow:
    0 0 0 6px rgba(139, 107, 69, 0.1),
    0 12px 24px rgba(80, 55, 30, 0.22);
  animation: regionPulse 1.8s ease-in-out infinite;
}

.region-btn.active-region::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 999px;
  border: 1px solid rgba(139, 107, 69, 0.28);
  animation: regionHalo 1.8s ease-out infinite;
}

.region-btn.china { left: 76%; top: 33%; }
.region-btn.taiwan { left: 79%; top: 40%; }
.region-btn.north-america { left: 19%; top: 27%; }
.region-btn.europe { left: 51%; top: 22%; }
.region-btn.asia { left: 72%; top: 27%; }
.region-btn.africa { left: 52%; top: 47%; }
.region-btn.south-america { left: 28%; top: 58%; }
.region-btn.oceania { left: 84%; top: 64%; }

.region-btn.china { animation-delay: 0.2s; }
.region-btn.taiwan { animation-delay: 0.3s; }
.region-btn.north-america { animation-delay: 0s; }
.region-btn.europe { animation-delay: 0.4s; }
.region-btn.asia { animation-delay: 0.8s; }
.region-btn.africa { animation-delay: 1.2s; }
.region-btn.south-america { animation-delay: 1.6s; }
.region-btn.oceania { animation-delay: 2s; }

@keyframes mapGlowShift {
  0% {
    transform: translate3d(-1%, -1%, 0) scale(1);
    opacity: 0.88;
  }
  100% {
    transform: translate3d(1.5%, 1%, 0) scale(1.04);
    opacity: 1;
  }
}

@keyframes regionHalo {
  0% {
    opacity: 0.7;
    transform: scale(0.92);
  }
  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

@keyframes mapWorldDrift {
  0%,
  100% {
    filter: contrast(1.05) brightness(1);
  }
  50% {
    filter: contrast(1.08) brightness(1.04);
  }
}

@keyframes mapLightSweep {
  0%,
  100% {
    transform: translate3d(-1%, 0, 0);
    opacity: 0.8;
  }
  50% {
    transform: translate3d(1.5%, -1%, 0);
    opacity: 1;
  }
}

@keyframes warPathFlow {
  from {
    stroke-dashoffset: 0;
  }
  to {
    stroke-dashoffset: -44;
  }
}

@keyframes regionFloat {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 4px));
  }
}

@keyframes regionPulse {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 5px));
  }
}

@keyframes mapCardReveal {
  from {
    opacity: 0;
    transform: translateY(-18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mapBarRise {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* 時間線頁 */
.timeline-bar {
  padding: 24px;
  margin-bottom: 22px;
}

.timeline-line {
  height: 6px;
  background: rgba(139, 107, 69, 0.4);
  border-radius: 999px;
  margin-bottom: 16px;
}

.timeline-points {
  display: flex;
  justify-content: space-between;
  color: var(--text-soft);
  font-weight: 600;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.event-card {
  padding: 22px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.event-year {
  font-weight: bold;
  color: var(--bg-accent);
}

.favorite-btn {
  background: rgba(139, 107, 69, 0.12);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 999px;
}

.favorite-btn:hover {
  background: rgba(139, 107, 69, 0.22);
}

.favorite-btn.is-favorite {
  background: var(--bg-accent);
  color: white;
}

.event-card h3 {
  margin-bottom: 10px;
}

.event-card p {
  color: var(--text-soft);
  line-height: 1.7;
  margin-bottom: 8px;
}

/* 詳情頁 */
.detail-layout {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 24px;
  padding: 28px;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.back-timeline-btn,
.back-map-btn {
  font-size: 0.85rem;
  opacity: 0.85;
}

.back-timeline-btn:hover,
.back-map-btn:hover {
  opacity: 1;
  transform: translateX(-2px);
}

.detail-year {
  color: var(--bg-accent);
  font-weight: bold;
}

.detail-title {
  font-size: 2rem;
  margin-bottom: 14px;
}

.detail-block {
  margin-top: 22px;
}

.detail-block h4 {
  margin-bottom: 10px;
}

.detail-block p {
  color: var(--text-soft);
  line-height: 1.9;
}

.image-placeholder {
  width: 100%;
  min-height: 320px;
  border-radius: var(--radius-md);
  border: 2px dashed rgba(120, 90, 60, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.2);
}

.detail-event-img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
}

/* 個人頁 */
.profile-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
}

.profile-card {
  padding: 24px;
  text-align: center;
}

.avatar-placeholder {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(139, 107, 69, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.profile-card h3 {
  margin-bottom: 10px;
}

.profile-card p {
  color: var(--text-soft);
  margin-bottom: 8px;
}

.profile-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.profile-content {
  min-width: 0;
}

.tab-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(139, 107, 69, 0.12);
  color: var(--text-main);
}

.tab-btn.active,
.tab-btn:hover {
  background: var(--bg-accent);
  color: white;
}

.mini-card-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mini-card {
  padding: 20px;
}

.mini-card h4 {
  margin-bottom: 10px;
}

.mini-card p {
  color: var(--text-soft);
  margin-bottom: 8px;
  line-height: 1.7;
}

/* 關於我們 */
.about-layout {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
}

.about-info {
  padding: 26px;
}

.about-info h3 {
  margin-bottom: 10px;
  margin-top: 18px;
}

.about-info h3:first-child {
  margin-top: 0;
}

.about-info p {
  color: var(--text-soft);
  line-height: 1.9;
}

.member-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.member-card {
  padding: 18px;
  text-align: center;
}

.member-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  background: rgba(139, 107, 69, 0.14);
  overflow: hidden;
  margin-bottom: 12px;
}

.member-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  border-radius: var(--radius-md);
}

/* 聯絡我們 */
.contact-layout {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr;
  gap: 22px;
}

.contact-form,
.contact-info {
  padding: 24px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid rgba(139, 107, 69, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.62);
  color: var(--text-main);
}

.form-group textarea {
  resize: vertical;
  min-height: 180px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--bg-accent);
  box-shadow: 0 0 0 3px rgba(139, 107, 69, 0.12);
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.contact-info h3 {
  margin-bottom: 12px;
}

.contact-info p {
  color: var(--text-soft);
  line-height: 1.8;
  margin-bottom: 10px;
}

/* 登入與註冊 */
.auth-shell {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 22px;
}

.auth-card {
  padding: 28px;
}

.auth-side-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.28), transparent 34%),
    linear-gradient(135deg, rgba(236, 222, 192, 0.96), rgba(221, 196, 158, 0.9));
}

.auth-kicker {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--bg-accent);
  font-size: 0.88rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-side-panel h3 {
  margin-bottom: 14px;
  font-size: 1.85rem;
}

.auth-side-panel p {
  color: var(--text-soft);
  line-height: 1.85;
}

.auth-feature-list {
  margin-top: 18px;
  padding-left: 20px;
  color: var(--text-main);
  line-height: 1.9;
}

.auth-feature-list li + li {
  margin-top: 6px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.auth-status {
  min-height: 24px;
  margin-top: 16px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.auth-status.success {
  color: #3f6b45;
  font-weight: 600;
}

.auth-status.error {
  color: #9a4d42;
  font-weight: 600;
}

/* 柔霧版雲層轉場 */
.cloud-curtain {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  overflow: hidden;
}

.cloud-curtain.active {
  opacity: 1;
  visibility: visible;
}

.cloud-layer {
  position: absolute;
  inset: -10%;
  background-image: url("assets/cloud.png");
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  filter: blur(14px);
  will-change: transform, opacity;
}

.cloud-layer-1 {
  background-size: 135% 135%;
  opacity: 0.64;
}

.cloud-layer-2 {
  background-size: 155% 155%;
  opacity: 0.5;
  mix-blend-mode: screen;
}

.cloud-layer-3 {
  background-size: 178% 178%;
  opacity: 0.38;
}

.cloud-center-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at center,
    rgba(255, 251, 242, 0.24) 0%,
    rgba(250, 243, 229, 0.46) 30%,
    rgba(236, 226, 205, 0.68) 62%,
    rgba(226, 214, 189, 0.82) 100%
  );
  opacity: 0;
  will-change: opacity;
}

.cloud-curtain.closing .cloud-layer-1 {
  animation: cloudIn1 1.18s ease-in-out forwards;
}
.cloud-curtain.closing .cloud-layer-2 {
  animation: cloudIn2 1.28s ease-in-out forwards;
}
.cloud-curtain.closing .cloud-layer-3 {
  animation: cloudIn3 1.38s ease-in-out forwards;
}
.cloud-curtain.closing .cloud-center-glow {
  animation: cloudGlowIn 1.12s ease-in-out forwards;
}

.cloud-curtain.opening .cloud-layer-1 {
  animation: cloudOut1 1.7s ease-in-out forwards;
}
.cloud-curtain.opening .cloud-layer-2 {
  animation: cloudOut2 1.95s ease-in-out forwards;
}
.cloud-curtain.opening .cloud-layer-3 {
  animation: cloudOut3 2.15s ease-in-out forwards;
}
.cloud-curtain.opening .cloud-center-glow {
  animation: cloudGlowOut 1.6s ease-in-out forwards;
}

@keyframes cloudIn1 {
  from {
    transform: translate(-26%, -10%) scale(1.28);
    opacity: 0;
  }
  to {
    transform: translate(0, 0) scale(1);
    opacity: 0.72;
  }
}

@keyframes cloudIn2 {
  from {
    transform: translate(24%, 12%) scale(1.34);
    opacity: 0;
  }
  to {
    transform: translate(0, 0) scale(1);
    opacity: 0.56;
  }
}

@keyframes cloudIn3 {
  from {
    transform: translate(-12%, 20%) scale(1.42);
    opacity: 0;
  }
  to {
    transform: translate(0, 0) scale(1);
    opacity: 0.44;
  }
}

@keyframes cloudGlowIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes cloudOut1 {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.72;
    filter: blur(14px);
  }
  35% {
    transform: translate(2%, -1%) scale(1.03);
    opacity: 0.66;
    filter: blur(13px);
  }
  100% {
    transform: translate(28%, -12%) scale(1.32);
    opacity: 0;
    filter: blur(18px);
  }
}

@keyframes cloudOut2 {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.56;
    filter: blur(14px);
  }
  40% {
    transform: translate(-1%, 2%) scale(1.04);
    opacity: 0.5;
    filter: blur(13px);
  }
  100% {
    transform: translate(-28%, 16%) scale(1.4);
    opacity: 0;
    filter: blur(20px);
  }
}

@keyframes cloudOut3 {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.44;
    filter: blur(14px);
  }
  45% {
    transform: translate(1%, 3%) scale(1.05);
    opacity: 0.38;
    filter: blur(13px);
  }
  100% {
    transform: translate(12%, 24%) scale(1.48);
    opacity: 0;
    filter: blur(22px);
  }
}

@keyframes cloudGlowOut {
  0% { opacity: 1; }
  45% { opacity: 0.92; }
  100% { opacity: 0; }
}

.page-section.page-enter-fog {
  opacity: 0.18 !important;
  filter: blur(6px);
  transform: scale(1.01);
  transition:
    opacity 1.2s ease,
    filter 1.2s ease,
    transform 1.2s ease;
}

.page-section.page-enter-clear {
  opacity: 1 !important;
  filter: blur(0);
  transform: scale(1);
}

@media (max-width: 1100px) {
  .detail-layout,
  .profile-layout,
  .about-layout,
  .contact-layout,
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .card-grid,
  .mini-card-list {
    grid-template-columns: 1fr 1fr;
  }

  .question-bank-overview,
  .question-bank-grid {
    grid-template-columns: 1fr;
  }

  .question-progress-head,
  .question-quiz-meta,
  .question-quiz-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .map-top-ui {
    min-width: 240px;
  }

  .map-event-card {
    width: 280px;
  }
}

@media (max-width: 820px) {
  .main-content {
    padding: 14px;
  }

  .sidebar {
    width: 250px;
    padding: 26px 18px 26px 30px;
  }

  .card-grid,
  .mini-card-list,
  .member-grid {
    grid-template-columns: 1fr;
  }

  .question-bank-overview {
    padding: 18px;
  }

  .question-card {
    padding: 20px;
  }

  .question-card-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .question-progress-panel,
  .question-quiz-panel {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .auth-entry-actions,
  .auth-user-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .auth-entry-actions .secondary-btn,
  .auth-entry-actions .profile-btn,
  .auth-user-actions .secondary-btn {
    flex: 1 1 auto;
  }

  .auth-card {
    padding: 22px;
  }

  .home-globe-stage {
    height: calc(100vh - 150px);
    min-height: 460px;
  }

  #map-page {
    height: calc(100vh - 150px);
    min-height: 560px;
  }

  .map-top-ui {
    top: 16px;
    left: 16px;
    min-width: 210px;
    padding: 14px 16px;
  }

  .map-event-card {
    bottom: 16px;
    left: 16px;
    top: auto;
    right: auto;
    width: min(260px, calc(100% - 32px));
    padding: 14px 16px;
  }

  .map-timeline-bar {
    width: calc(100% - 32px);
    bottom: 16px;
    padding: 14px 16px 12px;
  }

  .year-display {
    font-size: 1.45rem;
  }

  .region-btn {
    padding: 8px 14px;
    min-width: 92px;
    font-size: 0.92rem;
  }
}

/* =========================
   直式時間線（覆蓋舊版）
========================= */

#timeline-page {
  padding: 40px 0 80px;
}

.timeline-vertical-shell {
  width: 90%;
  max-width: 1100px;
  margin: auto;
}

.timeline-page-header {
  margin-bottom: 30px;
}

.timeline-page-header h2 {
  font-size: 2.4rem;
  margin-bottom: 10px;
}

.timeline-page-header p {
  color: #6b5a4a;
}

/* 主線 */
.timeline-main-line {
  position: absolute;
  left: 50%;
  top: 0;
  width: 4px;
  height: 100%;
  background: rgba(120, 90, 60, 0.3);
  transform: translateX(-50%);
  overflow: hidden;
}

.timeline-main-line::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -16%;
  width: 12px;
  height: 26%;
  transform: translateX(-50%);
  background: linear-gradient(
    to bottom,
    rgba(255, 244, 214, 0),
    rgba(255, 244, 214, 0.88),
    rgba(189, 144, 84, 0.12)
  );
  filter: blur(1px);
  opacity: 0;
}

/* wrapper */
.timeline-vertical-wrapper {
  position: relative;
}

/* 每一列 */
.timeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 100px 1fr;
  gap: 20px;
  align-items: center;
  margin: 80px 0;
  opacity: 0;
  transform: translateY(32px);
}

/* 年份 */
.timeline-year-badge {
  grid-column: 2;
  justify-self: center;
  background: #f5ecd9;
  padding: 10px 18px;
  border-radius: 20px;
  font-weight: bold;
  box-shadow: 0 6px 15px rgba(0,0,0,0.1);
  z-index: 2;
  opacity: 0;
  transform: scale(0.88);
}

/* 左右卡 */
.timeline-side {
  width: 100%;
  padding: 20px;
  border-radius: 12px;
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* 左 */
.timeline-world {
  grid-column: 1;
  transform: translateX(-38px);
}

/* 右 */
.timeline-china {
  grid-column: 3;
  transform: translateX(38px);
}

/* 小標籤 */
.timeline-side-label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  background: rgba(139,107,69,0.15);
  padding: 4px 10px;
  border-radius: 20px;
}

/* 文字 */
.timeline-side h3 {
  margin-bottom: 8px;
}

.timeline-side p {
  margin-bottom: 10px;
  color: #6b5a4a;
}

.timeline-row:hover .timeline-world {
  transform: translateX(-10px);
}

.timeline-row:hover .timeline-china {
  transform: translateX(10px);
}

.timeline-row:hover .timeline-side {
  box-shadow: 0 14px 28px rgba(60, 40, 20, 0.12);
}

#timeline-page.timeline-animated .timeline-main-line::after {
  animation: timelineLineSweep 3.6s ease-in-out infinite;
  opacity: 1;
}

#timeline-page.timeline-animated .timeline-row {
  animation: timelineRowReveal 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#timeline-page.timeline-animated .timeline-row:nth-child(2) {
  animation-delay: 0.08s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(3) {
  animation-delay: 0.18s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(4) {
  animation-delay: 0.28s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(5) {
  animation-delay: 0.38s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(6) {
  animation-delay: 0.48s;
}

#timeline-page.timeline-animated .timeline-year-badge {
  animation: timelineBadgePop 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#timeline-page.timeline-animated .timeline-world {
  animation: timelineCardLeft 0.78s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#timeline-page.timeline-animated .timeline-china {
  animation: timelineCardRight 0.78s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#timeline-page.timeline-animated .timeline-row:nth-child(2) .timeline-year-badge,
#timeline-page.timeline-animated .timeline-row:nth-child(2) .timeline-world,
#timeline-page.timeline-animated .timeline-row:nth-child(2) .timeline-china {
  animation-delay: 0.14s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(3) .timeline-year-badge,
#timeline-page.timeline-animated .timeline-row:nth-child(3) .timeline-world,
#timeline-page.timeline-animated .timeline-row:nth-child(3) .timeline-china {
  animation-delay: 0.24s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(4) .timeline-year-badge,
#timeline-page.timeline-animated .timeline-row:nth-child(4) .timeline-world,
#timeline-page.timeline-animated .timeline-row:nth-child(4) .timeline-china {
  animation-delay: 0.34s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(5) .timeline-year-badge,
#timeline-page.timeline-animated .timeline-row:nth-child(5) .timeline-world,
#timeline-page.timeline-animated .timeline-row:nth-child(5) .timeline-china {
  animation-delay: 0.44s;
}

#timeline-page.timeline-animated .timeline-row:nth-child(6) .timeline-year-badge,
#timeline-page.timeline-animated .timeline-row:nth-child(6) .timeline-world,
#timeline-page.timeline-animated .timeline-row:nth-child(6) .timeline-china {
  animation-delay: 0.54s;
}

@keyframes timelineLineSweep {
  0% {
    top: -18%;
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

@keyframes timelineRowReveal {
  from {
    opacity: 0;
    transform: translateY(32px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes timelineBadgePop {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes timelineCardLeft {
  from {
    opacity: 0;
    transform: translateX(-38px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes timelineCardRight {
  from {
    opacity: 0;
    transform: translateX(38px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* 關閉舊版橫時間線 */
.timeline-bar,
.timeline-points,
.card-grid {
  display: none !important;
}

/* 手機版 */
@media (max-width: 768px) {
  .timeline-row {
    grid-template-columns: 1fr;
    padding-left: 40px;
  }

  .timeline-main-line {
    left: 20px;
  }

  .timeline-year-badge {
    justify-self: start;
    margin-left: -20px;
  }

  .timeline-world,
  .timeline-china {
    grid-column: 1;
    transform: translateX(0);
  }

  #timeline-page.timeline-animated .timeline-world,
  #timeline-page.timeline-animated .timeline-china {
    animation: timelineRowReveal 0.72s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  }
}

/* =========================
   事件懸浮視窗 Modal
========================= */

.event-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 28, 18, 0.28);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 3000;
}

.event-modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.event-modal {
  position: relative;
  width: min(720px, 100%);
  max-height: min(82vh, 900px);
  overflow-y: auto;
  padding: 28px 28px 24px;
  border-radius: 24px;
  box-shadow: 0 18px 42px rgba(40, 28, 18, 0.2);
}

.event-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(139, 107, 69, 0.12);
  color: var(--text-main);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: 0.2s ease;
}

.event-modal-close:hover {
  background: rgba(139, 107, 69, 0.22);
  transform: scale(1.05);
}

.event-modal-tag {
  display: inline-block;
  margin-bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(139, 107, 69, 0.12);
  color: var(--bg-accent-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

.event-modal-title {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 10px;
  color: var(--text-main);
  padding-right: 48px;
}

.event-modal-year {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--bg-accent);
  margin-bottom: 18px;
}

.event-modal-body {
  color: var(--text-soft);
  line-height: 1.95;
  white-space: pre-line;
}

body.modal-open {
  overflow: hidden;
}

@media (max-width: 640px) {
  .event-modal {
    padding: 22px 18px 18px;
    border-radius: 18px;
  }

  .event-modal-title {
    font-size: 1.55rem;
  }

  .event-modal-year {
    font-size: 1rem;
  }
}

/* =========================
   聯絡我們 - 假送出效果
========================= */

.contact-status {
  margin-top: 14px;
  min-height: 24px;
  font-size: 0.95rem;
  color: var(--text-soft);
  transition: 0.3s;
}

.contact-status.success {
  color: #3f6b45;
  font-weight: 600;
}

.contact-status.error {
  color: #9a4d42;
}

.contact-form.sending {
  opacity: 0.75;
}

.contact-form.sending button {
  pointer-events: none;
  opacity: 0.7;
}

/* =========================
   時間線卡片收藏按鈕
========================= */

.timeline-side {
  position: relative;
  padding-top: 56px;
}

.timeline-favorite-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 8px 12px;
  font-size: 0.85rem;
  line-height: 1;
  z-index: 2;
}

.timeline-favorite-btn.is-favorite {
  background: var(--bg-accent);
  color: #fff;
}

@media (max-width: 768px) {
  .timeline-side {
    padding-top: 52px;
  }

  .timeline-favorite-btn {
    top: 14px;
    right: 14px;
    font-size: 0.82rem;
  }
}

/* =========================
   查詢框：時間線 / 收藏頁
========================= */

.timeline-header-tools,
.profile-tools-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.timeline-header-text {
  min-width: 220px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box input {
  min-width: 240px;
  height: 42px;
  border: 1px solid rgba(139, 107, 69, 0.25);
  border-radius: 999px;
  padding: 0 16px;
  font-size: 0.96rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-main);
}

.search-box input:focus {
  outline: none;
  border-color: var(--bg-accent);
  box-shadow: 0 0 0 3px rgba(139, 107, 69, 0.12);
}

.timeline-row.is-hidden,
.mini-card.is-hidden {
  display: none !important;
}

.search-empty {
  margin-top: 12px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .search-box {
    width: 100%;
  }

  .search-box input {
    min-width: 0;
    width: 100%;
  }
}

/* ─── Avatar ─────────────────────────────────────────────────────────────── */

.avatar-wrap {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  margin: 0 auto 18px;
  cursor: pointer;
}

.avatar-wrap .avatar-placeholder {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(139, 107, 69, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-soft);
  margin: 0;
}

.avatar-img {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 2px solid var(--border-color);
}

.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(61, 45, 31, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  opacity: 0;
  transition: opacity 0.2s;
  cursor: pointer;
}

.avatar-wrap:hover .avatar-upload-overlay {
  opacity: 1;
}

/* ─── Edit profile modal ─────────────────────────────────────────────────── */

.edit-profile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(61, 45, 31, 0.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
}

.edit-profile-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.edit-profile-modal {
  width: min(460px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px 28px 28px;
  position: relative;
}

.edit-profile-modal h3 {
  margin-bottom: 22px;
  font-size: 1.15rem;
}

.edit-profile-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-soft);
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}

.edit-profile-close:hover {
  background: rgba(139, 107, 69, 0.15);
}

.form-hint {
  font-size: 0.8em;
  color: var(--text-soft);
  font-weight: 400;
}

#profileEmailText {
  color: var(--text-soft);
  margin-bottom: 8px;
}

/* ─── Admin 後台 ────────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-tab-btn {
  padding: 8px 20px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.admin-tab-btn:hover { background: rgba(139,107,69,0.08); color: var(--text-main); }
.admin-tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.admin-panel { display: none; }
.admin-panel.active-panel { display: block; }

.admin-stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}

.admin-stat-card {
  padding: 24px;
  text-align: center;
}

.admin-stat-num {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.admin-stat-label {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.admin-table-wrap {
  overflow-x: auto;
  padding: 0;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.admin-table th {
  background: rgba(139,107,69,0.08);
  font-weight: 600;
  color: var(--text-main);
}

.admin-table td { color: var(--text-soft); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(139,107,69,0.04); }

.admin-table .danger-btn {
  padding: 4px 10px;
  font-size: 0.82rem;
  background: #c0392b;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}
.admin-table .danger-btn:hover { background: #a93226; }

.admin-table .edit-btn {
  padding: 4px 10px;
  font-size: 0.82rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-right: 6px;
  transition: background 0.2s;
}
.admin-table .edit-btn:hover { filter: brightness(0.9); }

/* Event modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal-box {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  padding: 32px;
}

.modal-close {
  position: absolute;
  top: 12px; right: 16px;
  background: none; border: none;
  font-size: 1.1rem;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}
.modal-close:hover { background: rgba(0,0,0,0.08); }

.modal-box h3 { margin-bottom: 20px; padding-right: 24px; }

.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text-main);
}
.form-input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 0.95rem;
  box-sizing: border-box;
  font-family: inherit;
}
.form-input:focus { outline: none; border-color: var(--accent); }

@media (max-width: 820px) {
  .admin-stat-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 540px) {
  .admin-stat-cards { grid-template-columns: 1fr; }
}

/* ─── Timeline search empty message ─────────────────────────────────────── */
.timeline-empty-msg {
  text-align: center;
  color: var(--text-muted, #888);
  padding: 3rem 0;
  font-size: 1.1rem;
}

/* ─── Timeline scroll-to-top btn ─────────────────────────────────────────── */
.timeline-scroll-top {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(60,40,20,0.22);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.3s, transform 0.3s, background 0.2s;
  pointer-events: none;
}
.timeline-scroll-top.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.timeline-scroll-top:hover {
  background: var(--bg-accent-dark);
}
