/* QuestPick 4.2.3: iPhone keyboard / numeric input layout stability.
   The keyboard must not trigger Safari's automatic page zoom.
   Do not disable pinch-to-zoom or lock the page scale. */
@media (max-width: 740px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  /* iOS zooms the entire page when a focused editable control has text <16px.
     Include every input, not only game editor dialogs (daily minutes live inline). */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="hidden"]),
  textarea, select,
  .pn-hall-search input,
  .search, .searchbox input,
  #session-minutes, #pn4-session-form input,
  #pn4-checkpoint-form textarea,
  #pn4-vault-game-search,
  #pn-hall-search {
    font-size: 16px !important;
    line-height: 1.35;
    min-width: 0;
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
  }
  input[type="number"] { font-variant-numeric: tabular-nums; }
  /* Daily session controls: no competing inline button when the keyboard appears.
     Keep this layout identical before and during focus. */
  .toolbar:has(#session-minutes) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 10px;
  }
  .toolbar:has(#session-minutes) > label,
  .toolbar:has(#session-minutes) > .btn { width: 100%; min-width: 0 !important; }
  .toolbar:has(#session-minutes) > .btn { justify-self: stretch; }
  #pn4-session-form, #pn4-session-form label.field,
  .pn4-journeygrid > .panel, #pn4-checkpoint-form,
  .main, #app { min-width: 0; max-width: 100%; }
  .pn4-journeygrid input[type="number"] { min-height: 49px; }
  /* Work with the previous trophy.js focus flag even if VisualViewport events
     arrive later than focusin (iOS native keyboard animation). */
  body.pn-input-focused .bottomnav,
  html.pn-keyboard-visible .bottomnav { display: none !important; }
  /* Input toolbar and form buttons stay within their panels on narrow iPhones. */
  .pn4-journeygrid form .btn, .pn4-noteform .btn { max-width: 100%; }
  /* The modal is scrollable INSIDE the remaining visual viewport.  No viewport
     width scaling and no transform on the dialog itself. */
  html.pn-keyboard-visible #modal[open] {
    max-height: max(170px, calc(var(--pn-vv-height, 100dvh) - env(safe-area-inset-top) - 18px)) !important;
    overscroll-behavior: contain;
  }
}
