html {
  -ms-touch-action: none;
}

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: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;

  cursor: default;
  color: #888;
  background-color: #333;

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

  display: flex;
  flex-direction: column;

  /* 手机适配：禁止下拉刷新/橡皮筋回弹（安卓 Chrome 上滑会触发整页回弹，
     横屏玩的时候表现为「画面跟着手指抖」）；禁掉长按选中和图片拖拽。 */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

canvas {
  background-color: rgba(0, 0, 0, 0);
  /* 让画布固定铺满视口：配合 width/height 100% 与 JS 的视口同步，
     避免 iOS Safari 地址栏收起/展开时用旧高度、留下黑边或按钮错位 */
  position: fixed;
  top: 0;
  left: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
  /* 所有手势交给游戏自己处理（引擎已经在 pointer/touch 上 preventDefault，
     这里再兜一层，防止系统双击缩放/长按菜单打断操作） */
  touch-action: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

#GameDiv, #Cocos3dGameContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#GameDiv {
  /* 刘海/圆角屏：不留内边距（游戏自己按 safe-area 摆 UI），但要保证铺满 */
  background-color: #181c28;
}

: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);
}

/* 竖屏提示层：小屏手机横屏体验才正常；竖屏时盖一层"请横屏"，等用户转向后自动消失。
   苹果手机对竖屏支持很差（按钮会挤在一起），所以强制引导横屏。 */
#ccRotateHint {
  display: none;
  position: fixed;
  /* 【PRELOAD_COMPAT_V1】老内核不认识 inset 简写 → 必须显式写四边，否则整个提示层塌陷 */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 99999;
  background: #181c28;
  color: #dfe6f5;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 18px;
  letter-spacing: 1px;
}
#ccRotateHint.on { display: flex; }
#ccRotateHint .ico {
  width: 64px; height: 64px; margin-bottom: 18px;
  border: 3px solid #dfe6f5; border-radius: 12px;
  animation: ccRot 1.6s ease-in-out infinite;
}
@keyframes ccRot {
  0%, 40% { transform: rotate(0deg); }
  70%, 100% { transform: rotate(90deg); }
}

/* ===== 资源加载页（DOM 版）=====
   和游戏内加载层用**同一套素材**（assets/loading/bg|logo|bar_frame|bar_fill），
   位置比例也照抄 Ui.ldLayout：logo 宽 = 42.5%、进度条宽 = 24.9%，
   垂直位置分别是 52.3% / 89.95% / 95.8%（安全区中心的偏移换算成百分比）。
   Cocos 自带启动页已在 src/settings.json 里关掉（splashScreen.totalTime=0），
   所以从打开页面到进入主菜单，玩家只会看到这一个加载页。 */
#ccPreload {
  position: fixed;
  /* 【PRELOAD_COMPAT_V1】关键修复：inset 简写是 Chrome 87+ 才有的，老内核会忽略它
     → 容器失去宽高塌陷成 0×0 → 加载页整个看不见（玩家反馈的现象）。
     显式四边写法所有内核都认。 */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  z-index: 9000;
  background: #1a5fa6;
  overflow: hidden;
  opacity: 1;
  transition: opacity .28s ease;
  -webkit-user-select: none;
  user-select: none;
}
#ccPreload.cc-out { opacity: 0; pointer-events: none; }
#ccPreload .p-bg {
  position: absolute;
  /* 【PRELOAD_COMPAT_V1】同上：四边兜底 */
  top: 0; right: 0; bottom: 0; left: 0;
  inset: 0;
  background: url('assets/loading/bg.png') center center / cover no-repeat;
}
#ccPreload .p-logo {
  position: absolute;
  left: 50%;
  top: 52.3%;
  width: 42.5%;
  max-width: 900px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#ccPreload .p-bar {
  position: absolute;
  left: 50%;
  top: 89.95%;
  width: 24.9%;
  min-width: 150px;
  transform: translate(-50%, -50%);
  background: url('assets/loading/bar_frame.png') center center / 100% 100% no-repeat;
  /* 321x31；【PRELOAD_COMPAT_V1】老内核没有 aspect-ratio（Chrome 88+）→ 改用它之前就有的
     「::before + padding-top 百分比」撑高：padding 百分比相对元素自身宽度解析，
     31/321 = 9.6573%，与 aspect-ratio 完全等价。 */
}
#ccPreload .p-bar::before {
  content: '';
  display: block;
  padding-top: 9.6573%;   /* 31 / 321 */
}
#ccPreload .p-fill {
  /* 和游戏内一致：从左端开始涨（fillStart=0），不是居中变宽。
     左右各留 1.87%（=(321-309)/2/321），最大宽度 96.26%。 */
  position: absolute;
  left: 1.87%;
  top: 50%;
  width: 96.26%;                 /* 309/321 */
  height: 61.3%;                 /* 19/31 */
  transform: translateY(-50%);
  background: url('assets/loading/bar_fill.png') left center / 100% 100% no-repeat;
  border-radius: 999px;
  /* 用裁切而不是拉伸：和游戏内 fillRange 一样，条纹纹理保持原始比例 */
  clip-path: inset(0 100% 0 0);
  transition: clip-path .12s linear;
}
#ccPreload .p-tip {
  position: absolute;
  left: 50%;
  top: 95.8%;
  transform: translate(-50%, -50%);
  color: #fff;
  /* 【PRELOAD_COMPAT_V1】clamp() 是 Chrome 79+；先给固定字号兜底，
     老内核忽略下面那行 clamp 时会退回 18px，而不是继承 body 的默认值。 */
  font-size: 18px;
  font-size: clamp(13px, 2.9vh, 26px);
  font-family: system-ui, 'PingFang SC', 'Microsoft YaHei', Arial;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55), 0 0 6px rgba(0, 0, 0, .35);
  white-space: nowrap;
}
/* 【CACHE_ON_V1】首次会一次性下完全部资源（约 10MB），提前说明，
   免得玩家以为「卡住了 / 一直在下载」；回访命中缓存时这一屏一闪而过。 */
#ccPreload .p-note {
  position: absolute;
  left: 50%;
  top: 78%;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, .88);
  font-size: 13px;
  font-size: clamp(11px, 2vh, 18px);
  font-family: system-ui, 'PingFang SC', 'Microsoft YaHei', Arial;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .55);
  white-space: nowrap;
  pointer-events: none;
}
