/**
 * Rumirf — мобильная адаптация (форум, профиль, кастомизация, рейтинг, кланы)
 * Touch-friendly: минимум 44px для кликабельных элементов
 */

@media (max-width: 1024px) {
  .header-nav { display: none; }
  .mobile-menu-btn { display: block !important; }
  .forum-header-shell { position: sticky; top: 0; z-index: 1000; }
  .top-strip {
    position: relative;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 14px !important;
  }
  .header-nav.open {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(9, 9, 16, 0.98);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    padding: 12px 14px;
    gap: 4px;
    z-index: 1001;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  }
  .header-nav.open .header-nav-link {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    border-radius: 12px;
    min-height: 44px;
    line-height: 1.25;
    text-align: center;
  }
  /* Форум: без sticky :hover на тач-экранах — только класс .open */
  .header-nav-dropdown:hover .header-dd-menu {
    display: none !important;
    pointer-events: none !important;
  }
  .header-nav-dropdown.open .header-dd-menu {
    display: block !important;
    pointer-events: auto !important;
  }
  .header-nav.open .header-nav-dropdown {
    display: block;
    width: 100%;
    margin: 0;
  }
  .header-nav.open .header-nav-dd-trigger,
  .header-nav.open #forumDDBtn {
    width: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    margin: 0;
  }
  .header-nav.open .header-dd-menu {
    display: none !important;
    position: static;
    transform: none;
    left: auto;
    min-width: 0;
    width: 100%;
    padding-top: 0;
  }
  .header-nav.open .header-nav-dropdown.open .header-dd-menu {
    display: block !important;
    pointer-events: auto !important;
  }
  .header-nav.open .header-dd-panel {
    background: rgba(139, 92, 246, 0.08);
    border: none;
    box-shadow: none;
    margin-top: 4px;
    padding: 4px 8px;
  }
  .header-nav.open .dd-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .top-strip-right {
    margin-left: auto;
    flex-wrap: wrap;
    gap: 8px 10px;
    max-width: 100%;
    justify-content: flex-end;
  }
  .top-auth-nick {
    flex: 1 1 100%;
    max-width: 100%;
    min-width: 0;
    order: 3;
    text-align: center;
    padding: 4px 8px;
  }
  .top-strip-right .btn {
    flex-shrink: 0;
  }
}

