:root {
  color-scheme: light;
  --bg: #f7f3ea;
  --surface: #ffffff;
  --surface-soft: #fffaf0;
  --ink: #24302f;
  --muted: #697574;
  --line: #e6ded0;
  --gold: #c9942e;
  --green: #2f9b7c;
  --blue: #4b83c3;
  --rose: #c96f62;
  --shadow: 0 18px 60px rgba(66, 54, 37, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 0%, rgba(201, 148, 46, 0.18), transparent 30%),
    radial-gradient(circle at 90% 12%, rgba(75, 131, 195, 0.16), transparent 26%),
    linear-gradient(180deg, #fffdf8, var(--bg));
  color: var(--ink);
}

html {
  scroll-behavior: smooth;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(960px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 36px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.start-screen {
  min-height: calc(100vh - 130px);
  display: none;
  align-content: center;
}

.start-screen.active {
  display: block;
}

.intro-copy {
  max-width: 760px;
}

.start-cta {
  margin-top: 12px;
  padding-inline: 28px;
}

.profile-screen.active {
  display: grid;
  max-width: 640px;
  margin: 0 auto;
  gap: 18px;
}

.profile-copy {
  max-width: 640px;
}

.kicker {
  margin: 0 0 12px;
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 680px;
  margin-bottom: 18px;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1.08;
  letter-spacing: 0;
}

.lede,
.result-desc {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(16px, 1.8vw, 19px);
  line-height: 1.8;
}

.prologue-card {
  max-width: 760px;
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 34px rgba(66, 54, 37, 0.08);
}

.prologue-card strong {
  display: block;
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 18px;
}

.prologue-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.prologue-card p + p {
  margin-top: 10px;
  color: var(--green);
  font-weight: 900;
}

.intro-points {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.intro-points li {
  position: relative;
  padding-left: 18px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
}

.intro-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
}

.type-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 760px;
  margin-top: 28px;
}

.type-strip span,
.tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.book-cover {
  position: relative;
  max-width: 760px;
  min-height: 210px;
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid rgba(201, 148, 46, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(9, 18, 23, 0.76), rgba(9, 18, 23, 0.18)),
    url("./assets/academy-bg.png") center / cover;
  box-shadow: var(--shadow);
}

.book-cover::before {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(255, 233, 178, 0.32);
  border-radius: 6px;
  pointer-events: none;
}

.book-cover div {
  position: absolute;
  left: 26px;
  right: 26px;
  bottom: 24px;
  display: grid;
  gap: 8px;
  color: #fff7df;
}

.book-cover span,
.book-cover small {
  color: rgba(255, 247, 223, 0.74);
  font-size: 12px;
  font-weight: 900;
}

.book-cover strong {
  max-width: 360px;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.08;
}

.entry-form,
.panel,
.result-hero,
.quiz-screen {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.entry-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions button {
  flex: 1 1 160px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 155, 124, 0.22);
  outline-offset: 2px;
}

.primary-button,
.secondary-button,
.ghost-button,
.download-link {
  min-height: 46px;
  border-radius: 8px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 900;
  text-decoration: none;
}

.primary-button {
  border: 0;
  background: var(--ink);
  color: #fff;
}

.secondary-button,
.ghost-button,
.download-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.fineprint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.bazi-main {
  font-size: clamp(20px, 5vw, 34px);
  font-weight: 900;
  color: var(--ink);
  margin: 12px 0;
}

.bazi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.bazi-cell {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fffaf1;
  display: grid;
  gap: 4px;
}

.bazi-cell span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.bazi-cell strong {
  font-size: 24px;
  color: var(--ink);
}

.bazi-cell small {
  color: var(--muted);
  line-height: 1.45;
}

.quiz-screen {
  padding: clamp(20px, 4vw, 38px);
}

.quiz-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 260px);
  gap: 20px;
  align-items: start;
  margin-bottom: 26px;
}

.simulator-hud {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.simulator-hud[hidden] {
  display: none !important;
}

.hud-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffaf0;
}

.hud-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.hud-card strong {
  color: var(--ink);
  font-size: 18px;
}

.event-line {
  margin: 0 0 18px;
  border-left: 4px solid var(--green);
  padding: 10px 12px;
  border-radius: 0 8px 8px 0;
  background: #eefaf4;
  color: var(--muted);
  line-height: 1.65;
}

