/* =========================================================
   C语言物语：从零到指针
   暗色 Galgame 风格 · 纯 CSS · 无外部资源
   ========================================================= */

:root {
  --bg: #070912;
  --bg-soft: #0d1122;
  --panel: rgba(17, 22, 42, 0.82);
  --panel-solid: #11162a;
  --panel-2: rgba(25, 31, 57, 0.72);
  --line: rgba(160, 175, 255, 0.16);
  --line-strong: rgba(160, 175, 255, 0.34);
  --text: #eef1ff;
  --muted: #a6aed0;
  --faint: #737ca3;
  --violet: #9b7bff;
  --violet-2: #c4a8ff;
  --pink: #ff8fc7;
  --cyan: #5fe3d0;
  --gold: #ffcf5c;
  --red: #ff6b81;
  --green: #6ee7a8;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --font-ui: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "Georgia", serif;
  --font-code: "Cascadia Code", "JetBrains Mono", "Consolas", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(1100px 700px at 80% -10%, rgba(120, 70, 220, 0.22), transparent 60%),
    radial-gradient(900px 600px at 0% 100%, rgba(30, 140, 160, 0.14), transparent 60%),
    var(--bg);
}

button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--violet-2); outline-offset: 2px; }
::selection { background: rgba(155, 123, 255, 0.42); }

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.03); }
::-webkit-scrollbar-thumb { background: rgba(155,123,255,0.35); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(155,123,255,0.55); }

/* ---------- 背景 ---------- */
.app {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.5;
  animation: floatOrb 18s ease-in-out infinite alternate;
}
.orb-a { width: 520px; height: 520px; left: -160px; top: -120px; background: #5b2ea8; }
.orb-b { width: 620px; height: 620px; right: -220px; top: 15%; background: #173f6b; animation-delay: -6s; }
.orb-c { width: 420px; height: 420px; left: 36%; bottom: -220px; background: #5d1b4c; animation-delay: -11s; }

@keyframes floatOrb {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(30px, -34px, 0) scale(1.08); }
}

.stars {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background-image:
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,0.8), transparent),
    radial-gradient(1px 1px at 28% 68%, rgba(196,168,255,0.8), transparent),
    radial-gradient(1.4px 1.4px at 46% 12%, rgba(255,255,255,0.65), transparent),
    radial-gradient(1px 1px at 63% 42%, rgba(95,227,208,0.8), transparent),
    radial-gradient(1.2px 1.2px at 78% 18%, rgba(255,255,255,0.75), transparent),
    radial-gradient(1px 1px at 88% 74%, rgba(255,143,199,0.8), transparent),
    radial-gradient(1px 1px at 8% 86%, rgba(255,255,255,0.55), transparent),
    radial-gradient(1.3px 1.3px at 34% 34%, rgba(255,207,92,0.55), transparent),
    radial-gradient(1px 1px at 54% 84%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 71% 92%, rgba(196,168,255,0.7), transparent);
  background-size: 720px 720px;
}

.grid-glow {
  position: absolute;
  inset: 0;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(155,123,255,0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155,123,255,0.12) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse at 50% 20%, #000 10%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 20%, #000 10%, transparent 72%);
}

/* ---------- 顶部状态栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 10px clamp(14px, 3vw, 30px);
  background: linear-gradient(180deg, rgba(8, 11, 23, 0.94), rgba(8, 11, 23, 0.66));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 10px;
}
.brand:hover { background: rgba(255,255,255,0.05); }
.brand-mark {
  font-family: var(--font-code);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: -1px;
  color: #0a0d18;
  background: linear-gradient(135deg, var(--cyan), var(--violet-2));
  padding: 5px 7px;
  border-radius: 8px;
}
.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
  font-size: 16px;
}
.topbar-center { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.chapter-pill {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(155,123,255,0.08);
  color: var(--violet-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
.save-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}
.save-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.save-pill.saving i { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

.topbar-stats { display: flex; gap: 8px; }
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--muted);
}
.stat-pill b { color: var(--text); font-variant-numeric: tabular-nums; }
.topbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  transition: 0.18s ease;
  font-size: 15px;
}
.icon-btn:hover { background: rgba(155,123,255,0.18); border-color: var(--line-strong); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(1px) scale(0.97); }

/* ---------- 屏幕系统 ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen { display: none; width: 100%; }
.screen.active { display: flex; flex-direction: column; flex: 1; animation: screenIn 0.34s ease both; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.hidden { display: none !important; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  text-align: center;
}
.btn:hover { background: rgba(155,123,255,0.16); border-color: var(--line-strong); transform: translateY(-2px); }
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #8e6cff, #c86ad6 55%, #ff8fc7);
  border: 0;
  color: #120a1d;
  box-shadow: 0 10px 30px rgba(142, 108, 255, 0.32);
}
.btn-primary:hover { box-shadow: 0 14px 38px rgba(255, 143, 199, 0.3); background: linear-gradient(135deg, #a082ff, #d77be0 55%, #ffa4d2); }
.btn-ghost { background: transparent; }
.btn-soft { background: rgba(255,255,255,0.045); border-color: var(--line); }
.btn-lg { padding: 15px 28px; font-size: 16px; border-radius: 14px; }
.btn.small { padding: 8px 12px; font-size: 12px; border-radius: 10px; }
.btn-back { padding-left: 12px; }
.link-btn {
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px;
}
.link-btn:hover { color: var(--muted); }
.danger { color: var(--red) !important; }
.btn.danger { border-color: rgba(255,107,129,0.3); }
.btn.danger:hover { background: rgba(255,107,129,0.1); }

/* ---------- 开始界面 ---------- */
.title-screen { align-items: center; justify-content: center; padding: 34px 18px 10px; }
.title-hero {
  width: min(100%, 980px);
  text-align: center;
  position: relative;
  padding: clamp(10px, 2vh, 26px) 0;
}

