/* Match the paper color at the edges of all three illustrations. */
.fullscreen-game #comic-dialog {
  --comic-ink:#173832; --comic-paper:#f5f7f4; --comic-cold:#14675a; --comic-warm:#8b4820;
  position:fixed; inset:0; width:100%; max-width:none; height:100%; height:100dvh; max-height:none;
  margin:0; padding:0; border:0; border-radius:0; color:var(--comic-ink); background:var(--comic-paper);
  color-scheme:light; overflow:hidden; box-sizing:border-box; box-shadow:none;
  font-family:"PingFang SC","Microsoft YaHei",system-ui,sans-serif;
}
.fullscreen-game #comic-dialog[open] { display:flex; flex-direction:column; }
.fullscreen-game #comic-dialog::backdrop { background:#f5f7f4; backdrop-filter:none; }
#comic-dialog > :is(#next-click-button,#next-click-message) { display:none; }
#comic-dialog .comic-scroll {
  display:flex; flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain;
  touch-action:pan-y; -webkit-overflow-scrolling:touch;
  padding:max(12px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right))
    max(12px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
}
#comic-dialog .comic-sheet {
  width:100%; max-width:560px; margin:auto; min-width:0;
}
#comic-dialog h2 {
  font-size:clamp(1.4rem,6vw,2rem); line-height:1.25; letter-spacing:.01em;
  margin:0; padding:14px 16px 8px; color:var(--comic-ink);
}
#comic-dialog h2:focus { outline:none; }
#comic-dialog .cooling-figure {
  position:relative; min-width:0; margin:0;
}
#comic-dialog .cooling-figure img { display:block; width:100%; height:auto; }
#comic-dialog [data-comic-wall-position] {
  /* Reserve room for the title, description and audio notice on short phones. */
  width:min(100%,470px,max(200px,calc(71dvh - 156px))); margin-inline:auto;
}
#comic-dialog .comic-sheet:has(>[data-comic-wall-position]:not([hidden])) h2 { text-align:center; }
#comic-dialog .position-label {
  position:absolute; left:80%; top:63.75%; transform:translateY(-50%);
  padding:2px 4px; white-space:nowrap;
  color:#28483f; font-size:clamp(.875rem,4vw,1.125rem); font-weight:760;
}
#comic-dialog .section-layer,#comic-dialog .section-interior,#comic-dialog .section-waist,#comic-dialog .route-label {
  position:absolute; transform:translate(-50%,-50%); white-space:nowrap;
}
#comic-dialog .section-layer {
  top:5%; padding:1px 4px; border-radius:4px; background:#f5f8f2;
  font-size:clamp(.75rem,3.5vw,.9375rem); font-weight:740;
}
#comic-dialog .layer-lining { left:19%; color:#6d5030; }
#comic-dialog .layer-stave { left:38.3%; color:#883f1e; }
#comic-dialog .layer-backing { left:59.1%; color:#605440; }
#comic-dialog .layer-shell { left:80%; color:#3b535e; }
#comic-dialog .section-interior {
  top:32%; left:50%; color:#fff8e9; text-shadow:0 1px 3px #372d24;
  font-size:clamp(1.125rem,5vw,1.5rem); font-weight:730;
}
#comic-dialog .section-waist {
  top:38%; left:92%; padding:1px 4px; border-radius:4px; background:#f5f8f2;
  color:#35554d; font-size:clamp(.8125rem,3.5vw,1rem); font-weight:760;
}
#comic-dialog .route-label {
  display:grid; justify-items:center; line-height:1.15; color:var(--comic-cold);
}
#comic-dialog .route-label b {
  display:grid; place-items:center; min-width:1.55em; min-height:1.55em;
  color:#fffdf3; border-radius:5px; background:var(--comic-cold);
  font-size:clamp(.8125rem,4vw,1.125rem);
}
#comic-dialog .route-label small {
  margin-top:2px; font-size:clamp(.6875rem,3vw,.875rem); font-weight:700;
}
#comic-dialog .route-supply { left:10.3%; top:88.5%; }
#comic-dialog .route-inlet { left:72%; top:83.3%; }
#comic-dialog .route-outlet { left:33.6%; top:16.5%; }
#comic-dialog .route-return { left:83.8%; top:12.2%; }
#comic-dialog :is(.route-outlet,.route-return) { color:var(--comic-warm); }
#comic-dialog :is(.route-outlet,.route-return) b { background:var(--comic-warm); }
#comic-dialog .comic-copy { min-width:0; padding:8px 16px 16px; }
#comic-dialog .comic-sentence {
  margin:0; white-space:pre-line; color:#243f39; font-size:clamp(.9375rem,4.2vw,1.0625rem); line-height:1.58;
}
#comic-dialog .comic-audio-status {
  flex:none; width:min(100%,480px); margin:0 auto; color:#435a53;
  padding:0 max(14px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));
  font-size:.875rem; text-align:center;
}
#comic-dialog .comic-audio-status:empty { display:none; }
#comic-dialog .comic-launch {
  position:absolute; inset:0; z-index:1; display:grid; place-items:center;
  background:radial-gradient(ellipse at center,#c7f3dd7a 0,transparent 58%), #17383242;
}
#comic-dialog .comic-start {
  position:relative; display:inline-flex; align-items:center; justify-content:center;
  gap:14px; min-width:min(254px,90vw); min-height:76px; padding:12px 26px;
  border:1px solid #77d3b4; border-radius:999px; touch-action:manipulation;
  color:#f5fffa; background:linear-gradient(155deg,#197e6c,#0a574e 70%,#0a4844);
  box-shadow:0 12px 34px #093b3659,inset 0 1px #ddffeb80;
  font-size:1.5rem; font-weight:800; line-height:1.2; white-space:nowrap;
}
#comic-dialog .comic-start-icon {
  display:grid; place-items:center; width:42px; height:42px; flex:none;
  border-radius:50%; background:linear-gradient(145deg,#f1fff6,#a9e7d1);
  box-shadow:0 2px 6px #083e3a55;
}
#comic-dialog .comic-start-icon::before {
  content:''; width:17px; height:20px; margin-left:3px; background:#0b594e;
  clip-path:polygon(0 10%,8% 0,17% 0,96% 42%,100% 47%,100% 53%,96% 58%,17% 100%,8% 100%,0 90%);
}
#comic-dialog .comic-start:focus-visible { outline:3px solid #e8fff2; outline-offset:4px; }
#comic-dialog .comic-start:hover { filter:brightness(1.1); }
#comic-dialog .comic-start:active { filter:brightness(.94); transform:scale(.97); }

