@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;600;700&family=Noto+Sans+TC:wght@300;400;500;700&display=swap');

:root {
  --sand: #F5EFE0;
  --sand-dark: #EDE4CC;
  --coral: #E8826A;
  --coral-light: #F5C4B3;
  --coral-dark: #C45F48;
  --teal: #4AAFA0;
  --teal-light: #A8DDD7;
  --teal-dark: #2D8578;
  --gold: #D4A843;
  --gold-light: #F5E0A0;
  --purple: #8B6FBE;
  --purple-light: #D4C5E8;
  --ink: #2C2416;
  --ink-mid: #5C4F3A;
  --ink-light: #8C7E6A;
  --white: #FFFDF8;
  --card-bg: rgba(255,253,248,0.92);
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(44,36,22,0.12);
  --shadow-lg: 0 16px 64px rgba(44,36,22,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--sand);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Background texture */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(74,175,160,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(232,130,106,0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(212,168,67,0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---- PAGE MANAGEMENT ---- */
.page { display: none; min-height: 100vh; position: relative; z-index: 1; }
.page.active { display: block; }

/* ---- NAV ---- */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245,239,224,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(212,168,67,0.2);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.nav-logo .logo-mark {
  width: 32px; height: 32px;
  background: var(--coral);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 700;
}

.nav-back {
  display: none;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--ink-mid);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.nav-back:hover { background: rgba(44,36,22,0.06); }
.nav-back.visible { display: flex; }

/* ---- HERO ---- */
.hero {
  min-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 60px 24px;
  position: relative;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-light);
  color: var(--ink-mid);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 24px;
  border: 1px solid rgba(212,168,67,0.3);
  animation: fadeSlideDown 0.6s ease both;
}

.hero h1 {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(28px, 6vw, 52px);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  max-width: 700px;
  animation: fadeSlideDown 0.6s ease 0.1s both;
}

.hero h1 em {
  font-style: normal;
  color: var(--coral);
  position: relative;
}

.hero h1 em::after {
  content: '';
  position: absolute;
  bottom: 2px; left: 0; right: 0;
  height: 3px;
  background: var(--coral-light);
  border-radius: 2px;
}

.hero-sub {
  font-size: 16px;
  color: var(--ink-mid);
  max-width: 500px;
  line-height: 1.7;
  margin-top: 16px;
  animation: fadeSlideDown 0.6s ease 0.2s both;
}

.hero-cta {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  animation: fadeSlideDown 0.6s ease 0.3s both;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--coral);
  color: white;
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 16px;
  font-weight: 700;
  padding: 16px 36px;
  border-radius: 100px;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 20px rgba(232,130,106,0.4);
  text-decoration: none;
}

.btn-primary:hover {
  background: var(--coral-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(232,130,106,0.45);
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--ink-mid);
  font-size: 14px;
  padding: 10px 20px;
  border-radius: 100px;
  border: 1.5px solid rgba(44,36,22,0.15);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-secondary:hover { border-color: var(--coral-light); color: var(--coral-dark); background: rgba(232,130,106,0.05); }

/* Floating animals decoration */
.hero-floats {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.float-char {
  position: absolute;
  width: 80px; height: 80px;
  background: var(--card-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  border: 2px solid rgba(212,168,67,0.15);
  animation: float 6s ease-in-out infinite;
  opacity: 0.7;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(-3deg); }
  50% { transform: translateY(-16px) rotate(3deg); }
}

/* ---- CHARACTER GRID ---- */
.section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 80px 24px;
}

.section-title {
  font-family: 'Noto Serif TC', serif;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
  margin-bottom: 8px;
}

.section-sub {
  text-align: center;
  color: var(--ink-light);
  font-size: 14px;
  margin-bottom: 48px;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 16px;
}

.char-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  border: 1.5px solid rgba(212,168,67,0.15);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.char-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--char-color, var(--teal));
  border-radius: var(--radius) var(--radius) 0 0;
}

.char-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(212,168,67,0.35);
}

.char-emoji {
  font-size: 40px;
  margin-bottom: 8px;
  display: block;
  line-height: 1;
}

.char-type {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--char-color, var(--teal));
  margin-bottom: 4px;
}

.char-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.3;
}

/* ---- FAQ ---- */
.faq-section {
  background: var(--white);
  padding: 80px 24px;
}

.faq-inner {
  max-width: 760px;
  margin: 0 auto;
}

.faq-item {
  border-bottom: 1px solid rgba(44,36,22,0.08);
  padding: 20px 0;
}

.faq-q {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.faq-q-icon {
  width: 22px; height: 22px;
  min-width: 22px;
  background: var(--teal-light);
  color: var(--teal-dark);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 700;
  margin-top: 1px;
}

.faq-a {
  font-size: 14px;
  color: var(--ink-mid);
  line-height: 1.75;
  padding-left: 32px;
}

/* ---- QUIZ PAGE ---- */
.quiz-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px;
}

.quiz-progress-bar-wrap {
  margin-bottom: 40px;
}

.quiz-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-light);
  margin-bottom: 8px;
}

