:root {
  --navy: #102a43;
  --navy-soft: #274761;
  --teal: #087f82;
  --teal-dark: #075b63;
  --mint: #dff7f2;
  --paper: #fffdf7;
  --red: #ef4b5f;
  --red-dark: #b92742;
  --blue: #2a91d1;
  --blue-dark: #1766a3;
  --yellow: #ffd24d;
  --green: #37b878;
  --line: #8ecdc8;
}

* { box-sizing: border-box; }
html, body { min-width: 1100px; min-height: 720px; }
body { margin: 0; overflow: hidden; color: var(--navy); background: #bfeae8; font-family: "Avenir Next", Avenir, "Nunito Sans", "Segoe UI", sans-serif; }
button { font: inherit; }
[hidden] { display: none !important; }

.game-shell { position: relative; width: 100%; height: 100vh; min-height: 720px; padding: 18px 24px 22px; background: linear-gradient(#d9f6f2, #b9e6e7); }
.game-hud { width: min(1370px, 100%); height: 70px; margin: 0 auto 14px; display: grid; grid-template-columns: 300px 1fr 410px; align-items: center; gap: 22px; padding: 9px 14px 9px 18px; border: 3px solid rgba(16,42,67,.13); border-radius: 22px; background: rgba(255,253,247,.92); box-shadow: 0 6px 0 rgba(18,92,97,.16), 0 16px 30px rgba(16,42,67,.08); }
.brand-chip { display: flex; align-items: center; gap: 10px; }
.brand-chip > span:last-child, .stat { display: grid; }
.brand-chip small, .stat small, .mission-heading small, .evidence-card small, .difficulty-card small, .speech-bubble small { color: #527083; font-size: 10px; font-weight: 950; letter-spacing: .1em; text-transform: uppercase; }
.brand-chip strong { margin-top: 1px; font-size: 18px; line-height: 1; }
.brand-pulse { display: grid; place-items: center; width: 42px; height: 42px; border: 3px solid #fff; border-radius: 14px; background: var(--red); color: #fff; box-shadow: 0 4px 0 var(--red-dark); font-size: 22px; animation: idle-beat 2.2s ease-in-out infinite; }
.mission-track { display: flex; justify-content: center; gap: 14px; }
.mission-dot { position: relative; width: 46px; height: 10px; border-radius: 10px; background: #c6dcdd; box-shadow: inset 0 2px 3px rgba(16,42,67,.12); }
.mission-dot.is-done { background: var(--green); }
.mission-dot.is-active { background: var(--yellow); box-shadow: 0 0 0 4px rgba(255,210,77,.18); }
.hud-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { grid-template-columns: 26px 1fr; grid-template-rows: 17px 20px; align-items: center; padding: 5px 10px; border: 2px solid #d4e5e4; border-radius: 13px; background: #f7fbfa; }
.stat > span { grid-row: 1 / 3; font-size: 19px; }
.stat strong { font-size: 18px; line-height: 1; }

.game-grid { width: min(1370px, 100%); height: calc(100vh - 124px); min-height: 596px; margin: 0 auto; display: grid; grid-template-columns: 200px minmax(510px, 1fr) 310px; gap: 14px; }
.coach-card, .mission-card, .lab-stage { border: 3px solid rgba(16,42,67,.16); box-shadow: 0 7px 0 rgba(18,92,97,.17), 0 20px 34px rgba(16,42,67,.09); }
.coach-card { position: relative; overflow: hidden; display: grid; grid-template-rows: minmax(250px, 1fr) auto auto; border-radius: 26px; background: linear-gradient(180deg, #e7fbf6 0 57%, #fffdf7 57%); }
.coach-card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 22%, rgba(255,255,255,.9), transparent 46%); pointer-events: none; }
.doctor-wrap { position: relative; min-height: 0; overflow: hidden; }
.doctor-wrap img { position: absolute; width: 130%; max-width: none; left: -20%; bottom: -24%; filter: drop-shadow(0 7px 5px rgba(16,42,67,.18)); transform-origin: 50% 90%; }
.coach-card.is-cheering .doctor-wrap img { animation: mascot-cheer 620ms ease-out; }
.coach-card.is-worried .doctor-wrap img { animation: mascot-worry 330ms ease-out; }
.speech-bubble { position: relative; z-index: 2; margin: 0 12px 11px; padding: 13px 14px 14px; border: 3px solid var(--navy); border-radius: 17px; background: #fff; box-shadow: 0 4px 0 rgba(16,42,67,.13); }
.speech-bubble::before { content: ""; position: absolute; left: 32px; top: -13px; width: 19px; height: 19px; border: solid var(--navy); border-width: 3px 0 0 3px; background: white; transform: rotate(45deg); }
.speech-bubble p { margin: 5px 0 0; font-size: 13px; font-weight: 800; line-height: 1.36; }
.courier-roster { position: relative; z-index: 2; display: grid; grid-template-columns: 45px 1fr 45px; align-items: center; gap: 5px; margin: 0 10px 10px; padding: 9px 7px; border-radius: 16px; background: #dff4f4; text-align: center; }
.courier-roster strong, .courier-roster small { display: block; }
.courier-roster strong { font-size: 11px; }
.courier-roster small { margin-top: 2px; color: #567184; font-size: 9px; line-height: 1.25; }
.courier { width: 45px; height: 45px; background-image: url("art/blood-buddies.png"); background-repeat: no-repeat; background-size: 400% 200%; filter: drop-shadow(0 3px 2px rgba(16,42,67,.2)); }
.courier.red { background-position: 0 0; }
.courier.blue { background-position: 0 100%; }

.lab-stage { position: relative; min-width: 0; overflow: hidden; border-radius: 29px; background: #c9edef url("art/lab-backdrop-01.webp") center / cover no-repeat; isolation: isolate; }
.lab-stage::after { content: ""; position: absolute; z-index: -1; inset: 0; background: rgba(224,248,246,.26); }
.lab-glow { position: absolute; z-index: -1; left: 50%; top: 52%; width: 68%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.8), rgba(255,255,255,0) 68%); transform: translate(-50%,-50%); }
.heart-board { display: block; width: 100%; height: 100%; min-height: 596px; }
.evidence-card { position: absolute; z-index: 7; left: 14px; top: 14px; width: 248px; min-height: 60px; display: grid; grid-template-columns: 14px 1fr; align-items: center; gap: 9px; padding: 9px 12px; border: 3px solid rgba(16,42,67,.18); border-radius: 16px; background: rgba(255,253,247,.95); box-shadow: 0 5px 0 rgba(16,42,67,.12); }
.status-light { width: 13px; height: 13px; border: 3px solid #fff; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--green), 0 0 12px var(--green); }
.evidence-card strong { display: block; margin-top: 2px; font-size: 12px; line-height: 1.3; }
.difficulty-card { position: absolute; z-index: 7; right: 14px; top: 14px; width: 188px; padding: 9px 11px; border: 3px solid rgba(16,42,67,.18); border-radius: 16px; background: rgba(255,253,247,.95); box-shadow: 0 5px 0 rgba(16,42,67,.12); }
.difficulty-card > div:first-child { display: flex; justify-content: space-between; align-items: baseline; }
.difficulty-card strong { font-size: 13px; }
.difficulty-card > span { display: block; margin-top: 4px; color: var(--teal-dark); font-size: 10px; font-weight: 900; }
.difficulty-rail { height: 7px; margin-top: 5px; overflow: hidden; border-radius: 10px; background: #d5e7e7; }
.difficulty-rail i { display: block; width: 20%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--red)); transition: width 280ms ease-out; }

.world-label { fill: #f8fcfb; stroke: var(--navy); stroke-width: 5; opacity: .92; }
.world-label text { fill: var(--navy); stroke: none; font-size: 12px; font-weight: 950; letter-spacing: .11em; text-anchor: middle; }
.route { fill: none; stroke-width: 18; stroke-linecap: round; opacity: .86; }
.blue-route { stroke: #72c8ed; }
.red-route { stroke: #f58a91; }
.heart { transform-box: fill-box; transform-origin: center; }
.heart-shell { fill: #ffddd8; stroke: var(--navy); stroke-width: 9; }
.septum { fill: none; stroke: var(--navy); stroke-width: 8; stroke-linecap: round; opacity: .68; }
.chamber { stroke: var(--navy); stroke-width: 6; }
.chamber-blue { fill: #55b4e3; }
.chamber-red { fill: #f06473; }
.chamber-label text { fill: #fff; stroke: rgba(16,42,67,.35); stroke-width: 1.5; paint-order: stroke; font-size: 10px; font-weight: 950; letter-spacing: .06em; text-anchor: middle; }
.valve-line { fill: none; stroke: #fff3c4; stroke-width: 9; stroke-linecap: round; transition: stroke 150ms ease-out, transform 150ms ease-out; }
.pressure-ring { fill: none; stroke: var(--yellow); stroke-width: 11; opacity: 0; transform-box: fill-box; transform-origin: center; }
.flow-particles circle { stroke: #fff; stroke-width: 3; opacity: .8; }
.blue-particles circle { fill: #187bbb; }
.red-particles circle { fill: #d92f47; }
.backflow-path { opacity: 0; }
.backflow-path path { fill: none; stroke: var(--red-dark); stroke-width: 9; stroke-dasharray: 10 9; }
.backflow-path text { fill: var(--red-dark); font-size: 12px; font-weight: 950; letter-spacing: .07em; }

.lab-stage.is-squeezing .heart { animation: heart-squeeze 700ms ease-out; }
.lab-stage.is-squeezing .pressure-ring, .lab-stage.highlight-pressure .pressure-ring { animation: pressure-pop 720ms ease-out 2; }
.lab-stage.is-flowing .flow-particles circle { animation: blood-pop 680ms ease-out both; }
.lab-stage.is-flowing .flow-particles circle:nth-child(2n) { animation-delay: 90ms; }
.lab-stage.is-flowing .route { stroke-dasharray: 14 12; animation: route-flow 700ms linear infinite; }
.lab-stage.is-backflow .backflow-path { opacity: 1; animation: pop-in 180ms ease-out; }
.lab-stage.is-backflow .valve-left { stroke: var(--yellow); transform: rotate(16deg); transform-origin: center; }
.lab-stage.highlight-valves .valve-line { stroke: var(--yellow); filter: drop-shadow(0 0 6px #ffd24d); }
.lab-stage.is-miss { animation: miss-shake 320ms ease-out; }
.lab-stage.is-fast .heart { animation: fast-beat 470ms ease-in-out 2; }
.cause-chain { position: absolute; z-index: 8; left: 50%; bottom: 13px; display: flex; align-items: center; gap: 6px; max-width: calc(100% - 24px); padding: 8px; border: 3px solid rgba(16,42,67,.18); border-radius: 15px; background: rgba(255,253,247,.97); box-shadow: 0 5px 0 rgba(16,42,67,.13); transform: translateX(-50%); white-space: nowrap; }
.cause-chain span { padding: 6px 8px; border-radius: 9px; background: #dff4f1; color: var(--teal-dark); font-size: 11px; font-weight: 950; }
.cause-chain b { color: var(--red); }
.pop-layer { position: absolute; z-index: 10; inset: 0; pointer-events: none; }
.pop { position: absolute; left: 50%; top: 48%; color: var(--yellow); font-size: 28px; text-shadow: 0 2px 0 var(--red-dark); animation: score-pop 650ms ease-out forwards; }

.mission-card { position: relative; display: flex; flex-direction: column; padding: 22px 18px 18px; border-radius: 26px; background: rgba(255,253,247,.97); }
.mission-heading { min-height: 132px; }
.mission-heading small { color: var(--teal); }
.mission-heading h1 { margin: 6px 0 8px; font-size: 30px; line-height: 1.02; letter-spacing: -.035em; }
.mission-heading p { margin: 0; color: #4d697a; font-size: 14px; font-weight: 700; line-height: 1.38; }
.choice-list { display: grid; gap: 8px; margin-top: 12px; }
.choice { position: relative; min-height: 56px; display: grid; grid-template-columns: 35px 1fr; align-items: center; gap: 9px; padding: 8px 11px; border: 3px solid #c9dddc; border-radius: 15px; background: #f9fcfb; color: var(--navy); text-align: left; cursor: pointer; box-shadow: 0 3px 0 #c9dddc; transition: transform 140ms ease-out, border-color 140ms ease-out, background 140ms ease-out, box-shadow 140ms ease-out; }
.choice::before { content: attr(data-key); display: grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: #e1eeee; color: var(--teal-dark); font-size: 12px; font-weight: 950; }
.choice span { font-size: 13px; font-weight: 850; line-height: 1.24; }
.choice:hover { transform: translateY(-2px); border-color: var(--teal); box-shadow: 0 5px 0 #7db7b4; }
.choice[aria-checked="true"] { border-color: var(--teal); background: #dff5ef; box-shadow: 0 4px 0 var(--teal-dark), inset 0 0 0 1px #fff; }
.choice[aria-checked="true"]::before { background: var(--teal); color: #fff; }
.feedback { min-height: 37px; margin: 10px 1px 4px; color: var(--teal-dark); font-size: 12px; font-weight: 850; line-height: 1.3; }
.feedback.is-error { color: var(--red-dark); }
.pump-control { width: 100%; min-height: 72px; margin-top: auto; display: grid; grid-template-columns: 51px 1fr; align-items: center; gap: 11px; padding: 9px 14px; border: 0; border-radius: 19px; background: var(--red); color: #fff; text-align: left; cursor: pointer; box-shadow: 0 7px 0 var(--red-dark), 0 12px 22px rgba(185,39,66,.18); transition: transform 130ms ease-out, box-shadow 130ms ease-out; }
.pump-control:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 9px 0 var(--red-dark), 0 14px 24px rgba(185,39,66,.22); }
.pump-control:not(:disabled):active { transform: translateY(5px); box-shadow: 0 2px 0 var(--red-dark); }
.pump-control:disabled { background: #9bb1b6; box-shadow: 0 5px 0 #687f86; cursor: not-allowed; }
.pump-icon { display: grid; place-items: center; width: 51px; height: 51px; border: 3px solid rgba(255,255,255,.76); border-radius: 17px; background: rgba(255,255,255,.17); font-size: 27px; }
.pump-control small, .pump-control strong { display: block; }
.pump-control small { margin-bottom: 2px; font-size: 9px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; opacity: .84; }
.pump-control strong { font-size: 17px; }
.practice-note { display: flex; align-items: center; gap: 7px; margin-top: 11px; padding: 8px 10px; border-radius: 12px; background: #e5f5f3; }
.practice-note > span { font-size: 26px; font-weight: 900; color: var(--teal); }
.practice-note p, .practice-note strong, .practice-note small { display: block; margin: 0; }
.practice-note strong { font-size: 10px; }
.practice-note small { color: #567184; font-size: 9px; line-height: 1.25; }

.celebration { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; background: rgba(12,43,56,.58); backdrop-filter: blur(4px); }
.celebration-card { position: relative; width: 470px; padding: 85px 35px 30px; border: 4px solid var(--navy); border-radius: 30px; background: var(--paper); box-shadow: 0 12px 0 rgba(7,49,58,.36); text-align: center; animation: celebration-in 260ms cubic-bezier(.2,.9,.25,1.18); }
.prop-sprite { background-image: url("art/lab-props.png"); background-size: 200% 200%; background-repeat: no-repeat; }
.trophy { position: absolute; left: 50%; top: -85px; width: 190px; height: 190px; background-position: 0 0; transform: translateX(-50%); filter: drop-shadow(0 8px 4px rgba(16,42,67,.22)); animation: trophy-bob 900ms ease-in-out infinite alternate; }
.celebration-card > small { color: var(--teal); font-size: 11px; font-weight: 950; letter-spacing: .12em; text-transform: uppercase; }
.celebration-card h2 { margin: 8px 0; font-size: 29px; line-height: 1.08; }
.celebration-card p { margin: 0 auto 20px; max-width: 360px; color: #527083; font-size: 14px; font-weight: 700; line-height: 1.45; }
.continue-button { width: 100%; min-height: 54px; border: 0; border-radius: 15px; background: var(--teal); color: #fff; box-shadow: 0 6px 0 var(--teal-dark); cursor: pointer; font-weight: 950; }
.confetti, .confetti::before, .confetti::after { position: absolute; width: 12px; height: 24px; border-radius: 3px; background: var(--yellow); box-shadow: -260px 60px 0 var(--red), 260px 80px 0 var(--blue), -200px -110px 0 var(--blue), 215px -125px 0 var(--green), -325px -35px 0 var(--yellow), 330px -15px 0 var(--red); animation: confetti-fall 1.4s ease-in-out infinite alternate; }
.confetti::before, .confetti::after { content: ""; left: 0; top: 0; transform: rotate(55deg) scale(.75); }
.confetti::after { transform: rotate(-35deg) scale(.6); animation-delay: -.7s; }

button:focus-visible { outline: 4px solid #005bd7; outline-offset: 3px; }
@keyframes idle-beat { 0%, 8%, 18%, 100% { transform: scale(1); } 12% { transform: scale(1.12); } }
@keyframes mascot-cheer { 0% { transform: translateY(0) rotate(0); } 35% { transform: translateY(-16px) rotate(-3deg); } 65% { transform: translateY(-8px) rotate(3deg); } }
@keyframes mascot-worry { 25% { transform: rotate(-2deg); } 65% { transform: rotate(2deg); } }
@keyframes heart-squeeze { 0%,100% { transform: scale(1); } 40% { transform: scale(.88); } 66% { transform: scale(1.035); } }
@keyframes fast-beat { 0%,100% { transform: scale(1); } 45% { transform: scale(.9); } }
@keyframes pressure-pop { 0% { opacity: .95; transform: scale(.55); } 100% { opacity: 0; transform: scale(1.55); } }
@keyframes blood-pop { 0% { opacity: .2; transform: scale(.55); } 45% { opacity: 1; transform: scale(1.4); } 100% { opacity: .85; transform: scale(1); } }
@keyframes route-flow { to { stroke-dashoffset: -52; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.8); } }
@keyframes miss-shake { 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
@keyframes score-pop { 0% { opacity: 0; transform: translate(-50%,-10%) scale(.6) rotate(-8deg); } 35% { opacity: 1; transform: translate(-50%,-50%) scale(1.25) rotate(5deg); } 100% { opacity: 0; transform: translate(-50%,-180%) scale(.9); } }
@keyframes celebration-in { from { opacity: 0; transform: translateY(28px) scale(.88); } }
@keyframes trophy-bob { to { transform: translateX(-50%) translateY(-7px) rotate(2deg); } }
@keyframes confetti-fall { to { transform: translateY(34px) rotate(18deg); } }

@media (max-height: 790px) {
  .game-shell { padding-top: 10px; }
  .game-hud { height: 62px; margin-bottom: 10px; }
  .game-grid { height: calc(100vh - 94px); }
  .heart-board { min-height: 570px; }
  .doctor-wrap img { bottom: -31%; }
  .mission-card { padding-top: 16px; }
  .mission-heading { min-height: 118px; }
}
@media (min-width: 1300px) {
  .game-grid { grid-template-columns: 230px minmax(550px, 1fr) 340px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
