#game-handwriting{position:fixed;bottom:12px;right:12px;z-index:22;margin:0;padding:0;border:1px solid #92aba0;border-radius:10px;background:#142639;max-width:calc(100vw - 24px);max-height:calc(100dvh - 70px);overflow:auto}#game-handwriting[open]{width:320px;padding:8px}#game-handwriting summary{cursor:pointer;min-height:44px;padding:10px;box-sizing:border-box}.game-handwriting-check{display:block;margin:8px auto;min-height:44px;padding:8px 20px}.grid-handwriting{max-width:min(300px,75vw)}.grid-handwriting summary{min-height:44px;padding:10px;cursor:pointer}.grid-handwriting .handwriting-board{min-width:220px}
.rescue-ui{position:absolute;inset:0;pointer-events:none;z-index:12;color:#ecffff;font-family:system-ui,sans-serif}.rescue-ui[hidden],.rescue-ui [hidden]{display:none!important}.rescue-ui button{min-height:44px;border:1px solid #6e9caa;border-radius:9px;background:#142639;color:#e6ffff;padding:8px 14px;cursor:pointer;font:inherit}.rescue-ui button:focus-visible{outline:3px solid #ffce75;outline-offset:2px}.rescue-ui button:disabled{opacity:.45;cursor:default}.rescue-ui button,.rescue-stick,.rescue-pad,.rescue-intro,.rescue-result{pointer-events:auto;touch-action:manipulation}
body.is-rescue #shooter-touch,body.is-rescue #shooter-map,body.is-rescue #shooter-held,body.is-rescue #shooter-say,body.is-rescue #shooter-guns,body.is-rescue .shooter-cross,body.is-rescue .shooter-hint,body.is-rescue #shooter-count{display:none!important}
body.is-rescue .shooter-readout{top:118px;width:min(90%,30rem);max-width:90vw}body.is-rescue .shooter-readout-text{font-size:clamp(1.4rem,4vw,2.5rem)}
.rescue-mode-label{position:absolute;top:65px;left:14px;color:#a8ffe0;font-size:14px}.rescue-count{position:absolute;top:65px;right:14px;display:flex;flex-direction:column;text-align:right;font-size:12px}.rescue-count strong{font-size:19px;color:#8af4ca}.rescue-message{position:absolute;bottom:128px;left:12px;right:12px;text-align:center;font-size:13px;text-shadow:0 2px 4px black}
/* Choosing how to play is a screen of its own: the battlefield is what the
   choice sends you into, so it is not left showing through behind the rules. */
.rescue-setup{position:fixed;z-index:26;inset:0;display:flex;align-items:center;justify-content:center;overflow:auto;padding:max(14px,env(safe-area-inset-top)) max(14px,env(safe-area-inset-right)) max(14px,env(safe-area-inset-bottom)) max(14px,env(safe-area-inset-left));background:radial-gradient(125% 100% at 50% -10%,#1b4363,#0b1d33 58%,#060f1c);color:#ecffff;font-family:system-ui,sans-serif}
.rescue-setup[hidden]{display:none}
body.is-rescue-setup .hud{z-index:27}
body.is-rescue-setup .hud-menu-button{display:none}
.rescue-setup::before{content:'';position:fixed;inset:0;pointer-events:none;background:repeating-linear-gradient(90deg,rgba(127,232,255,.07) 0 1px,transparent 1px 64px),repeating-linear-gradient(rgba(127,232,255,.07) 0 1px,transparent 1px 64px);-webkit-mask-image:radial-gradient(72% 62% at 50% 38%,#000,transparent);mask-image:radial-gradient(72% 62% at 50% 38%,#000,transparent)}
.rescue-setup button{min-height:44px;padding:8px 14px;border:1px solid #35617c;border-radius:10px;background:rgba(255,255,255,.05);color:#e6ffff;font:inherit;cursor:pointer;touch-action:manipulation}
.rescue-setup button:focus-visible{outline:3px solid #ffce75;outline-offset:2px}
.rescue-setup button:disabled{opacity:.45;cursor:default}
.rescue-intro{position:relative;display:flex;flex-direction:column;gap:clamp(12px,2.2vh,18px);width:min(100%,560px);max-height:min(100%,calc(100dvh - 28px));padding:clamp(16px,3vw,26px);box-sizing:border-box;background:linear-gradient(180deg,rgba(20,50,76,.96),rgba(9,26,44,.97));border:1px solid #34617a;border-radius:20px;box-shadow:0 30px 70px rgba(0,0,0,.6)}
.rescue-intro-head{display:grid;gap:4px}
.rescue-eyebrow{margin:0;color:#79d9c2;font-size:11px;font-weight:800;letter-spacing:.18em;text-transform:uppercase}
.rescue-intro h2{margin:0;color:#a7ffe1;font-size:clamp(20px,3.6vw,28px);font-weight:850;letter-spacing:-.015em}
.rescue-lead{margin:0;color:#a7c3d1;font-size:14px;line-height:1.45}
.rescue-intro-body{display:flex;flex-direction:column;gap:12px;min-height:0;overflow:auto;scrollbar-width:thin;scrollbar-color:#35617c transparent}
/* Both cards carry the same furniture — badge, name, one sentence — so the
   pair reads as one choice rather than two paragraphs of different length. */
.rescue-mode-choices{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.rescue-mode-choices button{position:relative;display:grid;grid-template-columns:auto minmax(0,1fr);grid-template-areas:'icon title' 'copy copy';align-items:center;column-gap:10px;row-gap:9px;padding:13px;border-width:2px;border-radius:15px;background:rgba(10,29,48,.75);text-align:left;transition:border-color 120ms,background 120ms,transform 120ms}
.rescue-mode-choices button:hover:not(:disabled){border-color:#5fc7ad;background:rgba(16,46,62,.85);transform:translateY(-1px)}
.rescue-mode-icon{grid-area:icon;display:grid;place-items:center;width:42px;height:42px;border:1px solid #35617c;border-radius:12px;background:rgba(6,20,34,.8);color:#8ef0d0;font-family:var(--jp-serif);font-size:23px;line-height:1}
.rescue-mode-choices strong{grid-area:title;color:#a8ffe0;font-size:22px;font-weight:800;letter-spacing:-.01em}
.rescue-mode-copy{grid-area:copy;color:#bcd4df;font-size:13px;line-height:1.5}
.rescue-mode-choices button[aria-pressed=true]{border-color:#8dffd5;background:linear-gradient(180deg,rgba(37,96,79,.95),rgba(19,60,54,.95))}
.rescue-mode-choices button[aria-pressed=true] .rescue-mode-icon{border-color:#8dffd5;background:rgba(141,255,213,.16);color:#d9fff2}
.rescue-mode-choices button[aria-pressed=true]::after{content:'✓';position:absolute;top:8px;right:11px;color:#8dffd5;font-size:14px;font-weight:800}
.rescue-input-note{margin:0;min-height:17px;color:#93d8c0;font-size:13px;line-height:1.35}
.rescue-rules{display:grid;gap:6px;margin:0;padding:12px 14px 12px 30px;border:1px solid #2a4d64;border-radius:13px;background:rgba(6,20,34,.55);color:#aec6d3;font-size:12.5px;line-height:1.5}
.rescue-rules li::marker{color:#5fc7ad}
.rescue-rules strong{color:#e4f6ff;font-weight:800}
/* Starting is the one thing this screen is for; the other two ways out share a
   quieter row beneath it. */
.rescue-intro-actions{display:grid;gap:9px;padding-top:clamp(10px,1.6vh,14px);border-top:1px solid #2a4d64}
.rescue-intro [data-rescue=start]{width:100%;min-height:52px;border-color:#8dffd5;background:linear-gradient(180deg,#2f7d64,#1e5748);color:#f0fffa;font-size:17px;font-weight:800}
.rescue-intro [data-rescue=start]:not(:disabled):hover{background:linear-gradient(180deg,#389275,#256855)}
.rescue-intro [data-rescue=start]:disabled{opacity:1;border-color:#35617c;background:rgba(255,255,255,.06);color:#8fa9b8}
.rescue-intro-more{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.rescue-intro-more button{color:#d5e9f2;font-size:14px}
.rescue-intro-more button:hover{background:rgba(255,255,255,.1)}
@media(prefers-reduced-motion:reduce){.rescue-mode-choices button{transition:none}.rescue-mode-choices button:hover:not(:disabled){transform:none}}
@media(max-width:560px){.rescue-mode-choices{grid-template-columns:1fr}}
@media(max-height:560px){.rescue-intro{gap:10px;padding:14px}.rescue-intro h2{font-size:19px}.rescue-lead{font-size:13px}.rescue-mode-choices button{row-gap:6px;padding:10px}.rescue-mode-icon{width:34px;height:34px;font-size:19px}.rescue-mode-choices strong{font-size:18px}.rescue-mode-copy{font-size:12px}.rescue-rules{padding:9px 11px 9px 26px;font-size:11.5px}.rescue-intro [data-rescue=start]{min-height:46px;font-size:15px}}
.rescue-reticle{position:absolute;width:36px;height:36px;transform:translate(-50%,-50%);border:2px solid #ffd982;border-radius:50%;box-shadow:0 0 4px #000}.rescue-reticle:after{content:'+';position:absolute;inset:0;display:grid;place-items:center;color:#ffe6a6;font-size:24px}.rescue-reticle.has-target{border-color:#8ff9d5;box-shadow:0 0 15px #5aefb9}
.rescue-controller{position:absolute;bottom:max(12px,env(safe-area-inset-bottom));left:14px;right:14px;display:flex;align-items:center;gap:16px}.rescue-stick{position:relative;flex:0 0 98px;height:98px;border-radius:45px;background:linear-gradient(135deg,#445165,#162130);border:2px solid #768390;box-shadow:inset 0 3px 12px #070c16,0 4px 8px #0008;touch-action:none;user-select:none}.rescue-stick span{position:absolute;width:54px;height:54px;left:50%;top:50%;transform:translate(-50%,-50%);border-radius:50%;background:radial-gradient(circle at 36% 30%,#5a6876,#1b2430 75%);border:2px solid #8c99a3;box-shadow:0 4px 6px #000}.rescue-stick small{position:absolute;bottom:4px;left:0;width:100%;text-align:center;font-size:9px;color:#b7c6d2;letter-spacing:2px}
.rescue-weapons{display:grid;grid-template-columns:repeat(6,minmax(50px,1fr));gap:8px;flex:1;max-width:780px;margin-left:auto}.rescue-weapons button{display:flex;flex-direction:column;align-items:center;padding:5px;min-width:0}.rescue-weapons small{font-size:11px;color:#e5ba63}.rescue-weapons span{font-family:'Yu Mincho',serif;font-size:clamp(18px,2.8vw,32px);overflow-wrap:anywhere;line-height:1.4}
.rescue-touch-controls .rescue-weapons small{display:none}.rescue-settings{display:none}.is-rescue .rescue-settings{display:grid;grid-template-columns:1fr}.rescue-settings p{margin:0;font-size:11px;color:var(--muted)}
.is-rescue .hud-menu-sheet{max-height:calc(100dvh - 48px);overflow:auto}
.rescue-draw-controls{position:absolute;bottom:24px;left:50%;transform:translateX(-50%);display:flex;gap:8px;white-space:nowrap}.rescue-result{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);background:#0b192cf2;border:1px solid #6594a4;border-radius:18px;padding:24px;width:min(90%,520px);max-height:78%;overflow:auto;box-sizing:border-box;box-shadow:0 15px 80px #000}.rescue-result h2{margin-top:0;color:#a7ffe1}.rescue-result p{line-height:1.5;color:#d2e4e9}.rescue-result button{margin:4px}
/* The writing surface floats over the full battlefield; it never resizes it. */
.rescue-pad{position:absolute;inset:0;z-index:3;pointer-events:none;background:transparent}
.rescue-pad-host{position:absolute;inset:176px max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
.rescue-pad .handwriting-input{display:grid;grid-template-rows:44px minmax(0,1fr) 36px 44px;gap:8px;width:100%;height:100%;max-width:none;margin:0;padding:0;border:0;border-radius:0;background:transparent;color:#e9fffa;pointer-events:none}
.rescue-pad .handwriting-top,.rescue-pad .handwriting-status,.rescue-pad .handwriting-actions{width:100%;max-width:640px;justify-self:center;box-sizing:border-box}
.rescue-pad .handwriting-top{padding:0 8px;border-radius:8px;background:#0a1e2bb8;font-size:12px}
.rescue-pad .handwriting-top label{min-height:44px;padding:0 8px;pointer-events:auto;cursor:pointer}
.rescue-writing-surface{display:grid;place-items:center;min-width:0;min-height:0;pointer-events:none}
.rescue-pad .handwriting-board{max-height:none;max-width:100%;margin:0;box-sizing:border-box;background:rgba(6,23,34,.3);border:1px solid #a0ffdc80;border-radius:18px;pointer-events:auto}
.rescue-pad .handwriting-grid{stroke:#c0ffe8!important;opacity:.25}
.rescue-pad .handwriting-accepted{stroke:#acffe2;stroke-width:2.2;opacity:.45}
.rescue-pad .handwriting-ink{stroke:#fff;stroke-width:1.5;opacity:.45}
.rescue-pad .handwriting-hint{stroke:#7fffd0;fill:#7fffd0;stroke-width:2.2;opacity:.45}
.rescue-pad .handwriting-start{opacity:.75}
.rescue-pad .handwriting-start circle{fill:#baffdf;stroke:#0d3b3c;stroke-width:.65;filter:drop-shadow(0 0 1px #afffe0)}
.rescue-pad .handwriting-outline{stroke:#dbfff066}
.rescue-pad .handwriting-status{min-height:0;margin:0;padding:3px 8px;border-radius:8px;font-size:11px;background:#0a1e2bb8;text-align:center;align-self:center}
.rescue-pad .has-mistake .handwriting-board{border-color:#ffb16e;box-shadow:inset 0 0 0 2px #ffb16e80}
.rescue-pad .has-mistake .handwriting-status{color:#ffebd4;background:#47200ee6;box-shadow:inset 0 0 0 1px #ffb16e}
.rescue-pad .handwriting-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.rescue-pad .handwriting-actions button{padding:6px;font-size:12px;pointer-events:auto;background:#102c3ae6;border-color:#8ab8b9;color:#e9fffa}
.rescue-drawing .rescue-draw-controls,.rescue-drawing .rescue-message{display:none}
@media(max-width:650px){.rescue-weapons{grid-template-columns:repeat(3,minmax(44px,1fr));gap:5px}.rescue-controller{gap:10px}.rescue-stick{flex-basis:90px;height:104px}.rescue-count{font-size:10px}.rescue-count strong{font-size:15px}.rescue-message{bottom:150px;font-size:12px}}


.rescue-reticle.is-selected{border:3px solid #8ff9d5;border-radius:8px;box-shadow:0 0 0 2px #102a26,0 0 18px #5aefb9}.rescue-reticle.is-selected:after{content:"SELECTED";inset:auto auto calc(100% + 6px) 50%;transform:translateX(-50%);font:700 9px system-ui;letter-spacing:1px;padding:3px 5px;border-radius:4px;background:#0b2527;color:#b6ffe6}.rescue-drawing .rescue-draw-controls{display:none}
.rescue-beam{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;filter:drop-shadow(0 0 5px #6af4ff)}.rescue-beam-line{fill:none;stroke:#91faff;stroke-width:2;stroke-dasharray:1;stroke-linecap:round}.rescue-beam-pulse{fill:#edffff}.rescue-beam-word{fill:#dcffff;stroke:#0c3446;stroke-width:2;paint-order:stroke;font-family:system-ui,sans-serif}.rescue-beaming .shooter-readout-text,.rescue-beaming .shooter-readout-label{animation:rescue-text-arrive 520ms ease-out both}@keyframes rescue-text-arrive{0%,45%{opacity:0;filter:blur(5px)}80%{opacity:1;filter:blur(0);color:#fff}100%{opacity:1;filter:blur(0)}}@media(prefers-reduced-motion:reduce){.rescue-beam{display:none}.rescue-beaming .shooter-readout-text,.rescue-beaming .shooter-readout-label{animation:none}}
@media(min-width:651px) and (min-aspect-ratio:4/3){
  .rescue-pad-host{top:64px}
  .rescue-pad .handwriting-input{grid-template-columns:minmax(0,1fr) 190px;grid-template-rows:44px minmax(0,1fr) 38px 96px;column-gap:16px}
  .rescue-writing-surface{grid-column:1;grid-row:1/-1}
  .rescue-pad .handwriting-top{grid-column:2;grid-row:1;gap:4px;font-size:11px;padding:0 4px}
  .rescue-pad .handwriting-top label{padding:0 4px}
  .rescue-pad .handwriting-status{grid-column:2;grid-row:3}
  .rescue-pad .handwriting-actions{grid-column:2;grid-row:4;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:44px 44px}
  .rescue-pad [data-rescue=close-pad]{grid-column:1/-1}
  .is-rescue .rescue-drawing .shooter-readout{left:auto;right:max(12px,env(safe-area-inset-right));top:126px;width:190px;max-width:none;transform:none}
  .is-rescue .rescue-drawing .shooter-readout-text{font-size:clamp(1.3rem,2.8vw,2rem)}
  .rescue-drawing .rescue-count{left:14px;right:auto;top:100px;text-align:left}
}
@media(max-height:700px) and (max-width:650px){
  .rescue-pad-host{top:148px;bottom:max(8px,env(safe-area-inset-bottom));left:max(8px,env(safe-area-inset-left));right:max(8px,env(safe-area-inset-right))}
  .rescue-pad .handwriting-input{gap:5px;grid-template-rows:44px minmax(0,1fr) 32px 44px}
  .rescue-pad .handwriting-status{font-size:10px;padding:2px 5px}
  .is-rescue .rescue-drawing .shooter-readout{top:100px}.is-rescue .shooter-room,.is-rescue .shooter-pace{font-size:11px}.is-rescue .shooter-bar{gap:8px}
}
/* A picture question is shown in the readout as well as on the robot's head. */
body.is-rescue .shooter-readout-text.rescue-readout-picture{width:96px;height:96px;margin:4px auto 0;background-color:#fffaf2;background-repeat:no-repeat;border-radius:8px}
