/* RUNQUEST 39 · iOS / Android responsive finishing layer. No business logic here. */
:root { color-scheme:dark; }
@media (max-width:700px), (orientation:landscape) and (max-height:540px) and (pointer:coarse) {
  html,body { width:100%; max-width:100%; overflow:hidden!important; overscroll-behavior:none; }
  body { -webkit-overflow-scrolling:auto; -webkit-tap-highlight-color:transparent; }
  .app { box-sizing:border-box; height:var(--rq-shell-height,100dvh)!important; max-height:var(--rq-shell-height,100dvh); min-width:0!important; overflow:hidden!important; }
  #appBody, .view:not(.hidden) { min-width:0; min-height:0; }
  .sidebar:not(.hidden) { box-sizing:border-box; left:max(8px,env(safe-area-inset-left))!important; right:max(8px,env(safe-area-inset-right))!important; }
  .sidebar button { touch-action:manipulation; min-width:0!important; }
  .sidebar button::before { flex:0 0 auto; }
  .rq-pager button, .rq-mobile-tabs button, #questBackdrop button, .segmentActions button, .segmentActions label, .routeTools button { touch-action:manipulation; }
  #questBackdrop .questSheet { height:var(--rq-shell-height,100dvh)!important; max-height:var(--rq-shell-height,100dvh)!important; min-height:0!important; }
  #questBackdrop select, input, textarea, select { font-size:16px!important; }
  input,select,textarea { scroll-margin-bottom:95px; }
  .rq-mobile-pane,.questSheet,.authPanel,.activityDrawer { overscroll-behavior:contain; -webkit-overflow-scrolling:touch; }
  #questBackdrop .rq-map-detail { touch-action:none; overscroll-behavior:contain; }
  #questBackdrop .rq-map-controls button { width:44px!important;height:44px!important;min-width:44px!important;min-height:44px!important; }
  #questBackdrop .rq-map-segment-picker select { min-height:44px!important; font-size:16px!important; }
  #view-segments .rq-quest-card .segmentActions > * { min-height:44px!important; }
  #view-segments .questFilters button { font-size:clamp(10px,3vw,12px); }
  body.rq-keyboard .app { height:var(--rq-visual-height,100dvh)!important; max-height:var(--rq-visual-height,100dvh)!important; padding-bottom:max(5px,env(safe-area-inset-bottom))!important; }
  body.rq-keyboard .sidebar:not(.hidden) { display:none!important; }
  body.rq-keyboard .questBackdrop:not(.hidden)>.questSheet { height:var(--rq-visual-height,100dvh)!important;max-height:var(--rq-visual-height,100dvh)!important;overflow-y:auto!important; }
  body.rq-keyboard .authPanel,body.rq-keyboard #view-profile .homeLayout>.panel,body.rq-keyboard #view-friends>.panel { overflow-y:auto!important; }
  body.rq-keyboard #view-segments .rq-quest-card .segmentMap { min-height:56px; }
  :is(button,a,input,select,textarea,[role=button]):focus-visible { outline:2px solid #73c7ff;outline-offset:2px; }
  .rq-update-banner { position:fixed;z-index:190;left:12px;right:12px;bottom:calc(80px + env(safe-area-inset-bottom));display:flex;align-items:center;gap:9px;padding:10px 11px;color:#edf7ff;background:#112e52;border:1px solid #397dce;border-radius:14px;box-shadow:0 12px 28px #0008;font:700 12px/1.4 system-ui; }
  .rq-update-banner span { flex:1;min-width:0; }
  .rq-update-banner button { min-height:44px;border:0;border-radius:10px;padding:8px 12px;background:#267bff;color:#fff;font:800 12px system-ui; }
  .rq-update-banner button:last-child { flex:none;background:transparent;color:#cce8ff;padding:8px; }
}
@media (orientation:landscape) and (max-height:540px) and (pointer:coarse) {
  .app { padding-left:max(10px,env(safe-area-inset-left))!important; padding-right:max(10px,env(safe-area-inset-right))!important; }
  .sidebar:not(.hidden) { height:51px!important;--rq-nav:51px;padding:3px 5px!important; }
  .app { padding-bottom:calc(51px + env(safe-area-inset-bottom) + 9px)!important; }
  .topbar { min-height:36px!important;height:36px!important;margin-bottom:3px!important; }
  .mobileBrand img { max-height:31px!important; }
  .view:not(.hidden) { overflow-y:auto!important;scrollbar-width:none;-webkit-overflow-scrolling:touch;overscroll-behavior:contain; }
  .view:not(.hidden)::-webkit-scrollbar { display:none; }
  #view-segments #segmentsList { min-height:185px; flex:0 0 auto; }
  #view-segments #segmentsList>.rq-quest-card:not(.rq-page-off) { min-height:185px; }
  #view-segments .rq-quest-card .segmentMap { min-height:95px; }
  #view-segments .rq-quest-card .segmentBody { flex:0 0 auto; }
  .questBackdrop>.questSheet { padding-left:max(12px,env(safe-area-inset-left))!important;padding-right:max(12px,env(safe-area-inset-right))!important;overflow-y:auto!important; }
  #questBackdrop .detailMap { min-height:130px;flex:0 0 130px;max-height:130px; }
  #questBackdrop .rq-map-segment-picker select { min-height:44px; }
}
@supports (-webkit-touch-callout:none) {
  /* iOS standalone PWA may report a shortened dvh; vh keeps the bottom safe area. */
  @media (display-mode:standalone) {
    html,body { height:100vh!important; }
    .app { height:100vh!important;max-height:100vh!important; }
    #questBackdrop>.questSheet { height:100vh!important;max-height:100vh!important; }
    body.rq-keyboard .app,body.rq-keyboard #questBackdrop>.questSheet { height:var(--rq-visual-height,100dvh)!important;max-height:var(--rq-visual-height,100dvh)!important; }
  }
}
@media (prefers-reduced-motion:reduce) {
  .app *, .questBackdrop *, .sidebar * { scroll-behavior:auto!important; }
  .rq-update-banner { animation:none!important; }
}