.title-badge {
  display: inline-block;
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--cyan);
  border: 1px solid rgba(95,227,208,0.3);
  background: rgba(95,227,208,0.06);
  border-radius: 999px;
  padding: 7px 13px;
  margin-bottom: 18px;
}
.game-title { margin: 0; line-height: 0.96; }
.title-line {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(50px, 9vw, 92px);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffffff 6%, #d9d0ff 48%, #a98cff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 42px rgba(155,123,255,0.38));
}
.title-sub {
  display: block;
  margin-top: 8px;
  font-size: clamp(16px, 2.6vw, 24px);
  letter-spacing: 0.5em;
  text-indent: 0.5em;
  color: var(--pink);
  font-weight: 600;
}
.title-tagline {
  margin: 18px auto 0;
  color: var(--muted);
  font-size: clamp(13px, 1.6vw, 15px);
  line-height: 1.9;
  max-width: 520px;
}

.hero-characters {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: clamp(10px, 4vw, 46px);
  margin: 24px auto 22px;
  min-height: 134px;
}
.hero-char { position: relative; animation: bob 4.5s ease-in-out infinite; }
.hero-char:nth-child(2) { animation-delay: -1.4s; }
.hero-char:nth-child(3) { animation-delay: -2.7s; }
.char-emoji {
  width: clamp(68px, 9vw, 96px);
  height: clamp(68px, 9vw, 96px);
  display: grid;
  place-items: center;
  font-size: clamp(36px, 5vw, 52px);
  border-radius: 30px;
  background: linear-gradient(160deg, rgba(155,123,255,0.22), rgba(255,143,199,0.08));
  border: 1px solid rgba(196,168,255,0.24);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 16px 38px rgba(0,0,0,0.3);
}
.char-zhan .char-emoji { background: linear-gradient(160deg, rgba(95,227,208,0.18), rgba(23,63,107,0.16)); border-color: rgba(95,227,208,0.24); }
.char-spirit .char-emoji { background: linear-gradient(160deg, rgba(255,207,92,0.2), rgba(255,143,199,0.1)); border-color: rgba(255,207,92,0.26); }
.char-label {
  margin-top: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.char-label small { display: block; font-size: 10px; font-weight: 400; color: var(--faint); margin-top: 2px; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.title-menu {
  width: min(100%, 470px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.title-menu .btn-lg { width: 100%; }
.title-menu > .btn-ghost { width: 100%; }
.title-menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.title-menu .link-btn { align-self: center; margin-top: 2px; }
.title-footnote { margin-top: 18px; font-size: 10px; letter-spacing: 0.12em; color: var(--faint); }

/* ---------- 内页 ---------- */
.page-wrap {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 42px) clamp(14px, 3vw, 26px) 30px;
  flex: 1;
}
.page-wrap.narrow { max-width: 820px; }
.page-head {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head > div:nth-child(2) { flex: 1; min-width: 150px; }
.eyebrow {
  margin: 0 0 4px;
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--violet-2);
}
.page-head h2 { margin: 0; font-family: var(--font-display); font-size: clamp(24px, 4vw, 34px); letter-spacing: 0.06em; }
.map-progress { color: var(--muted); font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; background: rgba(255,255,255,0.03); }
.map-legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; color: var(--faint); font-size: 12px; margin-bottom: 18px; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend .map-tip { margin-left: auto; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.done { background: var(--green); box-shadow: 0 0 8px rgba(110,231,168,0.5); }
.dot.open { background: var(--violet-2); box-shadow: 0 0 8px rgba(196,168,255,0.5); }
.dot.locked { background: #4a5170; }

/* ---------- 章节卡片 ---------- */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.chapter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  padding: 18px;
  min-height: 172px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(155deg, rgba(26,31,56,0.84), rgba(13,17,34,0.8));
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.chapter-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(240px 130px at 100% 0%, var(--accent, rgba(155,123,255,0.24)), transparent 70%);
  opacity: 0.34;
  pointer-events: none;
}
.chapter-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.chapter-card.locked { cursor: not-allowed; opacity: 0.52; }
.chapter-card.locked:hover { transform: none; box-shadow: none; }
.chapter-card.done { border-color: rgba(110,231,168,0.22); }
.chap-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: relative; z-index: 1; }
.chap-num { font-family: var(--font-code); font-size: 11px; color: var(--faint); letter-spacing: 0.1em; }
.chap-status { font-size: 10px; border-radius: 999px; padding: 3px 8px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.chap-status.done { color: var(--green); border-color: rgba(110,231,168,0.28); background: rgba(110,231,168,0.08); }
.chap-status.open { color: var(--violet-2); border-color: rgba(196,168,255,0.26); background: rgba(155,123,255,0.1); }
.chap-icon { font-size: 30px; position: relative; z-index: 1; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.3)); }
.chap-title { position: relative; z-index: 1; font-size: 17px; font-weight: 700; margin: 0; letter-spacing: 0.03em; }
.chap-sub { position: relative; z-index: 1; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; min-height: 36px; }
.chap-meta { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; color: var(--faint); font-size: 10px; margin-top: auto; }
.chap-progress { height: 3px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; position: relative; z-index: 1; }
.chap-progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet), var(--pink)); border-radius: inherit; }

