/* css/mobile-style.css */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #010103;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Roboto Mono", monospace;
  font-variant-numeric: tabular-nums; /* 等寬數字，防止數值變動時文字抖動 */
  overscroll-behavior: none;
}

#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

#hud-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 12px) env(safe-area-inset-right, 12px) env(safe-area-inset-bottom, 12px) env(safe-area-inset-left, 12px);
}

.interactive {
  pointer-events: auto !important;
}

/* 頂部儀表板 */
.flight-director {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  pointer-events: none;
}

.primary-telemetry {
  background: rgba(4, 16, 26, 0.78);
  border: 1px solid rgba(0, 229, 255, 0.35);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.15), inset 0 0 15px rgba(0, 229, 255, 0.05);
  border-radius: 8px;
  padding: 8px 12px;
  color: #00e5ff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  flex: 1;
  max-width: 480px;
  transition: max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1), padding 0.25s ease;
}

.primary-telemetry.collapsed {
  max-width: 300px;
  padding: 5px 10px;
  background: rgba(4, 16, 26, 0.88);
  border-color: rgba(0, 255, 170, 0.5);
}

.primary-telemetry.collapsed .collapse-hide {
  display: none !important;
}

.pri-data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.sec-data-row {
  font-size: 11px;
  margin-top: 4px;
  color: #a0c4d8;
  display: flex;
  gap: 8px;
}

/* 控制按鈕群 */
.btn-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hud-btn {
  background: rgba(4, 20, 32, 0.75);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #00e5ff;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: transform 0.1s ease, background 0.15s ease;
  min-width: 78px;
  text-align: center;
}

.hud-btn:active {
  transform: scale(0.94);
  background: rgba(0, 229, 255, 0.25);
}

.btn-abort {
  border-color: rgba(255, 51, 85, 0.6);
  color: #ff3355;
}

/* CBARS 瞄準具 */
#crosshair-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 140px;
  height: 140px;
  pointer-events: none;
}

.crosshair-circle {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 1px solid rgba(0, 255, 170, 0.2);
  border-radius: 50%;
}

.crosshair-reticle {
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 16px;
  border: 2px solid #00ffaa;
  box-shadow: 0 0 8px #00ffaa;
  transform: translate(-50%, -50%);
  will-change: transform;
}

/* 搖桿專屬觸控區 (GPU 合成加速) */
.joystick-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  padding-bottom: 12px;
  pointer-events: none;
  z-index: 50;
}

.stick-zone {
  position: relative;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.08) 0%, rgba(0, 229, 255, 0.22) 100%);
  border: 2px solid rgba(0, 229, 255, 0.45);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.18);
  touch-action: none !important;
  pointer-events: auto !important;
  cursor: pointer;
}

.stick-label {
  position: absolute;
  top: -18px;
  width: 100%;
  text-align: center;
  font-size: 10px;
  color: #00ffaa;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-shadow: 0 0 4px rgba(0, 255, 170, 0.5);
  pointer-events: none;
}

.stick-knob {
  position: absolute;
  top: 50%; left: 50%;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 255, 170, 0.85) 0%, rgba(0, 229, 255, 0.4) 100%);
  border: 2px solid #00ffaa;
  box-shadow: 0 0 12px #00ffaa;
  transform: translate(-50%, -50%);
  will-change: transform; /* 🚀 GPU 獨立合成圖層，徹底消除拖曳微卡頓 */
  pointer-events: none;
}

/* 敘事字幕框 */
.narrative-box {
  position: absolute;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(3, 12, 22, 0.85);
  border: 1px solid #00ffaa;
  box-shadow: 0 0 15px rgba(0, 255, 170, 0.25);
  border-radius: 6px;
  padding: 8px 16px;
  color: #fff;
  font-size: 12px;
  max-width: 85%;
  width: max-content;
  display: flex;
  gap: 8px;
  align-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.jar-tag {
  background: #00ffaa;
  color: #010103;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 800;
  font-size: 10px;
}

/* 結算彈窗 */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(1, 2, 6, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
}

.modal-overlay.hidden {
  display: none !important;
}

.report-card {
  background: rgba(4, 18, 30, 0.95);
  border: 1px solid #00ffaa;
  box-shadow: 0 0 25px rgba(0, 255, 170, 0.35);
  border-radius: 10px;
  padding: 20px;
  width: 90%;
  max-width: 320px;
  color: #fff;
}

.report-row {
  margin: 10px 0;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
}

/* 橫屏太空艙極限優化 */
@media screen and (orientation: landscape) {
  #hud-overlay {
    padding: 6px 14px;
  }
  .primary-telemetry {
    max-width: 250px;
    padding: 6px 10px;
    font-size: 11px;
    background: rgba(4, 16, 26, 0.65);
  }
  .pri-data-row {
    font-size: 12px !important;
  }
  .sec-data-row {
    font-size: 9.5px;
  }
  #telem-stream {
    font-size: 8px !important;
    gap: 4px !important;
  }
  .btn-group {
    gap: 4px;
  }
  .hud-btn {
    padding: 4px 6px;
    font-size: 9.5px;
    min-width: 62px;
  }
  .stick-zone {
    width: 86px;
    height: 86px;
  }
  .stick-knob {
    width: 34px;
    height: 34px;
  }
  .stick-label {
    top: -14px;
    font-size: 8.5px;
  }
  .narrative-box {
    bottom: 12px;
    padding: 4px 10px;
    font-size: 10px;
    max-width: 45%;
  }
  #crosshair-container {
    width: 90px;
    height: 90px;
  }
}
