:root {
  color-scheme: dark;
  --purple: oklch(0.49 0.23 316);
  --purple-deep: oklch(0.31 0.10 319);
  --char: oklch(0.23 0.018 15);
  --near-black: oklch(0.13 0.008 320);
  --orange: oklch(0.79 0.16 65);
  --text: oklch(0.94 0.016 75);
  --text-dim: oklch(0.72 0.022 65);
  --line: oklch(0.76 0.07 65 / 0.22);
  --overlay: oklch(0.13 0.008 320 / 0.78);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at 50% 0, var(--char), var(--near-black) 75%);
  background-attachment: fixed;
  font-size: 15px;
  line-height: 1.65;
}
button, input, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button, .history-item { touch-action: manipulation; }
button {
  min-height: 44px; border: 1px solid transparent; border-radius: 12px;
  cursor: pointer; color: inherit; background: none;
}
button:disabled { opacity: 0.55; cursor: wait; }
button:not(:disabled):active { transform: translateY(1px); }
button, a { transition: background-color 160ms ease-out, border-color 160ms ease-out; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 4px; }
button svg, a svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.page { position: relative; max-width: 600px; padding: 32px 24px 64px; margin: 0 auto; }
.hidden { display: none !important; }
.primary { background: var(--orange); color: var(--near-black); font-weight: 750; padding: 12px 20px; }
.primary:hover { background: oklch(0.84 0.14 65); }
.secondary { background: oklch(0.22 0.015 320 / 0.7); border-color: var(--line); padding: 10px 16px; }
.secondary:hover { border-color: var(--text-dim); }
.text-button, .link { color: var(--text-dim); font-size: 13px; padding: 8px 12px; }
.text-button:hover, .link:hover { color: var(--text); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; padding: 10px; background: var(--overlay); border-color: var(--line); border-radius: 50%; }
.audio-toggle { position: fixed; right: max(16px, env(safe-area-inset-right)); top: max(16px, env(safe-area-inset-top)); z-index: 10; }
.audio-toggle[aria-pressed="true"] { color: var(--orange); }
.audio-feedback { position: fixed; right: 16px; top: 68px; z-index: 10; max-width: 220px; padding: 8px 12px; border-radius: 10px; background: var(--overlay); color: var(--text-dim); font-size: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); }
input { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--overlay); color: var(--text); font-size: 16px; }
.error { color: oklch(0.82 0.11 30); font-size: 13px; background: oklch(0.29 0.045 25 / 0.7); border-radius: 10px; padding: 10px 12px; }
.loading { color: var(--text-dim); text-align: center; padding: 24px 0; }
.row { display: flex; gap: 12px; }
/* 首屏铺满手机视口，控件独立投影，不给整组表单铺底。 */
.home-page { padding: 0 24px 48px; }
.hero-stage { position: relative; isolation: isolate; overflow: hidden; min-height: max(100svh, 844px); }
.hero { display: block; width: 100%; height: 100%; position: absolute; inset: 0; object-fit: cover; object-position: center top; z-index: -2; }
.hero-form { position: absolute; left: 28px; right: 28px; bottom: max(32px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.tagline { font-size: 14px; font-weight: 600; color: var(--text); text-align: center; }
.hero-form .tagline, .hero-form .field > span, .hero-form .text-button { color: var(--text); text-shadow: 0 2px 4px oklch(0.1 0.008 320), 0 3px 14px oklch(0.1 0.008 320 / 0.9); }
.hero-form .type-btn, .hero-form input, .hero-start { box-shadow: 0 4px 14px oklch(0.1 0.008 320 / 0.65); }
.type-toggle { display: flex; gap: 8px; }
.type-btn { flex: 1; font-size: 14px; background: var(--overlay); border-color: var(--line); }
.type-btn.selected { color: var(--orange); border-color: oklch(0.79 0.16 65 / 0.8); background: oklch(0.23 0.026 50 / 0.8); font-weight: 650; }
.hero-start { display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 700; font-size: 15px; background: oklch(0.12 0.008 320 / 0.85); border-color: oklch(0.79 0.16 65 / 0.6); }
.hero-start:hover { background: oklch(0.28 0.035 55 / 0.95); }
.hero-form .text-button { min-height: 44px; margin: -8px 0; }
.browser-note { color: var(--text-dim); text-align: center; font-size: 11px; line-height: 1.85; margin: 24px auto 0; }
.history-section { margin-top: 32px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-heading h2 { font-size: 16px; font-weight: 650; }
.section-heading span { font-size: 11px; color: var(--text-dim); }
.history-list { display: flex; flex-direction: column; }
.history-item { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 16px 4px; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.history-item:hover { background: oklch(0.25 0.025 55 / 0.4); }
.history-item strong { display: block; font-size: 15px; font-weight: 650; }
.history-item span, .history-item small { color: var(--text-dim); font-size: 12px; }
.history-item svg { color: var(--orange); }
.quiz-page { max-width: 520px; padding-top: clamp(80px, 13vh, 136px); }
.quiz-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.progress { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.progress-track { height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 40px; }
.progress-fill { height: 100%; background: var(--orange); transform-origin: left; }
.scene { font-size: 13px; color: var(--orange); margin-bottom: 12px; }
#qtext { font-size: clamp(23px, 5.8vw, 28px); font-weight: 650; line-height: 1.55; margin-bottom: 32px; letter-spacing: 0.01em; }
#qtext:focus { outline: none; }
#options { display: flex; flex-direction: column; gap: 12px; }
.option { display: flex; align-items: center; text-align: left; width: 100%; padding: 16px 18px; min-height: 60px; color: var(--text); background: oklch(0.25 0.022 25 / 0.5); border-color: var(--line); font-size: 14px; line-height: 1.7; }
.option:hover { border-color: oklch(0.72 0.10 65 / 0.65); }
.option.selected { border-color: var(--orange); background: oklch(0.32 0.08 319 / 0.65); }
.option:disabled { opacity: 1; }
.quiz-hint { font-size: 11px; text-align: center; margin-top: 24px; color: var(--text-dim); }
.quiz-page .error { margin-top: 20px; }
#retryBtn { width: 100%; margin-top: 12px; }
.result-page { padding-top: 72px; }
.result-home { position: absolute; top: 20px; left: 24px; color: var(--text-dim); text-decoration: none; display: flex; align-items: center; gap: 6px; font-size: 12px; min-height: 44px; }
.result-header { text-align: center; margin: 8px 0 32px; }
.rarity { color: var(--text-dim); font-size: 14px; letter-spacing: 0.04em; margin-bottom: 8px; }
.rarity-info { display: inline-flex; vertical-align: middle; font-size: 10px; align-items: center; justify-content: center; width: 14px; height: 14px; border: 1px solid var(--text-dim); border-radius: 50%; margin-left: 6px; }
#roleName { font-size: clamp(18.75px, 4.65vw, 27px); font-weight: 750; letter-spacing: 0.025em; line-height: 1.45; text-wrap: balance; }
.free-card { margin: 0 auto; width: min(68vw, 250px); }
#roleCardImage { display: block; width: 100%; height: auto; aspect-ratio: 900 / 1380; object-fit: contain; border: 1px solid oklch(0.72 0.07 75); border-radius: 12px; background: #0a0916; }
.card-caption { color: var(--text-dim); font-size: 10px; text-align: center; margin-top: 10px; }
.quote { font-size: clamp(16px, 3.7vw, 19px); font-weight: 500; color: var(--orange); line-height: 1.75; text-align: center; margin: 28px 0 20px; }
.petname-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; }
#petNameText { grid-column: 2; font-size: 16px; font-weight: 650; overflow-wrap: anywhere; }
.petname-row .icon-button { justify-self: start; border: none; background: none; color: oklch(0.53 0.018 65); }
.petname-row .icon-button svg { width: 12px; height: 12px; }
.rename-form { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.rename-form input { width: min(100%, 200px); }
.rename-form .secondary { padding: 8px 12px; font-size: 13px; }
.name-status { min-height: 24px; color: var(--text-dim); font-size: 12px; text-align: center; }
.traits-layout { display: grid; grid-template-columns: 170px minmax(0, 1fr); align-items: center; gap: 24px; max-width: 390px; margin: 36px auto 0; padding: 28px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#radar { display: block; width: 170px; height: 155px; }
.traits-copy h2 { font-size: 16px; font-weight: 650; line-height: 1.5; margin-bottom: 12px; }
#shortLines { display: flex; flex-direction: column; list-style: none; gap: 10px; font-size: 13px; line-height: 1.8; color: var(--text-dim); }
.result-actions { display: flex; flex-direction: column; align-items: stretch; margin: 32px auto 0; max-width: 360px; gap: 12px; }
.result-actions .primary { min-height: 52px; font-size: 16px; }
.result-actions .row { justify-content: center; gap: 24px; }
.result-actions .secondary { font-size: 13px; padding: 8px 12px; background: none; border-color: transparent; color: var(--text-dim); }
.result-actions .secondary:hover { color: var(--text); border-color: var(--line); }
.custom-dialog { position: fixed; inset: 0; margin: auto; width: min(440px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow: auto; padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--char); color: var(--text); box-shadow: 0 24px 80px oklch(0.08 0.008 320 / 0.6); }
.custom-dialog::backdrop { background: oklch(0.10 0.008 320 / 0.82); }
.custom-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -8px -8px 12px 0; }
.custom-kicker { color: var(--orange); font-size: 12px; }
.custom-heading .icon-button { border-color: transparent; background: none; }
.custom-dialog h2 { font-size: 24px; line-height: 1.4; }
.custom-intro { margin-top: 8px; color: var(--text-dim); font-size: 14px; }
.custom-steps { display: flex; justify-content: space-between; gap: 6px; list-style: none; margin: 24px 0; padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--text-dim); }
.custom-steps [aria-current] { color: var(--orange); font-weight: 650; }
.role-choice { display: grid; grid-template-columns: 1fr auto; text-align: left; align-items: center; width: 100%; margin-top: 12px; padding: 16px 18px; border-color: var(--line); background: oklch(0.19 0.018 319); }
.role-choice:hover { border-color: var(--orange); }
.role-choice > span:first-child { grid-column: 1; color: var(--text-dim); font-size: 12px; }
.role-choice strong { grid-column: 1; font-size: 16px; }
.role-choice > span:last-child { grid-column: 2; grid-row: 1 / 3; color: var(--orange); }
.role-back { padding-left: 0; }
.role-slide { text-align: center; touch-action: pan-y; }
.role-rarity { color: var(--text-dim); font-size: 12px; }
.role-slide h3 { margin-top: 4px; font-size: 17px; }
.role-portrait { position: relative; width: min(100%, 160px); aspect-ratio: 4 / 5; margin: 4px auto; overflow: hidden; }
.role-portrait span { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-dim); font-size: 12px; }
.role-sprite-window { position: absolute; top: 50%; width: 100%; aspect-ratio: 1; overflow: hidden; transform: translateY(-50%); }
.role-portrait img { position: absolute; top: 0; left: 0; width: 400%; height: 400%; max-width: none; object-fit: fill; }
.role-quote { min-height: 3em; color: var(--orange); font-size: 13px; }
.role-navigation { display: flex; align-items: center; justify-content: center; gap: 30px; color: var(--text-dim); font-size: 12px; }
.role-navigation button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; color: var(--text); font-size: 25px; line-height: 1; }
.role-navigation button:disabled { cursor: default; opacity: 0.3; }
.role-swipe-hint { text-align: center; color: var(--text-dim); font-size: 11px; }
.role-browser > .primary { width: 100%; margin-top: 12px; }
.selected-role { margin: 12px 0; color: var(--text-dim); font-size: 13px; }
.selected-role strong { color: var(--text); }
.selected-role .text-button { min-height: 44px; color: var(--orange); }
.photo-picker { position: relative; min-height: 160px; border: 1px dashed var(--line); border-radius: 12px; overflow: hidden; background: var(--near-black); }
.photo-picker #photoLabel { display: flex; min-height: 160px; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; color: var(--orange); font-size: 16px; text-align: center; }
.photo-picker #photoLabel span { color: var(--text-dim); font-size: 11px; }
.photo-picker input { position: absolute; width: 1px; height: 1px; min-width: 0; min-height: 0; padding: 0; border: 0; opacity: 0; overflow: hidden; clip-path: inset(50%); pointer-events: none; }
.photo-picker:focus-within { outline: 2px solid var(--orange); outline-offset: 3px; }
#photoPreview { display: block; width: 100%; max-height: 240px; object-fit: contain; }
#photoPreview:not(.hidden) + #photoLabel { min-height: 52px; padding: 10px; font-size: 13px; }
#photoPreview:not(.hidden) + #photoLabel span { display: none; }
.custom-open, .custom-open body { overflow: hidden; overscroll-behavior: none; }
.custom-dialog { overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.custom-note { font-size: 12px; color: var(--text-dim); line-height: 1.8; margin-top: 12px; }
.photo-consent { display: flex; align-items: flex-start; gap: 10px; padding: 16px 0; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.photo-consent input { width: 20px; height: 20px; min-height: 20px; flex-shrink: 0; margin-top: 2px; accent-color: var(--orange); }
.custom-dialog section > button, .custom-pay-link { display: block; width: 100%; margin-top: 12px; }
.custom-pay-link { text-align: center; text-decoration: none; border-radius: 12px; min-height: 44px; }
.payment-amount { font-size: 20px; font-weight: 650; color: var(--orange); }
.payment-reference { display: flex; align-items: center; gap: 4px; margin-top: 12px; }
.payment-reference code { overflow-wrap: anywhere; font-size: 12px; flex: 1; user-select: all; }
.payment-order { margin-top: 24px; }
.payment-order summary { min-height: 44px; padding: 10px 0; cursor: pointer; color: var(--text-dim); font-size: 13px; }
.payment-order .secondary { width: 100%; margin-top: 12px; }
#customOutput { margin: 20px 0; text-align: center; }
#customImage { display: block; width: 100%; height: auto; border-radius: 12px; }
.custom-progress { font-size: 13px; color: var(--orange); margin-top: 12px; }
.custom-progress:empty { display: none; }
.custom-dialog .error { margin-top: 12px; }
@media (max-width: 350px) { .custom-dialog { padding: 20px 16px; } .custom-dialog h2 { font-size: 21px; } .custom-steps { font-size: 10px; } }
#resultError { margin-top: 12px; }
.result-footer { text-align: center; font-size: 11px; letter-spacing: 0.1em; color: var(--text-dim); margin-top: 48px; }
.empty-result { text-align: center; padding: 80px 0; }
.empty-result a { color: var(--orange); display: inline-block; padding: 16px; }
@media (max-width: 480px) {
  .page { padding-left: 20px; padding-right: 20px; }
  .home-page { padding: 0 0 40px; }
  .hero-stage { min-height: 100svh; }
  .history-section { padding: 0 20px; }
  .traits-layout { grid-template-columns: 150px minmax(0, 1fr); gap: 16px; }
  #radar { width: 150px; height: auto; }
  .traits-copy h2 { font-size: 14px; }
  #shortLines { font-size: 12px; gap: 8px; }
  .result-header { margin-bottom: 28px; }
}
@media (max-width: 350px) {
  .hero-form { left: 20px; right: 20px; }
  .tagline { font-size: 12px; }
  .traits-layout { grid-template-columns: 130px minmax(0, 1fr); gap: 12px; }
  #radar { width: 130px; }
  .result-page { padding-left: 16px; padding-right: 16px; }
  .result-actions .row { gap: 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
