:root {
  --bg: #17130f;
  --ink: #201a14;
  --muted: #6c6255;
  --line: rgba(62, 44, 24, 0.2);
  --gold: #c79a42;
  --paper: #f5eddb;
  --paper-strong: #fff6e4;
  --shadow: 0 18px 48px rgba(12, 8, 4, 0.28);
  --page-bg-image: none;
  --page-overlay: linear-gradient(180deg, rgba(245, 237, 219, 0.88), rgba(245, 237, 219, 0.96));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  background-image:
    var(--page-overlay),
    var(--page-bg-image),
    radial-gradient(circle at top left, rgba(197, 154, 66, 0.16), transparent 26rem),
    radial-gradient(circle at bottom right, rgba(53, 77, 103, 0.22), transparent 28rem);
  background-color: var(--bg);
  background-repeat: no-repeat;
  background-size: cover, cover, auto, auto;
  background-position: center, center, top left, bottom right;
  background-attachment: fixed, fixed, scroll, scroll;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.82;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.screen {
  min-height: calc(100svh - 40px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero {
  justify-content: space-between;
  padding-top: 8px;
}

.hero-copy {
  padding: 18px 0 2px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #a56f17;
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 11em;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(30px, 8vw, 38px);
  line-height: 1.16;
  letter-spacing: 0;
}

h2 {
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 24px;
  line-height: 1.25;
}

.lead {
  max-width: 27em;
  margin-top: 14px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.75;
}

.house-emblem {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 1px solid rgba(255, 246, 228, 0.7);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 247, 231, 0.86), rgba(239, 225, 199, 0.86)),
    radial-gradient(circle at top, rgba(197, 154, 66, 0.18), transparent 55%);
  box-shadow: var(--shadow);
}

.house-chip {
  --house-color: #c79a42;
  display: grid;
  min-height: 82px;
  padding: 12px;
  align-content: space-between;
  border: 1px solid rgba(62, 44, 24, 0.14);
  border-left: 5px solid var(--house-color);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.68);
  color: var(--ink);
}

.house-chip b {
  color: var(--house-color);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 12px;
  letter-spacing: 0;
}

.house-chip span {
  display: block;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.25;
}

.house-chip.gryffindor {
  --house-color: #9c312b;
}

.house-chip.ravenclaw {
  --house-color: #315f87;
}

.house-chip.hufflepuff {
  --house-color: #b99532;
}

.house-chip.slytherin {
  --house-color: #2f6c50;
}

.info-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.info-pill {
  min-height: 76px;
  padding: 13px;
  border: 1px solid rgba(62, 44, 24, 0.14);
  border-radius: 8px;
  background: rgba(255, 246, 228, 0.76);
}

.info-pill strong {
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
  font-weight: 900;
}

.info-pill span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.choice-btn {
  width: 100%;
  min-height: 52px;
  border-radius: 8px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.primary-btn {
  color: #fff7e7;
  background: linear-gradient(180deg, #2a2117, #15100c);
  box-shadow: 0 10px 28px rgba(18, 13, 8, 0.24);
  font-size: 17px;
  font-weight: 900;
}

.secondary-btn {
  border: 1px solid rgba(255, 246, 228, 0.34);
  color: #fff7e7;
  background: rgba(255, 246, 228, 0.12);
  font-weight: 800;
}

.ghost-btn {
  color: rgba(255, 247, 231, 0.78);
  background: transparent;
}

.primary-btn:active,
.secondary-btn:active,
.choice-btn:active {
  transform: scale(0.985);
}

.footer-note {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 4px 0 0;
}

.back-btn {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 246, 228, 0.34);
  border-radius: 999px;
  background: rgba(255, 246, 228, 0.9);
  color: var(--ink);
  font-size: 21px;
}

.progress-wrap {
  flex: 1;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: rgba(255, 247, 231, 0.86);
  font-size: 13px;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f0c852, #fff7df);
}

.question-card,
.result-panel {
  border: 1px solid rgba(255, 246, 228, 0.72);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 248, 232, 0.93), rgba(232, 219, 194, 0.93)),
    radial-gradient(circle at top left, rgba(197, 154, 66, 0.12), transparent 60%);
  box-shadow: var(--shadow);
}

.question-card {
  display: flex;
  align-items: center;
  min-height: clamp(220px, 35svh, 280px);
  padding: 22px;
}

.question-text {
  font-size: clamp(19px, 5.2vw, 22px);
  line-height: 1.55;
  font-weight: 750;
}

.choices {
  display: grid;
  gap: 11px;
}

.choice-btn {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 66px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 246, 228, 0.52);
  background: rgba(244, 237, 222, 0.9);
  color: #211b15;
  text-align: left;
  font-size: 15.5px;
  line-height: 1.45;
  box-shadow: 0 10px 24px rgba(6, 8, 13, 0.18);
}

.choice-letter {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(41, 30, 18, 0.2);
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.74);
  color: #7a5521;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
}

.choice-btn.selected {
  border-color: #f0c852;
  box-shadow: inset 0 0 0 2px rgba(240, 200, 82, 0.28), 0 10px 24px rgba(6, 8, 13, 0.18);
}

.result-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.result-mark {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  border-radius: 8px;
}

.result-title {
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 900;
}

.result-sub {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
}

