:root {
  --ink: #262823;
  --muted: #6f7068;
  --paper: #f2ecdf;
  --paper-2: #e5ddce;
  --jade: #69877b;
  --jade-dark: #315b50;
  --gold: #b9924d;
  --red: #9c4b3d;
  --line: rgba(49, 91, 80, .23);
  --shadow: 0 24px 70px rgba(59, 49, 35, .18);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 8%, rgba(255,255,255,.78), transparent 33%),
    radial-gradient(circle at 82% 92%, rgba(104,135,123,.14), transparent 30%),
    #ded6c7;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

button, input { font: inherit; }
button { color: inherit; }

#app {
  width: min(100%, 460px);
  min-height: 0;
  height: 100dvh;
  margin: 0 auto;
  background:
    linear-gradient(rgba(255,255,255,.2), rgba(255,255,255,0)),
    var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  border-radius: 0;
}

.screen {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: auto;
  animation: page-in .42s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.brand {
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--jade-dark);
}

.brand::before, .brand::after {
  content: "";
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--jade));
}
.brand::after { background: linear-gradient(90deg, var(--jade), transparent); }

.brand-title {
  font-size: clamp(27px, 8vw, 38px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: .14em;
  white-space: nowrap;
  text-shadow: 0 2px 0 rgba(255,255,255,.65);
}

.seal {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--red);
  color: var(--red);
  font-size: 11px;
  line-height: 1;
  transform: rotate(-4deg);
}

.start {
  padding: max(34px, env(safe-area-inset-top)) 26px max(34px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  isolation: isolate;
}

.start::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .38;
  background:
    radial-gradient(circle at 50% 39%, transparent 0 74px, rgba(105,135,123,.14) 75px 76px, transparent 77px 104px, rgba(105,135,123,.08) 105px 106px, transparent 107px),
    repeating-linear-gradient(120deg, transparent 0 34px, rgba(156,75,61,.025) 35px 36px);
}

.start-top { padding-top: 6px; }
.start .brand { margin-bottom: 54px; }

.kicker {
  font-family: Urbanist, sans-serif;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--red);
  text-transform: uppercase;
}

.start h1 {
  max-width: 360px;
  margin: 14px 0 20px;
  font-size: clamp(34px, 10vw, 49px);
  line-height: 1.18;
  letter-spacing: -.04em;
}

.start h1 em {
  color: var(--jade-dark);
  font-style: normal;
  background: linear-gradient(transparent 68%, rgba(185,146,77,.28) 68%);
}

.lead {
  margin: 0;
  max-width: 340px;
  color: #55574f;
  font-size: 16px;
  line-height: 1.9;
}

.start-promise {
  margin: 34px 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
}

.promise-item {
  padding: 15px 4px;
  text-align: center;
  position: relative;
}
.promise-item + .promise-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15px;
  bottom: 15px;
  width: 1px;
  background: var(--line);
}
.promise-item b { display: block; font: 800 22px/1 Urbanist, sans-serif; color: var(--jade-dark); }
.promise-item span { display: block; margin-top: 6px; font-size: 11px; color: var(--muted); }

.primary, .secondary {
  width: 100%;
  min-height: 54px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, background .18s;
}
.primary {
  border: 1px solid #294d44;
  color: #fffaf0;
  background: linear-gradient(135deg, #3c6a5e, #244e45);
  box-shadow: 0 12px 28px rgba(49,91,80,.22), inset 0 1px rgba(255,255,255,.25);
  font-weight: 700;
  letter-spacing: .12em;
}
.secondary {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.35);
  color: var(--jade-dark);
}
.primary:active, .secondary:active { transform: scale(.98); }

.fine-print {
  margin: 13px 0 0;
  text-align: center;
  color: #85857d;
  font-size: 11px;
  line-height: 1.7;
}

.quiz { padding: max(22px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom)); }
.quiz-head { display: flex; align-items: center; gap: 12px; }
.back {
  width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%;
  background: rgba(255,255,255,.4); cursor: pointer; font-family: sans-serif; font-size: 18px;
}
.progress-wrap { flex: 1; }
.progress-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 7px; }
.progress-track { height: 4px; background: rgba(49,91,80,.11); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--jade), var(--gold)); transition: width .35s; }

