:root {
  color-scheme: dark;
  --bg: #090906;
  --surface: rgba(28, 26, 19, .72);
  --surface-strong: rgba(37, 33, 22, .88);
  --line: rgba(210, 181, 118, .34);
  --line-soft: rgba(234, 224, 199, .14);
  --text: #f1ede3;
  --muted: #aaa394;
  --gold: #c9aa6c;
  --gold-bright: #e1c58a;
  --olive: #55583b;
  --wine: #4e2725;
  --radius: 26px;
  --serif: "Songti SC", "Noto Serif SC", "STSong", Georgia, serif;
  --sans: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--bg); }

body {
  min-height: 100dvh;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 78% 18%, rgba(105, 82, 38, .16), transparent 30%),
    radial-gradient(circle at 10% 68%, rgba(74, 78, 49, .12), transparent 34%),
    #090906;
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 4px; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100dvh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, rgba(18, 17, 12, .5), rgba(3, 3, 2, .82));
}

.screen { min-height: 100dvh; padding: max(26px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); }
.fade-in { animation: fade .48s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.brand { font: 500 .88rem/1 var(--serif); letter-spacing: .28em; color: var(--text); }
.brand .slash { color: var(--gold); margin: 0 .35em; }

.home {
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-inline: 0;
  background: #070705;
}
.home .brand { text-align: center; margin-top: 14px; position: relative; z-index: 3; }
.hero-stage { position: absolute; inset: 0; background: url("./assets/moon.webp") center 42% / cover no-repeat; }
.hero-stage::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(4,4,2,.08) 0%, rgba(6,6,3,.02) 42%, rgba(5,5,3,.3) 58%, #070705 86%); }
.home-content { align-self: end; padding: 0 26px 126px; text-align: center; position: relative; z-index: 2; }
.home h1 { margin: 0; font: 400 clamp(2.1rem, 9vw, 3rem)/1.42 var(--serif); letter-spacing: .08em; text-shadow: 0 2px 20px rgba(0,0,0,.7); }
.home .meta { margin: 20px 0 0; color: var(--gold); letter-spacing: .16em; font: 400 .95rem/1.6 var(--serif); }
.home-actions { position: absolute; z-index: 3; left: 24px; right: 24px; bottom: max(28px, env(safe-area-inset-bottom)); }

.primary, .secondary {
  min-height: 58px; border-radius: 999px; color: var(--text); cursor: pointer;
  border: 1px solid var(--line); transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.primary { width: 100%; background: linear-gradient(105deg, rgba(76,80,49,.72), rgba(108,72,38,.62)); box-shadow: inset 0 1px rgba(255,255,255,.05), 0 14px 40px rgba(0,0,0,.36); }
.primary:hover, .secondary:hover { transform: translateY(-2px); border-color: rgba(225,197,138,.65); }
.secondary { background: rgba(255,255,255,.035); }

.quiz { display: flex; flex-direction: column; }
.quiz-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin-bottom: 16px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); cursor: pointer; font-size: 1.55rem; }
.count { text-align: center; font-family: var(--serif); font-size: 1rem; letter-spacing: .12em; }
.progress { height: 3px; background: rgba(255,255,255,.12); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--olive), var(--gold-bright)); transition: width .35s ease; }
.question-area { display: flex; flex: 1; flex-direction: column; justify-content: center; padding: 38px 0 22px; }
.dimension { color: var(--gold); font-size: .78rem; letter-spacing: .16em; text-align: center; }
.question-area h2 { margin: 34px auto 0; max-width: 440px; text-align: center; font: 400 clamp(1.8rem, 7vw, 2.45rem)/1.45 var(--serif); letter-spacing: .035em; }
.instruction { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: .9rem; }
.scale-card { margin-top: 46px; padding: 28px 22px 24px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, rgba(41,37,25,.58), rgba(16,15,11,.55)); backdrop-filter: blur(16px); }
.scale-labels { display: flex; justify-content: space-between; gap: 20px; font: 400 .92rem/1.55 var(--serif); }
.scale-labels span:last-child { text-align: right; }
.scale-options { display: flex; justify-content: space-between; align-items: center; margin: 28px 4px 0; position: relative; }
.scale-options::before { content: ""; position: absolute; left: 8%; right: 8%; height: 1px; background: rgba(210,181,118,.42); }
.choice { width: 38px; height: 38px; padding: 0; border-radius: 50%; border: 1px solid rgba(210,181,118,.64); background: #12120d; position: relative; z-index: 1; cursor: pointer; transition: .2s ease; }
.choice:nth-child(2), .choice:nth-child(4) { width: 32px; height: 32px; }
.choice:nth-child(3) { width: 26px; height: 26px; }
.choice:hover { transform: scale(1.08); border-color: var(--gold-bright); }
.choice.selected { background: #9b762a; border-color: var(--gold-bright); box-shadow: 0 0 0 5px rgba(201,170,108,.1), 0 0 22px rgba(201,170,108,.4); }
.hint { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 22px; }
.quiz-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: 12px; }

@media (max-width: 480px) {
  .screen.quiz {
    min-height: 100svh;
    padding: max(16px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  }
  .quiz-top {
    grid-template-columns: 38px 1fr 38px;
    margin-bottom: 10px;
  }
  .icon-btn { width: 38px; height: 38px; font-size: 1.35rem; }
  .count { font-size: .94rem; }
  .question-area {
    flex: 0 1 auto;
    justify-content: flex-start;
    padding: clamp(34px, 8vh, 62px) 0 16px;
  }
  .dimension { font-size: .75rem; }
  .question-area h2 {
    margin-top: 22px;
    max-width: 21rem;
    font-size: clamp(1.72rem, 7.1vw, 2rem);
    line-height: 1.34;
    letter-spacing: .015em;
  }
  .instruction { margin-top: 16px; font-size: .86rem; }
  .scale-card {
    margin-top: 28px;
    padding: 20px 16px 18px;
    border-radius: 22px;
  }
  .scale-labels {
    align-items: flex-start;
    gap: 28px;
    font-size: .88rem;
    line-height: 1.5;
  }
  .scale-labels span { width: calc(50% - 14px); }
  .scale-options { margin: 20px 2px 0; }
  .choice { width: 34px; height: 34px; }
  .choice:nth-child(2), .choice:nth-child(4) { width: 29px; height: 29px; }
  .choice:nth-child(3) { width: 24px; height: 24px; }
  .hint { margin-top: 15px; font-size: .76rem; }
  .quiz-actions {
    margin-top: auto;
    grid-template-columns: .78fr 1.22fr;
    gap: 10px;
  }
  .quiz-actions .primary,
  .quiz-actions .secondary { min-height: 54px; }
}

.result { display: flex; flex-direction: column; gap: 18px; padding-bottom: 30px; }
.result-top { display: flex; align-items: center; justify-content: space-between; }
.text-btn { border: 0; padding: 10px 0; color: var(--gold); background: transparent; cursor: pointer; }
.type-hero { position: relative; overflow: hidden; min-height: 290px; padding: 34px 218px 30px 28px; border: 1px solid var(--line); border-radius: 28px; background: linear-gradient(135deg, rgba(78,82,48,.7), rgba(25,23,16,.86) 52%, rgba(78,39,37,.72)); }
.type-hero::after { content: ""; position: absolute; width: 180px; height: 180px; border: 1px solid rgba(225,197,138,.24); border-radius: 50%; right: -55px; top: -85px; box-shadow: 0 0 48px rgba(201,170,108,.12); }
.avatar { position: absolute; z-index: 1; top: 28px; right: 24px; width: 174px; aspect-ratio: 1; border-radius: 50%; border: 1px solid rgba(225,197,138,.55); background-image: url("./assets/personality-avatars.webp"); background-repeat: no-repeat; background-size: 400% 400%; box-shadow: 0 18px 45px rgba(0,0,0,.42), 0 0 0 7px rgba(201,170,108,.06); }
.kicker { margin: 0; color: var(--gold); font-size: .69rem; letter-spacing: .25em; }
.type-code { margin: 10px 0 0; font: 500 4.2rem/1 var(--serif); letter-spacing: .06em; }
.type-name { margin: 12px 0 0; font: 400 1.35rem/1.5 var(--serif); }
.tagline { margin: 10px 0 0; color: var(--muted); font-size: .9rem; line-height: 1.7; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-top: 2px; }
.section-title h2 { margin: 0; font: 400 1.28rem/1.4 var(--serif); }
.confidence { color: var(--gold); font-size: .78rem; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); backdrop-filter: blur(18px); }
.meter + .meter { margin-top: 18px; }
.meter-label { display: flex; justify-content: space-between; color: var(--text); font: .9rem/1.4 var(--serif); }
.meter-track { height: 6px; margin-top: 8px; border-radius: 99px; overflow: hidden; background: rgba(255,255,255,.11); }
.meter-fill { height: 100%; background: linear-gradient(90deg, var(--olive), var(--gold-bright)); border-radius: inherit; }
.tags { display: flex; gap: 8px; flex-wrap: wrap; }
.tag { padding: 9px 14px; border: 1px solid var(--line); border-radius: 99px; color: #ded6c3; background: rgba(90,87,54,.18); font-size: .8rem; }
.insight h3 { margin: 0; font: 400 1.16rem/1.5 var(--serif); }
.insight p { margin: 12px 0 0; color: var(--muted); font-size: .92rem; line-height: 1.9; }
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.analysis { position: relative; min-height: 190px; }
.analysis-no { display: block; margin-bottom: 12px; color: var(--gold); font: .72rem/1 var(--serif); letter-spacing: .18em; }
.analysis h3, .growth h3 { margin: 0; font: 400 1.05rem/1.5 var(--serif); }
.analysis p, .growth p { margin: 10px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.85; }
.analysis ul { margin: 12px 0 0; padding-left: 1.1em; color: var(--muted); font-size: .88rem; line-height: 1.85; }
.growth { background: linear-gradient(135deg, rgba(78,82,48,.35), rgba(32,26,17,.76)); }
.result .primary[data-action="save"] { margin-top: 2px; }
.result .primary { margin-top: auto; }
.disclaimer { margin: 0; text-align: center; color: #777166; font-size: .72rem; line-height: 1.6; }
.save-overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.82); backdrop-filter: blur(12px); }
.save-sheet { position: relative; width: min(100%, 420px); max-height: 92dvh; overflow: auto; padding: 22px; text-align: center; border: 1px solid var(--line); border-radius: 26px; background: #12110c; box-shadow: 0 30px 90px rgba(0,0,0,.65); }
.save-sheet p { margin: 0; font: 400 1.2rem/1.4 var(--serif); }
.save-sheet span { display: block; margin-top: 6px; color: var(--muted); font-size: .8rem; }
.save-sheet img { display: block; width: min(100%, 320px); margin: 18px auto; border-radius: 16px; box-shadow: 0 16px 40px rgba(0,0,0,.38); }
.save-close { position: absolute; top: 10px; right: 12px; width: 40px; height: 40px; border: 0; color: var(--text); background: transparent; font-size: 1.6rem; cursor: pointer; }
.download-card { display: grid; min-height: 52px; place-items: center; border: 1px solid var(--line); border-radius: 999px; color: var(--text); text-decoration: none; background: linear-gradient(105deg, rgba(76,80,49,.72), rgba(108,72,38,.62)); }

@media (max-width: 480px) {
  .type-hero { min-height: 0; padding: 224px 22px 24px; text-align: center; }
  .avatar { top: 24px; left: 50%; right: auto; width: 176px; transform: translateX(-50%); }
  .type-code { font-size: 3.8rem; }
  .analysis-grid { grid-template-columns: 1fr; }
  .analysis { min-height: 0; }
}

@media (min-width: 740px) {
  body { padding: 28px 0; }
  .app-shell { min-height: calc(100dvh - 56px); border: 1px solid rgba(225,197,138,.18); border-radius: 38px; box-shadow: 0 40px 100px rgba(0,0,0,.48); }
  .screen { min-height: calc(100dvh - 58px); border-radius: inherit; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
