:root {
  --bg: #070b14;
  --panel: #0f1726;
  --panel-2: #141e31;
  --line: #22304a;
  --text: #e6ecf5;
  --muted: #8a97ad;
  --red: #ef4444;
  --green: #22c55e;
  --yellow: #eab308;
  --cyan: #22d3ee;
  --orange: #fb923c;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1040px; margin: 0 auto; padding: 16px;
}
.logo { margin: 0; font-size: 28px; font-weight: 900; letter-spacing: -.02em; color: var(--red); }
.logo span { color: var(--text); }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-weight: 700; cursor: pointer;
}

.topbar-buttons { display: flex; gap: 8px; }
.home-btn { font-size: 18px; line-height: 1; }

main { max-width: 1040px; margin: 0 auto; padding: 0 16px 48px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px;
}

.btn {
  font: inherit; font-weight: 600; padding: 12px 20px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.btn:hover { border-color: #3a4d70; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: #dc2626; }

/* start */
.start { text-align: center; padding: 40px 24px; margin-top: 24px; }
.start h2 { margin: 12px 0 8px; font-size: 26px; }
.start p { max-width: 520px; margin: 0 auto 24px; color: #c3cde0; }
.start .note { margin: 16px auto 0; }
.start-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.ekg svg { width: 100%; max-width: 360px; height: 60px; }
.ekg polyline {
  fill: none; stroke: var(--green); stroke-width: 2.5;
  stroke-dasharray: 600; stroke-dashoffset: 600; animation: trace 2.2s linear infinite;
}
@keyframes trace { to { stroke-dashoffset: 0; } }

/* game */
.grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid { grid-template-columns: 1fr; } }

.chart-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.p-name { font-size: 22px; font-weight: 700; }
.mode-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); white-space: nowrap;
}
.complaint { font-size: 18px; font-weight: 600; color: var(--orange); margin-bottom: 8px; }
.presentation { margin: 0; color: #c3cde0; }
.chart-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.chart .hint { margin: 14px 0 0; }

.monitor {
  background: #02050a; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.vital { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 8px; background: #060b14; }
.vlabel { font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.vval { font-size: 34px; font-weight: 700; line-height: 1.1; transition: color .3s; }
.vunit { font-size: 11px; color: var(--muted); }
.vtext { font-size: 15px; font-weight: 600; margin-top: 4px; }
.vital.hr { color: var(--green); }
.vital.bp { color: #f87171; }
.vital.spo2 { color: var(--cyan); }
.vital.rr { color: var(--yellow); }
.vital.temp { color: #c4b5fd; }
.vital.mental { color: var(--text); }
.vital.unknown .vval { color: #334155; }
.vital.unknown .vunit { font-style: italic; }
.vval.flash-up { animation: flashUp 1s; }
.vval.flash-down { animation: flashDown 1s; }
@keyframes flashUp { 0%, 40% { color: #fff; text-shadow: 0 0 12px var(--green); } }
@keyframes flashDown { 0%, 40% { color: #fff; text-shadow: 0 0 12px var(--red); } }
.vval.alarm { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

.action { margin-top: 16px; }
.timer { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.timer-bar { flex: 1; height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
#timer-fill { height: 100%; width: 100%; background: var(--green); border-radius: 999px; }
#timer-fill.warn { background: var(--yellow); }
#timer-fill.danger { background: var(--red); }
.timer-num { font: 700 22px ui-monospace, Menlo, monospace; min-width: 52px; text-align: right; }
.timer-num.danger { color: var(--red); }

.search-wrap { position: relative; }
.discharge { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.discharge-menu { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.ghost { background: transparent; border-color: transparent; }
#search {
  width: 100%; font: inherit; font-size: 18px; padding: 14px 16px; border-radius: 10px;
  border: 2px solid var(--line); background: #0a111e; color: var(--text); outline: none;
}
#search:focus { border-color: #3b82f6; }
#search:disabled { opacity: .6; }
#suggestions {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 6px);
  list-style: none; margin: 0; padding: 6px; max-height: 320px; overflow-y: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
#suggestions li {
  padding: 9px 12px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 12px;
}
#suggestions li .cat { color: var(--muted); font-size: 12px; white-space: nowrap; }
#suggestions li.active, #suggestions li:hover { background: #1f2c47; }
#suggestions li.used { opacity: .55; }
#suggestions li.empty { color: var(--muted); cursor: default; }

.latest {
  margin-top: 14px; padding: 14px 16px; border-radius: 10px; border-left: 4px solid var(--line);
  background: var(--panel-2);
}
.latest .t { font-weight: 700; margin-bottom: 2px; }
.latest.good { border-color: var(--green); }
.latest.neutral { border-color: var(--yellow); }
.latest.bad, .latest.timeout { border-color: var(--red); }

.log-panel { margin-top: 16px; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.log li { display: flex; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-radius: 8px; }
.log li .dot { flex: none; width: 12px; height: 12px; border-radius: 3px; margin-top: 6px; }
.log li.good .dot { background: var(--green); }
.log li.neutral .dot { background: var(--yellow); }
.log li.bad .dot { background: var(--red); }
.log li.timeout .dot { background: #111; border: 1px solid #555; }
.log li .n { font-weight: 600; }
.log li .r { color: #c3cde0; font-size: 14px; }
.log:empty::after { content: "No treatments yet. The clock is ticking."; color: var(--muted); }

body.hurt { animation: hurt .5s; }
@keyframes hurt { 0% { box-shadow: inset 0 0 0 9999px rgba(239,68,68,.18); } }

/* dialogs */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  color: var(--text); padding: 28px; max-width: 520px; width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(2,5,10,.75); }
.result h2 { margin: 0 0 4px; font-size: 28px; }
.result h2.won { color: var(--green); }
.result h2.lost { color: var(--red); }
.result h2.survived { color: var(--yellow, #d4a72c); }
#r-missing { margin: 4px 0 10px; padding-left: 20px; }
.emoji-grid { font-size: 22px; letter-spacing: 2px; margin: 14px 0; word-break: break-all; }
.dx { background: var(--panel-2); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; }
.dx-name { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.dx p { margin: 0 0 12px; color: #c3cde0; }
.dx p:last-child { margin-bottom: 0; }
.result-buttons { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.help ol { padding-left: 20px; }
.help li { margin-bottom: 8px; }
.legend { font-size: 14px; }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; font-size: 13px; }

/* difficulty picker */
.difficulty { max-width: 420px; margin: 0 auto 18px; text-align: left; }
.difficulty label { display: block; margin-bottom: 6px; }
.difficulty input[type=range] { width: 100%; accent-color: var(--red); }
.difficulty-scale { display: flex; justify-content: space-between; gap: 8px; }
.difficulty-scale span:nth-child(2) { text-align: center; color: var(--text); }

/* medications, conditions and allergies found so far */
.bg-list { margin: 4px 0 0; padding-left: 18px; }
.bg-list li { margin: 2px 0; }
.bg-list li.allergy { color: var(--orange); }
#r-code { margin: -2px 0 8px; }
