/* ============================================================
 * Space Defender 3D - Mobile Landscape Optimized Styles
 * Max render: 1920x1080 (Android 9 landscape reference)
 * ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Courier New", "Consolas", monospace;
  color: #e0e0e0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  position: fixed;
}

/* 游戏画布：限制最大尺寸为安卓9横屏 1920x1080 */
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 1920px;
  max-height: 1080px;
  margin: 0 auto;
}

/* ---------- 覆盖层通用 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 10, 0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.overlay.hidden { display: none; }

.panel {
  text-align: center;
  padding: 20px 40px;
  border: 1px solid #00ffff;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
  background: rgba(0, 20, 40, 0.7);
  border-radius: 8px;
  max-width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.panel h1 {
  font-size: 2.2rem;
  letter-spacing: 0.2em;
  color: #fff;
  text-shadow: 0 0 15px #00ffff;
  margin-bottom: 8px;
}

.accent { color: #00ffff; text-shadow: 0 0 10px #00ffff; }

.subtitle {
  font-size: 0.95rem;
  color: #aaa;
  margin-bottom: 15px;
  letter-spacing: 0.1em;
}

.tip {
  font-size: 0.8rem;
  color: #888;
  margin: 10px 0;
  line-height: 1.5;
}

.tip b { color: #ffdd00; }

/* ---------- 按键提示 ---------- */
.controls {
  margin: 12px 0;
  line-height: 1.8;
  font-size: 0.9rem;
}

.mobile-only { display: none; }

kbd {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid #00ffff;
  border-radius: 3px;
  background: rgba(0, 255, 255, 0.1);
  color: #00ffff;
  font-family: monospace;
  font-size: 0.85rem;
  margin: 0 2px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block;
  margin-top: 12px;
  padding: 10px 36px;
  font-size: 1rem;
  font-family: inherit;
  letter-spacing: 0.2em;
  color: #00ffff;
  background: transparent;
  border: 2px solid #00ffff;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn:hover, .btn:active {
  background: #00ffff;
  color: #000;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

#hud.hidden { display: none; }

.hud-left, .hud-right { display: flex; gap: 20px; }

.hud-item { display: flex; flex-direction: column; }

.hud-label {
  font-size: 0.6rem;
  color: #00ffff;
  letter-spacing: 0.2em;
  opacity: 0.7;
}

.hud-item span:not(.hud-label) {
  font-size: 1.2rem;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 8px #00ffff;
}

#lives {
  color: #ff4466 !important;
  text-shadow: 0 0 8px #ff4466 !important;
  letter-spacing: 2px;
}

/* ---------- 移动端虚拟摇杆 ---------- */
.touch-zone {
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 120px;
  height: 120px;
  z-index: 60;
  display: none;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
}

.touch-zone.hidden { display: none; }

#joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 255, 255, 0.4);
  background: rgba(0, 255, 255, 0.05);
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 50px;
  height: 50px;
  margin: -25px 0 0 -25px;
  border-radius: 50%;
  background: rgba(0, 255, 255, 0.5);
  box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
}

/* ---------- 移动端射击按钮 ---------- */
.touch-btn {
  position: fixed;
  bottom: 40px;
  right: 40px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(255, 68, 102, 0.6);
  background: rgba(255, 68, 102, 0.2);
  font-size: 2rem;
  z-index: 60;
  display: none;
  cursor: pointer;
  padding-bottom: env(safe-area-inset-bottom);
  padding-right: env(safe-area-inset-right);
}

.touch-btn.hidden { display: none; }
.touch-btn:active {
  background: rgba(255, 68, 102, 0.5);
  transform: scale(0.95);
}

/* ---------- 竖屏旋转提示 ---------- */
.rotate-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 999;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  padding: 20px;
}

.rotate-overlay .rotate-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: rotatePhone 1.5s ease-in-out infinite;
}

.rotate-overlay p {
  font-size: 1.2rem;
  color: #00ffff;
  letter-spacing: 0.1em;
}

@keyframes rotatePhone {
  0%, 20% { transform: rotate(0deg); }
  60%, 100% { transform: rotate(90deg); }
}

/* ============================================================
 * 设备检测
 * ============================================================ */
@media (hover: none) and (pointer: coarse) {
  .mobile-only { display: block; }
  .pc-only { display: none; }
}

/* 竖屏手机：显示旋转提示 */
@media (orientation: portrait) and (max-width: 900px) {
  .rotate-overlay { display: flex; }
}

/* 横屏手机：显示触摸控件 */
@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .touch-zone { display: block; }
  .touch-btn { display: block; }
}

/* 小横屏（手机横屏高度小）：压缩UI */
@media (max-height: 500px) {
  .panel { padding: 15px 25px; }
  .panel h1 { font-size: 1.6rem; }
  .subtitle { font-size: 0.8rem; margin-bottom: 8px; }
  .controls { margin: 8px 0; font-size: 0.8rem; }
  .btn { padding: 8px 28px; font-size: 0.9rem; margin-top: 8px; }
  .hud-left, .hud-right { gap: 15px; }
  .hud-item span:not(.hud-label) { font-size: 1rem; }
  .touch-zone { width: 90px; height: 90px; bottom: 15px; left: 15px; }
  #joystick-knob { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
  .touch-btn { width: 70px; height: 70px; bottom: 20px; right: 20px; font-size: 1.5rem; }
}
