:root {
  color-scheme: light;
  --ink: #173047;
  --muted: #5f7485;
  --paper: rgba(255, 252, 238, 0.94);
  --paper-strong: #fffaf0;
  --line: rgba(37, 80, 109, 0.2);
  --blue: #3d9fe8;
  --deep-blue: #266eaa;
  --green: #48b77a;
  --gold: #f2c84b;
  --coral: #f47b5d;
  --violet: #8d73df;
  --shadow: 0 18px 44px rgba(38, 83, 113, 0.2);
  --radius: 8px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #b9e5ff;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.76) 0 1px, transparent 1px 100%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.46) 0 1px, transparent 1px 100%),
    linear-gradient(180deg, #75c8ff 0%, #c9efff 46%, #8bd47b 46%, #52b36d 100%);
  background-size: 100% 42px, 42px 100%, auto;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset-inline: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: 0;
  height: 38vh;
  background:
    linear-gradient(135deg, transparent 0 62%, rgba(255, 255, 255, 0.5) 62% 66%, transparent 66%),
    linear-gradient(225deg, transparent 0 64%, rgba(255, 255, 255, 0.42) 64% 68%, transparent 68%);
  background-size: 160px 76px, 190px 86px;
  opacity: 0.36;
}

body::after {
  bottom: 0;
  height: 34vh;
  background:
    linear-gradient(160deg, transparent 0 58%, rgba(33, 128, 79, 0.28) 58% 59%, transparent 59%),
    linear-gradient(20deg, transparent 0 64%, rgba(255, 242, 157, 0.38) 64% 65%, transparent 65%);
  background-size: 120px 70px, 150px 92px;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1160px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  background: rgba(255, 252, 238, 0.82);
  box-shadow: 0 8px 24px rgba(47, 112, 153, 0.14);
  backdrop-filter: blur(16px);
}

.brand-mark,
.top-actions,
.question-meta,
.stage-ribbon,
.result-actions,
.tag-row {
  display: flex;
  align-items: center;
}

.brand-mark {
  min-width: 0;
  gap: 10px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  text-decoration: none;
}

.brand-gem {
  width: 24px;
  height: 24px;
  border: 2px solid #fff6c5;
  border-radius: 7px;
  background:
    linear-gradient(135deg, #fff7a6 0 34%, #62d6ff 34% 68%, #6fcf8d 68%);
  box-shadow: 0 2px 0 rgba(33, 83, 110, 0.24);
  transform: rotate(45deg);
  flex: 0 0 auto;
}

.top-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.count-pill,
.text-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  color: var(--deep-blue);
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
}

.text-button {
  padding: 0 12px;
  cursor: pointer;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.quest-layout {
  display: grid;
  grid-template-columns: minmax(310px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: stretch;
}

.spirit-stage,
.quiz-panel,
.result-hero,
.detail-panel,
.spirit-strip {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.spirit-stage {
  position: sticky;
  top: 16px;
  min-height: 640px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(87, 193, 255, 0.92) 0%, rgba(212, 245, 255, 0.92) 45%, rgba(141, 214, 129, 0.96) 45% 100%);
}

.skyline {
  position: absolute;
  inset: auto 0 34%;
  height: 170px;
  background:
    linear-gradient(180deg, rgba(251, 237, 169, 0.0), rgba(251, 237, 169, 0.52)),
    linear-gradient(90deg, transparent 0 10%, rgba(255, 251, 218, 0.74) 10% 13%, transparent 13% 20%, rgba(255, 251, 218, 0.74) 20% 24%, transparent 24% 100%);
  clip-path: polygon(0 100%, 0 72%, 9% 72%, 9% 48%, 13% 48%, 13% 68%, 20% 68%, 20% 30%, 24% 30%, 24% 62%, 33% 62%, 33% 76%, 46% 76%, 46% 45%, 50% 45%, 50% 76%, 65% 76%, 65% 58%, 71% 58%, 71% 72%, 83% 72%, 83% 42%, 87% 42%, 87% 72%, 100% 72%, 100% 100%);
  opacity: 0.72;
}

.tower {
  position: absolute;
  bottom: 54px;
  width: 64px;
  height: 120px;
  background: rgba(246, 231, 164, 0.84);
  clip-path: polygon(50% 0, 100% 32%, 88% 100%, 12% 100%, 0 32%);
}

.tower-left {
  left: 9%;
}

.tower-right {
  right: 12%;
  height: 148px;
}

.stage-copy {
  position: relative;
  z-index: 2;
  padding: 24px;
}

.eyebrow {
  margin: 0;
  color: var(--deep-blue);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
}

.stage-copy h1,
.result-copy h1 {
  margin: 8px 0 0;
  font-size: 3rem;
  line-height: 1.02;
  letter-spacing: 0;
}

.stage-copy p:last-child {
  max-width: 20rem;
  margin: 8px 0 0;
  color: #355b58;
  font-weight: 800;
}

.lead-image {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 56px;
  width: min(95%, 470px);
  max-height: 74%;
  object-fit: contain;
  filter: drop-shadow(0 28px 20px rgba(36, 87, 66, 0.24));
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 220ms ease;
}

.lead-image.switching {
  opacity: 0.12;
  transform: translateX(-50%) scale(0.96);
}

.stage-ribbon {
  position: absolute;
  z-index: 3;
  inset-inline: 16px;
  bottom: 16px;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius);
  background: rgba(255, 250, 233, 0.9);
  color: #26516a;
  font-weight: 900;
}

.quiz-panel {
  min-height: 640px;
  padding: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 247, 226, 0.94)),
    var(--paper);
}

