#rx-touch-controls[hidden],#rx-touch-controls [hidden] { display:none!important; }
#rx-touch-controls { position:fixed; z-index:1000; bottom:env(safe-area-inset-bottom,0px); left:env(safe-area-inset-left,0px); right:env(safe-area-inset-right,0px); display:flex; flex-wrap:wrap; justify-content:center; gap:5px; padding:7px; background:#e8dbb5f5; border-top:3px double #9d7a3b; color:#312919; font:14px Georgia,serif; }
#rx-touch-controls button { min-height:44px; min-width:48px; padding:6px 10px; font:inherit; color:inherit; background:linear-gradient(#fff8df,#dfcc97); border:1px solid #9d7a3b; border-radius:7px; touch-action:manipulation; }
#rx-touch-controls button:focus-visible { outline:3px solid #286aae; }
#rx-touch-actions { display:contents; }
#rx-touch-zoom { display:inline-flex; gap:5px; }
#rx-touch-controls.collapsed { background:transparent; border:0; padding:4px; }
#rx-touch-toggle { font-weight:bold!important; }
#rx-touch-controls #rx-touch-stop { background:#733e2b; color:#fff6dc; }
#rx-touch-status { flex-basis:100%; text-align:center; font-size:12px; }
body.rx-touch #rx-hudbar,body.rx-touch #rx-inventory:not(.expanded),body.rx-touch #rx-minimap { display:none!important; }
body.rx-touch #rx-ui #rx-questbar { top:8px; left:8px; width:calc(100vw - 76px); max-width:560px; padding:7px 10px; pointer-events:auto; }
body.rx-touch #rx-ui #rx-questbar:not(.touch-expanded) { width:auto; min-width:90px; min-height:44px; padding:12px 14px; }
body.rx-touch #rx-questbar:not(.touch-expanded) > * { display:none; }
body.rx-touch #rx-questbar:not(.touch-expanded)::before { content:'Quest ▾'; font-weight:bold; font-size:15px; }
body.rx-touch #rx-questbar.touch-expanded .rx-q-title::after { content:' · Tap to hide ▴'; font-size:11px; text-transform:none; }
body.rx-touch #rx-tools { display:none!important; }
/* Use the original leather belt, illustrated slots and active glow. Scroll only if it cannot fit. */
body.rx-touch.rx-touch-tools #rx-tools { display:flex!important; top:68px; right:8px; bottom:auto; width:84px; max-height:calc(100dvh - var(--rx-dock-height,80px) - 76px); flex-flow:column nowrap; overflow-x:hidden; overflow-y:auto; align-items:center; }
body.rx-touch #rx-tools .rx-belt { display:block; flex:none; width:54px; height:34px; }
body.rx-touch #rx-tools .rx-tool { width:54px; height:50px; flex:none; }
body.rx-touch #rx-tools .rx-tool-lbl { display:none; }
body.rx-touch .rx-dialogue { width:min(540px,calc(100vw - 24px)); max-width:calc(100vw - 24px); max-height:calc(100dvh - 130px); }
body.rx-touch .rx-dialogue .rx-body { max-height:calc(100dvh - 185px); overflow-y:auto; }
body.rx-touch .rx-dialogue .rx-close { width:44px; height:44px; line-height:40px; }
body.rx-touch .rx-dialogue .rx-responses > * { min-height:44px; }
body.rx-touch #rx-ui #rx-inventory.expanded { top:var(--rx-inv-top,68px); left:6px; max-width:calc(100vw - 12px); overflow:visible; }
body.rx-touch #rx-inventory .rx-inv-main { min-width:0; }
body.rx-touch #rx-inventory .rx-inv-ctl { display:grid; grid-template-columns:auto minmax(0,1fr) auto minmax(0,.8fr); gap:4px; }
body.rx-touch #rx-inventory .rx-inv-ctl label { padding:3px 5px; }
body.rx-touch #rx-inventory .rx-inv-ctl input,body.rx-touch #rx-inventory .rx-inv-ctl select { width:100%; min-width:0; }
body.rx-touch #rx-inventory .rx-money { grid-column:1/-1; justify-content:end; margin-left:0; gap:12px; }
body.rx-touch #rx-inventory .rx-iq-slots { height:calc(var(--inv-rows) * 55px + 13px); overflow-y:auto; overflow-x:hidden; scrollbar-width:thin; }
body.rx-touch #rx-inventory .rx-iq-slots .rx-slot { flex:none; }
body.rx-touch #rx-inventory .rx-inv-grid { grid-template-columns:repeat(var(--inv-cols,8),var(--inv-slot)); }

