/* One phone layout, whether the game runs in a desktop frame or on a phone. */
@container game (max-width:700px) {
  .game-shell {
    --phone-nav-height: 60px;
    --phone-action-height: 104px;
  }
  .game-shell:has(#navigation:empty) {
    --phone-nav-height: 0px;
  }
  .game-topbar {
    height: 44px;
    padding-inline: 8px;
    gap: 6px;
  }
  .game-title-small {
    font-size: var(--type-body);
    letter-spacing: -0.3px;
  }
  .game-topbar .game-button {
    min-height: 40px;
    padding: 6px;
  }
  .topbar-tools {
    gap: 0;
  }
  .topbar-tools .game-button {
    min-width: 36px;
  }
  .career-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(90px, 1fr) auto;
    min-height: 56px;
    padding: 6px 12px;
    gap: 10px;
    font-size: var(--type-caption);
  }
  .career-strip strong {
    max-width: none;
  }
  .career-strip > span {
    font-size: var(--type-caption);
    line-height: 1.4;
  }
  .career-store {
    min-width: 64px;
    min-height: 44px;
    align-self: center;
    padding: 6px 9px;
    gap: 5px;
  }
  .career-store > span {
    font-size: var(--type-caption);
  }
  .career-store > strong {
    font-size: var(--type-body);
  }

  /* The navigation stays outside the content scroller and keeps every tab visible. */
  #navigation {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    height: var(--phone-nav-height);
    min-height: var(--phone-nav-height);
    padding: 4px 3px;
    gap: 0;
    overflow: visible;
    position: relative;
    bottom: auto;
  }
  #navigation:empty {
    display: none;
  }
  #navigation .game-button {
    min-width: 0;
    width: 100%;
    min-height: 50px;
    padding: 4px 1px;
    gap: 4px;
    font-size: var(--type-caption);
    line-height: 1.2;
    border-radius: 3px;
  }
  #navigation .ui-icon {
    width: 20px;
    height: 20px;
  }
  #navigation .game-button[aria-current='page'] {
    background: var(--ui-raised, #2a3c48);
    color: #f3d397;
  }
  #app {
    scroll-padding-block: 90px calc(var(--phone-action-height) + 12px);
    overscroll-behavior-y: contain;
  }
  #app .game-button:focus-visible {
    scroll-margin-block: 90px calc(var(--phone-action-height) + 12px);
  }

  .play-style {
    padding: 0 12px;
    gap: 10px;
    min-height: 44px;
    font-size: var(--type-caption);
  }
  .play-style .game-button {
    font-size: var(--type-caption);
    min-height: 44px;
    padding: 6px 0;
  }
  .match-screen,
  .play-style + .match-screen {
    height: auto;
    min-height: 100%;
  }
  .match-screen .match-scoreboard {
    position: sticky;
    top: 0;
    z-index: 6;
    grid-template-columns: minmax(0, 1.1fr) auto minmax(0, 1fr);
    padding: 10px 12px;
    gap: 10px;
    min-height: 82px;
    flex-basis: auto;
  }
  .match-screen .score-team {
    gap: 7px;
  }
  .match-screen .score-team .team-stamp {
    display: none;
  }
  .match-screen .opponent-name {
    font-size: var(--type-caption);
    max-width: none;
    white-space: normal;
    line-height: 1.3;
  }
  .match-screen .live-score {
    font-size: var(--type-score);
    line-height: 1.1;
    margin-top: 3px;
  }
  .match-screen .live-score span {
    font-size: var(--type-number);
  }
  .match-screen .score-overs {
    font-size: var(--type-caption);
    gap: 2px;
  }
  .match-screen .score-overs strong {
    font-size: var(--type-name);
  }
  .match-screen .score-overs small {
    font-size: var(--type-caption);
  }
  .match-screen .chase-equation {
    text-align: right;
    gap: 5px;
  }
  .match-screen .chase-equation strong {
    font-size: var(--type-section);
    line-height: 1.25;
  }
  .match-screen .chase-equation > span {
    font-size: var(--type-caption);
    line-height: 1.35;
  }
  .match-screen .stadium-wrap canvas {
    height: clamp(180px, min(70cqi, calc(100cqh - 430px)), 296px);
  }
  .match-screen .pitch-label {
    padding: 8px 12px;
    gap: 4px 10px;
    font-size: var(--type-caption);
    line-height: 1.4;
  }
  .match-screen .pitch-label span,
  .match-screen .pitch-label small {
    font-size: var(--type-caption);
  }
  .match-screen .match-commentary {
    padding: 10px 12px;
    min-height: 0;
  }
  .match-screen .match-commentary > p {
    font-size: var(--type-body);
    line-height: 1.5;
    margin-top: 8px;
    max-height: none;
    overflow: visible;
  }
  .match-screen .over-feed-row {
    font-size: var(--type-caption);
    grid-template-columns: 45px minmax(0, 1fr) 48px;
    gap: 6px;
  }
  .match-screen .over-feed-row > div {
    gap: 4px;
  }
  .match-screen .field-toolbar {
    padding: 10px 12px;
    border-bottom: 1px solid var(--edge);
  }
  .match-screen .field-summary strong {
    font-size: var(--type-body);
  }
  .match-screen .field-summary p {
    font-size: var(--type-caption);
    line-height: 1.5;
    margin: 4px 0 8px;
  }
  .match-screen .field-actions .game-button {
    min-height: 44px;
    font-size: var(--type-caption);
    padding: 8px;
  }
  .match-screen .field-quick-plans {
    padding: 8px 12px;
    gap: 6px;
  }
  .match-screen .field-quick-plans .game-button {
    font-size: var(--type-caption);
    min-height: 44px;
  }

  /* Detailed choices follow the field in one readable column. */
  #game-shell .match-screen .dugout {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px 12px;
    overflow: visible;
  }
  #game-shell .match-screen .dugout:has(.bowl-actions, .casual-play-footer) {
    padding-bottom: calc(var(--phone-action-height) + 16px);
  }
  .match-screen .innings-guide p,
  .match-screen .batter-read p,
  .match-screen .sim-hint {
    font-size: var(--type-body);
    line-height: 1.5;
  }
  .match-screen .batter-read strong,
  .match-screen .batter-read strong > span {
    font-size: var(--type-body);
  }
  .match-screen .bowler-needed {
    font-size: var(--type-body);
    line-height: 1.5;
  }
  .match-screen .bowling-plan-launch {
    min-height: 64px;
    padding-block: 8px;
  }
  .match-screen .bowling-plan-launch small {
    font-size: var(--type-body);
    line-height: 1.4;
  }
  .match-screen .casual-contestants {
    gap: 14px;
  }
  .match-screen .casual-player strong {
    font-size: var(--type-body);
    line-height: 1.35;
  }
  .match-screen .casual-player span {
    font-size: var(--type-caption);
    line-height: 1.4;
    margin-top: 3px;
  }
  .match-screen .casual-plan-hint {
    font-size: var(--type-body);
    line-height: 1.5;
  }
  .match-screen .casual-plans .game-button {
    font-size: var(--type-body);
    min-height: 48px;
  }
  .match-screen .moment-review {
    font-size: var(--type-body);
    line-height: 1.5;
    padding: 10px 0 10px 12px;
    scroll-margin-block: 96px 120px;
  }
  .match-screen .moment-review strong {
    font-size: var(--type-section);
  }
  .match-screen .batting-manager {
    padding-block: 8px 14px;
  }
  .match-screen .batting-manager-header strong {
    font-size: var(--type-section);
  }
  .match-screen .batting-manager-header small,
  .match-screen .batting-manager .batter-identity {
    font-size: var(--type-body);
    line-height: 1.4;
  }
  .match-screen .batting-intent button {
    min-height: 48px;
    font-size: var(--type-caption);
  }
  .match-screen .opposition-bowler p {
    font-size: var(--type-body);
    line-height: 1.5;
  }
  .match-screen .dugout > [data-action='tactics'],
  .match-screen .dugout > [data-action='batting-plan'] {
    min-height: 48px;
    font-size: var(--type-body);
    align-self: stretch;
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
  }
  .match-screen .dugout > [data-action='batting-plan'] small {
    font-size: var(--type-caption);
  }
  .match-screen .match-speed > span,
  .match-screen .playback-controls > .game-button {
    font-size: var(--type-body);
  }

  /* Reuse the live play controls as one dock; there is no duplicate action bar. */
  .match-screen .casual-play-footer,
  .match-screen .bowl-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--phone-nav-height);
    z-index: 12;
    margin: 0;
    padding: 10px 12px;
    background: var(--ui-surface, #182b38);
    border-top: 1px solid #60737b;
    box-shadow: 0 -5px 12px #08151c24;
  }
  .match-screen .casual-play-footer {
    gap: 6px;
  }
  .match-screen .casual-play-buttons {
    gap: 8px;
  }
  .match-screen .casual-play-buttons .game-button,
  .match-screen .bowl-actions .game-button {
    min-height: 50px;
    font-size: var(--type-section);
    padding: 10px 8px;
  }
  .match-screen .casual-play-footer > p {
    font-size: var(--type-caption) !important;
    line-height: 1.4;
    margin: 0;
  }
  .match-screen .bowl-actions [data-action='ball'] {
    font-size: var(--type-name);
  }
  .match-screen .casual-play-footer .stop-over:not([hidden]) {
    position: static;
    inset: auto;
    width: 100%;
    min-height: 50px;
    font-size: var(--type-body);
    margin: 0;
  }
  .match-screen .dugout > .stop-over:not([hidden]) {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--phone-nav-height) + 10px);
    z-index: 14;
    min-height: 50px;
    font-size: var(--type-body);
  }
  .game-shell[data-busy='true'] .match-screen .bowl-actions {
    visibility: hidden;
  }
  .game-shell:has(.match-screen) .notice {
    bottom: calc(var(--phone-nav-height) + var(--phone-action-height) + 8px);
    font-size: var(--type-body);
  }
  .match-screen .result-screen {
    gap: 14px;
    padding: 8px 0 20px;
  }
  .match-screen .result-screen p {
    font-size: var(--type-body);
    line-height: 1.5;
  }
  .match-screen .result-screen small {
    font-size: var(--type-caption);
    line-height: 1.5;
  }
  .match-screen .result-screen > .game-button {
    min-height: 50px;
    font-size: var(--type-section);
  }

  .career-hub {
    padding: 22px 16px;
    gap: 24px;
  }
  .hub-fixture > p:not(.hub-opponent),
  .hub-player p,
  .hub-last-report {
    font-size: var(--type-body);
    line-height: 1.5;
  }
  .hub-guidance {
    font-size: var(--type-body) !important;
    line-height: 1.5;
  }
  .hub-player h4 {
    font-size: var(--type-section);
  }
  .hub-player .game-button {
    min-height: 44px;
    font-size: var(--type-body);
  }
  .hub-links {
    gap: 8px;
  }
  .hub-links .game-button {
    min-height: 48px;
    font-size: var(--type-body);
  }

  /* Long player and store details retain their original close controls. */
  .player-report-dialog,
  .analysis-dialog,
  .gear-picker-dialog,
  .pack-reveal-dialog {
    scroll-padding-block: 110px 16px;
  }
  .report-header,
  .analysis-header,
  .gear-picker-header {
    position: sticky;
    top: 0;
    z-index: 4;
    background: var(--navy);
  }
  .report-header > .game-button,
  .gear-picker-header > .game-button,
  .analysis-header > .game-button {
    min-height: 44px;
    flex-shrink: 0;
  }
  .player-report-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .player-report-body > * {
    min-width: 0;
  }
  .player-report-body .stats-table-scroll {
    max-width: 100%;
    overscroll-behavior-x: contain;
  }
}

@container game (max-width:360px) {
  .game-title-small {
    font-size: var(--type-caption);
  }
  .game-topbar {
    gap: 3px;
    padding-inline: 5px;
  }
  .topbar-tools .game-button {
    min-width: 34px;
  }
  .career-strip {
    padding-inline: 8px;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) minmax(82px, 1fr) auto;
  }
  .career-strip .club-badge {
    width: 20px;
  }
  .career-store {
    min-width: 58px;
    padding-inline: 5px;
  }
  #navigation .game-button {
    font-size: var(--type-caption);
  }
  .match-screen .match-scoreboard {
    padding-inline: 10px;
    gap: 7px;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }
  .match-screen .live-score {
    font-size: var(--type-display);
  }
  .match-screen .chase-equation strong {
    font-size: var(--type-body);
  }
  .match-screen .over-feed-row > div {
    gap: 3px;
  }
  .match-screen .over-feed-row .delivery-chip {
    width: 21px;
    height: 23px;
    min-width: 21px;
  }
  .match-screen .batting-intent button {
    font-size: var(--type-caption);
  }
  .match-screen .casual-contestants {
    flex-direction: column;
    gap: 12px;
  }
}
