:root {
  color-scheme: light;
  --ink: #211b45;
  --paper: #e9d8ee;
  --focus: #703f96;
  font-family: 'Baskerville', 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .52; cursor: default; }
a, button, input { touch-action: manipulation; }
#app { position: relative; height: 100svh; max-width: 460px; margin: 0 auto; }
#status { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); white-space: nowrap; overflow: hidden; }
#loading { position: fixed; inset: 0; z-index: 20; max-width: 460px; margin: 0 auto; padding: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--ink); background: var(--paper); text-align: center; }
.loading-status { font-size: 21px; line-height: 1.4; max-width: 300px; }
.lilac-screen {
  --paper-edge: 22px;
  width: 100%; height: 100svh; position: relative; isolation: isolate;
  background: var(--paper) var(--paper-art, none) center / 100% 100% no-repeat;
  display: flex; flex-direction: column;
  padding: max(15px, env(safe-area-inset-top)) 22px max(30px, env(safe-area-inset-bottom));
}
.artwork-scene { position: absolute; inset: 0 0 auto; height: 46%; z-index: -1; pointer-events: none; }
.hero-art { position: absolute; width: 66%; height: 84%; object-fit: contain; right: 1%; top: 16%; }
.hero-distance .hero-art, .hero-connection .hero-art, .hero-supernova .hero-art { width: 90%; height: 82%; right: 5%; top: 18%; }
.signal-waves { position: absolute; left: 27%; top: 32%; width: 18%; height: 38%; stroke: #e795ce; stroke-width: 1; opacity: .7; }
.signal-heading { position: absolute; top: 5.5%; left: 8%; width: 84%; color: #e5b9e9; }
h1 { margin: 0; font-size: clamp(34px, 11.7vw, 52px); line-height: 1; font-weight: 400; letter-spacing: .035em; text-shadow: 0 1px 1px #1a103d; }
.signal-heading h1:focus { outline: none; }
.long-heading h1 { font-size: clamp(24px, 8vw, 35px); max-width: 95%; line-height: 1.06; }
.heading-rule { width: 155px; height: 20px; stroke: #edc7e7; stroke-width: 1; display: block; margin-top: 4px; }
.heading-rule .star { fill: #f8d3ec; stroke: none; }
.step-indicator { margin: 3px 0 0; font-size: 13px; letter-spacing: .1em; color: #f6d6f0; text-shadow: 0 0 2px #211b45, 0 1px 2px #211b45; }
.paper-content { margin-top: auto; width: 100%; position: relative; display: flex; flex-direction: column; gap: 9px; }
/* Foreground copy can rise into the painting as author paragraphs wrap.
   A feathered paper wash follows that content instead of a fixed sky boundary. */
.paper-content::before {
  content: ''; position: absolute; z-index: -1; pointer-events: none;
  inset: -100px calc(0px - var(--paper-edge)) -10px;
  background: linear-gradient(to bottom, #e9d8ee00, #e9d8ee08 9px, #e9d8ee25 27px, #e9d8ee60 50px, #e9d8eeaa 74px, #e9d8eeeb 100px, #e9d8eee8 calc(100% - 10px), #e9d8ee00);
}
.paper-stars { position: absolute; inset: 0 -22px; pointer-events: none; z-index: -1; }
.ink-star { position: absolute; width: 14px; height: 14px; fill: #393257; }
.ink-star-1 { left: 1%; top: 40px; }
.ink-star-2 { right: 1%; top: 66px; width: 10px; height: 10px; }
.ink-star-3 { left: 3%; top: 0; width: 8px; height: 8px; fill: #8f6daf; }
.question-form { width: 100%; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.question-prompt { display: block; padding: 0; width: 100%; text-align: center; font-size: clamp(21px, 6vw, 26px); font-weight: 400; line-height: 1.13; margin-bottom: 15px; text-shadow: 0 1px 4px #f1e1f5; }
.question-prompt span { display: block; }
.answer-list { display: grid; gap: 8px; }
.answer-choice { position: relative; width: 100%; min-height: 53px; padding: 7px 11px 7px 74px; display: flex; align-items: center; cursor: pointer; border: 1px solid transparent; border-radius: 20px 22px 18px 21px / 19px 20px 21px 22px; background: linear-gradient(105deg, #dfcee75c, #f5e9f251 62%, #d1c4e361); box-shadow: inset 1px 1px 0 #faf3ff70, 0 1px 2px #74568914; transition: background-color 160ms ease, transform 160ms ease; }
.answer-choice input { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; margin: 0; opacity: 0; }
.answer-copy { font-size: 19px; line-height: 1.15; letter-spacing: -.005em; position: relative; z-index: 1; }
.choice-ink { position: absolute; z-index: 0; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ink-outline { fill: none; stroke: #332c55; stroke-width: 1; vector-effect: non-scaling-stroke; }
.paper-flecks { opacity: .18; }
.answer-symbol { position: absolute; z-index: 2; width: 72px; height: 72px; left: -3px; top: 50%; transform: translateY(-50%); pointer-events: none; }
/* Full perimeter and wash identify selection without obscuring its artwork. */
.answer-choice[aria-pressed='true'] { background: #d2b8e6; box-shadow: inset 0 0 0 2px #563071, 0 1px 2px #74568914; opacity: 1; }
.answer-choice[aria-pressed='true'] .ink-outline { stroke: #40215e; stroke-width: 2; }
.answer-choice:focus-visible, .paper-button:focus-visible, .history-entry:focus-visible, .invitation-url:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.answer-error { min-height: 44px; margin: 4px 0 0; line-height: 16px; font-size: 13px; color: #622349; text-align: center; }
.answer-error:focus { outline: 1px dotted #622349; outline-offset: 1px; }
.navigation-actions { display: grid; grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr); align-items: center; gap: 4px; margin-top: 3px; }
.paper-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 49px; padding: 6px 12px; border: 1px solid var(--ink); border-radius: 26px 22px 25px 24px / 24px 27px 24px 21px; text-decoration: none; color: var(--ink); font-size: 23px; cursor: pointer; background: #ead9eac2; box-shadow: 2px 2px 0 #eee4f480; transition: transform 140ms ease, background-color 140ms ease; }
.paper-button:active { transform: translateY(1px); }
.button-label { min-width: 0; }
.navigation-arrow { width: 30px; height: 24px; flex: none; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.next-button { color: #f4d5f3; background: #3f285a var(--paper-art, none) 70% 9% / 290% auto; }
.navigation-star { font-size: 29px; text-align: center; font-weight: 400; }
.content-heading { margin: 0 0 4px; text-align: center; font-size: 30px; line-height: 1.04; font-weight: 400; }
.prose { font-size: 21px; line-height: 1.22; text-align: center; }
.prose p { margin: 0 0 .5em; }
.prose p:last-child { margin-bottom: 0; }
.result-title { font-size: 27px; }
.result-status { margin: 0; text-align: center; font-size: 16px; line-height: 1.18; }
.prototype-note { margin: 0; font-size: 14px; line-height: 1.25; text-align: center; }
.intro-screen .paper-content { gap: 12px; }
.intro-screen .prose { font-size: 23px; }
.intro-screen .answer-error:empty { min-height: 8px; }
.intro-screen h1 { max-width: 70%; }
.intro-screen .paper-button { font-size: 22px; }
.detail-screen .paper-content { position: absolute; top: 45%; left: 22px; right: 22px; bottom: max(30px, env(safe-area-inset-bottom)); width: auto; }
.detail-title { font-size: 22px; }
.detail-region { flex: 1; min-height: 0; text-align: left; font-size: 19px; line-height: 1.23; }
.pagination-probe { position: absolute; visibility: hidden; pointer-events: none; font: inherit; line-height: inherit; text-align: inherit; }
.page-count { min-height: 17px; margin: 0; text-align: center; font-size: 14px; line-height: 1.2; }
.outcome-pair { border-top: 1px solid #6a547b; border-bottom: 1px solid #6a547b; padding: 8px 0; font-size: 17px; line-height: 1.17; text-align: center; }
.outcome-pair p { margin: 0 0 5px; }
.outcome-pair p:last-child { margin: 0; }
.share-fallback, .secondary-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.share-fallback .paper-button, .secondary-actions .paper-button { font-size: 19px; }
.url-label { text-align: center; font-size: 14px; }
.invitation-url { width: 100%; min-height: 40px; border: 1px solid #6a547b; border-radius: 8px 12px 10px 9px; padding: 6px 10px; background: #f5e9f2aa; color: var(--ink); font-family: system-ui, sans-serif; font-size: 13px; }
.share-screen .answer-error { margin: 0; }
.analysis-meter { width: 100%; height: 12px; border: 1px solid var(--ink); border-radius: 3px 7px 5px 3px; padding: 2px; }
.analysis-meter span { display: block; width: 0; height: 100%; background: #774891; }
.analysis-percent { margin: 0; font-size: 27px; text-align: center; }

.history-list { display: grid; gap: 10px; }
.history-entry { display: block; border: 1px solid #44345d; border-radius: 18px 15px 20px 17px; padding: 10px 14px; background: #eee2f18c; color: var(--ink); text-decoration: none; }
.history-title { display: block; font-size: 20px; line-height: 1.08; }
.history-count { display: block; margin-top: 5px; font-size: 14px; }
.reply-title { margin: 0; font-size: 25px; font-weight: 400; text-align: center; line-height: 1.08; }
.reply-outcome { margin: 0; font-size: 18px; line-height: 1.1; text-align: center; }
@media (min-height: 900px) {
  .question-prompt { margin-bottom: 19px; }
  .answer-choice { min-height: 59px; }
  .answer-list { gap: 10px; }
  .paper-button { min-height: 54px; }
  .navigation-actions { margin-top: 10px; }
}
@media (max-height: 740px) {
  .lilac-screen { --paper-edge: 19px; }
  .lilac-screen { padding: 12px 19px max(19px, env(safe-area-inset-bottom)); background-image: linear-gradient(to bottom, #e9d8ee00 31%, #e9d8ee19 41%, #e9d8ee57 51%, #e9d8eea6 61%, var(--paper) 76%), var(--paper-art, none); background-size: 100% 100%, 100% 88%; background-position: center top, center -12px; }
  .artwork-scene { height: 38%; }
  .hero-art { width: 54%; height: 72%; right: 2%; top: 26%; }
  .signal-heading { top: 4%; }
  .paper-content { gap: 7px; }
  .question-prompt { font-size: 22px; margin-bottom: 12px; }
  .answer-choice { min-height: 49px; padding-left: 67px; }
  .answer-symbol { width: 64px; height: 64px; left: -3px; }
  .answer-copy { font-size: 17px; }
  .paper-button { min-height: 45px; font-size: 21px; }
  .content-heading { font-size: 27px; }
  .prose { font-size: 19px; }
  .intro-screen .prose { font-size: 20px; }
  .paper-stars { inset: 0 -19px; }
  .ink-star-1 { left: .8%; top: 32px; width: 8px; height: 8px; }
  .ink-star-2 { right: .8%; top: 56px; width: 7px; height: 7px; }
  .ink-star-3 { display: none; }
  .detail-screen .paper-content { top: 36%; left: 19px; right: 19px; bottom: max(19px, env(safe-area-inset-bottom)); }
  .detail-region { font-size: 18px; }
  .detail-title { font-size: 21px; }
  .result-title { font-size: 24px; }
}
@media (max-height: 600px) {
  .lilac-screen { --paper-edge: 16px; }
  .lilac-screen { padding: 10px 16px max(14px, env(safe-area-inset-bottom)); background-image: linear-gradient(to bottom, #e9d8ee00 10%, #e9d8ee12 25%, #e9d8ee57 38%, #e9d8eea6 48%, #e9d8eef0 60%, var(--paper) 67%), var(--paper-art, none); background-size: 100% 100%, 100% 78%; background-position: center top, center -20px; }
  .artwork-scene { height: 28%; }
  .hero-art { width: 47%; height: 72%; top: 26%; }
  .hero-distance .hero-art, .hero-connection .hero-art, .hero-supernova .hero-art { width: 68%; height: 82%; right: 1%; top: 16%; }
  h1 { font-size: 34px; }
  .long-heading h1 { font-size: 25px; max-width: 90%; }
  .heading-rule { width: 130px; margin-top: 1px; }
  .step-indicator { font-size: 12px; }
  .question-prompt { font-size: 19px; margin-bottom: 10px; }
  .answer-list { gap: 6px; }
  .answer-choice { min-height: 44px; padding: 5px 9px 5px 60px; }
  .answer-copy { font-size: 16px; }
  .answer-symbol { width: 58px; height: 58px; left: -4px; }
  .navigation-actions { grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1fr); margin-top: 1px; }
  .paper-button { min-height: 44px; padding: 5px 8px; font-size: 19px; gap: 7px; }
  .navigation-star { font-size: 24px; }
  .navigation-arrow { width: 25px; height: 22px; }
  .paper-content { gap: 6px; }
  .content-heading { font-size: 24px; }
  .prose { font-size: 17px; line-height: 1.18; }
  .prose p { margin-bottom: .4em; }
  .result-title { font-size: 21px; }
  .result-status { font-size: 14px; }
  .prototype-note { font-size: 13px; }
  .intro-screen .paper-content { gap: 8px; }
  .intro-screen .prose { font-size: 18px; }
  .intro-screen .paper-button { font-size: 20px; }
  .detail-screen .paper-content { top: 28%; left: 16px; right: 16px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .detail-title { font-size: 19px; }
  .detail-region { font-size: 17px; line-height: 1.21; }
  .paper-stars { inset: 0 -16px; }
  .outcome-pair { font-size: 15px; padding: 5px 0; }
  .history-entry { padding: 9px 12px; }
  .history-title { font-size: 18px; }
  .reply-title { font-size: 21px; }
  .reply-outcome { font-size: 16px; }
}
@media (max-height: 530px) {
  .lilac-screen { padding-bottom: max(10px, env(safe-area-inset-bottom)); background-size: 100% 100%, 100% 67%; }
  .artwork-scene { height: 22%; }
  .hero-art { width: 41%; height: 85%; top: 9%; right: 1%; }
  .signal-heading { top: 3.5%; }
  h1 { font-size: 30px; }
  .long-heading h1 { font-size: 23px; max-width: 95%; }
  .heading-rule { width: 110px; height: 14px; }
  .step-indicator { margin-top: 0; }
  .question-prompt { font-size: 18px; line-height: 1.08; margin-bottom: 8px; }
  .answer-error { margin-top: 2px; }
  .prose { font-size: 16px; }
  .paper-content { gap: 5px; }
  .content-heading { font-size: 22px; }
  .result-title { font-size: 20px; }
  .detail-screen .paper-content { top: 24%; bottom: max(10px, env(safe-area-inset-bottom)); }
  .detail-title { font-size: 18px; }
  .detail-region { font-size: 16px; }
  .share-screen .prose { font-size: 16px; }
}
@media (max-width: 360px) {
  .navigation-actions { grid-template-columns: minmax(0, 1fr) 24px minmax(0, 1fr); gap: 3px; }
  .navigation-actions .paper-button { padding-left: 6px; padding-right: 6px; gap: 5px; font-size: 20px; }
  .navigation-arrow { width: 25px; height: 22px; }
  .navigation-star { font-size: 24px; }
  .long-heading h1 { font-size: 25px; }
  .share-fallback .paper-button, .secondary-actions .paper-button { font-size: 17px; }
}
.single-word-heading h1 { font-size: clamp(20px, 6.2vw, 28px); letter-spacing: 0; max-width: 100%; }
@media (max-height: 530px) {
  .question-screen { background-image: linear-gradient(to bottom, #e9d8ee00 12%, #e9d8ee14 16%, #e9d8ee4d 22%, #e9d8eead 30%, var(--paper) 39%), var(--paper-art, none); }
  .question-screen .artwork-scene { height: 19%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Iteration: titles remain on the ink sky while choices carry the action. */
.signal-heading { color: #f6d7f2; }
.signal-heading h1 { font-weight: 600; text-shadow: 0 1px 1px #1a103d, 0 0 9px #211137, 0 2px 5px #211137; }
.question-screen .signal-heading::before { content: ''; position: absolute; z-index: -1; pointer-events: none; inset: -24px -18px; background: radial-gradient(ellipse at 35% 48%, #241339b3 0%, #24133991 23%, #24133952 43%, #24133921 63%, #24133900 85%); }
.answer-choice { color: var(--ink); text-align: left; font: inherit; }
.answer-symbol { object-fit: contain; }
.question-navigation .paper-button { font-size: 21px; }
.question-navigation .navigation-star { font-size: 23px; }
.result-screen .paper-content { gap: 7px; }
.result-screen .paper-button { min-height: 44px; font-size: 20px; }
.result-actions .paper-button { font-size: 18px; }
.retake-status:empty { display: none; }
.retake-status:not(:empty) { min-height: 32px; margin: 0; }
.analysis-interference { display: flex; flex-direction: column; gap: 9px; }
.analysis-explanation { margin: 0; text-align: center; font-size: 18px; line-height: 1.2; }
.result-card-preview { max-width: 100%; width: auto; height: min(29svh, 230px); object-fit: contain; align-self: center; border: 1px solid #745484; box-shadow: 2px 3px 0 #b898c757; }
.image-screen .paper-button { font-size: 20px; }
@media (max-height: 600px) {
  .result-screen .paper-content { gap: 5px; }
  .result-screen .paper-button { font-size: 18px; }
  .result-actions .paper-button { font-size: 17px; }
  .result-screen .prose { font-size: 16px; }
  .analysis-explanation { font-size: 16px; }
}
@media (max-height: 530px) {
  .result-screen .artwork-scene { height: 17%; }
  .result-screen .signal-heading { top: 3%; }
  .result-screen .signal-heading h1 { font-size: 24px; }
  .result-screen .heading-rule { height: 12px; }
  .result-screen .content-heading { font-size: 19px; }
  .result-screen .paper-content { gap: 4px; }
  .result-screen .result-status { font-size: 13px; }
  .result-screen .prototype-note { font-size: 12px; }
  .image-screen .paper-content { gap: 5px; }
  .image-screen .paper-button { font-size: 18px; }
  .image-screen .result-card-preview { height: 23svh; }
}

/* Keep every foreground pixel steady while the next scene is prepared. */
.lilac-screen[aria-busy='true'] button:disabled { opacity: 1; }
.lilac-screen[aria-busy='true'] .paper-button:active { transform: none; }
.transition-error .paper-button { min-height: 44px; padding: 0 4px; font-size: inherit; border: 0; border-radius: 0; background: none; box-shadow: none; text-decoration: underline; }
 .prototype-reset { position: absolute; right: 8px; top: max(5px, env(safe-area-inset-top)); z-index: 2; width: 44px; height: 44px; min-height: 44px !important; padding: 10px; border-radius: 5px; border-color: #e9d8ee8c; background: #e9d8eee8; box-shadow: none; }
.prototype-reset svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

@media (max-height: 530px) {
  .question-screen .answer-list { gap: 3px; }
  .question-screen .question-prompt { margin-bottom: 5px; }
}

/* V1: reserve the full 44px reset target plus a visible header gutter. */
.result-screen .signal-heading { width: auto; right: 64px; }
.result-screen .signal-heading h1 { font-size: clamp(26px, 8.5vw, 34px); }
@media (max-height: 530px) {
  .result-screen .signal-heading h1 { font-size: 24px; }
}

/* Removing quiz Back reclaims its footer while reserving honest retry feedback.
   The fixed feedback region keeps the selected option steady on save failure. */
.question-feedback { display: grid; grid-template-columns: minmax(0, 1fr) 100px; align-items: center; gap: 8px; min-height: 68px; }
.question-feedback .answer-error { margin: 0; min-height: 0; }
.question-feedback .answer-error:empty { grid-column: 1 / -1; }
.question-navigation { grid-column: 2; grid-row: 1; }
.question-navigation .paper-button { width: 100%; min-height: 44px; font-size: 16px; gap: 3px; padding-inline: 5px; }
.question-navigation .navigation-arrow { width: 20px; }
.question-feedback:has(.answer-error.transition-error) .answer-error { grid-column: 1 / -1; }
.personal-diagnosis { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 96px; }
.diagnosis-art { width: 96px; height: 96px; flex: none; object-fit: contain; pointer-events: none; }
.personal-diagnosis .result-title { margin: 0; min-width: 0; text-align: left; }
@media (max-height: 740px) {
  .personal-diagnosis { min-height: 80px; gap: 8px; }
  .diagnosis-art { width: 80px; height: 80px; }
}
@media (max-height: 600px) {
  .personal-diagnosis { min-height: 64px; gap: 7px; }
  .diagnosis-art { width: 64px; height: 64px; }
}

/* Long author words keep their spelling and fit beside the cutout. */
.long-diagnosis-title .result-title { font-size: clamp(18px, 5.5vw, 22px); }
