/* Mobile layout fix - 2026-06-18
   Keep this file loaded after the older connect-v* fixes. */

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

* {
  box-sizing: border-box;
}

img,
video,
iframe {
  max-width: 100%;
}

/* Logo guard: the logo file is square-ish (133x136). Older markup
   had a wide ratio, so keep width/height paired to prevent stretching. */
.brand-typing-wrap {
  align-items: center !important;
}

.brand-typing-wrap .brand {
  display: inline-flex !important;
  align-items: center !important;
  flex: 0 0 auto !important;
  line-height: 0 !important;
}

.brand-typing-wrap .brand img {
  display: block !important;
  width: auto !important;
  height: 68px !important;
  max-width: none !important;
  max-height: 68px !important;
  object-fit: contain !important;
}

.rd-navbar-static .brand-typing-wrap .brand img {
  height: 68px !important;
  max-height: 68px !important;
}

.rd-navbar-fixed .brand-typing-wrap .brand img {
  height: 58px !important;
  max-height: 58px !important;
}

@media (min-width: 1200px) and (max-width: 1399px) {
  .hero-video-slide .hero-grid,
  .hero-grid {
    grid-template-columns: 240px minmax(620px, 1fr) 280px !important;
    gap: 14px !important;
  }

  .hero-center-stack {
    grid-template-columns: minmax(330px, 1fr) 250px !important;
    gap: 12px !important;
  }

  .connect-chat-shell,
  .live-chat-shell {
    width: 250px !important;
    min-width: 0 !important;
  }

  .arcade-shell {
    min-width: 0 !important;
  }
}

@media (max-width: 1199px) {
  html,
  body,
  .page,
  .swiper-container,
  .swiper-wrapper,
  .swiper-slide,
  .hero-video-slide,
  .swiper-slide-caption.hero-dashboard {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow-x: hidden !important;
  }

  .swiper-slider-2,
  .swiper-slider-2 .swiper-wrapper,
  .swiper-slider-2 .swiper-slide {
    height: auto !important;
    min-height: 100dvh !important;
  }

  .hero-video-slide {
    background-size: cover !important;
    background-position: center top !important;
  }

  .hero-dashboard {
    display: block !important;
    align-items: stretch !important;
    padding: 92px 0 26px !important;
  }

  .hero-dashboard .container {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .hero-grid {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "games"
      "center"
      "news"
      "music" !important;
    overflow: visible !important;
  }

  .hero-market-card,
  .connect-games-card,
  .hero-center-stage,
  .hero-center-stack,
  .arcade-shell,
  .connect-chat-shell,
  .live-chat-shell,
  .hero-news-card,
  .hero-trending-card,
  .hero-trending-bottom,
  .x-feed-shell {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    justify-self: stretch !important;
    align-self: stretch !important;
  }

  .hero-market-card,
  .connect-games-card {
    order: 1 !important;
  }

  .hero-center-stage {
    order: 2 !important;
    display: block !important;
  }

  .hero-news-card {
    order: 3 !important;
  }

  .hero-trending-card,
  .hero-trending-bottom {
    order: 4 !important;
  }

  .hero-center-stack {
    display: flex !important;
    flex-direction: column !important;
    gap: 14px !important;
    grid-template-columns: 1fr !important;
  }

  .hero-market-card,
  .hero-news-card,
  .arcade-shell,
  .connect-chat-shell,
  .hero-trending-bottom {
    border-radius: 18px !important;
  }

  .connect-games-list {
    display: flex !important;
    gap: 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: none !important;
    padding-bottom: 6px !important;
    scroll-snap-type: x proximity !important;
  }

  #connect-games-list .connect-game-item,
  .connect-game-item {
    flex: 0 0 min(78vw, 285px) !important;
    min-width: 0 !important;
    scroll-snap-align: start !important;
  }

  .arcade-shell,
  .arcade-shell.mode-iframe,
  .arcade-shell.mode-message {
    min-height: 0 !important;
    height: auto !important;
    padding: 12px !important;
  }

  .arcade-topbar {
    align-items: flex-start !important;
    gap: 10px !important;
  }

  .arcade-actions {
    width: 100% !important;
    justify-content: flex-start !important;
  }

  .arcade-shell .game-wrap,
  .arcade-shell.mode-iframe .game-wrap,
  .game-wrap {
    flex: 0 0 auto !important;
    width: 100% !important;
    height: clamp(300px, 58dvh, 420px) !important;
    min-height: 300px !important;
    max-height: 420px !important;
  }

  #space-game,
  #connect-dynamic-game-frame.game-frame {
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 100% !important;
  }

  .connect-select-placeholder .panel {
    min-width: 0 !important;
    width: min(100%, 260px) !important;
    padding: 14px !important;
  }

  .connect-select-placeholder strong,
  .connect-select-placeholder h4,
  .game-panel h4 {
    font-size: 20px !important;
    line-height: 1.15 !important;
    overflow-wrap: anywhere !important;
  }

  .connect-chat-shell,
  .live-chat-shell {
    min-height: 320px !important;
    height: auto !important;
    max-height: none !important;
    padding: 14px !important;
  }

  .hero-news-card {
    max-height: none !important;
    overflow: visible !important;
    padding: 14px !important;
  }

  .news-feed,
  #news-feed,
  .x-feed-list {
    height: auto !important;
    max-height: none !important;
    overflow-y: visible !important;
    padding-right: 0 !important;
  }

  .news-item {
    width: 100% !important;
    min-width: 0 !important;
  }

  .news-body,
  .news-meta,
  .news-text,
  .x-post,
  .x-meta,
  .x-title {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
  }

  .hero-trending-bottom {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 14px !important;
  }

  .trending-feed,
  #music-trending-feed {
    display: flex !important;
    gap: 12px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding-bottom: 6px !important;
    scroll-snap-type: x proximity !important;
  }

  .music-spotlight-item,
  .connect-collection-card {
    flex: 0 0 min(82vw, 300px) !important;
    min-width: 0 !important;
    scroll-snap-align: start !important;
  }

  .social-sidebar,
  .social-fixed {
    display: none !important;
  }

  .cookiealert {
    padding: 10px 12px !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
  }

  .cookiealert .acceptcookies {
    display: inline-flex !important;
    margin-top: 8px !important;
  }
}

