/* Phone / tablet layout. Everything visual lives inside the touch media query,
   so mouse-driven (desktop) layouts are never affected. */
#sim-ui .sim-menu-toggle,#sim-ui .sim-mobile-menu{display:none}

@media (hover:none) and (pointer:coarse){
  :root{--m-l:calc(10px + env(safe-area-inset-left,0px));--m-r:calc(10px + env(safe-area-inset-right,0px));--m-t:calc(8px + env(safe-area-inset-top,0px));--m-b:calc(16px + env(safe-area-inset-bottom,0px));--m-pad:clamp(56px,16vmin,84px)}
  html,body{overscroll-behavior:none}
  body.sim-ui-ready #canvas{touch-action:none}
  body.sim-ui-ready #sim-ui>:not(.sim-dialog-backdrop),body.sim-ui-ready #mobileDriveControls{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;-webkit-tap-highlight-color:transparent}

  /* Top row: logo · speed · pause + menu */
  body.sim-ui-ready #sim-ui .sim-top{padding:var(--m-t) var(--m-r) 0 var(--m-l);gap:8px;background:none;align-items:flex-start}
  body.sim-ui-ready #sim-ui .sim-brand>div:not(.sim-brand-symbol),body.sim-ui-ready #sim-ui .sim-location{display:none}
  body.sim-ui-ready #sim-ui .sim-brand-symbol{width:30px;height:36px;margin-top:2px}
  body.sim-ui-ready #sim-ui .sim-brand-symbol svg{width:18px!important;height:18px!important}
  body.sim-ui-ready #sim-ui .sim-tools{gap:6px}
  body.sim-ui-ready #sim-ui .sim-tools>.sim-tool{display:none}
  body.sim-ui-ready #sim-ui .sim-tools>#sim-pause-button,body.sim-ui-ready #sim-ui .sim-tools>.sim-menu-toggle{display:flex;width:40px;min-width:40px;height:40px;min-height:40px;padding:0;border-radius:10px;background:#0f1c25cc;border-color:#d9e9ef29}
  body.sim-ui-ready #sim-ui.sim-menu-open .sim-menu-toggle{border-color:#dfb87780;color:var(--sim-accent)}

  /* Menu sheet with everything that used to sit on the screen */
  body.sim-ui-ready #sim-ui .sim-mobile-menu{position:absolute;top:calc(var(--m-t) + 46px);right:var(--m-r);z-index:40;flex-direction:column;gap:2px;width:min(250px,calc(100vw - 20px));max-height:calc(100dvh - var(--m-t) - 56px);overflow:auto;overscroll-behavior:contain;padding:6px;border:1px solid var(--sim-line);border-radius:14px;background:#12202b;box-shadow:0 18px 50px #0007;pointer-events:auto}
  body.sim-ui-ready #sim-ui.sim-menu-open .sim-mobile-menu{display:flex}
  body.sim-ui-ready #sim-ui .sim-menu-item{display:flex;align-items:center;gap:11px;min-height:44px;padding:0 12px;border-radius:9px;font-size:13px;text-align:left;color:#e4ecef}
  body.sim-ui-ready #sim-ui .sim-menu-item:active{background:#253744}
  body.sim-ui-ready #sim-ui .sim-menu-item>i{display:grid;place-items:center;width:20px;flex:none;font-style:normal;color:var(--sim-accent)}

  /* Speed, gear and limit: one small pill at the top centre */
  body.sim-ui-ready #sim-ui .sim-instruments{top:var(--m-t);bottom:auto;left:50%;right:auto;transform:translateX(-50%);width:auto;height:40px;padding:0 10px 0 12px;display:flex;align-items:center;border-radius:20px;background:#0f1c25cc;box-shadow:none;backdrop-filter:blur(10px)}
  body.sim-ui-ready #sim-ui .sim-instrument-top,body.sim-ui-ready #sim-ui .sim-instrument-foot,body.sim-ui-ready #sim-ui .sim-rpm,body.sim-ui-ready #sim-ui .sim-gear small{display:none}
  body.sim-ui-ready #sim-ui .sim-instrument-main{margin:0;gap:9px}
  body.sim-ui-ready #sim-ui .sim-speed{width:auto;min-width:52px;gap:3px}
  body.sim-ui-ready #sim-ui .sim-speed strong{font-size:25px;font-weight:400}
  body.sim-ui-ready #sim-ui .sim-speed small{font-size:8px}
  body.sim-ui-ready #sim-ui .sim-gear{padding-left:9px}
  body.sim-ui-ready #sim-ui .sim-gear strong{font-size:18px}
  body.sim-ui-ready #sim-ui .sim-limit{width:28px;height:28px;font-size:13px;border-width:3px;margin-left:0}

  /* Instructor: only the current instruction, as a slim strip */
  body.sim-ui-ready #sim-ui .sim-instructor{top:calc(var(--m-t) + 48px);bottom:auto;left:var(--m-l);right:auto;width:auto;max-width:min(300px,calc(100vw - 150px));padding:7px 10px;border-radius:10px;background:#101d26b8;box-shadow:none;backdrop-filter:blur(8px)}
  body.sim-ui-ready #sim-ui .sim-instructor>.sim-eyebrow,body.sim-ui-ready #sim-ui .sim-selected-instructor,body.sim-ui-ready #sim-ui .sim-instructor h1,body.sim-ui-ready #sim-ui .sim-lesson-progress,body.sim-ui-ready #sim-ui .sim-instructor-foot{display:none}
  body.sim-ui-ready #sim-ui .sim-instructor p{font-size:11px;line-height:1.4;color:#dde6ea;margin:0}
  body.sim-ui-ready #sim-ui #sim-hint{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;overflow:hidden}
  body.sim-ui-ready #sim-ui #sim-parking-guidance{margin-top:0}
  body.sim-ui-ready #sim-ui #sim-parking-progress{margin:6px 0}

  /* Exam log: a small score chip; tap to open, tap again to close */
  body.sim-ui-ready #sim-ui .sim-feedback:not(.is-expanded){top:calc(var(--m-t) + 48px);bottom:auto;left:auto;right:var(--m-r);width:auto;max-width:none;max-height:none;border-radius:10px;border-left-width:1px;background:#3a191fd9;box-shadow:none;z-index:18}
  body.sim-ui-ready #sim-ui .sim-feedback:not(.is-expanded) .sim-feedback-header{display:flex;align-items:center;gap:6px;padding:3px 3px 3px 10px;border:0}
  body.sim-ui-ready #sim-ui .sim-feedback:not(.is-expanded) :is(.sim-eyebrow,h2,.sim-feedback-total span,#sim-feedback-status,#sim-feedback-uncertain,.sim-feedback-records,.sim-feedback-footer,.sim-feedback-error){display:none}
  body.sim-ui-ready #sim-ui .sim-feedback:not(.is-expanded) .sim-feedback-title-row{display:contents}
  body.sim-ui-ready #sim-ui .sim-feedback:not(.is-expanded) .sim-feedback-total{order:-1}
  body.sim-ui-ready #sim-ui .sim-feedback:not(.is-expanded) .sim-feedback-total strong{font-size:14px;white-space:nowrap}
  body.sim-ui-ready #sim-ui .sim-feedback .sim-feedback-expand{width:34px;height:34px;min-width:34px;min-height:34px;font-size:16px}
  body.sim-ui-ready #sim-ui .sim-feedback.is-expanded{top:calc(var(--m-t) + 48px);left:var(--m-l);right:var(--m-r);bottom:calc(var(--m-b) + var(--m-pad) + 12px);width:auto;max-width:none;max-height:none;z-index:30}
  body.sim-ui-ready #sim-ui .sim-feedback.is-expanded .sim-feedback-footer{display:block}

  /* Traffic light */
  body.sim-ui-ready #sim-ui .sim-signal-panel{top:calc(var(--m-t) + 94px);bottom:auto;left:auto;right:var(--m-r);min-width:0;max-width:none;padding:6px 9px;gap:8px;border-radius:10px;background:#0f1c25cc}
  body.sim-ui-ready #sim-ui .sim-signal-panel strong{font-size:10px}
  body.sim-ui-ready #sim-ui .sim-signal-panel small{font-size:9px}

  /* Off the road: reachable from the menu instead */
  body.sim-ui-ready #sim-ui .sim-session,body.sim-ui-ready #sim-ui .sim-waze-trigger,body.sim-ui-ready #sim-ui .sim-controls-caption{display:none}
  body.sim-ui-ready #sim-ui .sim-bottom-shade{height:120px;opacity:.55}
  body.sim-ui-ready #sim-ui .sim-map-credit{left:0;right:0;bottom:calc(1px + env(safe-area-inset-bottom,0px));text-align:center;font-size:7px;opacity:.75;white-space:nowrap;overflow:hidden}
  body.sim-ui-ready #sim-ui .sim-minimap{right:var(--m-r);bottom:calc(var(--m-b) + var(--m-pad) + 14px);width:168px;height:140px;opacity:.9}

  /* Car switches: one compact row */
  body.sim-ui-ready #sim-ui .sim-driving-actions{left:50%;right:auto;transform:translateX(-50%);bottom:calc(var(--m-b) + var(--m-pad) + 10px);gap:6px}
  body.sim-ui-ready #sim-ui .sim-drive-button{width:46px;min-width:46px;height:44px;padding:4px 2px;gap:3px;font-size:8px;border-radius:10px;background:#12222db8}
  body.sim-ui-ready #sim-ui .sim-drive-button svg{width:17px;height:17px}

  /* Driving pads: steering under the left thumb, pedals under the right */
  body.sim-ui-ready #mobileDriveControls{display:grid;left:var(--m-l);right:var(--m-r);bottom:var(--m-b);z-index:14;grid-template-columns:var(--m-pad) var(--m-pad) 1fr var(--m-pad) var(--m-pad);grid-template-rows:var(--m-pad);gap:8px;pointer-events:none;touch-action:none}
  body.sim-ui-ready #mobileDriveControls button{pointer-events:auto;touch-action:none;border-radius:16px;font-size:24px;background:#152935c7;border-color:#b5c8d655;box-shadow:0 6px 20px #0004;backdrop-filter:blur(8px)}
  body.sim-ui-ready #mobileDriveControls [data-drive]{grid-row:1}
  body.sim-ui-ready #mobileDriveControls [data-drive="left"]{grid-column:1}
  body.sim-ui-ready #mobileDriveControls [data-drive="right"]{grid-column:2}
  body.sim-ui-ready #mobileDriveControls [data-drive="backward"]{grid-column:4;border-color:#ff9e8e80}
  body.sim-ui-ready #mobileDriveControls [data-drive="forward"]{grid-column:5;border-color:#7dd4bf80}
  body.sim-ui-ready #mobileDriveControls button.active{background:#bb9e6b;color:#0c1d29;transform:scale(.96)}
  body.sim-ui-ready #mobileDriveControls [data-drive="forward"].active{background:#7dd4bf}
  body.sim-ui-ready #mobileDriveControls [data-drive="backward"].active{background:#ff9e8e}

  body.sim-ui-ready #sim-ui .sim-pause{padding:20px 24px;width:min(320px,calc(100vw - 40px))}
  body.sim-ui-ready #sim-ui .sim-pause h2{font-size:22px;margin:8px 0 14px}
}

/* Small screens: no minimap */
@media (hover:none) and (pointer:coarse) and (max-width:700px),(hover:none) and (pointer:coarse) and (max-height:700px){
  body.sim-ui-ready #sim-ui .sim-minimap{display:none}
}

/* Phone held sideways: switches sit between the pads, traffic light under the speed */
@media (hover:none) and (pointer:coarse) and (orientation:landscape) and (max-height:540px){
  body.sim-ui-ready #sim-ui .sim-driving-actions{bottom:var(--m-b);gap:5px}
  body.sim-ui-ready #sim-ui .sim-drive-button{width:44px;min-width:44px;height:42px;font-size:7.5px}
  body.sim-ui-ready #sim-ui .sim-signal-panel{top:calc(var(--m-t) + 46px);right:auto;left:50%;transform:translateX(-50%)}
  body.sim-ui-ready #sim-ui .sim-instructor{max-width:min(280px,calc(50vw - 100px))}
  body.sim-ui-ready #sim-ui .sim-feedback.is-expanded{left:auto;width:min(420px,calc(100vw - 20px))}
  body.sim-ui-ready #sim-ui .sim-bottom-shade{height:90px}
}
