/* Mobile-only guardrail for the external LIVE chat panel.
   Keep the working player and mixed source/Droxion messages unchanged.
   Only keep the existing Droxion gift row + composer usable above mobile browser chrome. */
@media (max-width: 720px) {
  .dxLiveModalSheet .dxExternalLiveLayout {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow-y: auto !important;
  }

  .dxLiveModalSheet .dxSourceChatPanel {
    order: 3 !important;
    flex: 0 0 max(500px, calc(100dvh - 58px - 56.25vw)) !important;
    height: max(500px, calc(100dvh - 58px - 56.25vw)) !important;
    min-height: 500px !important;
    max-height: none !important;
    overflow: hidden !important;
  }

  .dxLiveModalSheet .dxDroxionChat.dxUnifiedChat {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
    min-height: 500px !important;
    overflow: hidden !important;
  }

  .dxLiveModalSheet .dxUnifiedChatTop {
    flex: 0 0 auto !important;
  }

  .dxLiveModalSheet .dxUnifiedChatStream {
    flex: 1 1 auto !important;
    min-height: 260px !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    padding-bottom: 70px !important;
  }

  /* All five quick gifts + More stay visible in one row above the type bar. */
  .dxLiveModalSheet .dxQuickGiftRail {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: calc(164px + env(safe-area-inset-bottom)) !important;
    z-index: 10058 !important;
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 6px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 8px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    background: #0f131c !important;
    border-top: 1px solid rgba(123,153,202,.12) !important;
  }

  .dxLiveModalSheet .dxQuickGiftRail > button {
    min-width: 0 !important;
    width: 100% !important;
    margin: 0 !important;
  }

  /* Message on Droxion + send button sit above Safari / in-app browser controls. */
  .dxLiveModalSheet .dxDroxionComposer {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 10059 !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 7px 8px !important;
    box-sizing: border-box !important;
    background: #0f131c !important;
    border-top: 1px solid rgba(123,153,202,.12) !important;
  }

  .dxLiveModalSheet .dxDroxionComposer input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }

  .dxLiveModalSheet .dxDroxionComposer .dxCoinsButton,
  .dxLiveModalSheet .dxDroxionComposer .dxGiftButton,
  .dxLiveModalSheet .dxDroxionComposer .dxSendButton {
    flex: 0 0 auto !important;
  }

  .dxLiveModalSheet .dxDroxionComposer .dxSendButton {
    min-width: 54px !important;
  }

  /* The opened gift/source sheet must render above the pinned gift rail and composer. */
  .dxLiveModalSheet .dxGiftBackdrop,
  .dxLiveModalSheet .dxSourceComposerBackdrop {
    z-index: 10070 !important;
  }

  /* If chat cannot send (for example the preview has no Droxion session), show the reason above the fixed controls. */
  .dxLiveModalSheet .dxDroxionChatNotice {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    bottom: calc(220px + env(safe-area-inset-bottom)) !important;
    z-index: 10061 !important;
    margin: 0 !important;
  }

  /* Coin button opens the existing Droxion Wallet / plans above the LIVE modal. */
  .walletOverlay {
    z-index: 10100 !important;
  }
}

@media (max-width: 430px) {
  .dxLiveModalSheet .dxSourceChatPanel,
  .dxLiveModalSheet .dxDroxionChat.dxUnifiedChat {
    min-height: 520px !important;
  }

  .dxLiveModalSheet .dxUnifiedChatStream {
    min-height: 280px !important;
  }
}

/* Installed/standalone app has no Safari bottom toolbar, so use the true app bottom. */
@media (display-mode: standalone) and (max-width: 720px) {
  .dxLiveModalSheet .dxDroxionComposer {
    bottom: env(safe-area-inset-bottom) !important;
  }

  .dxLiveModalSheet .dxQuickGiftRail {
    bottom: calc(68px + env(safe-area-inset-bottom)) !important;
  }

  .dxLiveModalSheet .dxDroxionChatNotice {
    bottom: calc(124px + env(safe-area-inset-bottom)) !important;
  }
}