.quiz-head h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(28px, 4.8vw, 48px);
  line-height: 1.16;
}

.progress-box {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-weight: 900;
}

.progress-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eee6d7;
}

#progressBar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 240ms ease;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.scale-grid {
  display: grid;
  gap: 12px;
}

.choice-card {
  width: 100%;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  text-align: left;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.choice-card:hover {
  border-color: rgba(47, 155, 124, 0.65);
  box-shadow: 0 12px 30px rgba(47, 155, 124, 0.12);
  transform: translateY(-2px);
}

.choice-card.selected {
  border-color: var(--green);
  background: #eefaf4;
  box-shadow: 0 0 0 3px rgba(47, 155, 124, 0.14);
}

.choice-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 17px;
}

.choice-card span {
  color: var(--muted);
  line-height: 1.55;
}

.scale-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface);
}

.scale-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: 17px;
  line-height: 1.5;
}

.scale-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.scale-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.scale-option {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.scale-option.selected {
  border-color: var(--green);
  background: #eefaf4;
  box-shadow: 0 0 0 3px rgba(47, 155, 124, 0.14);
}

.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}

.quiz-actions button {
  min-width: 120px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.result-hero {
  padding: clamp(24px, 5vw, 48px);
  margin-bottom: 18px;
  background: linear-gradient(135deg, #ffffff, #fff6df);
}

.result-title-block {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: clamp(18px, 4vw, 34px);
  align-items: center;
}

.avatar-card {
  position: relative;
  min-height: 190px;
  border: 1px solid rgba(201, 148, 46, 0.34);
  border-radius: 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  background:
    radial-gradient(circle at 50% 28%, var(--avatar-glow, rgba(47, 155, 124, 0.22)), transparent 42%),
    linear-gradient(180deg, #fffdf8, #f6efe1);
}

.avatar-card::after {
  content: "";
  position: absolute;
  width: 74px;
  height: 10px;
  bottom: 38px;
  border-radius: 999px;
  background: rgba(36, 48, 47, 0.09);
}

#archetypeAvatar {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  background: var(--avatar-color, #2f9b7c);
  color: #fff;
  font-size: 56px;
  box-shadow: 0 18px 34px rgba(66, 54, 37, 0.18);
}

#avatarCaption {
  position: relative;
  z-index: 1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.ending-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(20px, 4vw, 32px);
  margin-bottom: 18px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.ending-card h3 {
  margin-bottom: 10px;
  font-size: clamp(26px, 4vw, 42px);
}

.ending-card p {
  color: var(--muted);
  line-height: 1.75;
}

.share-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.share-copy span {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.6;
}

#archetypeName {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: clamp(42px, 7vw, 82px);
  line-height: 1;
}

.type-code {
  margin-bottom: 18px;
  color: var(--gold);
  font-size: clamp(18px, 2.8vw, 28px);
  font-weight: 900;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
  gap: 18px;
}

.panel {
  padding: 22px;
}

.panel h3 {
  margin-bottom: 16px;
  font-size: 20px;
}

#radarCanvas {
  width: 100%;
  max-width: 520px;
}

.major-list,
.career-list,
.domain-list,
.ability-list,
.fate-talent-list {
  display: grid;
  gap: 10px;
}

.major-item,
.career-item,
.domain-item,
.ability-item,
.fate-talent-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.major-top,
.domain-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 900;
}

.major-line {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.major-line strong {
  color: var(--ink);
}

.score-line {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eadfca;
}

.score-line span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.ability-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.ability-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.fate-talent-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--ink);
}

.fate-talent-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.ai-fate-card {
  background: #eefaf4;
  border-color: rgba(47, 155, 124, 0.28);
}

.local-fate-details {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.local-fate-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 900;
}

.local-fate-details .fate-talent-item {
  margin-top: 10px;
}

.reality-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

#posterCanvas {
  display: none;
}

.poster-preview {
  margin-top: 18px;
  display: grid;
  gap: 12px;
  justify-items: start;
}

