/* Option 1: map-first floating controls, with the live material/tool buttons
   sharing one strip. The transparent space between controls remains pannable. */
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] {
  --pad-key:44px;
  left:12px; right:12px; bottom:max(12px,env(safe-area-inset-bottom));
  width:auto; max-width:none; height:66px; min-height:0; max-height:none;
  transform:none; margin:0; padding:6px; overflow:visible;
  border:1.5px solid var(--shell-edge); border-radius:12px;
  background:var(--shell-paper); box-shadow:var(--shell-shadow);
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] :is(#edit-tools,.edit-mode-header,.edit-secondary,.edit-actions) {
  display:contents; padding:0; margin:0; border:0; background:none;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] :is(#onboarding,#work-mode-heading,#quick-start,#line-panel) { display:none; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] :is(#selection-bar,#edit-mode-status,#recent-work-copy) {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%);
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #inventory-open {
  position:absolute; left:6px; top:6px; width:36%; height:52px; min-height:52px;
  display:flex; gap:2px; padding:4px 17px 4px 2px; border:0; border-right:1px solid var(--shell-line);
  border-radius:0; box-shadow:none; background:transparent;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #bag-preview { width:38px; height:36px; flex:none; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #inventory-open strong { position:static; flex:1; width:auto; height:auto; min-width:0; margin:0; padding:0; clip-path:none; overflow:visible; text-align:left; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #inventory-open .material-chevron { display:block; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #bag-material { font:700 14px/1.25 var(--font-game); white-space:normal; overflow-wrap:anywhere; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] .toolbar {
  position:absolute; left:calc(36% + 12px); right:6px; top:6px; height:52px;
  display:flex; gap:5px; padding:0; border:0; background:none;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] .tool {
  flex:1; width:0; min-width:0; height:52px; min-height:52px; padding:3px 1px;
  flex-direction:column; gap:1px; font-size:13px; border-radius:7px;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] .tool .game-tool-art { width:26px; height:26px; }
html[lang] body[data-edit-mode="dig"] #selection-panel[data-mobile-controls="true"] .toolbar { left:6px; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] :is(#scope-toggle,#material-pick) {
  position:absolute; bottom:76px; width:auto; min-width:0; height:44px; min-height:44px;
  padding:5px 9px; margin:0; font-size:12px; border-width:1px; border-radius:8px;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #scope-toggle { left:0; padding-right:20px; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #material-pick { left:98px; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #material-pick .shortcut-key { display:none; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #edit-close {
  position:absolute; right:0; bottom:76px; top:auto; height:44px; min-height:44px; min-width:0;
  display:flex; flex-direction:row; padding:6px 8px; gap:4px; font-size:12px;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #edit-close .edit-exit-icon { width:17px; }
