/* ────────────────────────────── 基础 ────────────────────────────── */
:root {
  --ink: #f4f1ea;
  --ink-dim: rgba(244, 241, 234, 0.66);
  --ink-faint: rgba(244, 241, 234, 0.36);
  --glass: rgba(14, 16, 26, 0.52);
  --glass-hi: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.13);
  --accent: #a7c0ec;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --serif: "Songti SC", "STSong", "SimSun", Georgia, serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: #06070c;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
p { margin: 0; }

/* ────────────────────────────── 舞台 ────────────────────────────── */
.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #080a12;
}

.scene { position: absolute; inset: 0; z-index: 0; }
.scene__layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 900ms ease;
}
.scene__layer.is-on { opacity: 1; }

.fx { position: absolute; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.fx__dot {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  animation-name: drift;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
  opacity: 0;
}
.fx__dot--mote { background: rgba(255, 240, 200, 0.9); }

.scrim {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(6, 8, 14, 0.58) 0%,
    rgba(6, 8, 14, 0) 16%,
    rgba(6, 8, 14, 0.08) 34%,
    rgba(6, 8, 14, 0.52) 50%,
    rgba(6, 8, 14, 0.80) 63%,
    rgba(6, 8, 14, 0.93) 80%,
    rgba(6, 8, 14, 0.96) 100%
  );
}

/* ────────────────────────────── 进度 ────────────────────────────── */
.hud {
  position: relative;
  z-index: 4;
  padding: calc(var(--safe-t) + 16px) 22px 0;
}
.hud__track {
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}
.hud__bar {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--accent);
  transition: width 600ms cubic-bezier(0.22, 0.8, 0.2, 1);
}
.hud__meta {
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* ────────────────────────────── 面板 ────────────────────────────── */
.panel {
  position: relative;
  z-index: 4;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 22px calc(var(--safe-b) + 20px);
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.panel__inner { margin-top: auto; padding-top: 22px; }

.stage-enter { animation: stageEnter 620ms cubic-bezier(0.22, 0.85, 0.24, 1) both; }

/* 旁白 */
.narr {
  font-size: 15px;
  line-height: 1.95;
  color: var(--ink-dim);
  min-height: 3.6em;
  letter-spacing: 0.01em;
}
.narr__caret {
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 2px;
  vertical-align: -2px;
  background: var(--accent);
  opacity: 0.75;
  animation: caret 1s steps(1) infinite;
}
.narr--done + .narr__tip { opacity: 1; }

/* 回应阶段把旁白收成一行小字，给回应留出空间 */
.narr--compact {
  font-size: 13.5px;
  line-height: 1.7;
  min-height: 0;
  opacity: 0.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 问题 */
.q {
  margin-top: 16px;
  font-size: 21px;
  line-height: 1.55;
  font-weight: 600;
  letter-spacing: 0.01em;
  animation: fadeIn 520ms ease both;
}
.q__time {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--accent);
  opacity: 0.85;
}

/* 选项 */
.options { margin-top: 16px; display: flex; flex-direction: column; gap: 9px; }
.opt {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  text-align: left;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--glass);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
  animation: riseIn 560ms cubic-bezier(0.22, 0.85, 0.24, 1) both;
  animation-delay: calc(var(--i) * 85ms);
}
.opt:active { transform: scale(0.972); background: var(--glass-hi); border-color: rgba(255, 255, 255, 0.24); }
.opt__key {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 11px;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
}
.opt.is-picked { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.32); }

/* 选择后的回应 */
.fb { margin-top: 16px; }
.fb__badge {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  color: var(--accent);
  border: 1px solid rgba(255, 255, 255, 0.24);
  animation: fadeIn 400ms ease both;
}
.fb__line {
  margin-top: 14px;
  font-size: 17px;
  line-height: 1.85;
  color: var(--ink);
  animation: riseIn 560ms cubic-bezier(0.22, 0.85, 0.24, 1) 120ms both;
}
.fb__next {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  animation: fadeIn 600ms ease 700ms both;
}
.fb__next i { display: inline-block; animation: nudge 1.5s ease-in-out infinite; font-style: normal; }

