:root {
  color-scheme: light;
  --paper: #f7efe4;
  --paper-deep: #efe2d3;
  --card: #fffdf8;
  --ink: #332a25;
  --ink-soft: #57483f;
  --muted: #8e7d71;
  --red: #a83b34;
  --red-dark: #762a27;
  --red-pale: #f4dfd8;
  --gold: #c39a55;
  --gold-pale: #f1e4c9;
  --jade: #6f8d80;
  --line: #e3d5c5;
  --line-strong: #cfbca7;
  --shadow: 0 24px 70px rgba(93, 58, 41, .13);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); scroll-behavior: smooth; }
body {
  min-height: 100%; margin: 0; color: var(--ink); overflow-x: hidden;
  background:
    radial-gradient(circle at 9% 3%, rgba(168, 59, 52, .13), transparent 25rem),
    radial-gradient(circle at 96% 46%, rgba(195, 154, 85, .13), transparent 24rem),
    linear-gradient(180deg, #fbf4ea 0%, var(--paper) 52%, #f1e5d7 100%);
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid rgba(168, 59, 52, .25); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

#app { min-height: 100dvh; }
.scene { position: relative; min-height: 100dvh; width: min(100%, 480px); margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) 18px max(44px, env(safe-area-inset-bottom)); overflow: hidden; isolation: isolate; }
.paper-texture { position: fixed; inset: 0; z-index: -3; opacity: .18; pointer-events: none; background-image: repeating-radial-gradient(circle at 20% 30%, rgba(69,45,32,.18) 0 .45px, transparent .65px 4px); background-size: 9px 9px; }
.festival-ornament { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.festival-ornament i { position: absolute; display: block; }
.festival-ornament i:nth-child(1) { width: 260px; height: 260px; left: calc(50% - 365px); top: -135px; border: 1px solid rgba(168,59,52,.13); border-radius: 50%; box-shadow: inset 0 0 0 28px rgba(168,59,52,.025), inset 0 0 0 54px rgba(168,59,52,.018); }
.festival-ornament i:nth-child(2) { width: 210px; height: 210px; right: calc(50% - 330px); top: 42%; opacity: .12; background: repeating-conic-gradient(from 0deg, var(--gold) 0 2deg, transparent 2deg 18deg); border-radius: 50%; }
.festival-ornament i:nth-child(3) { width: 310px; height: 120px; left: calc(50% - 245px); bottom: -72px; border-top: 1px solid rgba(195,154,85,.28); border-radius: 50%; transform: rotate(-8deg); }

.cover-card, .paper-card, .question-card, .result-section, .result-hero, .transition-card, .easter-envelope {
  border: 1px solid rgba(168, 59, 52, .13); border-radius: 24px;
  background: rgba(255, 253, 248, .94); box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.gate-scene, .intro-scene, .transition-scene { display: grid; align-items: center; }
.gate-card { position: relative; padding: 20px 24px 28px; overflow: hidden; text-align: center; }
.gate-card::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(circle at 50% 9%, rgba(168,59,52,.11), transparent 34%), linear-gradient(180deg, rgba(255,255,255,.38), transparent 52%); }
.gate-card::after { content: "福"; position: absolute; z-index: -1; right: -18px; bottom: 105px; color: rgba(168,59,52,.035); font: 700 142px/1 "Kaiti SC", "STKaiti", serif; transform: rotate(-9deg); }
.cover-topline { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid rgba(195,154,85,.34); color: var(--muted); font-size: 11px; letter-spacing: .14em; }
.cover-topline b { padding: 4px 8px; border: 1px solid rgba(168,59,52,.24); border-radius: 99px; color: var(--red); font-weight: 700; letter-spacing: .08em; }
.table-illustration { width: min(100%, 350px); height: auto; display: block; margin: 6px auto -2px; overflow: visible; }
.window-line { fill: none; stroke: rgba(195,154,85,.25); stroke-width: 1; }
.table-shadow { fill: rgba(82,54,39,.12); }
.table-top { fill: url(#tableRed); stroke: rgba(117,42,38,.55); stroke-width: 2; }
.plate { fill: #fff5df; stroke: #c39a55; }
.dish { fill: #6f8d80; }
.seat { fill: #f1e4c9; stroke: rgba(168,59,52,.42); stroke-width: 2; }
.speech { fill: #fffdf8; stroke: rgba(168,59,52,.35); stroke-width: 1.2; }
.table-illustration text { fill: #6c5042; font: 12px "PingFang SC", sans-serif; text-anchor: middle; }
.eyebrow { margin: 0 0 11px; color: var(--red); font-size: 12px; font-weight: 760; letter-spacing: .18em; }
.cover-card h1, .intro-card h1, .transition-card h1 { margin: 0; font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; font-weight: 700; letter-spacing: .045em; }
.cover-card h1 { color: var(--red-dark); font-size: clamp(35px, 9.6vw, 46px); line-height: 1.25; }
.cover-hook { margin: 18px 0 16px; color: var(--ink-soft); font: 17px/1.8 "Kaiti SC", "STKaiti", "Songti SC", serif; }
.truth-teasers { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.truth-teasers span { padding: 6px 9px; border: 1px solid rgba(168,59,52,.14); border-radius: 99px; color: #795f52; background: rgba(255,255,255,.58); font-size: 11px; }
.primary-button, .outline-button { width: 100%; min-height: 54px; padding: 14px 18px; border-radius: 13px; cursor: pointer; font-weight: 760; letter-spacing: .035em; }
.primary-button { margin-top: 12px; border: 1px solid var(--red-dark); color: #fffaf2; background: linear-gradient(135deg, #b94a40, var(--red-dark)); box-shadow: 0 13px 30px rgba(118,42,39,.23); }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .56; cursor: wait; }
.hero-button { margin-top: 22px; }
.outline-button { border: 1px solid rgba(168,59,52,.42); color: var(--red-dark); background: rgba(255,253,248,.66); }
.code-panel { margin-top: 21px; padding: 17px 15px 15px; border: 1px solid var(--line); border-radius: 17px; background: rgba(247,239,228,.76); animation: panel-in .28s ease-out; }
.code-panel p { margin: 0 0 13px; }
.code-panel p b, .code-panel p span { display: block; }
.code-panel p b { color: var(--red-dark); font: 700 17px "Songti SC", serif; }
.code-panel p span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.code-field { display: block; }
.code-field input { width: 100%; min-height: 52px; padding: 13px 15px; border: 1px solid var(--line-strong); border-radius: 12px; color: var(--ink); background: #fffdf9; text-align: center; text-transform: uppercase; letter-spacing: .07em; }
.code-field input::placeholder { color: #a29184; letter-spacing: .02em; }
.micro-copy, .disclaimer, .result-disclaimer { color: var(--muted); font-size: 12px; line-height: 1.7; }
.micro-copy { margin: 13px 0 0; }
@keyframes panel-in { from { opacity: 0; transform: translateY(8px); } }

.intro-card { position: relative; padding: 31px 25px 27px; text-align: center; overflow: hidden; }
.entry-ticket { display: flex; align-items: center; gap: 8px; width: fit-content; margin: 0 auto 28px; padding: 9px 12px; border: 1px dashed rgba(168,59,52,.40); border-radius: 8px; color: var(--red-dark); background: var(--red-pale); transform: rotate(-2deg); }
.entry-ticket span, .entry-ticket em { color: var(--muted); font-size: 10px; font-style: normal; letter-spacing: .08em; }
.entry-ticket b { padding-inline: 8px; border-inline: 1px solid rgba(168,59,52,.28); font: 700 16px "Songti SC", serif; }
.intro-card h1 { font-size: 28px; line-height: 1.55; }
.intro-card > p:not(.eyebrow):not(.soft-note):not(.disclaimer) { color: #67574d; line-height: 1.88; }
.intro-notes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 25px 0; }
.intro-notes div { padding: 14px 4px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.68); }
.intro-notes b { display: block; color: var(--red); font: 700 24px "Songti SC", serif; }
.intro-notes span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.soft-note { padding: 13px 14px; border-left: 3px solid var(--gold); border-radius: 5px; color: #705d50; background: rgba(195,154,85,.10); font-size: 13px; line-height: 1.75; text-align: left; }
.text-button { display: block; margin: 13px auto 0; padding: 8px 10px; border: 0; color: var(--red); background: transparent; cursor: pointer; }
.disclaimer { margin: 18px 0 0; }

.quiz-scene { padding-top: max(14px, env(safe-area-inset-top)); }
.quiz-shell { min-height: calc(100dvh - 58px); }
.quiz-header { display: grid; grid-template-columns: 42px 1fr 42px; align-items: center; gap: 8px; }
.back-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 50%; color: var(--red); background: rgba(255,253,248,.72); cursor: pointer; }
.back-button:disabled { opacity: .26; cursor: default; }
.progress-meta { display: grid; justify-items: center; gap: 1px; color: var(--muted); font-size: 11px; }
.progress-meta b { color: var(--ink); font-size: 13px; font-weight: 680; }
.progress-track { height: 6px; margin: 13px 2px 25px; border-radius: 99px; background: #efd9d4; overflow: hidden; }
.progress-track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--red)); transition: width .34s ease; }
.question-card { position: relative; padding: 37px 20px 23px; }
.question-number { position: absolute; top: -19px; left: 21px; width: 42px; height: 42px; display: grid; place-items: center; border: 2px solid var(--red); border-radius: 50%; color: #fffaf2; background: var(--red); box-shadow: 0 5px 15px rgba(118,42,39,.18); font: 700 17px "Songti SC", serif; }
.question-lead { margin: 0 0 10px; padding-left: 11px; border-left: 2px solid var(--gold); color: #79675b; font-size: 13px; line-height: 1.72; }
.question-card h1 { margin: 0 0 22px; font: 700 22px/1.55 "Songti SC", "STSong", serif; }
.options { display: grid; gap: 10px; }
.option-button { width: 100%; min-height: 60px; display: grid; grid-template-columns: 17px 29px 1fr; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: rgba(255,255,255,.82); text-align: left; cursor: pointer; transition: transform .18s ease, border-color .18s ease, background .18s ease, color .18s ease; }
.option-radio { width: 15px; height: 15px; border: 1px solid #a89586; border-radius: 50%; transition: inherit; }
.option-letter { width: 29px; height: 29px; display: grid; place-items: center; border: 1px solid rgba(168,59,52,.22); border-radius: 8px; color: var(--red-dark); background: var(--red-pale); font: 750 13px/1 Georgia, "Times New Roman", serif; font-style: normal; transition: inherit; }
.option-button b { font-size: 15px; font-weight: 520; line-height: 1.58; }
.option-button:hover { transform: translateY(-1px); border-color: rgba(168,59,52,.42); }
.option-button.selected { color: #fffaf2; border-color: var(--red); background: linear-gradient(135deg, #a83b34, #7d2b27); box-shadow: 0 9px 25px rgba(118,42,39,.20); }
.option-button.selected .option-radio { border: 4px solid rgba(255,255,255,.93); background: var(--gold); }
.option-button.selected .option-letter { border-color: rgba(255,255,255,.45); color: #fff; background: rgba(255,255,255,.14); }

.transition-card { padding: 54px 24px; text-align: center; }
.transition-card h1 { font-size: 24px; line-height: 1.72; }
.seal-loader { position: relative; width: 86px; height: 86px; display: grid; place-items: center; margin: 0 auto 24px; border: 2px solid var(--red); color: var(--red); transform: rotate(-4deg); }
.seal-loader i { font: 700 37px "Kaiti SC", serif; font-style: normal; }
.seal-loader span { position: absolute; inset: -9px; border: 1px solid rgba(195,154,85,.7); animation: seal-pulse 1.1s ease-in-out infinite alternate; }
.loading-lines { position: relative; height: 24px; margin-top: 25px; color: var(--muted); font-size: 12px; overflow: hidden; }
.loading-lines span { position: absolute; inset: 0; opacity: 0; animation: loading-copy 1.5s infinite; }
.loading-lines span:nth-child(2) { animation-delay: .5s; }.loading-lines span:nth-child(3) { animation-delay: 1s; }
@keyframes seal-pulse { to { opacity: .2; transform: scale(1.08) rotate(7deg); } }
@keyframes loading-copy { 0%,29% { opacity: 1; transform: none; } 34%,100% { opacity: 0; transform: translateY(-5px); } }

.result-scene { width: min(100%, 550px); padding-inline: 13px; }
.result-scroll { display: grid; gap: 14px; --type-accent: var(--red); }
.result-hero { position: relative; padding: 36px 22px 28px; overflow: hidden; text-align: center; background: linear-gradient(180deg, color-mix(in srgb, var(--type-accent) 16%, #fffaf1), rgba(255,253,248,.98) 68%); }
.result-hero::after { content: ""; position: absolute; width: 170px; height: 170px; right: -72px; top: -72px; border: 1px solid color-mix(in srgb, var(--type-accent) 32%, transparent); border-radius: 50%; box-shadow: inset 0 0 0 24px color-mix(in srgb, var(--type-accent) 4%, transparent); }
.survival-stamp { width: fit-content; margin: 0 auto 12px; padding: 4px 9px; border: 1px solid var(--type-accent); color: var(--type-accent); font: 700 12px "Kaiti SC", serif; letter-spacing: .14em; transform: rotate(-2deg); }
.result-hero .eyebrow, .result-scroll .section-mark { color: var(--type-accent); }
.type-glyph { width: 90px; height: 90px; display: block; margin: 0 auto 4px; fill: none; stroke: var(--type-accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.result-hero h1 { margin: 1px 0 8px; color: var(--type-accent); font: 700 clamp(33px, 8.8vw, 45px) "Songti SC", serif; letter-spacing: .055em; }
.subtype-tag { display: inline-block; margin: 0; padding: 5px 14px; border: 1px solid color-mix(in srgb, var(--type-accent) 38%, transparent); border-radius: 99px; color: var(--type-accent); background: rgba(255,255,255,.58); font-size: 13px; }
.result-kicker { margin: 18px auto 0; max-width: 370px; color: #5c473d; font: 18px/1.7 "Kaiti SC", "STKaiti", serif; }
.tie-note { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.result-section { padding: 23px 20px; }
.section-mark { margin: 0 0 12px; font-size: 12px; font-weight: 760; letter-spacing: .16em; }
.verdict-card blockquote { margin: 0; color: #4f4037; font: 18px/1.92 "Kaiti SC", "STKaiti", "Songti SC", serif; }
.subtype-copy { margin-top: 19px; padding-top: 17px; border-top: 1px solid var(--line); }
.subtype-copy b { color: var(--type-accent); font-family: "Songti SC", serif; }
.subtype-copy p { margin: 8px 0 0; color: #66564c; font-size: 14px; line-height: 1.86; }
.mirror-card { display: grid; gap: 12px; }
.mirror-card > div { padding: 14px 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(247,239,228,.58); }
.mirror-card span { color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.mirror-card p { margin: 6px 0 0; color: #514138; font: 16px/1.65 "Kaiti SC", serif; }
.dimension-section h2 { margin: -2px 0 17px; font: 700 20px/1.55 "Songti SC", serif; }
.dimension-list { display: grid; gap: 10px; }
.dimension-card { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.72); }
.state-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.state-row span { font-size: 14px; font-weight: 720; }
.state-row strong { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--type-accent); font-size: 12px; }
.meter { height: 7px; margin: 11px 0; border-radius: 99px; background: #eadfd2; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--type-accent)); animation: meter-grow .65s ease-out both; transform-origin: left; }
.dimension-card p { margin: 0; color: #69584d; font-size: 13px; line-height: 1.77; }
.metric-note { margin: 13px 1px 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
@keyframes meter-grow { from { transform: scaleX(0); } }
.easter-envelope { overflow: hidden; }
.easter-envelope summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 66px; padding: 16px 20px; color: var(--red-dark); cursor: pointer; list-style: none; background: linear-gradient(135deg, #f1dfca, #f5e9d7); }
.easter-envelope summary::-webkit-details-marker { display: none; }
.easter-envelope summary span { font: 700 17px "Songti SC", serif; }
.easter-envelope summary b { padding: 6px 9px; border-radius: 99px; color: #fffaf2; background: var(--red); font-size: 11px; }
.easter-envelope > div { position: relative; padding: 25px 21px; text-align: center; }
.easter-envelope i { width: 40px; height: 40px; display: grid; place-items: center; margin: 0 auto 10px; border: 1px solid var(--red); color: var(--red); font: 700 22px "Kaiti SC", serif; font-style: normal; transform: rotate(-4deg); }
.easter-envelope h2 { margin: 0 0 9px; color: var(--red-dark); font: 700 22px "Songti SC", serif; }
.easter-envelope p { margin: 0; color: #665247; font-size: 14px; line-height: 1.82; text-align: left; }
.advice-card ol { display: grid; gap: 15px; margin: 0; padding: 0; list-style: none; counter-reset: advice; }
.advice-card li { display: grid; grid-template-columns: 27px 1fr; gap: 10px; align-items: start; counter-increment: advice; }
.advice-card li span { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--type-accent); }
.advice-card li span::after { content: counter(advice); font-size: 11px; }
.advice-card li p { margin: 0; color: #5f4e44; font-size: 14px; line-height: 1.82; }
.result-actions { display: grid; gap: 10px; padding: 6px 4px; }
.result-actions .primary-button { margin: 0; border-color: var(--type-accent); background: linear-gradient(135deg, color-mix(in srgb, var(--type-accent) 88%, #fff), var(--type-accent)); }
.result-actions .text-button { margin: 0 auto; color: var(--muted); }
.result-disclaimer { margin: 2px 13px 18px; text-align: center; }
.reveal { opacity: 0; transform: translateY(12px); transition: opacity .38s ease, transform .38s ease; }
.reveal.visible { opacity: 1; transform: none; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 80; max-width: calc(100% - 36px); padding: 11px 16px; border-radius: 99px; color: #fff; background: #5c4a40; box-shadow: 0 10px 35px rgba(0,0,0,.19); opacity: 0; transform: translate(-50%, 16px); pointer-events: none; transition: opacity .2s ease, transform .2s ease; font-size: 13px; text-align: center; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red-dark); }

@media (max-width: 390px) {
  .scene { padding-inline: 11px; }
  .gate-card, .intro-card { padding-inline: 19px; }
  .question-card { padding-inline: 15px; }
  .option-button { grid-template-columns: 16px 28px 1fr; gap: 8px; padding-inline: 11px; }
  .option-button b { font-size: 14px; }
  .table-illustration { margin-top: 2px; }
}

@supports not (color: color-mix(in srgb, red 50%, white)) {
  .result-hero { background: linear-gradient(180deg, #f4dfd8, #fffdf8 68%); }
  .subtype-tag { border-color: rgba(168,59,52,.34); }
  .result-actions .primary-button { background: var(--type-accent); }
}

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