/* ---------- 游戏舞台 ---------- */
.game-screen { padding: 12px clamp(10px, 2.2vw, 22px) 14px; }
.stage {
  position: relative;
  width: min(100%, 1320px);
  margin: 0 auto;
  flex: 1;
  min-height: calc(100dvh - 158px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(9, 12, 24, 0.58);
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.35);
}
.stage-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 23, 0.72);
  backdrop-filter: blur(12px);
  z-index: 4;
}
.stage-title { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.stage-title > span { font-size: 22px; }
.stage-title b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-title small { display: block; color: var(--faint); font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-steps { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.step-chip {
  font-size: 9px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 7px;
  white-space: nowrap;
}
.step-chip.active { color: var(--violet-2); border-color: rgba(196,168,255,0.4); background: rgba(155,123,255,0.12); }
.step-chip.done { color: var(--green); border-color: rgba(110,231,168,0.25); }

.scene {
  position: relative;
  flex: 1;
  min-height: 460px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  padding: 18px;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(155,123,255,0.18), transparent 58%),
    linear-gradient(180deg, rgba(20,25,49,0.3), rgba(5,7,15,0.78));
}
.scene-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 340px at 50% 25%, var(--scene-color, rgba(155,123,255,0.34)), transparent 70%);
  opacity: 0.55;
  transition: background 0.8s ease;
  pointer-events: none;
}
.scene-tag {
  position: absolute;
  top: 14px;
  left: 16px;
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: rgba(238,241,255,0.5);
  border-left: 2px solid var(--violet);
  padding-left: 8px;
}
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(155,123,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155,123,255,0.05) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,0.8), transparent 68%);
  -webkit-mask-image: linear-gradient(180deg, rgba(0,0,0,0.8), transparent 68%);
}

.sprites { position: absolute; inset: 0; pointer-events: none; }
.sprite {
  position: absolute;
  bottom: 178px;
  width: clamp(150px, 20vw, 260px);
  height: clamp(220px, 31vw, 380px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  transition: opacity 0.4s ease, transform 0.4s ease, filter 0.3s ease;
  filter: drop-shadow(0 24px 38px rgba(0,0,0,0.45));
}
.sprite.active { opacity: 1; transform: none; }
.sprite.dim { filter: brightness(0.58) saturate(0.7) drop-shadow(0 18px 28px rgba(0,0,0,0.4)); }
.sprite-left { left: clamp(6%, 14vw, 18%); }
.sprite-right { right: clamp(6%, 14vw, 18%); }
.sprite .portrait {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sprite .portrait-emoji {
  font-size: clamp(110px, 17vw, 210px);
  line-height: 1;
  filter: drop-shadow(0 0 26px rgba(155,123,255,0.25));
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: translateY(0) rotate(-0.5deg); }
  50% { transform: translateY(-7px) rotate(0.5deg); }
}
.sprite .portrait-ring {
  position: absolute;
  width: 78%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px dashed rgba(196,168,255,0.22);
  animation: spinSlow 26s linear infinite;
}
@keyframes spinSlow { to { transform: rotate(360deg); } }
.spirit-float {
  position: absolute;
  right: 16%;
  top: 18%;
  font-size: clamp(30px, 4vw, 46px);
  opacity: 0;
  transition: opacity 0.4s ease;
  filter: drop-shadow(0 0 18px rgba(255,207,92,0.4));
}
.spirit-float.active { opacity: 1; animation: bob 3.2s ease-in-out infinite; }

/* ---------- 对话框 ---------- */
.dialogue-wrap {
  position: relative;
  z-index: 3;
  width: 100%;
  border-radius: 16px;
  border: 1px solid rgba(196,168,255,0.26);
  background: linear-gradient(160deg, rgba(17,22,42,0.94), rgba(10,13,26,0.94));
  box-shadow: 0 18px 44px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06);
  backdrop-filter: blur(14px);
  padding: 14px 16px 10px;
}
.dialogue-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.speaker-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: linear-gradient(150deg, rgba(155,123,255,0.28), rgba(255,143,199,0.12));
  border: 1px solid rgba(196,168,255,0.25);
  flex: none;
}
.speaker-meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.speaker-name { font-size: 14px; font-weight: 700; color: var(--violet-2); letter-spacing: 0.06em; }
.speaker-expr {
  font-size: 10px;
  color: var(--pink);
  border: 1px solid rgba(255,143,199,0.24);
  background: rgba(255,143,199,0.07);
  padding: 2px 7px;
  border-radius: 999px;
}
.speak-btn {
  margin-left: auto;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  border-radius: 9px;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 12px;
  transition: 0.18s ease;
}
.speak-btn:hover { background: rgba(155,123,255,0.18); }
.speak-btn.speaking { background: rgba(95,227,208,0.18); border-color: rgba(95,227,208,0.4); }

