/* Compact controls on narrow or short screens retain target sizes and behavior. */
#mobileRideOptions{margin:0 0 20px;padding-bottom:18px;border-bottom:1px solid var(--line)}
#mobileRideOptions h3{font-size:16px;margin:0 0 12px}
.mobile-ride-settings{display:grid;grid-template-columns:1fr;gap:14px;margin-bottom:14px}
.mobile-ride-settings select{width:100%;min-height:44px;font-size:14px}
.mobile-ride-settings .effort{display:flex;gap:12px;font-size:12px}
.mobile-ride-settings input{flex:1;min-width:0;min-height:44px}
.mobile-ride-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.mobile-ride-actions button{min-height:44px;font-size:13px}
@media(max-width:1100px), (max-height:760px){
 #guestPanel.mobile-compact{grid-template-columns:64px minmax(0,1fr) auto;grid-template-areas:"speed modes modes" "steer actions pedals";gap:12px;align-items:end}
 #guestPanel.mobile-compact .ride-control{display:flex;flex-direction:column;max-width:none;width:100%;gap:6px}
 #guestPanel.mobile-compact .ride-control>label{width:100%}
 #guestPanel.mobile-compact #controlMode{min-height:44px;font-size:12px;letter-spacing:0;width:100%;padding:8px 10px}
 #guestPanel.mobile-compact #movementStatus[data-routine="true"]{display:none}
 #guestPanel.mobile-compact .ride-buttons{display:grid;grid-template-columns:1fr;max-width:none;width:100%;gap:6px;align-self:end}
 #guestPanel.mobile-compact .ride-buttons button{min-height:44px;padding:6px;font-size:11px}
 #guestPanel.mobile-compact .host-locator{background:#14262be8;border-radius:8px;padding:7px 9px}
 #guestPanel.mobile-compact #joystick{align-self:end}
}
@media(max-height:500px) and (min-width:521px) and (max-width:1100px){
 #guestPanel.mobile-compact{left:16px;right:16px;bottom:20px;grid-template-columns:44px minmax(170px,320px) minmax(0,1fr) 64px auto 84px;grid-template-areas:"speed modes gap steer pedals actions";gap:10px}
 #guestPanel.mobile-compact .ride-buttons{width:84px}
 #guestPanel.mobile-compact .ride-control{align-self:end}
 #guestPanel.mobile-compact .host-locator small{display:block;margin:2px 0 0}
 #guestPanel.mobile-compact .speedometer{align-self:end}
 body:has(#guestPanel.mobile-compact) .ride-top{top:72px;left:16px;right:16px;align-items:center;gap:8px}
 body:has(#guestPanel.mobile-compact) #ridePresence{margin:0;padding:0}
 body:has(#guestPanel.mobile-compact) #guestConversation{flex-basis:auto;width:auto;max-width:none;margin:0}
}
@media(max-width:360px){
 #guestPanel.mobile-compact{grid-template-columns:58px minmax(0,1fr) auto;gap:9px}
 #guestPanel.mobile-compact .ride-buttons button{font-size:10px}
 /* The distance and the one driving-mode action share the top row on
    very narrow phones. Stacking them costs an entire lane of road. */
 #guestPanel.mobile-compact .host-locator:has([data-host-catchup]:not([hidden])){
  position:relative;display:grid;grid-template-columns:minmax(0,1fr) 104px;
  align-items:center;gap:6px;padding:6px 7px;min-width:0;
 }
 #guestPanel.mobile-compact .host-locator:has([data-host-catchup]:not([hidden])) > [data-host-arrow]{
  position:absolute;left:8px;top:50%;transform:translateY(-50%);width:14px;
 }
 #guestPanel.mobile-compact .host-locator:has([data-host-catchup]:not([hidden])) > span:not([data-host-arrow]){
  min-width:0;padding-left:17px;overflow-wrap:anywhere;
 }
 #guestPanel.mobile-compact .host-locator:has([data-host-catchup]:not([hidden])) [data-host-catchup]{
  display:block;grid-column:2;grid-row:1;min-width:0;width:100%;flex:none;
  min-height:44px;font-size:10px;line-height:1.2;padding:6px 5px;
 }
}