@media (max-width: 768px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body {
    overflow-x: hidden;
  }

  .mobile-menu-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 8px 12px;
    flex-shrink: 0;
  }

  button,
  .btn,
  a.btn,
  input[type="submit"],
  input[type="button"],
  .dash-action-btn,
  .header-nav-link,
  .nav-tab,
  .tab,
  .pill,
  .paletteToggleBtn,
  .outfit-btn-ghost,
  .outfit-save-gta,
  .forum-cat-card,
  .itemCard {
    min-height: 44px;
  }

  .container,
  main.container,
  .dashboard-wrap,
  .wrap,
  .banner-wrap {
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    box-sizing: border-box;
  }

  /* ——— Forum dashboard ——— */
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    align-items: stretch !important;
  }
  .dash-profile,
  .dash-actions,
  .dash-center,
  .dash-news {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
  .dash-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px !important;
  }
  .dash-action-btn.play,
  .dash-action-btn[data-hub="play"] {
    grid-column: 1 / -1;
  }
  .dash-profile-avatar-wrap {
    min-height: 100px;
  }
  .dash-center-body {
    min-height: 0;
  }
  .dash-section-host .donate-packages {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  }

  body.forum-page-donate .dashboard-grid {
    grid-template-columns: 1fr !important;
  }
  body.forum-page-donate .dash-profile,
  body.forum-page-donate .dash-actions {
    display: none !important;
  }

  /* Forum hub */
  .forum-hub-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .forum-welcome-banner {
    flex-wrap: wrap;
    padding: 12px 14px;
    gap: 10px;
  }
  .forum-welcome-text span {
    display: block;
    margin-top: 4px;
  }
  .forum-cat-card {
    grid-template-columns: 40px 1fr;
    padding: 10px 12px;
    gap: 10px;
  }
  .forum-cat-latest {
    display: none;
  }

  /* Nav tabs (forum categories) */
  .nav-content {
    grid-template-columns: 1fr 1fr !important;
    left: 0 !important;
    right: 0 !important;
    padding: 8px 12px !important;
  }
  .nav-content .search-icon {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-height: 44px;
  }
  .nav-content a.nav-tab {
    min-height: 44px;
    justify-content: center;
    padding: 10px 8px;
    font-size: 0.82rem;
  }

  /* Create topic fullscreen */
  body.forum-creating .card#create {
    padding: 12px !important;
    margin: 0 !important;
    border-radius: 0 !important;
  }
  body.forum-creating #bodyEditor {
    min-height: 220px !important;
  }

  /* Thread list rows */
  #threadsList .forum-row {
    grid-template-columns: 1fr !important;
    gap: 8px;
    padding: 12px !important;
  }

  /* ——— Profile ——— */
  .profile-panel .profile-hero {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center;
    padding: 14px 12px !important;
    gap: 12px;
  }
  .profile-panel .profile-avatar-col {
    flex-direction: column;
    width: 100%;
    align-items: center;
  }
  .profile-panel .profile-actions {
    flex-direction: column;
    width: 100%;
    max-width: 280px;
  }
  .profile-panel .profile-actions .btn {
    width: 100%;
  }
  .profile-panel .profile-meta {
    width: 100%;
    min-width: 0;
  }
  .profile-panel #profileAvatarBox {
    width: 140px !important;
    height: 140px !important;
  }
  .profile-equip-col {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 200px;
    align-self: stretch !important;
  }
  .profile-body {
    padding: 14px 12px 24px !important;
  }
  .profile-content-grid {
    grid-template-columns: 1fr !important;
  }
  .profile-panel .tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .profile-panel .tabs::-webkit-scrollbar {
    display: none;
  }
  .profile-panel .tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
    min-width: max-content;
    padding: 10px 14px;
  }
  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)) !important;
    gap: 6px;
  }
  .profile-clan-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .profile-info-grid {
    grid-template-columns: 1fr !important;
  }
  .profile-info-grid .info-label {
    padding-top: 8px;
    border-top: 1px solid rgba(139, 92, 246, 0.08);
  }
  .profile-info-grid .info-label:first-of-type {
    border-top: none;
    padding-top: 0;
  }

  /* ——— Outfit / customization ——— */
  .outfit-studio {
    min-height: 100dvh;
    height: auto;
  }
  .outfit-layout {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr !important;
    height: auto !important;
    min-height: 0;
  }
  .outfit-stage {
    border-right: none;
    border-bottom: 1px solid rgba(255, 0, 120, 0.15);
    max-height: none;
    padding: 12px;
  }
  .outfit-preview-card {
    max-width: 280px;
  }
  .outfit-topbar {
    padding: 10px 12px;
    gap: 10px;
  }
  .outfit-topbar-left {
    width: 100%;
  }
  .outfit-topbar-right {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .outfit-topbar-right .outfit-save-gta {
    grid-column: 1 / -1;
  }
  .outfit-topbar-right .outfit-btn-ghost,
  .outfit-topbar-right .outfit-save-gta {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .outfit-catalog {
    padding: 12px !important;
    height: auto !important;
    min-height: 50vh;
  }
  .outfit-catalog .tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    grid-template-columns: unset !important;
  }
  .outfit-catalog .tab {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: 8px 12px;
  }
  .outfit-catalog .itemsGrid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)) !important;
    gap: 8px;
  }
  .outfit-catalog .slotTop {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .outfit-catalog .searchRow {
    flex-direction: column;
    align-items: stretch;
  }
  .outfit-catalog .searchRow .input {
    width: 100%;
    min-height: 44px;
  }
  .outfit-stage-actions {
    flex-wrap: wrap;
  }
  .outfit-stage-actions .btn {
    min-height: 44px;
  }

  /* ——— Rating ——— */
  .rating-top .grid3,
  .rating-bottom .grid3,
  .grid3 {
    grid-template-columns: 1fr !important;
  }
  .rating-top h1,
  .rating-bottom h2 {
    font-size: 1.25rem;
    padding: 0 4px;
  }
  .rating-top .list,
  .rating-bottom .list {
    max-height: none;
  }
  .row-first {
    min-height: auto !important;
    height: auto !important;
    max-height: none !important;
    flex-wrap: wrap;
    padding: 12px !important;
  }

  /* ——— Clans ——— */
  .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .chub-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .chub-left,
  .chub-right {
    position: static !important;
    max-height: none !important;
    display: grid !important;
  }
  .clan-studio {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    gap: 12px !important;
    padding: 0 10px 20px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }
  .clan-rail-left,
  .clan-rail-right,
  .clan-hub {
    display: block !important;
    position: static !important;
    max-height: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    grid-column: auto !important;
  }
  .clan-rail-right {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  .clan-rail-right .clan-rail-card {
    margin-bottom: 0 !important;
  }
  .clan-rail-nav {
    display: flex !important;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    margin-bottom: 10px;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .clan-rail-nav::-webkit-scrollbar {
    display: none;
  }
  .clan-rail-nav a,
  .clan-rail-nav button {
    flex: 0 0 auto;
    width: auto !important;
    white-space: nowrap;
    min-height: 44px;
    padding: 10px 14px !important;
  }
  .clan-rail-profile {
    text-align: left;
  }
  .clan-rail-profile .clan-rail-avatar {
    width: 64px !important;
    height: 64px !important;
    margin: 0 0 8px !important;
  }
  .clan-hub {
    min-width: 0;
    width: 100%;
  }
  .clan-hub-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
  }
  .clan-hub-tab {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
  }
  .clan-hub-toolbar {
    flex-wrap: wrap;
    justify-content: flex-start !important;
  }
  .clan-hub-toolbar .btn {
    min-height: 44px;
  }
  .clan-hero-banner {
    min-height: 120px;
  }
  .clan-hero-title {
    font-size: 1.25rem !important;
    word-break: break-word;
  }
  .clan-chat-hub {
    padding: 10px !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }
  .clan-chat-shell {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .clan-chat-panel,
  .clan-chat-members {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 10px !important;
  }
  .clan-chat-log {
    height: min(260px, 40vh) !important;
    max-width: 100% !important;
  }
  .clan-chat-members {
    max-height: 220px;
  }
  .clan-chat-input-row {
    flex-wrap: wrap !important;
    max-width: 100% !important;
    gap: 6px !important;
  }
  .clan-chat-input-wrap {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    max-width: 100% !important;
  }
  .clan-chat-input-wrap input {
    min-width: 0 !important;
  }
  .clan-chat-input-row > button {
    padding: 9px 12px !important;
    font-size: 0.78rem !important;
  }
  .clan-quick-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .my-clan-main {
    grid-template-columns: 1fr !important;
  }
  .my-clan-side {
    grid-template-columns: 1fr !important;
  }
  .portal-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .portal-toolbar .btn {
    min-height: 44px;
  }

  /* Вкладка «Мой клан» на /clans */
  #panel-my-clan,
  #myClanEmbedWrap {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
  }
  #myClanIframe,
  .my-clan-iframe {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 65vh !important;
    border-radius: 12px;
    display: block;
    box-sizing: border-box;
  }
  body.clans-focus-my-clan .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  body.clans-focus-my-clan .page-header > div:last-child {
    width: 100%;
    justify-content: stretch;
  }
  body.clans-focus-my-clan .tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 8px 10px !important;
    scrollbar-width: none;
  }
  body.clans-focus-my-clan .tabs::-webkit-scrollbar {
    display: none;
  }
  body.clans-focus-my-clan .tabs .tab {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: 10px 14px;
  }

  /* ——— Single clan page ——— */
  .clan-media-grid {
    grid-template-columns: 1fr !important;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .guide-grid {
    grid-template-columns: 1fr !important;
  }

  /* ——— Thread / topic view ——— */
  .topic-main-grid,
  .topic-comment-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
  .topic-author-col {
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px;
    padding: 0 0 8px !important;
    border-bottom: 1px solid rgba(139, 92, 246, 0.1);
  }
  .topic-comment-card .topic-author-col {
    padding-top: 0 !important;
  }
  .topic-avatar,
  .topic-comment-card .topic-avatar {
    width: 52px !important;
    height: 52px !important;
    flex-shrink: 0;
  }
  .topic-body-col,
  .topic-comment-body {
    padding-top: 10px !important;
  }
  .topic-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .topic-actions .btn {
    min-height: 44px;
  }
  #replyForm textarea,
  #replyBody {
    min-height: 120px;
    font-size: 16px;
  }
  .reply-emoji-row {
    flex-wrap: wrap;
  }
  #replyFaceEmote {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
  }

  /* Modals */
  #dailyBonusModal .modal-card,
  .modal-card {
    max-width: calc(100vw - 24px) !important;
    margin: 12px;
  }
}

@media (max-width: 480px) {
  .dash-actions {
    grid-template-columns: 1fr !important;
  }
  .top-strip-left .logo-text {
    font-size: 1rem;
  }
  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)) !important;
  }
  .outfit-catalog .itemsGrid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)) !important;
  }
  .outfit-stage .palette {
    grid-template-columns: repeat(6, 1fr) !important;
  }
  .profile-clan-stats {
    grid-template-columns: 1fr 1fr !important;
  }
  .nav-content {
    grid-template-columns: 1fr !important;
  }
}

/* Mobile menu button (hidden on desktop) */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 1.25rem;
  padding: 6px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.mobile-menu-btn:hover {
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.1);
}
