:root {
  color-scheme: dark;
  --paper: #eaf4f1;
  --paper-dim: #a7c2c0;
  --ink: #071d2b;
  --ink-2: #0c2d3d;
  --grid-line: rgba(93, 217, 255, .13);
  --cyan: #5dd9ff;
  --cyan-soft: #b4f0ff;
  --red: #ff5f6d;
  --red-deep: #c6334c;
  --yellow: #ffd166;
  --mint: #67e0b5;
  --orange: #ff9f5a;
  --shadow: 0 16px 44px rgba(0, 0, 0, .28);
  font-family: "Yu Gothic UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--ink); scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background-color: var(--ink);
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    radial-gradient(circle at 50% 8%, rgba(31, 102, 122, .54), transparent 39%);
  background-size: 28px 28px, 28px 28px, auto;
  overflow-x: hidden;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 4px; }
.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 50; padding: .8rem 1rem; color: var(--ink); background: var(--yellow); font-weight: 800; }
.skip-link:focus { top: 1rem; }
.app-shell { width: min(1180px, calc(100% - 24px)); margin: 0 auto; padding: 18px 0 64px; }

.masthead { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding: 18px 0 20px; border-bottom: 1px solid rgba(180, 240, 255, .42); }
.eyebrow, .chapter-mark { margin: 0 0 .4rem; color: var(--cyan); font-family: Consolas, monospace; letter-spacing: .12em; font-size: .78rem; font-weight: 800; }
h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 3.8rem); line-height: 1; letter-spacing: .04em; }
.subtitle { margin: .7rem 0 0; color: var(--paper-dim); font-weight: 700; }
.ink-button { border: 1px solid var(--cyan); background: var(--ink-2); color: var(--paper); padding: .72rem 1rem; min-height: 44px; cursor: pointer; box-shadow: 4px 4px 0 rgba(93, 217, 255, .25); }
.ink-button:hover { background: #123f50; }

.intro-sheet {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, .75fr);
  gap: clamp(1.4rem, 4vw, 4rem);
  margin-top: 28px;
  padding: clamp(24px, 5vw, 58px);
  border: 2px solid var(--cyan);
  background: rgba(7, 29, 43, .93);
  box-shadow: var(--shadow), inset 0 0 0 8px rgba(93, 217, 255, .05);
  overflow: hidden;
}
.intro-sheet::before { content: "HUMAN BODY / FLOW MAP"; position: absolute; right: -24px; top: 18px; color: rgba(180, 240, 255, .18); font: 800 clamp(1rem, 3vw, 2.5rem)/1 Consolas, monospace; transform: rotate(3deg); }
.intro-copy h2 { margin: 0 0 1rem; max-width: 18ch; font-size: clamp(2rem, 6vw, 4.5rem); line-height: 1.05; }
.intro-copy > p { max-width: 52rem; line-height: 1.9; }
.model-note { padding: .8rem 1rem; border-left: 4px solid var(--yellow); background: rgba(255, 209, 102, .09); color: #fff5cf; font-size: .94rem; }
.intro-steps { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: .7rem; }
.intro-steps li { display: flex; align-items: center; gap: .8rem; line-height: 1.5; }
.intro-steps span { flex: 0 0 32px; display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid var(--cyan); color: var(--cyan); font-family: Consolas, monospace; }
.intro-figure { position: relative; align-self: stretch; min-height: 320px; border-left: 1px dashed rgba(180, 240, 255, .45); background: radial-gradient(circle at center, rgba(93, 217, 255, .14), transparent 58%); }
.intro-figure::before, .intro-figure::after { content: ""; position: absolute; inset: 12% 10%; border: 3px solid var(--red); border-left-color: transparent; border-radius: 50%; transform: rotate(-20deg); }
.intro-figure::after { inset: 25% 23%; border-color: var(--cyan); border-right-color: transparent; transform: rotate(35deg); }
.drop { position: absolute; width: 30px; height: 42px; border-radius: 55% 55% 58% 58% / 68% 68% 35% 35%; background: var(--red); box-shadow: 0 0 18px rgba(255, 95, 109, .75); transform: rotate(45deg); }
.drop-a { left: 45%; top: 15%; }.drop-b { right: 14%; top: 54%; }.drop-c { left: 18%; bottom: 12%; }
.loop-arrow { position: absolute; inset: auto 1rem 1rem; color: var(--cyan-soft); text-align: center; font: 700 .86rem/1.5 Consolas, monospace; }
.start-button { grid-column: 1 / -1; justify-self: start; border: 0; min-height: 54px; padding: .9rem 1.4rem; background: var(--red); color: #17050a; font-weight: 900; cursor: pointer; box-shadow: 6px 6px 0 #7e2638; }
.start-button:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 #7e2638; }

.play-screen { margin-top: 18px; }
.status-rail { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid rgba(180, 240, 255, .36); background: rgba(5, 23, 35, .9); }
.status-rail div { padding: .65rem .85rem; min-width: 0; border-right: 1px solid rgba(180, 240, 255, .22); }
.status-rail div:last-child { border-right: 0; }
.status-rail span { display: block; color: var(--paper-dim); font-size: .72rem; }
.status-rail strong { display: block; margin-top: .2rem; color: var(--paper); font-family: Consolas, monospace; font-size: clamp(1rem, 3vw, 1.45rem); overflow-wrap: anywhere; }
.phase-strip { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: .7rem 1rem; padding: .8rem 1rem; border-bottom: 1px solid rgba(93, 217, 255, .35); }
.phase-strip span:first-child { color: var(--cyan); font: 800 .78rem Consolas, monospace; }
.phase-strip strong { font-size: 1.2rem; }
.phase-strip span:last-child { color: var(--paper-dim); }
.danger-banner { display: flex; align-items: center; gap: .7rem; margin: 10px 0; padding: .7rem 1rem; border-left: 6px solid var(--mint); background: rgba(103, 224, 181, .08); color: #d9fff1; }
.danger-banner.is-warning { border-left-color: var(--orange); background: rgba(255, 159, 90, .13); color: #ffe6d3; }
.danger-banner.is-critical { border-left-color: var(--red); background: rgba(255, 95, 109, .15); color: #ffe1e5; }
.danger-icon { font-size: 1.4rem; font-weight: 900; }

.body-world {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas: "activity activity" "body ledger" "controls controls" "pump pump";
  gap: 14px;
  padding: 14px;
  border: 2px solid rgba(93, 217, 255, .55);
  background: rgba(4, 21, 32, .88);
  box-shadow: var(--shadow);
  touch-action: pan-y;
}
.activity-note { grid-area: activity; display: flex; align-items: baseline; flex-wrap: wrap; gap: .5rem 1rem; padding: .75rem 1rem; border: 1px dashed var(--yellow); background: rgba(255, 209, 102, .06); }
.activity-note span { color: var(--yellow); font: 800 .73rem Consolas, monospace; }.activity-note strong { font-size: 1.3rem; }.activity-note p { margin: 0; color: var(--paper-dim); }
.body-map { grid-area: body; position: relative; min-height: 620px; border: 1px solid rgba(180, 240, 255, .34); background: linear-gradient(180deg, rgba(10, 49, 64, .62), rgba(4, 21, 32, .35)); overflow: hidden; }
.body-map::before { content: "FLOW FIELD"; position: absolute; left: .7rem; top: .5rem; color: rgba(180, 240, 255, .28); font: 800 .72rem Consolas, monospace; letter-spacing: .16em; }
.body-map svg { display: block; width: min(100%, 520px); height: auto; max-height: 690px; margin: 0 auto; overflow: visible; }
.silhouette { fill: rgba(180, 240, 255, .035); stroke: rgba(180, 240, 255, .42); stroke-width: 2; stroke-dasharray: 7 7; }
.route { fill: none; stroke-width: 9; stroke-linecap: round; opacity: .8; }
.route.outbound, .route.upper { stroke: var(--red); }.route.return { stroke: var(--cyan); }.route.upper { stroke-width: 6; }
.organ path { stroke-width: 3; }.organ text { fill: var(--paper); text-anchor: middle; font-size: 23px; font-weight: 900; paint-order: stroke; stroke: var(--ink); stroke-width: 5px; }
.lungs > path:not(.organ-detail) { fill: rgba(93, 217, 255, .2); stroke: var(--cyan); }.heart path { fill: var(--red-deep); stroke: #ff9aa5; }.gut > path:not(.organ-detail) { fill: rgba(255, 209, 102, .18); stroke: var(--yellow); }
.organ-detail { fill: none; stroke: var(--paper-dim); stroke-linecap: round; stroke-linejoin: round; }
.blood-dot { fill: var(--red); stroke: #ffd2d7; stroke-width: 2; }
.cell-cluster circle { fill: rgba(103, 224, 181, .18); stroke: var(--mint); stroke-width: 2; }.cell-cluster text { fill: var(--paper); font-size: 13px; text-anchor: middle; }
.world-message { position: absolute; left: 5%; right: 5%; bottom: 12px; padding: .75rem 1rem; border: 1px solid rgba(180, 240, 255, .55); background: rgba(4, 21, 32, .92); color: var(--cyan-soft); font-weight: 800; text-align: center; }
.body-map.is-danger .silhouette { stroke: var(--orange); }.body-map.is-danger .world-message { border-color: var(--orange); color: #ffe4c7; }
.body-map.is-pulsing .heart { transform-box: fill-box; transform-origin: center; animation: heartBeat .56s ease-out; }.body-map.is-pulsing .blood-dot { animation: flowDot .72s ease-out; }
.body-map.is-release { box-shadow: inset 0 0 60px rgba(103, 224, 181, .26); }.body-map.is-release .cell-cluster circle { fill: rgba(103, 224, 181, .45); }

.resource-ledger { grid-area: ledger; padding: 1rem; border-left: 5px double rgba(180, 240, 255, .35); background: rgba(9, 40, 53, .72); }
.resource-ledger h2 { margin: 0 0 1rem; font-size: 1.05rem; font-family: Consolas, monospace; }
.meter-row { display: grid; grid-template-columns: 1fr 42px; gap: .25rem .6rem; margin-bottom: 1rem; }
.meter-row label { grid-column: 1 / -1; color: var(--paper-dim); font-size: .84rem; }
.meter-row meter { width: 100%; height: 22px; accent-color: var(--mint); }.meter-row output { font-family: Consolas, monospace; font-weight: 900; text-align: right; }
meter::-webkit-meter-bar { background: #061925; border: 1px solid rgba(180,240,255,.25); border-radius: 0; }
meter::-webkit-meter-optimum-value { background: var(--mint); } meter::-webkit-meter-suboptimum-value { background: var(--yellow); } meter::-webkit-meter-even-less-good-value { background: var(--red); }
.minor-stock { margin-top: 1.4rem; padding-top: 1rem; border-top: 1px dashed rgba(180, 240, 255, .3); display: grid; gap: .8rem; color: var(--paper-dim); font-size: .85rem; }.minor-stock span { display: flex; justify-content: space-between; gap: 1rem; }.minor-stock strong { color: var(--yellow); font-family: Consolas, monospace; }

.organ-controls { grid-area: controls; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.control-module { padding: 1rem; border: 1px solid rgba(180, 240, 255, .32); background: rgba(7, 34, 47, .88); }
.module-heading { display: flex; gap: .8rem; align-items: flex-start; }.module-heading h2 { margin: 0; font-size: 1rem; }.module-heading p { margin: .25rem 0 .85rem; color: var(--paper-dim); font-size: .82rem; }.module-number { flex: 0 0 34px; display: grid; place-items: center; height: 34px; border: 1px solid currentColor; color: var(--cyan); font: 900 1rem Consolas, monospace; }
.digest-module .module-number { color: var(--yellow); }.control-module label { display: block; margin-bottom: .4rem; font-size: .8rem; font-weight: 800; }
.organ-slider { --position: 0%; width: 100%; height: 34px; margin: .2rem 0; appearance: none; background: linear-gradient(90deg, currentColor var(--position), rgba(255,255,255,.12) var(--position)); border: 1px solid currentColor; border-radius: 0; color: var(--cyan); touch-action: pan-y; }
.organ-slider::-webkit-slider-thumb { appearance: none; width: 34px; height: 34px; border: 3px solid var(--ink); background: currentColor; box-shadow: 0 0 0 2px currentColor; cursor: ew-resize; }.organ-slider::-moz-range-thumb { width: 30px; height: 30px; border: 3px solid var(--ink); border-radius: 0; background: currentColor; cursor: ew-resize; }
.digest-slider { color: var(--yellow); }.organ-slider:disabled { opacity: .35; cursor: not-allowed; }
.prep-rule { grid-column: 1 / -1; margin: 0; padding: .65rem .8rem; color: var(--paper-dim); border-left: 3px solid var(--paper-dim); font-size: .82rem; }

.pump-bay { grid-area: pump; padding: 1rem; border: 1px solid rgba(255, 95, 109, .54); background: rgba(55, 12, 27, .42); text-align: center; }
.charge-scale { display: grid; grid-template-columns: 35fr 37fr 28fr; margin-bottom: .35rem; color: var(--paper-dim); font-size: .72rem; }.charge-scale span:nth-child(2) { color: var(--mint); }.charge-scale span:last-child { color: var(--orange); }
.charge-track { position: relative; height: 22px; border: 1px solid var(--paper-dim); background: #061925; overflow: hidden; }.charge-fill { width: 0; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--mint) 55%, var(--orange) 73%, var(--red)); transition: width 80ms linear; }.safe-band, .risk-band { position: absolute; inset: 0 auto 0 35%; width: 37%; border-left: 2px solid var(--paper); border-right: 2px solid var(--paper); pointer-events: none; }.risk-band { left: 72%; width: 28%; border-color: var(--orange); }
.pump-button { display: inline-flex; align-items: center; justify-content: center; gap: .8rem; width: min(100%, 520px); min-height: 70px; margin: .9rem auto .45rem; border: 3px solid #ffabb4; background: var(--red-deep); color: white; cursor: pointer; touch-action: manipulation; box-shadow: 0 8px 0 #6f162b; user-select: none; }
.pump-button:active, .pump-button.is-charging { transform: translateY(5px); box-shadow: 0 3px 0 #6f162b; }.heart-symbol { font-size: 2rem; }.pump-bay p { max-width: 760px; margin: .5rem auto; color: var(--paper-dim); font-size: .82rem; line-height: 1.55; }
.rest-button { min-height: 44px; margin-top: .5rem; border: 1px dashed var(--yellow); background: transparent; color: var(--yellow); padding: .65rem 1rem; cursor: pointer; }.rest-button:disabled { opacity: .38; cursor: not-allowed; }
.cause-log { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: baseline; margin-top: 12px; padding: .8rem 1rem; border: 1px solid rgba(180, 240, 255, .25); background: rgba(4, 21, 32, .72); }.cause-log h2 { margin: 0; color: var(--cyan); font: 800 .78rem Consolas, monospace; }.cause-log p { margin: 0; line-height: 1.6; }

.quiz-screen, .result-screen { width: min(820px, 100%); margin: 28px auto 0; padding: clamp(20px, 5vw, 48px); border: 2px solid var(--cyan); background: rgba(5, 25, 38, .96); box-shadow: var(--shadow); }
.quiz-screen h2, .result-screen h2 { margin: 0 0 .8rem; font-size: clamp(1.6rem, 5vw, 2.8rem); }.quiz-question { margin: 1.2rem 0; padding: 1rem; border-left: 5px solid var(--yellow); background: rgba(255, 209, 102, .08); font-size: clamp(1.05rem, 3vw, 1.35rem); font-weight: 800; line-height: 1.65; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; min-width: 0; }
.quiz-choices button { min-width: 0; min-height: 58px; padding: .75rem; border: 1px solid var(--cyan); background: var(--ink-2); color: var(--paper); text-align: left; cursor: pointer; overflow-wrap: anywhere; line-height: 1.5; }.quiz-choices button:hover { background: #17485b; }.quiz-choices button[data-result="correct"] { border: 3px solid var(--mint); background: rgba(103, 224, 181, .15); }.quiz-choices button[data-result="wrong"] { border: 3px dashed var(--orange); background: rgba(255, 159, 90, .13); }
.quiz-feedback { min-height: 3.5rem; margin: 1rem 0; padding: .8rem; border-top: 1px dashed rgba(180,240,255,.3); line-height: 1.6; }
.result-score { display: flex; align-items: baseline; flex-wrap: wrap; gap: .4rem 1rem; margin: 1rem 0; padding: 1rem; border: 1px solid var(--red); background: rgba(255, 95, 109, .09); }.result-score span { color: var(--paper-dim); }.result-score strong { color: var(--yellow); font: 900 clamp(2rem, 7vw, 4rem) Consolas, monospace; }.result-score small { color: var(--mint); }
.result-screen > p { line-height: 1.75; }.result-findings { padding: 1rem; border-left: 5px solid var(--mint); background: rgba(103, 224, 181, .07); }.result-findings h3 { margin-top: 0; }.result-findings li { margin: .55rem 0; line-height: 1.55; }.result-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.2rem; }.result-actions .start-button { grid-column: auto; }
.ranking-panel { margin-top: 1rem; padding: 1rem; border: 2px solid var(--cyan); background: #092837; color: var(--paper); scroll-margin-top: 12px; }.ranking-panel .itc-ranking__tabs button { color: var(--paper); }.ranking-panel .itc-ranking__tabs button[aria-pressed="true"] { background: var(--cyan); color: #061925; }.ranking-panel .itc-ranking__table th, .ranking-panel .itc-ranking__table td { color: var(--paper); }

@keyframes heartBeat { 0% { transform: scale(1); } 35% { transform: scale(1.16); } 65% { transform: scale(.94); } 100% { transform: scale(1); } }
@keyframes flowDot { from { opacity: .25; transform: translate(-8px, -8px) scale(.7); } 55% { opacity: 1; } to { opacity: .55; transform: translate(18px, 18px) scale(1.25); } }

@media (max-width: 760px) {
  .app-shell { width: min(100% - 12px, 1180px); padding-top: 6px; }
  .masthead { align-items: center; }.masthead .subtitle { font-size: .84rem; }.masthead .ink-button { flex: 0 0 auto; padding-inline: .65rem; }
  .intro-sheet { grid-template-columns: 1fr; padding: 22px 18px; }.intro-figure { min-height: 210px; border-left: 0; border-top: 1px dashed rgba(180,240,255,.45); }.start-button { width: 100%; justify-self: stretch; }
  .status-rail { grid-template-columns: 1fr 1fr; }.status-rail div:nth-child(2) { border-right: 0; }.status-rail div:nth-child(-n+2) { border-bottom: 1px solid rgba(180,240,255,.22); }
  .phase-strip { grid-template-columns: auto 1fr; }.phase-strip span:last-child { grid-column: 1 / -1; }
  .body-world { grid-template-columns: 1fr; grid-template-areas: "activity" "body" "ledger" "controls" "pump"; padding: 8px; }
  .body-map { min-height: 500px; }.body-map svg { max-height: 590px; }.resource-ledger { border-left: 0; border-top: 5px double rgba(180,240,255,.35); }
  .organ-controls { grid-template-columns: 1fr; }.prep-rule { grid-column: 1; }.cause-log { grid-template-columns: 1fr; gap: .4rem; }
  .quiz-screen, .result-screen { margin-top: 12px; padding: 20px 14px; }.quiz-choices { grid-template-columns: 1fr; width: 100%; }.quiz-choices button { width: 100%; }
  .result-actions { display: grid; grid-template-columns: 1fr; }.ranking-panel { padding: .65rem; overflow-x: auto; }.itc-ranking__table { min-width: 420px; }
}

@media (max-width: 390px) {
  h1 { font-size: 1.65rem; }.eyebrow { font-size: .66rem; }.masthead { gap: .45rem; }.masthead .ink-button { font-size: .78rem; }
  .body-map { min-height: 450px; }.activity-note { align-items: flex-start; flex-direction: column; }.status-rail strong { font-size: .98rem; }
  .pump-button { min-height: 64px; padding: .6rem; }.pump-button strong { font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .blood-dot { opacity: .92; }
}
