:root {
  color-scheme: dark;
  --bg: #0d0f0e;
  --surface: #131512;
  --surface-raised: #181a17;
  --text: #e9e5dc;
  --muted: #aaa69a;
  --dim: #7d7e77;
  --line: #343630;
  --bronze: #aa8d5d;
  --bronze-bright: #c7aa78;
  --moss: #566156;
  --focus: #d3b984;
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  --serif: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--bg); scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

body::after {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .18;
  background-image: url("./assets/reference-dark-v3.webp");
  background-position: center top;
  background-repeat: repeat;
  background-size: 720px 720px;
  filter: brightness(.72) contrast(1.08) saturate(.55);
  mix-blend-mode: screen;
}

.ambient {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 32% at 8% 0%, rgba(168, 131, 74, .18), transparent 72%),
    linear-gradient(112deg, rgba(148, 116, 67, .07), transparent 34%);
}

button { font: inherit; }
button, [role="radio"], summary { touch-action: manipulation; }
button:focus-visible, [role="radio"]:focus-visible, summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

[hidden] { display: none !important; }

.app-shell {
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  border-inline: 1px solid rgba(255,255,255,.025);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(13, 15, 14, .80), rgba(13, 15, 14, .88)),
    url("./assets/reference-dark-v3.webp");
  background-position: center top;
  background-repeat: repeat;
  background-size: auto, 720px 720px;
}

.screen { min-height: 100dvh; padding-inline: clamp(20px, 6vw, 32px); }

.welcome-screen {
  position: relative;
  isolation: isolate;
  overflow-x: clip;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.welcome-screen::before,
.result-hero::before {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: .68;
  background-image: url("./assets/reference-light-v3.webp");
  background-position: left top;
  background-repeat: no-repeat;
  background-size: 100% auto;
  filter: saturate(.92) contrast(.98);
  mix-blend-mode: screen;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 54%, rgba(0,0,0,.74) 70%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 54%, rgba(0,0,0,.74) 70%, transparent 100%);
}

.welcome-screen::before {
  top: 0;
  right: 0;
  left: 0;
  height: min(68vh, 620px);
  margin-inline: calc(clamp(20px, 6vw, 32px) * -1);
}

.wordmark {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .18em;
}
.wordmark-line { display: inline-block; width: 22px; height: 1px; margin-right: 9px; background: var(--bronze); vertical-align: middle; }
.welcome-space { min-height: clamp(112px, 22vh, 190px); }
.eyebrow { margin: 0 0 14px; color: var(--bronze-bright); font-size: 12px; letter-spacing: .16em; }
h1, h2, p { text-wrap: pretty; }
h1, h2 { font-family: var(--serif); font-weight: 500; }
.welcome-screen h1 { margin: 0; font-size: clamp(40px, 11vw, 58px); line-height: 1.25; letter-spacing: .02em; }
.lead { max-width: 26em; margin: 28px 0 32px; color: var(--muted); }

.realm-symbols { display: grid; grid-template-columns: repeat(6, 1fr); margin: 2px 0 28px; border-block: 1px solid rgba(170, 141, 93, .24); }
.realm-symbol-item { display: grid; min-width: 0; padding: 12px 0 10px; place-items: center; color: #8d7b5e; }
.realm-symbol-item + .realm-symbol-item { border-left: 1px solid rgba(170, 141, 93, .12); }
.realm-symbol-item span { margin-top: 4px; color: var(--dim); font-size: 10px; white-space: nowrap; }
.realm-symbol { width: 24px; height: 24px; overflow: visible; fill: none; stroke: currentColor; stroke-width: 1.25; stroke-linecap: round; stroke-linejoin: round; }

.primary-button, .secondary-button {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--bronze);
  border-radius: 2px;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}
