/* ═══ JellyX Mobile Optimization ═══
 * Все правила здесь — только под мобилу. Desktop не затрагивается.
 * Контракт: bottom-nav, drawer-меню, фиксы header, modal, touch targets, safe area.
 */

/* ═══ BOTTOM NAVIGATION ═══ */
.mb-bottom-nav { display: none; }

@media (max-width: 768px) {
  .mb-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(14, 9, 26, 0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid rgba(139, 92, 246, 0.18);
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.4);
  }
  .mb-bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: #7c8aab;
    font-family: inherit;
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 4px;
    transition: color 0.2s;
    position: relative;
    min-width: 44px;
  }
  .mb-bn-item i { font-size: 19px; transition: transform 0.25s; }
  .mb-bn-item.active { color: #c4b5fd; }
  .mb-bn-item.active i { transform: scale(1.1); color: #c4b5fd; }
  .mb-bn-item:active { color: #fff; }
  .mb-bn-item .mb-bn-badge {
    position: absolute;
    top: 4px;
    right: 18%;
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 800;
    padding: 1px 5px;
    min-width: 14px;
    text-align: center;
  }

  /* Центральная выпуклая кнопка «Депозит» */
  .mb-bn-deposit {
    position: relative;
    transform: translateY(-18px);
  }
  .mb-bn-deposit .mb-bn-deposit-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22c55e, #16a34a);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    box-shadow: 0 8px 20px rgba(34, 197, 94, 0.45),
                0 0 0 4px rgba(14, 9, 26, 0.96);
    border: none;
    cursor: pointer;
    transition: transform 0.15s;
  }
  .mb-bn-deposit:active .mb-bn-deposit-fab { transform: scale(0.92); }
  .mb-bn-deposit .mb-bn-label {
    font-size: 10px;
    color: #22c55e;
    margin-top: 2px;
    font-weight: 700;
  }
}

/* ═══ DRAWER (выезжающее меню для «Ещё») ═══ */
.mb-drawer-bg,
.mb-drawer { display: none !important; }

@media (max-width: 768px) {
  .mb-drawer-bg {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 250;
    pointer-events: none;
    transition: background 0.3s;
  }
  .mb-drawer-bg.open {
    background: rgba(0, 0, 0, 0.65);
    pointer-events: auto;
    backdrop-filter: blur(4px);
  }
  .mb-drawer {
    display: flex !important;
    position: fixed;
    top: 0;
    bottom: 0;
    right: -85%;
    width: 85%;
    max-width: 320px;
    background: linear-gradient(180deg, #14091e, #0c0816);
    border-left: 1px solid rgba(139, 92, 246, 0.25);
    z-index: 260;
    transition: right 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    flex-direction: column;
    overflow-y: auto;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: -16px 0 60px rgba(0, 0, 0, 0.6);
  }
  .mb-drawer.open { right: 0; }
  .mb-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .mb-drawer-title {
    font-family: 'Unbounded', sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
  }
  .mb-drawer-title .jelly { color: #c4b5fd; }
  .mb-drawer-title .x { color: #fbbf24; }
  .mb-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #a8b3cf;
    font-size: 16px;
    cursor: pointer;
  }
  .mb-drawer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  .mb-drawer-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 18px;
  }
  .mb-drawer-user-info { flex: 1; min-width: 0; }
  .mb-drawer-username {
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mb-drawer-balance {
    font-size: 13px;
    color: #fbbf24;
    font-weight: 700;
    margin-top: 2px;
  }
  .mb-drawer-list {
    flex: 1;
    padding: 8px 0;
  }
  .mb-drawer-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    color: #cdd6ee;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: inherit;
    min-height: 48px;
  }
  .mb-drawer-item i {
    width: 22px;
    text-align: center;
    font-size: 16px;
    color: #8b5cf6;
  }
  .mb-drawer-item:active { background: rgba(139, 92, 246, 0.12); }
  .mb-drawer-item.active {
    background: rgba(139, 92, 246, 0.10);
    color: #fff;
    border-left: 3px solid #8b5cf6;
    padding-left: 17px;
  }
  .mb-drawer-item-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
  }
  .mb-drawer-sep {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 6px 16px;
  }
  .mb-drawer-logout {
    color: #ef4444;
    margin: 12px 16px;
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 12px;
    text-align: center;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    min-height: 44px;
  }
}

/* ═══ MOBILE HEADER FIXES ═══ */
@media (max-width: 768px) {
  .header {
    padding: 10px 12px !important;
    gap: 8px;
  }
  .hdr-logo { gap: 8px; }
  .hdr-logo img { width: 32px !important; height: 32px !important; }
  .hdr-logo-text { font-size: 14px !important; }
  /* Онлайн-счётчик — компактный: зелёная точка + число (текст «онлайн» скрыт через font-size:0) */
  .hdr-online {
    display: inline-flex !important;
    align-items: center;
    padding: 6px 10px !important;
    font-size: 0 !important; /* убирает текстовую ноду " онлайн" */
    gap: 5px !important;
    background: rgba(34, 197, 94, 0.08) !important;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    border-radius: 8px !important;
  }
  .hdr-online .hdr-online-dot {
    display: inline-block !important;
    width: 7px;
    height: 7px;
  }
  .hdr-online #hdrOnlineCount {
    display: inline !important;
    color: #4ade80 !important;
    font-weight: 800;
    font-size: 12px !important;
  }
  .hdr-fs-btn { display: none !important; }

  /* На мобиле скрываем «Депозит» и «Вывод» из header — они в bottom-nav */
  .hdr-deposit, #hd { display: none !important; }
  #hw { display: none !important; }

  .hdr-balance {
    padding: 6px 12px !important;
    font-size: 13px !important;
    min-height: 38px;
  }
  .hdr-balance i { font-size: 12px; }

  .hdr-btn, .hdr-btn-green {
    padding: 8px 14px !important;
    font-size: 12px !important;
    min-height: 40px;
  }
}

