/*
 * MATCHIQ phone layout.
 * Every rule in this file is width-scoped so the established desktop view
 * remains byte-for-byte visually governed by the existing stylesheets.
 */
@media (max-width: 760px) {
  html { overflow-x: hidden; scroll-padding-top: 78px; }
  body { min-width: 0; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
  button, input, select { touch-action: manipulation; }
  input, select, textarea { font-size: 16px !important; }
  .app-shell, .content-shell, .main-content, .view { min-width: 0; max-width: 100%; }

  .topbar {
    min-height: 64px;
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    gap: 8px;
  }
  .mobile-menu, .connect-button, .icon-button { min-width: 42px; min-height: 42px; }
  .league-switcher { min-width: 0; margin-left: 4px; padding: 7px 6px; }
  .league-switcher strong { max-width: min(35vw, 145px); font-size: 12px; }
  .topbar-actions { gap: 6px; }
  .sidebar {
    width: min(86vw, 320px);
    padding: calc(22px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom));
  }
  .brand { padding-bottom: 22px; }
  .nav-item { min-height: 48px; }
  .sidebar-note { margin-top: 14px; }

  .main-content { padding: 24px max(12px, env(safe-area-inset-right)) calc(72px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .page-intro { gap: 18px; margin-bottom: 22px; }
  .page-intro h1, .compact-intro h1 { font-size: clamp(34px, 10vw, 43px); line-height: 1; letter-spacing: -2.1px; }
  .page-intro p:not(.eyebrow) { margin-top: 9px; font-size: 13px; line-height: 1.55; }
  .eyebrow { margin-bottom: 7px; font-size: 9px; }
  .panel { border-radius: 18px; }
  .panel-header { gap: 10px; }
  .panel-header h2, .section-heading h2 { font-size: 20px; }
  .section-heading { margin-top: 25px; align-items: center; }
  .secondary-button, .primary-button, .reset-button { min-height: 44px; }
  .text-button { min-height: 40px; }

  /* Cockpit */
  .deadline-card { width: 100%; min-width: 0; }
  .kpi-grid { gap: 10px; }
  .kpi-card { min-height: 150px; padding: 17px; }
  .kpi-card > strong { margin-top: 15px; font-size: 27px; }
  .kpi-card > p { left: 17px; right: 17px; bottom: 14px; font-size: 10px; line-height: 1.45; }
  .cockpit-grid { gap: 10px; }
  .action-center, .market-pulse { padding: 17px; }
  .action-center { min-height: 0; }
  .action-item { padding: 14px 12px 14px 14px; gap: 10px; }
  .action-body h3 { font-size: 14px; line-height: 1.35; }
  .action-body p { font-size: 10px; line-height: 1.55; }
  .action-button { min-height: 36px; padding-inline: 12px; }
  .pulse-switcher { grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 6px; }
  .pulse-arrow { width: 38px; height: 42px; font-size: 16px; }
  .pulse-manager-option { min-width: 118px; min-height: 48px; padding: 7px 9px; }
  .pulse-manager-avatar { width: 31px; height: 31px; flex-basis: 31px; }
  .pulse-manager-option b { font-size: 10px; }
  .pulse-manager-option small { font-size: 9px; }
  .market-daily-insight { margin-top: 14px; padding: 17px; }
  .market-daily-insight strong { font-size: 29px; }
  .market-daily-insight p { margin-right: 38px; font-size: 11px; }
  .daily-pulse-badge { padding: 7px 9px; font-size: 8px; }
  .mover-card { min-height: 132px; }

  /* Transfer market: compact cards instead of a desktop table scroller. */
  .market-summary { width: 100%; padding: 13px 12px; gap: 0; overflow: hidden; }
  .market-summary > span { min-width: 0; flex: 1; }
  .market-summary span + span { padding-left: 10px; margin-left: 10px; }
  .market-summary small { overflow-wrap: anywhere; font-size: 7px; letter-spacing: .05em; }
  .market-summary strong { font-size: 12px; white-space: nowrap; }
  .toolbar { gap: 9px; padding: 9px; }
  .search-field { min-height: 46px; height: auto; }
  .filter-chips { width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .filter-chips button { min-width: 48px; height: 40px; flex: 1 0 auto; }
  .toolbar select { min-height: 46px; }
  .market-layout .table-panel { overflow: visible; border: 0; background: transparent; box-shadow: none; }
  .market-table { min-width: 0; }
  .market-table > .table-head { display: none; }
  #marketRows { display: grid; gap: 10px; }
  .market-table #marketRows .table-row {
    min-width: 0;
    min-height: 0;
    padding: 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(128px, .85fr);
    gap: 13px 10px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(19,34,28,.96), rgba(12,24,19,.96));
    box-shadow: 0 12px 28px rgba(0,0,0,.14);
  }
  .market-table #marketRows .manager-offer { border-left: 3px solid var(--cyan); }
  .market-table #marketRows .player-mini { grid-column: 1 / -1; align-items: center; gap: 11px; }
  .market-table #marketRows .player-avatar { width: 48px; height: 52px; flex: 0 0 48px; }
  .market-player-copy { min-width: 0; }
  .market-player-copy > strong { font-size: 15px; }
  .market-club-line { margin-top: 5px; flex-wrap: wrap; }
  .market-club-line .club-badge { width: 25px; height: 27px; }
  .market-table .next-opponent.is-market { width: 100%; margin: 6px 0 0; padding: 7px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .market-table .market-price { align-self: stretch; padding: 10px; border-radius: 11px; background: rgba(255,255,255,.025); }
  .market-table .market-price strong { font-size: 13px; }
  .market-trend-widget { min-width: 0; align-self: stretch; }
  .market-trend-primary { min-height: 100%; grid-template-columns: auto 1fr auto; }
  .market-trend-mini { display: none; }
  .market-table #marketRows .table-row > .table-cell:nth-child(4),
  .market-table #marketRows .expiry { padding: 10px; border: 1px solid var(--line); border-radius: 11px; background: rgba(0,0,0,.1); }
  .market-score { min-height: 42px; grid-column: 1 / -1; padding: 0 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid rgba(217,255,67,.18); border-radius: 11px; background: var(--lime-soft); }
  .market-score small { font-size: 9px; }
  .market-score strong { margin: 0 auto 0 8px; font-size: 16px; }
  .market-score i { font-size: 18px; }
  .advisor-card { padding: 18px; }
  .advisor-player h2 { font-size: 19px; }
  .bid-level { padding-block: 11px; }

  /* Squad and lineup */
  .module-tabs { padding: 5px; }
  .module-tabs > button { min-height: 82px; padding: 11px; }
  .module-tab-copy strong { font-size: 13px; }
  .module-tab-copy small { font-size: 9px; line-height: 1.35; }
  .lineup-mode-switch button { min-height: 46px; font-size: 12px; }
  .lineup-context h2 { font-size: 22px; }
  .lineup-context p { font-size: 11px; }
  .lineup-editor-tools { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .lineup-controlbar .formation-picker { min-height: 62px; }
  .lineup-kpis { gap: 7px; }
  .lineup-kpis > span { min-height: 68px; padding: 10px; }
  .lineup-kpis small { font-size: 9px; }
  .lineup-kpis strong { font-size: 16px; }
  .pitch { min-width: calc(var(--lineup-columns) * 82px + (var(--lineup-columns) - 1) * 7px + 24px); min-height: 580px; padding: 18px 12px; gap: 14px; }
  .pitch::before { inset: 12px; }
  .pitch::after { width: 104px; height: 104px; }
  .formation-row { gap: 7px; }
  .pitch-player-slot, .pitch-player, .empty-lineup-slot { width: 82px; min-width: 82px; flex-basis: 82px; height: 120px; }
  .pitch-player { padding: 9px 5px 6px; border-radius: 12px; }
  .pitch-player .player-avatar.medium { width: 40px; height: 40px; flex-basis: 40px; margin-bottom: 4px; }
  .lineup-card-club, .lineup-card-club .club-badge { width: 19px; height: 21px; left: 6px; top: 6px; }
  .lineup-card-name { min-height: 29px; }
  .lineup-card-name small { font-size: 8px; line-height: 12px; }
  .lineup-card-name strong { font-size: 11px; line-height: 16px; }
  .lineup-card-score { gap: 4px; padding-top: 4px; }
  .lineup-card-score b { font-size: 10px; }
  .lineup-card-score small { font-size: 7px; }
  .pitch-remove { right: 4px; top: 4px; width: 27px; height: 27px; }
  .empty-lineup-slot i { width: 30px; height: 30px; }
  .bench-chip { min-height: 76px; }
  .bench-add { width: 38px; height: 42px; }
  .portfolio-card-head { gap: 9px; flex-wrap: wrap; }
  .portfolio-current { width: 100%; padding-top: 10px; display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--line); text-align: left; }
  .portfolio-current strong { font-size: 16px; }
  .portfolio-card-metrics small, .portfolio-card-metrics em { font-size: 9px; }
  .portfolio-card-metrics strong { font-size: 12px; }
  .portfolio-trend-strip .market-range-cell { gap: 6px; }
  .portfolio-trend-strip .market-range-cell small { min-height: 49px; }

  /* Comparisons and league */
  .compare-panel { padding: 16px; }
  .compare-picker .search-field { min-width: 0; }
  .compare-heroes { gap: 8px; }
  .compare-hero { padding: 14px 8px; }
  .compare-hero .player-avatar { width: 58px; height: 64px; }
  .compare-hero h2 { font-size: 14px; line-height: 1.3; overflow-wrap: anywhere; }
  .compare-club { justify-content: center; flex-wrap: wrap; font-size: 11px; }
  .compare-club .club-badge { width: 34px; height: 36px; }
  .metric-row { min-height: 58px; grid-template-columns: 42px minmax(0,1fr) 66px minmax(0,1fr) 42px; }
  #view-league .compact-rule-profile, #view-league .standings-panel, #view-league .rivals-panel { padding: 17px; }
  #view-league .standing-row, #view-league .standing-row:not(.finance-row) { padding: 15px 11px; gap: 12px 8px; }
  #view-league .manager-cell { min-width: 0; }
  #view-league .manager-cell strong { font-size: 13px; }
  #view-league .standing-stat small { font-size: 8px; }
  #view-league .standing-stat b { font-size: 15px; }
  #view-league .finance-kpi-grid, #view-league .bonus-input-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  #view-league .transfer-card { grid-template-columns: minmax(0,1fr) minmax(0,.8fr); }
  .confidence-pill { width: 100%; justify-content: space-between; }

  /* Player centre and full player card */
  .hub-cache-toolbar { align-items: flex-start; font-size: 10px; }
  .hub-cache-toolbar button { flex: 0 0 auto; }
  .hub-progress { padding: 17px; gap: 14px; }
  .hub-progress-icon { width: 42px; height: 42px; flex-basis: 42px; }
  .player-hub-control { padding: 7px; }
  .player-hub-search { min-height: 58px; padding-inline: 11px; }
  .player-hub-search-copy small { font-size: 8px; }
  .player-hub-categories button { min-height: 42px; }
  .player-hub-positions button { height: 42px; }
  .player-hub-heading { align-items: center; }
  .player-hub-player-row { gap: 9px; }
  .player-hub-player strong { font-size: 13px; }
  .player-hub-player small { line-height: 1.4; font-size: 10px; white-space: normal; }
  .player-hub-owner { padding-top: 10px; border-top: 1px solid var(--line); }
  .player-hub-stat strong { font-size: 12px; }
  .player-hub-open { width: 32px; height: 32px; }
  .league-player-dialog { padding-bottom: env(safe-area-inset-bottom); }
  .league-player-close { width: 44px; height: 44px; }
  .league-player-hero { padding: calc(62px + env(safe-area-inset-top)) 16px 22px; grid-template-columns: 76px minmax(0,1fr); gap: 14px; }
  .league-player-hero > .player-avatar.xlarge { width: 76px; height: 76px; }
  .league-player-identity h2 { font-size: clamp(24px, 8vw, 31px); line-height: 1; overflow-wrap: anywhere; }
  .league-player-identity .eyebrow { margin-bottom: 9px; }
  .league-player-identity .eyebrow .club-badge { width: 38px; height: 40px; }
  .league-player-badges { margin-top: 11px; }
  .league-player-badges .next-opponent { width: 100%; }
  .league-player-hero-value strong { font-size: 28px; }
  .league-player-kpis > span { min-width: 0; }
  .league-player-kpis strong { font-size: 18px; overflow-wrap: anywhere; }
  .league-player-chart-card, .league-player-analysis-card, .league-player-form-card { padding: 16px 14px; }
  .league-player-section-head { align-items: flex-start; gap: 10px; }
  .league-player-section-head h3 { font-size: 19px; }
  .league-player-ranges > span { padding: 12px 9px; }
  .league-player-insight .insight-value { font-size: 21px; }
  .league-player-form-strip { scrollbar-width: thin; }

  /* Radar and manager check */
  .radar-upcoming, .radar-analysis { padding: 17px; }
  .radar-upcoming-head { align-items: flex-start; gap: 12px; }
  .radar-upcoming-head h2 { font-size: 20px; }
  .radar-next-row { min-height: 76px; }
  .radar-next-player .player-avatar { width: 38px; height: 42px; }
  .radar-controls { padding: 14px; }
  .radar-profile { align-items: flex-start; gap: 13px; }
  .radar-forecast > span { padding: 15px 11px; }
  .manager-lab .page-intro .secondary-button { width: 100%; }
  .manager-lab-switcher { grid-template-columns: 40px minmax(0,1fr) 40px; }
  .manager-lab-switcher > button { min-height: 40px; }
  .manager-lab-rail > button { min-width: 142px; min-height: 54px; }
  .manager-profile-identity { flex-wrap: wrap; }
  .manager-profile-copy { min-width: 0; }
  .manager-profile-copy h2 { overflow-wrap: anywhere; }
  .manager-stat-grid { grid-template-columns: 1fr 1fr; }
  .manager-compare-pickers { grid-template-columns: 1fr; gap: 10px; }
  .manager-compare-pickers > button { width: 44px; height: 44px; margin: 0; justify-self: center; transform: rotate(90deg); }
  .manager-compare-pickers select { width: 100%; min-height: 50px; }
  .manager-comparison-heads { gap: 8px; }
  .manager-comparison-heads article { padding: 16px 9px; }
  .manager-comparison-table { overflow-x: auto; }
  .manager-comparison-table table { min-width: 340px; }

  /* Calculator, drawers, dialogs and footer */
  .calc-mobile-finances { top: 72px; padding: 13px 14px; }
  .calc-mobile-finances strong { font-size: 16px; }
  .calc-tabs button { min-height: 45px; }
  .calc-price-switch button, .calc-player-option, .calc-icon-button { min-height: 42px; }
  .calc-finances, .calc-plan, .calc-composer { border-radius: 18px; }
  .player-drawer { width: 100%; padding: calc(18px + env(safe-area-inset-top)) 17px calc(24px + env(safe-area-inset-bottom)); }
  .drawer-close, .modal-close { width: 42px; height: 42px; top: 12px; right: 12px; }
  .drawer-hero { padding-top: 48px; gap: 12px; }
  .drawer-hero h2 { font-size: 22px; }
  .drawer-kpis { grid-template-columns: 1fr 1fr; }
  .connect-modal { width: calc(100% - 18px); max-height: calc(100dvh - 18px); padding: 26px 18px; overflow-y: auto; border-radius: 20px; }
  .connect-modal h2 { padding-right: 36px; font-size: 24px; }
  .privacy-actions { grid-template-columns: 1fr; }
  .toast { left: 10px; right: 10px; bottom: calc(12px + env(safe-area-inset-bottom)); min-width: 0; transform: translateY(20px); }
  .toast.is-visible { transform: none; }
  .site-footer { margin: 16px 14px calc(24px + env(safe-area-inset-bottom)); }
  .site-footer nav { width: 100%; gap: 8px; }
  .site-footer button { min-height: 40px; }
}

@media (max-width: 380px) {
  .main-content { padding-inline: 10px; }
  .league-switcher strong { max-width: 108px; }
  .page-intro h1, .compact-intro h1 { font-size: 33px; }
  .market-table #marketRows .table-row { grid-template-columns: 1fr; }
  .market-table #marketRows .player-mini, .market-score { grid-column: 1; }
  .market-summary span + span { padding-left: 7px; margin-left: 7px; }
  .module-tab-icon { display: none; }
  .module-tabs > button { min-height: 74px; }
  .compare-hero .player-avatar { width: 50px; height: 56px; }
  .metric-row { grid-template-columns: 38px minmax(0,1fr) 58px minmax(0,1fr) 38px; gap: 4px; }
  #view-league .finance-kpi-grid, #view-league .bonus-input-grid { grid-template-columns: 1fr; }
  #view-league .transfer-card { grid-template-columns: 1fr; }
  .manager-stat-grid { grid-template-columns: 1fr; }
  .league-player-hero { grid-template-columns: 66px minmax(0,1fr); }
  .league-player-hero > .player-avatar.xlarge { width: 66px; height: 70px; }
}

@media (max-width: 760px) and (orientation: landscape) {
  .league-player-dialog { height: 100dvh; }
  .connect-modal, .intro-dialog { max-height: calc(100dvh - 12px); }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
  .sidebar, .view, .market-daily-insight, .player-hub-player-row { animation: none !important; transition: none !important; }
}
