:root {
  --ink: #18252d;
  --ink-soft: #44545b;
  --panel: #e5e8df;
  --panel-dark: #b3bbb4;
  --line: #62716f;
  --orange: #d46b42;
  --orange-dark: #8d3d35;
  --red: #b52f39;
  --cream: #f9e9ce;
  --green: #567666;
  --shadow: rgba(12, 25, 32, 0.38);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  display: grid;
  place-items: center;
  min-width: 320px;
  background:
    radial-gradient(circle at 18% 12%, rgba(82, 104, 102, 0.35), transparent 26rem),
    radial-gradient(circle at 83% 80%, rgba(100, 60, 53, 0.28), transparent 30rem),
    #101b22;
  color: var(--ink);
  font-family: "Trebuchet MS", "Arial Narrow", sans-serif;
  overflow-x: hidden;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: min(1240px, 97vw);
  min-height: min(92vh, 900px);
  margin: 2vh auto;
  padding: 9px;
  border: 4px solid #2d3b43;
  border-radius: 11px;
  background: #67746f;
  box-shadow: 0 18px 45px var(--shadow), inset 0 0 0 2px #a2aaa2;
}

.chrome-strip {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 2px solid #35444a;
  border-bottom: 0;
  border-radius: 5px 5px 0 0;
  background: #27363d;
  color: #b5c4bb;
  font-family: "Courier New", monospace;
  font-size: 9px;
  letter-spacing: 0.13em;
}

.chrome-light {
  width: 7px;
  height: 7px;
  border: 1px solid #0b151b;
  border-radius: 50%;
  background: #bf6950;
  box-shadow: inset 1px 1px 2px #f3c29a;
}

.chrome-label {
  margin-left: 8px;
  opacity: 0.76;
}

.chrome-status {
  margin-left: auto;
  color: #9cd1a7;
}

.game-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 740px;
  overflow: hidden;
  border: 2px solid #2f3e43;
  border-radius: 0 0 5px 5px;
  background:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px),
    #d0d5cd;
  background-size: 17px 17px, 17px 17px, auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 78px;
  padding: 13px 24px 10px;
  border-bottom: 3px solid #74817b;
  background: linear-gradient(#ecf0e6, #cbd1c9);
  box-shadow: inset 0 -2px 0 rgba(255,255,255,0.7);
}

.eyebrow,
.stage-label,
.panel-tab,
.desk-tip,
.badge-med,
.overlay-kicker {
  margin: 0;
  color: #5c6b69;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin: 2px 0 0;
  color: #29383c;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(24px, 3.2vw, 40px);
  line-height: 0.98;
  letter-spacing: -0.04em;
  text-shadow: 1px 1px #fff;
}

.stage-readout {
  min-width: 170px;
  padding: 8px 11px;
  border: 2px solid #74817b;
  border-radius: 3px;
  background: rgba(247, 240, 217, 0.65);
  box-shadow: inset 1px 1px 0 #fff, 2px 2px 0 rgba(71, 79, 76, 0.25);
  text-align: right;
}

.stage-readout strong {
  display: inline-block;
  margin-top: 4px;
  color: #8b302e;
  font-family: Georgia, serif;
  font-size: 19px;
}

.stage-step {
  display: inline-block;
  margin-left: 5px;
  color: #65726d;
  font-family: "Courier New", monospace;
  font-size: 11px;
}

.clinic-layout {
  display: grid;
  grid-template-columns: minmax(200px, 0.28fr) minmax(0, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
  padding: 14px 16px 12px;
}

.panel-bevel {
  border: 2px solid #596865;
  background: linear-gradient(135deg, #e8ece3, #bac4bd);
  box-shadow: inset 2px 2px 0 rgba(255,255,255,0.84), inset -2px -2px 0 rgba(75,88,83,0.35), 3px 4px 0 rgba(50, 60, 58, 0.2);
}

.instruction-panel {
  position: relative;
  align-self: stretch;
  min-width: 0;
  padding: 18px 12px 12px;
  border-radius: 4px;
}

.panel-tab {
  position: absolute;
  top: -2px;
  left: 12px;
  padding: 4px 8px;
  border: 2px solid #596865;
  border-top: 0;
  background: #e5e8df;
  color: #4f6260;
  font-size: 9px;
}

.case-card {
  margin-top: 4px;
  padding: 12px 10px 10px;
  border: 1px dashed #8a958c;
  background: rgba(250, 244, 225, 0.5);
}

.case-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #7d3937;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
}

.case-dot,
.log-light,
.caption-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b64b42;
  box-shadow: 0 0 0 2px rgba(182, 75, 66, 0.16), inset 1px 1px 2px #f5c0a2;
}