/* ────────────────────────────── 封面 ────────────────────────────── */
.cover { text-align: left; }
.cover__eyebrow {
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--accent);
  opacity: 0.9;
}
.cover__title {
  margin: 16px 0 0;
  font-family: var(--serif);
  font-size: 46px;
  line-height: 1.2;
  letter-spacing: 0.03em;
  font-weight: 700;
}
.cover__sub {
  margin-top: 10px;
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
}
.cover__intro {
  margin-top: 24px;
  font-size: 15px;
  line-height: 2;
  color: var(--ink-dim);
  white-space: pre-line;
}
.cover__hint {
  margin-top: 18px;
  font-size: 11.5px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}

.cta {
  margin-top: 30px;
  width: 100%;
  padding: 18px;
  border-radius: 999px;
  font-size: 16.5px;
  font-weight: 600;
  color: #0a0c14;
  background: linear-gradient(135deg, #ffffff, #dfe4f2);
  animation: glow 3s ease-in-out infinite;
  transition: transform 160ms ease;
}
.cta:active { transform: scale(0.97); }
.cta--ghost {
  margin-top: 12px;
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid var(--line);
  animation: none;
  font-weight: 500;
}

/* ────────────────────────────── 结算中 ────────────────────────────── */
.loading { text-align: center; padding-bottom: 8px; }
.loading__title {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.loading__dots { display: flex; justify-content: center; gap: 7px; margin-top: 20px; }
.loading__dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.3s ease-in-out infinite;
}
.loading__dots i:nth-child(2) { animation-delay: 0.16s; }
.loading__dots i:nth-child(3) { animation-delay: 0.32s; }
.loading__sub { margin-top: 18px; font-size: 12.5px; letter-spacing: 0.14em; color: var(--ink-faint); }

/* ────────────────────────────── 结果页 ────────────────────────────── */
.panel--result {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: block; /* 不能用 flex：内容超高时子元素会被压扁，猫的 SVG 会变成 0 高 */
  overflow-y: auto;
  padding: calc(var(--safe-t) + 34px) 26px calc(var(--safe-b) + 34px);
  background: var(--res-bg);
  color: var(--res-ink);
  animation: revealUp 900ms cubic-bezier(0.22, 0.85, 0.24, 1) both;
}
[data-screen="result"] .scene,
[data-screen="result"] .scrim,
[data-screen="result"] .hud { display: none; }

.res__cat { width: 132px; height: 132px; margin: 0 auto 4px; display: block; opacity: 0.94; }
.res__eyebrow {
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.34em;
  opacity: 0.5;
}
.res__name {
  margin-top: 14px;
  text-align: center;
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0.03em;
  animation: revealUp 700ms cubic-bezier(0.22, 0.85, 0.24, 1) 120ms both;
}
.res__en {
  margin-top: 8px;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: 0.3em;
  opacity: 0.42;
}
.res__tagline {
  margin-top: 22px;
  text-align: center;
  font-size: 19px;
  line-height: 1.7;
  font-weight: 500;
  animation: revealUp 700ms cubic-bezier(0.22, 0.85, 0.24, 1) 220ms both;
}

.rule { height: 1px; margin: 34px 0 26px; background: currentColor; opacity: 0.14; }

.dims { display: flex; flex-direction: column; gap: 18px; }
.dim__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
  letter-spacing: 0.06em;
}
.dim__head span:first-child { opacity: 0.5; }
.dim__head span:last-child { font-weight: 600; letter-spacing: 0.02em; }
.dim__track {
  margin-top: 9px;
  height: 5px;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.dim__bg {
  position: absolute;
  inset: 0;
  background: currentColor;
  opacity: 0.13;
  border-radius: inherit;
}
.dim__fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  border-radius: inherit;
  background: currentColor;
  transition: width 1.1s cubic-bezier(0.22, 0.8, 0.2, 1);
  transition-delay: calc(var(--i) * 120ms);
}
.dim__ends {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  opacity: 0.4;
}