.dialogue-text {
  min-height: 76px;
  max-height: 180px;
  overflow-y: auto;
  font-size: clamp(14px, 1.4vw, 16px);
  line-height: 1.9;
  color: #f1f3ff;
  letter-spacing: 0.02em;
  white-space: pre-wrap;
  padding-right: 4px;
}
.dialogue-text .caret { color: var(--pink); animation: blink 0.9s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.dialogue-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; }
.dialogue-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.tool-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--faint);
  font-size: 11px;
  cursor: pointer;
  border-radius: 8px;
  padding: 5px 7px;
  transition: 0.16s ease;
  white-space: nowrap;
}
.tool-btn:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tool-btn.active { color: var(--cyan); background: rgba(95,227,208,0.08); border-color: rgba(95,227,208,0.22); }
.next-btn {
  border: 1px solid rgba(196,168,255,0.3);
  background: rgba(155,123,255,0.14);
  color: var(--violet-2);
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 12px;
  cursor: pointer;
  transition: 0.18s ease;
  white-space: nowrap;
}
.next-btn:hover { background: rgba(155,123,255,0.26); }
.next-btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- 选项 ---------- */
.choice-panel {
  position: absolute;
  left: 50%;
  bottom: 238px;
  transform: translateX(-50%);
  z-index: 6;
  width: min(92%, 620px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: choiceIn 0.3s ease both;
}
@keyframes choiceIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.choice-intro {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--violet-2);
  margin-bottom: 2px;
}
.choice-btn {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(196,168,255,0.3);
  background: linear-gradient(120deg, rgba(31,36,66,0.96), rgba(17,21,40,0.96));
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 13px;
  line-height: 1.6;
  cursor: pointer;
  transition: 0.18s ease;
  box-shadow: 0 10px 26px rgba(0,0,0,0.3);
}
.choice-btn:hover { border-color: var(--pink); background: linear-gradient(120deg, rgba(55,39,78,0.96), rgba(26,22,44,0.96)); transform: translateX(4px); }
.choice-btn:disabled { opacity: 0.42; cursor: default; transform: none; }

/* ---------- 学习面板 / 知识卡 ---------- */
.study-overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 7, 15, 0.72);
  backdrop-filter: blur(8px);
  overflow-y: auto;
}
.study-card {
  width: min(100%, 780px);
  max-height: calc(100% - 8px);
  overflow-y: auto;
  border-radius: 20px;
  border: 1px solid rgba(196,168,255,0.26);
  background: linear-gradient(165deg, rgba(23,28,53,0.98), rgba(11,15,30,0.99));
  box-shadow: 0 30px 80px rgba(0,0,0,0.55);
  padding: clamp(18px, 3vw, 30px);
  animation: cardIn 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.985); } to { opacity: 1; transform: none; } }
.study-kicker { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.study-kicker span {
  font-family: var(--font-code);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--cyan);
}
.study-kicker em {
  font-style: normal;
  font-size: 10px;
  color: var(--faint);
  border-left: 1px solid var(--line);
  padding-left: 8px;
}
.study-card h3 { margin: 0 0 10px; font-family: var(--font-display); font-size: clamp(20px, 3vw, 27px); line-height: 1.35; letter-spacing: 0.03em; }
.study-card p.lead { color: var(--muted); line-height: 1.9; font-size: 14px; margin: 0 0 14px; }
.k-code, .study-card pre {
  margin: 12px 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(95,227,208,0.16);
  background: #080b16;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 12.5px;
  line-height: 1.75;
  color: #c8f4ee;
  tab-size: 4;
}
.k-code .cmt { color: #6e7ca5; }
.k-code .str { color: #ffcf8a; }
.k-code .kw { color: #c4a8ff; }
.k-code .num { color: #ff9fbc; }
.study-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 2px solid var(--gold);
  background: rgba(255,207,92,0.06);
  border-radius: 0 8px 8px 0;
  color: #d8d2bb;
  font-size: 12px;
  line-height: 1.75;
}
.study-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.study-progress { margin-right: auto; color: var(--faint); font-size: 11px; }
.k-index { display: flex; gap: 5px; margin-left: auto; }
.study-exit { width: 28px; height: 28px; font-size: 12px; margin-left: 8px; flex: none; border-radius: 8px; }
.k-index + .study-exit { margin-left: 2px; }
.quiz-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.quiz-hint { color: var(--faint); font-size: 11px; }
.k-index i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.16); }
.k-index i.on { background: var(--violet-2); box-shadow: 0 0 8px rgba(196,168,255,0.5); }

/* ---------- 题目 ---------- */
.quiz-top { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.quiz-type {
  font-size: 10px;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid rgba(255,143,199,0.25);
  background: rgba(255,143,199,0.08);
  color: var(--pink);
  letter-spacing: 0.06em;
}
.quiz-count { font-size: 11px; color: var(--faint); }
.quiz-question { font-size: clamp(15px, 2vw, 18px); font-weight: 600; line-height: 1.75; margin: 0 0 16px; white-space: pre-wrap; }
.quiz-options { display: flex; flex-direction: column; gap: 8px; }
.quiz-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.035);
  border-radius: 11px;
  padding: 12px 13px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
  cursor: pointer;
  transition: 0.16s ease;
}
.quiz-option:hover { border-color: var(--line-strong); background: rgba(155,123,255,0.1); }
.quiz-option .opt-key {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255,255,255,0.07);
  color: var(--muted);
  font-family: var(--font-code);
  font-size: 11px;
}
.quiz-option.correct { border-color: rgba(110,231,168,0.55); background: rgba(110,231,168,0.1); }
.quiz-option.correct .opt-key { background: rgba(110,231,168,0.22); color: var(--green); }
.quiz-option.wrong { border-color: rgba(255,107,129,0.55); background: rgba(255,107,129,0.09); }
.quiz-option.wrong .opt-key { background: rgba(255,107,129,0.2); color: var(--red); }
.quiz-option:disabled { cursor: default; opacity: 0.8; }
.quiz-option.dimmed { opacity: 0.42; }

