/* ============================================================
   Poke-Kara — Mobile Design Override
   Modern layout: header + slide-out nav + chat redesign
   Inspired by screenshot 2 (Pallet Town style)
   ============================================================ */

@media (max-width: 768px) {
  /* ── Mobile Header Bar (game shell only) ── */
  .mob-header {
    display: flex !important;
  }

  /* Telegram-кнопка в витринном хедере: всегда видна на мобильных как иконка */
  .v-header__telegram {
    display: inline-flex !important;
    padding: 4px 8px;
    border-radius: 999px;
  }
  .v-header__telegram span {
    display: none;
  }
  .v-header__telegram-icon {
    margin: 0;
  }
}

/* Hide mobile header on desktop */
.mob-header {
  display: none;
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 110;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0));
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mob-header__profile {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}
.mob-header__profile:hover { text-decoration: none; color: inherit; }

.mob-header__profile-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
}
.mob-header__profile-wrap .mob-header__profile {
  flex: 1;
  min-width: 0;
}

/* Mobile profile dropdown (tooltip menu on tap) — выше бегущей строки (ticker z-index: 100) */
.mob-profile-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  min-width: 240px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,.15);
  z-index: 250;
  overflow: hidden;
}
.mob-profile-menu.mob-profile-menu--open {
  display: block;
}
.mob-profile-menu__header {
  padding: 12px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.mob-profile-menu__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.mob-profile-menu__list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
}
.mob-profile-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text);
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.mob-profile-menu__item:hover,
.mob-profile-menu__item:focus-visible {
  background: rgba(148,163,184,.12);
}
.mob-profile-menu__item--danger {
  color: #b91c1c;
}
.mob-profile-menu__item--danger:hover,
.mob-profile-menu__item--danger:focus-visible {
  background: rgba(254,202,202,.6);
}
.mob-profile-menu__icon {
  width: 22px;
  flex-shrink: 0;
  font-size: 16px;
}
.mob-profile-menu__label {
  flex: 1;
}
.mob-profile-menu__divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}
.mob-profile-menu__item button {
  all: unset;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 16px;
  margin: -10px -16px;
  font-size: 14px;
  color: inherit;
  cursor: pointer;
  font-family: inherit;
}

