/* Mobile / Touch — Bottom-Navigation, Sheets, Vollbild-Modals */

:root {
  --mobile-nav-h: 3.35rem;
  --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
}

.mobile-nav,
.mobile-backdrop,
.mobile-more-sheet {
  display: none !important;
}

@media (min-width: 769px) {
  .mobile-nav,
  .mobile-backdrop,
  .mobile-more-sheet {
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

@media (max-width: 768px) {
  .is-mobile {
    --topbar-h: 48px;
    --mobile-nav-h: 3.35rem;
  }

  .is-mobile .mobile-nav {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1200;
    height: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom));
    padding-bottom: var(--mobile-safe-bottom);
    background: linear-gradient(180deg, #7f1d1d, #6b1212);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.35);
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    font: inherit;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 0.35rem 0.2rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }

  .mobile-nav-btn .mobile-nav-icon {
    font-size: 1.15rem;
    line-height: 1;
  }

  .mobile-nav-btn.is-active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
  }

  .mobile-nav-badge {
    position: absolute;
    top: 0.2rem;
    right: calc(50% - 1.1rem);
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1.1rem;
    text-align: center;
  }

  .mobile-nav-badge.hidden {
    display: none;
  }

  .is-mobile .game-layout {
    top: var(--topbar-h);
    left: 0;
    right: 0;
    bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom));
    height: auto;
  }

  .is-mobile .topbar {
    padding: 0 0.5rem;
    gap: 0.35rem;
  }

  .is-mobile .topbar-brand {
    min-width: 0;
    flex: 1;
    min-width: 0;
  }

  .is-mobile .topbar-brand strong {
    font-size: 0.82rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 9rem;
  }

  .is-mobile .topbar-sub {
    font-size: 0.65rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 9rem;
  }

  .is-mobile .topbar-stats {
    flex-shrink: 0;
    gap: 0.25rem;
  }

  .is-mobile .topbar-stat {
    padding: 0.15rem 0.35rem;
  }

  .is-mobile .topbar-stat span {
    font-size: 0.58rem;
  }

  .is-mobile .topbar-stat strong {
    font-size: 0.78rem;
  }

  .is-mobile .topbar-stat--rank .rank-mini-bar {
    width: 2.5rem;
    height: 3px;
  }

  .is-mobile .topbar-actions {
    display: none;
  }

  .is-mobile .float-panel-grip,
  .is-mobile .float-panel-resize {
    display: none !important;
  }

  .is-mobile .float-panel--float,
  .is-mobile #float-panel-radio.float-panel {
    display: none;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: none !important;
    bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom)) !important;
    height: min(62vh, calc(100dvh - var(--topbar-h) - var(--mobile-nav-h) - var(--mobile-safe-bottom) - 4px)) !important;
    border-radius: 14px 14px 0 0;
    border: none;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.28);
    z-index: 900;
  }

  .is-mobile #float-panel-missions.mobile-open,
  .is-mobile #float-panel-buildings.mobile-open,
  .is-mobile #float-panel-radio.mobile-open {
    display: flex;
  }

  .is-mobile #float-panel-radio.radio-bar--collapsed .radio-list {
    display: none;
  }

  .is-mobile #float-panel-radio.mobile-open:not(.radio-bar--collapsed) {
    height: min(52vh, calc(100dvh - var(--topbar-h) - var(--mobile-nav-h) - var(--mobile-safe-bottom) - 4px)) !important;
  }

  .is-mobile #float-panel-radio.mobile-open.radio-bar--collapsed {
    height: auto !important;
    min-height: 2.5rem;
  }

  .is-mobile .panel-head,
  .is-mobile .radio-bar-head {
    padding: 0.5rem 0.65rem;
    touch-action: manipulation;
  }

  .is-mobile .panel-head h2,
  .is-mobile .radio-bar-head h2 {
    font-size: 0.9rem;
  }

  .is-mobile .filter-bar {
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem;
  }

  .is-mobile .filter-btn {
    font-size: 0.68rem;
    padding: 0.28rem 0.45rem;
  }

  .is-mobile .panel-body {
    -webkit-overflow-scrolling: touch;
  }

  .is-mobile .mobile-backdrop {
    display: block !important;
    visibility: visible !important;
    position: fixed;
    inset: 0;
    z-index: 850;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .is-mobile .mobile-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .is-mobile .mobile-more-sheet {
    display: flex !important;
    visibility: visible !important;
    flex-direction: column;
    gap: 0.35rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom));
    z-index: 1100;
    padding: 0.75rem;
    background: #fff;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
    transform: translateY(110%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: none;
  }

  .is-mobile .mobile-more-sheet.is-open {
    transform: translateY(0);
    pointer-events: auto;
  }

  .is-mobile .mobile-more-sheet .btn {
    justify-content: center;
    width: 100%;
  }

  .is-mobile .building-detail {
    left: 0 !important;
    right: 0 !important;
    top: var(--topbar-h) !important;
    bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom)) !important;
    width: auto !important;
    max-height: none !important;
    border-radius: 0;
    z-index: 950;
  }

  .is-mobile .modal {
    padding: 0;
    align-items: stretch;
  }

  .is-mobile .modal-card,
  .is-mobile .modal-card--wide {
    width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .is-mobile .modal--alarm .alarm-shell,
  .is-mobile .modal--vehicle-detail .vehicle-detail-shell,
  .is-mobile .modal--settings .settings-shell,
  .is-mobile .modal--credits .credits-shell,
  .is-mobile .settings-shell {
    width: 100%;
    height: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
  }

  .is-mobile .alarm-body {
    grid-template-columns: 1fr;
  }

  .is-mobile .alarm-side {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 32vh;
  }

  .is-mobile .vehicle-detail-body {
    grid-template-columns: 1fr;
  }

  .is-mobile .vehicle-detail-side {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 30vh;
  }

  .is-mobile .vehicle-detail-table-wrap {
    max-height: 40vh;
  }

  .is-mobile .setup-overlay {
    padding: 0.5rem;
  }

  .is-mobile .setup-panel {
    width: 100%;
    max-height: 100dvh;
    border-radius: 12px;
    padding: 1rem 0.85rem;
  }

  .is-mobile .setup-search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .is-mobile .setup-search-row input {
    width: 100%;
  }

  .is-mobile .setup-map {
    height: 38vh;
    min-height: 200px;
  }

  .is-mobile .toast {
    bottom: calc(var(--mobile-nav-h) + var(--mobile-safe-bottom) + 0.65rem);
    max-width: calc(100vw - 1.5rem);
    font-size: 0.8rem;
  }

  .is-mobile .build-type-grid {
    grid-template-columns: 1fr;
  }

  .is-mobile .dist-btn {
    font-size: 0.68rem;
    padding: 0.28rem 0.4rem;
  }

  .is-mobile .mission-alarm-btn {
    writing-mode: horizontal-tb;
    transform: none;
    padding: 0.35rem 0.5rem;
    min-width: 3.2rem;
    font-size: 0.68rem;
  }

  .is-mobile .mission-card-ls-inner {
    flex-direction: row;
    align-items: stretch;
  }
}

@media (max-width: 480px) {
  .is-mobile .topbar-stat:nth-child(3) {
    display: none;
  }
}
