:root {
  --bg: #0f1020;
  --bg2: #1a1c3a;
  --card: #232544;
  --accent: #ff5d73;
  --accent2: #ffd23f;
  --good: #3ddc97;
  --panic: #ff3b3b;
  --text: #f4f4ff;
  --muted: #9aa0c7;
  --radius: 18px;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

#app {
  max-width: 520px;
  height: 100dvh;
  margin: 0 auto;
  position: relative;
  background: radial-gradient(120% 90% at 50% 0%, var(--bg2), var(--bg));
  overflow: hidden;
}

/* ===== SCREENS ===== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 18px;
  opacity: 0;
  transform: translateX(30px);
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease;
}
.screen.active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ===== HOME ===== */
.home-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,93,115,.18), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,210,63,.14), transparent 40%);
  pointer-events: none;
}
.home-header { text-align: center; margin-top: 8vh; z-index: 1; }
.logo-bounce { font-size: 76px; animation: bounce 1.6s ease-in-out infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-14px)} }
.title {
  font-size: 46px; font-weight: 900; margin: 6px 0 0;
  letter-spacing: 2px; text-shadow: 0 4px 0 rgba(0,0,0,.25);
}
.title span { color: var(--accent2); }
.subtitle {
  margin: 2px 0 0; color: var(--accent);
  font-weight: 700; font-style: italic; letter-spacing: 1px;
}
.home-menu {
  margin-top: auto; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 14px; z-index: 1;
}
.disclaimer-mini { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 6px; }

/* ===== BUTTONS ===== */
.btn {
  border: none; border-radius: var(--radius);
  padding: 16px 18px; font-size: 18px; font-weight: 800;
  color: #16172b; cursor: pointer; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.96); }
.btn-emoji { font-size: 22px; }
.btn-play { background: var(--accent2); }
.btn-panic { background: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); box-shadow: none; border: 1.5px solid #34376a; }
.btn-replay { background: var(--good); }

/* ===== TOPBAR ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.topbar h2 { font-size: 20px; margin: 0; flex: 1; text-align: center; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none;
  background: var(--card); color: var(--text); font-size: 20px; cursor: pointer;
}
.icon-btn:active { transform: scale(.92); }
.score-pill {
  background: var(--card); padding: 8px 14px; border-radius: 999px;
  font-weight: 800; font-size: 15px; white-space: nowrap;
}

/* ===== LEVEL LIST ===== */
.level-list { display: flex; flex-direction: column; gap: 14px; flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 20px; }
.level-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  box-shadow: var(--shadow); border: 1.5px solid transparent;
  transition: transform .08s ease, border-color .15s ease;
  flex: none;
}
.level-card:active { transform: scale(.98); }
.level-card .lv-emoji { font-size: 40px; }
.level-card .lv-info { flex: 1; }
.level-card .lv-info h3 { margin: 0 0 4px; font-size: 17px; }
.level-card .lv-info p { margin: 0; color: var(--muted); font-size: 13px; }
.level-card .lv-stars { color: var(--accent2); font-size: 16px; letter-spacing: 1px; }

