:root {
  --purple-main: #8B7CB6;
  --purple-light: #B8A9D4;
  --purple-pale: #D8D0E8;
  --bg-start: #FAF8FF;
  --bg-end: #F0ECF7;
  --gold: #D4AF37;
  --gold-warm: #C9A84C;
  --teal: #4AB8B8;
  --teal-light: #E8F6F6;
  --text-dark: #3A3550;
  --text-muted: #6B6580;
  --text-light: #9890A8;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-shadow: 0 8px 32px rgba(139, 124, 182, 0.12);
  --option-hover: rgba(184, 169, 212, 0.15);
  --option-active: rgba(139, 124, 182, 0.2);
  --radius: 16px;
  --radius-sm: 12px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: "Noto Serif TC", Georgia, "Times New Roman", serif;
  background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  /* 點點背景 */
  background-image:
    radial-gradient(rgba(139, 124, 182, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
  background-color: var(--bg-end);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* 動態雲朵背景 canvas */
#clouds-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* 容器 */
.container {
  width: 100%;
  max-width: 520px;
  padding: 1rem;
  padding-top: 1.5rem;
  padding-bottom: 1rem;
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* 畫面切換 */
.screen {
  display: none;
  animation: fadeIn 0.6s ease;
  width: 100%;
}

.screen.active {
  display: block;
}

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

/* 卡片 */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(184, 169, 212, 0.2);
  padding: 2.5rem 2rem;
  text-align: center;
}

/* 魔法圓陣裝飾 */
.magic-circle {
  font-size: 2.5rem;
  color: var(--gold);
  margin-bottom: 1rem;
  letter-spacing: 0.5rem;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* 開始畫面 */
.title {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text-dark);
  margin-bottom: 1rem;
  letter-spacing: 0.1em;
}

.subtitle {
  font-size: 1rem;
  color: var(--purple-main);
  margin-bottom: 0.75rem;
  font-weight: 400;
}

.desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* 裝飾分隔線（芙莉蓮官網風格） */
.ornament-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.ornament-line {
  display: block;
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.ornament-symbol {
  color: var(--gold);
  font-size: 1.2rem;
  line-height: 1;
}

/* 芙莉蓮官網風格按鈕（柔和版） */
.btn-frieren {
  display: inline-block;
  padding: 0.8rem 2.5rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: var(--purple-main);
  background: linear-gradient(180deg, #fff 0%, #F5F0FA 100%);
  border: 1.5px solid var(--purple-pale);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(139, 124, 182, 0.1);
  letter-spacing: 0.1em;
  position: relative;
}

.btn-frieren::before,
.btn-frieren::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: var(--purple-light);
  border-style: solid;
}

.btn-frieren::before {
  top: -1px;
  left: -1px;
  border-width: 1.5px 0 0 1.5px;
}

.btn-frieren::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 1.5px 1.5px 0;
}

.btn-frieren:hover {
  background: linear-gradient(180deg, #F5F0FA 0%, #EDE6F5 100%);
  border-color: var(--purple-light);
  box-shadow: 0 4px 16px rgba(139, 124, 182, 0.18);
  transform: translateY(-1px);
}

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

.btn-frieren.btn-secondary {
  background: #fff;
  color: var(--text-muted);
  border-color: rgba(216, 208, 232, 0.6);
}

.btn-frieren.btn-secondary::before,
.btn-frieren.btn-secondary::after {
  border-color: rgba(216, 208, 232, 0.6);
}

.btn-frieren.btn-secondary:hover {
  background: var(--bg-end);
  color: var(--text-dark);
  border-color: var(--purple-pale);
}

/* 進度條 */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--purple-pale);
  border-radius: 2px;
  margin-bottom: 2rem;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-main), var(--gold));
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

/* 題號 */
.question-number {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.75rem;
  letter-spacing: 0.15em;
}

/* 題目文字 */
.question-text {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.7;
  color: var(--text-dark);
  margin-bottom: 1.75rem;
}

/* 選項 */
.options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--purple-pale);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s ease;
  text-align: left;
  line-height: 1.5;
  min-height: 48px;
}

.option-btn:hover {
  background: var(--option-hover);
  border-color: var(--purple-light);
  transform: translateX(4px);
}

