/* =========================================================
   OLD ZOMBIE v15 — мобильная версия для всех страниц
   Подключается последним. Планшет ≤ 991px, телефон ≤ 767px, маленький ≤ 400px
   ========================================================= */

/* ---------- Общее: никакого горизонтального скролла ---------- */
html, body { max-width: 100%; overflow-x: hidden; }
img, video, iframe { max-width: 100%; }
.main, .shell, .panel, .pad { min-width: 0; }
pre, code { white-space: pre-wrap; word-break: break-word; }
.mnav-menu { border: 0; background: none; padding: 0; font: inherit; cursor: pointer; }

/* ---------- Боковое меню: всегда прокручивается ---------- */
@media (max-width: 1279px) {
  .sidebar { width: min(300px, 86vw); overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-bottom: env(safe-area-inset-bottom); }
  .sb-nav, .sb-nav-v14 { overflow: visible; flex: none; }
  .sb-group.open .sb-submenu { max-height: 400px; }
  .sb-sublink, .sb-link, .sb-group-toggle { min-height: 46px; }
}

/* =========================================================
   ПЛАНШЕТ ≤ 991px
   ========================================================= */
@media (max-width: 991px) {
  .cab-grid, .srv-grid, .nt-grid, .doc-grid, .settings-grid, .pgrid, .rules-wrap,
  .vip-buy, .vip2-inner, .shots, .friend-add-panel, .adm-two, .cab-two, .vipx-two,
  .board-duo, .ticket-card-grid, .store-hero-in, .photo-stage { grid-template-columns: 1fr !important; }
  .srv-side, .board-side { grid-template-columns: 1fr 1fr; }
  .doc-grid > aside, .doc-grid > nav { position: static !important; }
  .post { grid-template-columns: 1fr !important; }
  .post > :first-child { display: flex; align-items: center; gap: 12px; text-align: left; }
  .top-head-stats { width: 100%; }
  .top-head-stats > div { flex: 1; min-width: 0; }
  .shop15-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* =========================================================
   ТЕЛЕФОН ≤ 767px
   ========================================================= */
@media (max-width: 767px) {
  :root { --pad: 14px; }

  /* Типографика */
  h1 { font-size: 24px; }
  .page-title h1, .top-head h1 { font-size: 24px !important; }
  .page-title { flex-direction: column; align-items: flex-start !important; gap: 12px; }
  .page-title > * { max-width: 100%; }
  .page-shell { padding-top: 16px; padding-bottom: 24px; }

  /* Сетки → одна колонка */
  .srv-side, .board-side, .friends-grid, .cat-grid, .help-start, .shop-history-grid,
  .shop-info, .vip2-grid, .vipx-grid, .perk-grid, .store-grid, .store-grid-v14, .shop-grid,
  .friend-requests, .server-friend-list, .gift-friend-list, .ban-card, .achievements,
  .shop15-faq, .vs-options, .cat-pick { grid-template-columns: 1fr !important; }
  .help-tiles, .quick, .srv-kpis, .ban-kpis, .adm-kpis, .vip2-numbers, .stat-grid, .cab-main .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .friend-meta { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* Панели и заголовки */
  .panel { border-radius: 14px; }
  .panel-head { flex-wrap: wrap; gap: 8px; }
  .panel-head h2 { min-width: 0; }
  .section-head, .friends-section-head, .topic-head, .reply-head, .order-head, .catalog-heading { flex-direction: column; align-items: flex-start !important; gap: 10px; }

  /* Кнопки удобного размера для пальца */
  .btn-neon, .btn-violet, .btn-ghost-oz, .btn-outline-dark-oz, .btn-gift, .btn-owned, .btn-steam { min-height: 44px; }
  .hero-actions > *, .error-actions > * { width: 100%; justify-content: center; }
  .error-actions { flex-direction: column; }

  /* Формы: 16px — чтобы iPhone не зумил поле */
  input, select, textarea, .oz-input, .form-control, .form-select { font-size: 16px !important; }
  .oz-form .row { row-gap: 12px; }
  .friend-search-form, .tb-search { grid-template-columns: 1fr; }
  textarea { min-height: 120px; }

  /* Вкладки → горизонтальная лента */
  .oz-tabs, .adm-tabs, .store-tabs, .nav-tabs, .nav-pills {
    flex-wrap: nowrap !important; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
  }
  .oz-tabs::-webkit-scrollbar, .adm-tabs::-webkit-scrollbar, .store-tabs::-webkit-scrollbar, .nav-tabs::-webkit-scrollbar { display: none; }
  .oz-tabs > *, .adm-tabs > *, .store-tabs > *, .nav-tabs > *, .nav-pills > * { flex: none; white-space: nowrap; scroll-snap-align: start; }

  /* Выпадашки в шапке (уведомления, баланс, профиль) — на всю ширину */
  .topbar .dropdown-menu.notify-dd,
  .topbar .dropdown-menu.wallet-dd,
  .topbar .dropdown-menu.oz-dropdown {
    position: fixed !important; inset: calc(var(--tb) + 6px) 10px auto 10px !important;
    transform: none !important; width: auto !important; min-width: 0 !important;
    max-height: calc(100vh - var(--tb) - 110px); overflow-y: auto; border-radius: 16px;
  }
  .tb-balance { padding: 0 10px; }
  .tb-balance b { font-size: 12px; }
  .tb-actions { margin-left: auto; }

  /* Модальные окна → «шторка» снизу */
  .modal-dialog { margin: 0; max-width: none !important; min-height: 100%; display: flex; align-items: flex-end; }
  .modal.fade .modal-dialog { transform: translateY(40px); }
  .modal.show .modal-dialog { transform: none; }
  .modal-content { width: 100%; border-radius: 20px 20px 0 0 !important; max-height: 92vh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
  .photo-modal-dialog { align-items: center; }
  .photo-modal-content { border-radius: 16px !important; margin: 10px; }
  .buy-actions { display: grid !important; grid-template-columns: 1fr 1fr; gap: 8px; }
  .buy-actions #buySubmit { grid-column: 1 / -1; order: -1; }
  .buy-actions > * { width: 100%; justify-content: center; }
  .buy-rows > div { gap: 10px; }

  /* Таблицы → карточки (подписи ставит app.js из заголовков) */
  .table-wrap { overflow: visible; }
  table.m-cards, table.m-cards tbody, table.m-cards tr, table.m-cards td { display: block; width: 100%; }
  table.m-cards thead { display: none; }
  table.m-cards tbody tr { margin: 10px; width: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, .02); }
  table.m-cards tbody tr.empty-row { border: 0; background: none; }
  table.m-cards td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0 !important; border: 0 !important; text-align: right; min-width: 0; }
  table.m-cards td + td { border-top: 1px dashed var(--line) !important; }
  table.m-cards td[data-label]::before { content: attr(data-label); flex: none; color: var(--dim); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; text-align: left; }
  table.m-cards td[colspan] { display: block; text-align: center; }
  table.m-cards td[colspan]::before { display: none; }
  table.m-cards td > * { min-width: 0; }
  table.m-cards td form, table.m-cards td .btn-group { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  table.m-cards .pl-cell b { max-width: 150px; }
  /* Столбцы, которые на старых стилях скрывались — в карточках снова видны */
  table.m-cards.top-table td:nth-child(4), table.m-cards.top-table td:nth-child(7) { display: flex; }
  table.m-cards tbody tr:hover td { background: none !important; }

  /* ---------- Топ ---------- */
  .top-head-stats { gap: 8px; }
  .top-head-stats > div { padding: 8px; }
  .top-head-stats b { font-size: 16px; }
  .podium-v15 { grid-template-columns: 1fr; gap: 10px; }
  .podium-v15 .pod-1 { order: -1; }
  .pod { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; text-align: left; padding: 14px !important; gap: 4px 12px; }
  .pod img, .pod-1 img { width: 54px; height: 54px; }
  .pod-medal { position: absolute; top: 10px; right: 10px; }
  .pod-name { flex: 1; min-width: 0; }
  .pod-badges, .pod-kills, .pod-meta { width: 100%; justify-content: flex-start; padding-left: 66px; margin-top: -2px; }
  .pod-kills b { font-size: 18px; }
  .top-toolbar { flex-direction: column; align-items: stretch; }
  .top-toolbar .oz-search-inline { max-width: none; }
  #topTable.m-cards tbody tr.podium-row { display: none; }
  #topTable.m-cards tbody tr:not(.empty-row) { display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 10px; }
  #topTable td:nth-child(1) { grid-row: span 7; align-items: flex-start; justify-content: center; border: 0 !important; }
  #topTable td:nth-child(1)::before { display: none; }
  #topTable td:nth-child(2) { justify-content: flex-start; border: 0 !important; }
  #topTable td:nth-child(2)::before { display: none; }
  .top-me { padding: 10px 12px; }

  /* ---------- Магазин ---------- */
  .shop15-hero-in { padding-top: 22px; padding-bottom: 22px; gap: 18px; }
  .shop15-hero h1 { font-size: 28px; }
  .shop15-steps { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .shop15-steps li { flex: none; }
  .shop15-wallet .w-top b { font-size: 24px; }
  .shop15-bar { top: var(--tb); padding-top: 10px; padding-bottom: 10px; gap: 10px; }
  .shop-chips { margin: 0 calc(var(--pad) * -1); padding: 0 var(--pad); }
  .shop-chips a { height: 38px; padding: 0 12px; }
  .shop-tools { display: grid; grid-template-columns: 1fr 130px; }
  .shop-sort { width: 100%; }
  .shop15-grid { grid-template-columns: 1fr; gap: 12px; }
  .pc-visual { height: 150px; }
  .t-model .pc-visual { height: 280px; }
  .pc-foot { flex-wrap: wrap; }
  .pc-actions { flex: 1; justify-content: flex-end; }
  .pc-buy { flex: 1; justify-content: center; max-width: 220px; }
  .order-body .order-done { flex-direction: column; align-items: flex-start; }
  .order-done .btn-neon { width: 100%; justify-content: center; }
  .friends-shop-cta { grid-template-columns: 1fr !important; text-align: center; justify-items: center; }
  .gift-preset { flex-wrap: wrap; }
  .vs-cmd code { display: block; margin-top: 6px; }

  /* ---------- Форум / темы ---------- */
  .trow { grid-template-columns: 38px minmax(0, 1fr) auto !important; }
  .trow-last, .trow > :nth-child(n+4) { display: none !important; }
  .forum-stats { flex-wrap: wrap; }
  .post { padding: 14px !important; }
  .post img { max-width: 100%; height: auto; }
  .post-body, .topic-body { overflow-wrap: anywhere; }
  .ticket-card { padding: 14px; }

  /* ---------- Профиль / игрок ---------- */
  .profile-actions { grid-template-columns: 1fr 1fr !important; width: 100%; }
  .player-hero, .srv-hero-body, .doc-hero-body, .friends-hero-in { flex-direction: column; align-items: flex-start !important; text-align: left; }
  .wallet-card-actions, .wd-actions, .store-wallet-actions { grid-template-columns: 1fr 1fr; }
  .transfer .row > * { width: 100%; }
  .level-card { flex-direction: column; align-items: flex-start; }

  /* ---------- Друзья ---------- */
  .friend-card-head { grid-template-columns: auto 1fr !important; }
  .friend-card-head > :last-child { grid-column: 1 / -1; }
  .friend-card-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .friend-card-actions > * { width: 100%; justify-content: center; }
  .friend-request-row { flex-wrap: wrap; }

  /* ---------- Сервер / баны ---------- */
  .srv-bar, .sc-bar { flex-wrap: wrap; }
  .ban-card > * { min-width: 0; }
  .cmd-list > div { grid-template-columns: 1fr !important; gap: 6px; }

  /* ---------- VIP ---------- */
  .vip2-hero h1, .vip2-hero .h1 { font-size: 30px; }
  .period-opt { flex-wrap: wrap; }

  /* ---------- Правила / помощь ---------- */
  .rule-list li { grid-template-columns: 34px minmax(0, 1fr) !important; }
  .rule-list li > :nth-child(3) { grid-column: 2; }
  .faq-list summary, .oz-accordion .accordion-button { font-size: 14px; }

  /* ---------- Админка ---------- */
  .adm-list li { flex-wrap: wrap; gap: 8px; }
  .adm-list li > a { min-width: 0; flex: 1 1 200px; }
  .adm-table-wrap, .adm-scroll { overflow-x: auto; }
  .mod-bar { flex-wrap: wrap; gap: 8px; }
  .mod-bar > * { flex: 1 1 140px; }

  /* ---------- Уведомления ---------- */
  .notify-item > button { grid-template-columns: auto 1fr !important; }
  .notify-dot { position: absolute; right: 12px; top: 14px; }

  /* ---------- Подвал и нижнее меню ---------- */
  .footer-cols { grid-template-columns: 1fr 1fr !important; }
  .mnav-item span { white-space: nowrap; }
  .oz-toast { z-index: 1090; }
}

/* =========================================================
   МАЛЕНЬКИЕ ТЕЛЕФОНЫ ≤ 400px
   ========================================================= */
@media (max-width: 400px) {
  :root { --pad: 12px; }
  .help-tiles, .quick, .srv-kpis, .ban-kpis, .adm-kpis, .ach-grid { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .footer-cols { grid-template-columns: 1fr !important; }
  .profile-actions { grid-template-columns: 1fr !important; }
  .shop-tools { grid-template-columns: 1fr; }
  .top-head-stats b { font-size: 14px; }
  .tb-balance b { display: none; }
  .avatar-pick { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
}

/* Горизонтальная ориентация телефона: шторка не на весь экран */
@media (max-height: 500px) and (orientation: landscape) {
  .modal-content { max-height: 96vh; }
  .mnav { height: 56px; }
  .mnav-play-btn { width: 50px; height: 50px; margin-top: -22px; }
}