.question-no { margin-top: 44px; color: var(--red); font: 800 13px Urbanist, sans-serif; letter-spacing: .16em; }
.question {
  margin: 14px 0 28px;
  font-size: clamp(24px, 7.2vw, 32px);
  line-height: 1.5;
  letter-spacing: -.025em;
}
.options { display: grid; gap: 12px; }
.option {
  width: 100%;
  border: 1px solid rgba(49,91,80,.16);
  border-radius: 18px;
  padding: 17px 17px 17px 56px;
  background: rgba(255,255,255,.48);
  box-shadow: 0 5px 20px rgba(73,63,48,.045);
  text-align: left;
  line-height: 1.65;
  cursor: pointer;
  position: relative;
  transition: .18s ease;
}
.option::before {
  content: attr(data-letter);
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--jade-dark); font: 800 12px Urbanist, sans-serif;
}
.option:hover, .option:focus-visible { border-color: var(--jade); background: rgba(255,255,255,.76); transform: translateY(-1px); }
.option.selected { background: #dce7e1; border-color: var(--jade); }

.tie-note { margin: -15px 0 24px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.tie-options { gap: 10px; }
.tie-option span { color: #353932; font-size: 14px; font-weight: 650; }

.result {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 37%, rgba(255,255,255,.84), transparent 44%),
    linear-gradient(180deg, #f4efe5 0%, #e8e1d5 100%);
}
.result > * { flex-shrink: 0; min-width: 0; }

.result .brand { padding: 0 5px; }
.result .brand-title { font-size: clamp(26px, 7.7vw, 34px); }

.identity { margin: 18px 2px 12px; padding-left: 9px; border-left: 2px solid var(--gold); }
.identity-prefix { color: var(--muted); font-size: 14px; letter-spacing: .08em; }
.identity-name { font-size: clamp(28px, 8vw, 36px); font-weight: 900; line-height: 1.18; letter-spacing: -.03em; }
.identity-en {
  display: inline-block; margin-top: 7px; color: var(--red);
  font: 800 clamp(21px, 6vw, 28px)/1 Urbanist, sans-serif; letter-spacing: .04em;
}

.result-visual {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px;
  grid-template-rows: 28px minmax(0, 1fr);
  height: clamp(300px, calc(100dvh - 420px), 540px);
  column-gap: 6px;
  margin-top: 0;
}
.figure-stage { position: relative; grid-column: 1; grid-row: 2; min-width: 0; min-height: 0; isolation: isolate; }
.figure {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; object-position: center;
  filter: saturate(.93) contrast(1.01);
  transition: filter .55s, transform .65s cubic-bezier(.2,.8,.2,1), opacity .25s;
}
.stage-2 .figure { transform: scale(.985); filter: saturate(.78) contrast(.96) brightness(.94); }
.stage-3 .figure { top: 4%; height: 84%; transform: none; filter: saturate(.98) contrast(1.01) brightness(1.025); }

.ink-halo {
  position: absolute; width: 75%; aspect-ratio: 1; border-radius: 50%; left: 7%; top: 15%;
  border: 1px solid rgba(105,135,123,.16); box-shadow: 0 0 0 24px rgba(105,135,123,.035), 0 0 0 50px rgba(105,135,123,.02);
  animation: breathe 4.6s ease-in-out infinite; pointer-events: none;
}
@keyframes breathe { 50% { transform: scale(1.045); opacity: .58; } }

.thoughts { position: absolute; inset: 6px 0; display: flex; flex-direction: column; justify-content: space-evenly; gap: 8px; pointer-events: none; z-index: 2; }
.thought {
  position: relative; max-width: 94%; padding: 9px 11px; border: 1px solid rgba(255,255,255,.62);
  border-radius: 18px 18px 18px 5px; color: #353932; background: rgba(244,239,229,.82);
  backdrop-filter: blur(10px); box-shadow: 0 12px 28px rgba(47,47,42,.13); font-size: 12px; line-height: 1.6;
  opacity: 0; transform: translateY(13px) scale(.96);
}
.thought:nth-child(1), .thought:nth-child(3) { align-self: flex-start; }
.thought:nth-child(2) { align-self: flex-end; border-radius: 18px 18px 5px 18px; }
.stage-2 .thought { animation: thought-in .48s cubic-bezier(.2,.8,.2,1) forwards; }
.stage-2 .thought:nth-child(2) { animation-delay: .14s; }
.stage-2 .thought:nth-child(3) { animation-delay: .28s; }
@keyframes thought-in { to { opacity: 1; transform: translateY(0) scale(1); } }

/* An open sanctuary: fine perimeter light, no surface covering the portrait. */
.sanctuary { position: absolute; inset: 0; pointer-events: none; opacity: 0; transform: translateY(8px) scale(.96); transition: opacity .7s, transform .9s cubic-bezier(.2,.8,.2,1); }
.sanctuary svg { width: 100%; height: 100%; overflow: visible; }
.ground-shadow { fill: #244f43; opacity: .16; filter: blur(6px); }
.boundary-arc { fill: none; stroke: url(#rimLight); stroke-width: 2.3; opacity: 1; stroke-linecap: round; stroke-dasharray: 1000; stroke-dashoffset: 1000; transition: stroke-dashoffset 1.4s ease; filter: drop-shadow(0 0 3px #b8dfc8); }
.boundary-aura { fill: none; stroke: #5f9f88; stroke-width: 10; opacity: .32; filter: blur(5px); }
.boundary-inner { fill: none; stroke: #e4f9d9; stroke-width: 1.1; opacity: .9; filter: drop-shadow(0 0 2px #63937b); }
.boundary-floor { fill: none; stroke: #6f9a88; stroke-width: .8; opacity: .5; }
.boundary-front { fill: none; stroke: url(#rimLight); stroke-width: 2; filter: drop-shadow(0 -2px 3px #e5ffe1); }
.boundary-spark { fill: none; stroke: #fff9de; stroke-width: 1.4; stroke-linecap: round; filter: drop-shadow(0 0 3px #ad9062); }
.sanctuary-label { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); white-space: nowrap; color: #476c5c; font-size: 10px; letter-spacing: .16em; padding: 4px 10px; background: linear-gradient(90deg, transparent, #f4efe5df 20%, #f4efe5df 80%, transparent); }
.stage-3 .sanctuary { opacity: 1; transform: none; }
.stage-3 .boundary-arc { stroke-dashoffset: 0; }
.stage-3 .ink-halo { opacity: 0; animation: none; }

.rail-hint {
  position: relative; grid-column: 1 / -1; grid-row: 1; justify-self: end; align-self: start; z-index: 6; margin: 0; padding: 4px 6px;
  border: 1px solid rgba(49,91,80,.18); border-radius: 999px; background: rgba(242,236,223,.78);
  color: var(--jade-dark); font-size: 10px; letter-spacing: .03em; backdrop-filter: blur(7px);
}
.slider-zone { position: relative; grid-column: 2; grid-row: 2; margin: 16px 0; width: 76px; z-index: 5; }
.rail-line { position: absolute; top: 13px; bottom: 13px; right: 12px; width: 2px; background: linear-gradient(var(--gold), var(--jade-dark)); opacity: .55; }
.drag-rail { position: absolute; inset: 0 0 0 52px; z-index: 3; cursor: grab; touch-action: none; outline: 0; }
.drag-rail:active { cursor: grabbing; }
.drag-rail:focus-visible { border-radius: 24px; box-shadow: 0 0 0 2px rgba(49,91,80,.32); }
.knob {
  position: absolute; right: 0; top: calc(var(--stage) * 50%); width: 27px; height: 27px;
  transform: translate(0, -50%); border-radius: 50%; border: 5px solid #f5eee2;
  background: var(--red); box-shadow: 0 0 0 1px rgba(67,68,61,.35), 0 5px 12px rgba(45,39,31,.25);
  transition: top .28s cubic-bezier(.2,.8,.2,1);
}
.stops { position: absolute; top: 0; right: 7px; bottom: 0; width: 10px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; pointer-events: none; }
.stop { width: 10px; height: 10px; border: 2px solid var(--paper); border-radius: 50%; background: var(--jade); box-shadow: 0 0 0 1px var(--jade); }
.stop-labels { position: absolute; inset: 0; pointer-events: none; }
.stage-step { position: absolute; left: 0; top: calc(var(--step) * 50%); transform: translateY(-50%); width: 49px; min-height: 58px; padding: 7px 2px; border: 1px solid #93aa9e; border-radius: 12px; background: #f8f4ec; color: var(--jade-dark); pointer-events: auto; cursor: pointer; box-shadow: 0 3px 8px #315b500c; }
.stage-step b { display: block; margin-bottom: 5px; font: 800 13px Urbanist,sans-serif; }
.stage-step span { display: block; font-size: 10px; white-space: nowrap; }
.stage-step.active { background: var(--jade-dark); color: #fff8e9; border-color: var(--jade-dark); box-shadow: 0 3px 10px #315b5033; }
.stage-step:focus-visible, .stage-next:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.stage-next { display: flex; justify-content: space-between; gap: 12px; width: 100%; margin-top: 12px; padding: 11px 12px; min-height: 44px; border: 1px solid #99afa3; border-radius: 9px; background: #e0e9df; color: var(--jade-dark); font-size: 12px; font-weight: 650; line-height: 1.5; cursor: pointer; text-align: left; }
.stage-next:hover { background: #d0e1d2; }

.stage-copy {
  position: relative; z-index: 4;
  min-height: 128px;
  margin: 8px 4px 0;
  padding: 13px 14px 12px;
  background: linear-gradient(90deg, rgba(242,236,223,.98), rgba(242,236,223,.78), transparent);
  border-left: 2px solid var(--red);
}
.stage-label { margin: 0 0 5px; color: var(--red); font: 800 11px Urbanist, sans-serif; letter-spacing: .14em; }
.stage-line { margin: 0; font-size: clamp(18px, 5.3vw, 22px); font-weight: 800; line-height: 1.42; }
.stage-detail { margin: 7px 0 0; color: #595c54; font-size: 12px; line-height: 1.62; }

.result-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: 9px; margin-top: 14px; }
.result-actions button { min-height: 46px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 30; transform: translate(-50%, 18px);
  padding: 10px 16px; border-radius: 99px; background: #263d36; color: white; font-size: 12px;
  opacity: 0; pointer-events: none; transition: .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.share-sheet { position: absolute; inset: 0; z-index: 40; display: grid; align-items: end; overflow: hidden; }
.share-sheet[hidden] { display: none; }
.share-backdrop { position: absolute; inset: 0; border: 0; background: rgba(27,36,32,.34); opacity: 0; transition: opacity .22s; }
.share-panel {
  max-height: 100%; overflow-y: auto;
  position: relative; z-index: 1; padding: 17px 20px max(22px, env(safe-area-inset-bottom));
  border: 1px solid rgba(255,255,255,.65); border-radius: 26px 26px 0 0;
  background: rgba(246,241,231,.96); backdrop-filter: blur(20px); box-shadow: 0 -22px 60px rgba(35,41,37,.2);
  transform: translateY(105%); transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.share-sheet.open .share-backdrop { opacity: 1; }
.share-sheet.open .share-panel { transform: translateY(0); }
.share-grip { width: 36px; height: 4px; border-radius: 99px; background: rgba(49,91,80,.23); margin: 0 auto 16px; }
.share-close { position: absolute; right: 16px; top: 16px; width: 32px; height: 32px; border: 0; border-radius: 50%; background: rgba(49,91,80,.08); font: 400 22px/1 sans-serif; cursor: pointer; }
.share-panel h2 { margin: 7px 38px 14px 0; font-size: 22px; line-height: 1.35; }
.share-result-line { display: grid; gap: 5px; padding: 13px 14px; border-left: 2px solid var(--gold); background: rgba(255,255,255,.45); }
.share-result-line b { color: var(--jade-dark); font: 800 15px Urbanist, "Noto Serif SC", serif; }
.share-result-line span { color: #55584f; font-size: 12px; }
.wechat-tip { margin: 15px 0; color: #4f554e; font-size: 13px; line-height: 1.7; }
.share-panel .primary, .share-panel .secondary { min-height: 48px; }
.share-destination { margin-top: 9px; }
.share-note { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 10px; }

.error { padding: 60px 28px; line-height: 1.8; }

/* A bilingual character atlas, composed from the same portraits as the results. */
.start { padding: max(24px, env(safe-area-inset-top)) 20px 0; justify-content: flex-start; gap: 22px; }
.start > * { flex-shrink: 0; }
.start .start-top { padding: 0; }
.start .brand { margin-bottom: 24px; gap: 8px; }
.start .brand-title { font-size: clamp(25px, 7.5vw, 34px); }
.home-eyebrow { margin: 0 0 12px; font: 700 10px/1.6 Urbanist, sans-serif; letter-spacing: .12em; color: var(--red); }
.start h1 { font-size: clamp(30px, 8.7vw, 39px); line-height: 1.22; margin: 0 0 12px; letter-spacing: -.035em; }
.start h1 em { background: none; }
.start .lead { font-size: 14px; line-height: 1.8; color: #6b6b60; }
.home-facts { display: flex; align-items: center; gap: 12px; margin-top: 18px; font-size: 11px; color: var(--muted); }
.home-facts span + span { padding-left: 12px; border-left: 1px solid var(--line); }
.home-facts b { font: 800 15px Urbanist, sans-serif; color: var(--jade-dark); }
.atlas-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; margin-bottom: 14px; }
.atlas-heading h2 { margin: 0; font-size: 16px; color: var(--jade-dark); }
.atlas-heading > span { font-size: 10px; color: var(--muted); }
.portrait-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px 8px; }
.portrait-tile { margin: 0; min-width: 0; }
.portrait-image { position: relative; aspect-ratio: 1 / 1.16; border-radius: 32px 32px 5px 5px; overflow: hidden; background: #e8e1d5; }
.portrait-image img { width: 100%; height: 100%; display: block; object-fit: contain; }
.portrait-number { position: absolute; left: 6px; top: 7px; color: #6b7268; z-index: 1; font: 650 9px Urbanist,sans-serif; }
.portrait-tile figcaption { display: grid; gap: 3px; text-align: center; padding-top: 7px; }
.portrait-tile strong { font-size: clamp(10px, 2.85vw, 13px); line-height: 1.5; font-weight: 700; white-space: nowrap; }
.portrait-tile figcaption > span { font: 800 clamp(8px, 2.25vw, 10px)/1.3 Urbanist,sans-serif; color: var(--red); letter-spacing: .015em; overflow-wrap: anywhere; }
.home-process { display: flex; justify-content: space-between; align-items: center; gap: 3px; border-block: 1px solid var(--line); padding: 12px 0; font-size: 9px; color: var(--jade-dark); }
.home-process i { font-style: normal; color: var(--gold); }
.home-cta { position: sticky; bottom: 0; z-index: 8; padding: 12px 0 max(14px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, rgba(242,236,223,.92), var(--paper) 28%); backdrop-filter: blur(10px); }
.home-cta .primary { display: flex; align-items: center; justify-content: center; gap: 20px; }
.home-cta .fine-print { margin-top: 8px; font-size: 9px; }
.image-status { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; background: var(--paper); color: var(--jade-dark); z-index: 3; font-size: 12px; text-align: center; }
.image-status button { padding: 7px 12px; border: 1px solid var(--line); border-radius: 20px; background: #fff8; cursor: pointer; font-size: 11px; }

@media (min-width: 600px) {
  #app { height: min(960px, calc(100dvh - 32px)); border-radius: 28px; }
}

@media (max-height: 760px) {
  .identity { margin-top: 15px; }
  .start .brand { margin-bottom: 32px; }
}

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