.poster-preview img {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.download-link {
  display: inline-grid;
  place-items: center;
}

@media (max-width: 920px) {
  .start-screen.active,
  .profile-screen.active,
  .result-grid,
  .quiz-head,
  .simulator-hud,
  .share-copy,
  .choice-grid,
  .result-title-block {
    grid-template-columns: 1fr;
  }

  .app-shell {
    width: min(100% - 18px, 960px);
    padding-top: 10px;
    padding-bottom: 28px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 -9px 16px;
    padding: 8px 9px;
    background: rgba(255, 253, 248, 0.86);
    backdrop-filter: blur(12px);
  }

  .brand {
    font-size: 15px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .ghost-button {
    min-height: 38px;
    padding: 0 12px;
    font-size: 13px;
  }

  .start-screen {
    min-height: auto;
  }

  .start-screen.active {
    gap: 16px;
  }

  h1 {
    font-size: clamp(32px, 9vw, 44px);
    line-height: 1.12;
  }

  .lede {
    font-size: 16px;
    line-height: 1.72;
  }

  .prologue-card {
    padding: 14px;
  }

  .type-strip {
    gap: 8px;
    margin-top: 18px;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }

  .type-strip span {
    flex: 0 0 auto;
  }

  .book-cover {
    min-height: 170px;
  }

  .entry-form,
  .quiz-screen,
  .ending-card,
  .panel,
  .result-hero {
    padding: 16px;
  }

  label {
    font-size: 13px;
  }

  input,
  select,
  .primary-button,
  .secondary-button,
  .download-link {
    min-height: 50px;
  }

  .quiz-head {
    gap: 12px;
    margin-bottom: 16px;
  }

  .quiz-head h2 {
    font-size: clamp(24px, 8vw, 34px);
  }

  .choice-card {
    min-height: auto;
    padding: 14px;
  }

  .scale-card {
    padding: 14px;
  }

  .scale-card strong {
    font-size: 15px;
    line-height: 1.45;
  }

  .scale-labels {
    gap: 12px;
    font-size: 12px;
    line-height: 1.35;
  }

  .scale-options {
    gap: 6px;
  }

  .scale-option {
    min-height: 46px;
    border-radius: 10px;
  }

  .quiz-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 18px -16px -16px;
    padding: 10px 16px;
    background: rgba(255, 253, 248, 0.92);
    backdrop-filter: blur(12px);
  }

  .quiz-actions button {
    width: 100%;
  }

  .avatar-card {
    min-height: 168px;
  }

  .bazi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .major-top,
  .domain-top,
  .career-item strong {
    align-items: flex-start;
  }

  #archetypeAvatar {
    width: 100px;
    height: 100px;
    font-size: 50px;
  }

  #archetypeName {
    font-size: clamp(40px, 13vw, 62px);
  }

  .result-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 18px -9px 0;
    padding: 10px 9px;
    background: rgba(255, 253, 248, 0.92);
    backdrop-filter: blur(12px);
  }

  .result-actions button {
    flex: 1 1 150px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding: 10px 12px 28px;
  }

  .topbar {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  h1 {
    font-size: clamp(30px, 8.2vw, 38px);
  }

  .book-cover {
    min-height: 126px;
    margin-top: 14px;
  }

  .book-cover div {
    left: 16px;
    right: 16px;
    bottom: 14px;
    gap: 4px;
  }

  .book-cover strong {
    max-width: 260px;
    font-size: clamp(20px, 6.4vw, 26px);
  }

  .book-cover span,
  .book-cover small {
    font-size: 10px;
  }

  .type-strip {
    flex-wrap: nowrap;
    max-width: none;
    margin-inline: -12px;
    padding: 0 12px 6px;
  }

  .type-strip span {
    font-size: 12px;
    padding: 7px 10px;
  }

  .entry-form {
    padding: 16px;
  }

  .form-actions button,
  .start-cta {
    width: 100%;
  }

  .quiz-screen {
    padding: 14px;
  }

  .quiz-head h2 {
    font-size: clamp(25px, 9vw, 34px);
  }

  .choice-grid,
  .scale-grid {
    gap: 10px;
  }

  .bazi-grid {
    grid-template-columns: 1fr;
  }

  .result-hero,
  .ending-card,
  .panel {
    padding: 14px;
  }

  .career-item,
  .major-card,
  .domain-card,
  .fate-talent-item {
    padding: 12px;
  }
}
