/* 心性年龄测试 · 暮色紫金主题 */
:root {
  --bg: #12102a;
  --bg2: #1b1638;
  --card: rgba(255, 255, 255, .06);
  --card2: rgba(255, 255, 255, .09);
  --line: rgba(255, 255, 255, .12);
  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, .82);
  --ink-dim: rgba(255, 255, 255, .52);
  --gold: #f0c987;
  --gold-deep: #d9a441;
  --violet: #a78bfa;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { overflow: hidden; }

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  height: 100%;
  overflow: hidden;
}

/* ---------- 背景 ---------- */
.bg-decor { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bg-glow {
  position: absolute; border-radius: 50%; filter: blur(50px); opacity: .5;
}
.bg-glow-1 { width: 320px; height: 320px; top: -90px; left: -80px; background: rgba(167, 139, 250, .32); }
.bg-glow-2 { width: 300px; height: 300px; bottom: 40px; right: -110px; background: rgba(240, 201, 135, .18); }
.bg-stars { position: absolute; inset: 0; }
.bg-stars i {
  position: absolute; background: #fff; border-radius: 50%; opacity: .5;
  animation: twinkle 3.6s ease-in-out infinite;
}
@keyframes twinkle { 0%, 100% { opacity: .18; } 50% { opacity: .7; } }

/* ---------- 屏幕 ---------- */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column;
}
.screen.active { display: flex; }