.case-copy {
  margin: 8px 0 0;
  color: #344449;
  font-size: 12px;
  line-height: 1.4;
}

.hint-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 13px;
  padding: 10px 8px;
  border: 2px solid #c07955;
  background: #f1dbb9;
  box-shadow: inset 1px 1px 0 #fff3d7;
}

.hint-mark {
  display: grid;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: #a94137;
  color: #ffebbd;
  font-family: Georgia, serif;
  font-weight: 700;
}

.hint-box p {
  margin: 0;
  color: #493b33;
  font-size: 12px;
  line-height: 1.27;
}

.progress-block {
  margin-top: 17px;
}

.progress-heading {
  display: flex;
  justify-content: space-between;
  color: #566662;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
}

.progress-heading strong {
  color: #8a3a35;
}

.progress-track {
  height: 14px;
  margin-top: 5px;
  overflow: hidden;
  border: 2px solid #55635f;
  background: #87958c;
  box-shadow: inset 2px 2px 0 rgba(0,0,0,0.18);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(135deg, #a83c38 0 8px, #cb6550 8px 14px);
  transition: width 0.14s ease-out;
}

.message-log {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 18px;
  padding: 8px 7px;
  border-top: 2px dotted #89938d;
  border-bottom: 2px dotted #89938d;
}

.message-log .log-light {
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  background: #8a9a8e;
  box-shadow: none;
}

.message-log p {
  margin: 0;
  color: #4f5c5a;
  font-family: "Courier New", monospace;
  font-size: 10px;
  line-height: 1.3;
}

.medical-note {
  margin: auto 2px 0;
  color: #687670;
  font-family: "Courier New", monospace;
  font-size: 9px;
  line-height: 1.3;
}

.treatment-bay {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 2px solid #798781;
  border-radius: 4px;
  background: #65736e;
  box-shadow: inset 3px 3px 0 rgba(255,255,255,0.18), inset -3px -3px 0 rgba(21, 32, 35, 0.23);
}

.bay-sign {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 29px;
  padding: 0 11px;
  border-bottom: 2px solid #38494d;
  background: #39494d;
  color: #d1d7c6;
  font-family: "Courier New", monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.11em;
}

.sign-cross {
  display: grid;
  width: 15px;
  height: 15px;
  place-items: center;
  border: 1px solid #d98562;
  color: #f3ae82;
  font-size: 14px;
  line-height: 1;
}

.scene-wrap {
  position: relative;
  width: 100%;
  max-height: 100%;
  flex: 1;
  min-height: 330px;
  overflow: hidden;
  padding: 10px;
  cursor: crosshair;
}

.toe-scene {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 2px solid #485952;
  border-radius: 3px;
  background: #aab5ae;
  box-shadow: 0 4px 0 rgba(19, 27, 29, 0.25), inset 0 0 20px rgba(37, 50, 48, 0.28);
}

.toe-shadow {
  animation: shadow-breathe 3.3s ease-in-out infinite;
}

.inflammation-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: inflammation-pulse 1.55s ease-in-out infinite;
}

.skin-fold {
  stroke-linecap: round;
}

.raw-wound,
.raw-wound-inner,
.nail-bed {
  transition: opacity 0.45s ease, filter 0.45s ease;
}

.contamination {
  transition: opacity 0.8s ease, transform 0.4s ease;
}

.ingrown-piece {
  transform-box: fill-box;
  transform-origin: center left;
  transition: transform 0.2s ease-out, opacity 0.5s ease;
}

.nail-cut-line {
  transition: opacity 0.25s ease;
}

.scene-wrap.cleaned .contamination {
  opacity: 0.16;
}

.scene-wrap.cleaned .inflammation-pulse {
  opacity: 0.72;
  animation-duration: 2.8s;
}

.scene-wrap.cut .nail-cut-line {
  opacity: 1;
}

.scene-wrap.cut .ingrown-piece {
  filter: drop-shadow(2px 2px 0 rgba(91, 29, 32, 0.32));
}

.scene-wrap.removed .ingrown-piece,
.scene-wrap.removed .piece-glint,
.scene-wrap.removed .nail-cut-line {
  opacity: 0;
}

.scene-wrap.removed .blood-effects {
  opacity: 1;
  animation: blood-pop 0.55s ease-out both;
}

.scene-wrap.finished .blood-effects,
.scene-wrap.finished .raw-wound-inner {
  opacity: 0.25;
}