#mobile-edit-pad { display:grid; grid-template-columns:repeat(3,var(--pad-key)); grid-template-rows:repeat(3,var(--pad-key)); gap:2px; touch-action:none; }
#mobile-edit-pad button {
  display:grid; place-items:center; min-width:0; padding:0; border:1.5px solid var(--shell-edge);
  border-radius:10px; background:var(--shell-paper); box-shadow:var(--shell-shadow); touch-action:none; user-select:none; -webkit-user-select:none;
}
#mobile-edit-pad button img { width:26px; height:26px; pointer-events:none; opacity:.8; }
#mobile-edit-pad [data-direction="0,-1"] { grid-area:1 / 2; }
#mobile-edit-pad [data-direction="0,-1"] img { transform:none; }
#mobile-edit-pad [data-direction="-1,0"] { grid-area:2 / 1; }
#mobile-edit-pad [data-direction="-1,0"] img { transform:rotate(-90deg); }
#mobile-edit-pad [data-direction="1,0"] { grid-area:2 / 3; }
#mobile-edit-pad [data-direction="1,0"] img { transform:rotate(90deg); }
#mobile-edit-pad [data-direction="0,1"] { grid-area:3 / 2; }
#mobile-edit-pad [data-direction="0,1"] img { transform:rotate(180deg); }
#mobile-edit-pad button[data-held="true"] { background:#ffe5b3; box-shadow:var(--shell-control-pressed); }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #mobile-edit-pad { position:absolute; left:2px; bottom:161px; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #mobile-edit-apply {
  position:absolute; right:3px; bottom:160px; width:88px; height:88px; padding:8px;
  display:flex; align-items:center; justify-content:center; flex-direction:column; gap:5px;
  border:1.5px solid #9d873f; border-radius:17px; color:var(--shell-ink); background:#ffe5a0;
  box-shadow:inset 0 2px 0 #fff6cf,inset 0 -4px 0 #d9bc78,0 3px 4px #24443726;
  font:700 20px/1.15 var(--font-game); touch-action:manipulation;
}
#mobile-edit-apply img { width:34px; height:34px; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #mobile-edit-apply[data-multi="true"] { font-size:16px; word-break:keep-all; }
#mobile-edit-apply:active:not(:disabled) { filter:brightness(.94); }
#mobile-edit-apply:disabled { opacity:.6; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #recent-work { position:absolute; right:9px; bottom:258px; width:76px; margin:0; padding:0; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #undo {
  width:76px; height:60px; min-height:60px; padding:5px; display:flex; flex-direction:column; gap:2px;
  border:1px solid var(--shell-edge); border-radius:11px; background:var(--shell-paper); box-shadow:var(--shell-shadow); font-size:12px;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #undo .game-icon { width:26px; height:26px; }
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #mobile-edit-hint {
  position:absolute; left:0; bottom:126px; width:max-content; max-width:100%; margin:0; padding:5px 9px;
  border-radius:8px; background:#365641ed; color:#fffbee; font:500 12px/1.35 var(--font-ui); pointer-events:none;
  box-sizing:border-box; white-space:normal; word-break:keep-all; overflow-wrap:anywhere;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #scope-panel {
  position:absolute; left:0; right:0; bottom:126px; top:auto; width:auto; max-width:none; margin:0; z-index:3;
}
html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #energy-reduce-range { position:absolute; right:0; bottom:310px; }
@media (max-width:350px) {
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] { left:8px; right:8px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #material-pick { left:89px; padding:5px 6px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #edit-close { padding:6px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #edit-close .edit-exit-icon { display:none; }
}
@media (max-height:450px) and (orientation:landscape) {
  html[lang][data-mobile-shell="true"] body[data-world-kind] .world-stage:has(#selection-panel[data-mobile-controls="true"]) .map-view-controls { top:64px; width:142px; }
  html[lang][data-mobile-shell="true"] body[data-world-kind] .world-stage:has(#selection-panel[data-mobile-controls="true"]) #map-view-controls #view-options { display:flex; flex-direction:row; gap:5px; }
  html[lang][data-mobile-shell="true"] body[data-world-kind] .world-stage:has(#selection-panel[data-mobile-controls="true"]) #map-view-controls #view-rotation { display:flex; flex-direction:row; width:auto; gap:5px; }
  html[lang][data-mobile-shell="true"] body[data-world-kind] .world-stage:has(#selection-panel[data-mobile-controls="true"]) #map-view-controls button { flex:none; width:44px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] { left:max(12px,env(safe-area-inset-left)); right:max(12px,env(safe-area-inset-right)); height:60px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #mobile-edit-pad { bottom:74px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #mobile-edit-apply { bottom:74px; width:76px; height:76px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #recent-work { right:3px; bottom:154px; width:76px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #undo { width:76px; height:44px; min-height:44px; flex-direction:row; font-size:11px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #undo .game-icon { width:18px; height:18px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #mobile-edit-hint { left:50%; bottom:124px; max-width:calc(100% - 340px); transform:translateX(-50%); }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #scope-toggle { left:calc(50% - 145px); bottom:72px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #material-pick { left:calc(50% - 47px); bottom:72px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #edit-close { right:calc(50% - 145px); bottom:72px; }
  html[lang] body[data-edit-mode] #selection-panel[data-mobile-controls="true"] #scope-panel { left:155px; right:90px; bottom:124px; }
}
@media (max-height:360px) and (orientation:landscape) {
  html[lang][data-mobile-shell="true"] body[data-world-kind] .world-stage:has(#selection-panel[data-mobile-controls="true"]) .world-links { display:flex; flex-flow:row nowrap; top:64px; left:160px; width:106px; }
}
