/* ============================================================
   蛤蟆先生的心灵奇旅 — 手绘水彩风格主题
   配色：暖白底 + 治愈绿(蛤蟆) + 灰蓝(苍鹭/成人) + 暖阳黄(顿悟) + 灰红(困扰)
   ============================================================ */

:root {
  --cream: #FDFBF7;
  --cream-2: #F6F0E6;
  --cream-3: #EFE6D6;
  --paper-line: rgba(141, 153, 174, 0.18);
  --green: #8AB17D;
  --green-deep: #6E9466;
  --green-soft: rgba(138, 177, 125, 0.16);
  --blue: #8D99AE;
  --blue-deep: #6B7689;
  --blue-soft: rgba(141, 153, 174, 0.16);
  --yellow: #E9C46A;
  --yellow-deep: #D9A93F;
  --red: #D98A8A;
  --red-deep: #C56A6A;
  --ink: #3D405B;
  --ink-soft: #5B5E78;
  --ink-faint: rgba(61, 64, 91, 0.55);
  --shadow-soft: 0 14px 34px rgba(61, 64, 91, 0.12);
  --shadow-card: 0 10px 26px rgba(61, 64, 91, 0.14);
  --radius-lg: 26px;
  --radius-md: 18px;
  --font-hand: "Ma Shan Zheng", "Xingkai SC", "STKaiti", "KaiTi", "楷体", serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

.app-body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(1200px 600px at 12% -10%, rgba(138, 177, 125, 0.10), transparent 60%),
    radial-gradient(1000px 560px at 110% 6%, rgba(233, 196, 106, 0.12), transparent 55%),
    radial-gradient(900px 520px at 50% 120%, rgba(141, 153, 174, 0.10), transparent 60%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

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

/* paper grain texture overlay */
.app-body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.045'/%3E%3C/svg%3E");
}

/* ---------- generic helpers ---------- */
.screen { position: relative; z-index: 1; min-height: 100vh; }
.center-col {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 40px);
}
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ============================================================
   首页 / 标题页
   ============================================================ */
#hero-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  padding: 24px;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: var(--cream-3);
  background-size: cover;
  background-position: center;
  transition: opacity 1.2s ease;
  opacity: 0;
}
.hero-bg.loaded { opacity: 1; }

/* watercolor fallback wash behind the generated image */
.hero-wash {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(60% 50% at 30% 25%, rgba(138,177,125,0.55), transparent 70%),
    radial-gradient(55% 45% at 78% 30%, rgba(233,196,106,0.45), transparent 70%),
    radial-gradient(70% 60% at 50% 100%, rgba(141,153,174,0.55), transparent 70%),
    linear-gradient(180deg, #eaf0e2 0%, #f3ead7 55%, #dfe4ea 100%);
}

.hero-veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(253,251,247,0.30) 0%, rgba(253,251,247,0.10) 38%, rgba(61,64,91,0.34) 100%);
  backdrop-filter: blur(0.5px);
}

.hero-inner {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: min(680px, 92vw);
}

.hero-emblem { width: clamp(96px, 22vw, 150px); height: auto; filter: drop-shadow(0 8px 16px rgba(61,64,91,0.22)); animation: floaty 6s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0) rotate(-1deg);} 50% { transform: translateY(-10px) rotate(1deg);} }

.hero-title {
  font-family: var(--font-hand);
  font-size: clamp(2.6rem, 9vw, 5rem);
  line-height: 1.05;
  margin: 0;
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(110,148,102,0.55),
    0 6px 18px rgba(61,64,91,0.45),
    0 0 30px rgba(233,196,106,0.35);
  animation: titleIn 1s cubic-bezier(.2,.9,.25,1) both;
}
@keyframes titleIn { from { opacity: 0; transform: translateY(22px) scale(0.96);} to { opacity: 1; transform: none; } }