/* One help surface stays with the rider rather than disappearing into Setup. */
@media(max-width:1100px), (max-height:760px){
 #guestPanel.mobile-compact > .ride-control-guidance{position:absolute;left:0;bottom:calc(100% + 12px);z-index:2;display:flex;max-width:min(100%,calc(100vw - 24px))}
 #guestPanel.mobile-compact > .ride-control-guidance .ride-control-help summary{min-height:44px;padding:12px 14px;font-size:13px}
 #guestPanel.mobile-compact > .ride-control-guidance .ride-control-cue{display:none}
 #guestPanel.mobile-compact > .ride-control-guidance .ride-control-instructions{position:absolute;bottom:calc(100% + 8px);left:0;width:min(370px,calc(100vw - 32px));max-height:min(51vh,440px,calc(100dvh - 380px));overflow:auto}
}
/* A short desktop window needs compact controls, not full-width control bars. */
@media(min-width:1101px) and (max-height:760px){
 #guestPanel.mobile-compact{max-width:760px;margin-left:auto;margin-right:0}
}

/* Keep host actions readable as a second row instead of squeezing five across. */
@media(max-width:600px) and (min-height:501px){
 #hostHud .host-session-controls{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
 #hostHud .host-session-controls button{min-height:44px;font-size:11px;padding:8px;white-space:normal}
 #hostHud .recording-controls{min-width:0;flex-wrap:wrap}
 #hostHud .recording-controls button{flex:1;width:100%}
}