.answer-row { display: flex; gap: 8px; margin-top: 6px; }
.answer-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  background: #080b16;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font-family: var(--font-code);
  font-size: 13px;
  outline: none;
}
.answer-input:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(155,123,255,0.12); }
.answer-input::placeholder { color: #555f80; }

.quiz-feedback {
  margin-top: 14px;
  border-radius: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.035);
  font-size: 12.5px;
  line-height: 1.8;
  color: var(--muted);
  animation: fadeUp 0.25s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.quiz-feedback.ok { border-color: rgba(110,231,168,0.35); background: rgba(110,231,168,0.07); }
.quiz-feedback.no { border-color: rgba(255,107,129,0.35); background: rgba(255,107,129,0.06); }
.quiz-feedback b { color: var(--text); }
.quiz-feedback .fb-title { display: block; margin-bottom: 3px; font-weight: 700; }
.quiz-feedback.ok .fb-title { color: var(--green); }
.quiz-feedback.no .fb-title { color: var(--red); }
.quiz-feedback .fb-exp { color: var(--muted); }
.quiz-feedback .fb-answer { color: var(--gold); }

.boss-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,207,92,0.22);
  background: rgba(255,207,92,0.06);
  color: #e9dcb4;
  font-size: 12px;
  margin-bottom: 14px;
}
.boss-banner b { color: var(--gold); }

/* ---------- 结算 ---------- */
.result-wrap { text-align: center; padding: 6px 2px; }
.result-icon { font-size: 52px; filter: drop-shadow(0 8px 20px rgba(155,123,255,0.3)); }
.result-title { font-family: var(--font-display); font-size: clamp(24px, 4vw, 34px); margin: 6px 0 6px; }
.result-sub { color: var(--muted); font-size: 13px; line-height: 1.8; margin: 0 0 16px; }
.result-stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.result-stat {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.035);
  padding: 10px 14px;
}
.result-stat small { display: block; color: var(--faint); font-size: 10px; margin-bottom: 3px; }
.result-stat b { font-size: 19px; color: var(--violet-2); }
.result-stars { font-size: 24px; letter-spacing: 0.12em; margin: 6px 0; }
.result-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- 错题本 ---------- */
.wrong-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.wrong-summary .result-stat { min-width: 110px; }
.wrong-list { display: flex; flex-direction: column; gap: 10px; }
.wrong-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17,22,42,0.66);
  padding: 15px 16px;
}
.wrong-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }
.wrong-chapter { font-size: 10px; color: var(--violet-2); border: 1px solid rgba(196,168,255,0.2); background: rgba(155,123,255,0.07); border-radius: 999px; padding: 2px 8px; }
.wrong-type { font-size: 10px; color: var(--faint); }
.wrong-date { margin-left: auto; font-size: 10px; color: var(--faint); }
.wrong-q { font-size: 13px; line-height: 1.75; margin: 0 0 8px; white-space: pre-wrap; }
.wrong-ans { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--faint); }
.wrong-ans b.no { color: var(--red); }
.wrong-ans b.ok { color: var(--green); }
.wrong-exp { margin: 8px 0 0; font-size: 12px; line-height: 1.75; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 8px; }
.empty-state { text-align: center; padding: 56px 18px; color: var(--faint); border: 1px dashed var(--line); border-radius: 16px; }
.empty-state .big { font-size: 38px; margin-bottom: 8px; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.8; }

/* ---------- 成就 ---------- */
.ach-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ach-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(17,22,42,0.66);
  transition: 0.18s ease;
}
.ach-card.unlocked { border-color: rgba(255,207,92,0.24); background: linear-gradient(150deg, rgba(255,207,92,0.07), rgba(17,22,42,0.7)); }
.ach-card.locked { opacity: 0.5; }
.ach-icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 23px;
  border-radius: 13px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}
.ach-card.unlocked .ach-icon { background: rgba(255,207,92,0.12); border-color: rgba(255,207,92,0.25); }
.ach-info b { display: block; font-size: 13px; margin-bottom: 4px; }
.ach-info p { margin: 0; color: var(--faint); font-size: 11px; line-height: 1.6; }
.ach-status { display: inline-block; margin-top: 6px; font-size: 9px; color: var(--faint); }
.ach-card.unlocked .ach-status { color: var(--gold); }