/* ===== GAME ===== */
.game-screen { padding-bottom: 0; }
.game-stage {
  flex: 1; position: relative; border-radius: var(--radius);
  background: linear-gradient(180deg, #16183a, #101227);
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.character {
  font-size: 110px; line-height: 1; transition: transform .15s ease, opacity .4s ease;
}
.character.pulse { animation: cprPulse .25s ease; }
@keyframes cprPulse { 0%{transform:scale(1)} 50%{transform:scale(.84)} 100%{transform:scale(1)} }
.character.dead { animation: logout 1s forwards; }
@keyframes logout {
  0%{transform:rotate(0) scale(1); opacity:1}
  40%{transform:rotate(-12deg) scale(1.05)}
  100%{transform:rotate(180deg) scale(.3) translateY(120px); opacity:0}
}
.character.win { animation: winJump .6s ease infinite alternate; }
@keyframes winJump { from{transform:translateY(0)} to{transform:translateY(-20px) rotate(6deg)} }

.beat-ring {
  position: absolute; top: 50%; left: 50%;
  width: 180px; height: 180px; margin: -90px 0 0 -90px;
  border: 4px solid var(--accent2); border-radius: 50%;
  opacity: 0; pointer-events: none;
}
.beat-ring.go { animation: ring 1s linear infinite; }
@keyframes ring { 0%{transform:scale(.4);opacity:.9} 100%{transform:scale(1.1);opacity:0} }

.float-text {
  position: absolute; font-weight: 900; font-size: 26px; pointer-events: none;
  animation: floatUp .8s ease forwards;
}
@keyframes floatUp { from{transform:translateY(0);opacity:1} to{transform:translateY(-60px);opacity:0} }

.progress-bar { position: absolute; top: 10px; left: 12px; right: 12px; height: 12px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--good); transition: width .2s ease; }

.tilt-meter {
  position: absolute; bottom: 16px; left: 12px; right: 12px; height: 22px;
  background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden;
}
.tilt-zone { position: absolute; top: 0; bottom: 0; background: rgba(61,220,151,.35); }
.tilt-knob { position: absolute; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--accent2); transform: translateX(-50%); transition: left .08s linear; }

