/* Layout: one phone-width column (max 480px); game scenes stacked: HUD, stage (bg + patient), tabs, panel, footer. Single deliberate look: KMA navy + scrub teal on warm sand. */
:root {
  --navy: #01014b;
  --teal: #2e8b88;
  --sand: #f4eee3;
  --card: #fffdf8;
  --ink: #16163a;
  --muted: #6b6a80;
  --line: #e3d9c6;
  --good: #1d7a55;
  --good-bg: #e3f3ea;
  --bad: #b3261e;
  --bad-bg: #fbe7e4;
  --warn: #9a6200;
  --warn-bg: #fff2d2;
  --yel: #f2c14e;
  --fa:
    "Poppins", "IBM Plex Sans Arabic", Tahoma, system-ui, sans-serif; /* English → Poppins, Arabic → IBM Plex Sans Arabic (Poppins has no Arabic glyphs) */
  --fd: "Montserrat", "Cairo", Tahoma, sans-serif; /* headings: English → Montserrat, Arabic → Cairo */
  --fr: var(--fa);
  --fm: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  background: var(--navy);
  color: var(--ink);
  font: 15px/1.6 var(--fa);
  direction: rtl;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:focus-visible {
  outline: 3px solid var(--yel);
  outline-offset: 2px;
}
button.primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  font-weight: 700;
}
button.ghost {
  background: rgba(255, 253, 248, 0.92);
}
button.small {
  min-height: 34px;
  padding: 4px 10px;
  font-size: 0.85rem;
}
button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--sand);
  position: relative;
  overflow: hidden;
}
.en,
[dir="ltr"] {
  font-family: var(--fa);
  unicode-bidi: isolate;
}
.clock b,
.ecgwrap,
.tape b {
  font-family: var(--fm);
}
.term {
  color: var(--teal);
  font-family: var(--fa);
  font-weight: 600;
  font-size: 0.94em;
  unicode-bidi: isolate;
  white-space: normal;
}
.toast .term,
.sharein .term {
  color: inherit;
}
.muted {
  color: var(--muted);
}
.center {
  text-align: center;
}
.strong {
  font-weight: 700;
}
.pill {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.8rem;
}

/* title */
.bar {
  height: 8px;
  background: var(--line);
  border-radius: 6px;
  overflow: hidden;
  margin: 4px 0;
}
.bar i {
  display: block;
  height: 100%;
  background: var(--teal);
}
.menu {
  display: grid;
  gap: 8px;
}

/* case */
.case {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-size: cover;
  background-position: center top;
}
.hud {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(1, 1, 75, 0.92);
  color: #fff;
}
.hud img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.clock {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: var(--navy);
  border-radius: 10px;
  padding: 2px 10px;
}
.clock b {
  font: 600 1.05rem var(--fm);
}
.meter {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 70px;
}
.meter > span:last-child {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 6px;
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
}
.hp i {
  background: #5fd38d;
}
.ang i {
  background: #ff7a59;
}
.love i {
  background: #e2557a;
}
.meter.love > span:last-child {
  background: var(--line);
}
.chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  padding: 2px 10px 2px 6px;
  font-weight: 700;
  font-size: 0.85rem;
}
.chip img {
  width: 18px;
  height: 18px;
}
.stage {
  position: relative;
  height: 42vh;
  min-height: 250px;
  max-height: 380px;
}
.patient {
  position: absolute;
  bottom: 0;
  inset-inline-start: 50%;
  transform: translateX(50%);
  height: 100%;
  max-width: 70%;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
}
.nameplate {
  position: absolute;
  bottom: 10px;
  inset-inline-start: 12px;
  background: var(--card);
  border-radius: 10px;
  padding: 4px 10px;
  display: grid;
  font-size: 0.85rem;
  box-shadow: 0 2px 0 var(--line);
}
.family {
  position: absolute;
  bottom: 0;
  inset-inline-end: 0;
  width: 38%;
  display: grid;
  justify-items: center;
}
.family img {
  width: 100%;
  max-height: 170px;
  object-fit: contain;
}
.fbtns {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 0 4px 8px;
}
.warnb {
  background: var(--warn-bg);
  border-color: var(--warn);
}
.panel {
  flex: 1;
  background: var(--sand);
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) 90px max(12px, env(safe-area-inset-left, 0px));
}
.list {
  display: grid;
  gap: 8px;
}
.q {
  justify-content: space-between;
  text-align: start;
  width: 100%;
  flex-wrap: wrap;
}
.q > span {
  display: grid;
  flex: 1;
  min-width: 0;
}
.q small {
  color: var(--muted);
  font-size: 0.75rem;
}
.q em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.8rem;
}
.q em.ready {
  color: var(--good);
  font-weight: 700;
}
.q em.na {
  color: var(--bad);
}
.q.done {
  background: #f0ebe0;
}
.q.done em {
  flex-basis: 100%;
  color: var(--ink);
}
.q.tx.must,
.q.tx.ok {
  background: var(--good-bg);
  border-color: var(--good);
}
.q.tx.avoid {
  background: var(--bad-bg);
  border-color: var(--bad);
}
.q.tx.avoid em {
  color: var(--bad);
}
.q img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: var(--sand);
}
.ex {
  flex-direction: column;
  align-items: flex-start;
  min-height: 64px;
}
.ex span {
  color: var(--muted);
  font-size: 0.85rem;
}
.ex.done span {
  color: var(--ink);
}
.qhead {
  font-weight: 700;
  margin: 4px 0 8px;
}
.opts {
  display: grid;
  gap: 8px;
}
.opt {
  justify-content: flex-start;
  text-align: start;
}
.opt.right {
  background: var(--good-bg);
  border-color: var(--good);
}
.opt.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
}
.goodt {
  color: var(--good);
  font-weight: 700;
}
.badt {
  color: var(--bad);
  font-weight: 700;
}
.callbox {
  display: flex;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  margin-top: 10px;
}
.callbox img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: var(--sand);
  flex: none;
}
.callbox p {
  margin: 4px 0;
}

/* modal & toast */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(1, 1, 75, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--card);
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  overflow: auto;
  border-radius: 20px 20px 0 0;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px))
    max(16px, env(safe-area-inset-left, 0px));
  position: relative;
}
.modal.wide .sheet {
  max-width: 760px;
}
.sheet h2 {
  font: 800 1.3rem var(--fd);
  margin: 0 0 10px;
  color: var(--navy);
}
.x {
  position: absolute;
  top: 10px;
  inset-inline-end: 10px;
  width: 40px;
  height: 40px;
  min-height: 40px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.3rem;
}
.intro {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.intro img {
  width: 42%;
  max-height: 300px;
  object-fit: contain;
}
.intro blockquote {
  margin: 8px 0 12px;
  border-inline-start: 4px solid var(--teal);
  padding: 6px 10px;
  background: var(--sand);
  border-radius: 8px;
}
.big {
  width: 160px;
  max-width: 60%;
}
.warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-radius: 10px;
  padding: 8px 10px;
}
p.en.big {
  font-size: 1.1rem;
  font-weight: 600;
  width: auto;
}
#toasts {
  position: fixed;
  z-index: 30;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(460px, calc(100% - 24px));
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--card);
  border: 2px solid var(--teal);
  border-radius: 14px;
  padding: 8px 10px;
  box-shadow: 0 8px 20px rgba(1, 1, 75, 0.25);
  animation: in 0.25s ease-out;
  transition: opacity 0.5s;
}
.toast img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: var(--sand);
  flex: none;
}
.toast.bad {
  border-color: var(--bad);
  background: #fff6f4;
}
.toast.warn {
  border-color: var(--warn);
}
.toast.out {
  opacity: 0;
}
.xpfly {
  justify-self: center;
  background: var(--yel);
  color: var(--navy);
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 14px;
  animation: up 1.8s ease-out forwards;
}
.xpfly small {
  font-weight: 500;
}
@keyframes in {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }
}
@keyframes up {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  15% {
    opacity: 1;
    transform: none;
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-12px);
  }
}