/* ═══ EXTRA SMALL (≤480px) — iPhone SE и узкие android ═══ */
@media (max-width: 480px) {
  .header {
    padding: 8px 10px !important;
    gap: 6px;
  }
  .hdr-logo-text { display: none !important; }
  .hdr-balance {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }
  .main-content {
    padding: 12px !important;
  }
  .game-grid.grid-wrap {
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)) !important;
    gap: 6px !important;
  }
  .gc-thumb { height: 130px !important; }
  .orig-grid {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)) !important;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .promo-card-title { font-size: 14px !important; }
}

/* ═══ MODAL FIXES (на мобиле меньше padding, ближе к краям) ═══ */
@media (max-width: 768px) {
  .modal-card {
    padding: 22px !important;
    max-width: 95% !important;
    width: 95% !important;
    max-height: 88vh;
    overflow-y: auto;
  }
  .terms-modal-card {
    width: 96% !important;
    max-height: 88vh;
  }
  .terms-modal-header { padding: 16px 18px 12px !important; }
  .terms-modal-body { padding: 16px 18px !important; }
  .modal-close {
    width: 36px !important;
    height: 36px !important;
    font-size: 16px !important;
    top: 10px !important;
    right: 10px !important;
  }
}

/* ═══ TOUCH TARGETS (≥44px по Apple HIG) ═══ */
@media (max-width: 768px) {
  .bet-btn {
    width: 44px !important;
    height: 44px !important;
    font-size: 18px !important;
  }
  .bet-preset {
    padding: 10px 14px !important;
    font-size: 12px !important;
    min-height: 40px;
  }
  .play-btn, .cashout-btn, .reset-btn {
    padding: 16px !important;
    font-size: 14px !important;
    min-height: 52px;
  }
  .gc-overlay .gc-play-btn {
    padding: 12px 20px !important;
    font-size: 13px !important;
  }
  /* Все ссылки и кнопки внутри основного контента */
  .main-content button,
  .main-content a {
    min-height: 40px;
  }
}

/* ═══ БАННЕРЫ НА МОБИЛЕ — пропорции 1600×529 (≈3:1), картинка не обрезается ═══ */
@media (max-width: 768px) {
  .banner-slide {
    min-height: 0 !important;
    aspect-ratio: 1600 / 529 !important;
    height: auto !important;
    border-radius: 14px !important;
  }
  .banner-slide img,
  .banner-has-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center center !important;
  }
  .banner-overlay-text {
    padding: 14px 18px !important;
    justify-content: center !important;
  }
  .banner-big {
    font-size: 18px !important;
    line-height: 1.1;
  }
  .banner-sub {
    font-size: 11px !important;
    margin-top: 3px;
  }
  .banner-btn {
    margin-top: 8px;
    padding: 8px 14px !important;
    font-size: 11px !important;
    min-height: 36px;
    width: fit-content;
  }
  /* Каруселька — корректное пространство под dots */
  .banner-carousel { margin-bottom: 22px !important; }
}