/* ---------- 设置 ---------- */
.settings-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(17,22,42,0.7);
  padding: clamp(16px, 3vw, 26px);
}
.setting-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.3fr) minmax(120px, 1fr) 58px;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  border-bottom: 1px dashed var(--line);
}
.setting-row:last-of-type { border-bottom: 0; }
.setting-label b { display: block; font-size: 13px; margin-bottom: 3px; }
.setting-label small { display: block; color: var(--faint); font-size: 10px; line-height: 1.5; }
.setting-val { font-family: var(--font-code); font-size: 11px; color: var(--violet-2); text-align: right; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--violet), rgba(255,255,255,0.12));
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #f0eaff;
  border: 2px solid var(--violet);
  box-shadow: 0 0 12px rgba(155,123,255,0.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #f0eaff;
  border: 2px solid var(--violet);
  cursor: pointer;
}

.switch { position: relative; display: inline-block; width: 44px; height: 24px; justify-self: start; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 99px;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--line);
  transition: 0.2s ease;
  cursor: pointer;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #cdd2ea;
  top: 3px; left: 3px;
  transition: 0.2s ease;
}
.switch input:checked + span { background: rgba(155,123,255,0.55); border-color: rgba(196,168,255,0.5); }
.switch input:checked + span::after { transform: translateX(20px); background: #fff; }

.settings-note {
  margin: 16px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(95,227,208,0.05);
  border: 1px solid rgba(95,227,208,0.14);
}
.settings-note p { margin: 0 0 6px; color: var(--muted); font-size: 11px; line-height: 1.7; }
.settings-note p:last-child { margin-bottom: 0; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- 侧边抽屉 ---------- */
.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(2, 4, 10, 0.6);
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 61;
  width: min(86vw, 330px);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #12172c, #0a0e1c);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 70px rgba(0,0,0,0.5);
  padding: 20px;
  animation: drawerIn 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.drawer-head h3 { margin: 0; font-family: var(--font-display); font-size: 20px; }
.drawer-nav { display: flex; flex-direction: column; gap: 6px; }
.drawer-nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: 0.16s ease;
}
.drawer-nav button:hover { background: rgba(155,123,255,0.1); border-color: var(--line); color: var(--text); }
.drawer-nav button span { width: 20px; text-align: center; }
.drawer-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; line-height: 1.7; }
.drawer-hint { margin-top: 4px; }

/* ---------- 通用弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2, 4, 10, 0.74);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease both;
}
.modal {
  width: min(100%, 520px);
  max-height: min(86dvh, 760px);
  overflow-y: auto;
  border-radius: 18px;
  border: 1px solid rgba(196,168,255,0.26);
  background: linear-gradient(165deg, #171c35, #0b0f1e);
  box-shadow: var(--shadow);
  animation: cardIn 0.26s ease both;
}
.modal.wide { width: min(100%, 760px); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}
.modal-head h3 { margin: 0; font-family: var(--font-display); font-size: 20px; }
.modal-body { padding: 12px 18px 6px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.modal-body p { margin: 0 0 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px 18px; flex-wrap: wrap; }

/* 历史记录 */
.history-list { display: flex; flex-direction: column; gap: 8px; max-height: 52dvh; overflow-y: auto; padding-right: 4px; }
.history-item { border-left: 2px solid var(--line-strong); padding: 2px 0 2px 10px; }
.history-item b { color: var(--violet-2); font-size: 11px; }
.history-item p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }

/* 存档槽 */
.save-slots { display: flex; flex-direction: column; gap: 8px; }
.save-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  padding: 11px 12px;
}
.save-slot-info { flex: 1; min-width: 0; }
.save-slot-info b { display: block; font-size: 12px; margin-bottom: 2px; }
.save-slot-info small { color: var(--faint); font-size: 10px; display: block; line-height: 1.5; }
.save-slot-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.save-slot-actions .btn { padding: 6px 9px; font-size: 10px; border-radius: 8px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  max-width: min(90vw, 470px);
  border: 1px solid rgba(196,168,255,0.3);
  background: rgba(17,22,42,0.96);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 12px;
  line-height: 1.6;
  box-shadow: 0 16px 44px rgba(0,0,0,0.5);
  animation: toastIn 0.25s ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 页脚 ---------- */
.site-footer {
  padding: 14px 18px 16px;
  text-align: center;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.03em;
  line-height: 1.7;
  border-top: 1px solid rgba(160,175,255,0.07);
  background: rgba(6,8,16,0.5);
}
.footer-dot { margin: 0 6px; opacity: 0.6; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .chapter-grid, .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { border-radius: 18px; }
  .stage-steps { display: none; }
  .sprite { bottom: 200px; }
  .choice-panel { bottom: 242px; }
}

@media (max-width: 680px) {
  .topbar { gap: 8px; padding: 8px 12px; min-height: 56px; }
  .brand-text { display: none; }
  .topbar-center { gap: 6px; }
  .chapter-pill { max-width: 132px; font-size: 10px; padding: 5px 9px; }
  .save-pill { display: none; }
  .topbar-stats { gap: 4px; }
  .stat-pill { padding: 4px 7px; font-size: 10px; }
  .icon-btn { width: 32px; height: 32px; font-size: 13px; border-radius: 9px; }
  .page-head { gap: 10px; }
  .page-head h2 { font-size: 24px; }
  .map-legend .map-tip { margin-left: 0; flex-basis: 100%; }
  .chapter-grid, .ach-grid { grid-template-columns: 1fr; }
  .chapter-card { min-height: 150px; }
  .title-screen { padding-top: 22px; }
  .hero-characters { gap: 9px; min-height: 110px; margin: 18px auto 18px; }
  .char-emoji { width: 64px; height: 64px; font-size: 34px; border-radius: 22px; }
  .char-label { font-size: 11px; }
  .title-menu-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .title-menu .btn { padding: 12px 14px; font-size: 13px; }

  .game-screen { padding: 7px 7px 10px; }
  .stage { min-height: calc(100dvh - 130px); border-radius: 15px; }
  .stage-head { padding: 7px 9px; gap: 7px; }
  .stage-title > span { font-size: 17px; }
  .stage-title b { font-size: 11px; }
  .stage-title small { font-size: 9px; }
  .btn.small { padding: 6px 8px; font-size: 10px; }
  .scene { padding: 9px; min-height: 420px; align-items: flex-end; }
  .scene-tag { font-size: 8px; top: 10px; left: 10px; }
  .sprite { bottom: 216px; width: 150px; height: 220px; }
  .sprite-left { left: 1%; }
  .sprite-right { right: 1%; }
  .sprite .portrait-emoji { font-size: 112px; }
  .spirit-float { top: 12%; right: 8%; font-size: 28px; }

  .dialogue-wrap { padding: 11px 11px 8px; border-radius: 13px; }
  .speaker-avatar { width: 32px; height: 32px; font-size: 18px; border-radius: 10px; }
  .speaker-name { font-size: 12px; }
  .speaker-expr { font-size: 9px; }
  .dialogue-text { min-height: 92px; max-height: 160px; font-size: 13px; line-height: 1.85; }
  .dialogue-foot { align-items: flex-end; }
  .dialogue-tools { gap: 2px; }
  .tool-btn { font-size: 10px; padding: 4px 5px; }
  .next-btn { font-size: 11px; padding: 6px 10px; }
  .choice-panel { bottom: 238px; width: 94%; gap: 6px; }
  .choice-btn { font-size: 12px; padding: 11px 12px; }
  .choice-intro { font-size: 9px; }

  .study-overlay { padding: 8px; align-items: flex-start; }
  .study-card { padding: 16px 14px; border-radius: 15px; max-height: calc(100dvh - 120px); }
  .study-card h3 { font-size: 20px; }
  .study-card p.lead { font-size: 12.5px; }
  .k-code, .study-card pre { font-size: 11px; padding: 11px 12px; }
  .quiz-question { font-size: 14px; }
  .quiz-option { font-size: 12px; padding: 10px; }
  .study-actions { gap: 6px; }
  .study-actions .btn { padding: 9px 12px; font-size: 12px; }

  .page-wrap { padding: 16px 12px 24px; }
  .setting-row { grid-template-columns: 1fr 58px; gap: 10px; }
  .setting-row input[type="range"] { grid-column: 1 / -1; grid-row: 2; }
  .setting-row .switch { grid-column: 2; grid-row: 1; justify-self: end; }
  .settings-card { padding: 14px; }
  .settings-actions { justify-content: stretch; }
  .settings-actions .btn { flex: 1; }
  .wrong-date { margin-left: 0; flex-basis: 100%; }
  .ach-grid { grid-template-columns: 1fr; }
  .site-footer { font-size: 9px; padding: 10px 12px 12px; }
}

@media (max-width: 380px) {
  .topbar-stats .stat-pill:last-child { display: none; }
  .title-line { font-size: 44px; }
  .hero-characters { gap: 5px; }
  .char-emoji { width: 56px; height: 56px; font-size: 30px; }
  .sprite .portrait-emoji { font-size: 96px; }
}

/* 减少动态效果 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* =========================================================
   2026-11 视觉升级：日系 galgame 背景 / 樱花 / 女主皮肤
   ========================================================= */
.scene {
  isolation: isolate;
  background:
    radial-gradient(ellipse at 50% 24%, rgba(155,123,255,0.20), transparent 58%),
    linear-gradient(180deg, #1a2140 0%, #0b0e1c 78%);
}
.scene-bg {
  position: absolute;
  inset: -18px;
  z-index: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  filter: saturate(1.04) brightness(0.70) contrast(1.04);
  transform: scale(1.035);
  transition: opacity 0.65s ease, background-image 0.4s ease;
  pointer-events: none;
}
.scene-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(6,8,17,0.34) 0%, transparent 26%, transparent 74%, rgba(6,8,17,0.34) 100%),
    linear-gradient(180deg, rgba(8,10,22,0.18) 0%, rgba(8,10,22,0.10) 34%, rgba(8,10,22,0.56) 68%, rgba(6,8,17,0.90) 100%),
    radial-gradient(ellipse at 50% 32%, transparent 20%, rgba(7,9,20,0.34) 100%);
}
.scene-glow { z-index: 1; mix-blend-mode: screen; }
.sakura {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}
.sakura span {
  position: absolute;
  top: -24px;
  width: 9px;
  height: 7px;
  border-radius: 80% 8% 80% 8%;
  background: linear-gradient(135deg, rgba(255,190,224,0.95), rgba(255,138,192,0.55));
  box-shadow: 0 0 8px rgba(255,150,205,0.25);
  opacity: 0;
  animation: petalFall var(--dur, 12s) linear infinite;
  animation-delay: var(--delay, 0s);
  transform: rotate(var(--rot, 0deg));
}
@keyframes petalFall {
  0% { opacity: 0; transform: translate3d(0, -10px, 0) rotate(0deg) scale(0.8); }
  10% { opacity: 0.85; }
  75% { opacity: 0.65; }
  100% { opacity: 0; transform: translate3d(var(--drift, 42px), 88vh, 0) rotate(300deg) scale(1.05); }
}
.sprites { z-index: 3; }
.dialogue-wrap { z-index: 4; background: linear-gradient(160deg, rgba(17,22,42,0.93), rgba(10,13,26,0.95)); }
.scene::after { z-index: 2; opacity: 0.55; }
.scene-tag { z-index: 5; text-shadow: 0 1px 10px rgba(0,0,0,0.8); }

