/* GOVN touch-friendly enhancements. Scoped to narrow viewports; games retain their own controls. */
@media (max-width: 820px) {
  html { -webkit-text-size-adjust:100%; }
  body { min-width:0; }
  a, button, select, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
  img, video { max-width:100%; }
  .app, .app .main, .app .content, .app .card, .app #view-root { min-width:0; max-width:100%; }
  .app .main { padding-bottom:calc(83px + env(safe-area-inset-bottom, 0px)); }
  .app .mobile-bar {
    padding-left:max(12px, env(safe-area-inset-left, 12px));
    padding-right:max(12px, env(safe-area-inset-right, 12px));
    gap:9px;
  }
  .app .mobile-brand { min-width:0; white-space:normal; line-height:1.15; }
  .app .topbar {
    height:auto; min-height:0; padding:10px 14px 12px;
    display:flex; flex-direction:column; align-items:stretch; gap:9px;
  }
  .app .topbar .breadcrumb { gap:6px; min-height:18px; font-size:11px; }
  .app .topbar .top-actions { display:flex; flex-wrap:wrap; align-items:center; gap:7px; min-width:0; }
  .app .top-actions #auth-button { min-height:44px; flex:1 1 130px; white-space:normal; font-size:12px!important; }
  .app .top-actions #sync-indicator { flex:0 1 auto; max-width:100%; overflow:hidden; text-overflow:ellipsis; }
  .app .top-actions button:not(#auth-button) { min-height:42px; }
  .app .content { padding:16px 12px 22px; }
  .app .card, .app .card-pad { min-width:0; }
  .app .card-pad { padding:16px; }
  .app .button-row { gap:8px; }
  .app .button-row .button { min-height:44px; white-space:normal; }
  .app .table-wrap, .app .table-scroll, .app .s3-board-wrap {
    overflow-x:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch;
  }
  .app #ktwr-hub-iframe, .app #arcade-iframe { width:100%; max-width:100%; border:0; }
  .app dialog {
    width:calc(100vw - 18px); max-width:540px;
    max-height:calc(100dvh - 16px); overscroll-behavior:contain;
    margin:auto; border-radius:14px;
  }
  .app dialog .modal-inner { padding:17px 16px; }
  .app dialog input, .app dialog select, .app dialog textarea { font-size:16px!important; max-width:100%; }
  .app dialog .modal-actions { gap:8px; flex-wrap:wrap; }
  .app dialog .modal-actions button, .app dialog .modal-close { min-height:44px; }
  .app .sidebar { max-height:100dvh; padding-bottom:max(18px, env(safe-area-inset-bottom, 18px)); }
  .app .nav button, .app .nav a { min-height:44px; }
  .app .govn-main-hero, .app .govn-hub-banner { max-width:100%; }
  #govn-mobile-dock {
    position:fixed; z-index:45; bottom:0; left:0; right:0;
    display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:3px;
    min-height:66px; padding:5px max(6px, env(safe-area-inset-right, 6px))
      max(6px, env(safe-area-inset-bottom, 6px))
      max(6px, env(safe-area-inset-left, 6px));
    border-top:1px solid #8b683c;
    background:#111519f5; -webkit-backdrop-filter:blur(14px); backdrop-filter:blur(14px);
    box-shadow:0 -7px 26px #0008;
  }
  #govn-mobile-dock a, #govn-mobile-dock button {
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:1px; min-width:0; min-height:53px; padding:4px 1px; border:1px solid transparent;
    border-radius:10px; background:transparent; color:#e9d5ae; text-decoration:none;
    font:800 10px/1.15 Inter,system-ui,sans-serif; text-align:center;
  }
  #govn-mobile-dock a:focus-visible, #govn-mobile-dock button:focus-visible,
  #govn-mobile-dock a:hover, #govn-mobile-dock button:hover {
    border-color:#b28a53; background:#46351f;
  }
  #govn-mobile-dock .govn-dock-icon { display:block; font-size:21px; line-height:1.15; }
  #govn-mobile-dock a[aria-current="page"] { color:#ffdfa0; background:#3e301d; }
  /* Keep the pop-up and the mobile menu above the quick bar when opened. */
  .app .sidebar { z-index:50; }
  .app .sidebar-overlay { z-index:49; }
  .hub-shell { width:100%; max-width:100%; padding:0 12px 18px; }
  .hub-header { align-items:flex-start; flex-wrap:wrap; gap:10px; padding:14px 0; }
  .hub-brand { min-width:0; gap:10px; }
  .hub-brand h1 { overflow-wrap:anywhere; font-size:clamp(18px,4vw,26px); }
  .hub-brand .hub-crest { width:48px; height:52px; flex:none; }
  .hub-header-tools { gap:8px; min-width:0; flex-wrap:wrap; }
  .hub-tabs { display:flex; gap:8px; overflow-x:auto; max-width:100%; scroll-snap-type:x proximity; -webkit-overflow-scrolling:touch; }
  .hub-tabs button, .hub-tabs a.govn-hub-interview-nav {
    min-height:45px; scroll-snap-align:start; flex:0 0 auto; padding:10px 13px; white-space:nowrap;
  }
  .topline { gap:12px; }
  .topline .toolbar { min-width:0; }
  .topline .home-link, .topline .locale-label { min-height:44px; display:inline-flex; align-items:center; }
  .topline .locale-label select { min-height:34px; font-size:16px; }
  .arcade-app .arcade-masthead { flex-wrap:wrap; gap:10px; padding:12px 0; }
  .arcade-app .arcade-masthead .back-link { min-height:44px; display:inline-flex; align-items:center; }
  .arcade-app .arcade-masthead .brand-title { min-width:130px; }
  .arcade-app .intro { min-width:0; }
  /* One-tap RSVP stays large and prevents Safari keyboard zoom. */
  #mission-root .rsvp-actions .rsvp { min-height:108px; }
  #mission-root input, #mission-root select, #mission-root textarea { font-size:16px; }
  #mission-root .members { -webkit-overflow-scrolling:touch; }
  #mission-root .member-actions { flex-wrap:wrap; justify-content:flex-end; }
  #mission-root .member-actions button { min-width:38px; min-height:42px; }
  #login-dialog, #edit-dialog { width:calc(100vw - 18px); max-height:calc(100dvh - 16px); }
  #login-dialog input, #edit-dialog input, #edit-dialog select, #edit-dialog textarea { font-size:16px; }
  #login-dialog .primary, #edit-dialog .primary { min-height:48px; }
}
@media (max-width: 480px) {
  .app .top-actions .ktwr-visitor-pill { display:none!important; }
  .app .top-actions .region-badge { display:none!important; }
  .app .top-actions .button.gold { font-size:12px!important; min-width:42px; }
  .app .top-actions [data-action="add-member"] { font-size:0!important; }
  .app .top-actions [data-action="add-member"] #top-plus { font-size:15px; }
  .app .top-actions [data-action="export"] { padding:10px; }
  .app .content { padding:14px 9px 18px; }
  .app .mobile-brand { font-size:12px!important; letter-spacing:.03em; }
  .hub-shell { padding:0 9px 16px; }
  .hub-header-tools { width:100%; justify-content:space-between; }
  .hub-header-tools #hub-status { flex:1; min-width:0; font-size:11px; }
  .topline .toolbar { width:100%; justify-content:space-between; }
  #mission-root .member-item .member-name { flex:1 1 140px; }
  #mission-root .member-actions { width:100%; }
}
@media (min-width:821px) {
  #govn-mobile-dock { display:none!important; }
}
@media (prefers-reduced-motion:reduce) {
  #govn-mobile-dock * { transition:none!important; }
}

/*
 * iOS Home Screen app status-bar clearance.
 * iOS 26 may report safe-area-inset-top = 0 even while the clock overlays
 * a black-translucent PWA. The 62px floor keeps touch targets below the clock.
 * Scope to installed iOS WebKit only; regular Safari and Android stay unchanged.
 * The existing govn-pwa.js toggles the govn-app-installed root class.
 */
@media screen and (max-width:820px) {
  @supports (-webkit-touch-callout: none) {
    html.govn-app-installed body {
      padding-top:max(62px, env(safe-area-inset-top, 0px))!important;
    }
    html.govn-app-installed .app .sidebar {
      padding-top:max(62px, env(safe-area-inset-top, 0px))!important;
      max-height:100dvh;
      overflow-y:auto;
      -webkit-overflow-scrolling:touch;
    }
    html.govn-app-installed .app .mobile-bar {
      position:relative;
      z-index:1;
    }
  }
}