/* ---------- 首页 ---------- */
.home-inner {
  margin: auto; width: 100%;
  padding: calc(40px + env(safe-area-inset-top)) 26px 40px;
  text-align: center;
}
.home-badge {
  display: inline-block; font-size: 12px; letter-spacing: .12em;
  color: var(--gold); border: 1px solid rgba(240, 201, 135, .32);
  padding: 5px 14px; border-radius: 999px; margin-bottom: 20px;
  background: rgba(240, 201, 135, .07);
}
.home-title {
  font-size: 38px; font-weight: 800; letter-spacing: .02em; line-height: 1.25;
  background: linear-gradient(100deg, #fff 20%, var(--gold) 90%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.home-sub { margin-top: 14px; color: var(--ink-dim); font-size: 15px; line-height: 1.9; }
.home-sub em { font-style: normal; color: var(--gold); font-weight: 600; }

.home-dims {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin: 26px 0 4px;
}
.home-dims span {
  font-size: 12px; color: var(--ink-soft);
  background: var(--card); border: 1px solid var(--line);
  padding: 6px 11px; border-radius: 999px;
}

.age-row {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 22px 0 4px; font-size: 13px; color: var(--ink-dim);
  flex-wrap: wrap;
}
.age-row input {
  width: 74px; padding: 9px 10px; text-align: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  color: var(--ink); font-size: 15px; font-family: inherit;
}
.age-row input:focus { outline: none; border-color: rgba(240, 201, 135, .55); }
.age-row small { font-size: 11px; opacity: .7; }

.btn {
  display: block; width: 100%; padding: 14px 0; border: 0; border-radius: 999px;
  font-size: 16px; font-weight: 700; font-family: inherit; cursor: pointer;
  color: var(--ink); background: var(--card2);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary {
  color: #241804;
  background: linear-gradient(100deg, var(--gold), var(--gold-deep));
  box-shadow: 0 10px 30px rgba(240, 201, 135, .22);
}
.btn-lg { margin-top: 24px; padding: 16px 0; font-size: 17px; }
.btn-ghost {
  margin-top: 12px; background: transparent; border: 1px solid var(--line);
  color: var(--ink-soft); font-weight: 600; font-size: 14px; padding: 12px 0;
}

.home-meta {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line);
}
.meta-item b { display: block; font-size: 20px; color: var(--gold); }
.meta-item span { font-size: 11px; color: var(--ink-dim); }
.home-tip { margin: 20px 0 0; font-size: 12px; color: var(--ink-dim); }
.home-tip.tip-link { color: var(--gold); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 授权码 ---------- */
.code-inner {
  margin: auto; width: 100%; max-width: 340px;
  padding: 40px 26px; text-align: center; position: relative;
}
.code-back { position: absolute; top: 26px; left: 20px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-soft); font-size: 18px; cursor: pointer;
}
.code-badge { font-size: 34px; margin-bottom: 12px; }
.code-title { font-size: 24px; font-weight: 800; }
.code-sub { margin-top: 10px; font-size: 13px; color: var(--ink-dim); }
.code-sub b { color: var(--gold); }
.code-input {
  width: 100%; margin-top: 24px; padding: 15px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  color: var(--ink); font-size: 17px; letter-spacing: .12em; text-align: center;
  font-family: ui-monospace, Consolas, monospace;
}
.code-input:focus { outline: none; border-color: rgba(240, 201, 135, .6); background: rgba(255, 255, 255, .08); }
.code-msg { min-height: 20px; margin: 10px 0 4px; font-size: 13px; color: var(--ink-dim); }
.code-msg.err { color: #ff9d9d; }
.code-msg.ok { color: #8fe0a4; }
.code-tip { margin: 18px 0 0; font-size: 11px; line-height: 1.7; color: var(--ink-dim); }

/* ---------- 答题 ---------- */
.quiz-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 18px 10px;
}
.quiz-progress { flex: 1; height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.quiz-progress-bar { height: 100%; width: 2%; border-radius: 999px; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width .35s ease; }
.quiz-count { font-size: 12px; color: var(--ink-dim); min-width: 48px; text-align: right; }

.quiz-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 20px calc(28px + var(--safe-b));
}
.quiz-dim {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  margin-bottom: 18px; font-size: 12px; color: var(--ink-dim);
}
.dim-icon { font-size: 16px; }
.dim-name { color: var(--gold); font-weight: 600; }

.quiz-card { animation: fadeUp .32s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.quiz-question { font-size: 21px; line-height: 1.6; font-weight: 700; margin-bottom: 24px; }
.quiz-options { display: flex; flex-direction: column; gap: 12px; }
.opt {
  display: flex; align-items: center; gap: 12px; text-align: left;
  padding: 15px 16px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink-soft); font-size: 15px; line-height: 1.5;
  font-family: inherit; cursor: pointer; transition: all .18s ease;
}
.opt:active { transform: scale(.985); }
.opt-letter {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .08); color: var(--gold);
  font-size: 13px; font-weight: 700;
}
.opt.picked { border-color: rgba(240, 201, 135, .6); background: rgba(240, 201, 135, .1); color: #fff; }
.opt.picked .opt-letter { background: var(--gold); color: #241804; }
.quiz-foot { margin-top: 26px; text-align: center; font-size: 12px; color: var(--ink-dim); }

/* ---------- 分析中 ---------- */
.analysis-box { margin: auto; text-align: center; padding: 30px; }
.analysis-orb { position: relative; width: 130px; height: 130px; margin: 0 auto 34px; }
.orb-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(240, 201, 135, .35);
}
.orb-ring-1 { animation: spin 5s linear infinite; border-top-color: var(--gold); }
.orb-ring-2 { inset: 18px; animation: spin 3.4s linear infinite reverse; border-bottom-color: var(--violet); }
@keyframes spin { to { transform: rotate(360deg); } }
.orb-core {
  position: absolute; inset: 42px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; color: var(--gold);
  background: radial-gradient(circle, rgba(240, 201, 135, .3), transparent 70%);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }
.analysis-text { font-size: 15px; color: var(--ink-soft); margin-bottom: 18px; min-height: 24px; }
.analysis-bar { width: 200px; height: 3px; margin: 0 auto; border-radius: 999px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.analysis-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--violet), var(--gold)); transition: width .3s ease; }
.analysis-sub { margin-top: 16px; font-size: 12px; color: var(--ink-dim); }

/* ---------- 结果 ---------- */
.result-scroll {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}
.result-hero {
  position: relative; height: 300px; overflow: hidden;
  display: flex; align-items: flex-end; justify-content: center;
}
.hero-scene { position: absolute; inset: 0; }
.hero-scene svg { width: 100%; height: 100%; }
.hero-mask {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(18, 16, 42, .35) 0%, rgba(18, 16, 42, .85) 62%, var(--bg) 100%);
}
.hero-home { position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 18px; }
.hero-text { position: relative; text-align: center; padding: 0 24px 26px; }
.hero-label { font-size: 13px; color: var(--ink-dim); letter-spacing: .18em; }
.hero-age {
  font-size: 76px; font-weight: 800; line-height: 1.05; margin: 6px 0 4px;
  background: linear-gradient(100deg, #fff 15%, var(--gold) 85%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-nick { font-size: 17px; font-weight: 700; color: var(--gold); }
.hero-diff {
  margin-top: 10px; font-size: 13px; color: var(--ink-soft);
  background: rgba(255, 255, 255, .07); border: 1px solid var(--line);
  display: inline-block; padding: 6px 14px; border-radius: 999px;
}
.hero-diff b { color: var(--gold); font-size: 15px; }

.result-tags { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 6px 20px 20px; }
.tag-chip {
  font-size: 12px; padding: 6px 13px; border-radius: 999px;
  background: rgba(240, 201, 135, .12); border: 1px solid rgba(240, 201, 135, .3); color: var(--gold);
}

.panel { margin: 0 16px 14px; padding: 20px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.panel-title small { display: block; margin-top: 5px; font-size: 11px; font-weight: 400; color: var(--ink-dim); }

.radar-wrap { display: grid; place-items: center; }
#radar-canvas { width: 100%; max-width: 320px; height: auto; }
.radar-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 14px; justify-content: center; }
.radar-legend span { font-size: 11px; color: var(--ink-dim); display: flex; align-items: center; gap: 5px; }
.radar-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

.dim-list { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.dim-row .dim-row-top { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.dim-row-top b { font-weight: 700; }
.dim-row-top .dim-age { margin-left: auto; color: var(--gold); font-size: 12px; }
.dim-row-top .dim-label { color: var(--ink-dim); font-size: 12px; }
.dim-row .dim-desc { margin-top: 4px; font-size: 12px; color: var(--ink-dim); line-height: 1.6; }
.dim-bar { margin-top: 8px; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.dim-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--violet), var(--gold)); }

.advice-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.advice-list li {
  position: relative; padding-left: 26px; font-size: 13px; line-height: 1.75; color: var(--ink-soft);
}
.advice-list li::before {
  content: ''; position: absolute; left: 4px; top: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
}

.panel-quote { background: rgba(240, 201, 135, .07); border-color: rgba(240, 201, 135, .22); }
.quote-text { font-size: 14px; line-height: 1.95; color: var(--ink-soft); }
.quote-peer { margin-top: 14px; font-size: 13px; color: var(--gold); font-weight: 600; text-align: center; }

.result-spacer { height: 12px; }

/* ---------- 底部操作 ---------- */
.action-bar {
  display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--line); background: rgba(18, 16, 42, .92);
  backdrop-filter: blur(10px);
}
.action-btn {
  flex: 1; padding: 13px 0; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink-soft);
  font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.action-btn:active { transform: scale(.98); }
.action-primary { color: #241804; border: 0; background: linear-gradient(100deg, var(--gold), var(--gold-deep)); }

/* ---------- 海报 ---------- */
.modal { position: absolute; inset: 0; display: none; place-items: center; background: rgba(8, 6, 18, .9); z-index: 50; padding: 20px; }
.modal.active { display: grid; }
.poster-wrap { width: 100%; max-width: 320px; text-align: center; }
#poster-canvas { width: 100%; height: auto; border-radius: 14px; }
.poster-img { display: block; width: 100%; height: auto; border-radius: 14px; }
.poster-hint { margin: 14px 0; font-size: 12px; color: var(--ink-dim); }
.poster-actions { display: flex; flex-direction: column; gap: 10px; }
.poster-actions .btn { text-decoration: none; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: absolute; left: 50%; bottom: calc(88px + var(--safe-b));
  transform: translate(-50%, 12px);
  max-width: 84%; padding: 10px 18px; border-radius: 999px;
  background: rgba(0, 0, 0, .82); color: #fff; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
