/* ========================================================
   KSP-WASM 移动端适配与虚拟操控面板样式 (mobile.css)
   ======================================================== */

:root {
  --hud-accent: #00e5ff;
  --hud-stage: #ff1744;
  --hud-warn: #ffab00;
  --hud-bg: rgba(12, 18, 30, 0.75);
  --hud-btn-bg: rgba(26, 38, 57, 0.82);
  --hud-btn-active: rgba(0, 229, 255, 0.35);
  --hud-border: rgba(0, 229, 255, 0.4);
  --hud-text: #ffffff;
  --hud-opacity: 0.85;
}

/* 移动端视口与全局防误触 */
html, body {
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

/* 顶部快速启动栏（在小屏或触屏上提示一键启动） */
#mobileLaunchBanner {
  display: none;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  padding: 10px 14px;
  border-bottom: 2px solid var(--hud-accent);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  #mobileLaunchBanner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
}

.mobile-play-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, #00c853, #009624);
  border: 1px solid #b9f6ca;
  border-radius: 6px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 200, 83, 0.4);
  transition: transform 0.1s, background 0.2s;
}

.mobile-play-btn:active {
  transform: scale(0.97);
  background: #007e1e;
}

/* 竖屏旋转设备提醒遮罩 */
#portraitNotice {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(10, 14, 23, 0.94);
  backdrop-filter: blur(10px);
  color: #ffffff;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}

@media (orientation: portrait) and (max-width: 900px) {
  #portraitNotice.active {
    display: flex;
  }
}

.rotate-phone-icon {
  font-size: 54px;
  margin-bottom: 16px;
  animation: rotatePhone 2.5s ease-in-out infinite alternate;
}

@keyframes rotatePhone {
  0% { transform: rotate(0deg); }
  35% { transform: rotate(0deg); }
  65% { transform: rotate(-90deg); }
  100% { transform: rotate(-90deg); }
}

.notice-title {
  font-size: 18px;
  font-weight: bold;
  color: var(--hud-accent);
  margin-bottom: 8px;
}

.notice-sub {
  font-size: 13px;
  color: #a0aec0;
  max-width: 280px;
  line-height: 1.5;
  margin-bottom: 20px;
}

.dismiss-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
}

/* ========================================================
   虚拟飞行控制 HUD (Virtual Flight HUD)
   ======================================================== */
#mobileHUD {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: var(--hud-opacity);
  transition: opacity 0.3s ease;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#mobileHUD.active {
  display: block;
}

#mobileHUD.hidden-hud .hud-left,
#mobileHUD.hidden-hud .hud-right,
#mobileHUD.hidden-hud .hud-top-center,
#mobileHUD.hidden-hud .hud-throttle {
  display: none !important;
}

/* 允许按键交互 */
#mobileHUD * {
  box-sizing: border-box;
}

.hud-btn {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--hud-btn-bg);
  border: 1.5px solid var(--hud-border);
  color: var(--hud-text);
  border-radius: 8px;
  font-weight: bold;
  text-align: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.08s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.hud-btn:active,
.hud-btn.pressed {
  background: var(--hud-btn-active);
  border-color: var(--hud-accent);
  box-shadow: 0 0 14px var(--hud-accent);
  transform: scale(0.94);
}

.hud-btn.toggled-on {
  background: rgba(0, 229, 255, 0.4);
  border-color: #00e5ff;
  color: #ffffff;
  box-shadow: 0 0 12px #00e5ff;
}

.hud-btn .btn-key {
  font-size: 13px;
  line-height: 1.1;
}

.hud-btn .btn-desc {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: normal;
  margin-top: 1px;
}

/* 顶部工具栏 */
.hud-top-bar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  gap: 8px;
}