body.rx-touch #rx-tutorialhint { max-width:calc(100vw - 24px); bottom:calc(var(--rx-dock-height,80px) + 20px); }
body.rx-touch #info { display:none; }
body.rx-touch #rx-algebra-clock { bottom:calc(var(--rx-dock-height,80px) + 20px); }
@media(max-height:600px),(max-width:600px) {
    body.rx-touch .rx-dialogue { position:fixed; left:12px!important; top:68px!important; width:calc(100vw - 24px); max-width:none; max-height:calc(100dvh - 160px); }
    body.rx-touch .rx-dialogue .rx-body { max-height:calc(100dvh - 225px); }
    body.rx-touch .rx-dialogue .rx-tail { display:none; }
}

body.rx-touch #rx-dev-badge { bottom:calc(var(--rx-dock-height,80px) + 14px); left:8px; font-size:10px; opacity:.85; max-width:calc(100vw - 16px); pointer-events:none; }

#rx-walk-controls { position:fixed; bottom:16px; left:50%; transform:translateX(-50%); z-index:1000; }
#rx-walk-controls button { padding:10px 18px; min-height:44px; border:2px solid #9d7a3b; border-radius:8px; color:#fff6dc; background:#36584c; font:bold 15px Georgia,serif; cursor:pointer; }
#rx-walk-controls[hidden],body.rx-touch #rx-walk-controls { display:none; }
#rx-touch-controls button:disabled { opacity:.55; cursor:default; }

#rx-touch-joystick { position:fixed; z-index:995; width:112px; height:112px; margin:-56px 0 0 -56px; box-sizing:border-box; border:3px solid #f6dfa7b8; border-radius:50%; background:#2e483a55; box-shadow:0 0 0 2px #253b31a8,inset 0 0 24px #182d3370; pointer-events:none; }
#rx-touch-joystick[hidden] { display:none; }
#rx-touch-joystick span { position:absolute; left:50%; top:50%; width:36px; height:36px; margin:-18px; box-sizing:border-box; border:2px solid #fff2d3; border-radius:50%; background:#b79850c9; box-shadow:0 2px 6px #0006; }

