/* Phase-one interaction cleanup: one overlay owner at a time and protected map lanes. */

html body .memory-editor.open,
html body .memory-database-page.side-panel,
html body .account-menu.open,
html body .notification-hub.open,
html body .pin-search-panel.open {
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 720px), (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  /* The first-memory invitation and map gadget share one row without touching. */
  html body main.app-shell section.map-stage.map-focus .map-empty-state.is-visible,
  html body .app-shell section.map-stage.map-focus .map-empty-state.is-visible {
    position: absolute !important;
    right: calc(max(14px, env(safe-area-inset-right)) + 102px) !important;
    bottom: calc(78px + env(safe-area-inset-bottom) + 20px) !important;
    left: max(14px, env(safe-area-inset-left)) !important;
    display: grid !important;
    grid-template-columns: 40px minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    grid-template-areas:
      "mascot title"
      "mascot copy" !important;
    align-items: center !important;
    box-sizing: border-box !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 92px !important;
    max-height: 92px !important;
    margin: 0 !important;
    padding: 10px 11px !important;
    gap: 3px 8px !important;
    border-radius: 22px !important;
    text-align: left !important;
    transform: none !important;
  }

  html body main.app-shell section.map-stage.map-focus .map-empty-state.is-visible img,
  html body .app-shell section.map-stage.map-focus .map-empty-state.is-visible img {
    grid-area: mascot !important;
    align-self: center !important;
    justify-self: center !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    margin: 0 !important;
    object-fit: contain !important;
  }

  html body main.app-shell section.map-stage.map-focus .map-empty-state.is-visible strong,
  html body .app-shell section.map-stage.map-focus .map-empty-state.is-visible strong {
    grid-area: title !important;
    align-self: end !important;
    justify-self: stretch !important;
    min-width: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    font-size: 0.76rem !important;
    line-height: 1.12 !important;
    text-align: left !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  html body main.app-shell section.map-stage.map-focus .map-empty-state.is-visible span,
  html body .app-shell section.map-stage.map-focus .map-empty-state.is-visible span {
    grid-area: copy !important;
    align-self: start !important;
    justify-self: stretch !important;
    display: -webkit-box !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    overflow: hidden !important;
    font-size: 0.64rem !important;
    line-height: 1.24 !important;
    text-align: left !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
  }

  html body main.app-shell section.map-stage.map-focus .map-empty-state.is-visible::after,
  html body .app-shell section.map-stage.map-focus .map-empty-state.is-visible::after {
    right: auto !important;
    bottom: -7px !important;
    left: 70% !important;
    transform: translateX(-50%) rotate(45deg) !important;
  }

  html body:has(.map-empty-state.is-visible) main.app-shell section.map-stage.map-focus .map-navigation-gadget,
  html body:has(.map-empty-state.is-visible) .app-shell section.map-stage.map-focus .map-navigation-gadget {
    right: max(14px, env(safe-area-inset-right)) !important;
    bottom: calc(78px + env(safe-area-inset-bottom) + 20px) !important;
  }
}

@media (max-width: 350px) {
  html body main.app-shell section.map-stage.map-focus .map-empty-state.is-visible,
  html body .app-shell section.map-stage.map-focus .map-empty-state.is-visible {
    right: calc(max(12px, env(safe-area-inset-right)) + 98px) !important;
    left: max(12px, env(safe-area-inset-left)) !important;
    grid-template-columns: 36px minmax(0, 1fr) !important;
    min-height: 94px !important;
    max-height: 94px !important;
    padding-inline: 9px !important;
    gap: 3px 7px !important;
  }

  html body main.app-shell section.map-stage.map-focus .map-empty-state.is-visible img,
  html body .app-shell section.map-stage.map-focus .map-empty-state.is-visible img {
    width: 36px !important;
    min-width: 36px !important;
    max-width: 36px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html body .memory-editor,
  html body .memory-database-page.side-panel,
  html body .account-menu,
  html body .notification-hub,
  html body .pin-search-panel,
  html body .map-empty-state {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