.option-btn:active {
  background: var(--option-active);
  border-color: var(--purple-main);
}

.option-btn.selected {
  background: linear-gradient(135deg, rgba(139, 124, 182, 0.15), rgba(212, 175, 55, 0.1));
  border-color: var(--purple-main);
  color: var(--text-dark);
  font-weight: 600;
}

/* 診斷摘要頁 */
.result-card {
  padding: 2.5rem 2rem;
}

.result-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

.result-placeholder {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.result-answers {
  text-align: left;
  margin-bottom: 2rem;
}

.result-answer-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--purple-pale);
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.result-answer-item:last-child {
  border-bottom: none;
}

.result-answer-item .q-label {
  color: var(--purple-main);
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}

/* 結果角色頁 */
.result-character-card {
  padding: 1.5rem 1.5rem;
}

.character-name-label {
  font-size: 0.85rem;
  color: var(--text-light);
  letter-spacing: 0.15em;
  margin-bottom: 0.25rem;
}

.character-name {
  font-size: 2rem;
  font-weight: 700;
  color: var(--purple-main);
  margin-bottom: 0.25rem;
  letter-spacing: 0.15em;
}

.character-name-suffix {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  letter-spacing: 0.2em;
}

.character-desc {
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: 0.75rem;
  background: linear-gradient(90deg, var(--gold-warm), var(--purple-main));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.character-image-wrapper {
  width: 100%;
  aspect-ratio: 4 / 5;
  margin: 0 auto 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1.5px solid var(--purple-pale);
  box-shadow: 0 4px 20px rgba(139, 124, 182, 0.12);
}

.character-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* 圖片載入失敗的 fallback */
.character-image-wrapper.no-image {
  background: linear-gradient(135deg, var(--purple-pale), var(--teal-light));
  padding: 3rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 260px;
}

.character-image-wrapper.no-image::after {
  content: '✦';
  font-size: 3rem;
  color: var(--gold);
}

.character-quote {
  font-size: 0.85rem;
  color: var(--text-dark);
  line-height: 1.5;
  font-style: italic;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.06), rgba(139, 124, 182, 0.06));
  border-left: 3px solid var(--purple-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 0;
  text-align: left;
}

.result-actions {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  margin-top: 1rem;
  width: 100%;
}

.result-actions .btn-frieren {
  flex: 1;
  padding: 0.8rem 0.5rem;
}

/* CosMate 導下載區 */
.cosmate-footer {
  width: 100%;
  max-width: calc(520px - 2rem);
  background: rgba(139, 124, 182, 0.08);
  border-radius: var(--radius);
  padding: 1.8rem 1.5rem;
  text-align: center;
  margin: 0 auto 2rem;
  position: relative;
  z-index: 1;
  border: 1px solid rgba(184, 169, 212, 0.15);
}

.ad-content h2 {
  color: var(--text-dark);
  margin-bottom: 1rem;
  font-size: 1.1rem;
  font-weight: bold;
}

.footer-cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  max-width: fit-content;
  margin: 0 auto;
}

.cosmate-download-btn {
  display: inline-block;
  background: var(--purple-main);
  color: #fff;
  text-decoration: none;
  font-weight: bold;
  font-size: 1rem;
  padding: 10px 25px;
  border-radius: 6px;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(139, 124, 182, 0.3);
  line-height: 24px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cosmate-download-btn:hover {
  background: #7668a5;
  transform: scale(1.02);
}

.social-row {
  display: flex;
  gap: 8px;
}

.social-icon {
  width: 44px;
  height: 44px;
  background: #fff;
  border: 1px solid var(--purple-pale);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  color: #000;
}

.social-icon svg {
  width: 20px;
  height: 20px;
  fill: #000;
}

.social-icon:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border-color: var(--purple-main);
}

/* RWD */
@media (max-width: 600px) {
  .container {
    padding: 0.75rem;
  }

  .card {
    padding: 2rem 1.25rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .question-text {
    font-size: 1.1rem;
  }

  .option-btn {
    font-size: 0.9rem;
    padding: 0.875rem 1rem;
  }

  .character-name {
    font-size: 1.6rem;
  }

  .footer-cta-row {
    flex-direction: column;
  }
}

@media (min-width: 601px) {
  body {
    padding-top: 2rem;
  }
}