/* All dialog states share the usable area above the measured control dock. */
body.rx-touch .rx-dialogue,body.rx-touch .rx-dialogue.rx-submitting { position:fixed; top:12px!important; left:50%!important; transform:translateX(-50%); width:min(540px,calc(100vw - 24px)); max-width:calc(100vw - 24px); max-height:calc(100dvh - var(--rx-dock-height,80px) - 24px); }
body.rx-touch .rx-dialogue .rx-body,body.rx-touch .rx-dialogue.rx-submitting .rx-body { max-height:calc(100dvh - var(--rx-dock-height,80px) - 92px); overflow-y:scroll; overscroll-behavior:contain; scrollbar-gutter:stable; }
body.rx-touch .rx-dialogue .rx-tail { display:none; }
body.rx-touch .rx-dialogue .rx-body::-webkit-scrollbar { width:10px; background:#e4d7af; }
body.rx-touch .rx-dialogue .rx-body::-webkit-scrollbar-thumb { background:#8b7749; border:2px solid #e4d7af; border-radius:6px; }
body.rx-touch:has(.rx-dialogue[style*="display: block"]) #rx-dev-badge { display:none; }
body.rx-touch #rx-datalib { top:30px; }
body.rx-touch:has(.rx-dialogue[style*="display: block"]) .rx-dbg-toggle,
body.rx-touch:has(#rx-datalib[style*="display: block"]) .rx-dbg-toggle { display:none; }
body.rx-touch #rx-datalib .rx-panel-x { width:44px; height:44px; line-height:40px; right:4px; top:4px; }
/* A tool workspace owns input; its own Close/Save/Cancel controls replace the world dock. */
body.rx-touch:has(#rx-foodweb[style*="display: block"]) #rx-touch-controls,
body.rx-touch:has(#rx-foodweb[style*="display: block"]) #rx-dev-badge,
body.rx-touch:has(#rx-foodweb[style*="display: block"]) #rx-menu-toggle { display:none!important; }
body.rx-touch #rx-foodweb[style*="display: block"] { height:calc(100dvh - 48px); }
/* Reuse desktop tool content in bounded, tabbed workspaces. */
.rx-mobile-workspace { position:fixed!important;inset:24px 12px 12px!important;transform:none!important;margin:0 auto!important;width:min(1000px,calc(100vw - 24px))!important;max-width:calc(100vw - 24px)!important;height:calc(100dvh - 36px)!important;max-height:calc(100dvh - 36px)!important;box-sizing:border-box;overflow:hidden!important;padding:12px!important;z-index:1100!important; }
.rx-mobile-workspace:not([style*="display: none"]) { display:flex!important;flex-direction:column;gap:8px; }
.rx-mobile-workspace .rx-mw-header { display:flex;align-items:center;gap:10px;flex:none;min-height:36px; }
.rx-mobile-workspace .rx-mw-header h2 { flex:1;margin:0!important;font-size:20px!important; }
.rx-mobile-workspace .rx-mw-header .timeline-header { flex:1; }
.rx-mobile-workspace .rx-mw-header .timeline-header img { width:44px;height:44px; }
.rx-mobile-workspace .rx-mw-tabs { display:flex;gap:5px;flex:none;overflow-x:auto;scrollbar-gutter:stable; }
.rx-mobile-workspace .rx-mw-tabs button { flex:1;min-width:0;white-space:normal;overflow-wrap:anywhere;min-height:44px;padding:6px 10px;font:bold 14px Georgia,serif;color:#fff6dc;background:linear-gradient(#5b8fc9,#2c5893);border:2px solid #a9863c;border-radius:7px; }
.rx-mobile-workspace .rx-mw-tabs button[aria-selected=true] { color:#312919;background:linear-gradient(#fff6db,#dfcb94);box-shadow:inset 0 0 0 2px #9d7a3b; }
.rx-mobile-workspace .rx-mw-content { flex:1;min-height:0;display:flex; }
.rx-mobile-workspace .rx-mw-pane { flex:1;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding:8px; }
.rx-mobile-workspace .rx-mw-pane[hidden] { display:none!important; }
.rx-mobile-workspace .rx-mw-footer { flex:none;display:flex;flex-direction:column;gap:6px; }
.rx-mobile-workspace .rx-mw-footer p { margin:0!important;font-size:13px; }
.rx-mobile-workspace .rx-mw-footer .timeline-actions,.rx-mobile-workspace .rx-mw-footer .ev-row { margin:0!important;gap:6px; }
.rx-mobile-workspace button,.rx-mobile-workspace select { min-height:44px;touch-action:manipulation; }
.rx-mobile-workspace input[type=range] { min-height:44px;touch-action:pan-y; }
.rx-mobile-workspace :focus-visible { outline:3px solid #a77922;outline-offset:2px; }
.rx-mobile-workspace .rx-mw-stepper { display:flex;gap:8px;justify-content:center;margin:6px 0; }
.rx-mobile-workspace .rx-mw-stepper button { min-width:44px;font-size:20px; }
.rx-mobile-workspace .rx-mw-pane::-webkit-scrollbar,.rx-mobile-workspace .rx-mw-tabs::-webkit-scrollbar { width:12px;height:12px;background:#e4d7af; }
.rx-mobile-workspace .rx-mw-pane::-webkit-scrollbar-thumb,.rx-mobile-workspace .rx-mw-tabs::-webkit-scrollbar-thumb { background:#8b7749;border:2px solid #e4d7af;border-radius:6px; }
body:has(.rx-mobile-workspace:not([style*="display: none"])) #rx-touch-controls,
body:has(.rx-mobile-workspace:not([style*="display: none"])) #rx-menu-toggle,
body:has(.rx-mobile-workspace:not([style*="display: none"])) #rx-debug,
body:has(.rx-mobile-workspace:not([style*="display: none"])) #rx-dev-badge { display:none!important; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-sliders { display:flex;flex-wrap:wrap;gap:14px; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-org { width:150px; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-globe { width:min(430px,100%);margin:70px auto 0; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-legend { min-width:560px; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-foot { flex-wrap:wrap;margin:0;gap:6px; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-cycles .inc,#rx-ecoglobe.rx-mobile-workspace .rx-eg-cycles .dec { min-width:44px;min-height:44px; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-slot { width:44px;height:44px;line-height:40px;font:inherit; }
#rx-ecoglobe.rx-mobile-workspace .rx-eg-bottom { margin:0; }
#rx-evoglobe.rx-mobile-workspace .ev-globe { width:min(360px,100%);margin:70px auto 0; }
#rx-evoglobe.rx-mobile-workspace .ev-controls { min-width:0; }
#rx-evoglobe.rx-mobile-workspace .ev-close { float:none;min-width:44px; }
#rx-evoglobe.rx-mobile-workspace .ev-bar { grid-template-columns:95px minmax(50px,1fr) 35px; }
.biology-timeline.rx-mobile-workspace .timeline-rows { min-width:660px;grid-template-columns:repeat(4,minmax(0,1fr));margin:0;gap:10px; }
.biology-timeline.rx-mobile-workspace .timeline-chart { min-width:560px; }
.biology-timeline.rx-mobile-workspace .timeline-palette { padding:4px; }
.biology-timeline.rx-mobile-workspace .timeline-slot-button { min-height:100px; }
.biology-timeline.rx-mobile-workspace .timeline-return { min-height:44px; }
body.rx-touch #rx-survey { top:68px;left:8px;right:auto;width:min(340px,calc(100vw - 108px));box-sizing:border-box; }
body.rx-touch #rx-survey .rx-sv-top { flex-wrap:wrap; }
body.rx-touch #rx-survey button { min-height:44px;padding:5px 8px;font:inherit; }
body.rx-touch #rx-survey .rx-sv-count { position:static;margin-top:4px; }
body.rx-touch #rx-survey .rx-sv-slots { display:grid;grid-template-columns:repeat(10,minmax(0,1fr));gap:2px; }
body.rx-touch #rx-survey .rx-sv-slot { width:auto;min-width:0; }
body.rx-touch #rx-survey.collapsed .rx-sv-body,body.rx-touch #rx-survey.collapsed .rx-sv-slots { display:none; }
body.rx-touch #rx-order { position:fixed;left:50%;top:12px;transform:translateX(-50%);max-width:calc(100vw - 24px);max-height:calc(100dvh - var(--rx-dock-height,80px) - 24px);overflow-y:scroll;scrollbar-gutter:stable;z-index:980; }
body.rx-touch #rx-order button { min-width:44px;min-height:44px;font:inherit; }
body.rx-touch #rx-order .rx-or-confirm { max-width:100%; }
@media(max-height:500px) { .rx-mobile-workspace .rx-mw-header { min-height:24px; } .rx-mobile-workspace .rx-mw-header h2 { font-size:16px!important; } .rx-mobile-workspace .rx-mw-header .timeline-header img { width:28px;height:28px; } .rx-mobile-workspace { gap:4px!important;padding:8px!important; } }
.rx-sv-toggle { display:none; }
body.rx-touch #rx-survey .rx-sv-toggle { display:block;color:#312919;background:linear-gradient(#fff8df,#dfcc97);border:1px solid #9d7a3b;border-radius:5px; }
#rx-ecoglobe .rx-eg-cycles button { font:inherit;color:inherit;background:transparent;border:0; }

@media(max-width:500px) { .rx-mobile-workspace .rx-mw-tabs { display:grid;grid-template-columns:repeat(2,minmax(0,1fr)); } .rx-mobile-workspace .rx-mw-tabs button { overflow-wrap:normal; } }

@media(max-width:500px) { .biology-timeline.rx-mobile-workspace .timeline-rows { min-width:0;grid-template-columns:1fr; } }
/* Map views keep actions fixed while the selected panel scrolls. */
#rx-zone-map.rx-mobile-workspace .rx-mw-header,#rx-world-map.rx-mobile-workspace .rx-mw-header { background:transparent; }
#rx-zone-map.rx-mobile-workspace .rx-mw-pane,#rx-world-map.rx-mobile-workspace .rx-mw-pane { display:block; }
#rx-zone-map.rx-mobile-workspace .rx-mw-pane[hidden],#rx-world-map.rx-mobile-workspace .rx-mw-pane[hidden] { display:none!important; }
#rx-zone-map.rx-mobile-workspace #rx-zone-canvas { height:100%;min-height:110px;touch-action:manipulation; }
#rx-zone-map.rx-mobile-workspace #rx-zone-markers,#rx-world-map.rx-mobile-workspace .place-list { max-height:none;overflow:visible; }
#rx-zone-map.rx-mobile-workspace .map-actions { display:flex;flex-wrap:wrap;gap:6px; }
#rx-zone-map.rx-mobile-workspace #rx-zone-pin { max-height:3em;overflow:auto; }
#rx-zone-map.rx-mobile-workspace #rx-zone-filters label { min-height:44px; }
#rx-zone-map.rx-mobile-workspace #rx-zone-filters input { width:24px;height:24px; }
#rx-world-map.rx-mobile-workspace #rx-world-map-pane-map-0:not([hidden]) { display:flex;flex-direction:column;overflow:hidden; }
#rx-world-map.rx-mobile-workspace .world-scroll { flex:1;min-height:90px;height:auto;touch-action:pan-x pan-y;scrollbar-gutter:stable; }
#rx-world-map.rx-mobile-workspace .location { width:28px;height:28px; }
#rx-world-map.rx-mobile-workspace .location::before { content:'';position:absolute;inset:-8px; }
#rx-world-map.rx-mobile-workspace .route-controls { grid-template-columns:1fr;gap:8px;margin:8px 0; }
#rx-world-map.rx-mobile-workspace .world-scroll::-webkit-scrollbar { width:12px;height:12px;background:#e4d7af; }
#rx-world-map.rx-mobile-workspace .world-scroll::-webkit-scrollbar-thumb { background:#8b7749;border:2px solid #e4d7af;border-radius:6px; }
@media(max-width:500px){#rx-zone-map.rx-mobile-workspace .rx-panel-hdr,#rx-world-map.rx-mobile-workspace .rx-panel-hdr{font-size:16px!important;max-width:95%;}}
body.rx-touch #rx-progress-panel { position:fixed;inset:12px;width:auto;max-width:none;max-height:none;display:flex;flex-direction:column;overflow:hidden; }
body.rx-touch #rx-progress-panel[hidden] { display:none; }
body.rx-touch #rx-progress-list { flex:1;min-height:50px;overflow:auto;scrollbar-gutter:stable; }
body.rx-touch #rx-progress button,body.rx-touch #rx-progress input { min-height:44px;font-size:16px; }
body.rx-touch #rx-progress-panel>p { font-size:14px;margin:4px 0; }
body.rx-touch #rx-progress-restart { display:none; }
body.rx-touch #rx-progress-confirm { max-height:25dvh;overflow:auto; }
body.rx-touch #rx-progress-list::-webkit-scrollbar { width:12px;background:#e4d7af; }
body.rx-touch #rx-progress-list::-webkit-scrollbar-thumb { background:#8b7749;border:2px solid #e4d7af;border-radius:6px; }
body.rx-touch #rx-progress-panel .rx-progress-body { flex:1;min-height:0;overflow:auto;scrollbar-gutter:stable; }
body.rx-touch #rx-progress-panel #rx-progress-list { flex:none;overflow:visible;max-height:none; }
body.rx-touch #rx-progress-panel #rx-progress-restart { display:block; }
body.rx-touch #rx-progress-panel #rx-progress-footer { flex:none;margin-top:8px; }
body.rx-touch .rx-progress-body::-webkit-scrollbar { width:12px;background:#e4d7af; }
body.rx-touch .rx-progress-body::-webkit-scrollbar-thumb { background:#8b7749;border:2px solid #e4d7af;border-radius:6px; }
#rx-zone-map.rx-mobile-workspace #rx-zone-map-pane-map-0:not([hidden]) { display:flex;flex-direction:column;overflow:hidden; }
#rx-zone-map.rx-mobile-workspace #rx-zone-canvas { flex:1;min-height:90px;height:auto; }
#rx-zone-map.rx-mobile-workspace .map-actions small { align-self:center;font-size:13px; }
#rx-zone-map.rx-mobile-workspace .rx-mw-tabs button,#rx-world-map.rx-mobile-workspace .rx-mw-tabs button { color:#fff6dc;background:linear-gradient(#5b8fc9,#2c5893);border:2px solid #a9863c; }
#rx-zone-map.rx-mobile-workspace .rx-mw-tabs button[aria-selected=true],#rx-world-map.rx-mobile-workspace .rx-mw-tabs button[aria-selected=true] { color:#312919;background:linear-gradient(#fff6db,#dfcb94); }

body.rx-touch #rx-progress-panel>h2 { flex:none; }