@media (prefers-reduced-motion:no-preference) {
  #comic-dialog .comic-launch { animation:comic-launch-light 480ms ease-out both; }
  #comic-dialog .comic-start { animation:comic-start-pop 720ms ease-out both; }
  #comic-dialog .comic-start::after {
    content:''; position:absolute; inset:-4px; border:2px solid #edfff5;
    border-radius:inherit; pointer-events:none;
    animation:comic-start-ripple 900ms 220ms ease-out both;
  }
}
@keyframes comic-launch-light { from { opacity:0; } to { opacity:1; } }
@keyframes comic-start-pop {
  0% { opacity:0; scale:.55; }
  44% { opacity:1; scale:1.12; }
  72% { scale:.96; }
  100% { scale:1; }
}
@keyframes comic-start-ripple {
  0% { opacity:.95; transform:scale(.92); }
  100% { opacity:0; transform:scale(1.38); }
}

@media(max-height:650px) and (orientation:landscape) {
  #comic-dialog .comic-sheet {
    grid-template-columns:1fr 1fr; grid-template-rows:auto auto;
    align-content:center; column-gap:12px;
  }
  #comic-dialog .comic-sheet:has(>[data-comic-wall-position]:not([hidden])) { display:grid; max-width:760px; }
  #comic-dialog .cooling-figure { grid-area:1 / 1 / span 2; align-self:center; }
  #comic-dialog [data-comic-wall-position] { width:min(100%,max(150px,calc(71dvh - 47px))); }
  #comic-dialog h2 { grid-column:2; align-self:end; }
  #comic-dialog .comic-copy { grid-column:2; align-self:start; }
  #comic-dialog .comic-sheet:has(>[data-comic-wall-position]:not([hidden])) h2 { padding:0 8px 6px; text-align:start; }
  #comic-dialog [data-comic-wall-position]:not([hidden])~.comic-copy { padding:0 8px; }
}

