/* Landscape phones: real viewport, no document rotation.
   Content sits between the bars, inside the notch, and scrolls instead of clipping. */

@media (orientation: landscape) and (max-height: 540px) {
  .navbar {
    padding:
      4px
      max(12px, env(safe-area-inset-right, 0px))
      4px
      max(12px, env(safe-area-inset-left, 0px));
  }

  .navbar-brand-logo {
    height: 32px;
    max-width: min(120px, 28vw);
  }

  .navbar-balance-chip,
  .navbar-profile {
    padding-top: 2px;
    padding-bottom: 2px;
  }

  .bottom-navbar {
    --bnav-height: 40px;
    padding:
      2px
      max(8px, env(safe-area-inset-right, 0px))
      calc(2px + env(safe-area-inset-bottom, 0px))
      max(8px, env(safe-area-inset-left, 0px));
  }

  .bnav-label {
    display: none;
  }

  #lobby {
    top: 40px;
    right: env(safe-area-inset-right, 0px);
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    left: env(safe-area-inset-left, 0px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
  }

  #lobby .lobby-center {
    position: fixed !important;
    left: 50% !important;
    top: 50% !important;
    width: 270px !important;
    max-width: 270px !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 6px;
    transform: translate(-50%, -50%) scale(0.62) !important;
    transform-origin: center center !important;
    z-index: 80;
  }

  #lobby .lobby-card,
  #lobby .tournament-teaser {
    width: 100%;
  }

  .history-page,
  .profile-page,
  .tournament-page {
    top: 40px;
    right: env(safe-area-inset-right, 0px);
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    left: env(safe-area-inset-left, 0px);
    width: auto;
    height: auto;
    max-height: none;
    padding: 8px 12px 10px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    zoom: 1;
  }

  .history-panel,
  .profile-content {
    width: min(100%, 720px);
    margin-right: auto;
    margin-left: auto;
    min-height: 0;
    overflow: visible;
  }

  .history-header h1 {
    font-size: 1.05rem;
    margin-bottom: 2px;
  }

  .history-subtitle {
    font-size: 0.75rem;
  }

  .history-tabs {
    gap: 4px;
  }

  .history-tab {
    height: 32px;
    font-size: 0.72rem;
  }

  .history-list {
    overflow: visible;
    max-height: none;
  }

  .profile-content {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
    gap: 8px;
    align-items: start;
  }

  .profile-hero {
    grid-column: 1;
    grid-row: 1 / span 2;
    padding: 10px;
  }

  .profile-balance-card,
  .profile-content > .profile-card:nth-child(3) {
    grid-column: 2;
  }

  .profile-content > .profile-card:nth-child(4) {
    grid-column: 1 / -1;
  }

  .profile-avatar-wrap {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
  }

  .profile-username {
    font-size: 1rem;
  }

  .profile-btn {
    height: 34px;
    flex: 1 1 120px;
  }

  .profile-card {
    padding: 10px;
  }

  .tx-modal {
    width: min(520px, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px));
    max-height: calc(100svh - 16px);
    margin: auto;
  }

  .tx-modal-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    max-height: calc(100svh - 16px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tx-modal-title {
    font-size: 1rem;
  }

  .tx-modal-close {
    width: 30px;
    height: 30px;
  }

  .tx-modal-submit {
    height: 40px;
    flex-shrink: 0;
  }

  .tx-modal-hint {
    white-space: normal;
  }
}
