.mobile-fit-options{display:none}
@media(max-width:700px),(pointer:coarse),(max-width:950px) and (max-height:500px){
 body.phone-fit{margin:0!important;min-width:0!important;overflow-anchor:none}
 body.phone-fit .app,body.phone-fit>main{box-sizing:border-box!important;padding:2px!important;width:100%!important;max-width:100%!important}
 body.phone-fit header{display:flex!important;flex-wrap:wrap!important;align-items:center;gap:4px!important;padding:3px 4px!important;margin:0!important;min-height:0!important;max-width:100%;box-sizing:border-box}
 body.phone-fit header .brand,body.phone-fit header>h1{flex:1 0 100%;min-width:0}
 body.phone-fit header h1{font-size:16px!important;line-height:1.2!important;margin:0!important}
 body.phone-fit header>#gameHelpLauncher,body.phone-fit header>.electrical-manual-open{flex:1 1 auto!important;width:auto!important;min-width:0!important;min-height:38px!important;padding:5px 8px!important;font-size:13px!important;margin:0!important;white-space:normal!important}
 body.phone-fit .toolbar{gap:3px!important;padding:3px!important;max-width:100%!important}
 body.phone-fit .toolbar .practice-badge{padding:4px 6px!important;margin:0!important;font-size:12px!important;line-height:1.3!important;min-height:0!important}
 body.phone-fit .toolbar .tools,body.phone-fit .sensor-view-controls{gap:4px!important;margin:0!important;align-items:center;position:relative}
 body.phone-fit .toolbar .tools>button,body.phone-fit .toolbar>button,body.phone-fit .sensor-view-controls>button{font-size:13px!important;min-height:40px!important;padding:5px 7px!important;margin:0!important;min-width:40px!important}
 body.phone-fit .mobile-fit-options{display:block;position:relative;order:3;flex:0 0 auto;margin:0;border:1px solid #7895a8;border-radius:6px;background:#233d50;color:#fff;z-index:80}
 body.phone-fit .mobile-fit-options>summary{min-height:40px!important;padding:7px!important;font:700 13px/1.5 system-ui!important;cursor:pointer;box-sizing:border-box}
 body.phone-fit .mobile-fit-panel{position:absolute;right:0;top:calc(100% + 4px);width:min(310px,88vw);max-height:65dvh;overflow:auto;background:#102b40;border:1px solid #7895a8;border-radius:6px;padding:8px;box-shadow:0 8px 18px #0008;box-sizing:border-box}
 body.phone-fit .mobile-fit-options:not([open])>.mobile-fit-panel{display:none!important}
 body.phone-fit .mobile-fit-panel>*{width:100%!important;max-width:100%!important;box-sizing:border-box;margin:4px 0!important}
 body.phone-fit .mobile-fit-panel .sensor-tools{display:flex;flex-wrap:wrap!important;white-space:normal;overflow:visible}
 body.phone-fit main>.sensor-tools{display:none!important}
 body.phone-fit .mobile-fit-panel .screen-auto-rotate:not([hidden]){display:flex!important}
 body.phone-fit .tap-guide{padding:4px 6px!important;font-size:12px!important;line-height:1.3!important;min-height:0!important}
 body.phone-fit .board-viewport,body.phone-fit .sensor-scroll{display:flex;flex-direction:column;align-items:flex-start;width:100%!important;min-width:0!important;box-sizing:border-box;overscroll-behavior:auto}
 body.phone-fit .circuit-frame,body.phone-fit .sensor-frame,body.phone-fit .sensor-scene-frame{flex:none;margin:auto!important}
 body.phone-fit .screen-rotation-status:not(:empty){font-size:12px!important;line-height:1.3!important;padding:2px!important}
 body.phone-fit .sensor-wiring-nav{flex-wrap:wrap;gap:4px;margin:4px 0!important}
 body.phone-fit .sensor-wiring-nav select{max-width:100%;min-width:0}
 body.phone-fit #sensorTitle{font-size:14px!important;line-height:1.3;margin:4px 0!important}
 body.phone-fit #sensorMessage{font-size:12px!important;line-height:1.3;margin:3px 0!important}
 body.phone-fit .sensor-work,body.phone-fit .sensor-lab{min-width:0;max-width:100%}
}
@media(max-width:950px) and (max-height:500px){
 body.phone-fit header{flex-wrap:nowrap!important}
 body.phone-fit header .brand,body.phone-fit header>h1{flex:1 1 auto;min-width:0}
 body.phone-fit header h1{font-size:14px!important}
 body.phone-fit header>#gameHelpLauncher,body.phone-fit header>.electrical-manual-open{flex:0 1 auto!important;min-height:34px!important;font-size:12px!important}
 body.phone-fit .toolbar .practice-badge{font-size:11px!important;line-height:1.2!important;padding:2px 6px!important}
 body.phone-fit .tap-guide{font-size:11px!important;padding:2px 6px!important}
 body.phone-fit .tap-guide strong{display:inline!important;margin-right:5px}
}

/* Native finger panning must remain possible even when starting on a screw. */
body #workspace,body .board-viewport,body .sensor-scroll,body #board,body #board .terminal,body #diagram,body #diagram .pin,body #sensorBoard,body .sensor-terminal{touch-action:manipulation!important}
body .board-viewport,body .sensor-scroll{overscroll-behavior:auto;overflow-anchor:none}
body #board img,body #diagram image,body #sensorBoard image{-webkit-user-drag:none;user-select:none}
/* Essential navigation remains outside the collapsed options on phones. */
.mobile-practice-switch{display:none}
body.phone-fit .mobile-practice-switch{display:flex;align-items:center;gap:5px;width:100%;box-sizing:border-box;font:700 14px/1.3 system-ui;padding:3px 4px;color:#d8f4ff}
body.phone-fit .mobile-practice-switch select{flex:1;min-width:0;max-width:100%;min-height:36px;background:#102b40;color:#d8f4ff;border:1px solid #7895a8;border-radius:5px;font:700 14px system-ui}
