/* Keep tablet and phone controls inside their cards and comfortable to tap. */
@media (max-width: 1000px) {
  .division-board > .division-column:nth-child(n) .court-picker-menu {
    left: 8px;
    right: 8px;
    top: 100%;
    width: auto;
    max-width: none;
    transform: none;
    margin-top: 6px;
  }
}

@media (max-width: 950px) {
  .roster-card { height: auto; }
  .group-edit-row > * { min-width: 0; }
  .group-edit-row strong, .group-edit-row small { overflow-wrap: anywhere; }
}

@media (max-width: 650px) {
  .header-inner { gap: 10px; }
  .top-nav { min-height: 44px; height: auto; }
  .top-nav-button { min-width: 0; min-height: 44px; padding: 0 5px; font-size: 13px; white-space: nowrap; }
  .header-button, .text-button, .icon-button, .roster-tabs button,
  .roster-team-actions button, .team-management-actions button { min-height: 44px; }
  .icon-button { min-width: 44px; }
  .roster-team-actions { gap: 10px; }
  .roster-team-actions button { min-width: 60px; padding: 8px; }
  .roster-card-head, .roster-column-labels { flex-shrink: 0; }
  .roster-column-labels { gap: 5px; font-size: 9px; }
  .roster-row { grid-template-columns: 32px minmax(0, 1fr) 48px; }
  .roster-column-labels { grid-template-columns: 32px minmax(0, 1fr) 48px; }
  .team-record { white-space: nowrap; }
  .contact-section input, .contact-section textarea, .manual-editor-fields select,
  .upcoming-editor select { font-size: 16px; }
  .site-footer > .container { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  .simulation-panel, .simulation-actions { min-width: 0; }
  .simulation-actions { flex: 1 1 100%; flex-wrap: wrap; gap: 12px; }
  .simulation-actions label { min-height: 44px; }
  .simulation-actions button, .admin-toolbar .button { min-height: 44px; }
  .match-list-tabs { gap: 12px; }
  .match-list-tabs button { min-width: 0; min-height: 44px; gap: 5px; font-size: clamp(14px, 4.1vw, 17px); }
  .match-list-tabs button span { padding: 3px 5px; }
  .division-courts { gap: 14px 10px; }
  .court-tile { padding: 10px 7px; }
  .court-tile-head strong { font-size: 14px; }
  .court-tile-head > span { font-size: 8px; letter-spacing: .5px; }
  .court-score-inputs { width: 48px; gap: 6px; }
  .court-score-inputs input { height: 40px; min-height: 40px; }
  .court-score-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 4px; }
  .court-score-footer .court-group { font-size: 11px; white-space: nowrap; }
  .court-score-footer .court-match-clock { min-width: 0; font-size: 12px; text-align: right; }
  .court-score-footer .button { grid-column: 1 / -1; min-height: 44px; font-size: 12px; }
  .court-manual-toggle { min-height: 44px; font-size: 11px; }
  .vacant .court-group { min-height: 74px; padding: 9px 0 0; }
  .court-controls-placeholder { min-height: 44px; }
  .court-picker summary, .upcoming-actions .manual-edit-toggle { min-height: 44px; }
  .court-picker-options { gap: 4px; }
  .court-picker-menu { padding: 8px; }
  .court-choice { min-height: 52px; padding: 7px 1px; }
  .court-choice small { font-size: 8px; }
  .upcoming-status-row { flex-wrap: wrap; }
  .staging-callout { min-width: 140px; }
  .manual-editor-actions { flex-wrap: wrap; gap: 10px; }
  .compact-results .match-entry { padding: 10px; }
  .compact-results .match-pair { gap: 5px; }
  .compact-results .inline-score-team { grid-template-columns: minmax(0, 1fr) 44px; gap: 6px; padding: 7px; }
  .compact-results .inline-team-copy { display: contents; }
  .compact-results .inline-team-copy h3 { grid-column: 1 / -1; display: block; font-size: 12px; line-height: 1.4; margin: 0; }
  .compact-results .team-match-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 3px 6px; font-size: 10px; min-width: 0; white-space: normal; }
  .compact-results .team-match-meta span { white-space: normal; overflow-wrap: anywhere; }
  .compact-results .team-match-meta strong { font-size: 12px; }
  .compact-results .inline-score-field { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 5px; font-size: 10px; }
  .compact-results .inline-score-field input { width: 48px; font-size: 18px; min-height: 44px; }
  .compact-results .match-row-actions { grid-template-columns: minmax(112px, auto); }
  .compact-results .match-row-actions .button { min-height: 44px; font-size: 12px; }
  .compact-results .match-versus { font-size: 10px; }
  dialog { max-height: calc(100dvh - 24px); }
  .two-col { grid-template-columns: 1fr; }
  body:has(dialog[open]) #coach-tommy-chat { display: none; }
  .toast { bottom: 78px; width: max-content; }
}

@media (max-width: 359px) {
  .division-courts .court-floor { aspect-ratio: 1 / 2.4; }
  .court-score-form .court-player { font-size: 11px; left: 6%; right: 6%; }
  .court-player > span { -webkit-line-clamp: 4; }
  .upcoming-heading { flex-wrap: wrap; }
  .court-warmup { width: 68px; }
  .court-warmup strong { font-size: 19px; }
}
