html {
  -ms-touch-action: none;
  width: 100%;
  height: 100%;
}

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);
}

/* Remove spin of input type number */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    /* display: none; <- Crashes Chrome on hover */
    -webkit-appearance: none;
    margin: 0; /* <-- Apparently some margin are still there even though it's hidden */
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  overflow: hidden;

  cursor: default;
  color: #888;
  background-color: #000;

  text-align: center;
  font-family: Helvetica, Verdana, Arial, sans-serif;

  display: flex;
  align-items: center;
  justify-content: center;
}

canvas {
  background-color: rgba(0, 0, 0, 0);
}

#GameDiv {
  position: relative;
  width: 100vw;
  height: min(100vh, 56.25vw);
  height: min(100dvh, 56.25vw);
  max-width: 100vw;
  max-height: min(100vh, 56.25vw);
  max-height: min(100dvh, 56.25vw);
  flex: 0 0 auto;
  margin: 0;
  overflow: hidden;
  background-color: transparent;
  /* 提升为独立 GPU 合成层：键盘开合会触发浏览器整页重新合成，独立层可减少 canvas 被波及而整页黑屏 */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

/* 竖屏手机预旋转：与 index 模板内联的预旋转保持一致。JS（applyWebCanvasFit）接管前先把
   #GameDiv 按虚拟横屏旋转铺满，避免首帧出现一条横向窄带再跳变。仅限触屏小屏设备。 */
@media (orientation: portrait) and (pointer: coarse) and (max-width: 920px) {
  #GameDiv {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 100vh;
    width: 100dvh;
    height: min(100vw, 56.25vh);
    height: min(100vw, 56.25dvh);
    max-width: none;
    max-height: none;
    transform: translate(-50%, -50%) rotate(90deg);
    -webkit-transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
  }
}

#WebSplash {
  position: absolute;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  background: #000;
  opacity: 1;
  pointer-events: none;
  transition: opacity 240ms ease-out;
}

#WebSplash > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

#WebSplash.is-hidden {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  #WebSplash {
    transition: none;
  }
}

#Cocos3dGameContainer, #GameCanvas {
  width: 100%;
  height: 100%;
}

#Cocos3dGameContainer {
  position: relative;
  overflow: hidden;
}

#GameCanvas {
  display: block;
  touch-action: none;
  /* 同上：canvas 独立合成层，避免键盘开合重合成时渲染表面被清空黑屏 */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

: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);
}