.game-instruction {
  text-align: center; font-size: 15px; color: var(--text);
  min-height: 22px; margin-bottom: 10px; font-weight: 600;
}
.game-controls { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; }
.tap-zone {
  height: 96px; border-radius: var(--radius); background: var(--accent);
  color: #fff; font-size: 22px; font-weight: 900; display: flex;
  align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow);
}
.tap-zone:active { transform: scale(.97); filter: brightness(1.1); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  background: var(--card); border: 1.5px solid #34376a; border-radius: 14px;
  padding: 16px 10px; font-size: 15px; font-weight: 700; color: var(--text); cursor: pointer; text-align: center;
}
.choice:active { transform: scale(.97); }
.choice.correct { background: var(--good); color:#06281b; border-color: var(--good); }
.choice.wrong { background: var(--accent); color:#fff; border-color: var(--accent); }

/* ===== RESULT OVERLAY ===== */
.result-overlay {
  position: absolute; inset: 0; background: rgba(10,11,26,.95);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 12px; text-align: center; padding: 28px 24px; z-index: 30; animation: fadeIn .3s ease;
  overflow-y: auto;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }
.result-overlay .r-emoji { font-size: 90px; }
.result-overlay h2 { margin: 0; font-size: 28px; }
.result-overlay p { margin: 0; color: var(--muted); max-width: 320px; }
.result-stars { font-size: 34px; color: var(--accent2); letter-spacing: 4px; }
.result-overlay .btn { width: 220px; }
.lesson-box {
  background: var(--card); border-radius: 14px; padding: 14px 16px;
  font-size: 14px; color: var(--text); max-width: 340px; border-left: 4px solid var(--good);
}

/* ===== PANIC ===== */
.panic-screen { background: linear-gradient(180deg,#2a0d12,#150a14); }
.panic-topbar h2 { color: var(--panic); font-weight: 900; }
.panic-pick { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.panic-lead { text-align: center; color: var(--muted); margin: 6px 0 8px; }
.panic-card {
  background: var(--card); border: 2px solid #4a2030; border-radius: var(--radius);
  padding: 20px 16px; font-size: 19px; font-weight: 800; color: var(--text);
  cursor: pointer; text-align: left; flex: none;
}
.panic-card:active { transform: scale(.98); }
.panic-call {
  margin-top: 8px; background: var(--panic); color: #fff; text-align: center;
  padding: 18px; border-radius: var(--radius); font-size: 20px; font-weight: 900;
  text-decoration: none; box-shadow: var(--shadow); animation: pulseRed 1.4s infinite; flex: none;
}
.panic-call.small { animation: none; padding: 14px; font-size: 17px; margin-top: auto; }
@keyframes pulseRed { 0%,100%{box-shadow:0 0 0 0 rgba(255,59,59,.5)} 50%{box-shadow:0 0 0 14px rgba(255,59,59,0)} }

.panic-steps { display: flex; flex-direction: column; align-items: center; gap: 16px; height: 100%; }
.metronome-ring {
  width: 130px; height: 130px; border-radius: 50%; border: 6px solid #4a2030;
  display: flex; align-items: center; justify-content: center; font-size: 40px;
  color: var(--accent2); margin-top: 8px; transition: border-color .1s, transform .1s;
}
.metronome-ring.beat { border-color: var(--accent2); transform: scale(1.08); }
.panic-step-text {
  font-size: 24px; font-weight: 800; text-align: center; line-height: 1.4;
  flex: 1; display: flex; align-items: center; padding: 0 6px;
}
.panic-nav { display: flex; gap: 12px; width: 100%; }
.panic-nav .btn { flex: 1; }
.panic-steps .btn-replay, .panic-steps .btn-ghost { width: 100%; }

/* ===== ABOUT ===== */
.about-body { overflow-y: auto; line-height: 1.6; font-size: 15.5px; }
.about-body p { margin: 0 0 14px; }
.about-warn {
  background: rgba(255,59,59,.12); border: 1.5px solid var(--panic);
  border-radius: 14px; padding: 14px; font-size: 14px; line-height: 1.5;
}

.hidden { display: none !important; }

/* ===== HOME EXTRAS ===== */
.home-row { display: flex; gap: 12px; }
.home-row .btn { flex: 1; padding: 14px 10px; font-size: 16px; }
.settings-gear {
  position: absolute; top: 16px; right: 16px; z-index: 2;
  width: 44px; height: 44px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.08); color: var(--text); font-size: 22px; cursor: pointer;
}
.settings-gear:active { transform: rotate(40deg); }

/* ===== SETTINGS MODAL ===== */
.modal {
  position: fixed; inset: 0; z-index: 50; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(8,9,20,.75); animation: fadeIn .2s ease;
}
.modal-card {
  background: var(--card); border-radius: 20px; padding: 22px;
  width: 100%; max-width: 360px; box-shadow: var(--shadow);
}
.modal-card h2 { margin: 0 0 16px; text-align: center; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px; font-size: 16px; font-weight: 600;
  border-bottom: 1px solid #34376a;
}
.toggle-row input { width: 52px; height: 30px; appearance: none; background: #3a3d70; border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; }
.toggle-row input:checked { background: var(--good); }
.toggle-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; }
.toggle-row input:checked::after { left: 25px; }
.modal-card .btn { margin-top: 18px; width: 100%; }

/* ===== STREAK BANNER ===== */
.streak-banner {
  background: linear-gradient(90deg, rgba(255,210,63,.18), rgba(255,93,115,.14));
  border: 1.5px solid #4a4632; border-radius: 14px;
  padding: 12px 14px; margin-bottom: 14px; font-weight: 700; font-size: 14.5px;
  display: flex; align-items: center; gap: 8px;
}
.streak-banner.empty { display: none; }

/* ===== ACHIEVEMENTS ===== */
.ach-body { overflow-y: auto; padding-bottom: 20px; }
.ach-stats {
  display: flex; gap: 12px; margin-bottom: 18px;
}
.ach-stat {
  flex: 1; background: var(--card); border-radius: 16px; padding: 16px 10px;
  text-align: center; box-shadow: var(--shadow);
}
.ach-stat .num { font-size: 30px; font-weight: 900; color: var(--accent2); }
.ach-stat .lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ach-section-title { font-size: 15px; color: var(--muted); margin: 6px 0 10px; font-weight: 700; }
.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.badge {
  background: var(--card); border-radius: 16px; padding: 14px; text-align: center;
  border: 1.5px solid transparent; opacity: .45; filter: grayscale(1);
}
.badge.unlocked { opacity: 1; filter: none; border-color: var(--accent2); }
.badge .b-emoji { font-size: 38px; }
.badge .b-name { font-weight: 800; font-size: 14px; margin: 6px 0 2px; }
.badge .b-desc { font-size: 12px; color: var(--muted); line-height: 1.3; }

/* ===== COMBO ===== */
.combo-tag {
  position: absolute; top: 30px; right: 14px; font-weight: 900; font-size: 20px;
  color: var(--accent2); text-shadow: 0 2px 0 rgba(0,0,0,.3); transition: transform .1s;
}
.combo-tag.bump { transform: scale(1.35); }

/* ===== GAME: HOSE (xả nước chữa bỏng) ===== */
.wound {
  position: absolute; font-size: 90px; transition: filter .2s;
  touch-action: none;
}
.water-stream {
  position: absolute; font-size: 60px; pointer-events: none;
  transform: translate(-50%, -90%); transition: opacity .1s; opacity: 0;
}
.water-stream.on { opacity: 1; }
.cool-label {
  position: absolute; bottom: 44px; left: 12px; right: 12px; text-align: center;
  font-weight: 800; font-size: 15px; color: var(--good);
}

/* ===== GAME: PRESS (cầm máu) ===== */
.gauze {
  position: absolute; font-size: 56px; touch-action: none; cursor: grab;
  transition: transform .1s;
}
.drop-target {
  position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px;
  border: 3px dashed var(--good); border-radius: 50%; opacity: .8;
}
.force-wrap { margin-bottom: 12px; }
.force-track { height: 26px; background: rgba(255,255,255,.1); border-radius: 999px; overflow: hidden; position: relative; }
.force-good-zone { position: absolute; top: 0; bottom: 0; left: 55%; right: 8%; background: rgba(61,220,151,.3); }
.force-fill { height: 100%; width: 0; background: var(--accent); transition: width .06s linear; }
.force-hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 6px; }

/* ===== SPLASH SCREEN ===== */
.splash {
  position: absolute; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: radial-gradient(120% 90% at 50% 30%, var(--bg2), var(--bg));
  transition: opacity .5s ease, visibility .5s ease;
}
.splash.gone { opacity: 0; visibility: hidden; }
.splash-logo { font-size: 96px; animation: splashPop .6s cubic-bezier(.2,1.4,.4,1) both, bounce 1.6s 1s ease-in-out infinite; }
@keyframes splashPop { from { transform: scale(0) rotate(-30deg); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.splash-title { font-size: 40px; font-weight: 900; letter-spacing: 2px; animation: fadeIn .5s .3s both; }
.splash-title span { color: var(--accent2); }
.splash-sub { color: var(--accent); font-weight: 700; font-style: italic; animation: fadeIn .5s .5s both; }
.splash-bar { width: 180px; height: 6px; background: rgba(255,255,255,.12); border-radius: 999px; overflow: hidden; margin-top: 18px; }
.splash-bar-fill { height: 100%; width: 0; background: var(--accent2); border-radius: 999px; animation: loadbar 1.3s .3s ease forwards; }
@keyframes loadbar { to { width: 100%; } }

/* ===== TUTORIAL OVERLAY ===== */
.tutorial {
  position: absolute; inset: 0; z-index: 60; display: flex;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(8,9,20,.82); animation: fadeIn .25s ease;
}
.tutorial-card {
  background: var(--card); border-radius: 22px; padding: 26px 22px; text-align: center;
  max-width: 360px; width: 100%; box-shadow: var(--shadow); border: 1.5px solid #34376a;
  animation: cardIn .35s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes cardIn { from { transform: translateY(24px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.tut-emoji { font-size: 72px; animation: bobFloat 2s ease-in-out infinite; }
.tutorial-card h2 { margin: 8px 0 10px; }
.tutorial-card p { color: var(--text); line-height: 1.55; font-size: 15.5px; margin: 0 0 20px; }
.tutorial-card .btn { width: 100%; }

/* ===== CHARACTER IDLE LIFE ===== */
.character { animation: bobFloat 2.4s ease-in-out infinite; }
@keyframes bobFloat { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }

/* nhịp vào màn của các thẻ level */
.level-card { animation: cardIn .3s ease both; }
.level-card:nth-child(2) { animation-delay: .03s; }
.level-card:nth-child(3) { animation-delay: .06s; }
.level-card:nth-child(4) { animation-delay: .09s; }
.level-card:nth-child(5) { animation-delay: .12s; }

/* chuyển màn mượt hơn */
.screen { transition: opacity .3s ease, transform .32s cubic-bezier(.2,.9,.3,1); }

/* ===== SOURCES ===== */
.src-item {
  background: var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px;
  border-left: 4px solid var(--good);
}
.src-item h3 { margin: 0 0 6px; font-size: 16px; }
.src-item p { margin: 0 0 8px; font-size: 14px; color: var(--text); line-height: 1.5; }
.src-item a {
  display: inline-block; margin: 2px 10px 2px 0; font-size: 13.5px; font-weight: 700;
  color: var(--accent2); text-decoration: none;
}
.src-item a:active { opacity: .7; }

/* ===== I18N ===== */
body.lang-en .only-vi { display: none; }
body:not(.lang-en) .only-en { display: none; }
.lang-switch { display: flex; gap: 6px; }
.lang-opt {
  padding: 6px 14px; border-radius: 10px; border: 1.5px solid #34376a;
  background: transparent; color: var(--muted); font-weight: 800; cursor: pointer;
}
.lang-opt.active { background: var(--accent2); color: #16172b; border-color: var(--accent2); }

/* ===== TOAST ===== */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  background: #2b2e57; color: var(--text); padding: 12px 20px; border-radius: 999px;
  font-weight: 700; font-size: 14.5px; box-shadow: var(--shadow); z-index: 120;
  opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none;
  max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== ACCESSIBILITY ===== */

/* Hiện rõ viền focus khi điều hướng bàn phím */
:focus-visible {
  outline: 3px solid #8ab4ff;
  outline-offset: 2px;
  border-radius: 8px;
}

/* Vùng chỉ dành cho trình đọc màn hình */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Giảm chuyển động: theo cài đặt hệ điều hành hoặc bật trong app */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
body.a11y-reduce *, body.a11y-reduce *::before, body.a11y-reduce *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
/* vẫn giữ nhịp metronome & vòng beat vì là chức năng (dẫn nhịp CPR) */
body.a11y-reduce .beat-ring.go { animation: ring 1s linear infinite !important; }
body.a11y-reduce .metronome-ring.beat { transition: none; }

/* Tương phản cao */
body.a11y-contrast {
  --text: #ffffff;
  --muted: #d6daf5;
  --bg: #000010;
  --card: #1c1e3e;
}
body.a11y-contrast .level-card,
body.a11y-contrast .src-item,
body.a11y-contrast .panic-card,
body.a11y-contrast .choice { border: 2px solid #c9cee8; }
body.a11y-contrast .btn-ghost { border-color: #c9cee8; color: #fff; }
body.a11y-contrast .disclaimer-mini,
body.a11y-contrast .game-instruction { color: #eef0ff; }

/* Chữ lớn */
body.a11y-large .btn { font-size: 20px; }
body.a11y-large .panic-step-text { font-size: 28px; }
body.a11y-large .panic-card { font-size: 21px; }
body.a11y-large .choice { font-size: 17px; }
body.a11y-large .game-instruction { font-size: 17px; }
body.a11y-large .level-card .lv-info h3 { font-size: 19px; }
body.a11y-large .level-card .lv-info p { font-size: 15px; }
body.a11y-large .about-body { font-size: 17.5px; }
body.a11y-large .topbar h2 { font-size: 22px; }
body.a11y-large .result-overlay p,
body.a11y-large .lesson-box { font-size: 16px; }

/* Chế độ nghiêm túc: bỏ animation "đăng xuất" quay lộn, thay bằng mờ dần nhẹ */
body.mode-serious .character.dead { animation: seriousFade .8s forwards; }
@keyframes seriousFade { to { opacity: .25; filter: grayscale(1); } }

/* ===== SURVIVAL MODE ===== */
.survival-card {
  background: linear-gradient(100deg, rgba(255,210,63,.16), rgba(255,93,115,.16));
  border: 1.5px solid var(--accent2);
}
.survival-card .lv-stars { color: var(--accent2); font-size: 22px; }
.surv-score {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -160%);
  font-size: 64px; font-weight: 900; color: var(--accent2);
  text-shadow: 0 3px 0 rgba(0,0,0,.3);
}

/* ===== VOICE PICKER ===== */
.voice-select {
  background: var(--bg2); color: var(--text); border: 1.5px solid #34376a;
  border-radius: 10px; padding: 8px 10px; font-size: 14px; max-width: 58%;
}
.voice-warn {
  background: rgba(255,210,63,.12); border: 1px solid var(--accent2); border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; line-height: 1.45; color: var(--text); margin: 8px 0 0;
}

/* ===== EMERGENCY TOOLKIT ===== */
.btn-tools { background: #4ea1ff; color: #06203f; }
.emerg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 24px; display: flex; flex-direction: column; gap: 16px; }
.emerg-card {
  background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow); flex: none;
}
.emerg-card h3 { margin: 0 0 4px; font-size: 18px; }
.emerg-sub { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; line-height: 1.45; }

/* máy đếm nhịp */
.metro-ring2 {
  width: 150px; height: 150px; border-radius: 50%; border: 8px solid #3a3d70;
  display: flex; align-items: center; justify-content: center; margin: 6px auto 16px;
  font-size: 44px; font-weight: 900; color: var(--accent2); transition: transform .08s, border-color .08s;
}
.metro-ring2.beat { border-color: var(--accent); transform: scale(1.09); color: var(--accent); }
#metro-toggle { width: 100%; }

/* số khẩn cấp */
.num-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.num-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--bg2); border: 1.5px solid #34376a; border-radius: 14px;
  padding: 14px 8px; text-decoration: none; color: var(--text);
}
.num-btn b { font-size: 30px; color: #4ea1ff; }
.num-btn span { font-size: 12.5px; color: var(--muted); text-align: center; }
.num-btn:active { transform: scale(.97); }
.num-btn.num-115 { border-color: var(--panic); }
.num-btn.num-115 b { color: var(--panic); }

/* thẻ y tế */
#medcard-view { font-size: 15px; line-height: 1.7; margin-bottom: 14px; }
#medcard-view .mc-row { display: flex; gap: 8px; }
#medcard-view .mc-row b { min-width: 110px; color: var(--muted); font-weight: 600; }
#medcard-view .mc-empty { color: var(--muted); font-style: italic; }
#medcard-view .mc-blood { display: inline-block; background: var(--panic); color: #fff; font-weight: 800; padding: 2px 12px; border-radius: 999px; }
.mc-call {
  display: inline-flex; gap: 8px; align-items: center; margin-top: 8px;
  background: var(--good); color: #06281b; font-weight: 800; padding: 12px 16px;
  border-radius: 12px; text-decoration: none;
}
#medcard-edit { width: 100%; }
.medcard-form { display: flex; flex-direction: column; gap: 14px; }
.medcard-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; }
.medcard-form input, .medcard-form select, .medcard-form textarea {
  background: var(--bg2); color: var(--text); border: 1.5px solid #34376a;
  border-radius: 10px; padding: 11px 12px; font-size: 15px; font-family: inherit; resize: vertical;
}
.medcard-form .btn { margin-top: 6px; }

/* ===== HANDBOOK (cẩm nang tra cứu) ===== */
.hb-lead { color: var(--muted); font-size: 13.5px; line-height: 1.45; margin: 0 0 14px; }
.handbook-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 24px; display: flex; flex-direction: column; gap: 10px; }
.hb-item { flex: none; background: var(--card); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.hb-head {
  width: 100%; text-align: left; background: transparent; border: none; color: var(--text);
  font-size: 16px; font-weight: 800; padding: 15px 16px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.hb-head .hb-arrow { color: var(--muted); transition: transform .2s; flex: none; }
.hb-item.open .hb-head .hb-arrow { transform: rotate(90deg); }
.hb-steps { padding: 0 18px 14px 22px; margin: 0; display: none; }
.hb-item.open .hb-steps { display: block; animation: fadeIn .2s ease; }
.hb-steps li { margin: 0 0 8px; line-height: 1.5; font-size: 14.5px; }
.hb-steps li::marker { color: var(--accent2); font-weight: 800; }
