/* 全屏自适应背景：cover 铺满视口（loading / main 共用，两侧可见）
 * 内容区宽高由引擎 designResolution 567×1008 + fitHeight 控制。
 */
html,
body {
  -ms-touch-action: none;
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  padding: 0;
  background-color: #0a1628;
  background-image: url("./assets/common_bg.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

body,
canvas,
div {
  display: block;
  outline: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);

  user-select: none;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -khtml-user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

body {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 0;
  border: 0;
  margin: 0;

  cursor: default;
  color: #888;
  /* 背景同时挂在 body：运行时代码会写入 body 的 inline 样式；若动态
   * 纹理尚未就绪，仍能使用构建模板内已复制的 common_bg.png。 */
  background-color: #0a1628;
  background-image: url("./assets/common_bg.png");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;

  text-align: center;
  font-family: Helvetica, Verdana, Arial, sans-serif;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  isolation: isolate;
}

/* Canvas may be portrait-width in an embedded host. Keep this layer in the
 * full browser viewport, behind both loading and main GameDiv. Runtime writes
 * --mm-outer-background from the imported common_bg SpriteFrame. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-color: #0a1628;
  background-image: var(--mm-outer-background, url("./assets/common_bg.png"));
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
}

canvas {
  background-color: rgba(0, 0, 0, 0);
}

/* GameDiv is the positioning parent for game-local DOM overlays. */
#GameDiv {
  /* Loading 场景在运行时布局脚本接管前就会显示。线上 Cocos 首帧可能把
   * 容器写到旧的全屏投影坐标，因此这里必须先以真实浏览器视口固定居中。 */
  margin: 0 !important;
  position: fixed !important;
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) !important;
  z-index: 1;
  background-color: transparent;
}

#GameDiv,
#Cocos3dGameContainer,
#GameCanvas {
  box-sizing: border-box;
  max-width: none;
}

#Cocos3dGameContainer,
#GameCanvas {
  width: 100%;
  height: 100%;
  background-color: transparent;
}

/* PC uses the original portrait game surface: fixed 567 × 1008.
 * H5 keeps the responsive full-host canvas below. */
@media (min-width: 567px) {
  #GameDiv,
  #Cocos3dGameContainer,
  #GameCanvas {
    width: 567px !important;
    height: 1008px !important;
  }
}

@media (max-width: 566px) {
  #GameDiv,
  #Cocos3dGameContainer,
  #GameCanvas {
    width: 100% !important;
    height: 100% !important;
  }
}

:root {
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);
}