.quiz-progress-track {
  height: 6px;
  background: rgba(44,36,22,0.1);
  border-radius: 100px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  border-radius: 100px;
  transition: width 0.5s ease;
}

.quiz-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(212,168,67,0.2);
  animation: cardIn 0.35s ease both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

.quiz-q-number {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--teal);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.quiz-q-text {
  font-family: 'Noto Serif TC', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  margin-bottom: 28px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: rgba(245,239,224,0.6);
  border: 1.5px solid rgba(44,36,22,0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 15px;
  color: var(--ink-mid);
  text-align: left;
}

.quiz-option:hover {
  border-color: var(--teal);
  background: rgba(74,175,160,0.06);
  color: var(--ink);
}

.quiz-option.selected {
  border-color: var(--teal);
  background: rgba(74,175,160,0.1);
  color: var(--teal-dark);
}

.quiz-option-dot {
  width: 20px; height: 20px;
  min-width: 20px;
  border-radius: 50%;
  border: 1.5px solid rgba(44,36,22,0.2);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

.quiz-option.selected .quiz-option-dot {
  background: var(--teal);
  border-color: var(--teal);
}

.quiz-option.selected .quiz-option-dot::after {
  content: '✓';
  color: white;
  font-size: 11px;
  font-weight: 700;
}

.quiz-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
}

.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: 1.5px solid rgba(44,36,22,0.15);
  background: transparent;
  color: var(--ink-mid);
  font-family: 'Noto Sans TC', sans-serif;
}

.btn-nav:hover:not(:disabled) { background: rgba(44,36,22,0.05); }
.btn-nav:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-nav.primary {
  background: var(--coral);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(232,130,106,0.3);
}

.btn-nav.primary:hover:not(:disabled) {
  background: var(--coral-dark);
  transform: translateX(2px);
}

/* ---- RESULT PAGE ---- */
.result-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 48px 24px;
  text-align: center;
}

.result-crown {
  font-size: 48px;
  margin-bottom: 8px;
  animation: bounceIn 0.6s ease both;
}

.result-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink-light);
  text-transform: uppercase;
  margin-bottom: 8px;
  animation: fadeSlideDown 0.5s ease 0.1s both;
}

.result-type {
  font-family: 'Noto Serif TC', serif;
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 4px;
  animation: fadeSlideDown 0.5s ease 0.15s both;
  line-height: 1;
  margin-bottom: 4px;
}

.result-name {
  font-family: 'Noto Serif TC', serif;
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 32px;
  animation: fadeSlideDown 0.5s ease 0.2s both;
}

.result-char-img {
  width: 180px; height: 180px;
  background: var(--card-bg);
  border-radius: 50%;
  margin: 0 auto 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 100px;
  border: 3px solid;
  animation: bounceIn 0.6s ease 0.25s both;
  box-shadow: var(--shadow);
}

.result-desc {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px 32px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink-mid);
  text-align: left;
  border: 1px solid rgba(212,168,67,0.2);
  margin-bottom: 28px;
  animation: fadeSlideDown 0.5s ease 0.35s both;
}

.result-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 32px;
  animation: fadeSlideDown 0.5s ease 0.4s both;
}

.trait-tag {
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fadeSlideDown 0.5s ease 0.45s both;
}

/* ---- CHARACTER DETAIL MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(44,36,22,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius);
  max-width: 480px;
  width: 100%;
  padding: 36px;
  position: relative;
  animation: modalIn 0.3s ease both;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  background: rgba(44,36,22,0.08);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-mid);
  transition: background 0.2s;
}
.modal-close:hover { background: rgba(44,36,22,0.15); }

/* ---- FOOTER ---- */
footer {
  background: var(--ink);
  color: rgba(245,239,224,0.6);
  text-align: center;
  padding: 32px 24px;
  font-size: 13px;
  line-height: 1.8;
}

footer a { color: var(--coral-light); text-decoration: none; }
footer a:hover { color: var(--coral); }

footer .footer-logo {
  font-family: 'Noto Serif TC', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--sand);
  margin-bottom: 8px;
  display: block;
}

/* ---- ANIMATIONS ---- */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes bounceIn {
  0% { opacity: 0; transform: scale(0.7); }
  60% { transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .quiz-card { padding: 28px 20px; }
  .char-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .char-card { padding: 14px 10px; }
  .char-emoji { font-size: 30px; }
  .result-type { font-size: 48px; }
  .result-char-img { width: 140px; height: 140px; font-size: 72px; }
}

/* ---- MBTI comparison table ---- */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 24px;
  font-size: 13px;
}
.compare-table th {
  background: var(--sand-dark);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 12px;
  color: var(--ink-mid);
}
.compare-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(44,36,22,0.06);
  color: var(--ink-mid);
  vertical-align: top;
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table .bullet { color: var(--coral); margin-right: 4px; }

/* ---- CHARACTER CARD IMAGE ---- */
.char-card .char-emoji {
  font-size: 40px;
  margin-bottom: 8px;
  display: block;
  line-height: 1;
}

/* Result image override — show real photo, not emoji circle */
.result-char-img {
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-char-img img {
  width: 148px;
  height: 148px;
  object-fit: contain;
  border-radius: 50%;
}
