:root {
  --ink: #12080b;
  --ink-2: #1d0d12;
  --paper: #f3e7d4;
  --paper-dim: #c9b69d;
  --red: #b2223b;
  --red-deep: #6b1126;
  --gold: #c9a46a;
  --line: rgba(243, 231, 212, 0.14);
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { background: var(--ink); }
body {
  margin: 0;
  min-height: 100svh;
  color: var(--paper);
  background:
    radial-gradient(circle at 18% 8%, rgba(168, 35, 55, 0.24), transparent 31rem),
    radial-gradient(circle at 84% 92%, rgba(201, 164, 106, 0.12), transparent 28rem),
    linear-gradient(150deg, #16090d 0%, #0d0709 50%, #1a0b10 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.7), transparent 70%);
}

.grain {
  position: fixed;
  inset: 0;
  opacity: .18;
  pointer-events: none;
  z-index: 20;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.88' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.17'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
}

button { font: inherit; }

.app {
  position: relative;
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 22px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 1px solid rgba(201,164,106,.8);
  color: var(--gold);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 20px;
  transform: rotate(-3deg);
}
.brand b { display: block; font-size: 13px; letter-spacing: .18em; font-weight: 600; }
.brand small { display: block; margin-top: 3px; font-size: 8px; letter-spacing: .16em; color: var(--paper-dim); }
.status-dot {
  max-width: 110px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 10px;
  letter-spacing: .14em;
  color: var(--paper-dim);
}
.status-dot::before {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 7px;
  border-radius: 50%; background: var(--gold); box-shadow: 0 0 14px rgba(201,164,106,.8);
}
.status-dot.closed::before { background: #7a4350; box-shadow: none; }

.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  animation: screenIn .5s cubic-bezier(.2,.8,.2,1) both;
}
.screen.active { display: flex; }
@keyframes screenIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.eyebrow,
.question-kicker,
.result-en {
  margin: 0 0 13px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: .3em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 18px;
  font-family: "STKaiti", "KaiTi", "Songti SC", serif;
  font-size: clamp(38px, 11vw, 54px);
  line-height: 1.08;
  font-weight: 500;
  letter-spacing: .03em;
}
h1 em { color: var(--red); font-style: normal; }
.lead { color: #d7c7b3; font-size: 14px; line-height: 1.9; margin-bottom: 24px; }

.hero-mark {
  width: 88px; height: 88px;
  display: grid; place-items: center;
  margin: 0 0 25px;
  border: 1px solid rgba(178,34,59,.56);
  border-radius: 50%;
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 44px;
  color: #e0c9b0;
  background: radial-gradient(circle, rgba(178,34,59,.3), rgba(178,34,59,.04) 62%, transparent 63%);
  box-shadow: 0 0 55px rgba(178,34,59,.18);
}

.trait-row { display: flex; gap: 8px; margin: 2px 0 28px; flex-wrap: wrap; }
.trait-row span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  color: var(--paper-dim);
  font-size: 10px;
  letter-spacing: .12em;
}

.primary, .ghost, .text-button, .option {
  appearance: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.primary {
  width: 100%;
  min-height: 56px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff8ee;
  background: linear-gradient(115deg, var(--red), #7e1730);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 14px 34px rgba(122,12,36,.28);
  font-size: 15px;
  letter-spacing: .08em;
  transition: transform .18s ease, filter .18s ease;
}
.primary:active { transform: scale(.985); filter: brightness(1.08); }
.primary b { font-size: 22px; font-weight: 400; }
.primary:disabled { opacity: .52; cursor: wait; }
.ghost {
  width: 100%; min-height: 48px; background: transparent; color: var(--paper-dim);
  border: 1px solid var(--line); font-size: 13px;
}
.text-button {
  align-self: flex-start; margin-top: 22px; padding: 8px 0; color: var(--paper-dim); background: transparent; font-size: 12px;
}
.text-button:disabled { opacity: .25; }

.disclaimer { margin: 14px 0 0; color: #806f6b; font-size: 10px; line-height: 1.6; text-align: center; }
.tiny { color: #8e7d73; font-size: 11px; line-height: 1.8; }

.loading-orb {
  width: 62px; height: 62px; border: 1px solid rgba(201,164,106,.25); border-top-color: var(--gold);
  border-radius: 50%; margin-bottom: 28px; animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.stamp {
  align-self: flex-start; margin-bottom: 26px; padding: 8px 12px;
  transform: rotate(-3deg); border: 1px solid rgba(178,34,59,.8); color: #d35d72;
  font-family: "STKaiti", "KaiTi", serif; font-size: 18px; letter-spacing: .18em;
}
.rule { height: 1px; width: 100%; margin: 24px 0 18px; background: var(--line); }

.progress-head {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  gap: 5px;
  margin-bottom: 54px;
  color: var(--paper-dim);
  font-size: 12px;
  letter-spacing: .08em;
}
.progress-head #questionIndex { color: var(--paper); font-size: 18px; }
.progress-track { height: 1px; margin-left: 14px; overflow: hidden; background: rgba(243,231,212,.13); }
.progress-track i { display: block; height: 100%; width: 16.6%; background: var(--red); transition: width .35s ease; }

.question { font-family: "STKaiti", "KaiTi", "Songti SC", serif; font-size: clamp(27px, 8.4vw, 38px); line-height: 1.32; font-weight: 500; margin-bottom: 30px; }
.options { display: grid; gap: 11px; }
.option {
  position: relative;
  width: 100%;
  padding: 18px 16px 18px 48px;
  text-align: left;
  color: #e4d6c3;
  background: rgba(255,255,255,.035);
  border: 1px solid rgba(243,231,212,.12);
  line-height: 1.55;
  font-size: 14px;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}
.option::before {
  content: attr(data-letter);
  position: absolute; left: 17px; top: 50%; transform: translateY(-50%);
  color: var(--gold); font-size: 11px; letter-spacing: .12em;
}
.option:focus-visible { border-color: rgba(178,34,59,.78); background: rgba(178,34,59,.12); outline: none; }
.option.selected { border-color: rgba(178,34,59,.95); background: rgba(178,34,59,.16); }
.option:disabled { cursor: default; }
@media (hover: hover) {
  .option:hover { border-color: rgba(178,34,59,.78); background: rgba(178,34,59,.12); }
}
.option:active { transform: scale(.99); }

.result-card {
  position: relative;
  overflow: hidden;
  padding: 38px 25px 28px;
  background:
    radial-gradient(circle at 50% 0%, rgba(178,34,59,.26), transparent 44%),
    linear-gradient(145deg, rgba(255,255,255,.052), rgba(255,255,255,.018));
  border: 1px solid rgba(243,231,212,.15);
  box-shadow: var(--shadow);
}
.result-card::after {
  content: ""; position: absolute; width: 190px; height: 190px; right: -100px; bottom: -100px;
  border: 1px solid rgba(201,164,106,.18); border-radius: 50%;
}
.result-glyph {
  width: 112px; height: 112px; margin: 0 auto 24px;
  display: grid; place-items: center;
  border: 1px solid rgba(201,164,106,.55); border-radius: 50%;
  font-family: "STKaiti", "KaiTi", serif; font-size: 58px; color: #f0dfca;
  background: radial-gradient(circle, rgba(178,34,59,.34), rgba(178,34,59,.03) 65%, transparent 66%);
  box-shadow: 0 0 50px rgba(178,34,59,.18);
}
.result-en { text-align: center; margin-bottom: 9px; }
.result-card h2 { font-family: "STKaiti", "KaiTi", serif; font-size: 42px; font-weight: 500; text-align: center; margin-bottom: 10px; }
.result-line { min-height: 48px; color: #d8c4ad; text-align: center; font-size: 14px; line-height: 1.8; }
.result-stats { display: grid; gap: 10px; margin: 26px 0 24px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { display: grid; grid-template-columns: 62px 1fr; gap: 10px; align-items: center; font-size: 11px; color: var(--paper-dim); }
.stat b { color: var(--paper); font-weight: 500; }
.stat-track { height: 4px; background: rgba(255,255,255,.08); overflow: hidden; }
.stat-track i { display: block; height: 100%; background: linear-gradient(90deg, var(--red-deep), var(--red), var(--gold)); }
.result-copy { color: #d4c4b3; font-size: 13px; line-height: 1.95; }
.result-quote { margin-top: 22px; padding-left: 14px; border-left: 2px solid var(--red); color: #f0dfca; font-family: "STKaiti", "KaiTi", serif; font-size: 17px; line-height: 1.7; }
.result-actions { display: grid; gap: 10px; margin-top: 18px; }

.footer {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 30px; padding-top: 14px;
  border-top: 1px solid var(--line); color: #6f5f59; font-size: 8px; letter-spacing: .14em;
}

.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 60; max-width: calc(100vw - 44px); padding: 11px 15px;
  transform: translate(-50%, 25px); opacity: 0; pointer-events: none;
  background: rgba(27, 13, 17, .96); border: 1px solid rgba(201,164,106,.3);
  color: #e8d7bf; font-size: 12px; transition: .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .app { padding-left: 17px; padding-right: 17px; }
  .result-card { padding-left: 20px; padding-right: 20px; }
  .result-card h2 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.poster-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(7, 4, 5, .88);
  backdrop-filter: blur(12px);
}
.poster-modal-card {
  width: min(100%, 390px);
  max-height: 92svh;
  overflow: auto;
  padding: 16px;
  background: #170b0f;
  border: 1px solid rgba(201,164,106,.28);
  box-shadow: var(--shadow);
}
.poster-modal-card p {
  margin: 2px 0 12px;
  color: var(--paper-dim);
  text-align: center;
  font-size: 12px;
}
.poster-modal-card img {
  display: block;
  width: 100%;
  max-height: 68svh;
  object-fit: contain;
  background: #0d0709;
}
.poster-modal-card a,
.poster-modal-card button {
  width: 100%;
  min-height: 44px;
  margin-top: 10px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(201,164,106,.34);
  color: var(--paper);
  background: rgba(178,34,59,.22);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
}
.poster-modal-card button {
  background: transparent;
  color: var(--paper-dim);
}

.redeem-screen { justify-content: flex-start; padding-top: clamp(28px, 8vh, 76px); }
.redeem-form { display: grid; gap: 12px; margin: 6px 0 24px; }
.field-label { color: var(--gold); font-size: 10px; letter-spacing: .2em; }
.field-input {
  width: 100%;
  min-height: 56px;
  padding: 0 15px;
  border: 1px solid rgba(243,231,212,.18);
  color: var(--paper);
  background: rgba(255,255,255,.045);
  outline: none;
  font-size: 15px;
  letter-spacing: .04em;
}
.field-input::placeholder { color: #76655f; }
.field-input:focus { border-color: rgba(178,34,59,.85); background: rgba(178,34,59,.1); }
.redeem-result {
  margin-top: 8px;
  padding: 18px 16px;
  border: 1px solid rgba(201,164,106,.28);
  background: rgba(255,255,255,.035);
  animation: screenIn .35s ease both;
}
.redeem-url {
  padding: 12px;
  overflow-wrap: anywhere;
  color: #f0dfca;
  background: rgba(0,0,0,.22);
  border: 1px dashed rgba(201,164,106,.25);
  font-size: 12px;
  line-height: 1.65;
}
.redeem-result .primary { display: grid; place-items: center; text-decoration: none; }

/* Per-test themes */
body.theme-animal {
  --theme-accent: #b2223b;
  --theme-accent-deep: #6b1126;
}
body.theme-age {
  --ink: #0a1014;
  --ink-2: #101b21;
  --paper: #e9e7de;
  --paper-dim: #a9b3b6;
  --red: #3e8299;
  --red-deep: #1d4a5b;
  --gold: #c1a670;
  --line: rgba(233,231,222,.15);
  background:
    radial-gradient(circle at 16% 10%, rgba(62,130,153,.27), transparent 28rem),
    radial-gradient(circle at 86% 88%, rgba(193,166,112,.13), transparent 26rem),
    linear-gradient(145deg, #0b1318, #080d10 50%, #111b20);
}
body.theme-age::before { background-size: 32px 32px; }
body.theme-age .brand-mark { border-radius: 2px; transform: rotate(0deg); }
body.theme-age .hero-mark {
  border-radius: 5px;
  border-color: rgba(62,130,153,.72);
  background: linear-gradient(145deg, rgba(62,130,153,.28), rgba(62,130,153,.04));
  box-shadow: 0 0 44px rgba(62,130,153,.16);
}
body.theme-age .primary { background: linear-gradient(115deg, #3e8299, #1d4a5b); box-shadow: 0 14px 34px rgba(29,74,91,.3); }
body.theme-age .result-card {
  background:
    linear-gradient(rgba(233,231,222,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233,231,222,.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(62,130,153,.22), transparent 45%),
    linear-gradient(145deg, rgba(255,255,255,.045), rgba(255,255,255,.015));
  background-size: 24px 24px, 24px 24px, auto, auto;
}
body.theme-age .result-glyph { border-radius: 8px; border-color: rgba(62,130,153,.68); }
body.theme-age .result-quote { border-color: #3e8299; }
body.theme-age .stat-track i { background: linear-gradient(90deg, #1d4a5b, #3e8299, #c1a670); }

body.theme-role {
  --ink: #120b0a;
  --ink-2: #21110d;
  --paper: #f2e4cc;
  --paper-dim: #c4a983;
  --red: #a94825;
  --red-deep: #5f2114;
  --gold: #d0ad70;
  --line: rgba(242,228,204,.15);
  background:
    linear-gradient(118deg, rgba(169,72,37,.11) 0 12%, transparent 12% 88%, rgba(169,72,37,.11) 88%),
    radial-gradient(circle at 72% 8%, rgba(208,173,112,.18), transparent 30rem),
    linear-gradient(145deg, #190d0b, #0c0707 55%, #20100d);
}
body.theme-role .brand-mark { border-radius: 50% 50% 3px 3px; transform: rotate(-4deg); }
body.theme-role .hero-mark {
  border-radius: 50% 50% 5px 5px;
  border-color: rgba(208,173,112,.68);
  background: linear-gradient(160deg, rgba(169,72,37,.38), rgba(95,33,20,.08));
  box-shadow: 0 0 55px rgba(169,72,37,.22);
}
body.theme-role .primary { background: linear-gradient(115deg, #a94825, #5f2114); box-shadow: 0 14px 34px rgba(95,33,20,.34); }
body.theme-role .result-card {
  background:
    linear-gradient(90deg, rgba(208,173,112,.12) 0 2px, transparent 2px),
    radial-gradient(circle at 50% 0%, rgba(169,72,37,.25), transparent 46%),
    linear-gradient(145deg, rgba(255,255,255,.055), rgba(255,255,255,.016));
  background-size: 100% 100%, auto, auto;
}
body.theme-role .result-card::before {
  content: "SCENE 01 / TAKE 01";
  position: absolute;
  top: 14px;
  right: 14px;
  color: rgba(242,228,204,.28);
  font-size: 8px;
  letter-spacing: .18em;
}
body.theme-role .result-glyph { border-radius: 50% 50% 7px 7px; border-color: rgba(208,173,112,.62); }
body.theme-role .result-quote { border-color: #d0ad70; }
body.theme-role .stat-track i { background: linear-gradient(90deg, #5f2114, #a94825, #d0ad70); }

.radar-wrap {
  margin: 4px 0 24px;
  padding: 12px 6px 4px;
  border-top: 1px solid var(--line);
}
.radar-title {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 10px;
  letter-spacing: .2em;
  text-align: center;
}
.radar-svg { display: block; width: 100%; height: auto; overflow: visible; }
.radar-grid { fill: none; stroke: rgba(243,231,212,.13); stroke-width: 1; }
.radar-axis { stroke: rgba(243,231,212,.12); stroke-width: 1; }
.radar-area { fill: color-mix(in srgb, var(--red) 30%, transparent); stroke: var(--red); stroke-width: 2; }
.radar-dot { fill: var(--gold); stroke: var(--ink); stroke-width: 2; }
.radar-label { fill: var(--paper-dim); font-size: 10px; font-family: "PingFang SC", "Microsoft YaHei", sans-serif; }
.radar-score { fill: var(--paper); font-size: 9px; font-weight: 600; }