@media(max-height:500px) and (orientation:landscape) {
  #comic-dialog .comic-sheet { display:grid; max-width:760px; }
  #comic-dialog h2 { padding:0 8px 6px; font-size:1.3rem; }
  #comic-dialog .comic-copy { padding:0 8px; }
  #comic-dialog .comic-sentence { font-size:1rem; line-height:1.5; }
}

/* Remove observation-mode chrome from the game. Only the booklet explains
   anatomy; the work view keeps the player's full screen for routing. */
.comic-game .scene-view-tabs,.comic-game #view-tools { display:none!important; }

/* The callout's centre is the actual pipe end. Labels never intercept a stroke. */
#work-cues { position:absolute; pointer-events:none; user-select:none; z-index:1; }
body:not([data-scene-view="work"]) #work-cues,
body:not([data-scene-state="ready"]) #work-cues { display:none; }
.work-pin {
  --ink:#ffc37c; position:absolute; width:24px; height:24px;
  transform:translate(-50%,-50%); border:2px solid var(--ink); border-radius:50%;
  box-shadow:0 0 0 2px #172c2dc9,inset 0 0 0 1px #172c2d;
}
.work-pin[data-tone=supply],.work-pin[data-tone=passed] { --ink:#90eed2; }
.work-pin[data-tone=fault] { --ink:#ffb59a; border-style:dashed; }
.work-pin b {
  position:absolute; bottom:calc(100% + 5px); left:50%; transform:translateX(-50%);
  padding:3px 7px; white-space:nowrap; border:1px solid var(--ink); border-radius:5px;
  background:#203236; color:var(--ink); font:700 13px/1.2 system-ui,sans-serif;
  box-shadow:0 2px 4px #101f2060;
}
.work-pin b::after { content:''; position:absolute; left:50%; top:100%; height:6px; border-left:2px solid var(--ink); }
.work-pin.below b { top:calc(100% + 5px); bottom:auto; }
.work-pin.below b::after { top:auto; bottom:100%; }
.work-pin.tag-left b,.work-pin.tag-right b { top:50%; bottom:auto; transform:translateY(-50%); }
.work-pin.tag-left b { left:auto; right:calc(100% + 5px); }
.work-pin.tag-right b { left:calc(100% + 5px); }
.work-pin.tag-left b::after,.work-pin.tag-right b::after { top:50%; bottom:auto; height:0; width:6px; border:0; border-top:2px solid var(--ink); }
.work-pin.tag-left b::after { left:100%; }
.work-pin.tag-right b::after { left:auto; right:100%; }
.work-pin.edge-left b { left:3px; transform:none; }
.work-pin.edge-left b::after { left:6px; }
.work-pin.edge-right b { left:auto; right:3px; transform:none; }
.work-pin.edge-right b::after { left:auto; right:6px; }
@keyframes seat-pin { from { opacity:.4; scale:1.12; } to { opacity:1; scale:1; } }
@media (prefers-reduced-motion:no-preference) {
  html:not(.reduce-motion) .work-pin b { animation:seat-pin 180ms ease-out; }
}
