/* Content stays complete; wide datasets scroll inside their own region. */
.team-roster-context {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.team-roster-context strong { min-width: 0; overflow-wrap: anywhere; }
.team-roster-context button { min-height: 44px; }
.team-roster-scroll-hint { display: none; }
.team-inline-detail-deck-filter-label { display: none; }
.team-inline-detail-deck-card-date { display: none; font-size: 0.75rem; color: var(--muted); }
.team-inline-detail-deck-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skill-chip[role="button"] { cursor: pointer; }
.skill-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 820px) {
  body { min-width: 0; overflow-x: auto; }
  .statistics-shell, .stats-panel, .team-inline-detail, .live-view,
  .live-block, .wc-tickets-view, .wc-tickets-section, .team-detail-content {
    min-width: 0;
    max-width: 100%;
  }

  /* Natural page height avoids competing small nested vertical scroll areas. */
  .statistics-shell, .stats-panel, .team-detail-panel {
    height: auto;
    min-height: calc(100dvh - var(--mobile-top-menu-height));
  }

  .table-wrap, .team-inline-detail .team-detail-table-wrap,
  .wc-tickets-table-wrap, .live-competition-table-wrap, .math-table-wrap, .scoring-table-wrap {
    min-width: 0;
    max-width: 100%;
    overflow: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap { flex: 0 0 auto; min-height: 0; max-height: none; }
  .team-inline-detail .team-detail-table-wrap { flex: 0 0 auto; max-height: none; }
  .team-detail-table { min-width: 980px; }
  .team-detail-table th, .team-detail-table td { font-size: 0.875rem; }
  .team-detail-player-name { max-width: 18rem; white-space: normal; overflow-wrap: anywhere; }
  .team-detail-table th:nth-child(3), .team-detail-table td:nth-child(3) {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 140px;
    max-width: 200px;
    background-color: var(--panel);
  }
  .team-detail-table thead th:nth-child(3) { z-index: 3; }
  .team-detail-player-row-mng td:nth-child(3) { background-color: #471f2a; }
  .team-detail-player-row-historical-dead td:nth-child(3) { background-color: #0b0a0c; }
  .team-detail-player-row-historical-other-injury td:nth-child(3) { background-color: #651c20; }

  .team-inline-detail .team-detail-roster { min-width: 0; }
  .team-roster-context { order: 0; align-items: flex-start; padding-inline: 8px; }
  .team-roster-context strong { flex: 1 1 160px; line-height: 1.5; }
  .team-roster-context button { flex: 0 1 auto; white-space: normal; }
  .team-roster-scroll-hint { display: block; flex-basis: 100%; color: var(--muted); font-size: 0.875rem; line-height: 1.5; }
  .team-inline-detail .team-detail-table-wrap { order: 2; }

  .filter-control { min-width: 0; }
  .filters-grid input { min-width: 0; width: 100%; min-height: 44px; font-size: 1rem; }
  .filter-options { max-width: 100%; max-height: min(260px, 45dvh); }
  .filter-options button, .top-menu-link, .guide-nav-item, .site-footer-link { min-height: 44px; }
  .top-menu-icon-button, .top-menu-toggle, .language-globe-button, .modal-close-button {
    min-width: 44px;
    min-height: 44px;
  }
  .top-menu-nav { max-height: calc(100dvh - var(--mobile-top-menu-height) - 16px); overflow-y: auto; }
  .top-menu-submenu { max-width: 100%; }
  .auto-refresh-menu { max-width: calc(100vw - 20px); }
  .auto-refresh-menu input { font-size: 1rem; }
  .live-block-header, .live-block-header-inline { flex-wrap: wrap; gap: 12px; }
  .live-card-title, .live-competition-title, .live-match-team-name,
  .team-detail-card-label, .team-detail-card-value, .guide-article, .legal-article { overflow-wrap: anywhere; }
  .live-action-button, .team-detail-sos-button { min-height: 44px; white-space: normal; }
  .live-bracket { overflow-x: auto; scrollbar-width: auto; }
  .live-bracket-round { flex: 0 0 240px; }
  .live-bracket-connector { flex: 0 0 24px; }
  .live-bracket-round-title { font-size: 0.875rem; }
  .live-bracket-series { font-size: 0.875rem; }

  .modal-backdrop { padding: 8px; align-items: center; }
  .modal-panel, .guide-panel, .math-panel, .scoring-panel, .team-detail-sos-modal-panel {
    min-width: 0;
    max-width: 100%;
    max-height: calc(100dvh - 16px);
    overflow-y: auto;
  }
  .modal-header { position: sticky; top: 0; z-index: 2; align-items: flex-start; gap: 12px; padding: 12px; }
  .modal-header h2 { min-width: 0; overflow-wrap: anywhere; }
  .modal-close-button { flex-shrink: 0; }
  .modal-body, .guide-content, .legal-content { min-width: 0; padding: 14px; }
  .math-table-wrap table { min-width: 600px; }
  .scoring-table-wrap table { min-width: 420px; }
  .modal-body code, .math-formula { max-width: 100%; overflow-x: auto; }
  .team-detail-sos-dialog-title, .guide-achievement-title { white-space: normal; overflow: visible; }
  .team-detail-sos-dialog-header { flex-wrap: wrap; }
  .team-detail-sos-dialog-actions { margin-left: auto; }
  .team-detail-sos-help-button { min-height: 44px; }
  .skill-help-tooltip { left: 10px; right: 10px; bottom: 10px; max-width: calc(100vw - 20px); max-height: 50dvh; overflow-y: auto; }
  .floating-tooltip { max-width: calc(100vw - 20px); max-height: 45dvh; overflow-y: auto; }
  .skill-chip[role="button"] { display: inline-flex; align-items: center; min-height: 36px; padding: 2px 4px; }
}

@media (max-width: 360px) {
  .top-menu-logos { gap: 4px; }
  .top-menu-logos img { max-width: 38px; }
  .team-inline-detail-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-block { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .team-inline-detail-deck-card { transition: none; }
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  /* On touch/narrow layouts matches are distinct cards, never overlapping. */
  .team-inline-detail-deck {
    order: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    min-width: 0;
    padding: 12px 4px;
    gap: 12px;
    z-index: auto;
  }
  .team-inline-detail-deck-filters { flex-direction: row; flex-wrap: wrap; align-self: stretch; gap: 8px; }
  .team-inline-detail-deck-filter {
    width: auto;
    height: auto;
    min-width: 44px;
    min-height: 44px;
    flex: 1 1 auto;
    gap: 6px;
    padding: 6px 8px;
  }
  .team-inline-detail-deck-filter-swatch { width: 24px; height: 24px; flex-shrink: 0; font-size: 0.875rem; }
  .team-inline-detail-deck-filter-label { display: inline; font-size: 0.875rem; }
  .team-inline-detail-deck-stack {
    display: flex;
    align-items: stretch;
    gap: 12px;
    height: auto;
    min-height: 0;
    overflow-x: auto;
    padding: 5px 4px 14px;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    scrollbar-width: auto;
  }
  .team-inline-detail-deck-card,
  .team-inline-detail-deck-card.is-active,
  .team-inline-detail-deck-card.is-rest-focus {
    position: relative;
    inset: auto;
    flex: 0 0 min(260px, 85%);
    width: auto;
    min-width: 0;
    min-height: 148px;
    transform: none;
    scroll-snap-align: start;
    overflow: visible;
    transition: none;
  }
  .team-inline-detail-deck-card-face { border-radius: 12px; }
  .team-inline-detail-deck-card-body { padding: 12px; gap: 8px; opacity: 1; }
  .team-inline-detail-deck-card-coach, .team-inline-detail-deck-card-rival {
    font-size: 0.95rem;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
  }
  .team-inline-detail-deck-card-score { font-size: 1.25rem; }
  .team-inline-detail-deck-card-date { display: block; }
  .team-inline-detail-deck-empty { position: static; min-height: 64px; }

}