.progress-area {
  margin-bottom: 14px;
}

.question-meta {
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.progress-track {
  height: 12px;
  margin-top: 10px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: var(--radius);
  background: rgba(49, 115, 137, 0.16);
}

.progress-track span {
  display: block;
  width: 6.25%;
  height: 100%;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--green), var(--gold), var(--coral));
  transition: width 180ms ease;
}

.question-card {
  display: grid;
  grid-template-rows: auto auto 1fr;
  min-height: 500px;
  padding: 22px;
  border: 1px solid rgba(41, 91, 117, 0.16);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(93, 188, 255, 0.16), transparent 42%),
    linear-gradient(315deg, rgba(245, 197, 75, 0.2), transparent 38%),
    rgba(255, 255, 255, 0.62);
}

.scene-label {
  width: fit-content;
  margin: 0 0 12px;
  padding: 6px 10px;
  border: 1px solid rgba(41, 91, 117, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.62);
  color: var(--deep-blue);
  font-size: 0.86rem;
  font-weight: 900;
}

.question-card h2 {
  min-height: 5.8rem;
  margin: 0;
  font-size: 1.9rem;
  line-height: 1.26;
  letter-spacing: 0;
}

.answer-list {
  display: grid;
  gap: 12px;
  align-content: start;
  margin-top: 20px;
}

.answer-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 72px;
  padding: 12px;
  border: 2px solid rgba(41, 91, 117, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
}

.answer-option:hover {
  transform: translateY(-1px);
  border-color: rgba(61, 159, 232, 0.55);
  background: #ffffff;
}

.answer-option.selected {
  border-color: var(--coral);
  background: #fff4dc;
  box-shadow: 0 8px 18px rgba(244, 123, 93, 0.16);
}

.answer-key {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-weight: 900;
}

.answer-option:nth-child(2) .answer-key {
  background: var(--green);
}

.answer-option:nth-child(3) .answer-key {
  background: var(--gold);
  color: #4f3f08;
}

.answer-option:nth-child(4) .answer-key {
  background: var(--violet);
}

.answer-text {
  min-width: 0;
}

.answer-text strong {
  display: block;
  font-size: 1.02rem;
  line-height: 1.34;
}

