/* ── Responsive ──────────────────────────────────────────────────────────────── */
/* Tablets / half-screen windows (721–960px): the same two columns as a grid — the card
   on the left, the brain column (preview, coins line, missions) on the right. */
@media (max-width: 960px) and (min-width: 721px) {
  #main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
  }
  #game-col { grid-column: 1; }
  #brain-col {
    grid-column: 2;
    min-width: 0;
    padding: 12px 14px;
  }
  #topbar { padding: 8px 14px; }
  #tb-logo { width: 40px; height: 40px; }
}

@media (max-width: 720px) {
  html { height: auto; }
  body { height: auto; min-height: 100vh; overflow-y: auto; overflow-x: hidden; }
  #app { height: auto; min-height: 100vh; }
  #main { flex: none; flex-direction: column; overflow: visible; min-height: 0; }
  #game-col { overflow-y: visible; padding: 20px 16px; }
  /* Stacked: the card, then the brain (preview, coins line), then the missions. */
  #brain-col {
    flex: none;
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--line);
  }
  #brain-preview-btn { max-width: 300px; margin: 0 auto; }

  /* Top bar: ONE row of 44 px targets down to 320 px; the focus chip takes the free width and
     ellipsises, 📊 and ⚙️ shrink to icon-only squares (they keep their aria-label). */
  #topbar { gap: 4px; padding: 6px 6px; min-height: 0; }
  #tb-logo { width: 30px; height: 30px; margin-right: 0; }
  #tb-auth { margin-left: 0; }
  .tb-auth-btn { padding: 5px 8px; font-size: 12px; }
  .tb-account { max-width: 90px; }

  /* Stacked layout: the brain and missions sit BELOW the card — hold roughly a card's
     height while loading so they don't jump down when it appears (CLS). */
  #loading-msg { min-height: 380px; box-sizing: border-box; }

  #topbar .mb-btn { min-height: 44px; padding: 5px 10px; flex: none; }
  #topbar .mb-focus { flex: 1 1 0; min-width: 44px; display: flex; align-items: center; gap: 4px; }
  #mb-focus-label { flex: 0 1 auto; min-width: 0; white-space: nowrap; }
  #topbar .mb-label { display: none; }
  #topbar #stats-btn, #topbar #settings-btn { min-width: 44px; padding: 5px 0; font-size: 16px; }
  /* The ⚙️ wrap no longer pushes the right-hand items: the focus chip already fills the row. */
  .settings-wrap { margin-right: 0; }
  /* ≥ 12px on phones (legibility; Lighthouse 'font-size'). */
  .q-prompt { font-size: 12px; }
  .q-text { font-size: 21px; }
  #card { padding: 20px; max-width: none; }
  #combo-widget { padding: 4px 7px; gap: 3px; flex: none; }
  #combo-widget .c-n { font-size: 14px; }
  #combo-widget .c-mult { font-size: 15px; }
  /* the wrong-run note stays visible on touch (no hover), as two small lines */
  #combo-widget .c-word { font-size: 9px; line-height: 1.05; white-space: normal; max-width: 58px; }
}


/* Touch targets: every control on a phone is at least 44×44 px (UX plan §6). */
@media (max-width: 720px) {
  .rule-btn { min-width: 44px; min-height: 44px; margin-bottom: 8px; padding: 0 10px; }
  .btn-primary, .btn-skip, .btn-link, .btn-secondary, .accent-toggle { min-height: 44px; }
  .ms-skip { min-height: 44px; min-width: 44px; }
  .modal-close { min-width: 44px; min-height: 44px; }
}