/* ECG */
.ecgwrap {
  position: relative;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.ecgwrap canvas {
  display: block;
  width: 100%;
  min-width: 620px;
}
.hits {
  position: absolute;
  inset: 0;
  min-width: 620px;
}
.hit {
  position: absolute;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  min-height: 0;
  padding: 0;
  justify-content: flex-start;
  align-items: flex-start;
}
.hit span {
  opacity: 0;
}
.hit.on {
  border-color: var(--teal);
  background: rgba(46, 139, 136, 0.12);
}
.hit.want {
  box-shadow: inset 0 0 0 3px var(--good);
}

/* book */
.book details {
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}
.book summary {
  font-weight: 700;
  cursor: pointer;
  color: var(--navy);
}
.nums {
  display: grid;
  gap: 2px;
  background: var(--sand);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 6px 0;
  text-align: left;
}
.quiz {
  display: grid;
  gap: 6px;
  background: #eaf3f2;
  border-radius: 8px;
  padding: 8px 10px;
}
.ans {
  color: var(--good);
  font-weight: 600;
}

/* outcome */
.outcome {
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 10px;
}
.outcome .week {
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  background-size: cover;
  background-position: center;
  min-height: 260px;
  display: flex;
  align-items: flex-end;
}
.weekin {
  width: 100%;
  padding: 16px;
  background: linear-gradient(to top, rgba(1, 1, 75, 0.9), rgba(1, 1, 75, 0));
  color: #fff;
}
.weekrow {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.weekrow img {
  width: 110px;
  flex: none;
}
.weekrow p {
  margin: 0;
  font-weight: 500;
}
.gray {
  filter: grayscale(1) opacity(0.7);
}
.stars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}
.star {
  font-size: 2.2rem;
  color: var(--line);
  display: grid;
  line-height: 1.1;
}
.star.on {
  color: var(--yel);
  text-shadow: 0 2px 0 #c99512;
}
.star small {
  font-size: 0.75rem;
  color: var(--muted);
}
.sum {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.sum div {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  display: grid;
}
.sum b {
  font: 900 1.4rem var(--fd);
  color: var(--navy);
}
.outcome h3 {
  font: 700 1.05rem var(--fd);
  margin: 8px 0 0;
  color: var(--navy);
}
.tape {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.tape li {
  display: flex;
  gap: 10px;
  background: var(--card);
  border-inline-start: 4px solid var(--good);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.88rem;
}
.tape li.late {
  border-color: var(--yel);
}
.tape li.trap {
  border-color: var(--bad);
}
.tape li.call {
  border-color: #5b6bd6;
}
.tape li span {
  display: grid;
}
.must {
  margin: 0;
  padding-inline-start: 18px;
  display: grid;
  gap: 2px;
  text-align: left;
}
.must li.ok {
  color: var(--good);
}
.must li.miss {
  color: var(--bad);
}
.note {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.note.bad {
  background: var(--bad-bg);
  border-color: var(--bad);
}
.teach {
  display: flex;
  gap: 10px;
  background: #e7f2f1;
  border-radius: 14px;
  padding: 10px;
}
.teach img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: #fff;
  flex: none;
}
.teach p {
  margin: 4px 0 0;
  font-family: var(--fr);
  line-height: 1.75;
}
.book details p,
.book details li {
  font-family: var(--fr);
  line-height: 1.75;
}
.chaps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.share {
  border-radius: 18px;
  background-size: cover;
  padding: 14px;
  margin-top: 6px;
}
.sharein {
  border: 2px solid #fff;
  border-radius: 14px;
  color: #fff;
  padding: 16px;
  text-align: center;
  display: grid;
  gap: 4px;
  background: rgba(1, 1, 75, 0.55);
}
.sharein small {
  letter-spacing: 0.14em;
  font-weight: 700;
}
.sharein b {
  font: 900 2rem var(--fd);
}
.sharein p {
  margin: 0;
}

/* animated intro */
.intro-s {
  min-height: 100vh;
  background: radial-gradient(circle at 50% 30%, #14148a 0%, var(--navy) 62%);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 32px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px));
  position: relative;
  overflow: hidden;
  text-align: center;
}
.intro-s .glow {
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(46, 139, 136, 0.45), transparent 65%);
  top: 8%;
  animation: pulse 1.4s ease-in-out infinite;
}
.kma {
  display: grid;
  gap: 2px;
  opacity: 0;
  animation: fadeup 0.7s 0.2s ease-out forwards;
  position: relative;
}
.kma span {
  border: 2px solid #fff;
  border-radius: 12px;
  padding: 6px 14px;
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 0.85rem;
}
.kma small {
  color: #bfbdf5;
}
.ekg {
  width: 100%;
  max-width: 440px;
  height: 90px;
  position: relative;
}
.ekg path {
  fill: none;
  stroke: #5fe3c9;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation:
    draw 1.8s 0.7s ease-in-out forwards,
    beat 1.4s 2.6s ease-in-out infinite;
  filter: drop-shadow(0 0 6px #5fe3c9);
}
.ttl {
  font: 900 4.2rem/1.2 var(--fd);
  margin: 0;
  position: relative;
}
.ttl span {
  display: inline-block;
  clip-path: inset(0 0 0 100%);
  transform: scale(0.85);
  animation: wipe 0.9s 2.2s cubic-bezier(0.3, 1.3, 0.5, 1) forwards;
  text-shadow: 0 4px 0 var(--teal);
}
@keyframes wipe {
  to {
    clip-path: inset(0 0 0 0);
    transform: none;
  }
}
.intro-s .sub {
  margin: 0;
  color: #dcdaff;
  opacity: 0;
  animation: fadeup 0.6s 3s ease-out forwards;
  position: relative;
}
.intro-s .doc {
  width: 200px;
  max-width: 52%;
  opacity: 0;
  transform: translateX(-60px);
  animation: slidein 0.7s 3.2s ease-out forwards;
  position: relative;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.35));
}
.start {
  font: 800 1.4rem var(--fd) !important;
  padding: 12px 40px;
  border-radius: 999px;
  opacity: 0;
  animation:
    fadeup 0.5s 3.8s ease-out forwards,
    glowb 1.6s 4.3s ease-in-out infinite;
  position: relative;
  box-shadow: 0 0 0 0 rgba(95, 227, 201, 0.6);
}
.start span {
  font-family: var(--fd);
}
@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes beat {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}
@keyframes pop {
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fadeup {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes slidein {
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(0.9);
    opacity: 0.6;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}
@keyframes glowb {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(95, 227, 201, 0.55);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(95, 227, 201, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .ttl span {
    clip-path: none !important;
    transform: none !important;
  }
  .kma,
  .intro-s .sub,
  .intro-s .doc,
  .start {
    opacity: 1 !important;
    transform: none !important;
  }
  .ekg path {
    stroke-dashoffset: 0;
  }
}
.ttl em {
  font-style: normal;
  color: var(--yel);
  text-shadow: 0 4px 0 #c99512;
}
.slogan {
  font-family: var(--fd);
  font-weight: 700;
  font-size: 1.08rem;
  white-space: nowrap;
  color: #fff;
  letter-spacing: 0.01em;
}
.intro-s .slogan {
  font-size: 1.45rem;
  color: #ffe7a3;
}
.sharein .slogan {
  font-style: normal;
  font-size: 1rem;
  color: #ffe7a3;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
.q.tx > span,
.tape li > span {
  display: block;
}
.tape li > span small {
  display: block;
}
body:has(.modal) #toasts {
  bottom: auto;
  top: calc(8px + env(safe-area-inset-top, 0px));
}
button {
  min-height: 48px;
  border-radius: 14px;
  transition:
    transform 0.08s ease,
    background 0.2s;
}
button:active:not(:disabled) {
  transform: scale(0.97);
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

/* vitals strip */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .hud {
  position: static;
}
.vitals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 10px;
  background: #05052e;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.vt {
  display: grid;
  text-align: center;
  border-radius: 8px;
  padding: 2px 0;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.4s;
}
.vt small {
  font-size: 0.66rem;
  color: #9c9bd6;
  font-family: var(--fm);
}
.vt b {
  font: 600 1.08rem var(--fm);
  color: #5fe3c9;
}
.vt.warn b {
  color: #ffd166;
}
.vt.bad {
  background: rgba(255, 80, 80, 0.18);
  animation: blink 1s infinite;
}
.vt.bad b {
  color: #ff7272;
}
@keyframes blink {
  50% {
    background: rgba(255, 80, 80, 0.04);
  }
}

/* monitor */
.monitor {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  z-index: 2;
  width: 42%;
  max-width: 190px;
  background: rgba(3, 3, 30, 0.86);
  border: 2px solid #2a2a6a;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.monitor canvas {
  display: block;
  width: 100%;
  height: 46px;
}
.monb {
  position: absolute;
  bottom: -14px;
  inset-inline-start: -10px;
  min-height: 30px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.8rem;
  background: #fff;
}

/* patient condition */
.patient {
  transition: filter 0.8s;
}
.stage.sev1 .patient {
  filter: saturate(0.7) brightness(1.03) drop-shadow(0 6px 10px rgba(0, 0, 0, 0.25));
}
.stage.sev2 .patient {
  filter: grayscale(0.45) brightness(0.95) drop-shadow(0 0 14px rgba(255, 60, 60, 0.55));
  animation: shake 2.4s ease-in-out infinite;
}
.stage.sev2::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 70px rgba(255, 0, 0, 0.45);
  animation: vign 1.2s ease-in-out infinite;
}
@keyframes vign {
  50% {
    box-shadow: inset 0 0 30px rgba(255, 0, 0, 0.15);
  }
}
.sweat {
  position: absolute;
  top: 16%;
  inset-inline-start: 50%;
  width: 90px;
  height: 70px;
  transform: translateX(50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
}
.stage.sev1 .sweat,
.stage.sev2 .sweat {
  opacity: 1;
}
.sweat i {
  position: absolute;
  width: 9px;
  height: 13px;
  background: #9fd8ff;
  border-radius: 50% 50% 50% 50%/60% 60% 40% 40%;
  border: 1px solid #4a90c2;
  animation: drip 1.6s ease-in infinite;
}
.sweat i:nth-child(1) {
  left: 8px;
  top: 10px;
}
.sweat i:nth-child(2) {
  left: 62px;
  top: 4px;
  animation-delay: 0.5s;
}
.sweat i:nth-child(3) {
  left: 36px;
  top: 22px;
  animation-delay: 1s;
}
@keyframes drip {
  0% {
    transform: translateY(0);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translateY(26px);
    opacity: 0;
  }
}

/* bottom sheet */
.modal {
  animation: fadeb 0.2s ease-out;
}
.sheet {
  animation: sheetup 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  transition: transform 0.15s;
  padding-top: 22px;
}
.handle {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 5px;
  border-radius: 3px;
  background: var(--line);
}
@keyframes sheetup {
  from {
    transform: translateY(100%);
  }
}
@keyframes fadeb {
  from {
    background: rgba(1, 1, 75, 0);
  }
}

/* panel fade */
.panel.fade > * {
  animation: fadeup 0.25s ease-out;
}

/* XP fly */
.xpdot {
  position: fixed;
  z-index: 40;
  transform: translate(-50%, -50%);
  background: var(--yel);
  color: var(--navy);
  font-weight: 800;
  border-radius: 999px;
  padding: 4px 10px;
  transition:
    left 0.6s cubic-bezier(0.5, 0, 0.4, 1),
    top 0.6s cubic-bezier(0.5, 0, 0.4, 1),
    opacity 0.6s,
    transform 0.6s;
  pointer-events: none;
  font-family: var(--fm);
}
.chip.bump {
  animation: bump 0.4s;
}
@keyframes bump {
  40% {
    transform: scale(1.25);
    background: var(--yel);
    color: var(--navy);
  }
}

/* daily */

/* outcome rating */
.star {
  opacity: 0;
  transform: scale(0.3);
  animation: starin 0.45s cubic-bezier(0.3, 1.6, 0.5, 1) forwards;
}
@keyframes starin {
  to {
    opacity: 1;
    transform: none;
  }
}
.records {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.rec {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.85rem;
}
.rec.gold {
  background: #fff2d2;
  border-color: #e2b33c;
  font-weight: 700;
}
.shareimg {
  width: 100%;
  border-radius: 12px;
}
.dl {
  display: block;
  text-align: center;
  margin-top: 8px;
  color: var(--teal);
  font-weight: 700;
}

/* map */
.map {
  min-height: 100vh;
  background: linear-gradient(#f4eee3, #e9dfcb);
  padding: 0 12px 40px;
}
.maphead {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  background: inherit;
}
.maphead b {
  font: 800 1.15rem var(--fd);
  color: var(--navy);
}
.maphead span {
  font-weight: 800;
  color: #c99512;
}
.zone {
  border-radius: 18px;
  padding: 12px;
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
}
.z-easy {
  border-top: 6px solid #5fd38d;
}
.z-medium {
  border-top: 6px solid #f2c14e;
}
.z-hard {
  border-top: 6px solid #e2557a;
}
.zt {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.zt b {
  font: 800 1.05rem var(--fd);
  color: var(--navy);
}
.zt small {
  color: var(--muted);
}
.path {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px 6px;
}
.node {
  flex-direction: column;
  gap: 0;
  padding: 4px;
  min-height: 0;
  border-radius: 16px;
  position: relative;
  transform: translateY(calc(var(--o) * 6px));
  background: #fff;
}
.node img {
  width: 100%;
  height: 58px;
  object-fit: contain;
}
.node i {
  position: absolute;
  top: 2px;
  inset-inline-start: 4px;
  font-style: normal;
  font-weight: 800;
  font-size: 0.75rem;
  background: var(--navy);
  color: #fff;
  border-radius: 999px;
  padding: 0 6px;
}
.node span {
  font-size: 0.72rem;
  color: #c99512;
  letter-spacing: -0.05em;
}
.node.lock {
  filter: grayscale(1);
  opacity: 0.45;
}
.node.s3 {
  border-color: #e2b33c;
  box-shadow: 0 0 0 2px #ffe7a3;
}

/* night / dark */
.case.dark {
  color: #e8e8f6;
}
.case.dark .panel {
  background: #10123a;
}
.case.dark button:not(.primary):not(.hit) {
  background: #1b1e52;
  border-color: #2c3070;
  color: #e8e8f6;
}
.case.dark .q.done {
  background: #22265e;
}
.case.dark .q small,
.case.dark .q em,
.case.dark .muted {
  color: #a9a8d8;
}
.case.dark .q.done em {
  color: #e8e8f6;
}
.case.dark .q.tx.must,
.case.dark .q.tx.ok,
.case.dark .opt.right {
  background: #123d33;
  border-color: #2fa37e;
}
.case.dark .q.tx.avoid,
.case.dark .opt.wrong {
  background: #4a1a22;
  border-color: #e05a5a;
}
.case.dark .callbox {
  background: #1b1e52;
  border-color: #2c3070;
}
.case.dark .nameplate {
  background: #1b1e52;
  color: #fff;
  box-shadow: none;
}
html.dark .sheet {
  background: #15173f;
  color: #e8e8f6;
}
html.dark .sheet h2 {
  color: #fff;
}
html.dark .sheet button:not(.primary):not(.hit) {
  background: #1f2259;
  border-color: #2c3070;
  color: #e8e8f6;
}
html.dark .intro blockquote,
html.dark .nums {
  background: #1f2259;
}
html.dark .quiz {
  background: #16354a;
}
html.dark .toast {
  background: #1b1e52;
  color: #e8e8f6;
}
html.dark .map {
  background: linear-gradient(#10123a, #070824);
}
html.dark .zone,
html.dark .node {
  background: #1b1e52;
  border-color: #2c3070;
}
html.dark .maphead b,
html.dark .zt b {
  color: #fff;
}

/* ordered management */
.plan {
  margin: 0 0 10px;
  padding: 8px 10px 8px 10px;
  padding-inline-start: 28px;
  background: var(--good-bg);
  border-radius: 12px;
  display: grid;
  gap: 2px;
  font-size: 0.9rem;
}
.plan li.next {
  color: var(--muted);
  list-style: none;
  margin-inline-start: -16px;
}
.case.dark .plan {
  background: #123d33;
}
.q.nope {
  animation: nope 0.4s;
}
@keyframes nope {
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}

/* dx gate */

/* briefing */
.brief {
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.bscene {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.75);
}
.bclock {
  position: absolute;
  top: 16px;
  inset-inline: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  background: rgba(1, 1, 75, 0.75);
  border-radius: 14px;
  padding: 8px 14px;
  animation: fadeup 0.5s ease-out;
}
.bclock span {
  font: 800 1.05rem var(--fd);
}
.bclock b {
  font: 600 1.3rem var(--fm);
  color: #5fe3c9;
}
.bwho {
  position: relative;
  display: flex;
  justify-content: center;
  height: 52vh;
}
.bwho img {
  height: 100%;
  max-width: 80%;
  object-fit: contain;
  animation: fadeup 0.35s ease-out;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.4));
}
.bbox {
  position: relative;
  margin: 0 12px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border: 3px solid var(--navy);
  border-radius: 18px;
  padding: 12px 14px;
  min-height: 150px;
  display: grid;
  gap: 4px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.bbox b {
  font: 800 1rem var(--fd);
  color: var(--teal);
}
.bbox p {
  margin: 0;
  font-family: var(--fr);
  font-size: 1.05rem;
  line-height: 1.8;
  min-height: 3.6em;
}
.bbtns {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

/* tour */
.tour {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.tring {
  position: fixed;
  border-radius: 14px;
  box-shadow:
    0 0 0 3px var(--yel),
    0 0 0 9999px rgba(1, 1, 40, 0.72);
  transition: all 0.35s cubic-bezier(0.3, 1, 0.4, 1);
  pointer-events: none;
}
.tbox {
  position: fixed;
  inset-inline: 16px;
  max-width: 448px;
  margin: 0 auto;
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  transition: top 0.35s;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.tbox p {
  margin: 0;
  font-family: var(--fr);
  line-height: 1.75;
}
.tbox small {
  color: var(--muted);
  text-align: center;
}
body:has(.tour) #toasts {
  bottom: auto;
  top: calc(8px + env(safe-area-inset-top, 0px));
}

/* fit title + slogan on narrow phones */
.ttl {
  font-size: clamp(2.4rem, 14vw, 4.2rem) !important;
  white-space: nowrap;
}
.slogan {
  font-size: clamp(0.82rem, 4.3vw, 1.08rem) !important;
  white-space: nowrap;
}
.intro-s .slogan {
  font-size: clamp(0.9rem, 4.9vw, 1.45rem) !important;
}
.sharein .slogan {
  font-size: clamp(0.8rem, 4vw, 1rem) !important;
  white-space: normal;
}

/* textbook exam */
.exsec {
  margin-bottom: 12px;
}
.exh {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 2px 0 6px;
  border-bottom: 2px solid var(--teal);
  padding-bottom: 4px;
}
.exh b {
  font: 800 0.98rem var(--fd);
  color: var(--navy);
  letter-spacing: 0.02em;
}
.exh button {
  min-height: 32px;
  font-size: 0.75rem;
}
.exlist {
  display: grid;
  gap: 6px;
}
.exlist .ex {
  flex-direction: row;
  justify-content: flex-start;
  align-items: baseline;
  gap: 10px;
  min-height: 44px;
  text-align: left;
  flex-wrap: wrap;
}
.exlist .ex b {
  font-weight: 700;
  min-width: 118px;
  color: var(--navy);
}
.exlist .ex span {
  flex: 1;
  color: var(--muted);
  font-size: 0.9rem;
}
.exlist .ex.done span {
  color: var(--ink);
}
.case.dark .exh b,
.case.dark .exlist .ex b {
  color: #bfe9e2;
}
.tname {
  text-align: left;
  font-weight: 600;
}

/* normal values */
.ltrh {
  text-align: left;
}
.labs {
  text-align: left;
}
.labs h3 {
  font: 800 0.95rem var(--fd);
  color: var(--teal);
  margin: 12px 0 4px;
}
.labs table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.labs th {
  text-align: left;
  font-weight: 600;
  padding: 5px 8px 5px 0;
  width: 38%;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.labs td {
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--fa);
}
html.dark .labs th,
html.dark .labs td {
  border-color: #2c3070;
}

/* character motion */
.stage {
  background-size: cover;
  background-position: center 35%;
}
.patient {
  animation: breathe 3.6s ease-in-out infinite;
  transform-origin: 50% 100%;
}
.patient.talk {
  animation:
    talk 0.45s ease-in-out 3,
    breathe 3.6s 1.4s ease-in-out infinite;
}
.stage.sev1 .patient {
  animation-duration: 2.4s;
}
.stage.sev2 .patient {
  animation:
    breathe 1.2s ease-in-out infinite,
    shake 2.4s ease-in-out infinite;
}
.family img {
  animation: sway 4.5s ease-in-out infinite;
  transform-origin: 50% 100%;
}
@keyframes sway {
  0%,
  100% {
    transform: rotate(0);
  }
  50% {
    transform: rotate(1.2deg) translateY(-1px);
  }
}
.bwho img.talking {
  animation:
    fadeup 0.35s ease-out,
    talkb 0.5s 0.35s ease-in-out infinite;
}
@keyframes talkb {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px) rotate(-0.6deg);
  }
}
.monitor {
  animation: none;
}

/* live clock */
.clock {
  transition: box-shadow 0.3s;
}
.clock.tick img {
  transform: rotate(12deg);
}
.clock img {
  transition: transform 0.25s;
}

/* salary sms */
.sms {
  background: #f3f6fb;
  border-radius: 16px;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
  border: 1px solid #d7deea;
  margin: 6px 0 12px;
  animation: smsin 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.smsh {
  display: flex;
  justify-content: space-between;
  color: #4a5675;
  font-weight: 700;
}
.smsh small {
  color: var(--muted);
  font-weight: 400;
}
.sms p {
  margin: 0;
}
.smsamt {
  font: 900 2.2rem var(--fd);
  color: var(--good);
  text-align: center;
}
.smsamt small {
  font-size: 1rem;
}
@keyframes smsin {
  from {
    transform: translateY(-30px) scale(0.9);
    opacity: 0;
  }
}
html.dark .sms {
  background: #1f2259;
  border-color: #2c3070;
}
@media (prefers-reduced-motion: reduce) {
  .patient,
  .family img,
  .bwho img {
    animation: none !important;
  }
}

/* dark-mode contrast fixes */
.case.dark .exlist .ex span {
  color: #a9a8d8;
}
.case.dark .exlist .ex.done span {
  color: #f1f1fb;
}
html.dark .labs th,
html.dark .labs td,
html.dark .sheet p,
html.dark .sheet li {
  color: #e8e8f6;
}
html.dark .sheet .muted {
  color: #a9a8d8;
}
.sheet .opt:disabled {
  opacity: 1;
}
.sheet .opt:disabled:not(.right):not(.wrong) {
  opacity: 0.55;
}
html.dark .sheet .opt.right,
.sheet .opt.right {
  background: var(--good-bg) !important;
  border-color: var(--good) !important;
  color: var(--good) !important;
  font-weight: 700;
}
html.dark .sheet .opt.wrong,
.sheet .opt.wrong {
  background: var(--bad-bg) !important;
  border-color: var(--bad) !important;
  color: var(--bad) !important;
}
.ltrh {
  padding-left: 48px;
}
:root {
  --y1: #ffd84d;
  --y2: #f2b705;
  --ink2: #0b0c2a;
}
button.primary {
  background: linear-gradient(#ffe27a, var(--y2));
  color: var(--ink2);
  border: 0;
  box-shadow: 0 4px 0 #b88700;
  font-weight: 800;
}
button.primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #b88700;
}

/* home */
.home {
  min-height: 100vh;
  background-size: cover;
  background-position: center;
  position: relative;
  padding: 12px 14px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: #fff;
}
.home::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(5, 6, 40, 0.78), rgba(5, 6, 40, 0.55) 30%, rgba(5, 6, 40, 0.92) 62%);
}
.home > * {
  position: relative;
}
.htop {
  display: grid;
  grid-template-columns: repeat(4, 1fr) auto;
  gap: 6px;
  align-items: stretch;
}
.hico {
  flex-direction: column;
  gap: 2px;
  background: rgba(16, 18, 58, 0.85);
  border: 1.5px solid rgba(255, 216, 77, 0.55);
  color: var(--y1);
  font-weight: 800;
  font-size: 0.72rem;
  border-radius: 14px;
  padding: 6px 2px;
  min-height: 58px;
}
.hico span {
  font-size: 1.25rem;
  line-height: 1;
}
.wallet {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(16, 18, 58, 0.9);
  border-radius: 999px;
  padding: 0 10px;
  font: 800 1rem var(--fm);
  color: var(--y1);
  align-self: center;
  height: 40px;
}
.wallet img {
  width: 22px;
  height: 22px;
}
.logo {
  text-align: center;
  margin-top: 6px;
}
.logo .kma {
  font:
    800 0.7rem "Montserrat",
    "Cairo",
    sans-serif;
  letter-spacing: 0.18em;
  color: #bfc2ff;
}
.logo h1 {
  margin: 2px 0 0;
  font: 900 clamp(2.6rem, 15vw, 4.4rem)/1.15 var(--fd);
  color: var(--y1);
  -webkit-text-stroke: 7px var(--ink2);
  paint-order: stroke fill;
  text-shadow:
    0 6px 0 var(--ink2),
    0 0 0 #fff;
  filter: drop-shadow(0 0 0 #fff) drop-shadow(0 3px 0 #fff);
}
.logo h1 em {
  font-style: normal;
  color: #fff;
}
.logo .slogan {
  color: #ffe7a3 !important;
  margin: 0;
}
.badges {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.badges span {
  border: 1.5px solid var(--y1);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.72rem;
  font-weight: 800;
  background: rgba(16, 18, 58, 0.85);
}
.badges .free {
  border-color: #5fe3c9;
  color: #5fe3c9;
}
.hdoc {
  width: 120px;
  align-self: center;
  margin: -4px 0 -8px;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
  animation: breathe2 3.6s ease-in-out infinite;
}
@keyframes breathe2 {
  50% {
    transform: translateY(-3px);
  }
}
.hcards {
  display: grid;
  gap: 8px;
}
.card,
.mode .mbtn {
  background: rgba(16, 18, 58, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  color: #fff;
}
.card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.card > div {
  flex: 1;
  display: grid;
  gap: 3px;
}
.card b {
  color: var(--y1);
  font: 800 1rem var(--fd);
}
.card small {
  color: #c9c8f0;
  font-size: 0.75rem;
}
.card.lvl img {
  width: 46px;
  height: 46px;
}
.card .bar {
  background: rgba(255, 255, 255, 0.15);
  height: 7px;
}
.card .bar i {
  background: var(--y1);
}
.dots {
  display: inline-flex;
  gap: 4px;
  margin-inline-start: 6px;
}
.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
}
.dots i.on {
  background: var(--y1);
}
.prize {
  font: 900 1rem var(--fm);
  color: var(--y1);
  white-space: nowrap;
}
.mode {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.mode .mbtn {
  flex: 1;
  justify-content: flex-start;
  gap: 10px;
  padding: 10px 12px;
  min-height: 64px;
  position: relative;
  text-align: start;
}
.mi {
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 216, 77, 0.12);
  display: grid;
  place-items: center;
  flex: none;
}
.mt {
  display: grid;
  flex: 1;
}
.mt b {
  font: 800 1.05rem var(--fd);
  color: #fff;
}
.mt small {
  color: #c9c8f0;
  font-size: 0.75rem;
}
.mode .go {
  font-style: normal;
  background: linear-gradient(#ffe27a, var(--y2));
  color: var(--ink2);
  font-weight: 800;
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 3px 0 #b88700;
  white-space: nowrap;
}
.newb {
  position: absolute;
  top: -8px;
  inset-inline-start: 10px;
  font-style: normal;
  background: var(--y1);
  color: var(--ink2);
  font-weight: 800;
  font-size: 0.68rem;
  border-radius: 999px;
  padding: 1px 8px;
}
.qmark {
  width: 40px;
  min-height: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  font-weight: 800;
  align-self: center;
  flex: none;
}
.copy {
  text-align: center;
  color: #8f8ec2;
  font-size: 0.72rem;
  margin: 4px 0 0;
}

/* compact clinical header */
.topbar .monitor {
  position: relative;
  inset: auto;
  width: auto;
  max-width: none;
  margin: 0;
  border-radius: 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #03031e;
  padding: 0 44px 0 6px;
  box-shadow: none;
  animation: none;
}
.topbar .monitor canvas {
  height: 34px;
}
.topbar .monb {
  position: absolute;
  top: 2px;
  bottom: auto;
  inset-inline-start: auto;
  left: 6px;
  width: 30px;
  height: 30px;
  min-height: 30px;
}
.finbtn {
  margin-inline-start: auto;
  min-height: 34px;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 800;
  border-radius: 999px;
  background: linear-gradient(#ffe27a, var(--y2));
  color: var(--ink2);
  border: 0;
}
.stage {
  height: 150px;
  min-height: 0;
  max-height: none;
}
.ptbtn {
  position: absolute;
  bottom: 0;
  inset-inline-start: 8px;
  height: 100%;
  width: 34%;
  padding: 0;
  border: 0;
  background: none;
  min-height: 0;
  display: block;
}
.ptbtn .patient {
  position: absolute;
  inset: auto;
  bottom: 0;
  left: 50%;
  height: 100%;
  max-width: 100%;
  transform: translateX(-50%);
}
@keyframes breathe {
  0%,
  100% {
    transform: translateX(-50%) scale(1, 1);
  }
  50% {
    transform: translateX(-50%) scale(1.012, 1.022) translateY(-1px);
  }
}
@keyframes talk {
  0%,
  100% {
    transform: translateX(-50%) rotate(0);
  }
  30% {
    transform: translateX(-50%) rotate(-1.2deg) translateY(-3px);
  }
  70% {
    transform: translateX(-50%) rotate(1deg);
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(-50%);
  }
  50% {
    transform: translateX(calc(-50% + 2px));
  }
}
.ptbtn .sweat {
  top: 6%;
  left: 50%;
  inset-inline-start: auto;
  transform: translateX(-50%);
  width: 70px;
  height: 60px;
}
.nameplate {
  bottom: auto;
  top: 10px;
  inset-inline-start: 36%;
  max-width: 38%;
  background: rgba(11, 12, 42, 0.82);
  color: #fff;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.nameplate small {
  color: #c9c8f0;
  font-size: 0.7rem;
  line-height: 1.4;
}
.family {
  width: 30%;
}
.family img {
  max-height: 96px;
}
.fbtns button {
  min-height: 30px;
  font-size: 0.72rem;
  padding: 2px 6px;
}
.ptfull {
  width: 80%;
  max-height: 55vh;
  object-fit: contain;
}
.subtabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px 0;
  background: var(--sand);
}
.subtabs button {
  flex: 1;
  min-height: 40px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9rem;
}
.subtabs button.on {
  background: var(--navy);
  color: var(--y1);
  border-color: var(--navy);
}
.panel {
  padding-bottom: 110px;
}
.bnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #0b0c2a;
  border-top: 2px solid var(--y2);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
}
.bnav button {
  flex-direction: column;
  gap: 0;
  background: none;
  border: 0;
  color: #a9a8d8;
  font-size: 0.78rem;
  font-weight: 700;
  min-height: 56px;
  border-radius: 12px;
}
.bnav button .gi {
  font-size: 1.3rem;
  line-height: 1.2;
  filter: grayscale(0.6);
}
.bnav button.on {
  color: var(--y1);
  background: rgba(255, 216, 77, 0.1);
}
.bnav button.on .gi {
  filter: none;
}
#toasts {
  bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}
.quick {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.quick button {
  flex-direction: column;
  font-size: 0.78rem;
  min-height: 62px;
}

/* working diagnosis */
.opt.picked {
  background: #fff2c2;
  border-color: var(--y2);
  font-weight: 700;
}
.gather {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.gather span {
  font-size: 0.75rem;
  background: var(--sand);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}
.gather span.ok {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}
.small {
  font-size: 0.8rem;
}

/* outcome: three messages */
.three {
  display: grid;
  gap: 8px;
}
.m3 {
  border-radius: 14px;
  padding: 10px 12px;
  display: grid;
  gap: 4px;
  border-inline-start: 5px solid;
}
.m3 small {
  font-weight: 800;
  color: var(--muted);
}
.m3 b {
  font-size: 1.02rem;
}
.m3 span {
  font-size: 0.78rem;
  color: var(--muted);
}
.m3 p {
  margin: 0;
  font-size: 0.86rem;
}
.m3.ok {
  background: var(--good-bg);
  border-color: var(--good);
}
.m3.bad {
  background: var(--bad-bg);
  border-color: var(--bad);
}
.m3.next {
  background: #fff7da;
  border-color: var(--y2);
}
.m3.next button {
  width: 100%;
}
details.more {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px 12px;
}
details.more summary {
  font-weight: 800;
  color: var(--navy);
  cursor: pointer;
  padding: 4px 0;
}
.brands summary {
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

/* ECG full screen */
.fsb {
  margin-bottom: 8px;
}
.modal.full .sheet {
  max-width: 100%;
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
}
.leadchips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.leadchips button {
  min-height: 32px;
  padding: 2px 10px;
  font-family: var(--fm);
}
.leadchips button.on {
  background: var(--navy);
  color: var(--y1);
}
.ecgfull {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
.ecgfull canvas {
  display: block;
}

/* dark (default) case look */
.case.dark .subtabs {
  background: #10123a;
}
.case.dark .subtabs button {
  background: #1b1e52;
  color: #e8e8f6;
  border-color: #2c3070;
}
.case.dark .subtabs button.on {
  background: var(--y1);
  color: var(--ink2);
}
.case.dark .opt.picked,
html.dark .opt.picked {
  background: #3a3410;
  border-color: var(--y1);
  color: #ffe7a3;
}
.case.dark .gather span {
  background: #1b1e52;
  border-color: #2c3070;
}
html.dark .outcome {
  background: #0b0c2a;
  color: #e8e8f6;
}
html.dark .m3.ok {
  background: #123d33;
}
html.dark .m3.bad {
  background: #4a1a22;
}
html.dark .m3.next {
  background: #2e2a10;
}
html.dark .m3 small,
html.dark .m3 span {
  color: #c9c8f0;
}
html.dark details.more,
html.dark .sum div,
html.dark .rec,
html.dark .note,
html.dark .callbox {
  background: #15173f;
  border-color: #2c3070;
  color: #e8e8f6;
}
html.dark details.more summary,
html.dark .sum b,
html.dark .outcome h3 {
  color: var(--y1);
}
html.dark .teach {
  background: #123a44;
}
html.dark #app {
  background: #0b0c2a;
}
.case .ptbtn,
.case.dark .ptbtn {
  background: none !important;
  border: 0 !important;
}
.ptbtn img.patient {
  width: auto;
  height: 100%;
  object-fit: contain;
}
html.dark button.ghost {
  background: #1b1e52;
  color: #e8e8f6;
  border-color: #2c3070;
}
html.dark .home button.ghost {
  background: rgba(16, 18, 58, 0.85);
}
.case.dark .plan {
  background: #123d33;
  color: #dff5ec;
}
.case.dark .plan li.next {
  color: #9fd9c4;
}

/* pause button + touch targets (≥ 44px hit area even where the icon is small) */
.pausebtn {
  margin-inline-start: auto;
  position: relative;
  width: 34px;
  min-height: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 0.8rem;
  flex: none;
}
.pausebtn + .finbtn {
  margin-inline-start: 0;
}
.pausebtn::after,
.monb::after,
.leadchips button::after {
  content: "";
  position: absolute;
  inset: -6px;
}
.leadchips button {
  position: relative;
  min-height: 40px;
  min-width: 44px;
}
.qmark {
  width: 44px;
  min-height: 44px;
  height: 44px;
}
.fbtns button {
  min-height: 44px;
}

/* skills board, time targets, vitals before/after, reference line */
.skills {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}
.sk {
  display: grid;
  grid-template-columns: 7.5em 1fr 3em;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.sk .bar {
  height: 10px;
  border-radius: 99px;
  background: rgba(127, 127, 127, 0.2);
  overflow: hidden;
}
.sk .bar i {
  display: block;
  height: 100%;
  background: var(--teal);
}
.sk .bar.low i {
  background: var(--bad);
}
.times {
  list-style: none;
  padding: 0;
  margin: 8px 0;
  display: grid;
  gap: 6px;
}
.times li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--good-bg);
  color: var(--good);
}
.times li.miss {
  background: var(--bad-bg);
  color: var(--bad);
}
.vbefore {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 0.9rem;
}
.vbefore th,
.vbefore td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.ref {
  margin: 6px 16px;
}
textarea {
  font: inherit;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
}

/* home header with six tools + the shop (عدّتك) */
.htop {
  grid-template-columns: repeat(6, 1fr) auto;
}
.hico {
  min-width: 0;
  font-size: 0.62rem;
  padding: 6px 2px;
}
.shophead {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}
.coins {
  background: rgba(242, 193, 78, 0.18);
  color: var(--y1, #f2c14e);
  border: 1px solid rgba(242, 193, 78, 0.5);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 800;
}
.shop {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 10px 0;
}
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 12px 8px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: rgba(127, 127, 127, 0.06);
}
.tool.max {
  border-color: var(--good);
  background: var(--good-bg);
}
.tool .ti img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.tool .ti .gi {
  font-size: 2rem;
  line-height: 44px;
}
.tool b {
  font-size: 0.95rem;
}
.tool small {
  font-size: 0.72rem;
  line-height: 1.35;
}
.tool .cur {
  color: var(--good);
}
.tool .nx {
  opacity: 0.8;
}
.tool button {
  margin-top: auto;
  width: 100%;
  justify-content: center;
}
.short {
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  background: rgba(127, 127, 127, 0.12);
  font-weight: 800;
}
.reward {
  font-size: 1.05rem;
}

/* simpler home: one big start, the rest under «المزيد» */
.htop.simple {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.htop.simple .hico {
  width: 48px;
  min-height: 48px;
  padding: 0;
}
.bigstart {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  text-align: start;
  width: 100%;
  padding: 16px 18px;
  border-radius: 20px;
  border: 0;
  background: linear-gradient(#ffe27a, var(--y2, #f2c14e));
  color: #16163a;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.25);
}
.bigstart span {
  grid-row: 1/3;
  font-size: 2rem;
  align-self: center;
}
.bigstart b {
  font-size: 1.25rem;
}
.bigstart small {
  opacity: 0.8;
}
.bigstart.second {
  background: rgba(16, 18, 58, 0.85);
  color: #fff;
  border: 1.5px solid rgba(255, 216, 77, 0.55);
  box-shadow: none;
  padding: 12px 18px;
}
.bigstart.second b {
  font-size: 1.05rem;
}
.morebtn {
  width: 100%;
  justify-content: center;
  padding: 12px;
  border-radius: 16px;
  background: rgba(16, 18, 58, 0.85);
  color: #ffe27a;
  border: 1.5px solid rgba(255, 216, 77, 0.45);
  font-weight: 800;
  position: relative;
}
.morebtn .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ff6b6b;
  margin-inline-start: 6px;
}
.q .mi {
  font-size: 1.4rem;
  flex: none;
}
/* case: five tabs, next-step bar, coach */
.bnav.b5 {
  grid-template-columns: repeat(5, 1fr);
}
.nextbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 12px 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(46, 139, 136, 0.16);
  border: 1.5px solid var(--teal);
  font-weight: 700;
  font-size: 0.92rem;
}
.nextbar[hidden] {
  display: none;
}
.nextbar button {
  flex: none;
}
.coach {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  width: min(456px, calc(100vw - 24px));
  z-index: 30;
  background: #fffdf8;
  color: #16163a;
  border: 2px solid #f2c14e;
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.coach p {
  margin: 2px 0 6px;
  font-weight: 700;
}
.coach small {
  opacity: 0.7;
}
.glow {
  outline: 3px solid #f2c14e !important;
  outline-offset: 2px;
  animation: glowp 1.2s ease-in-out infinite;
  position: relative;
  z-index: 2;
}
@keyframes glowp {
  50% {
    outline-color: rgba(242, 193, 78, 0.25);
  }
}
@media (prefers-reduced-motion: reduce) {
  .glow {
    animation: none;
  }
}
body:has(.coach) .xpfly {
  display: none;
}
.case:has(.coach) .panel {
  padding-bottom: 210px;
}
/* quick decision + mastery map */
.qd {
  min-height: 100vh;
  background: linear-gradient(#f4eee3, #e9dfcb);
  padding: 0 12px 40px;
}
html.dark .qd {
  background: linear-gradient(#10123a, #070824);
  color: #eef;
}
.qcase {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 6px 0;
}
.qcase img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: #fff;
  flex: none;
}
.qcase h2 {
  margin: 0;
  font-size: 19px;
}
.qcase p {
  margin: 3px 0;
}
.qhx {
  margin: 6px 0 10px;
  padding-inline-start: 18px;
  line-height: 1.8;
}
.qd .ecgwrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 12px;
  margin-bottom: 10px;
}
.qd #qfb .primary {
  width: 100%;
  margin-top: 10px;
}
.qd .teach {
  margin-top: 8px;
  display: block;
  line-height: 1.8;
}
html.dark .qd .teach {
  background: #1b2350;
}
.mastery {
  display: grid;
  gap: 8px;
  margin: 6px 0;
}
.ms {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
}
.ms span {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.ms small {
  opacity: 0.7;
}
.ms i {
  font-style: normal;
  letter-spacing: 2px;
  color: var(--good);
}
.ms.l3 {
  background: var(--good-bg);
}
html.dark .ms {
  background: rgba(255, 255, 255, 0.06);
}
.qd .opt {
  background: #fff;
  color: #1c1f3a;
}
html.dark .qd .opt {
  background: #1b2350;
  color: #eef;
  border-color: #33407a;
}
html.dark .qd .opt.right {
  background: #123d33;
  border-color: #2fa37e;
}
html.dark .qd .opt.wrong {
  background: #4a1a22;
  border-color: #e05a5a;
}
.qd .opt:disabled {
  opacity: 1;
}
.qd .note {
  margin-top: 10px;
}
html.dark .qd .note {
  background: #1b2350;
  color: #eef;
}
/* social links + update note */
.social {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 2px;
}
.social a {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.social svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}
.social .s-fb {
  background: #1877f2;
}
.social .s-yt {
  background: #ff0000;
}
.social .s-tg {
  background: #229ed9;
}
.social .s-form {
  background: #673ab7;
}
.upd {
  display: block;
  margin: 10px auto 0;
  max-width: 340px;
  text-align: center;
  font-size: 0.8rem;
  color: #ffe7a3;
  background: rgba(16, 18, 58, 0.85);
  border: 1px dashed var(--y1);
  border-radius: 12px;
  padding: 7px 10px;
  text-decoration: none;
}
.upd b {
  color: #5fe3c9;
}
html.dark .modal p.warn {
  background: #3a2e10;
  color: #ffd98a;
}
/* ---------- study library ---------- */
.study {
  min-height: 100vh;
  background: linear-gradient(#f4eee3, #e9dfcb);
  padding: 0 12px 40px;
}
html.dark .study {
  background: linear-gradient(#10123a, #070824);
  color: #eef;
}
.study h3 {
  margin: 18px 0 8px;
}
.study .bigstart {
  width: 100%;
  margin: 8px 0;
}
.study .q img.mi {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: #fff;
}
#ccard {
  width: 100%;
  margin: 10px 0;
}
.chap h2 {
  margin-bottom: 2px;
}
.chap h3 {
  margin: 18px 0 8px;
  font-size: 1.02rem;
}
.chap .en {
  margin: 0;
  font-family: var(--fa);
  font-weight: 600;
  opacity: 0.8;
  text-align: left;
}
.chap .arline {
  background: rgba(95, 227, 201, 0.12);
  border-radius: 10px;
  padding: 8px 10px;
  line-height: 1.8;
}
.chap ul.pearls {
  text-align: left;
  padding-left: 18px;
  line-height: 1.6;
}
.chap .chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cardhead {
  display: flex;
  gap: 10px;
  align-items: center;
}
.cardhead img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  background: #fff;
  flex: none;
}
/* flowchart: spine column + 90° side branches. High contrast, few colours:
   step = white/navy box, decision = amber box with "?", end = green / amber / red by meaning */
.flow {
  --ln: #59618f;
  --fn-bg: #ffffff;
  --fn-fg: #10123a;
  --q-bg: #fff1c9;
  --q-fg: #3b2a00;
  --q-bd: #c98a00;
  --lbl: #6b4e00;
  font-family: var(--fa);
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 6px 0 10px;
}
.flow .term,
.mx .term {
  color: inherit !important;
  background: none !important;
  font-weight: inherit;
}
.flow .fr {
  display: grid;
  grid-template-columns: minmax(0, 54%) 34px minmax(0, 1fr);
  align-items: center;
}
.flow .fn {
  border: 2px solid var(--ln);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--fn-bg);
  color: var(--fn-fg);
  text-align: center;
  font-weight: 500;
}
.flow .k-s {
  border-radius: 999px;
  background: #1f2a6b;
  border-color: #1f2a6b;
  color: #fff;
  font-weight: 700;
}
.flow .k-q {
  background: var(--q-bg);
  color: var(--q-fg);
  border: 2px solid var(--q-bd);
  border-inline-start-width: 6px;
  font-weight: 600;
}
.flow .k-e {
  border-radius: 12px;
  font-weight: 600;
}
.flow .t-good {
  background: #e3f6ef;
  border-color: #1f8a63;
  color: #0b3b2c;
}
.flow .t-warn {
  background: #fff3d6;
  border-color: #c98a00;
  color: #3b2a00;
}
.flow .t-bad {
  background: #fde6e6;
  border-color: #c53030;
  color: #5a0f0f;
}
.flow .fv {
  height: 28px;
  position: relative;
}
.flow .fv::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 6px;
  border-left: 2px solid var(--ln);
}
.flow .fv::after {
  content: "";
  position: absolute;
  left: calc(50% - 5px);
  bottom: 0;
  border: 5px solid transparent;
  border-top: 7px solid var(--ln);
  border-bottom: 0;
}
.flow .fh {
  position: relative;
  align-self: stretch;
  min-height: 24px;
}
.flow .fh::before {
  content: "";
  position: absolute;
  left: 0;
  right: 6px;
  top: 50%;
  border-top: 2px solid var(--ln);
}
.flow .fh::after {
  content: "";
  position: absolute;
  right: 0;
  top: calc(50% - 5px);
  border: 5px solid transparent;
  border-left: 7px solid var(--ln);
  border-right: 0;
}
.flow .fv span,
.flow .fh span {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--lbl);
  white-space: nowrap;
}
.flow .fv span {
  left: calc(50% + 7px);
  top: 5px;
}
.flow .fh span {
  left: 0;
  right: 0;
  top: calc(50% - 17px);
  text-align: center;
}
.flow .k-p {
  text-align: start;
}
.flow .fside {
  display: flex;
  flex-direction: column;
}
.flow .fside .fn {
  font-size: 0.8rem;
  text-align: left;
  padding: 7px 8px;
}
.flow .fvs {
  height: 14px;
  border-left: 2px solid var(--ln);
  margin-left: 50%;
}
html.dark .flow {
  --ln: #aab2e8;
  --fn-bg: #141a45;
  --fn-fg: #ffffff;
  --q-bg: #4a3a0e;
  --q-fg: #fff4d6;
  --q-bd: #f2b53a;
  --lbl: #ffd98a;
}
html.dark .flow .k-s {
  background: #5fe3c9;
  border-color: #5fe3c9;
  color: #0b0d2e;
}
html.dark .flow .t-good {
  background: #0f3b30;
  border-color: #3ccb9a;
  color: #fff;
}
html.dark .flow .t-warn {
  background: #43330a;
  border-color: #f2b53a;
  color: #fff;
}
html.dark .flow .t-bad {
  background: #4d1620;
  border-color: #ff6b6b;
  color: #fff;
}
/* matrices */
.mx {
  margin: 12px 0;
}
.mx h4 {
  margin: 0 0 6px;
  font-size: 0.92rem;
  font-family: var(--fa);
  text-align: left;
}
.mxs {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}
.mx table {
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 100%;
  font-family: var(--fa);
  color: #10123a;
  background: #fff;
}
.mx th,
.mx td {
  padding: 7px 9px;
  border-bottom: 1px solid #d9dcef;
  vertical-align: top;
  text-align: left;
  min-width: 110px;
}
.mx thead th {
  background: #1f2a6b;
  color: #fff;
  position: sticky;
  top: 0;
}
.mx tbody th {
  position: sticky;
  left: 0;
  background: #e6e9f7;
  color: #10123a;
  font-weight: 700;
  z-index: 1;
}
html.dark .mx table {
  background: #1b2350;
  color: #f2f3ff;
}
html.dark .mx th,
html.dark .mx td {
  border-bottom-color: #2f3a78;
}
html.dark .mx thead th {
  background: #5fe3c9;
  color: #0b0d2e;
}
html.dark .mx tbody th {
  background: #2a3470;
  color: #fff;
}

/* headings and primary actions: Montserrat for English, Cairo for Arabic */
h1,
h2,
h3,
.bigstart b,
.primary,
.maphead b {
  font-family: var(--fd);
}
