.mobile-activity, .mobile-confirm {
  display: none;
}

@media (max-width: 600px) and (orientation: portrait) {
  #app:has(.game-shell) {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right)
      env(safe-area-inset-bottom) env(safe-area-inset-left);
    overflow: hidden;
  }

  #app:has(.game-shell) .topbar {
    flex: 0 0 auto;
    min-height: 44px;
    gap: 5px;
    padding: 4px 9px;
  }

  #app:has(.game-shell) .brand { gap: 5px; }
  #app:has(.game-shell) .brand strong { font-size: 11px; letter-spacing: .6px; }
  #app:has(.game-shell) .brand small { display: none; }
  #app:has(.game-shell) .brand-mark { width: 24px; height: 24px; }
  #app:has(.game-shell) .header-right { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  #app:has(.game-shell) .header-right button { font-size: 10px; padding: 4px; }
  #app:has(.game-shell) .header-right .icon-button { min-width: 29px; min-height: 30px; }
  .solo-switch { font-size: 0; gap: 0; }
  .solo-switch select { width: 80px; }

  .game-shell {
    min-height: 0;
    margin: 0;
    padding: 0 5px 5px;
  }

  .game-shell > .activity, .view-tools .layout-radios { display: none; }
  .game-shell .table-topline { justify-content: space-between; min-height: 34px; padding: 0 4px; gap: 2px; }
  .game-shell .view-tools { position: static; gap: 0; margin-left: auto; }
  .game-shell .view-tools button { width: 34px; min-height: 34px; }
  .game-shell .mobile-activity { display: inline-block; }
  .game-shell .turn-order { gap: 2px; }
  .game-shell .turn-order span { width: 16px; height: 16px; font-size: 8px; }
  .game-shell .turn-order i { display: none; }
  .game-shell .turn-order:before { margin-right: 4px; }
  .game-shell .final-round-pill { margin: 0 3px 0 0; padding: 2px 3px; font-size: 8px; }

  .game-shell > .table-surface:not(.lobby-table) {
    --opponent: clamp(58px, 11.5dvh, 112px);
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "north" "objectives" "supplies" "draft" "south" "controls";
    align-content: stretch;
    gap: 5px;
    padding: 7px;
    min-height: 0;
    border-width: 2px;
    border-radius: 13px;
  }

  .game-shell .opponents-row {
    justify-content: center;
    gap: clamp(6px, 3vw, 14px);
    min-width: 0;
  }

  .opponents-row .player-zone {
    flex: 0 1 var(--opponent);
    width: var(--opponent);
    min-width: 0;
    gap: 4px;
  }

  .game-shell .opponents-row .board {
    width: 100%;
    gap: 2px;
    padding: 3px;
  }

  .opponents-row .player-heading { gap: 4px; }
  .opponents-row .player-zone:only-child {
    flex: 0 1 auto;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  .game-shell .opponents-row .player-zone:only-child .board {
    flex: 0 0 var(--opponent);
    width: var(--opponent);
  }
  .opponents-row .player-zone:only-child .player-heading { width: auto; }
  .opponents-row .player-identity { flex-basis: 36px; }
  .opponents-row .cartoon-avatar { width: 26px; height: 28px; margin: 0 auto; }
  .opponents-row .player-heading .score { font-size: 16px; }
  .opponents-row .player-heading .score sub { font-size: 8px; }
  .opponents-row .hidden-hand img { width: 12px; height: 18px; margin-left: -8px; }
  .opponents-row .hidden-hand img:nth-child(n+4) { display: none; }

  .game-shell .shared-center, .game-shell .draft-section, .game-shell .draft-floor { display: contents; }
  .game-shell .objective-groups {
    grid-area: objectives;
    justify-content: center;
    gap: 7px;
    padding: 5px;
    border: 1px solid #7a9d7a55;
    border-radius: 8px;
    min-width: 0;
  }

  .game-shell .objective-row { display: flex; justify-content: center; gap: 3px; }
  .game-shell .objective { flex: 1 1 0; min-width: 0; max-width: 58px; border-radius: 4px; }
  .game-shell .objective img { width: 100%; height: auto; display: block; }

  .game-shell .table-tools {
    grid-area: supplies;
    width: 100%;
    justify-content: center;
    padding: 0 55px 0 0;
    gap: 12px;
    min-height: 29px;
  }

  .game-shell .table-tools .pile b,
  .game-shell .table-tools .bag-count b { font-size: 12px; }
  .game-shell .table-tools .discard-symbol,
  .game-shell .table-tools .bag-count span { font-size: 16px; }
  .game-shell .objective-deck img { width: 13px; height: 20px; }
  .game-shell .objective-deck small { font-size: 7px; }
  .game-shell .draw-stack {
    grid-area: supplies;
    justify-self: end;
    align-self: center;
    min-height: 30px;
    gap: 4px;
    padding-left: 6px;
  }

  .game-shell .draw-stack img { width: 16px; height: 24px; }
  .game-shell .draw-stack span b { font-size: 13px; }
  .game-shell .pool {
    grid-area: draft;
    min-width: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 3px;
    min-height: 34px;
  }

  .game-shell .pool-tile {
    flex: 0 1 37px;
    width: min(37px, calc((100vw - 48px) / 9));
    min-width: 0;
    height: auto;
    aspect-ratio: 1;
    touch-action: none;
  }

  .game-shell .own-player {
    align-self: stretch;
    align-items: start;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 38px minmax(0, 1fr);
    row-gap: 4px;
    padding: 0;
    min-height: 0;
    container-type: size;
  }

  .game-shell .own-player .player-heading {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    max-width: none;
    margin: 0;
    gap: 12px;
    justify-content: center;
  }

  .own-player .player-identity { flex: 0 1 auto; flex-direction: row; gap: 5px; }
  .own-player .player-identity .name-button strong { max-width: 90px; font-size: 11px; }
  .own-player .player-heading .cartoon-avatar { width: 29px; height: 32px; }
  .own-player .player-heading .score { font-size: 21px; }
  .mobile-hand.secondary { padding: 5px 8px; font-size: 11px; min-height: 34px; }
  .mobile-hand b { margin-left: 3px; color: #edc579; }
  .game-shell .own-player .board {
    grid-row: 2;
    grid-column: 1;
    align-self: center;
    margin: 0 auto;
    width: max(0px, min(calc(100cqh - 42px), 100cqw, 420px));
    gap: 4px;
    padding: 5px;
  }

  .own-player .cell-coordinate { font-size: 9px; }
  .own-player .cell.staged { touch-action: none; }
  .game-shell .score-wrap:hover .score-popover,
  .game-shell .score-wrap:focus-within .score-popover { display: none; }
  .game-shell .preview-label { display: none; }
  .game-shell .turn-message {
    grid-area: controls;
    position: static;
    width: 100%;
    margin: 0;
    padding: 4px 6px;
    min-height: 0;
    border-radius: 8px;
    background: #103d41;
  }

  .game-shell .turn-message > strong { font-size: 12px; }
  .game-shell .turn-message > .eyebrow { margin: 0 0 2px; }
  .game-shell .turn-message p { margin: 3px 0; }
  .game-shell .turn-message label { margin: 3px 0; font-size: 10px; }
  .game-shell .turn-message select { margin: 3px auto; min-height: 32px; }
  .game-shell .turn-message .button-row { margin: 3px 0 0; gap: 5px; }
  .game-shell .turn-message button { min-height: 34px; padding: 5px 8px; font-size: 11px; }
  .game-shell .turn-message.action-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 2px 6px;
  }
  .game-shell .action-controls > .eyebrow,
  .game-shell .action-controls > p { display: none; }
  .game-shell .action-controls > strong { grid-column: 1 / -1; }
  .game-shell .action-controls:has(label) > strong { grid-column: 1; }
  .game-shell .action-controls > label { grid-column: 2; }
  .game-shell .action-controls > small,
  .game-shell .action-controls > .discard-picker,
  .game-shell .action-controls > .button-row { grid-column: 1 / -1; }
  .game-shell .action-controls select { margin: 0; }
  .game-shell .turn-message .discard-picker { max-height: 48px; overflow: auto; }
  .game-shell .turn-message:has(.staging-hint) { display: flex; align-items: center; justify-content: center; gap: 12px; }
  .game-shell .turn-message .mobile-confirm { display: inline; font-size: 11px; }
  .game-shell .turn-ready, .game-shell .turn-message.idle-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 40px;
  }

  .game-shell .turn-ready > strong { display: block; }
  .game-shell .idle-status > .eyebrow, .game-shell .idle-status > p { display: none; }

  .game-shell > .lobby-table { padding: 8px; }
  .lobby-simple { padding: 8px; }
  .lobby-brand h1 { font-size: 20px; }
  .lobby-brand .brand-mark { width: 31px; height: 31px; }
  .lobby-code { font-size: 25px; }
  .lobby-seat-list { gap: 5px; }
  .lobby-seat-avatar { width: min(100%, 52px); height: 54px; }
  .lobby-seat > strong, .vacant small { font-size: 9px; }
  .lobby-buttons { gap: 6px; }
  .lobby-buttons button { min-width: 0; flex: 1; padding: 8px; font-size: 12px; }

  .modal-backdrop { padding: 10px; }
  .modal { max-height: calc(100dvh - 20px); }
  .modal[aria-label="hand"] .hand-row { flex-wrap: wrap; max-height: none; }
  .modal[aria-label="hand"] .action-card { min-height: 64px; }
  .activity-history { padding-left: 20px; }
  .activity-history li { margin-bottom: 8px; font-size: 12px; }
  .card-detail { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .card-detail img { max-height: 44dvh; width: auto; max-width: 100%; justify-self: center; }
}

@media (max-width: 600px) and (orientation: portrait) and (max-height: 700px) {
  .game-shell > .table-surface:not(.lobby-table) { --opponent: clamp(54px, 10dvh, 74px); }
  .game-shell .objective { max-width: 45px; }
  .game-shell .objective-groups { padding: 3px; }
  .game-shell .opponents-row .cartoon-avatar { width: 23px; height: 25px; }
}
