/* 听见小宇宙 — 治愈水彩主题样式 */

:root {
  --paper: #f9f6f0;
  --paper-2: #f3ede2;
  --star: #ffd166;
  --calm: #8ecae6;
  --grow: #95d5b2;
  --coral: #ef8354;
  --ink: #2b2d42;
  --ink-soft: #5b5d72;
  --ease: cubic-bezier(0.34, 0.1, 0.2, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-soft: 0 10px 30px rgba(43, 45, 66, 0.12), 0 2px 8px rgba(43, 45, 66, 0.08);
  --radius: 24px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Quicksand', 'Nunito', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(142, 202, 230, 0.18), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(255, 209, 102, 0.16), transparent 50%),
    var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app { min-height: 100vh; min-height: 100dvh; position: relative; }

.title-font {
  font-family: 'ZCOOL XiaoWei', 'Ma Shan Zheng', 'STKaiti', 'KaiTi', serif;
}

button { font-family: inherit; cursor: pointer; }

/* ============ 通用按钮（手绘厚度） ============ */
.uni-btn {
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--star);
  box-shadow:
    0 6px 0 rgba(214, 165, 70, 0.55),
    0 12px 24px rgba(255, 209, 102, 0.4);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s var(--ease);
  letter-spacing: 0.04em;
}
.uni-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 rgba(214, 165, 70, 0.55), 0 18px 32px rgba(255, 209, 102, 0.5);
}
.uni-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 rgba(214, 165, 70, 0.55); }
.uni-btn.ghost {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  box-shadow: 0 4px 0 rgba(43, 45, 66, 0.1), 0 10px 20px rgba(43, 45, 66, 0.08);
  backdrop-filter: blur(6px);
}
.uni-btn.calm {
  background: var(--calm);
  box-shadow: 0 6px 0 rgba(90, 158, 192, 0.55), 0 12px 24px rgba(142, 202, 230, 0.4);
}

/* ============ 屏幕容器与过渡 ============ */
.screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.6s var(--ease-soft) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============ 首页 ============ */
.home {
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 22px calc(40px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.home-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #2a2c4a;
  /* 兜底水彩夜空渐变 */
  background-image:
    radial-gradient(circle at 25% 20%, rgba(255, 209, 102, 0.35), transparent 40%),
    radial-gradient(circle at 78% 30%, rgba(142, 202, 230, 0.3), transparent 45%),
    linear-gradient(180deg, #3a3c66 0%, #5a6a93 45%, #b8c6c2 80%, #f0e6cf 100%);
  transition: opacity 1.2s var(--ease-soft);
}
.home-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(249, 246, 240, 0.4);
}
.home-particles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.spark {
  position: absolute;
  border-radius: 50%;
  background: #fff7d6;
  box-shadow: 0 0 8px 2px rgba(255, 230, 150, 0.8);
  opacity: 0;
  animation: twinkle var(--dur, 4s) var(--ease-soft) infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.6); }
  50% { opacity: 0.9; transform: translateY(-14px) scale(1); }
}

.home-inner { position: relative; z-index: 2; max-width: 640px; width: 100%; }
.home-title {
  font-size: clamp(2.6rem, 11vw, 4.4rem);
  margin: 0;
  line-height: 1.15;
  color: var(--ink);
  text-shadow: 0 0 18px rgba(255, 209, 102, 0.75), 0 2px 4px rgba(255, 255, 255, 0.6);
}
.home-title .ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(18px);
  animation: charIn 0.7s var(--ease) forwards;
}
@keyframes charIn { to { opacity: 1; transform: translateY(0); } }
.home-sub {
  margin: 14px 0 6px;
  font-size: clamp(1rem, 4vw, 1.25rem);
  color: var(--ink-soft);
  font-weight: 600;
  opacity: 0;
  animation: charIn 0.8s 0.9s var(--ease) forwards;
}
.home-tag {
  display: inline-block;
  margin-bottom: 30px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(6px);
  font-size: 0.85rem;
  color: var(--ink-soft);
  opacity: 0;
  animation: charIn 0.8s 1.1s var(--ease) forwards;
}
.home-actions {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  opacity: 0;
  animation: charIn 0.8s 1.3s var(--ease) forwards;
}
.home-actions .row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.home-progress {
  margin-top: 18px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
.home-progress .jar-mini { font-size: 1.1rem; }

/* ============ 顶部 HUD ============ */
.hud {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px calc(12px);
  padding-top: calc(12px + env(safe-area-inset-top));
}
.hud .spacer { flex: 1; }
.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  border: none;
}
.star-jar { position: relative; }
.star-jar .count { color: var(--coral); }
.jar-pop { animation: jarPop 0.5s var(--ease); }
@keyframes jarPop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }

/* ============ 游戏舞台 ============ */
.stage {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 6px 18px calc(26px + env(safe-area-inset-bottom));
  overflow: hidden;
}
.stage-art {
  position: relative;
  flex: 1 1 auto;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 10px;
}
.scene-figure {
  width: min(86%, 460px);
  border-radius: 30px;
  padding: 18px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.66), rgba(243, 237, 226, 0.55));
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  transition: filter 0.8s var(--ease-soft), transform 0.8s var(--ease-soft);
}
.scene-figure.reality { filter: grayscale(0.45) brightness(0.96); }
.scene-figure.universe {
  background: linear-gradient(160deg, rgba(142, 202, 230, 0.32), rgba(255, 209, 102, 0.22));
  box-shadow: 0 0 40px rgba(255, 209, 102, 0.35), var(--shadow-soft);
}
.art-svg { width: 100%; height: auto; display: block; }
.art-float { animation: floatY 6s ease-in-out infinite; }
.art-drift { animation: floatY 8s ease-in-out infinite reverse; }
.art-pulse { animation: pulseGlow 3s ease-in-out infinite; transform-origin: center; }
.art-spin { transform-origin: 160px 120px; animation: slowSpin 14s linear infinite; }
@keyframes floatY { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes pulseGlow { 0%, 100% { opacity: 0.6; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.12); } }
@keyframes slowSpin { to { transform: rotate(360deg); } }

.child-silhouette {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 70px;
  height: 90px;
}

/* ============ 叙事面板 ============ */
.panel {
  position: relative;
  z-index: 5;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 18px 20px;
  margin-top: auto;
  animation: panelUp 0.5s var(--ease) both;
}
@keyframes panelUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.panel .eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--calm);
  font-weight: 700;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.panel h2 { margin: 0 0 10px; font-size: 1.4rem; }
.narr { margin: 0 0 8px; line-height: 1.85; font-size: 1.06rem; color: var(--ink); }
.narr.dim { color: var(--ink-soft); }
.narr.mono { color: #3d6b80; font-style: normal; }
.conflict-line {
  margin: 10px 0;
  padding: 10px 14px;
  border-left: 4px solid var(--coral);
  border-radius: 0 14px 14px 0;
  background: rgba(239, 131, 84, 0.1);
  color: var(--coral);
  font-weight: 700;
}
.insight-line {
  margin: 12px 0 4px;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(149, 213, 178, 0.18);
  color: #3a7a5b;
  line-height: 1.7;
}
.panel-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.panel-actions .uni-btn { flex: 1 1 auto; }

/* ============ 焦虑值仪表 ============ */
.anx-wrap { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.anx-label { font-size: 0.82rem; color: var(--ink-soft); white-space: nowrap; font-weight: 700; }
.anx-bar { flex: 1; height: 12px; border-radius: 999px; background: rgba(43, 45, 66, 0.1); overflow: hidden; }
.anx-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  background: linear-gradient(90deg, var(--grow), var(--star), var(--coral));
  transition: width 0.8s var(--ease-soft);
}

/* 焦虑红晕 + 抖动 */
.anx-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  box-shadow: inset 0 0 0 rgba(239, 131, 84, 0);
  transition: box-shadow 0.8s var(--ease-soft);
}
.anx-vignette.on { box-shadow: inset 0 0 120px 20px rgba(239, 131, 84, var(--glow, 0.28)); }
.shake { animation: shake 0.4s var(--ease-soft); }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-2px, -1px); }
  80% { transform: translate(2px, 1px); }
}