.mob-header__avatar-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mob-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary-weak), rgba(124,58,237,.12));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 18px;
  color: var(--primary);
  border: 2px solid var(--border);
}
.mob-header__avatar-wrap.tc-avatar-frame .mob-header__avatar {
  border-color: transparent;
}
.mob-header__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mob-header__name {
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mob-header__icons {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mob-header__icon {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  cursor: pointer;
  text-decoration: none;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.mob-header__icon .panel-icon{
  width: 26px;
  height: 26px;
  object-fit: contain;
  display:block;
}
.mob-header__icon .panel-icon-fb{
  font-size: 22px;
  line-height:1;
}
.mob-header__icon:hover {
  background: rgba(0,0,0,.06);
  color: var(--text);
}
.mob-header__icon--notif {
  position: relative;
}
.mob-header__icon--burger {
  font-size: 20px;
  padding: 0;
}

/* Кнопка «Эффекты» в шапке — рядом с ником */
.mob-header__icon--buffs {
  flex-shrink: 0;
  margin-left: 6px;
  font-size: 20px;
  color: #b45309;
  background: rgba(251, 191, 36, 0.2);
}
.mob-header__icon--buffs:hover {
  background: rgba(251, 191, 36, 0.35);
  color: #92400e;
}
.mob-header__icon--buffs.mob-header__icon--active {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
}

/* ── Mobile Nav Drawer (slide-out) ── */
.mob-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 998;
  opacity: 0;
  transition: opacity .25s;
}
.mob-nav-overlay.mob-nav-overlay--open {
  display: block;
  opacity: 1;
}

.mob-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: var(--card);
  z-index: 999;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(0.32,0.72,0,1);
  box-shadow: 4px 0 24px rgba(0,0,0,.12);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.mob-nav-drawer.mob-nav-drawer--open {
  transform: translateX(0);
}

.mob-nav-drawer__head {
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mob-nav-drawer__title {
  font-weight: 900;
  font-size: 18px;
  color: var(--text);
}
.mob-nav-drawer__close {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 12px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.mob-nav-drawer__close:hover {
  background: rgba(0,0,0,.06);
  color: var(--text);
}

/* Icon grid: компактные карточки, крупные иконки */
.mob-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px 10px 14px;
  flex: 1;
}

.mob-nav-grid__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 6px 4px;
  min-height: 0;
  border-radius: 12px;
  background: var(--soft);
  border: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  font-weight: 700;
  font-size: 0; /* скрываем подписи, оставляя только иконку */
  transition: all .15s;
}
.mob-nav-grid__item:hover {
  background: var(--primary-weak);
  border-color: rgba(37,99,235,.2);
  color: var(--primary);
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,99,235,.15);
}
.mob-nav-grid__item .mob-nav-grid__ic {
  font-size: 36px;
  line-height: 1;
}
.mob-nav-grid__item .mob-nav-grid__ic .panel-icon{
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}
.mob-nav-grid__item .mob-nav-grid__ic .panel-icon-fb{
  font-size: 36px;
  line-height: 1;
}
.mob-nav-grid__item--premium {
  background: linear-gradient(135deg, rgba(255,193,7,.15), rgba(255,152,0,.1));
  border-color: rgba(255,193,7,.3);
}
.mob-nav-grid__item--premium:hover {
  background: linear-gradient(135deg, rgba(255,193,7,.25), rgba(255,152,0,.2));
  border-color: rgba(255,193,7,.5);
}
.mob-nav-grid__item--danger {
  background: var(--danger-weak);
  border-color: rgba(220,38,38,.2);
}
.mob-nav-grid__item--danger:hover {
  background: rgba(220,38,38,.15);
  color: var(--danger);
}

/* VIP badge: do not overlap mobile header (place below header) */
@media (max-width: 768px) {
  .vip-badge-float {
    top: 58px;
    right: 12px;
    padding: 4px 10px;
    font-size: 11px;
  }
}

/* Dock on mobile: hide and use drawer + tabbar instead */
@media (max-width: 560px) {
  .game-shell > .dock {
    display: none !important;
  }
  .mob-header {
    display: flex !important;
  }
  .mob-tabbar {
    display: flex !important;
  }
}

@media (min-width: 561px) {
  .mob-header,
  .mob-nav-overlay,
  .mob-nav-drawer,
  .mob-tabbar {
    display: none !important;
  }
}

/* ── Mobile bottom tab bar (4 core buttons) ── */
.mob-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 16px rgba(0,0,0,.06);
  padding: 4px 0;
  padding-bottom: calc(4px + env(safe-area-inset-bottom, 0));
  justify-content: space-around;
  align-items: stretch;
}
.mob-tabbar__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  padding: 10px 4px 8px;
  text-decoration: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  transition: color .15s, background .15s;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.mob-tabbar__btn:hover,
.mob-tabbar__btn:active {
  color: var(--primary);
  background: rgba(37,99,235,.06);
  text-decoration: none;
}
.mob-tabbar__ic {
  font-size: 36px;
  line-height: 1;
}
.mob-tabbar__ic .panel-icon{
  width: 36px;
  height: 36px;
  object-fit: contain;
  display:block;
}
.mob-tabbar__ic .panel-icon-fb{
  font-size: 36px;
  line-height:1;
}
.mob-tabbar__label {
  font-size: 0; /* скрываем подписи в таббаре, оставляя только иконки */
}

