/* =====================================================
   MOBILE RESPONSIVE (max-width: 768px)
   — scroll vertikal, tanpa overflow horizontal, lock flex
===================================================== */
@media (max-width: 768px) {
  html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body {
    overflow-y: auto !important; /* Allow scroll on mobile */
    height: auto;
  }

  #main-dashboard {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 10px);
  }

  .navbar {
    height: auto;
    min-height: 60px;
    padding: 12px max(16px, env(safe-area-inset-right, 0px)) 12px
      max(16px, env(safe-area-inset-left, 0px));
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }

  .logo {
    font-size: clamp(14px, 4vw, 18px);
    gap: 8px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .logo img {
    width: 30px;
    height: 30px;
  }

  .connection {
    flex-shrink: 0;
    gap: 8px;
    margin-left: auto;
  }

  #connText {
    font-size: 11px;
    white-space: nowrap;
  }

  .dashboard {
    padding: 12px max(12px, env(safe-area-inset-left, 0px)) 12px
      max(12px, env(safe-area-inset-right, 0px));
    min-height: 0;
    gap: 12px;
    box-sizing: border-box;
    width: 100%;
  }

  .main-grid {
    grid-template-columns: 1fr;
    flex: 0 0 auto;
  }
  
  .main-grid > .container {
    grid-column: 1 !important;
    grid-row: auto !important;
  }
  
  .main-grid > .container:nth-child(2) {
    order: -1;
  }

  .top-row {
    grid-template-columns: 1fr;
  }

  .container {
    min-width: 0;
    width: 100%;
    padding: 12px;
  }

  .container-header {
    font-size: 13px;
  }

  .clock-box {
    min-height: 60px;
    font-size: clamp(20px, 5vw, 24px);
    padding: 12px;
  }

  .mission-grid {
    grid-template-columns: repeat(3, 1fr); /* 3 cols for mobile looks better */
    gap: 8px;
  }

  .step {
    font-size: 10px;
    padding: 8px 4px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  .telemetry {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .telemetry-card {
    padding: 10px;
  }
  
  .telemetry-card .value {
    font-size: 16px;
  }

  .camera-grid {
    grid-template-columns: 1fr;
  }

  .camera-box {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  .map-info {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .map-wrapper {
    height: 250px;
    min-height: 200px;
  }

  .compass {
    width: 60px;
    height: 60px;
    top: 10px;
    right: max(10px, env(safe-area-inset-right, 0px));
  }

  .compass-inner {
    width: 42px;
    height: 42px;
  }

  .needle {
    width: 6px;
    height: 22px;
  }

  .needle-body {
    width: 6px;
    height: 22px;
    margin-left: -3px;
  }

  .compass-pivot {
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
  }

  /* Disable hover transform on mobile to avoid jumping layout */
  .container:hover, .telemetry-card:hover, .camera-box:hover img, .logo img:hover {
    transform: none;
  }
}