/* ============ 呼吸圈 ============ */
.breath-zone { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 0 4px; }
.breath-hint { font-size: 0.95rem; color: var(--ink-soft); text-align: center; min-height: 1.3em; }
.breath-circle {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: pointer;
}
.breath-circle svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.breath-core {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #cdebf7, var(--calm));
  box-shadow: 0 0 26px rgba(142, 202, 230, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  transition: transform 0.2s linear, background 0.6s var(--ease-soft), box-shadow 0.6s var(--ease-soft);
}
.breath-core.warm { background: radial-gradient(circle at 35% 30%, #fff0c2, var(--star)); box-shadow: 0 0 40px rgba(255, 209, 102, 0.8); color: var(--ink); }
.breath-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(142, 202, 230, 0.5);
  animation: hintPulse 2.6s ease-in-out infinite;
}
@keyframes hintPulse { 0% { transform: scale(0.7); opacity: 0.8; } 100% { transform: scale(1.15); opacity: 0; } }
.ripple {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(255, 209, 102, 0.6);
  pointer-events: none;
  animation: rippleOut 1.4s var(--ease-soft) forwards;
}
@keyframes rippleOut { from { width: 90px; height: 90px; opacity: 0.7; } to { width: 280px; height: 280px; opacity: 0; } }
.breath-count { font-size: 0.95rem; color: var(--calm); font-weight: 700; }

/* ============ 杂念清理 ============ */
.thoughts-layer { position: absolute; inset: 0; z-index: 8; pointer-events: none; }
.thought {
  position: absolute;
  pointer-events: auto;
  padding: 12px 18px;
  border-radius: 18px 22px 16px 24px;
  background: rgba(43, 45, 66, 0.88);
  color: #f3ede2;
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  cursor: grab;
  touch-action: none;
  border: 1.5px dashed rgba(239, 131, 84, 0.7);
  box-shadow: 0 6px 16px rgba(43, 45, 66, 0.35);
  filter: drop-shadow(0 1px 0 rgba(239, 131, 84, 0.4));
  transition: opacity 0.4s, transform 0.4s var(--ease);
  will-change: transform;
}
.thought.grabbing { cursor: grabbing; transform: scale(1.08); z-index: 30; }
.thought.dissolve { animation: dissolve 0.6s var(--ease-soft) forwards; }
@keyframes dissolve {
  to { opacity: 0; transform: scale(1.6) translateY(-24px); filter: blur(8px); }
}
.thoughts-tip { text-align: center; font-size: 0.9rem; color: var(--ink-soft); margin: 4px 0 8px; }

/* ============ 选项卡片 ============ */
.choices { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.choice {
  text-align: left;
  border: 2px solid rgba(142, 202, 230, 0.4);
  background: rgba(255, 255, 255, 0.82);
  border-radius: 18px;
  padding: 14px 18px;
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s, opacity 0.4s;
  box-shadow: 0 4px 14px rgba(43, 45, 66, 0.07);
}
.choice:hover { transform: translateY(-3px); border-color: var(--star); box-shadow: 0 10px 22px rgba(255, 209, 102, 0.25); }
.choice:active { transform: translateY(0); }
.choice.correct { border-color: var(--grow); background: rgba(149, 213, 178, 0.22); box-shadow: 0 0 26px rgba(149, 213, 178, 0.5); }
.choice.wrong { border-color: var(--coral); background: rgba(239, 131, 84, 0.14); }
.choice.faded { opacity: 0.35; }
.choice-fb {
  margin-top: 8px;
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: 14px;
  animation: panelUp 0.4s var(--ease) both;
}
.choice-fb.good { background: rgba(149, 213, 178, 0.2); color: #3a7a5b; }
.choice-fb.bad { background: rgba(239, 131, 84, 0.14); color: var(--coral); }

/* ============ 星光粒子层 ============ */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.fx-star {
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--star);
  box-shadow: 0 0 12px 3px rgba(255, 209, 102, 0.9);
}
.float-plus {
  position: fixed;
  z-index: 61;
  color: var(--coral);
  font-weight: 800;
  font-size: 1.3rem;
  pointer-events: none;
  animation: floatPlus 1.1s var(--ease) forwards;
}
@keyframes floatPlus { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-50px); } }

/* ============ 图鉴 ============ */
.codex { padding: 0 18px calc(40px + env(safe-area-inset-bottom)); }
.codex-head { text-align: center; padding: 18px 10px 8px; }
.codex-head h2 { margin: 6px 0; font-size: 1.8rem; }
.codex-head p { color: var(--ink-soft); margin: 0; }
.codex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  max-width: 880px;
  margin: 18px auto 0;
}
.card-flip { perspective: 1200px; height: 280px; }
.card-inner {
  position: relative;
  width: 100%; height: 100%;
  transition: transform 0.7s var(--ease);
  transform-style: preserve-3d;
  cursor: pointer;
}
.card-flip.flipped .card-inner { transform: rotateY(180deg); }
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.card-front { background: linear-gradient(165deg, #fffaf0, #f3ede2); border-top: 6px solid var(--star); }
.card-front .emoji { font-size: 2.4rem; }
.card-front h3 { margin: 8px 0 4px; font-size: 1.2rem; }
.card-front .tag { font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 10px; }
.card-front .front-text { font-size: 0.95rem; line-height: 1.6; color: var(--ink); flex: 1; }
.card-front .flip-hint { font-size: 0.78rem; color: var(--calm); margin-top: 8px; }
.card-back { background: linear-gradient(165deg, #2b2d42, #3a3d5c); color: #f3ede2; transform: rotateY(180deg); }
.card-back h4 { margin: 0 0 8px; font-size: 1rem; color: var(--star); }
.card-back .detail { font-size: 0.85rem; line-height: 1.6; flex: 1; overflow: auto; }
.card-back .voice { margin-top: 10px; font-size: 0.82rem; font-style: italic; color: var(--calm); border-top: 1px dashed rgba(255, 255, 255, 0.2); padding-top: 8px; }
.card-locked { background: repeating-linear-gradient(45deg, #ece6da, #ece6da 10px, #e3dccd 10px, #e3dccd 20px); color: var(--ink-soft); align-items: center; justify-content: center; text-align: center; }
.card-locked .lock { font-size: 2rem; opacity: 0.6; }

/* ============ 结局 ============ */
.ending { align-items: center; justify-content: center; text-align: center; padding: 40px 24px; }
.ending-sky {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(255, 209, 102, 0.25), transparent 50%),
    linear-gradient(180deg, #2b2d42 0%, #4a4d75 55%, #8a9bb0 100%);
}
.ending-inner { position: relative; z-index: 2; max-width: 560px; }
.ending h2 { font-size: clamp(2rem, 9vw, 3.2rem); color: #fff7e6; text-shadow: 0 0 24px rgba(255, 209, 102, 0.7); margin: 0 0 16px; }
.ending p { color: rgba(255, 255, 255, 0.92); line-height: 1.9; font-size: 1.05rem; }
.ending .jar-big { font-size: 3.6rem; margin: 10px 0; animation: floatY 5s ease-in-out infinite; }
.ending .ending-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 26px; }

/* ============ toast ============ */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  z-index: 80;
  max-width: min(90vw, 420px);
  padding: 14px 20px;
  border-radius: 16px;
  background: rgba(43, 45, 66, 0.94);
  color: #fff7e6;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  text-align: center;
  line-height: 1.5;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.app-toast.err { background: rgba(176, 64, 36, 0.96); }

/* ============ 引导 coachmark ============ */
.coach {
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: rgba(255, 247, 214, 0.85);
  border-radius: 14px;
  padding: 8px 14px;
  margin: 0 auto 10px;
  max-width: 320px;
  animation: panelUp 0.5s var(--ease) both;
}

/* ============ 响应式 ============ */
@media (max-width: 540px) {
  .stage { padding: 4px 14px calc(22px + env(safe-area-inset-bottom)); }
  .panel { padding: 16px; border-radius: 20px; }
  .panel h2 { font-size: 1.25rem; }
  .narr { font-size: 1rem; }
  .breath-circle { width: 150px; height: 150px; }
  .card-flip { height: 300px; }
}

/* ============ 减弱动效 ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.15s !important;
  }
  .spark, .art-float, .art-drift, .art-pulse, .art-spin, .breath-pulse-ring { animation: none !important; }
  .spark { opacity: 0.5; }
}