.scene-wrap.finished .inflammation-pulse {
  opacity: 0.22;
  animation-play-state: paused;
}

.scene-wrap.finished .aftercare-layer {
  opacity: 1;
  animation: dressing-fade 0.8s ease-out both;
}

.scene-wrap.finished .raw-wound,
.scene-wrap.finished .nail-bed {
  opacity: 0.38;
}

.target-label {
  position: absolute;
  z-index: 2;
  padding: 4px 6px;
  border: 1px solid rgba(255, 232, 193, 0.7);
  background: rgba(80, 34, 32, 0.8);
  color: #ffe8bd;
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.fragment-tray {
  position: absolute;
  z-index: 5;
  right: 24px;
  bottom: 27px;
  width: 108px;
  height: 50px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.2s ease;
}

.fragment-tray.visible {
  opacity: 1;
  pointer-events: auto;
}

.tray-plate {
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 102px;
  height: 38px;
  border: 2px solid #5d6c68;
  border-radius: 50% 50% 8px 8px;
  background: linear-gradient(#dfe4d8, #9ea9a1);
  box-shadow: inset 2px 2px 0 #fff, 2px 3px 0 rgba(41, 51, 48, 0.26);
}

.tray-fragment {
  position: absolute;
  left: 33px;
  top: 14px;
  width: 40px;
  height: 12px;
  border: 2px solid #75493e;
  border-radius: 70% 28% 60% 35%;
  background: linear-gradient(110deg, #f1d5ae, #b88167);
  box-shadow: inset 6px 2px 0 rgba(255, 240, 218, 0.42), 1px 2px 0 rgba(75, 36, 36, 0.28);
  transform-origin: center;
  transition: transform 0.15s ease-out;
}

.tray-fragment::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 2px;
  width: 7px;
  height: 3px;
  border-radius: 50%;
  background: #8c3337;
}

.tray-label {
  position: absolute;
  left: 13px;
  bottom: -11px;
  color: #f2e6c6;
  font-family: "Courier New", monospace;
  font-size: 8px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 1px 1px 0 #3d4c4b;
}

.label-swab {
  left: 31%;
  top: 51%;
}

.label-nipper {
  left: 66%;
  top: 43%;
}

.label-tweezers {
  left: 64%;
  top: 53%;
}

.scene-wrap.show-targets .target-label {
  opacity: 0.84;
}

.scene-wrap.active-swab .label-swab,
.scene-wrap.active-nippers .label-nipper,
.scene-wrap.active-tweezers .label-tweezers {
  opacity: 1;
  animation: target-blink 0.9s ease-in-out infinite;
}

.drag-ripple {
  position: absolute;
  z-index: 4;
  width: 30px;
  height: 30px;
  border: 2px solid #ffe2ad;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.35);
}

.drag-ripple.show {
  animation: ripple 0.42s ease-out;
}

.scene-particles .particle {
  fill: #f0c15b;
  opacity: 0;
}

.scene-wrap.cleaned .scene-particles .particle {
  animation: particle-fade 0.8s ease-out both;
}

.scene-wrap.cleaned .scene-particles .particle-a { animation-delay: 0.1s; }
.scene-wrap.cleaned .scene-particles .particle-b { animation-delay: 0.23s; }
.scene-wrap.cleaned .scene-particles .particle-c { animation-delay: 0.35s; }

.scene-caption {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-top: 2px solid #36474a;
  color: #e6e5d2;
  font-family: "Courier New", monospace;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.scene-caption .caption-dot {
  width: 5px;
  height: 5px;
  background: #f0bd73;
  box-shadow: none;
}

.tool-desk {
  position: relative;
  margin: 0 16px 16px;
  padding: 18px 12px 11px;
  border-radius: 4px;
}

.desk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}

.desk-tip {
  color: #6b7972;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tool-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 7px;
  padding: 8px 9px 7px 7px;
  border: 2px solid #62716d;
  border-radius: 3px;
  background: linear-gradient(135deg, #edf0e6, #c6cec3);
  color: var(--ink);
  text-align: left;
  cursor: grab;
  box-shadow: inset 1px 1px 0 #fff, 2px 2px 0 rgba(65, 73, 69, 0.22);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  touch-action: none;
  user-select: none;
}

.tool-card:hover,
.tool-card:focus-visible {
  z-index: 3;
  border-color: #ad593f;
  background: linear-gradient(135deg, #fff1d2, #e4ccb0);
  transform: translateY(-2px);
  outline: none;
}

.tool-card:active,
.tool-card.dragging {
  cursor: grabbing;
  transform: translateY(1px) rotate(-1deg);
}

.tool-card.is-correct {
  border-color: #ac5a3e;
  box-shadow: inset 0 0 0 2px rgba(207, 103, 67, 0.3), 2px 2px 0 rgba(65, 73, 69, 0.22);
}

.tool-card.wrong-tool {
  animation: wrong-tool 0.32s ease-in-out;
  border-color: #a33c39;
}

.tool-badge {
  position: absolute;
  top: 4px;
  left: 5px;
  color: #77837c;
  font-family: "Courier New", monospace;
  font-size: 8px;
}

.tool-icon {
  position: relative;
  grid-row: span 2;
  width: 35px;
  height: 35px;
  margin-top: 5px;
  border: 2px solid #64716b;
  border-radius: 50%;
  background: #d8ded4;
  box-shadow: inset 1px 1px 0 #fff;
}

.tool-name,
.tool-subtitle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tool-name {
  margin-top: 4px;
  color: #314148;
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 700;
}

.tool-subtitle {
  margin-top: 1px;
  color: #6a7772;
  font-family: "Courier New", monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.swab-stick {
  position: absolute;
  top: 15px;
  left: 9px;
  width: 24px;
  height: 4px;
  border-radius: 5px;
  background: #bd835c;
  transform: rotate(-35deg);
}

.swab-head {
  position: absolute;
  top: 6px;
  right: 3px;
  width: 14px;
  height: 8px;
  border-radius: 7px;
  background: #f4e4c4;
  box-shadow: inset -2px -1px 0 #d6bd9b;
  transform: rotate(-35deg);
}

.nipper-icon {
  background: #c9d3cd;
}

.nipper-ring {
  position: absolute;
  top: 19px;
  width: 10px;
  height: 10px;
  border: 3px solid #7b6659;
  border-radius: 50%;
}

.ring-left { left: 4px; }
.ring-right { right: 4px; }

.nipper-jaw {
  position: absolute;
  top: 5px;
  left: 14px;
  width: 5px;
  height: 23px;
  border-radius: 3px;
  background: #8f9c96;
  transform: rotate(42deg);
  box-shadow: 4px 1px 0 #6b7973;
}

.tweezer-icon {
  background: #d4d9d1;
}

.tweezer-icon span {
  position: absolute;
  top: 5px;
  left: 15px;
  width: 4px;
  height: 25px;
  border-radius: 4px 4px 2px 2px;
  background: #8e9b95;
  transform-origin: bottom;
}

.tweezer-icon span:first-child { transform: rotate(12deg); }
.tweezer-icon span:last-child { transform: rotate(-12deg); }

.salve-icon {
  background: #d7d4c9;
}

.salve-jar {
  position: absolute;
  left: 8px;
  bottom: 5px;
  width: 20px;
  height: 15px;
  border: 2px solid #846e5e;
  border-radius: 3px 3px 7px 7px;
  background: #e8bc6a;
}

.salve-lid {
  position: absolute;
  top: 8px;
  left: 7px;
  width: 22px;
  height: 7px;
  border: 2px solid #7e675b;
  border-radius: 3px;
  background: #b77d5c;
}

.salve-cross {
  position: absolute;
  top: 15px;
  left: 16px;
  color: #9c3532;
  font-weight: 700;
}

.screen-overlay {
  position: absolute;
  z-index: 20;
  inset: 33px 11px 11px;
  display: grid;
  place-items: center;
  padding: 30px 18px;
  background: rgba(21, 32, 37, 0.72);
  backdrop-filter: blur(3px);
}

.screen-overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(500px, 96%);
  padding: 33px 34px 25px;
  border: 3px solid #37474d;
  border-radius: 5px;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.24), transparent 40%),
    linear-gradient(#ebede1, #bec7be);
  box-shadow: inset 3px 3px 0 #fff6dc, inset -3px -3px 0 #78857d, 10px 13px 0 rgba(15, 23, 27, 0.4);
  text-align: center;
}

.badge-med {
  display: inline-block;
  padding: 5px 7px;
  border: 1px solid #8a6b59;
  background: #e2b985;
  color: #643d34;
  font-size: 9px;
}

.success-badge {
  background: #b2caa6;
  border-color: #5d765e;
  color: #36573e;
}

.overlay-art,
.complete-art {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 18px auto 13px;
  border: 3px solid #6b7b73;
  border-radius: 50%;
  background: #bdc9be;
  box-shadow: inset 2px 2px 0 #eef3df, 4px 4px 0 rgba(47, 61, 59, 0.3);
}

.mini-toe {
  position: absolute;
  left: 22px;
  top: 15px;
  width: 42px;
  height: 55px;
  border-radius: 48% 52% 46% 45%;
  background: linear-gradient(130deg, #f2c6a9, #bd6c5d);
  transform: rotate(-18deg);
  box-shadow: inset 7px 4px 0 rgba(255, 235, 208, 0.28);
}

.mini-toe::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 14px;
  width: 16px;
  height: 20px;
  border-radius: 45%;
  background: #a42830;
  box-shadow: inset 4px 2px 0 #f0b14f;
}

.mini-pulse {
  position: absolute;
  right: 10px;
  top: 21px;
  width: 12px;
  height: 12px;
  border: 2px solid #c13b3e;
  border-radius: 50%;
  animation: inflammation-pulse 1.5s ease-in-out infinite;
}

.overlay-kicker {
  color: #69766f;
  font-size: 10px;
}

.overlay-card h2 {
  margin: 5px 0 12px;
  color: #263840;
  font-family: Georgia, serif;
  font-size: clamp(27px, 4vw, 42px);
  line-height: 0.98;
  letter-spacing: -0.045em;
  text-shadow: 1px 1px #fff;
}

.overlay-copy {
  margin-bottom: 21px;
  color: #4d5b5b;
  font-size: 14px;
  line-height: 1.45;
}

.primary-button {
  min-width: 190px;
  padding: 12px 20px 11px;
  border: 3px solid #713a35;
  border-radius: 3px;
  background: linear-gradient(#d98558, #a9473c);
  color: #fff2d2;
  font-family: "Courier New", monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.13em;
  cursor: pointer;
  box-shadow: inset 2px 2px 0 rgba(255, 231, 183, 0.4), 4px 4px 0 #4b3938;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  filter: brightness(1.12);
  outline: none;
}

.primary-button:active {
  transform: translate(2px, 2px);
  box-shadow: inset 2px 2px 0 rgba(255, 231, 183, 0.4), 2px 2px 0 #4b3938;
}

.primary-button span {
  margin-left: 7px;
  font-size: 13px;
}

.overlay-footnote {
  margin: 20px 0 0;
  color: #718078;
  font-family: "Courier New", monospace;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.complete-art {
  border-color: #58725d;
  background: #bbceb0;
}

.check-mark {
  position: absolute;
  inset: 5px;
  display: grid;
  place-items: center;
  border: 3px solid #54705a;
  border-radius: 50%;
  color: #46654f;
  font-family: Georgia, serif;
  font-size: 52px;
  line-height: 1;
}

.spark {
  position: absolute;
  color: #b66c40;
  font-size: 17px;
  animation: spark-pop 1.2s ease-in-out infinite;
}

.spark-one { right: -17px; top: 4px; }
.spark-two { left: -17px; bottom: 9px; animation-delay: 0.35s; }

.complete-card .overlay-copy {
  margin-bottom: 18px;
}

.drag-ghost {
  position: fixed;
  z-index: 50;
  width: 130px;
  padding: 8px 10px;
  border: 2px solid #8e3c38;
  background: rgba(244, 222, 185, 0.94);
  color: #5c3230;
  font-family: "Courier New", monospace;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  box-shadow: 3px 3px 0 rgba(38, 36, 32, 0.35);
  transform: translate(-50%, -135%);
}

body.dragging-tool {
  cursor: grabbing;
}

@keyframes inflammation-pulse {
  0%, 100% { transform: scale(0.95); opacity: 0.72; }
  50% { transform: scale(1.06); opacity: 0.96; }
}

@keyframes shadow-breathe {
  0%, 100% { opacity: 0.22; transform: scaleX(0.98); }
  50% { opacity: 0.34; transform: scaleX(1.03); }
}

@keyframes target-blink {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

@keyframes ripple {
  0% { opacity: 0.8; transform: translate(-50%, -50%) scale(0.35); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.55); }
}

@keyframes particle-fade {
  0% { opacity: 0; transform: translate(0, 0); }
  40% { opacity: 0.8; }
  100% { opacity: 0; transform: translate(0, -19px); }
}

@keyframes blood-pop {
  0% { opacity: 0; transform: scale(0.6); transform-origin: center; }
  55% { opacity: 1; }
  100% { opacity: 0.92; transform: scale(1); }
}

@keyframes dressing-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

@keyframes wrong-tool {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes spark-pop {
  0%, 100% { opacity: 0.35; transform: scale(0.82) rotate(-8deg); }
  50% { opacity: 1; transform: scale(1.12) rotate(8deg); }
}

@media (max-width: 900px) {
  .game-shell {
    width: 99vw;
    min-height: 0;
    margin: 0.5vh auto;
  }

  .game-stage {
    min-height: 0;
  }

  .clinic-layout {
    grid-template-columns: 205px minmax(0, 1fr);
  }

  .tool-name {
    font-size: 12px;
  }
}

@media (max-width: 700px) {
  body {
    display: block;
  }

  .game-shell {
    width: 100vw;
    margin: 0;
    border-width: 2px;
    border-radius: 0;
  }

  .chrome-strip {
    border-radius: 0;
  }

  .top-bar {
    padding: 12px 14px 10px;
  }

  .stage-readout {
    min-width: 132px;
  }

  .clinic-layout {
    grid-template-columns: 1fr;
  }

  .instruction-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-top: 18px;
  }

  .case-card,
  .hint-box,
  .progress-block,
  .message-log,
  .medical-note {
    margin-top: 4px;
  }

  .medical-note {
    grid-column: span 2;
  }

  .treatment-bay {
    min-height: 390px;
  }

  .tool-desk {
    margin: 0 12px 12px;
  }

  .tool-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 22px;
  }

  .eyebrow {
    font-size: 8px;
  }

  .stage-readout {
    min-width: 110px;
    padding: 6px;
  }

  .stage-readout strong {
    font-size: 15px;
  }

  .instruction-panel {
    display: block;
  }

  .medical-note {
    margin-top: 11px;
  }

  .scene-wrap {
    min-height: 290px;
  }

  .overlay-card {
    padding: 25px 16px 19px;
  }
}

/*
  실행 방법: index.html과 같은 폴더에 두고 브라우저에서 index.html을 엽니다.
  다음 개선 포인트: 도구별 커서 스킨, 사운드 파일, 더 다양한 환부 상태와 저장 가능한 최고 점수를 추가합니다.
*/

/* 자유형 치료 시뮬레이션 HUD */
.top-bar {
  align-items: flex-start;
}

.patient-hud {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: min(620px, 57%);
  padding: 7px 8px;
  border: 2px solid #6b7973;
  border-radius: 3px;
  background: rgba(245, 239, 217, 0.74);
  box-shadow: inset 1px 1px 0 #fff, 2px 2px 0 rgba(71, 79, 76, 0.22);
}

.patient-hud-title {
  display: flex;
  flex-direction: column;
  min-width: 60px;
  padding-top: 2px;
}

.patient-hud-title strong {
  margin-top: 5px;
  color: #3f7351;
  font-family: Georgia, serif;
  font-size: 16px;
}

.patient-hud-title strong[data-level="warning"] {
  color: #a96332;
}

.patient-hud-title strong[data-level="critical"] {
  color: #a32635;
  animation: danger-text-pulse 0.8s ease-in-out infinite;
}

.sound-toggle {
  align-self: center;
  flex: 0 0 auto;
  padding: 7px 8px;
  border: 2px solid #66756f;
  border-radius: 3px;
  background: #d9dfd3;
  color: #415252;
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 1px 1px 0 #fff, 2px 2px 0 rgba(65, 73, 69, 0.18);
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  background: #f1dcbb;
  outline: none;
}

.sound-toggle[aria-pressed="true"] {
  background: #c6cfca;
  color: #7a3d3b;
}

.patient-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(65px, 1fr));
  gap: 6px;
  flex: 1;
}

.patient-stat {
  min-width: 0;
  padding: 4px 5px 5px;
  border: 1px solid #87938b;
  background: rgba(223, 229, 218, 0.7);
}

.stat-label {
  display: flex;
  justify-content: space-between;
  gap: 3px;
  color: #4e5d5a;
  font-family: "Courier New", monospace;
  font-size: 9px;
  font-weight: 700;
}

.stat-label strong {
  color: #32464b;
}

.metric-track {
  height: 7px;
  margin-top: 5px;
  overflow: hidden;
  border: 1px solid #65736e;
  background: #8e9b91;
  box-shadow: inset 1px 1px 0 rgba(0,0,0,0.15);
}

.metric-fill {
  display: block;
  width: 0;
  height: 100%;
  background: #5c9b69;
  transition: width 0.22s ease, background 0.22s ease;
}

.pain-stat .metric-fill,
.inflame-stat .metric-fill {
  background: #d18a4c;
}

.bleed-stat .metric-fill {
  background: #b93642;
}

.game-shell[data-status="warning"] .hp-stat .metric-fill {
  background: #c68542;
}

.game-shell[data-status="critical"] .hp-stat .metric-fill {
  background: #b52f39;
  animation: hp-danger-pulse 0.72s ease-in-out infinite;
}

.cause-note {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 10px;
  padding: 8px 7px;
  border-top: 1px dotted #89938d;
  border-bottom: 1px dotted #89938d;
}

.cause-light {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-top: 3px;
  border-radius: 50%;
  background: #bd6844;
  box-shadow: 0 0 0 2px rgba(189, 104, 68, 0.16);
}

.cause-note p {
  margin: 0;
  color: #5b6560;
  font-family: "Courier New", monospace;
  font-size: 9px;
  line-height: 1.35;
}

.tool-card.selected {
  border-color: #ad593f;
  background: linear-gradient(135deg, #fff1d2, #e4ccb0);
  box-shadow: inset 0 0 0 2px rgba(207, 103, 67, 0.3), 2px 2px 0 rgba(65, 73, 69, 0.22);
}

.tool-card.selected::after {
  content: "선택됨";
  position: absolute;
  right: 5px;
  top: 4px;
  color: #984735;
  font-family: "Courier New", monospace;
  font-size: 8px;
  font-weight: 700;
}

.drag-ghost {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 144px;
  min-height: 40px;
  padding: 5px 8px;
  border-radius: 3px;
  background: rgba(244, 222, 185, 0.96);
}

.ghost-tool-art {
  position: relative;
  display: inline-block;
  flex: 0 0 25px;
  width: 25px;
  height: 25px;
  border: 1px solid #806458;
  border-radius: 50%;
  background: #dfd9c8;
  box-shadow: inset 1px 1px 0 #fff5da;
}

.ghost-tool-art::before,
.ghost-tool-art::after {
  content: "";
  position: absolute;
  display: block;
}

.ghost-swab .ghost-tool-art::before {
  top: 11px;
  left: 4px;
  width: 18px;
  height: 3px;
  border-radius: 3px;
  background: #ad704f;
  transform: rotate(-34deg);
}

.ghost-swab .ghost-tool-art::after {
  top: 5px;
  right: 2px;
  width: 9px;
  height: 6px;
  border-radius: 6px;
  background: #f8e4c1;
  transform: rotate(-34deg);
}

.ghost-nippers .ghost-tool-art::before {
  top: 4px;
  left: 10px;
  width: 4px;
  height: 18px;
  border-radius: 4px;
  background: #7b8982;
  transform: rotate(42deg);
  box-shadow: 4px 1px 0 #62706b;
}

.ghost-nippers .ghost-tool-art::after {
  bottom: 2px;
  left: 6px;
  width: 13px;
  height: 7px;
  border: 2px solid #876956;
  border-radius: 50%;
}

.ghost-tweezers .ghost-tool-art::before,
.ghost-tweezers .ghost-tool-art::after {
  top: 3px;
  left: 10px;
  width: 3px;
  height: 19px;
  border-radius: 4px;
  background: #7f9089;
}

.ghost-tweezers .ghost-tool-art::before { transform: rotate(11deg); }
.ghost-tweezers .ghost-tool-art::after { transform: rotate(-11deg); }

.ghost-salve .ghost-tool-art::before {
  left: 5px;
  bottom: 3px;
  width: 15px;
  height: 12px;
  border: 2px solid #886d59;
  border-radius: 3px 3px 6px 6px;
  background: #e7b965;
}

.ghost-salve .ghost-tool-art::after {
  left: 4px;
  top: 6px;
  width: 17px;
  height: 6px;
  border: 2px solid #806456;
  border-radius: 3px;
  background: #b87d5b;
}

.ghost-swab.is-dirty .ghost-tool-art::after {
  background: #b83d39;
  box-shadow: 3px 2px 0 #dfb44b;
}

.scene-wrap .blood-effects {
  transition: opacity 0.32s ease, transform 0.3s ease;
}

.treatment-canvas {
  position: absolute;
  z-index: 3;
  left: 12px;
  top: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  pointer-events: none;
}

.drag-ghost {
  transform: translate(-50%, -135%) rotate(0deg);
  transform-origin: 50% 88%;
  transition: transform 0.08s ease-out;
}

.drag-ghost .ghost-tool-art {
  transition: transform 0.12s ease-out, filter 0.12s ease-out;
}

.drag-ghost.is-pressed .ghost-tool-art {
  filter: brightness(0.88) saturate(1.25);
  transform: translateY(2px) scale(0.95);
}

.drag-ghost.outside-game {
  opacity: 0;
}

.ghost-nippers.is-pressed .ghost-tool-art::before {
  transform: rotate(26deg);
}

.ghost-tweezers.is-pressed .ghost-tool-art::before {
  transform: rotate(5deg);
}

.ghost-tweezers.is-pressed .ghost-tool-art::after {
  transform: rotate(-5deg);
}

.scene-wrap.finished .aftercare-layer {
  opacity: 1;
}

.game-shell.game-over .game-stage {
  filter: brightness(0.42) saturate(0.72);
  transition: filter 0.35s ease;
}

.game-shell.damage-flash::after {
  content: "";
  position: absolute;
  z-index: 19;
  inset: 9px;
  border-radius: 7px;
  background: rgba(170, 23, 32, 0.38);
  pointer-events: none;
  animation: damage-flash 0.23s ease-out both;
}

.ending-stats {
  display: grid;
  gap: 5px;
  margin: 0 auto 18px;
  padding: 8px;
  border: 1px dashed #87938a;
  background: rgba(240, 234, 213, 0.56);
}

.success-stats {
  grid-template-columns: repeat(3, 1fr);
}

.death-stats {
  grid-template-columns: repeat(5, 1fr);
}

.ending-stats div {
  min-width: 0;
  padding: 5px 3px;
  border: 1px solid rgba(100, 111, 103, 0.48);
}

.ending-stats span,
.ending-stats strong {
  display: block;
}

.ending-stats span {
  color: #65736c;
  font-family: "Courier New", monospace;
  font-size: 8px;
}

.ending-stats strong {
  margin-top: 3px;
  color: #3c4d4e;
  font-family: Georgia, serif;
  font-size: 15px;
}

.death-card {
  border-color: #523b40;
  background: linear-gradient(135deg, rgba(255,255,255,0.16), transparent 40%), linear-gradient(#d6d8cf, #9fa9a1);
}

.death-badge {
  border-color: #87333c;
  background: #bc6259;
  color: #fff0d3;
}

.flatline-art {
  position: relative;
  width: 270px;
  height: 78px;
  margin: 17px auto 13px;
  overflow: hidden;
  border: 2px solid #3f5254;
  background: #17252a;
  box-shadow: inset 0 0 0 3px rgba(11, 18, 21, 0.4), 4px 4px 0 rgba(48, 51, 48, 0.3);
}

.flatline-grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(96, 175, 133, 0.13) 1px, transparent 1px), linear-gradient(90deg, rgba(96, 175, 133, 0.13) 1px, transparent 1px);
  background-size: 18px 18px;
}

.flatline-line {
  position: absolute;
  left: 7px;
  right: 7px;
  top: 33px;
  color: #b83f4b;
  font-family: "Courier New", monospace;
  font-size: 20px;
  letter-spacing: 2px;
  text-shadow: 0 0 6px rgba(220, 57, 70, 0.7);
  animation: flatline-glow 1.2s ease-in-out infinite;
}

.flatline-dot {
  position: absolute;
  top: 31px;
  right: 17px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e05c60;
  box-shadow: 0 0 8px #e05c60;
  animation: flatline-dot 1.2s steps(2, end) infinite;
}

.failure-cause {
  margin: 0 auto 16px;
  color: #713e40;
  font-family: "Courier New", monospace;
  font-size: 10px;
  line-height: 1.35;
}

.ending-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.secondary-button {
  min-width: 120px;
  padding: 11px 14px 10px;
  border: 3px solid #52635e;
  border-radius: 3px;
  background: linear-gradient(#d6ddd2, #9eaca1);
  color: #35484c;
  font-family: "Courier New", monospace;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 2px 2px 0 #f4f4dd, 3px 3px 0 #4b5654;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  filter: brightness(1.08);
  outline: none;
}

@keyframes danger-text-pulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@keyframes hp-danger-pulse {
  0%, 100% { filter: brightness(0.9); }
  50% { filter: brightness(1.4); }
}

@keyframes damage-flash {
  0% { opacity: 0.82; }
  100% { opacity: 0; }
}

@keyframes flatline-glow {
  0%, 100% { opacity: 0.75; }
  50% { opacity: 1; }
}

@keyframes flatline-dot {
  0%, 80% { opacity: 1; }
  81%, 100% { opacity: 0.2; }
}

@media (max-width: 900px) {
  .top-bar {
    flex-direction: column;
    gap: 10px;
  }

  .patient-hud {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .patient-hud {
    display: block;
  }

  .patient-hud-title {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 5px;
  }

  .patient-hud-title strong {
    margin-top: 0;
  }

  .patient-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .success-stats,
  .death-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .flatline-art {
    width: min(270px, 90%);
  }
}