/* ── Chat redesign (screenshot 3 style) ── */
@media (max-width: 768px) {
  .chat-card {
    border-radius: 20px 20px 0 0;
  }
  .chat-head {
    padding: 12px 16px 0;
    border-bottom: none;
  }
  .chat-title {
    font-size: 16px;
    font-weight: 900;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .chat-title-text {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .chat-close-btn {
    display: flex;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .chat-close-btn:hover {
    background: rgba(0,0,0,.06);
    color: var(--text);
  }

  /* Pill-shaped tabs */
  .chat-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    padding-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .chat-tabs::-webkit-scrollbar { display: none; }
  .chat-tab {
    flex: 0 0 auto;
    padding: 8px 16px;
    border-radius: 999px;
    border: none;
    background: rgba(0,0,0,.06);
    color: var(--muted);
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
  }
  .chat-tab:hover {
    background: rgba(0,0,0,.08);
    color: var(--text);
  }
  .chat-tab.active {
    background: var(--text);
    color: #fff;
    border-bottom: none;
  }
  .chat-tab[disabled] {
    opacity: .5;
    cursor: not-allowed;
  }

  /* Search bar: hidden on mobile to free space (user requested) */
  .chat-search-wrap {
    display: none !important;
  }

  /* Chat body: more height so several messages visible; padding so input bar doesn't cover last message */
  .chat-body {
    max-height: min(55vh, 420px);
    min-height: 220px;
    padding-bottom: 80px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Message bubbles - cleaner layout */
  .msg {
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--soft);
    border: 1px solid var(--border);
  }
  .msg-head {
    margin-bottom: 6px;
  }
  .msg-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
  .msg-body {
    margin-left: 0;
    margin-top: 4px;
  }

  /* Bottom action bar - screenshot 3 style */
  .chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border);
    background: var(--card);
  }
  .chat-form-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
  }
  .chat-form-action-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
  }
  .chat-form-action-btn:hover {
    background: rgba(0,0,0,.06);
    color: var(--text);
  }
  .chat-form-action-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
  }
  .chat-form .input {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border-radius: 20px;
  }
  .chat-form .btn.primary {
    padding: 10px 18px;
    border-radius: 20px;
    background: var(--ok);
    color: #fff;
    font-weight: 800;
  }

  /* Level restriction message */
  .chat-level-restriction {
    padding: 8px 16px;
    font-size: 12px;
    color: var(--muted);
    background: rgba(100,116,139,.08);
  }

  /* Scroll badge (screenshot 3) */
  .chat-scroll-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }
  .chat-form-action-btn { position: relative; }
  .chat-send-btn { background: var(--ok) !important; border-radius: 20px; padding: 10px 18px; font-weight: 800; }

  /* Pokemon picker tabs */
  .chat-pokemon-picker-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
  }
  .chat-pokemon-picker-tab {
    flex: 1;
    padding: 6px 8px;
    border: none;
    border-radius: 8px;
    background: rgba(0,0,0,.06);
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    color: var(--muted);
  }
  .chat-pokemon-picker-tab.active {
    background: var(--primary);
    color: #fff;
  }
}

/* ── World scene as card on mobile (Pallet Town style, screenshot 2) ── */
@media (max-width: 560px) {
  .gw {
    padding: 0 12px;
  }
  .gw-scene {
    border-radius: 20px;
    margin: 0 0 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    overflow: hidden;
  }
  .gw-encounters {
    background: var(--card);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
  }
  .gw-bottom {
    background: var(--card);
    border-radius: 16px;
    padding: 14px;
    margin-bottom: 12px;
    padding-bottom: calc(14px + 66px + env(safe-area-inset-bottom, 0));
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
  }

  /* Inventory inside modal: grid scrolls, detail panel is pinned to bottom */
  .modal-content:has(.inv-page) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal-content:has(.inv-page) .inv-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .modal-content:has(.inv-page) .inv-grid {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 96px; /* место под панель деталей */
  }
  .modal-content:has(.inv-page) .inv-detail {
    order: 2;
    position: sticky;
    bottom: 0;
    z-index: 20;
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 24px rgba(15,23,42,.18);
    background: var(--card);
    padding-top: 8px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  }

  /* Чуть мягче внешний вид инвентаря на мобильных */
  .inv-grid{
    background: transparent;
    border: none;
    padding-inline: 4px;
  }
  .inv-card{
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(15,23,42,.12);
  }
  .inv-card__icon{
    background: var(--inv-icon-bg,#f8fafc);
  }
  .inv-detail{
    border-radius: 16px 16px 0 0;
  }
}

/* Quick access grid (screenshot 2: colorful icons) */
.gw-quick-grid {
  display: none;
}

/* On mobile, hide quick grid — all sections are in the hamburger menu */
@media (max-width: 560px) {
  .gw-quick-grid {
    display: none !important;
  }
}
@media (max-width: 560px) {
  .gw-quick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 6px;
    border-radius: 14px;
    background: var(--soft);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
    font-size: 10px;
    transition: all .15s;
  }
  .gw-quick-item:hover,
  .gw-quick-item:active {
    background: var(--primary-weak);
    border-color: rgba(37,99,235,.25);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37,99,235,.15);
    text-decoration: none;
    color: var(--primary);
  }
  .gw-quick-ic {
    font-size: 24px;
    line-height: 1;
  }
  .gw-quick-item--premium {
    background: linear-gradient(135deg, rgba(255,193,7,.12), rgba(255,152,0,.08));
    border-color: rgba(255,193,7,.25);
  }
  .gw-quick-item--premium:hover,
  .gw-quick-item--premium:active {
    background: linear-gradient(135deg, rgba(255,193,7,.2), rgba(255,152,0,.15));
    border-color: rgba(255,193,7,.4);
    color: #b45309;
  }
}

/* Блок условий боя внутри модалки НПС (лимит уровня, сюжет и т.д.) */
.battle-conditions-in-modal {
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.35);
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
}
.battle-conditions-in-modal strong {
  display: inline;
}