.primary-button { background: var(--bronze); color: #10120f; font-weight: 600; letter-spacing: .08em; }
.primary-button:hover { background: var(--bronze-bright); }
.primary-button:active { background: #927747; }
.primary-button:disabled { cursor: not-allowed; opacity: .48; }
.secondary-button { background: transparent; color: var(--muted); border-color: var(--line); }
.fine-print { color: var(--dim); font-size: 12px; line-height: 1.6; }
.welcome-screen > .fine-print { margin: 14px 8px 0; text-align: center; }

.quiz-screen { display: flex; min-height: 100dvh; flex-direction: column; padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }
.quiz-header, .result-nav { display: flex; min-height: 48px; align-items: center; justify-content: space-between; }
.icon-button { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button svg, .primary-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.progress-copy { color: var(--dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.progress-copy #progress-current { color: var(--text); }
.progress-divider { margin-inline: 7px; }
.progress-track { height: 1px; margin-top: 8px; background: var(--line); }
.progress-track span { display: block; width: 0; height: 1px; background: var(--bronze); transition: width 260ms ease; }
.question-wrap { flex: 1; padding-top: clamp(40px, 8vh, 76px); }
.question-wrap h2 { margin: 0 0 34px; font-size: clamp(25px, 7vw, 34px); line-height: 1.5; }
.answer-list { display: grid; gap: 10px; }
.answer-option {
  display: grid;
  min-height: 60px;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(23, 25, 22, .62);
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}
.answer-option:hover { border-color: #656257; color: var(--text); }
.answer-option[aria-checked="true"] { border-color: var(--bronze); background: rgba(170,141,93,.1); color: var(--text); }
.answer-letter { color: var(--bronze); font-family: var(--serif); }
.quiz-hint { margin: 20px 0 0; color: var(--dim); font-size: 12px; text-align: center; }

.loading-screen { display: grid; min-height: 100dvh; place-content: center; text-align: center; }
.loading-screen h2 { margin: 0; font-size: 30px; }
.loading-detail { min-height: 2em; margin: 18px 0 0; color: var(--dim); font-size: 12px; letter-spacing: .04em; }
.breathing-mark { width: 54px; height: 54px; margin: 0 auto 34px; border: 1px solid var(--bronze); border-radius: 50%; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .38; transform: scale(.72); } }

.result-screen { overflow-x: clip; padding-top: var(--safe-top); padding-bottom: calc(var(--safe-bottom) + 28px); }
.text-button { min-height: 44px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; }
.result-hero { position: relative; isolation: isolate; min-height: min(88vh, 780px); padding-top: clamp(104px, 19vh, 160px); padding-bottom: 52px; }
.result-hero::before { top: -68px; right: calc(clamp(20px, 6vw, 32px) * -1); left: calc(clamp(20px, 6vw, 32px) * -1); height: min(68vh, 590px); }
.result-symbol { position: absolute; top: clamp(42px, 8vh, 70px); right: 0; color: rgba(199, 170, 120, .72); }
.result-symbol .realm-symbol { width: 54px; height: 54px; stroke-width: .8; }
.result-hero h1 { margin: 0; font-size: clamp(64px, 20vw, 96px); line-height: 1.05; letter-spacing: .06em; }
.result-conclusion { max-width: 17em; margin: 34px 0 18px; color: var(--text); font-family: var(--serif); font-size: clamp(20px, 5.8vw, 27px); line-height: 1.7; }
.stress-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; margin-top: 34px; padding-top: 26px; border-top: 1px solid rgba(170, 141, 93, .34); }
.stress-label { margin: 0 0 7px; color: var(--bronze-bright); font-size: 11px; letter-spacing: .14em; }
.stress-result h2 { margin: 0; font-size: clamp(36px, 10vw, 48px); line-height: 1.2; letter-spacing: .05em; }
.stress-result-copy { max-width: 23em; margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.stress-result-symbol { color: rgba(199, 170, 120, .5); }
.stress-result-symbol .realm-symbol { width: 38px; height: 38px; stroke-width: .9; }
.combination-title { margin: 26px 0 0; color: var(--bronze-bright); font-family: var(--serif); font-size: 18px; letter-spacing: .08em; }
.mechanism-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.mechanism-tags span { padding: 5px 10px; border: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.result-purpose-note { max-width: 34em; margin-top: 36px; padding: 20px 0 0 18px; border-top: 1px solid rgba(170, 141, 93, .3); border-left: 1px solid rgba(170, 141, 93, .55); }
.result-purpose-note p { margin: 0; color: var(--muted); font-family: var(--serif); font-size: 14px; line-height: 1.9; }
.hairline { height: 1px; background: linear-gradient(90deg, var(--bronze), var(--line) 34%, transparent); }
.result-section { padding: 56px 0; border-bottom: 1px solid var(--line); }
.section-index { margin: 0 0 10px; color: var(--bronze); font-size: 11px; letter-spacing: .15em; }
.result-section h2 { margin: 0 0 22px; font-size: 26px; line-height: 1.4; }
.result-section p { color: var(--muted); }
.body-large { font-family: var(--serif); font-size: 18px; line-height: 1.9; }
.mechanism-copy { display: grid; gap: 0; margin-top: 26px; counter-reset: mechanism; }
.mechanism-copy > p { display: grid; grid-template-columns: 24px 1fr; gap: 9px; margin: 0; padding: 14px 0; border-top: 1px solid var(--line); }
.mechanism-copy > p::before { counter-increment: mechanism; content: "0" counter(mechanism); color: var(--bronze); font-size: 10px; }
.evidence-card { padding: 22px 0 24px; border-top: 1px solid var(--line); }
.evidence-card .evidence-meta { margin: 0 0 12px; color: var(--bronze-bright); font-size: 11px; letter-spacing: .08em; }
.evidence-card blockquote { margin: 0 0 14px; padding-left: 14px; border-left: 1px solid rgba(170, 141, 93, .55); color: var(--text); font-family: var(--serif); font-size: 16px; line-height: 1.75; }
.evidence-card > p:last-child { margin: 0; color: var(--muted); line-height: 1.8; }
.quiet-list { padding: 0; margin: 0; list-style: none; color: var(--muted); }
.quiet-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.resource-section { background: linear-gradient(100deg, rgba(170, 141, 93, .07), transparent 72%); }
.resource-list { display: grid; gap: 0; counter-reset: resource; }
.resource-list li { display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding: 16px 0; color: var(--text); font-family: var(--serif); font-size: 17px; line-height: 1.7; }
.resource-list li::before { counter-increment: resource; content: "0" counter(resource); color: var(--bronze); font-family: var(--sans); font-size: 10px; letter-spacing: .08em; }
.protection-section { position: relative; }
.protection-section::before { content: ""; position: absolute; inset: 28px -18px; z-index: -1; background: radial-gradient(circle at 12% 30%, rgba(170, 141, 93, .08), transparent 52%); pointer-events: none; }
.gentle-boundary { margin-top: 34px; padding: 22px 0 0 18px; border-top: 1px solid var(--line); border-left: 1px solid rgba(170, 141, 93, .5); }
.gentle-boundary h3 { margin: 0 0 10px; color: var(--bronze-bright); font-size: 14px; font-weight: 400; letter-spacing: .08em; }
.gentle-boundary p { margin: 0; line-height: 1.8; }
.state-pair { display: grid; grid-template-columns: 1fr 1fr; margin-top: 32px; border-block: 1px solid var(--line); }
.state-pair div { padding: 17px 0; }
.state-pair div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.state-pair span { display: block; color: var(--dim); font-size: 11px; }
.state-pair strong { display: block; margin-top: 5px; font-family: var(--serif); font-size: 22px; font-weight: 500; }
.advice-section blockquote { margin: 0; padding-left: 20px; border-left: 1px solid var(--bronze); color: var(--text); font-family: var(--serif); font-size: 22px; line-height: 1.8; }
.differentiation-section { padding: 26px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.differentiation-section summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; color: var(--muted); cursor: pointer; list-style: none; }
.differentiation-section summary::-webkit-details-marker { display: none; }
.differentiation-section summary::after { content: "＋"; color: var(--bronze); }
.differentiation-section[open] summary::after { content: "－"; }
.differentiation-section p { margin: 14px 0 4px; color: var(--dim); font-size: 14px; line-height: 1.8; }
.distribution-section { padding: 34px 0; border-bottom: 1px solid var(--line); }
.distribution-section summary { display: flex; min-height: 44px; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.distribution-section summary::-webkit-details-marker { display: none; }
.realm-bars { display: grid; gap: 13px; margin-top: 24px; }
.realm-bar { display: grid; grid-template-columns: 22px 58px 1fr 30px; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.realm-bar .realm-symbol { width: 18px; height: 18px; color: var(--dim); stroke-width: 1.1; }
.realm-bar.primary .realm-symbol { color: var(--bronze-bright); }
.realm-bar-track { height: 2px; background: var(--line); }
.realm-bar-fill { display: block; height: 2px; background: var(--muted); }
.realm-bar.primary .realm-bar-fill { background: var(--bronze-bright); }
.distribution-section > p { color: var(--dim); font-size: 12px; }
.result-actions { display: grid; gap: 12px; padding: 42px 0 20px; }
.result-actions .primary-button { display: flex; align-items: center; justify-content: center; gap: 10px; }
.result-note { margin-block: 8px; }

.share-dialog { width: min(100% - 24px, 520px); max-height: 96dvh; padding: 14px; border: 1px solid rgba(170,141,93,.28); border-radius: 3px; background: #0b0d0b; color: var(--text); }
.share-dialog::backdrop { background: rgba(0,0,0,.8); backdrop-filter: blur(4px); }
.share-dialog-header { display: flex; align-items: center; justify-content: space-between; }
.share-dialog-header p { margin: 0; }
.share-dialog canvas { display: block; width: 100%; height: auto; margin: 10px 0 14px; background: #090b09; box-shadow: 0 18px 52px rgba(0,0,0,.38); }

@media (min-width: 700px) {
  body { padding-block: 40px; }
  .app-shell { min-height: calc(100dvh - 80px); box-shadow: 0 40px 120px rgba(0,0,0,.4); }
  .screen { min-height: calc(100dvh - 80px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
