/* 像素星舰指挥官 - 主样式表 */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0e27;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

#gameContainer {
  width: 100%;
  height: 100%;
  position: relative;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 按钮通用样式 */
button {
  font-family: inherit;
  outline: none;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 16px;
  transition: all 0.15s ease;
}

button:hover {
  transform: scale(1.05);
}

button:active {
  transform: scale(0.95);
  transition: transform 0.05s ease;
}

button:focus {
  outline: 2px solid rgba(255, 255, 255, 0.3);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* 移动端触控优化 */
@media (pointer: coarse) {
  button {
    min-width: 48px;
    min-height: 48px;
    padding: 12px 20px;
  }

  .build-btn {
    min-width: 70px;
    min-height: 70px;
    padding: 12px;
  }

  .menu-btn {
    min-height: 52px;
    font-size: 18px;
  }

  .action-btn {
    min-height: 48px;
    font-size: 14px;
  }
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .build-buttons {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .build-btn {
    min-width: 70px;
    min-height: 70px;
    font-size: 10px;
    padding: 12px 8px;
  }

  .unit-info-panel {
    min-width: 150px;
    font-size: 12px;
    padding: 10px;
  }

  .production-buttons {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .produce-btn {
    min-height: 50px;
    padding: 10px 6px;
  }
}

@media (max-height: 600px) {
  .hud-top-bar {
    height: 36px;
    font-size: 12px;
    padding: 0 12px;
  }

  .resource-bar {
    height: 28px;
    padding: 0 12px;
    gap: 20px;
  }

  .build-panel {
    bottom: 36px;
    padding: 8px;
  }

  .minimap {
    bottom: 36px;
    right: 12px;
  }

  .unit-info-panel {
    bottom: 36px;
    left: 12px;
  }
}

/* iOS Safari 特殊处理 */
@supports (-webkit-touch-callout: none) {
  /* iOS橡皮筋效果禁用 */
  body {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /* iOS安全区域适配 */
  .hud-top-bar {
    padding-top: max(0px, env(safe-area-inset-top));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }

  .resource-bar {
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
}

/* 加载和错误屏幕 */
#loading-screen, #error-screen {
  -webkit-user-select: none;
  user-select: none;
}

/* 横屏提示 */
@media (orientation: portrait) {
  #loading-screen::after {
    content: "请旋转设备横屏游玩";
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
  }
}