@media (max-width: 480px) {
  .banner-big { font-size: 16px !important; }
  .banner-sub { font-size: 10px !important; }
}

/* ═══ ОСНОВНОЙ КОНТЕНТ — отступ снизу под bottom-nav ═══ */
@media (max-width: 768px) {
  body { padding-bottom: 0; }
  .main-content {
    padding-bottom: 90px !important;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0)) !important;
  }
  .main-area { min-height: 100vh; }
}

/* ═══ SAFE AREA для iPhone X+ (notch + home indicator) ═══ */
@media (max-width: 768px) {
  .header {
    padding-top: calc(10px + env(safe-area-inset-top, 0)) !important;
    padding-left: calc(12px + env(safe-area-inset-left, 0)) !important;
    padding-right: calc(12px + env(safe-area-inset-right, 0)) !important;
  }
}

/* ═══ ОТКЛЮЧАЕМ HOVER ЭФФЕКТЫ НА TOUCH (ломаются на тапе) ═══ */
@media (hover: none) and (pointer: coarse) {
  .game-card:hover,
  .promo-card:hover,
  .bonus-card:hover,
  .sb-item:hover,
  .hdr-btn:hover {
    transform: none !important;
  }
}

/* ═══ WINNERS TICKER (Live выигрыши) — мобильная версия ═══ */
@media (max-width: 768px) {
  .winners-ticker {
    height: auto !important;
    min-height: 64px !important;
    margin-bottom: 16px !important;
    border-radius: 12px !important;
    overflow: hidden !important;
  }
  .winners-ticker-label {
    padding: 0 12px !important;
    font-size: 0 !important; /* прячем текст «Live выигрыши», оставляем только иконку */
    border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
    flex-shrink: 0;
  }
  .winners-ticker-label i {
    font-size: 18px !important;
  }
  .winners-ticker-label .wt-label-text {
    display: none !important;
  }
  .winners-ticker-track {
    padding: 8px 0 !important;
    overflow-x: hidden !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%) !important;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 20px, #000 calc(100% - 20px), transparent 100%) !important;
  }
  .wt-marquee { animation-duration: 50s !important; }
  .wt-half { gap: 8px !important; padding-left: 8px !important; }
  .winner-item {
    padding: 10px 14px !important;
    font-size: 13px !important;
    min-height: 48px;
    border-radius: 10px !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 3px !important;
    min-width: 130px;
  }
  .winner-item .wt-nick {
    font-size: 12px !important;
    font-weight: 700 !important;
    line-height: 1.2;
  }
  .winner-item .wt-sep { display: none !important; }
  .winner-item .wt-game {
    font-size: 10px !important;
    color: rgba(168, 179, 207, 0.8) !important;
    line-height: 1;
  }
  .winner-item .wt-amount {
    font-size: 14px !important;
    font-weight: 800 !important;
    line-height: 1.1;
    margin-top: 2px;
  }
  .winner-item.big {
    box-shadow: 0 0 16px rgba(255, 193, 7, 0.3) !important;
  }
  .winner-item.big .wt-amount { font-size: 15px !important; }
}

@media (max-width: 480px) {
  .winners-ticker { min-height: 60px !important; }
  .winner-item { min-width: 118px; padding: 8px 12px !important; }
}

/* ═══ УЛУЧШЕНИЯ ДЛЯ ПРОКРУТКИ ═══ */
@media (max-width: 768px) {
  body {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
  }
  .winners-ticker {
    -webkit-overflow-scrolling: touch;
  }
  /* Запрещаем pull-to-refresh случайно срабатывать */
  html { overscroll-behavior: contain; }
}

/* ═══ КАПЛЯ-ПОДСКАЗКА ПЕРВОГО ЗАХОДА (PWA install hint) ═══ */
.mb-install-hint {
  display: none;
  position: fixed;
  bottom: 80px;
  left: 16px;
  right: 16px;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 600;
  z-index: 300;
  box-shadow: 0 12px 40px rgba(139, 92, 246, 0.5);
  align-items: center;
  gap: 12px;
}
.mb-install-hint.show { display: flex; }
.mb-install-hint button {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  min-height: 36px;
}
