:root {
  --pink: #ff5c8a;
  --pink-dark: #e23d6d;
  --bg: #fff7ec;
  --ink: #2b2d42;
  --muted: #7a7d90;
  --green: #2bb673;
  --red: #ef476f;
  --blue: #3a86ff;
  --yellow: #ffbe0b;
  --purple: #8338ec;
  --radius: 22px;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 20px;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

/* ---------- 顶栏 / 页脚 ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--pink);
  color: #fff;
  box-shadow: 0 3px 0 var(--pink-dark);
}
.topbar h1 { flex: 1; margin: 0; font-size: 30px; letter-spacing: 2px; }
.icon-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  font-size: 28px;
  display: grid; place-items: center;
}
.icon-btn:active { transform: scale(0.92); }

#view { flex: 1; overflow-y: auto; padding: 18px 24px; -webkit-overflow-scrolling: touch; }

.footer {
  display: flex; justify-content: center; align-items: center; gap: 16px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  font-size: 14px; color: var(--muted);
}
.ver { opacity: 0.7; }
.diag { font-size: 15px !important; color: var(--muted); background: #f6efe6; padding: 8px 12px; border-radius: 10px; }
.link-btn { background: none; font-size: 14px; color: var(--muted); text-decoration: underline; padding: 4px 8px; }

/* ---------- 监护仪 ---------- */

.monitor {
  position: relative;
  border-radius: 18px;
  overflow: hidden;
  border: 4px solid #ffd0dc;
  background: #fff1f4;
}
.monitor canvas { display: block; width: 100%; height: 100%; }
.heart {
  position: absolute; top: 10px; right: 12px;
  width: 44px; height: 40px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.15));
}
.heart-svg { width: 100%; height: 100%; fill: #ff2d55; }
.heart.beat { animation: beat 0.32s ease-out; }
.heart[data-mode="shiver"] { animation: shiver 0.12s infinite; }
.heart[data-mode="still"] .heart-svg { fill: #b9bac6; }
.heart[data-mode="off"] { display: none; }
@keyframes beat { 0% { transform: scale(1); } 30% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes shiver { 0% { transform: translate(0, 0); } 25% { transform: translate(-2px, 1px); } 50% { transform: translate(2px, -1px); } 75% { transform: translate(-1px, -1px); } }

.home-monitor { height: 24vh; min-height: 140px; }
.quiz-monitor { height: 34vh; min-height: 200px; }
.big-monitor { height: 38vh; min-height: 220px; margin: 10px 0; }
.card-monitor { height: 120px; border-width: 3px; }
.card-monitor .heart { width: 30px; height: 27px; top: 6px; right: 8px; }

/* ---------- 首页 ---------- */

.home { display: flex; flex-direction: column; gap: 18px; max-width: 1200px; margin: 0 auto; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 20px 12px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 30px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.08s;
}
.mode-card:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); }
.mode-card small { font-size: 18px; opacity: 0.9; }
.mode-icon { font-size: 52px; line-height: 1; }
.c1 { background: var(--purple); }
.c2 { background: var(--blue); }
.c3 { background: var(--green); }
.c4 { background: #00a6a6; }
.c5 { background: #ff8c1a; }
.c6 { background: var(--red); }

/* ---------- 按钮 ---------- */

.big-btn {
  padding: 16px 34px;
  border-radius: 999px;
  background: #fff;
  font-size: 24px;
  font-weight: bold;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
  border: 3px solid #f0e2d0;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.big-btn.primary { background: var(--pink); color: #fff; border-color: var(--pink-dark); }
.big-btn.danger { background: var(--red); color: #fff; border-color: #c9304f; font-size: 18px; }
.row { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }

.speak {
  display: inline-grid; place-items: center;
  width: 46px; height: 46px;
  margin-left: 6px;
  border-radius: 50%;
  background: #fff3c4;
  font-size: 22px;
  vertical-align: middle;
  box-shadow: 0 3px 0 #f0d77a;
}
.speak:active { transform: translateY(2px); box-shadow: none; }

/* ---------- 图鉴 ---------- */

.atlas-tip { margin: 0 0 14px; font-size: 20px; color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px;
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
  box-shadow: 0 5px 0 #f0e2d0;
  border: 3px solid #f6e9d8;
}
.card:active { transform: translateY(3px); }
.card b { font-size: 24px; margin-top: 4px; }
.card .sci { color: var(--muted); font-size: 15px; }
.card p { margin: 0; font-size: 16px; line-height: 1.45; }

/* ---------- 弹窗 ---------- */

.overlay {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: rgba(43, 45, 66, 0.55);
  z-index: 10;
  padding: 20px;
}
.modal-box {
  position: relative;
  width: min(920px, 100%);
  max-height: 100%;
  overflow-y: auto;
  background: #fff;
  border-radius: 28px;
  padding: 22px 28px;
}
.modal-box h2 { margin: 0 60px 0 0; font-size: 34px; }
.modal-box h2 small { font-size: 18px; color: var(--muted); font-weight: normal; margin-left: 8px; }
.modal-box .close { position: absolute; top: 16px; right: 16px; background: #f3eee8; font-size: 22px; }
.modal-box p { font-size: 22px; line-height: 1.6; margin: 10px 0; }
.aed { display: inline-block; padding: 8px 18px; border-radius: 999px; font-weight: bold; }
.aed.yes { background: #fff3c4; color: #b06d00; }
.aed.no { background: #e9f1ff; color: #2459b8; }

.parent table { width: 100%; border-collapse: collapse; font-size: 18px; }
.parent th, .parent td { border-bottom: 1px solid #eee; padding: 10px 8px; text-align: left; }

/* ---------- 开始页 ---------- */

.start { background: linear-gradient(160deg, #ff8fab, #ff5c8a); z-index: 20; }
.start-box { text-align: center; color: #fff; }
.start-box h2 { font-size: 64px; margin: 10px 0; letter-spacing: 6px; }
.start-box p { font-size: 26px; margin: 0 0 40px; }
.start-heart { font-size: 110px; animation: beat 0.8s infinite; }
.start .big-btn { font-size: 40px; padding: 22px 80px; background: #fff; color: var(--pink-dark); border-color: #ffd0dc; }

/* ---------- 题目 ---------- */

.level-pick { text-align: center; padding-top: 6vh; }
.level-pick h2 { font-size: 34px; }
.level-btn {
  display: flex; flex-direction: column; gap: 8px;
  width: 300px; padding: 40px 20px;
  border-radius: var(--radius);
  color: #fff; font-size: 36px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
}
.level-btn small { font-size: 20px; }

.quiz { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.progress { display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 20px; font-weight: bold; color: var(--muted); }
.progress .score { margin-left: auto; }
.dots { display: flex; gap: 8px; flex-wrap: wrap; }
.dot, .chip.step {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; border: 3px solid #eadfd2;
  font-size: 18px; font-weight: bold; color: var(--muted);
}
.dot.ok, .chip.step.ok { background: #dcf7e9; border-color: var(--green); color: var(--green); }
.dot.bad { background: #ffe1e8; border-color: var(--red); color: var(--red); }
.dot.now, .chip.step.now { border-color: var(--yellow); background: #fff3c4; color: var(--ink); transform: scale(1.15); }
.nav-btn { width: 52px; height: 44px; border-radius: 14px; background: #fff; border: 3px solid #eadfd2; font-size: 18px; }
.step-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chips-label { font-weight: bold; color: var(--muted); }
.chip { padding: 8px 14px; border-radius: 999px; background: #f6efe6; border: 2px solid #eadfd2; font-size: 16px; }
.chip.ok { background: #dcf7e9; border-color: var(--green); }
.chip.now { background: #fff3c4; border-color: var(--yellow); font-weight: bold; }
.question { margin: 4px 0; font-size: 32px; text-align: center; }

.options { display: grid; gap: 16px; }
.options.n3 { grid-template-columns: repeat(3, 1fr); }
.options.n4 { grid-template-columns: repeat(4, 1fr); }
.opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 20px 10px;
  border-radius: var(--radius);
  background: #fff;
  border: 4px solid #e9dccb;
  box-shadow: 0 5px 0 #e9dccb;
  font-size: 24px; justify-content: center; line-height: 1.3;
}
.opt small { font-size: 16px; color: var(--muted); }
.opt:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 #e9dccb; }
.opt:disabled { cursor: default; opacity: 0.55; }
.opt.right { background: #dcf7e9; border-color: var(--green); box-shadow: 0 5px 0 var(--green); opacity: 1; }
.opt.wrong { background: #ffe1e8; border-color: var(--red); box-shadow: 0 5px 0 var(--red); opacity: 1; animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

.tf-options { grid-template-columns: 1fr 1fr; max-width: 760px; width: 100%; margin: 0 auto; }
.tf-options .opt { font-size: 40px; padding: 22px; }
.fact-card {
  height: 34vh; min-height: 200px;
  display: grid; place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, #ffe8a3, #ffd1dc);
  font-size: 48px; font-weight: bold;
}

.feedback {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 20px;
  border-radius: var(--radius);
  animation: pop 0.25s ease-out;
}
.feedback p { flex: 1; margin: 0; font-size: 22px; line-height: 1.5; }
.feedback.good { background: #dcf7e9; }
.feedback.bad { background: #fff3c4; }
@keyframes pop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.finish { text-align: center; padding-top: 6vh; }
.stars { font-size: 90px; letter-spacing: 10px; }
.finish h2 { font-size: 44px; margin: 10px 0; }
.finish p { font-size: 26px; }

/* ---------- 难度 / 图鉴分级 ---------- */

.level-btn.lv1 { background: var(--green); }
.level-btn.lv2 { background: var(--blue); }
.level-btn.lv3 { background: var(--purple); }
.level-btn.lv4 { background: #e07a00; }
.level-btn { width: 240px; }
.level-note { color: var(--muted); font-size: 20px; margin-top: 28px; }
.level-title { margin: 22px 0 12px; font-size: 26px; padding-left: 12px; border-left: 8px solid; }
.level-title.lv1 { border-color: var(--green); }
.level-title.lv2 { border-color: var(--blue); }
.level-title.lv3 { border-color: var(--purple); }
.level-title.lv4 { border-color: #e07a00; }
.big-btn.small { font-size: 18px; padding: 10px 22px; }

/* ---------- 实验室 ---------- */

.lab { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.lab-monitor { height: 25vh; min-height: 170px; }
.lab > .monitor-box { position: sticky; top: 0; z-index: 2; } /* 往下调滑块时心电图固定在顶部，随时能看到变化 */
.lab-body { display: grid; grid-template-columns: 0.9fr 1.25fr 0.85fr; gap: 12px; align-items: start; }
.lab.free .lab-body { grid-template-columns: 1fr 1.4fr; }
.sliders { display: flex; flex-direction: column; gap: 4px; background: #fff; border-radius: var(--radius); padding: 14px 20px; }
.slider span { display: flex; justify-content: space-between; font-size: 19px; }
.slider b { color: var(--pink-dark); }
.slider input { width: 100%; height: 32px; accent-color: var(--pink); }
.detect { background: #fff; border-radius: var(--radius); padding: 14px 20px; }
.task-title.done { color: var(--green); }
.detect-label { margin: 0; color: var(--muted); font-size: 16px; }
.detect-name { margin: 4px 0; font-size: 26px; font-weight: bold; color: var(--pink-dark); }
.detect-name.none { color: var(--muted); }
.detect-say { margin: 0; font-size: 17px; line-height: 1.5; }
.detect.pop { animation: pop 0.3s ease-out; }

/* ---------- AED 小判官 ---------- */

.scene-note { margin: 0; padding: 10px 18px; border-radius: 14px; background: #fff3c4; font-size: 20px; font-weight: bold; }
.opt.shock b { color: #d96a00; }
.finish-note { color: var(--muted); }

/* ---------- 急救 ---------- */

.rescue { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.monitor-wrap { position: relative; }
.rescue-monitor { height: 30vh; min-height: 190px; border-color: #c7d2e0; }
.mon-status {
  position: absolute; left: 14px; top: 12px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(43, 45, 66, 0.85); color: #fff;
  font-size: 18px; font-weight: bold;
}
.mon-status.warn { background: #ff8c1a; animation: blink 1s infinite; }
.mon-status.ok { background: var(--green); }
@keyframes blink { 50% { opacity: 0.6; } }
.story p { margin: 0; padding: 12px 18px; border-radius: 16px; background: #fff; font-size: 22px; line-height: 1.5; }
.story p.aed { background: #e9f1ff; color: #1d4ea8; font-weight: bold; }
.step-count { font-size: 20px; font-weight: bold; color: var(--muted); }
.steps .opt { font-size: 22px; padding: 18px 10px; }
.opt.hint { border-color: var(--yellow); box-shadow: 0 5px 0 var(--yellow); animation: glow 0.8s infinite alternate; }
@keyframes glow { to { background: #fff3c4; } }
.shock-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 190px; height: 190px; margin: 0 auto;
  border-radius: 50%;
  background: #ff8c1a; color: #fff;
  font-size: 70px; line-height: 1;
  box-shadow: 0 8px 0 #c76400, 0 0 0 10px #ffe0bd;
  animation: pulse 1s infinite;
}
.shock-btn span { font-size: 30px; font-weight: bold; }
.shock-btn:disabled { animation: none; opacity: 0.6; }
@keyframes pulse { 50% { transform: scale(1.06); } }
.cpr { display: flex; align-items: center; justify-content: center; gap: 30px; }
.metro { width: 40px; height: 40px; border-radius: 50%; background: #f0e2d0; }
.metro.on { animation: flash 0.25s ease-out; }
@keyframes flash { from { background: var(--pink); transform: scale(1.3); } to { background: #f0e2d0; transform: scale(1); } }
.cpr-btn {
  width: 180px; height: 180px; border-radius: 50%;
  background: var(--pink); color: #fff; font-size: 40px; font-weight: bold;
  box-shadow: 0 8px 0 var(--pink-dark);
}
.cpr-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--pink-dark); }
.cpr-info { display: flex; flex-direction: column; gap: 8px; min-width: 260px; }
.cpr-info .count { font-size: 40px; }
.cpr-info .rate { font-size: 20px; color: var(--muted); }
.win { text-align: center; }
.win-icon { font-size: 80px; }


/* ---------- 实验室：开关和任务 ---------- */

.lab-col { display: flex; flex-direction: column; gap: 12px; }
.panel-title { margin: 0 0 4px; font-size: 16px; font-weight: bold; color: var(--muted); }
.sliders.dim .slider { opacity: 0.4; }
.mech-note { margin: 4px 0; font-size: 15px; color: var(--pink-dark); }
.sliders .big-btn { align-self: flex-start; margin-top: 4px; }
.mechs { display: flex; flex-direction: column; gap: 8px; background: #fff; border-radius: var(--radius); padding: 14px 16px; }
.switch > span { font-size: 16px; color: var(--muted); font-weight: bold; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.seg button { padding: 6px 11px; border-radius: 999px; background: #f6efe6; border: 2px solid #eadfd2; font-size: 14px; }
.seg button.on { background: var(--pink); border-color: var(--pink-dark); color: #fff; font-weight: bold; }

/* 右侧任务列表：按级别分组，可以滚动，任务再多也放得下 */
.tasks {
  position: sticky; top: calc(25vh + 12px);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 25vh - 170px); min-height: 320px;
  background: #fff; border-radius: var(--radius); overflow: hidden;
}
.task-head { padding: 12px 16px; border-bottom: 2px solid #f3eadf; }
.task-head p { margin: 4px 0; line-height: 1.45; }
.task-title { font-weight: bold; font-size: 18px; }
.task-title.done { color: var(--green); }
.task-hint { font-size: 15px; color: var(--ink); }
.task-label { font-size: 14px; color: var(--muted); }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.task-list { flex: 1; overflow-y: auto; padding: 6px 10px 12px; -webkit-overflow-scrolling: touch; }
.task-lv { position: sticky; top: 0; margin: 8px 0 4px; padding: 4px 10px; border-radius: 8px; font-size: 14px; font-weight: bold; color: #fff; }
.task-lv.lv1 { background: var(--green); }
.task-lv.lv2 { background: var(--blue); }
.task-lv.lv3 { background: var(--purple); }
.task-lv.lv4 { background: #e07a00; }
.task-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 9px 10px; margin: 2px 0;
  border-radius: 10px; background: none; text-align: left; font-size: 16px;
}
.task-item:active { background: #f6efe6; }
.task-item.now { background: #fff3c4; font-weight: bold; }
.task-item.ok { color: var(--green); }
.task-item.peek { color: var(--blue); }
.task-item i { font-style: normal; }

/* ---------- 知识判断题：标签缩小，题目放大 ---------- */

.quiz.fact .fact-card {
  height: auto; min-height: 0; align-self: center;
  padding: 8px 22px; border-radius: 999px; font-size: 20px;
}
.quiz.fact .question {
  min-height: 34vh; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 20px 40px; border-radius: var(--radius);
  background: linear-gradient(135deg, #fff7d6, #ffe3ea);
  font-size: 40px; line-height: 1.4;
}
.quiz.fact .tf-visual { display: flex; justify-content: center; }

/* ---------- 全屏按钮 ---------- */

.fs-icon { width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }


/* ---------- 12 导联 ---------- */

.monitor-box { display: flex; flex-direction: column; }
.ecg12 { border-radius: 14px; overflow: hidden; border: 3px solid #ffd0dc; background: #fff1f4; }
.ecg12 canvas { display: block; width: 100%; }
.lead-toggle {
  cursor: pointer; user-select: none;
  align-self: flex-end; margin-top: 6px;
  padding: 7px 16px; border-radius: 999px;
  background: #e9f1ff; color: #1d4ea8; border: 2px solid #b9d0ff;
  font-size: 16px; font-weight: bold;
}
.lead-toggle:active { transform: translateY(2px); }
.card { position: relative; }
.badge12 {
  position: absolute; top: 18px; left: 18px;
  padding: 2px 8px; border-radius: 8px;
  background: #e07a00; color: #fff; font-size: 12px; font-weight: bold;
}


/* ---------- 急救场景动画 ---------- */

.rescue-top { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.scene-wrap { height: 30vh; min-height: 190px; border-radius: 18px; overflow: hidden; border: 4px solid #cfe6ff; background: #e6f5ff; }
.scene { display: block; width: 100%; height: 100%; }
.scene .helper, .scene .hero, .scene .hero-arms, .scene .aed, .scene .patient { transition: transform 0.8s ease, opacity 0.4s; }
.scene .arms-reach, .scene .arms-up, .scene .phone, .scene .wires, .scene .pads,
.scene .eyes-open, .scene .eyes-closed { transition: opacity 0.35s; }

/* 拨打 120，然后跑去拿 AED */
.scene .phone { opacity: 0; }
.scene.calling .phone { opacity: 1; }
.scene.calling .waves { animation: sceneBlink 0.5s infinite; }
@keyframes sceneBlink { 50% { opacity: 0.15; } }
.scene.helper-away .helper { transform: translateX(-150px); }

/* AED：拿来、开机、分析 */
.scene .aed { opacity: 0; transform: translateX(-280px); }
.scene.has-aed .aed { opacity: 1; transform: none; }
.scene .aed-lid { transform-box: fill-box; transform-origin: left bottom; transition: transform 0.5s; }
.scene.aed-on .aed-lid { transform: rotate(-35deg); }
.scene.aed-on .aed-screen { fill: #4cff9a; }
.scene.analyzing .aed-screen { animation: sceneBlink 0.25s infinite; }
.scene .wires, .scene .pads { opacity: 0; }
.scene.pads-on .wires, .scene.pads-on .pads { opacity: 1; }

/* 小英雄：按压、拍肩、举手离开 */
.scene .arms-up { opacity: 0; }
.scene.standclear .arms-up, .scene.win .arms-up { opacity: 1; }
.scene.standclear .arms-reach, .scene.win .arms-reach { opacity: 0; }
.scene.standclear .hero, .scene.standclear .hero-arms { transform: translate(26px, -6px); }
.scene.standclear .helper { transform: translateX(-14px); }
.scene.press .hero, .scene.press .hero-arms { transform: translateY(6px); transition: transform 0.08s; }
.scene.tap .arms-reach { animation: tap 0.35s 2; }
@keyframes tap { 50% { transform: translate(16px, 3px); } }

/* 电击：闪电 + 身体弹一下 */
.scene .bolt { opacity: 0; }
.scene.bolt .bolt { animation: boltflash 0.7s; }
@keyframes boltflash { 0%, 100% { opacity: 0; } 15%, 45% { opacity: 1; } 30% { opacity: 0.2; } }
.scene.jolt .patient { animation: jolt 0.5s; }
@keyframes jolt { 20% { transform: translateY(-9px); } 40% { transform: translateY(2px); } 60% { transform: translateY(-4px); } }

/* 救活：睁眼、爱心、救护车 */
.scene .eyes-open, .scene .hearts, .scene .alert { opacity: 0; }
.scene.win .eyes-open, .scene.win .hearts { opacity: 1; }
.scene.win .eyes-closed { opacity: 0; }
.scene .hearts path { transform-box: fill-box; }
.scene.win .hearts path { animation: floatUp 2.2s ease-in infinite; }
.scene.win .hearts .h2 { animation-delay: 0.7s; }
.scene.win .hearts .h3 { animation-delay: 1.4s; }
@keyframes floatUp { 0% { transform: translateY(10px); opacity: 0; } 30% { opacity: 1; } 100% { transform: translateY(-55px); opacity: 0; } }
.scene .amb { opacity: 0; transform: translateX(150px); }
.scene.win .amb { opacity: 1; transform: none; transition: transform 1.6s ease-out, opacity 0.3s; }
.scene.win .siren { animation: siren 0.5s infinite; }
@keyframes siren { 50% { fill: #3a86ff; } }

/* 开场的“！”和对话气泡 */
.scene.notice .alert { opacity: 1; animation: hop 0.5s infinite alternate; }
@keyframes hop { to { transform: translateY(-6px); } }
.scene .bubble { opacity: 0; transition: opacity 0.2s; }
.scene .bubble.show { opacity: 1; }


/* ---------- 心跳节奏大师 ---------- */

.c7 { background: #ff6fb5; }
.beat-pick { max-width: 1100px; margin: 0 auto; text-align: center; }
.beat-pick h2 { font-size: 32px; margin: 10px 0; }
.beat-stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 18px; }
.beat-stage {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 18px 12px; border-radius: var(--radius);
  background: #fff; border: 4px solid #ffd0e6; box-shadow: 0 5px 0 #ffd0e6;
}
.beat-stage:active { transform: translateY(3px); box-shadow: 0 2px 0 #ffd0e6; }
.beat-stage b { font-size: 22px; }
.beat-stage small { font-size: 14px; color: var(--muted); line-height: 1.4; }
.beat-icon { font-size: 42px; line-height: 1; }
.beat-stars { font-size: 22px; letter-spacing: 2px; }
.beat-game { max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.beat-hud { display: flex; justify-content: space-between; align-items: center; font-size: 22px; font-weight: bold; }
.beat-hud .combo { color: #ff8c1a; }
.beat-track { height: 30vh; min-height: 190px; border-radius: 18px; overflow: hidden; border: 4px solid #ffd0dc; touch-action: none; }
.beat-track canvas { display: block; width: 100%; height: 100%; }
.beat-pad { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.beat-tip { margin: 0; font-size: 20px; color: var(--muted); }
.beat-btn {
  width: 100%; max-width: 640px; padding: 26px; border-radius: 999px;
  background: var(--pink); color: #fff; font-size: 40px; font-weight: bold;
  box-shadow: 0 8px 0 var(--pink-dark); touch-action: none;
}
.beat-btn:active { transform: translateY(6px); box-shadow: 0 2px 0 var(--pink-dark); }
.beat-result { text-align: center; }
.beat-result h2 { font-size: 34px; margin: 6px 0; }
.beat-result p { font-size: 20px; margin: 6px 0; }
.mode-grid { grid-template-columns: repeat(4, 1fr); }

.beat-stages { grid-template-columns: repeat(3, 1fr); }
.theme-bubble .beat-track { border-color: #9fd3ff; }
.theme-hero .beat-track { border-color: #ff9aa8; }
.theme-arcade .beat-track { border-color: #c3a6ff; }
.beat-stage.endless { border-color: #ffd98a; box-shadow: 0 5px 0 #ffd98a; background: #fffaf0; }
.beat-stage.casual { border-color: #a8dfb5; box-shadow: 0 5px 0 #a8dfb5; background: #f5fff6; }
.casual-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 850px; margin: 24px auto; }
.casual-option { display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 18px; border: 3px solid #ffd0e6; border-radius: var(--radius); background: #fff; font-size: 20px; font-weight: bold; text-align: left; }
.casual-option input { width: 24px; height: 24px; accent-color: var(--pink); }
.casual-error { color: #d52c51; font-weight: bold; }
.casual-actions { justify-content: center; gap: 14px; }
.beat-hud { gap: 10px; flex-wrap: wrap; }
.beat-hud .hearts { font-size: 22px; letter-spacing: 1px; }
.mascot { font-size: 36px; line-height: 1; display: inline-block; }
.mascot.bounce { animation: beat 0.35s ease-out; }
.beat-game.fever .beat-track { border-color: #ffbe0b; box-shadow: 0 0 18px #ffd84d; }
.beat-game.fever .combo { animation: hop 0.4s infinite alternate; }
.beat-btns { display: flex; gap: 16px; width: 100%; max-width: 760px; }
.beat-btns .beat-btn { flex: 1; }
.beat-btn.normal { background: #ff4d6d; box-shadow: 0 8px 0 #c9304f; }
.beat-btn.early { background: #8338ec; box-shadow: 0 8px 0 #5e22b0; }
.beat-shock {
  padding: 20px 60px; border-radius: 999px; background: #ff8c1a; color: #fff;
  font-size: 36px; font-weight: bold; box-shadow: 0 8px 0 #c76400; animation: pulse 0.6s infinite; touch-action: none;
}

.beat-record { font-size: 16px; font-weight: bold; color: #b06d00; }
.beat-hud .best { font-size: 16px; color: #b06d00; }
.beat-result .record { font-size: 20px; font-weight: bold; color: #b06d00; }
.beat-result .record.new { color: #ff5c8a; animation: pop 0.4s ease-out; }

/* 竖屏或较窄屏幕的兜底 */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .options.n4 { grid-template-columns: repeat(2, 1fr); }
  .mode-grid { grid-template-columns: 1fr; }
  .feedback { flex-direction: column; }
  .lab-body, .lab.free .lab-body { grid-template-columns: 1fr; }
  .tasks { position: static; max-height: 60vh; }
  .cpr { flex-wrap: wrap; }
  .rescue-top { grid-template-columns: 1fr; }
  .beat-stages { grid-template-columns: 1fr 1fr; }
  .casual-options { grid-template-columns: 1fr 1fr; }
  .quiz.fact .question { font-size: 28px; padding: 16px 20px; min-height: 26vh; }
}

/* 检查更新的提示条 */
#update-bar { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 8px); transform: translateX(-50%); z-index: 50; padding: 12px 22px; border-radius: 999px; background: #2b2d42; color: #fff; font-size: 18px; font-weight: bold; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