.answer-text span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.step-nav {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 12px;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  border-radius: var(--radius);
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  border: 0;
  background: linear-gradient(180deg, #ffb84e, #f47b5d);
  color: #462510;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.42), 0 10px 18px rgba(244, 123, 93, 0.22);
}

.secondary-button {
  border: 2px solid rgba(41, 91, 117, 0.18);
  background: rgba(255, 255, 255, 0.78);
  color: var(--deep-blue);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

.spirit-strip {
  margin-top: 16px;
  padding: 12px;
  background: rgba(255, 252, 238, 0.82);
}

.strip-list {
  display: grid;
  grid-template-columns: repeat(16, minmax(58px, 1fr));
  gap: 8px;
}

.strip-item {
  position: relative;
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid rgba(41, 91, 117, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  text-align: center;
}

.strip-item.active {
  border-color: var(--coral);
  background: #fff4dc;
}

.strip-item img {
  display: block;
  width: 48px;
  height: 48px;
  margin: 0 auto 4px;
  object-fit: contain;
}

.strip-item span {
  display: block;
  overflow: hidden;
  color: #335368;
  font-size: 0.74rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strip-item em {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  background: var(--coral);
  color: #fff;
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
}

.result-screen {
  padding-bottom: 24px;
}

.result-hero {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.18fr);
  gap: 18px;
  overflow: hidden;
  padding: 18px;
  background:
    linear-gradient(120deg, rgba(80, 184, 229, 0.3), transparent 48%),
    linear-gradient(300deg, rgba(242, 200, 75, 0.28), transparent 42%),
    rgba(255, 252, 238, 0.92);
}

.result-art {
  position: relative;
  min-height: 520px;
  border: 1px solid rgba(41, 91, 117, 0.14);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(117, 200, 255, 0.86), rgba(206, 244, 255, 0.86) 46%, rgba(123, 204, 103, 0.9) 46%);
  overflow: hidden;
}

.result-art::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 35%;
  background:
    linear-gradient(155deg, transparent 0 62%, rgba(44, 141, 73, 0.35) 62% 64%, transparent 64%),
    linear-gradient(25deg, transparent 0 64%, rgba(255, 242, 157, 0.32) 64% 66%, transparent 66%);
  background-size: 130px 70px, 170px 88px;
}

.result-art img {
  position: absolute;
  left: 50%;
  bottom: 42px;
  width: min(96%, 500px);
  max-height: 86%;
  object-fit: contain;
  filter: drop-shadow(0 26px 18px rgba(36, 87, 66, 0.22));
  transform: translateX(-50%);
}

.result-number {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: rgba(255, 250, 233, 0.9);
  color: var(--deep-blue);
  font-weight: 900;
}

.result-copy {
  align-self: center;
  padding: 24px 18px;
}

.result-title {
  margin: 8px 0 0;
  color: var(--deep-blue);
  font-size: 1.2rem;
  font-weight: 900;
}

.result-profile {
  max-width: 44rem;
  margin: 18px 0 0;
  color: #2b4657;
  font-size: 1.08rem;
  line-height: 1.82;
}

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

.tag-row span {
  padding: 7px 10px;
  border: 1px solid rgba(41, 91, 117, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  color: var(--deep-blue);
  font-weight: 900;
}

.family-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.family-row:empty {
  display: none;
}

.family-chip {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 116px;
  max-width: 170px;
  padding: 6px 9px 6px 6px;
  border: 1px solid rgba(41, 91, 117, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
}

.family-chip.active {
  border-color: var(--coral);
  background: #fff4dc;
}

.family-chip img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.family-chip span {
  min-width: 0;
  overflow: hidden;
  color: #335368;
  font-size: 0.84rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-actions {
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.result-actions .primary-button,
.result-actions .secondary-button {
  min-width: 136px;
  padding-inline: 18px;
}

.copy-status {
  min-height: 1.4em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.result-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.detail-panel {
  min-height: 210px;
  padding: 18px;
  background: rgba(255, 252, 238, 0.9);
}

.detail-panel h2 {
  margin: 10px 0 0;
  font-size: 1.25rem;
  line-height: 1.34;
  letter-spacing: 0;
}

.detail-panel p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.72;
}

@media (max-width: 980px) {
  .quest-layout,
  .result-hero,
  .result-details {
    grid-template-columns: 1fr;
  }

  .spirit-stage {
    position: relative;
    top: auto;
    min-height: 470px;
  }

  .quiz-panel {
    min-height: auto;
  }

  .question-card {
    min-height: auto;
  }

  .strip-list {
    grid-template-columns: repeat(8, minmax(56px, 1fr));
  }

  .result-art {
    min-height: 430px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-bottom: 22px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-mark {
    font-size: 0.94rem;
  }

  .count-pill {
    display: none;
  }

  .spirit-stage {
    min-height: 390px;
  }

  .stage-copy,
  .quiz-panel,
  .question-card,
  .result-copy {
    padding: 16px;
  }

  .stage-copy h1,
  .result-copy h1 {
    font-size: 2.3rem;
  }

  .question-card h2 {
    min-height: auto;
    font-size: 1.45rem;
  }

  .answer-option {
    grid-template-columns: 30px minmax(0, 1fr);
    min-height: 78px;
    padding: 10px;
  }

  .answer-key {
    width: 30px;
    height: 30px;
  }

  .answer-text strong {
    font-size: 0.96rem;
  }

  .answer-text span {
    font-size: 0.84rem;
  }

  .step-nav {
    grid-template-columns: 1fr;
  }

  .strip-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .result-art {
    min-height: 360px;
  }

  .result-profile {
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
