:root {
  --ma-surface: #0b1c2a;
  --ma-line: rgba(176, 209, 222, 0.17);
  --ma-text: #edf5f7;
  --ma-muted: #a2bac7;
  --ma-mint: #a5f3d5;
  --ma-radius: 22px;
  color-scheme: dark;
}

html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body { background-color: #07131f; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, select, summary, a { touch-action: manipulation; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; }
:focus-visible { outline: 3px solid var(--ma-mint); outline-offset: 4px; }
[hidden] { display: none !important; }
input, select, textarea { max-width: 100%; font-size: max(16px, 1em); }
img { max-width: 100%; }
.ma-skip { position: fixed; top: -100px; left: 1rem; z-index: 200; padding: 0.75rem; background: var(--ma-mint); color: #071d21; border-radius: 10px; }
.ma-skip:focus { top: 1rem; }
.ma-skip:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; padding: 0; }
.ma-header { width: min(1320px, 94vw); margin: 0 auto; min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; position: relative; z-index: 30; font-family: "Space Grotesk", "Manrope", sans-serif; }
.ma-brand { display: inline-flex; gap: 0.65rem; align-items: center; text-decoration: none; color: var(--ma-text); font-size: 0.86rem; font-weight: 700; letter-spacing: 0.12em; }
.ma-mark { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid rgba(165, 243, 213, 0.45); border-radius: 10px; color: var(--ma-mint); font-size: 1rem; letter-spacing: -0.12em; padding-right: 0.12em; }
.ma-header-actions { display: flex; align-items: center; gap: 0.55rem; }
.ma-sound, .ma-game-menu > summary { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; border: 1px solid var(--ma-line); background: rgba(14, 36, 50, 0.85); color: var(--ma-text); border-radius: 999px; min-height: 40px; padding: 0.4rem 0.9rem; font: inherit; font-size: 0.77rem; white-space: nowrap; }
.ma-sound::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #738d9b; }
.ma-sound[aria-pressed="true"]::before { background: var(--ma-mint); box-shadow: 0 0 9px #a5f3d555; }
.ma-game-menu { position: relative; }
.ma-game-menu > summary { list-style: none; cursor: pointer; }
.ma-game-menu > summary::-webkit-details-marker { display: none; }
.ma-game-menu > summary::after { content: "+"; color: var(--ma-mint); }
.ma-game-menu[open] > summary::after { content: "-"; }
.ma-game-links { position: absolute; right: 0; top: calc(100% + 10px); width: min(300px, 86vw); border: 1px solid var(--ma-line); border-radius: 18px; padding: 0.4rem; background: #0b202e; box-shadow: 0 20px 50px #020b15aa; }
.ma-game-links a { display: block; padding: 0.8rem 0.9rem; color: #c9dde4; text-decoration: none; font-size: 0.85rem; border-radius: 12px; }
.ma-game-links a:hover, .ma-game-links a[aria-current="page"] { background: #a5f3d510; color: var(--ma-mint); }
.ma-game-links small { display: block; color: var(--ma-muted); font-size: 0.66rem; margin-top: 0.2rem; }

body .hero, body .portal-hero { border-color: var(--ma-line); box-shadow: 0 12px 40px #020c1726; border-radius: var(--ma-radius); }
body .hero .subtitle, body .portal-subtitle { line-height: 1.65; }
body .hero .hero-art, body .portal-art { box-shadow: none; }
body .panel, body .card, body .block, body .board-card, body .control-card, body .game-panel { border-color: var(--ma-line); }
body .panel:hover, body .card:hover, body .block:hover, body .board-card:hover, body .control-card:hover, body .scene-box:hover, body .case-card:hover, body .game-panel:hover, body .monitor-frame:hover { transform: none; }
body .hero-art img, body .portal-art img { animation: none; object-fit: contain; }
.hud strong, .hud .value, #timerText, #timer-text { font-variant-numeric: tabular-nums; }
.option-btn, .action-btn { text-align: left; line-height: 1.5; white-space: normal; overflow-wrap: anywhere; }
.option-btn { min-height: 52px; }
.option-btn.correct { box-shadow: inset 3px 0 0 #a5f3d5; }
.option-btn.wrong { box-shadow: inset 3px 0 0 #ffb1a9; }
.explanation { line-height: 1.65; }
.next-case-btn { width: 100%; margin-top: 0.7rem; min-height: 46px; }
body .result-modal, body .modal, body #question-modal, body #winner-modal { z-index: 100; }
body[data-game="ecg-snapdx"] .monitor-frame .strip-stage { position: relative; inset: auto; }
body[data-game="ecg-snapdx"] .layout { align-items: start; }
.ma-runtime-note { color: var(--ma-muted); font-size: 0.78rem; line-height: 1.55; }
.powered-by { padding-bottom: env(safe-area-inset-bottom); }
.powered-by a { text-decoration: none; }
.ma-game-intro { padding: 1.2rem 0; display: flex; gap: 1rem; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--ma-line); }
.ma-game-intro p { margin: 0; color: var(--ma-muted); max-width: 66ch; font-size: 0.88rem; line-height: 1.6; }
.ma-game-intro span { color: var(--ma-mint); font-size: 0.72rem; letter-spacing: 0.12em; white-space: nowrap; }
body.running-ecg .hero, body.running-abg .hero, body.running-sepsis .hero { display: block; padding: 0.85rem 1.2rem !important; }
body.running-ecg .hero h1, body.running-abg .hero h1, body.running-sepsis .hero h1 { font-size: 1.65rem; margin: 0; }
body.running-ecg .hero :is(.eyebrow,.subtitle,.hero-meta,.link-line,.hero-art), body.running-abg .hero :is(.eyebrow,.subtitle,.hero-meta,.link-line,.hero-art), body.running-sepsis .hero :is(.eyebrow,.subtitle,.hero-meta,.link-line,.hero-art) { display: none; }

/* Fixed children must never inherit a transformed or filtered containing block. */
body.er-mobile-running .scene-panel, body.er-mobile-running .game-shell, body.er-mobile-running .game-grid { transform: none; filter: none; backdrop-filter: none; animation: none; }
body.running-ecg .monitor-panel, body.running-abg .monitor-panel, body.running-sepsis .monitor-panel { transform: none; }

@media (max-width: 900px) {
  .ma-header { min-height: 64px; width: 94vw; }
  .ma-brand { font-size: 0.75rem; gap: 0.45rem; }
  .ma-mark { width: 28px; height: 28px; border-radius: 9px; }
  .ma-sound, .ma-game-menu > summary { min-height: 42px; font-size: 0.7rem; padding: 0.4rem 0.65rem; }
  body .shell, body .app-shell { padding-top: 0.1rem; }
  body .panel, body .block, body .board-card, body .control-card, body .case-card, body .game-panel, body .hud-item { backdrop-filter: none; }
  body .hero h1, body .portal-hero h1 { font-size: clamp(1.85rem, 7.6vw, 2.8rem); line-height: 1.12; letter-spacing: -0.04em; }
  body .hero, body .portal-hero { padding: 1.1rem !important; }
  body .hero .subtitle, body .portal-subtitle { font-size: 0.88rem; line-height: 1.6; }
  body .hud { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.3rem; }
  body .hud-item { min-width: 0; padding: 0.5rem 0.35rem; border-radius: 10px; }
  body .hud-item .label { font-size: 0.59rem; letter-spacing: 0; white-space: normal; }
  body .hud-item strong { font-size: 1.05rem; }
  body.running-ecg .monitor-panel, body.running-abg .monitor-panel, body.running-sepsis .monitor-panel { top: calc(0.35rem + env(safe-area-inset-top)); background: #0b2030; border-radius: 16px; box-shadow: 0 8px 26px #020c1766; }
  body.running-ecg .control-panel > .block:first-child, body.running-abg .control-panel > .block:first-child, body.running-sepsis .control-panel > .block:first-child { display: none; }
  body.running-sepsis #scenarioText { max-height: 25svh; overflow-y: auto; scrollbar-width: thin; -webkit-line-clamp: unset; display: block; }
  body.running-sepsis .sepsis-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body.running-sepsis .sepsis-grid .sepsis-cell { min-height: 56px; padding: 0.3rem; }
  body.running-sepsis .sepsis-grid .sepsis-cell span { font-size: 0.55rem; line-height: 1.3; }
  body.running-sepsis #scenarioText { max-height: 20svh; overscroll-behavior: contain; }
  .option-btn, .action-btn { min-height: 54px; font-size: 0.9rem; padding: 0.85rem; }
  body.running-ecg .strip-stage img { max-height: 30svh; object-fit: contain; }
  body.running-ecg .ecg-paper-head { padding: 0.4rem 0.6rem; }
  body.running-ecg .ecg-paper-caption { padding: 0.35rem 0.5rem; font-size: 0.57rem; }
  body.er-mobile-running .hud { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body.er-mobile-running .game-shell { padding-top: calc(var(--er-hud-height, 84px) + 1rem + env(safe-area-inset-top)); }
  body.er-mobile-running.er-mobile-has-case .game-shell { padding-bottom: calc(var(--er-case-height, 150px) + 1.2rem + env(safe-area-inset-bottom)); }
  body.er-mobile-running #mobileCaseDockDesc { max-height: 24svh; font-size: 0.8rem; line-height: 1.5; }
  .ma-game-intro { align-items: flex-start; gap: 0.8rem; }
  .ma-game-intro span { font-size: 0.62rem; }
}
@media (max-width: 360px) {
  .ma-brand { letter-spacing: 0.05em; }
  .ma-sound { font-size: 0.65rem; padding-inline: 0.5rem; }
  .ma-header-actions { gap: 0.3rem; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