.judgment {
  margin-top: 16px;
  padding: 15px;
  border-left: 4px solid var(--gold);
  background: rgba(185, 134, 50, 0.11);
  font-size: 18px;
  line-height: 1.65;
  font-weight: 800;
}

.result-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.mini-card {
  padding: 14px;
  border: 1px solid rgba(62, 44, 24, 0.14);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.62);
}

.mini-card b {
  display: block;
  margin-bottom: 6px;
}

.mini-card strong {
  display: block;
  margin-bottom: 6px;
  color: #2a2116;
  font-size: 15px;
  line-height: 1.45;
}

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

.score-list {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.score-row {
  display: grid;
  grid-template-columns: 74px 1fr 34px;
  gap: 9px;
  align-items: center;
  font-size: 13px;
}

.score-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31, 28, 24, 0.1);
}

.score-fill {
  height: 100%;
  border-radius: inherit;
}

body[data-page="quiz"] .progress-label,
body[data-page="result"] .ghost-btn,
body[data-page="share"] .ghost-btn,
body[data-page="share"] .share-tip {
  color: rgba(255, 250, 240, 0.78);
}

.locked-report {
  margin-top: 14px;
  padding: 15px;
  border: 1px dashed rgba(62, 44, 24, 0.2);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.62);
  color: var(--muted);
  line-height: 1.65;
}

.actions {
  display: grid;
  gap: 10px;
}

.share-action-row {
  display: flex;
  justify-content: center;
  gap: 18px;
}

.text-btn {
  min-height: 34px;
  padding: 0 4px;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 247, 231, 0.76);
  font-size: 14px;
}

.text-btn:active {
  opacity: 0.72;
}

.share-card {
  position: relative;
  display: flex;
  width: min(100%, calc((100svh - 92px) * 9 / 16));
  max-width: 420px;
  aspect-ratio: 9 / 16;
  min-height: 0;
  margin: 0 auto;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 26px 22px;
  border: 1px solid rgba(255, 246, 228, 0.28);
  border-radius: 8px;
  background-image:
    linear-gradient(180deg, rgba(9, 11, 18, 0.3), rgba(9, 11, 18, 0.86)),
    var(--page-bg-image);
  background-size: cover;
  background-position: center;
  box-shadow: var(--shadow);
  color: #fff7e7;
}

.share-card-shade {
  position: absolute;
  inset: auto 0 0;
  height: 58%;
  background: linear-gradient(180deg, transparent, rgba(7, 8, 12, 0.78));
}

.share-content,
.share-bottom {
  position: relative;
  z-index: 1;
}

.share-kicker {
  color: rgba(255, 247, 231, 0.76);
  font-size: 13px;
  font-weight: 800;
}

.share-house {
  margin-top: 12px;
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(42px, 12vw, 58px);
  line-height: 1.05;
  font-weight: 900;
}

.share-sub {
  margin-top: 8px;
  color: rgba(255, 247, 231, 0.78);
  font-size: 14px;
}

.share-quote {
  max-width: 12em;
  margin-top: 16px;
  font-size: clamp(20px, 5.4vw, 27px);
  line-height: 1.42;
  font-weight: 900;
}

.share-mini-grid {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.share-note {
  padding: 10px 12px;
  border: 1px solid rgba(255, 247, 231, 0.2);
  border-radius: 8px;
  background: rgba(8, 9, 13, 0.42);
  color: rgba(255, 247, 231, 0.86);
  backdrop-filter: blur(6px);
}

.share-note b {
  display: block;
  margin-bottom: 4px;
  color: rgba(255, 232, 177, 0.95);
  font-size: 12px;
}

.share-note strong {
  display: block;
  color: #fff7e7;
  font-size: 13px;
  line-height: 1.35;
}

.share-note span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
}

.share-bottom {
  display: flex;
  align-items: end;
  gap: 12px;
}

.share-qr {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  padding: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  object-fit: contain;
}

.share-tip {
  color: rgba(255, 247, 231, 0.78);
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 340px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .house-emblem {
    gap: 8px;
    padding: 10px;
  }

  .house-chip {
    min-height: 76px;
    padding: 10px;
  }

  .question-card {
    min-height: 210px;
    padding: 18px;
  }

  .choice-btn {
    grid-template-columns: 32px 1fr;
    gap: 10px;
    min-height: 62px;
    font-size: 14.5px;
  }

  .choice-letter {
    width: 31px;
    height: 31px;
  }
}

body[data-page="quiz"] .app-shell,
body[data-page="share"] .app-shell {
  padding-top: max(10px, env(safe-area-inset-top));
}

body[data-page="share"] .actions {
  width: min(100%, 420px);
  margin: 0 auto;
}

.share-actions {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 247, 231, 0.16);
  border-radius: 8px;
  background: rgba(6, 8, 13, 0.34);
  backdrop-filter: blur(8px);
}

.share-tool {
  min-height: 42px;
  border-radius: 7px;
  background: rgba(255, 247, 231, 0.08);
  color: rgba(255, 247, 231, 0.82);
  font-size: 14px;
  font-weight: 800;
}

.share-tool.is-primary {
  background: rgba(255, 247, 231, 0.16);
  color: #fff7e7;
}

.share-tool:active {
  transform: scale(0.985);
}