/* Recorded photographs have no navigable rider world. Conversation stays separate. */
#guestPanel.ride-hud[data-measured-capture="true"],
body:has(#guestPanel[data-measured-capture="true"]) #mobileRideOptions,
body:has(#guestPanel[data-measured-capture="true"]) #guestRideUnits{display:none}

/* The rider's secondary labels need to survive full-screen scenery and phone glass. */
body:not(.guest-host-main):has(#guestPanel:not([hidden])) .ride-top > span:not([hidden]) {
 font-size:10px;letter-spacing:.1px;line-height:1.35;color:#edf7f0;
}
body:not(.guest-host-main) #guestPanel .speedometer span {font-size:11px;letter-spacing:.1px;line-height:1.3}
body:not(.guest-host-main) #guestPanel .speedometer small {font-size:11px;letter-spacing:0;line-height:1.3}
body:not(.guest-host-main) #guestPanel .steer-label {font-size:11px;letter-spacing:0;bottom:-19px}
body:not(.guest-host-main) #guestPanel .pedal small,body:not(.guest-host-main) #guestPanel .ride-brake small {font-size:10px;opacity:1;line-height:1.1}
@media(max-width:520px){
 body:not(.guest-host-main) #guestPanel .speedometer span,body:not(.guest-host-main) #guestPanel .speedometer small{font-size:10px}
 body:not(.guest-host-main):has(#guestPanel:not([hidden])) .ride-top > span:not([hidden]){font-size:9.5px;letter-spacing:0}
}
/* On short screens the original waiting card crossed the active steering,
   pedal and chat targets. Give it the open strip between voice and movement. */
@media(max-width:520px) and (max-height:650px){
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting{
  left:12px;right:12px;width:auto;top:calc(100dvh - 249px);transform:none;
  padding:5px 9px;border-radius:12px;display:flex;gap:7px;
  align-items:center;justify-content:space-between;text-align:left
 }
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting h2{
  min-width:0;flex:1;font-size:12px;line-height:1.2;letter-spacing:0;margin:0
 }
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting button{
  flex:none;min-height:40px;font-size:11px;padding:6px 9px;margin:0;white-space:nowrap
 }
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting .eyebrow,
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting>p{display:none}
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) .ride-chat{
  top:118px;bottom:auto;right:12px
 }
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #guestPanel>.ride-control-guidance{
  display:none
 }
}
@media(max-width:520px) and (max-height:540px){
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #guestPanel{display:none!important}
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting{top:auto;bottom:14px}
}
@media(min-width:521px) and (max-width:1100px) and (max-height:500px){
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting{
  top:calc(100dvh - 184px);transform:translateX(-50%);width:min(70vw,430px);
  padding:6px 11px;border-radius:12px;display:flex;gap:10px;
  align-items:center;justify-content:space-between;text-align:left
 }
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting h2{
  min-width:0;flex:1;font-size:14px;line-height:1.25;letter-spacing:0;margin:0
 }
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting button{
  flex:none;min-height:40px;font-size:11px;margin:0
 }
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting .eyebrow,
 body:not(.guest-host-main):has(#guestPanel:not([hidden])):has(#routeWaiting:not([hidden])) #routeWaiting>p{display:none}
}

/* --- Mobile & landscape HUD contrast + zero-overlap clearance --- */
@media (max-width: 760px) {
  body:has(.vehicle-strip:not([hidden])) #guestPanel.mobile-compact > .ride-control-guidance {
    left: 120px;
    max-width: calc(100% - 196px);
  }
}
@media (max-width: 380px) {
  body:has(.vehicle-strip:not([hidden])) #guestPanel.mobile-compact > .ride-control-guidance {
    left: 102px;
    bottom: calc(100% + 10px);
    max-width: calc(100% - 168px);
  }
  #guestPanel.mobile-compact > .ride-control-guidance .ride-control-help summary {
    min-height: 40px;
    padding: 8px 9px;
    font-size: 11.5px;
    white-space: nowrap;
  }
}
@media (max-width: 520px) and (max-height: 620px) {
  #guestPanel.mobile-compact {
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    padding: 8px 10px;
    gap: 6px 8px;
  }
  #guestPanel.mobile-compact #joystick {
    width: 52px;
    height: 52px;
  }
  #guestPanel.mobile-compact #stick {
    width: 22px;
    height: 22px;
    left: 14px;
    top: 14px;
  }
  #guestPanel.mobile-compact .pedal {
    width: 72px;
    height: 48px;
    font-size: 11px;
  }
  #guestPanel.mobile-compact .ride-brake {
    min-width: 58px;
    min-height: 46px;
    padding: 6px;
    font-size: 11px;
  }
  #guestPanel.mobile-compact .ride-buttons button {
    min-height: 38px;
    padding: 5px;
  }
  body:not(.guest-host-main):has(#guestPanel:not([hidden])) #guestConversation:not([hidden]) .host-conversation-buttons button {
    min-height: 40px;
    padding: 6px 5px;
  }
}
@media (max-width: 520px) {
  body:not(:has(#lobby:not([hidden]))):not(.page-viewer) .ride-top {
    top: calc(68px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    max-width: none;
  }
  #guestPanel.mobile-compact .speedometer,
  #guestPanel.mobile-compact .ride-control {
    background: rgba(14, 20, 28, 0.86);
    border: 1px solid rgba(186, 230, 220, 0.34);
    border-radius: 12px;
    padding: 6px 10px;
    color: #f8fafc;
    text-shadow: none;
  }
  #guestPanel.mobile-compact .speedometer span,
  #guestPanel.mobile-compact .speedometer small,
  #guestPanel.mobile-compact .ride-control > span {
    color: #e2e8f0;
  }
}
@media (min-width: 521px) and (max-width: 1100px) and (max-height: 500px) {
  #guestPanel .speedometer,
  #guestPanel .ride-control {
    background: rgba(14, 20, 28, 0.86);
    border: 1px solid rgba(186, 230, 220, 0.34);
    border-radius: 12px;
    padding: 6px 10px;
    color: #f8fafc;
    text-shadow: none;
  }
  #guestPanel .speedometer span,
  #guestPanel .speedometer small,
  #guestPanel .ride-control > span {
    color: #e2e8f0;
  }
  body:not(.guest-host-main):has(#rideChatPanel:not([hidden])) #guestPanel {
    left: calc(12px + env(safe-area-inset-left, 0px));
    right: calc(360px + env(safe-area-inset-right, 0px));
    max-width: none;
    margin: 0;
    padding: 8px 10px;
    gap: 6px;
    grid-template-columns: 44px minmax(0, 1fr) 52px auto 68px;
    grid-template-areas: "speed modes steer pedals actions";
  }
  body:not(.guest-host-main):has(#rideChatPanel:not([hidden])) #guestPanel #joystick {
    width: 50px;
    height: 50px;
  }
  body:not(.guest-host-main):has(#rideChatPanel:not([hidden])) #guestPanel #stick {
    width: 22px;
    height: 22px;
    left: 13px;
    top: 13px;
  }
  body:not(.guest-host-main):has(#rideChatPanel:not([hidden])) #guestPanel .pedal {
    width: 62px;
    height: 48px;
    font-size: 10px;
  }
  body:not(.guest-host-main):has(#rideChatPanel:not([hidden])) #guestPanel .ride-brake {
    min-width: 50px;
    min-height: 46px;
    padding: 5px;
    font-size: 10px;
  }
  body:not(.guest-host-main):has(#rideChatPanel:not([hidden])) #guestPanel .ride-buttons {
    width: 68px;
  }
}

@media (max-height: 500px) {
  body:has(#rideChatPanel:not([hidden])) #guestPanel > .ride-control-guidance {
    display: none !important;
  }
}
