/* Mission usability fixes. Desktop keeps its established design; narrow screens reflow at 1:1. */
.fg-collapse { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: 9px; color: inherit; background: var(--tile) }
.fp-h, .fl-h { gap: 8px }
.fp-h > b, .fl-h > b { margin-inline-start: auto }
.fg-lcol > .fp.collapsed { flex: none }
#fg-panel-links { min-height: 0; display: flex; flex-direction: column }
.fl-readiness { margin: 0 2px 10px; font-size: 12px; line-height: 1.4; color: var(--muted) }
.fg-camera { position: absolute; top: 150px; left: 50%; transform: translateX(-50%); z-index: 5; padding: 5px }
.fg-ctx ~ .fg-camera { top: 208px }
.fg-camera .fg-chipb { height: 36px }
.fg .s3d-label.click { cursor: pointer; pointer-events: auto }
.fg[data-route="f-build"] .g-pipe .g-ps { animation: none }
.iv-feedback { margin-top: 16px; padding: 14px; border: 1px solid #FFD15C; border-radius: 12px; color: var(--text); background: var(--panel-2); line-height: 1.5 }
.iv-feedback b { color: #FFD15C }
.iv-feedback p { margin: 6px 0 }
.iv-feedback small { color: var(--muted) }
[data-theme="light"] .iv-feedback b { color: #805c00 }
.iv-record-review { color: var(--warn) }

@media (max-width: 900px) {
  #stage.mission-responsive { left: 0; top: 0; width: 100%; height: 100%; transform: none; overflow: hidden }
  #stage.mission-responsive .screen { overflow: hidden }
  #stage.mission-responsive .fg { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; overflow-x: hidden; padding: 0 12px; scroll-padding: 16px 0 86px; overscroll-behavior: contain; background: var(--bg) }
  #stage.mission-responsive .fg > * { flex-shrink: 0; min-width: 0 }
  #stage.mission-responsive .fg button { touch-action: manipulation }
  #stage.mission-responsive .fg :is(input, textarea) { font-size: 16px; max-width: 100% }
  #stage.mission-responsive .fg :is(.btn, .sg-opt, .f6-tabs button, .mx-tool, .fg-chipb, .fp-show, .fg-find, .fg-collapse, .fg-cb, .mch-ib) { min-height: 44px; height: auto }

  /* Compact, readable mission header. */
  #stage.mission-responsive .mx-top { position: relative; inset: auto; order: 0; height: auto; min-height: 155px; margin: 0 -12px; padding: 14px 12px 10px; display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px 12px }
  #stage.mission-responsive .mx-back { position: static; width: 44px; height: 44px }
  #stage.mission-responsive .mx-ttl { position: static; min-width: 0 }
  #stage.mission-responsive .mx-crumbs { font-size: 12px; flex-wrap: wrap; gap: 5px }
  #stage.mission-responsive .mx-ttl h1 { font-size: 20px; line-height: 1.3; flex-wrap: wrap; gap: 5px; margin: 3px 0 0 }
  #stage.mission-responsive .mx-ttl .mx-pill { display: none }
  #stage.mission-responsive .mx-kdb { position: static; grid-column: 1 / -1; justify-content: center; height: auto; gap: 6px }
  #stage.mission-responsive .mx-kdb > i { width: 12px }
  #stage.mission-responsive .mx-kdb button { height: 40px; font-size: 14px; padding-inline-end: 12px }
  #stage.mission-responsive .mx-tr { display: none }
  #stage.mission-responsive .mx-prog { position: static; grid-column: 1 / -1; width: auto; height: auto; margin: 0; transform: none }

  /* Seven steps remain reachable without covering the work. */
  #stage.mission-responsive .fg-lcol { display: contents }
  #stage.mission-responsive .fg .fg-quest { position: relative; inset: auto; width: auto; max-height: none; margin: 0; order: 1; padding: 12px; overflow: visible }
  #stage.mission-responsive .fg-quest h2 { font-size: 16px; margin: 6px 0 10px }
  #stage.mission-responsive .fg-qh { gap: 8px; flex-wrap: wrap }
  #stage.mission-responsive .fg-qt { margin-inline-start: auto }
  #stage.mission-responsive .fg-qt .fg-chipb { font-size: 12px; padding: 0 10px }
  #stage.mission-responsive .fg-stl, #stage.mission-responsive .fg-quest .fh-close { display: none }
  #stage.mission-responsive .fg-sts, #stage.mission-responsive .fg-quest.compact .fg-sts { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; height: auto; min-height: 48px; overflow: visible; margin-top: 10px; padding: 2px 0 }
  #stage.mission-responsive .fg-st, #stage.mission-responsive .fg-quest.compact .fg-st { flex: none; width: auto; min-width: 0; min-height: 44px; padding: 0; justify-content: center; border-radius: 10px }
  #stage.mission-responsive .fg-st i, #stage.mission-responsive .fg-quest.compact .fg-st i { width: 30px; height: 30px }
  #stage.mission-responsive .fg-st span, #stage.mission-responsive .fg-st em { display: none }
  #stage.mission-responsive .fg-chip { font-size: 12px; padding: 0 8px }

  /* The scene has its own touch area, with the inventory immediately below it. */
  #stage.mission-responsive .fg .mx-scene.fg-scene { position: relative; inset: auto; order: 2; width: auto; height: clamp(280px, 44vh, 440px); margin: 0 -12px; border-block: 1px solid var(--line-2) }
  #stage.mission-responsive .fg .s3d-label.click { min-height: 44px; padding: 7px 10px }
  #stage.mission-responsive .fg-camera { position: relative; inset: auto; order: 3; transform: none; padding: 0; border: 0; background: none; margin-top: -6px; align-self: flex-start }
  #stage.mission-responsive .fg-camera button { font-size: 14px }
  #stage.mission-responsive .fg-hint { position: relative; inset: auto; order: 4; transform: none; height: auto; white-space: normal; border-radius: 12px; padding: 12px; flex-wrap: wrap; font-size: 14px; line-height: 1.45 }
  #stage.mission-responsive .fg-hint > .ico { display: none }
  #stage.mission-responsive .fg-find { margin: 0; width: 100%; justify-content: center }
  #stage.mission-responsive .fg-bottom { position: relative; inset: auto; order: 5; flex-direction: column; gap: 10px; align-items: stretch }
  #stage.mission-responsive .fg-hotbar { margin: 0; width: 100%; padding: 12px; flex: none }
  #stage.mission-responsive .fg-invh { flex-wrap: wrap; gap: 8px }
  #stage.mission-responsive .fg-invnote { display: none }
  #stage.mission-responsive .fg-invb { min-width: 0; height: auto; flex-direction: column; gap: 10px }
  #stage.mission-responsive .fg-slots { overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin }
  #stage.mission-responsive .fg-slot { min-width: 94px; height: 142px }
  #stage.mission-responsive .fg-slot b { font-size: 13px }
  #stage.mission-responsive .fg-slot kbd { display: none }
  #stage.mission-responsive .fg-cnote { padding: 4px 0; font-size: 13px }
  #stage.mission-responsive .fg-coins { order: 2; width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px }
  #stage.mission-responsive .fg-coins .fg-cbar { grid-column: 1 / -1; grid-row: 3 }
  #stage.mission-responsive .fg-coins .fg-link { grid-column: 2; grid-row: 2; font-size: 12px; justify-self: end }
  #stage.mission-responsive .fg-coins b { font-size: 16px; text-align: end }
  #stage.mission-responsive .fg-ctx { position: relative; inset: auto; order: 4; transform: none; max-width: 100%; white-space: normal; justify-content: flex-start; margin: 0 }
  #stage.mission-responsive .fg-ctx > b { width: 100% }
  #stage.mission-responsive .fg-wtag { min-height: 44px }
  #stage.mission-responsive .fg .fp { order: 6; width: auto; max-height: none; flex: none; padding: 12px }
  #stage.mission-responsive .fp-body { max-height: 360px }
  #stage.mission-responsive .fg-links { position: relative; inset: auto; order: 7; width: auto; max-height: none }
  #stage.mission-responsive .fl-list { max-height: 340px }
  #stage.mission-responsive .fg-pdel, #stage.mission-responsive .fg-sw { min-width: 40px; min-height: 40px }
  #stage.mission-responsive .fg-help { position: relative; inset: auto; order: 8; width: auto }
  #stage.mission-responsive .fg-askb, #stage.mission-responsive .fg-hintb { min-height: 44px; font-size: 14px }
  #stage.mission-responsive .fg-topwrap { position: absolute; inset: 0; z-index: 4 }
  #stage.mission-responsive .fg.plan .fg-topwrap { position: relative; order: 2; height: 320px; margin-top: -332px }

  /* Reading, experiments, assessment and submission use natural document flow. */
  #stage.mission-responsive .fg.page .fg-scene { display: none }
  #stage.mission-responsive .fg.page .fg-page { position: relative; inset: auto; order: 4; width: auto; display: block }
  #stage.mission-responsive .fg.page .fg-page > :is(.mx-panel, .mx-info, .mx-out, section, div) { position: relative; inset: auto; width: 100%; height: auto; min-height: 0; max-height: none; overflow: visible; padding: 16px; border-radius: 16px }
  #stage.mission-responsive .fg.page :is(.f6-briefbody, .f6-invbody, .f6-trbody, .f6-subbody, .mx-read, .sg-body) { max-height: none; height: auto; overflow: visible; flex: none }
  #stage.mission-responsive .fg.page .fg-side { position: relative; inset: auto; order: 5; width: auto; max-height: none; padding: 12px }
  #stage.mission-responsive .fg[data-route="f-research"] .fg-side, #stage.mission-responsive .fg[data-route="f-understand"] .fg-side { order: 3 }
  #stage.mission-responsive .fg-side .fg-sl { max-height: 270px }
  #stage.mission-responsive .fg.page .fg-help { order: 2 }
  #stage.mission-responsive .fg-pbottom { position: relative; inset: auto; order: 6; flex-wrap: wrap }
  #stage.mission-responsive .fg-say { padding: 12px; font-size: 14px }
  #stage.mission-responsive .fg-say #st-msg { max-height: none; overflow: visible }
  #stage.mission-responsive .fg-tools { width: 100%; justify-content: flex-end }
  #stage.mission-responsive .fg .mx-panel h4 { font-size: 17px; flex-wrap: wrap }
  #stage.mission-responsive .fg .mx-panel h4 > span { margin-inline-start: 0; font-size: 13px }
  #stage.mission-responsive .iv-kits, #stage.mission-responsive .iv-src, #stage.mission-responsive .sg-why, #stage.mission-responsive .f6-form { grid-template-columns: minmax(0, 1fr) }
  #stage.mission-responsive .f6-res { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  #stage.mission-responsive .f6-res > div:last-child { grid-column: 1 / -1 }
  #stage.mission-responsive .f6-invfoot { flex-direction: column; align-items: stretch; gap: 12px }
  #stage.mission-responsive .f6-invfoot .btn { justify-content: center }
  #stage.mission-responsive .tx-path { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  #stage.mission-responsive .tx-sec { grid-template-columns: minmax(0, 1fr); padding: 12px }
  #stage.mission-responsive .tx-i { display: none }
  #stage.mission-responsive .f6-ans { flex-wrap: wrap }
  #stage.mission-responsive .f6-ans input { width: 120px }
  #stage.mission-responsive .f6-clim { display: block; overflow-x: auto; font-size: 12px }
  #stage.mission-responsive .f6-clim th, #stage.mission-responsive .f6-clim td { padding: 8px 6px }
  #stage.mission-responsive .f6-ev { flex-wrap: wrap }
  #stage.mission-responsive .f6-subgrid, #stage.mission-responsive .rsb-grid { display: grid; grid-template-columns: minmax(0, 1fr); height: auto; max-height: none; overflow: visible; flex: none }
  #stage.mission-responsive .f6-subright { min-width: 0 }
  #stage.mission-responsive .sb-acts { flex-wrap: wrap }
  #stage.mission-responsive .sb-acts .btn { min-width: 0; width: 100%; white-space: normal }
  #stage.mission-responsive .fgd, #stage.mission-responsive .fgd-hero, #stage.mission-responsive .fgd-row3, #stage.mission-responsive .fgd-row2, #stage.mission-responsive .fgd-parts { grid-template-columns: minmax(0, 1fr); min-height: 0 }
  #stage.mission-responsive .fgd-st { grid-template-columns: repeat(2, minmax(0, 1fr)) }

  /* Test playback and diagnosis stay in reach below the scene. */
  #stage.mission-responsive .fg-tbottom { position: relative; inset: auto; order: 4; transform: none; width: 100% }
  #stage.mission-responsive .fg-start, #stage.mission-responsive .fg-timeline { flex-wrap: wrap; gap: 12px; padding: 16px }
  #stage.mission-responsive .fg-start > div { flex-basis: 70% }
  #stage.mission-responsive .fg-start .btn, #stage.mission-responsive .fg-rgo { width: 100%; justify-content: center }
  #stage.mission-responsive .fg-result { display: flex; flex-direction: column; align-items: stretch; padding: 16px }
  #stage.mission-responsive .fg-pl { min-width: 0; width: 100% }
  #stage.mission-responsive .fg-details { position: relative; inset: auto; order: 5; width: 100%; max-height: none; transform: none; padding: 14px }
  #stage.mission-responsive .fg-details .f6-csvg { min-height: 220px }
  #stage.mission-responsive .fi-choices { grid-template-columns: minmax(0, 1fr) }

  /* Sticky next action plus horizontally scrollable secondary actions. */
  #stage.mission-responsive .fg .mx-foot { position: sticky; inset: auto; bottom: 0; order: 20; height: auto; min-height: 155px; margin: auto -12px 0; padding: 14px 12px max(10px, env(safe-area-inset-bottom)); gap: 8px 12px; flex-wrap: wrap; z-index: 12 }
  #stage.mission-responsive .mx-foot .mx-rw, #stage.mission-responsive .mx-foot .sp { display: none }
  #stage.mission-responsive .mx-foot .mx-go { order: -1; width: 100%; min-width: 0; min-height: 44px; height: auto; margin: 0; justify-content: center }
  #stage.mission-responsive .mx-foot > button:not(.mx-go) { flex: 1; min-width: 0; font-size: 12px; min-height: 40px; padding: 4px }
  #stage.mission-responsive .mx-foot > button:not(.mx-go) .ico { display: none }

  #stage.mission-responsive .modal { width: calc(100% - 24px) !important; max-width: 640px; max-height: calc(100% - 32px) }
  #stage.mission-responsive .modal-head { padding: 16px }
  #stage.mission-responsive .modal-head h3 { font-size: 21px }
  #stage.mission-responsive .modal-body { padding: 4px 16px 16px }
  #stage.mission-responsive .modal-foot { padding: 12px 16px; flex-wrap: wrap }
  #stage.mission-responsive .pop { max-width: calc(100% - 20px); max-height: calc(100% - 40px); overflow: auto }
  #stage.mission-responsive .mch { position: absolute; inset: 12px; width: auto; height: auto; z-index: 75 }
  #stage.mission-responsive .mch-b { max-width: 100% }
  #stage.mission-responsive .mch-ib { min-width: 40px; min-height: 44px }
  #stage.mission-responsive .toasts { max-width: calc(100% - 24px); inset-inline: 12px; bottom: 130px }
  #viewport:has(.mission-responsive) #proto-nav-btn { display: none }
}

/* Stable build utilities inside the Parts / Connect panel. */
.fg-invh { flex-wrap:wrap }
.fg-build-tools { display:flex; flex-wrap:wrap; align-items:center; gap:6px; margin-inline-start:auto }
.fg-build-tools .fg-chipb { height:36px; padding-inline:10px; white-space:nowrap }
#stage.mission-responsive .fg-build-tools { width:100%; margin:0 }
#stage.mission-responsive .fg-build-tools .fg-chipb { min-height:40px; flex:1; font-size:12px }

/* Reserve the actual toolbar height, including wrapping utility controls. */
#stage:not(.mission-responsive) .fg[data-route="f-build"] .fg-lcol { bottom:var(--build-toolbar-clearance,320px); min-height:0; overflow:hidden }
#stage:not(.mission-responsive) .fg[data-route="f-build"] .fg-lcol > .fp { min-height:0; overflow:hidden }
#stage:not(.mission-responsive) .fg[data-route="f-build"] .fp-h { flex:none }
#stage:not(.mission-responsive) .fg[data-route="f-build"] .fp-body { flex:1; min-height:0; overflow-y:auto; scrollbar-width:thin; overscroll-behavior:contain }
#stage:not(.mission-responsive) .fg[data-route="f-build"] .fp-body::-webkit-scrollbar { display:block; width:5px }

/* Solid black mission help buttons in both themes. */
.fg .fg-help .fg-askb, .fg .fg-help .fg-hintb, [data-theme="light"] .fg .fg-help .fg-askb, [data-theme="light"] .fg .fg-help .fg-hintb { background:#000; color:#fff; border-color:#343438 }
.fg .fg-help .fg-hintb, [data-theme="light"] .fg .fg-help .fg-hintb { color:#00ff6f; border-color:#008c40 }
.fg .fg-help button:hover, .fg .fg-help button:focus-visible { background:#000; border-color:#00ff6f }

/* Give the mission mentor label comfortable horizontal space. */
.fg .fg-help .fg-askb { min-width:200px; padding-inline:20px; gap:10px; white-space:nowrap; flex-shrink:0 }
.fg .fg-help .fg-askb .mface { flex-shrink:0 }