.hud-top-left, .hud-top-right, .hud-top-center {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.hud-top-btn {
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 6px;
  min-width: 44px;
  height: 32px;
}

/* 左侧：姿态四向控制与滚转 */
.hud-left {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

/* 十字方向键布局 */
.dpad-container {
  display: grid;
  grid-template-columns: 50px 50px 50px;
  grid-template-rows: 50px 50px 50px;
  gap: 6px;
  align-items: center;
  justify-items: center;
}

.dpad-btn {
  width: 50px;
  height: 50px;
  font-size: 16px;
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-center{
  grid-column: 2;
  grid-row: 2;
  font-size: 9px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.6);
  pointer-events: none;
}
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

/* 滚转行 (Q / E) */
.roll-row {
  display: flex;
  gap: 12px;
}

.roll-btn {
  width: 74px;
  height: 36px;
}

/* 油门推力控制列（位于左侧偏中） */
.hud-throttle {
  position: absolute;
  bottom: 24px;
  left: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: auto;
}

.throttle-btn {
  width: 54px;
  height: 36px;
}

.throttle-max {
  border-color: #00e676;
  color: #00e676;
}

.throttle-cut {
  border-color: #ff5252;
  color: #ff5252;
}

/* 右侧：动作与核心按钮 */
.hud-right {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

/* 核心辅助开关 (SAS, RCS, MAP, 视角) */
.action-grid {
  display: grid;
  grid-template-columns: 56px 56px;
  gap: 8px;
}

.action-btn {
  width: 56px;
  height: 48px;
}

/* 分级点火按钮（醒目大圆盘） */
.stage-btn {
  width: 120px;
  height: 60px;
  background: linear-gradient(135deg, rgba(213, 0, 0, 0.88), rgba(255, 23, 68, 0.88));
  border: 2px solid #ff8a80;
  border-radius: 30px;
  box-shadow: 0 4px 15px rgba(255, 23, 68, 0.6), inset 0 2px 4px rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 15px;
  letter-spacing: 1px;
}

.stage-btn:active,
.stage-btn.pressed {
  background: #ff1744;
  box-shadow: 0 0 25px #ff1744;
  transform: scale(0.95);
}

/* 视角旋转触控引导浮层（默认完全穿透，不拦截任何鼠标与触屏点击） */
#touchLookArea {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 仅在明确进入视角旋转模式时临时捕获单指手势 */
#touchLookArea.active {
  pointer-events: auto;
}

/* 视角旋转提示指示器 */
#lookHintToast {
  display: none;
  background: rgba(12, 18, 30, 0.88);
  border: 1px solid var(--hud-accent);
  color: #00e5ff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  pointer-events: none;
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.4);
  user-select: none;
  -webkit-user-select: none;
}

#lookHintToast.show {
  display: block;
  animation: lookToastFade 1.6s ease forwards;
}

@keyframes lookToastFade {
  0% { opacity: 0; transform: scale(0.9); }
  15% { opacity: 1; transform: scale(1); }
  80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.95); }
}

/* 在小屏幕上的尺寸自适应 */
@media (max-height: 450px) {
  .dpad-container {
    grid-template-columns: 42px 42px 42px;
    grid-template-rows: 42px 42px 42px;
    gap: 4px;
  }
  .dpad-btn { width: 42px; height: 42px; }
  .roll-btn { width: 62px; height: 32px; font-size: 11px; }
  .action-btn { width: 50px; height: 42px; }
  .stage-btn { width: 106px; height: 50px; font-size: 13px; }
  .hud-throttle { left: 168px; bottom: 16px; }
  .throttle-btn { width: 46px; height: 32px; }
}

/* ========================================================
   镜头视距缩放与画面大小调节控件 (Zoom Controller)
   ======================================================== */
.hud-zoom-bar {
  position: absolute;
  right: 16px;
  top: 46%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--hud-border);
  border-radius: 20px;
  padding: 8px 5px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  z-index: 105;
}

.zoom-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 14px;
}

.zoom-btn .btn-key {
  font-size: 15px;
}

.zoom-btn:active,
.zoom-btn.pressed {
  background: rgba(0, 229, 255, 0.4);
  box-shadow: 0 0 12px var(--hud-accent);
}

/* 垂直弹性阻尼缩放滑轨 */
.zoom-track {
  position: relative;
  width: 22px;
  height: 80px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  cursor: ns-resize;
  overflow: hidden;
}

.zoom-track::before {
  content: "";
  position: absolute;
  width: 2px;
  height: 60px;
  background: rgba(0, 229, 255, 0.25);
  border-radius: 1px;
}

.zoom-thumb {
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, #00e5ff, #0091ea);
  border: 1.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.8);
  pointer-events: none;
  transition: transform 0.15s ease-out;
}

.zoom-thumb.dragging {
  transition: none;
  box-shadow: 0 0 16px #00e5ff;
  transform: scale(1.15);
}

.zoom-label {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.65);
  user-select: none;
  margin-top: 1px;
}

@media (max-height: 450px) {
  .hud-zoom-bar {
    right: 10px;
    top: 42%;
    padding: 5px 3px;
    gap: 3px;
  }
  .zoom-btn { width: 36px; height: 36px; }
  .zoom-track { height: 60px; width: 18px; }
  .zoom-thumb { width: 14px; height: 14px; }
}

/* 模态弹窗与全屏确认框通用可见性修复 */
.modal-bg .window {
  opacity: 1 !important;
  visibility: visible !important;
  position: relative !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
}

/* 移动端模态弹窗与全屏确认框样式优化 */
@media (max-width: 900px), (hover: none) and (pointer: coarse) {
  .modal-bg .window {
    width: 92vw !important;
    max-width: 480px !important;
  }
  .modal-bg .window-body {
    font-size: 13px !important;
    line-height: 1.6 !important;
    padding: 14px !important;
  }
  #modalFoot {
    gap: 10px !important;
    padding: 8px 12px 12px !important;
  }
  #modalFoot button {
    min-height: 38px !important;
    padding: 6px 18px !important;
    font-size: 14px !important;
    font-weight: bold !important;
    border-radius: 6px !important;
    cursor: pointer !important;
  }
}

