/**
 * Global mobile layout fixes (home + any page that links this sheet).
 * Loaded in <head> so it applies with critical CSS, before deferred bundles.
 */

@media (max-width: 720px) {
  html {
    overflow-x: clip;
  }

  body {
    overflow-x: clip;
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }

  .site-shell {
    width: 100%;
    max-width: 100%;
    padding-inline: clamp(8px, 3.2vw, 16px);
    box-sizing: border-box;
  }

  main,
  main > section,
  .hero,
  .hero-copy,
  .hero-panel,
  .feature-grid,
  .project-grid,
  .footer-inner {
    min-width: 0;
  }

  ins.adsbygoogle {
    display: block !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  ins.adsbygoogle iframe {
    max-width: 100% !important;
  }

  video {
    max-width: 100%;
    height: auto;
  }

  .king-analysis-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .king-chart-row {
    grid-template-columns: minmax(72px, auto) minmax(0, 1fr);
    gap: 6px;
  }

  .king-filter-search {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .king-confidence-select {
    max-width: 100%;
    min-width: 0 !important;
  }

  .king-filter-field--search {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .signal-row,
  .console-line {
    flex-wrap: wrap;
    gap: 8px;
  }

  .signal-value {
    min-width: 0;
    text-align: inherit;
  }

  .modal {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-panel {
    width: 100%;
    max-width: 100%;
    max-height: min(92dvh, 100%);
    border-radius: var(--radius-sm, 18px) var(--radius-sm, 18px) 0 0;
  }

  .modal-inner {
    max-height: min(78dvh, 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  pre,
  code {
    max-width: 100%;
    overflow-x: auto;
    word-break: break-word;
  }
}

@media (max-width: 400px) {
  .nav-link {
    padding: 9px 11px;
    font-size: 0.68rem;
  }

  .back-to-top {
    width: 48px;
    height: 48px;
    inset-inline-end: max(12px, env(safe-area-inset-right, 0));
    bottom: max(12px, env(safe-area-inset-bottom, 0));
  }
}
