: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); }
.task-label { margin: 0 0 8px !important; color: var(--muted); font-size: 16px !important; }
.task-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.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 { width: 280px; }
.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); }
.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-body { display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px; }
.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); }
.sliders .big-btn { align-self: flex-start; }
.lab-side { display: flex; flex-direction: column; gap: 14px; }
.task, .detect { background: #fff; border-radius: var(--radius); padding: 14px 20px; }
.task p { margin: 6px 0; font-size: 20px; line-height: 1.5; }
.task-title { font-weight: bold; font-size: 22px !important; }
.task-title.done { color: var(--green); }
.detect-label { margin: 0; color: var(--muted); font-size: 16px; }
.detect-name { margin: 4px 0; font-size: 32px; 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 { 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; }

/* 竖屏或较窄屏幕的兜底 */
@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 { grid-template-columns: 1fr; }
  .cpr { flex-wrap: wrap; }
}