.res__code {
  margin-top: 30px;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.26em;
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

.res__body {
  margin-top: 30px;
  font-size: 16px;
  line-height: 2.05;
  animation: revealUp 700ms ease 300ms both;
}

.chips { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 24px; }
.chip {
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  background: rgba(0, 0, 0, 0.07);
  color: inherit;
  opacity: 0.85;
}

.notes { margin-top: 30px; display: flex; flex-direction: column; gap: 16px; }
.note { display: flex; gap: 12px; font-size: 14.5px; line-height: 1.85; }
.note__label {
  flex: 0 0 auto;
  width: 44px;
  padding-top: 2px;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  opacity: 0.45;
}
.note--advice { padding: 16px 18px; border-radius: 16px; background: currentColor; }
.note--advice > * { color: var(--res-bg-solid); }
.note--advice .note__label { opacity: 0.55; }

.res__actions { margin-top: 34px; display: flex; flex-direction: column; gap: 11px; }
.btn-solid {
  padding: 17px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  background: var(--res-ink);
  color: var(--res-bg-solid);
}
.btn-ghost {
  padding: 15px;
  border-radius: 999px;
  font-size: 14.5px;
  border: 1px solid currentColor;
  opacity: 0.6;
  color: var(--res-ink);
}
.btn-solid:active, .btn-ghost:active { transform: scale(0.975); }
.res__foot {
  margin-top: 26px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.16em;
  opacity: 0.35;
}

/* ────────────────────────────── 分享卡 ────────────────────────────── */
.poster {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: calc(var(--safe-t) + 24px) 22px calc(var(--safe-b) + 24px);
  background: rgba(5, 6, 11, 0.94);
  animation: fadeIn 320ms ease both;
}
.poster img {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
  animation: revealUp 520ms cubic-bezier(0.22, 0.85, 0.24, 1) both;
}
.poster__tip { font-size: 12.5px; letter-spacing: 0.14em; color: rgba(244, 241, 234, 0.6); }
.poster__close {
  padding: 13px 30px;
  border-radius: 999px;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(244, 241, 234, 0.8);
}

/* ────────────────────────────── 猫与场景动效 ────────────────────────────── */
.cat-layer { transition: transform 620ms cubic-bezier(0.22, 0.8, 0.2, 1); }
.cat-layer.react-in { transform: translateY(-7px) scale(1.07); }
.cat-layer.react-away { transform: translateY(5px) scale(0.93); }
.cat-layer.react-alert { transform: translateY(-11px) scale(1.05); }
.cat-layer.react-still { transform: scale(1.025); }

.cat-breathe {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: breathe 4.4s ease-in-out infinite;
}
.cat-eyes { animation: blink 6.4s infinite; }
.star { animation: twinkle 3.6s ease-in-out infinite; }
.mote { animation: mote 7.5s ease-in-out infinite; }
.screen { animation: flicker 5.5s ease-in-out infinite; }
.steam path { animation: steam 4.4s ease-in-out infinite; }

/* ────────────────────────────── 关键帧 ────────────────────────────── */
@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes revealUp {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: none; }
}
@keyframes stageEnter {
  from { opacity: 0; transform: translateY(26px); }
  to { opacity: 1; transform: none; }
}
@keyframes caret { 0%, 50% { opacity: 0.75; } 51%, 100% { opacity: 0; } }
@keyframes nudge { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: 0.4; } 50% { transform: translateY(-7px); opacity: 1; } }
@keyframes glow {
  0%, 100% { box-shadow: 0 12px 34px rgba(0, 0, 0, 0.42); }
  50% { box-shadow: 0 12px 48px rgba(255, 255, 255, 0.3); }
}
@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(1.012, 1.022); }
}
@keyframes blink {
  0%, 93%, 100% { transform: scaleY(1); }
  95.5% { transform: scaleY(0.08); }
}
@keyframes twinkle { 0%, 100% { opacity: 0.22; } 50% { opacity: 1; } }
@keyframes flicker { 0%, 100% { opacity: 0.88; } 47% { opacity: 0.79; } 53% { opacity: 0.93; } }
@keyframes steam {
  0% { opacity: 0; transform: translateY(8px); }
  40% { opacity: 0.5; }
  100% { opacity: 0; transform: translateY(-26px); }
}
@keyframes mote {
  0% { opacity: 0; transform: translate3d(0, 12px, 0); }
  45% { opacity: 0.75; }
  100% { opacity: 0; transform: translate3d(16px, -46px, 0); }
}
@keyframes drift {
  0% { opacity: 0; transform: translate3d(0, 0, 0); }
  18% { opacity: 0.5; }
  82% { opacity: 0.28; }
  100% { opacity: 0; transform: translate3d(20px, -70px, 0); }
}

/* ────────────────────────────── 桌面预览 ────────────────────────────── */
@media (min-width: 560px) {
  body { display: grid; place-items: center; background: #06070c; }
  .app {
    position: relative;
    width: 420px;
    height: min(880px, 100dvh);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    box-shadow: 0 40px 90px rgba(0, 0, 0, 0.72);
  }
}

/* ────────────────────────────── 无障碍 ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