/* 标题页：女主切换 */
.heroine-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: -4px auto 16px;
  padding: 5px;
  border: 1px solid rgba(196,168,255,0.16);
  border-radius: 999px;
  background: rgba(12,16,32,0.42);
  backdrop-filter: blur(10px);
  width: fit-content;
}
.heroine-pick-label { color: var(--faint); font-size: 10px; letter-spacing: 0.12em; padding: 0 5px 0 9px; }
.heroine-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
  transition: 0.18s ease;
}
.heroine-chip span { font-size: 14px; }
.heroine-chip small { font-size: 9px; color: var(--faint); }
.heroine-chip:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.heroine-chip.active {
  color: var(--violet-2);
  border-color: rgba(196,168,255,0.34);
  background: linear-gradient(120deg, rgba(155,123,255,0.22), rgba(255,143,199,0.09));
  box-shadow: 0 4px 18px rgba(155,123,255,0.16);
}
.heroine-chip.active small { color: var(--pink); }

/* 设置页：女主皮肤 */
.heroine-setting { padding: 2px 0 18px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
.heroine-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.heroine-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,0.025);
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  transition: 0.18s ease;
}
.heroine-option:hover { border-color: rgba(196,168,255,0.45); background: rgba(155,123,255,0.08); }
.heroine-option.active {
  border-color: rgba(255,143,199,0.46);
  background: linear-gradient(130deg, rgba(155,123,255,0.18), rgba(255,143,199,0.08));
  box-shadow: 0 6px 22px rgba(155,123,255,0.12);
}
.heroine-option-art {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 12px;
  font-size: 23px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
}
.heroine-option b { display: block; font-size: 12px; margin-bottom: 3px; }
.heroine-option small { display: block; color: var(--faint); font-size: 9px; }
.heroine-disclaimer {
  margin: 10px 0 0;
  color: var(--faint);
  font-size: 9px;
  line-height: 1.65;
}
.voice-pack-status {
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px dashed rgba(95,227,208,0.22);
  border-radius: 10px;
  background: rgba(95,227,208,0.04);
  color: var(--cyan);
  font-size: 10px;
  line-height: 1.6;
}
.footer-fan { color: rgba(238,241,255,0.42); }

/* 丛雨立绘（内联 SVG 容器） */
.sprite .portrait > svg,
.speaker-avatar > svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 0 24px rgba(129,235,180,0.16));
}
.speaker-avatar { overflow: hidden; }
.speaker-avatar > svg { transform: scale(1.14) translateY(2px); }
body.skin-murasame .char-ning { border-color: rgba(121,235,178,0.3); }
body.skin-murasame .char-ning .char-emoji { filter: drop-shadow(0 0 16px rgba(121,235,178,0.35)); }

/* 日系画面在移动端更聚焦人物 */
@media (max-width: 680px) {
  .scene-bg { inset: -12px; filter: saturate(1.03) brightness(0.72); }
  .heroine-pick { margin-bottom: 12px; gap: 4px; }
  .heroine-pick-label { display: none; }
  .heroine-options { gap: 8px; }
  .heroine-option { padding: 9px; gap: 8px; }
  .heroine-option-art { width: 32px; height: 32px; font-size: 19px; }
  .heroine-option b { font-size: 11px; }
  .heroine-option small { font-size: 8px; }
  .sakura span:nth-child(n+9) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sakura { display: none; }
  .scene-bg { transition: none; }
}


/* 标题页丛雨头像 & 立绘对比度 */
.char-emoji { overflow: hidden; }
.char-emoji > svg { width: 100%; height: 100%; display: block; }
.sprite-left .portrait > svg {
  filter: drop-shadow(0 18px 30px rgba(0,0,0,0.48)) drop-shadow(0 0 22px rgba(129,235,180,0.16));
}

/* ---------- 标题页场景背景（2026-11 增补） ---------- */
.title-screen {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}
.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url("img_bg/bg_classroom.webp") center / cover no-repeat;
  opacity: 0.30;
  filter: saturate(1.06) brightness(0.82);
  pointer-events: none;
}
.title-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(12, 14, 30, 0.10), rgba(8, 10, 22, 0.76) 72%),
    linear-gradient(180deg, rgba(8, 10, 22, 0.42), rgba(8, 10, 22, 0.22) 35%, rgba(8, 10, 22, 0.84));
  pointer-events: none;
}
.title-hero {
  z-index: 2;
}
body.skin-murasame .title-screen::before {
  background-image: url("img_bg/bg_shrine.webp");
  opacity: 0.28;
}
@media (max-width: 680px) {
  .title-screen::before { opacity: 0.24; }
  body.skin-murasame .title-screen::before { opacity: 0.23; }
}