.hero-title .accent {
  background: linear-gradient(180deg, #fbe9b0 0%, var(--yellow) 60%, var(--yellow-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
}

.hero-tagline {
  font-size: clamp(0.95rem, 2.6vw, 1.18rem);
  color: #fdf6e8;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 10px rgba(61,64,91,0.5);
  margin: 0;
  opacity: 0;
  animation: fadeUp 1s ease 0.5s forwards;
}
.hero-sub {
  font-size: clamp(0.78rem, 2.2vw, 0.95rem);
  color: rgba(253,246,232,0.86);
  max-width: 30ch;
  line-height: 1.7;
  margin: 4px auto 0;
  text-shadow: 0 1px 8px rgba(61,64,91,0.55);
  opacity: 0;
  animation: fadeUp 1s ease 0.8s forwards;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px);} to { opacity: 1; transform: none;} }

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 86vw);
  margin-top: 10px;
  opacity: 0;
  animation: fadeUp 0.9s ease 1.05s forwards;
}

.hero-foot {
  position: absolute;
  bottom: 14px;
  z-index: 3;
  display: flex;
  gap: 14px;
  font-size: 0.74rem;
  color: rgba(253,246,232,0.8);
  text-shadow: 0 1px 6px rgba(61,64,91,0.5);
}
.hero-foot button {
  background: none; border: none; color: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px; font-size: inherit;
  padding: 4px;
}
.hero-foot button:hover { color: #fff; }

/* ---------- themed buttons ---------- */
.btn-leaf {
  position: relative;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  color: #fff;
  padding: 15px 26px;
  border-radius: 40px 40px 38px 40px;
  background: linear-gradient(165deg, #9ec08f 0%, var(--green) 55%, var(--green-deep) 100%);
  box-shadow: 0 10px 22px rgba(110,148,102,0.4), inset 0 1px 0 rgba(255,255,255,0.45);
  transition: transform 0.18s cubic-bezier(.2,.9,.3,1.4), box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-leaf:hover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(110,148,102,0.5), inset 0 1px 0 rgba(255,255,255,0.5); filter: brightness(1.04); }
.btn-leaf:active { transform: translateY(0) scale(0.97); }

.btn-ink {
  border: none; cursor: pointer; font-weight: 700; letter-spacing: 0.06em;
  color: #fff; padding: 14px 24px; border-radius: 38px;
  font-size: 1rem; font-family: var(--font-body);
  background: linear-gradient(165deg, #a4afc1 0%, var(--blue) 55%, var(--blue-deep) 100%);
  box-shadow: 0 9px 20px rgba(107,118,137,0.38), inset 0 1px 0 rgba(255,255,255,0.4);
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-ink:hover { transform: translateY(-3px); filter: brightness(1.05); }
.btn-ink:active { transform: translateY(0) scale(0.97); }

.btn-ghost-ink {
  border: 1.5px solid rgba(253,246,232,0.7);
  background: rgba(61,64,91,0.18);
  color: #fff; cursor: pointer; font-weight: 600; letter-spacing: 0.06em;
  padding: 12px 22px; border-radius: 36px; font-size: 0.95rem;
  font-family: var(--font-body);
  backdrop-filter: blur(4px);
  transition: transform 0.18s ease, background 0.2s ease;
}
.btn-ghost-ink:hover { transform: translateY(-2px); background: rgba(61,64,91,0.32); }
.btn-ghost-ink:active { transform: scale(0.97); }

.btn-leaf:disabled, .btn-ink:disabled { opacity: 0.55; cursor: not-allowed; transform: none; filter: grayscale(0.3); }

/* ============================================================
   首页粒子：萤火虫 + 花瓣（童话/森林氛围）
   ============================================================ */
.particle-field { position: absolute; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.firefly {
  position: absolute;
  width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #fff6cf 0%, var(--yellow) 45%, rgba(233,196,106,0) 72%);
  filter: drop-shadow(0 0 6px rgba(233,196,106,0.85));
  animation: fireflyGlow 3.2s ease-in-out infinite;
}
@keyframes fireflyGlow {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  50% { opacity: 1; transform: scale(1.15); }
}
.petal {
  position: absolute;
  top: -8%;
  width: 14px; height: 14px;
  background: radial-gradient(circle at 30% 30%, #fff, var(--green) 80%);
  border-radius: 80% 0 80% 0;
  opacity: 0.85;
  animation: petalFall linear infinite;
}
@keyframes petalFall {
  0% { transform: translateY(-10vh) translateX(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.9; }
  100% { transform: translateY(112vh) translateX(40px) rotate(360deg); opacity: 0.2; }
}

/* ============================================================
   游戏内：咨询室界面
   ============================================================ */
#game-screen { display: flex; flex-direction: column; min-height: 100vh; }

.game-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px clamp(12px, 3vw, 26px);
  background: linear-gradient(180deg, rgba(253,251,247,0.96), rgba(246,240,230,0.9));
  border-bottom: 1px solid var(--paper-line);
  box-shadow: 0 6px 18px rgba(61,64,91,0.06);
  backdrop-filter: blur(6px);
}
.topbar-title {
  font-family: var(--font-hand);
  font-size: clamp(1.05rem, 3.4vw, 1.4rem);
  color: var(--green-deep);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.topbar-chapter {
  font-size: 0.74rem; color: var(--ink-soft); font-weight: 600;
  background: var(--green-soft); padding: 3px 10px; border-radius: 20px;
  white-space: nowrap;
}
.topbar-spacer { flex: 1; }
.icon-btn {
  border: none; cursor: pointer; width: 38px; height: 38px;
  border-radius: 50%; background: var(--cream-2);
  display: grid; place-items: center; color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--paper-line);
  transition: transform 0.16s ease, background 0.2s ease, color 0.2s ease;
}
.icon-btn:hover { transform: translateY(-2px); background: var(--green-soft); color: var(--green-deep); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn svg { width: 20px; height: 20px; }

/* meters HUD */
.hud {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 10px clamp(12px, 3vw, 26px) 0;
}
.meter {
  flex: 1 1 130px; min-width: 120px;
  background: #fff; border-radius: 16px; padding: 9px 12px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--paper-line);
}
.meter-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; }
.meter-head .val { font-variant-numeric: tabular-nums; }
.meter-bar { height: 9px; border-radius: 8px; background: var(--cream-3); overflow: hidden; box-shadow: inset 0 1px 2px rgba(61,64,91,0.1); }
.meter-fill { height: 100%; width: 0%; border-radius: 8px; transition: width 0.7s cubic-bezier(.2,.9,.25,1); }
.meter-fill.resilience { background: linear-gradient(90deg, #b6d3a8, var(--green)); }
.meter-fill.adult { background: linear-gradient(90deg, #aeb8c8, var(--blue)); }
.meter-fill.growth { background: linear-gradient(90deg, #f4dd9e, var(--yellow)); }
.meter.flash-hurt { animation: meterHurt 0.5s ease; }
@keyframes meterHurt { 0%,100%{transform:none;} 25%{transform:translateX(-5px);} 75%{transform:translateX(5px);} }

/* stage / characters */
.stage {
  position: relative;
  flex: 1;
  display: flex; flex-direction: column;
  padding: 14px clamp(12px, 3vw, 26px) 20px;
  max-width: 920px; width: 100%; margin: 0 auto;
}

.scene-art {
  position: relative;
  display: flex; align-items: flex-end; justify-content: center; gap: clamp(20px, 8vw, 70px);
  min-height: clamp(160px, 30vh, 240px);
  margin-bottom: 6px;
}
.char {
  position: relative;
  width: clamp(90px, 24vw, 150px);
  transition: transform 0.4s cubic-bezier(.2,.9,.25,1), filter 0.4s ease, opacity 0.4s ease;
  filter: drop-shadow(0 10px 14px rgba(61,64,91,0.18));
}
.char svg { width: 100%; height: auto; display: block; }
.char.dim { opacity: 0.55; filter: grayscale(0.3) drop-shadow(0 8px 10px rgba(61,64,91,0.12)); transform: scale(0.94); }
.char.speaking { transform: translateY(-6px) scale(1.04); }
.char.nodding { animation: nod 1.1s ease; }
@keyframes nod { 0%,100%{transform:translateY(-6px) rotate(0);} 30%{transform:translateY(2px) rotate(2deg);} 60%{transform:translateY(-4px) rotate(-1deg);} }
.char.shake { animation: charShake 0.5s ease; }
@keyframes charShake { 0%,100%{transform:translateX(0);} 20%{transform:translateX(-7px) rotate(-3deg);} 40%{transform:translateX(7px) rotate(3deg);} 60%{transform:translateX(-5px) rotate(-2deg);} 80%{transform:translateX(5px) rotate(1deg);} }
.char-label {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  font-size: 0.7rem; font-weight: 700; color: var(--ink-soft);
  background: rgba(255,255,255,0.85); padding: 2px 10px; border-radius: 12px;
  white-space: nowrap; box-shadow: var(--shadow-card);
}

/* dialogue panel — like an open notebook page */
.dialogue {
  position: relative;
  background:
    linear-gradient(180deg, #fffdf8, #fbf6ec);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 4vw, 26px);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--paper-line);
  animation: panelIn 0.5s cubic-bezier(.2,.9,.25,1) both;
}
.dialogue::before {
  content: ""; position: absolute; left: 22px; top: 14px; bottom: 14px; width: 2px;
  background: repeating-linear-gradient(180deg, var(--red) 0 6px, transparent 6px 12px);
  opacity: 0.25; border-radius: 2px;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.speaker-name {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-hand);
  font-size: 1.15rem; letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.speaker-name.heron { color: var(--blue-deep); }
.speaker-name.toad { color: var(--green-deep); }
.speaker-name.narrator { color: var(--ink-soft); font-style: italic; }
.speaker-dot { width: 10px; height: 10px; border-radius: 50%; }
.speaker-name.heron .speaker-dot { background: var(--blue); }
.speaker-name.toad .speaker-dot { background: var(--green); }
.speaker-name.narrator .speaker-dot { background: var(--ink-soft); }

.dialogue-text {
  font-size: clamp(1rem, 2.8vw, 1.12rem);
  line-height: 1.95;
  color: var(--ink);
  padding-left: 18px;
  min-height: 2em;
}
.dialogue-text .typing-caret {
  display: inline-block; width: 2px; height: 1.05em; vertical-align: -0.15em;
  background: var(--green); margin-left: 2px; animation: caret 0.7s step-end infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.dialogue-text em { color: var(--green-deep); font-style: normal; font-weight: 700; }
.dialogue-text .quote { color: var(--blue-deep); }

/* choices */
.choices { display: flex; flex-direction: column; gap: 11px; margin-top: 18px; }
.choice {
  position: relative;
  text-align: left; cursor: pointer;
  background: #fff;
  border: 1.5px solid var(--paper-line);
  border-radius: 16px;
  padding: 13px 16px 13px 46px;
  font-size: 0.98rem; line-height: 1.6; color: var(--ink);
  font-family: var(--font-body);
  box-shadow: 0 4px 12px rgba(61,64,91,0.07);
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.choice:hover { transform: translateY(-2px); border-color: var(--green); background: #fcfff8; box-shadow: 0 10px 22px rgba(110,148,102,0.2); }
.choice:active { transform: translateY(0) scale(0.99); }
.choice .num {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--green-soft); color: var(--green-deep);
  font-size: 0.78rem; font-weight: 800; display: grid; place-items: center;
}
.choice.correct { border-color: var(--green); background: linear-gradient(180deg, #f1f8ec, #e8f3e0); animation: choicePulse 0.6s ease; }
.choice.wrong { border-color: var(--red); background: linear-gradient(180deg, #fbeeee, #f6e3e3); animation: choiceWrong 0.5s ease; }
.choice.correct .num { background: var(--green); color: #fff; }
.choice.wrong .num { background: var(--red); color: #fff; }
.choice:disabled { cursor: default; }
.choice.muted { opacity: 0.5; }
@keyframes choicePulse { 0%{transform:scale(1);} 40%{transform:scale(1.03);} 100%{transform:scale(1);} }
@keyframes choiceWrong { 0%,100%{transform:translateX(0);} 25%{transform:translateX(-6px);} 75%{transform:translateX(6px);} }

.choice-tag {
  display: inline-block; font-size: 0.66rem; font-weight: 700;
  padding: 2px 8px; border-radius: 10px; margin-left: 8px; vertical-align: middle;
}
.tag-child { background: rgba(217,138,138,0.18); color: var(--red-deep); }
.tag-parent { background: rgba(141,153,174,0.2); color: var(--blue-deep); }
.tag-adult { background: rgba(138,177,125,0.2); color: var(--green-deep); }

/* feedback bubble after choice */
.feedback {
  margin-top: 14px;
  border-radius: 16px;
  padding: 14px 16px 14px 18px;
  font-size: 0.95rem; line-height: 1.8;
  animation: panelIn 0.4s ease both;
  border-left: 5px solid var(--green);
  background: linear-gradient(180deg, #f3f8ee, #ecf4e4);
  color: var(--ink);
}
.feedback.bad { border-left-color: var(--red); background: linear-gradient(180deg, #fbefef, #f6e4e4); }
.feedback.insight { border-left-color: var(--yellow); background: linear-gradient(180deg, #fcf4dd, #f8ecc6); }
.feedback .fb-title { font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }

.advance-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* hint for keyboard */
.kbd-hint { font-size: 0.72rem; color: var(--ink-faint); text-align: center; margin-top: 10px; }
.app-kbd { display:inline-block; padding: 1px 6px; border-radius: 6px; background: var(--cream-3); border: 1px solid var(--paper-line); font-size: 0.7rem; font-weight: 700; color: var(--ink-soft); }

/* ============================================================
   情绪温度计（拖拽 / 滑动）
   ============================================================ */
.thermo-wrap { display: flex; gap: clamp(18px, 5vw, 40px); align-items: stretch; margin-top: 18px; flex-wrap: wrap; }
.thermo {
  position: relative;
  flex: 0 0 auto;
  width: 92px; min-height: 320px;
  display: flex; flex-direction: column; align-items: center;
  user-select: none; touch-action: none;
}
.thermo-track {
  position: relative;
  width: 34px; flex: 1;
  border-radius: 22px;
  background: linear-gradient(180deg, #cfe0c5 0%, #f3ead3 50%, #ecc7c7 100%);
  box-shadow: inset 0 2px 6px rgba(61,64,91,0.18), 0 6px 16px rgba(61,64,91,0.1);
  border: 2px solid #fff;
}
.thermo-fill {
  position: absolute; left: 4px; right: 4px; bottom: 4px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--red) 0%, var(--yellow) 55%, var(--green) 100%);
  background-size: 100% 320px; background-position: bottom;
  transition: height 0.18s ease;
  box-shadow: 0 0 12px rgba(217,138,138,0.4);
}
.thermo-bulb {
  width: 60px; height: 60px; border-radius: 50%; margin-top: -12px;
  background: radial-gradient(circle at 38% 35%, #f0a8a8, var(--red) 70%);
  border: 3px solid #fff; box-shadow: 0 8px 18px rgba(197,106,106,0.4);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1.3rem;
}
.thermo-knob {
  position: absolute; left: 50%; transform: translate(-50%, 50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #fff, #f3ead3 75%);
  border: 3px solid var(--yellow); box-shadow: var(--shadow-card);
  cursor: grab; display: grid; place-items: center; z-index: 3;
  font-weight: 800; color: var(--ink); font-size: 1.05rem;
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}
.thermo-knob:active { cursor: grabbing; }
.thermo.dragging .thermo-knob { box-shadow: 0 0 0 8px rgba(233,196,106,0.25), var(--shadow-card); }
.thermo-scale { position: absolute; right: -34px; top: 0; bottom: 0; display: flex; flex-direction: column-reverse; justify-content: space-between; font-size: 0.66rem; color: var(--ink-faint); font-weight: 700; padding: 6px 0; }
.thermo-side { flex: 1; min-width: 200px; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.thermo-readout {
  font-size: 0.95rem; line-height: 1.8; color: var(--ink);
  background: #fff; border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--shadow-card); border: 1px solid var(--paper-line);
  min-height: 80px; transition: background 0.4s ease;
}
.thermo-readout .big { font-family: var(--font-hand); font-size: 1.5rem; color: var(--green-deep); }

/* ============================================================
   咨询作业拖拽
   ============================================================ */
.homework-area { margin-top: 16px; display: grid; gap: 16px; }
.hw-pool { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 60px; padding: 8px; }
.hw-card {
  cursor: grab; touch-action: none; user-select: none;
  background: linear-gradient(180deg, #fffdf6, #fbf3e2);
  border: 1.5px dashed var(--yellow-deep);
  border-radius: 14px; padding: 12px 16px; font-size: 0.92rem; font-weight: 600; color: var(--ink);
  box-shadow: var(--shadow-card); max-width: 240px;
  transition: transform 0.16s ease, box-shadow 0.2s ease, opacity 0.3s ease;
}
.hw-card:hover { transform: translateY(-3px) rotate(-1deg); }
.hw-card.dragging { opacity: 0.4; }
.hw-card.placed { display: none; }
.hw-board {
  border: 2px dashed var(--blue);
  border-radius: var(--radius-md);
  background: var(--blue-soft);
  padding: 16px; min-height: 130px;
  display: flex; flex-wrap: wrap; gap: 10px; align-content: flex-start;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.2s ease;
}
.hw-board.over { background: rgba(138,177,125,0.22); border-color: var(--green); transform: scale(1.01); }
.hw-board-title { width: 100%; font-weight: 800; color: var(--blue-deep); font-size: 0.86rem; margin-bottom: 4px; }
.hw-placed {
  background: #fff; border: 1.5px solid var(--green); border-radius: 12px;
  padding: 9px 13px; font-size: 0.88rem; color: var(--green-deep); font-weight: 600;
  box-shadow: var(--shadow-card); animation: pop 0.4s cubic-bezier(.2,1.4,.4,1) both;
}
@keyframes pop { 0%{transform:scale(0.5);opacity:0;} 60%{transform:scale(1.12);} 100%{transform:scale(1);opacity:1;} }

/* ============================================================
   概念卡片图鉴（翻阅）
   ============================================================ */
.codex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.concept-card {
  position: relative;
  background: linear-gradient(180deg, #fffdf8, #f6efe1);
  border-radius: 16px; padding: 16px 14px;
  box-shadow: var(--shadow-card); border: 1px solid var(--paper-line);
  cursor: pointer; transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}
.concept-card::after { content: ""; position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: var(--green-soft); }
.concept-card:hover { transform: translateY(-4px) rotate(-0.5deg); box-shadow: var(--shadow-soft); }
.concept-card.locked { filter: grayscale(0.85); opacity: 0.55; cursor: default; }
.concept-card.locked:hover { transform: none; }
.cc-icon { font-size: 1.6rem; position: relative; z-index: 1; }
.cc-title { font-family: var(--font-hand); font-size: 1.1rem; color: var(--ink); margin-top: 6px; position: relative; z-index: 1; }
.cc-skill { font-size: 0.66rem; color: var(--ink-faint); margin-top: 3px; position: relative; z-index: 1; }
.cc-new { position: absolute; top: 8px; right: 8px; z-index: 2; background: var(--yellow); color: var(--ink); font-size: 0.6rem; font-weight: 800; padding: 2px 7px; border-radius: 10px; }

/* unlock toast for new card */
.card-pop {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  z-index: 1200; background: linear-gradient(180deg, #fffdf6, #f6ecd2);
  border: 1px solid var(--yellow-deep); border-radius: 18px;
  padding: 12px 18px; box-shadow: var(--shadow-soft);
  display: flex; align-items: center; gap: 12px; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease;
}
.card-pop.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.card-pop .cp-icon { font-size: 1.7rem; }
.card-pop .cp-sub { font-size: 0.72rem; color: var(--ink-soft); }
.card-pop .cp-title { font-weight: 800; color: var(--green-deep); }

/* ============================================================
   通用 modal / overlay
   ============================================================ */
.app-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(61,64,91,0.45);
  backdrop-filter: blur(4px);
}
.app-overlay.show { display: flex; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.app-modal {
  background: linear-gradient(180deg, #fffdf8, #f6efe2);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(61,64,91,0.35);
  border: 1px solid var(--paper-line);
  width: min(640px, 94vw); max-height: 86vh; overflow: auto;
  padding: clamp(18px, 4vw, 28px);
  animation: modalIn 0.35s cubic-bezier(.2,.9,.25,1) both;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
.app-modal h2 { font-family: var(--font-hand); color: var(--green-deep); font-size: 1.6rem; margin: 0 0 6px; letter-spacing: 0.04em; }
.app-modal .modal-close {
  float: right; border: none; background: var(--cream-3); cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%; color: var(--ink-soft); font-size: 1.1rem;
  transition: background 0.2s ease, transform 0.15s ease;
}
.app-modal .modal-close:hover { background: var(--red); color: #fff; transform: rotate(90deg); }
.modal-body { font-size: 0.95rem; line-height: 1.85; color: var(--ink); }
.modal-body h3 { color: var(--blue-deep); font-size: 1rem; margin: 14px 0 4px; }
.modal-body ul { padding-left: 20px; }
.modal-body .quote-block { border-left: 4px solid var(--yellow); background: rgba(233,196,106,0.12); padding: 10px 14px; border-radius: 10px; margin: 10px 0; font-style: italic; color: var(--ink-soft); }

/* concept detail flip-ish entrance */
.concept-detail .cc-big-icon { font-size: 2.6rem; }

/* ============================================================
   过场转场 / 关卡切换
   ============================================================ */
.transition-veil {
  position: fixed; inset: 0; z-index: 1500;
  display: none; align-items: center; justify-content: center; flex-direction: column;
  gap: 16px; text-align: center;
  background: linear-gradient(180deg, #6E9466 0%, #3D405B 100%);
  color: #fff; padding: 24px;
}
.transition-veil.show { display: flex; animation: fadeIn 0.5s ease; }
.transition-veil .tv-chapter { font-family: var(--font-hand); font-size: clamp(1.8rem,7vw,3rem); letter-spacing: 0.08em; text-shadow: 0 4px 16px rgba(0,0,0,0.3); animation: titleIn 0.9s ease both; }
.transition-veil .tv-sub { font-size: 1rem; opacity: 0.9; max-width: 32ch; line-height: 1.8; animation: fadeUp 1s ease 0.4s both; }
.transition-veil .tv-num { font-size: 0.8rem; letter-spacing: 0.3em; opacity: 0.7; }

/* ============================================================
   全屏视觉特效层
   ============================================================ */
#fx-layer { position: fixed; inset: 0; z-index: 1400; pointer-events: none; overflow: hidden; }
.red-flash {
  position: fixed; inset: 0; z-index: 1390; pointer-events: none;
  background: radial-gradient(circle, rgba(217,138,138,0) 40%, rgba(217,138,138,0.55) 100%);
  opacity: 0;
}
.red-flash.go { animation: redFlash 0.55s ease; }
@keyframes redFlash { 0%{opacity:0;} 25%{opacity:1;} 100%{opacity:0;} }

.float-text {
  position: fixed; z-index: 1410; pointer-events: none;
  font-family: var(--font-hand); font-weight: 800; font-size: 1.4rem;
  text-shadow: 0 2px 8px rgba(61,64,91,0.25);
  animation: floatUp 1.1s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes floatUp { 0%{opacity:0; transform: translateY(0) scale(0.8);} 20%{opacity:1; transform: translateY(-10px) scale(1.1);} 100%{opacity:0; transform: translateY(-70px) scale(1);} }

.confetti { position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px; opacity: 0.95; }
@keyframes confettiFall { 0%{transform: translateY(-10vh) rotate(0); opacity: 1;} 100%{transform: translateY(110vh) rotate(720deg); opacity: 0.3;} }

.screen-grayed { filter: grayscale(0.92) brightness(0.92); transition: filter 0.8s ease; }

/* ============================================================
   结局 / Game Over
   ============================================================ */
#ending-screen { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.ending-card {
  position: relative;
  background: linear-gradient(180deg, #fffdf8, #f5edda);
  border-radius: 30px; padding: clamp(22px, 5vw, 40px);
  box-shadow: var(--shadow-soft); border: 1px solid var(--paper-line);
  width: min(640px, 94vw); text-align: center;
  animation: modalIn 0.6s ease both;
}
.ending-emblem { width: 120px; margin: 0 auto 8px; animation: floaty 5s ease-in-out infinite; }
.ending-title { font-family: var(--font-hand); font-size: clamp(2rem, 7vw, 3rem); color: var(--green-deep); letter-spacing: 0.05em; margin: 6px 0; }
.ending-pos { font-family: var(--font-hand); font-size: 1.5rem; color: var(--yellow-deep); margin: 4px 0 12px; }
.ending-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.estat { background: #fff; border-radius: 16px; padding: 12px 18px; box-shadow: var(--shadow-card); min-width: 96px; }
.estat .v { font-family: var(--font-hand); font-size: 1.7rem; color: var(--green-deep); }
.estat .l { font-size: 0.72rem; color: var(--ink-soft); font-weight: 600; }
.ending-quote { font-style: italic; color: var(--ink-soft); line-height: 1.9; margin: 16px 0; padding: 0 6px; }
.ending-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }

.gameover-card { background: linear-gradient(180deg, #f4eef0, #e7dde0); }
.gameover-card .ending-title { color: var(--red-deep); }

/* leaderboard */
.lb-list { list-style: none; padding: 0; margin: 12px 0 0; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px; background: #fff; margin-bottom: 7px; box-shadow: var(--shadow-card); }
.lb-row.me { background: var(--green-soft); border: 1px solid var(--green); }
.lb-rank { font-family: var(--font-hand); font-size: 1.2rem; width: 30px; color: var(--green-deep); text-align: center; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 800; color: var(--yellow-deep); }
.name-input {
  width: 100%; padding: 11px 14px; border-radius: 14px; font-size: 0.95rem;
  border: 1.5px solid var(--paper-line); background: #fff; color: var(--ink);
  font-family: var(--font-body); margin-top: 6px;
}
.name-input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* error toast */
.app-toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%) translateY(-24px);
  z-index: 2000; max-width: min(440px, 92vw);
  background: linear-gradient(180deg, #fbeeee, #f5e0e0);
  border: 1px solid var(--red); border-left: 5px solid var(--red-deep);
  border-radius: 14px; padding: 12px 16px; color: var(--ink);
  box-shadow: var(--shadow-soft); font-size: 0.9rem; line-height: 1.6;
  opacity: 0; pointer-events: none; transition: opacity 0.3s ease, transform 0.3s ease;
}
.app-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.app-toast.ok { background: linear-gradient(180deg, #f1f8ec, #e6f2dd); border-color: var(--green); border-left-color: var(--green-deep); }

/* loading hint on hero */
.hero-loading { font-size: 0.72rem; color: rgba(253,246,232,0.8); display: flex; align-items: center; gap: 8px; }
.hero-loading .spin { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 560px) {
  .hud { gap: 8px; }
  .meter { flex: 1 1 100%; }
  .scene-art { gap: 16px; min-height: 140px; }
  .thermo-side { min-width: 100%; }
  .topbar-title { font-size: 1.05rem; }
  .hero-foot { flex-wrap: wrap; justify-content: center; }
}

/* ============================================================
   prefers-reduced-motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .firefly, .petal, .hero-emblem, .ending-emblem { animation: none !important; }
  .firefly { opacity: 0.7 !important; }
}