@media (max-width: 560px) {
  .hero-dashboard {
    padding-top: 82px !important;
  }

  .hero-dashboard .container {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .brand-typing-wrap {
    gap: 6px !important;
  }

  .brand-typing-fixed {
    display: inline-block !important;
    max-width: 176px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 10px !important;
    letter-spacing: .03em !important;
  }

  .rd-navbar-fixed .brand-typing-wrap .brand img,
  .brand-typing-wrap .brand img {
    width: auto !important;
    height: 58px !important;
    max-height: 58px !important;
    max-width: none !important;
    object-fit: contain !important;
  }

  .hero-grid {
    gap: 12px !important;
  }

  .hero-market-card,
  .hero-news-card,
  .arcade-shell,
  .connect-chat-shell,
  .hero-trending-bottom {
    border-radius: 16px !important;
  }

  .arcade-shell .game-wrap,
  .arcade-shell.mode-iframe .game-wrap,
  .game-wrap {
    height: clamp(280px, 56dvh, 380px) !important;
    min-height: 280px !important;
    max-height: 380px !important;
  }

  .connect-chat-shell,
  .live-chat-shell {
    min-height: 520px !important;
    height: min(78dvh, 680px) !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .connect-chat-shell .chat-messages,
  .connect-chat-shell #chat-messages,
  .live-chat-shell .chat-messages,
  .live-chat-shell #chat-messages {
    min-height: 340px !important;
    height: auto !important;
    flex: 1 1 auto !important;
    max-height: none !important;
    font-size: 14px !important;
  }

  .connect-chat-shell .chat-message,
  .live-chat-shell .chat-message {
    padding: 10px 12px !important;
    border-radius: 14px !important;
  }

  .connect-chat-shell .chat-text,
  .live-chat-shell .chat-text {
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  .connect-chat-shell #chat-input,
  .live-chat-shell #chat-input {
    min-height: 46px !important;
    font-size: 15px !important;
  }

  .connect-chat-shell #chat-send-btn,
  .connect-chat-shell #emoji-toggle-btn,
  .live-chat-shell #chat-send-btn,
  .live-chat-shell #emoji-toggle-btn {
    width: 46px !important;
    height: 46px !important;
    min-width: 46px !important;
  }

  .market-title,
  .news-title,
  .connect-games-titlebar {
    gap: 8px !important;
  }

  .market-title h3,
  .news-title h3 {
    font-size: 18px !important;
  }

  .news-item {
    gap: 10px !important;
    padding: 10px !important;
  }

  .news-thumb,
  #news-feed .news-thumb {
    width: 58px !important;
    min-width: 58px !important;
    height: 58px !important;
  }
}

@media (max-width: 380px) {
  .brand-typing-fixed {
    max-width: 140px !important;
    font-size: 9px !important;
  }

  .rd-navbar-fixed .brand-typing-wrap .brand img,
  .brand-typing-wrap .brand img {
    height: 52px !important;
    max-height: 52px !important;
  }
}

/* CONNECT_MOBILE_SCROLL_TOUCH_V6 */
@media (max-width: 767px) {
  html,
  body {
    overscroll-behavior-y: auto !important;
    scroll-behavior: auto !important;
  }

  .hero-grid,
  .hero-market-card,
  .hero-news-card,
  .hero-trending-bottom,
  .connect-chat-shell {
    touch-action: pan-y !important;
  }

  .connect-games-list {
    touch-action: pan-x pan-y !important;
  }

  .arcade-shell.mode-iframe .game-wrap,
  .arcade-shell.mode-iframe #game-wrap,
  #connect-dynamic-game-frame.game-frame:not(.hidden) {
    touch-action: none !important;
  }
}
