html {
  -ms-touch-action: none;
  width: 100%;
  height: 100%;
}

html.browser-mode,
html.browser-mode body,
html.standalone-mode,
html.standalone-mode body {
  position: fixed;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
}

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

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

body {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  margin: 0;
  cursor: default;
  color: #888;
  background-color: #000;
  text-align: center;
  font-family: Helvetica, Verdana, Arial, sans-serif;
  overflow: hidden;
}

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

#GameDiv,
#Cocos3dGameContainer,
#GameCanvas {
  width: 100%;
  height: 100%;
}

/* 与 HTML splash 同底图：关掉 splash 淡出时不会露黑（替代原 Creator 插屏托底） */
#GameDiv {
  background-color: #000;
  background-image: url("./splash-bg.jpg");
  background-repeat: no-repeat;
  background-position: center center;
  background-size: auto 100%;
}

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

#splash {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background-color: #000;
  background-image: url("./logo.png"), url("./splash-bg.jpg");
  background-repeat: no-repeat, no-repeat;
  background-position: center center, center center;
  /* logo 缩小一半，保持原比例；背景仍铺满高度 */
  background-size: 22.5% auto, auto 100%;
  z-index: 1;
  pointer-events: none;
}

#splash.is-hidden {
  opacity: 0;
  visibility: hidden;
  /* 稍长淡出，底下已有同款 splash-bg，观感更丝滑 */
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

/*
 * HTML 闪屏进度：对齐 GeneralProgress（相对容器比例，避免 100vw 在强制横屏下错位）
 * - 底图九宫格宽 985 / 高 65
 * - 条图 985x56，高度约底图的 56/65，水平 fillRange 裁剪
 * - tip：白字粗体，约 40/985 相对进度条宽度
 */
#splash-progress {
  --bar-w: 985;
  --track-h: 65;
  --fill-h: 56;
  position: absolute;
  left: 50%;
  bottom: 10%;
  width: min(51.302%, 985px); /* 985/1920 */
  transform: translateX(-50%);
  z-index: 2;
  container-type: inline-size;
  container-name: splash-progress;
}

#splash-progress-track {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 985 / 65;
  height: auto;
  container-type: inline-size;
  container-name: splash-track;
  /* 九宫格：只锁左右圆头，高度随 aspect-ratio */
  border-style: solid;
  border-width: 0;
  border-image-source: url("./sp_progress_base.png");
  border-image-slice: 0 40 0 40 fill;
  border-image-width: 0 4.06%; /* 40/985 */
  border-image-repeat: stretch;
  background-color: transparent;
}

#splash-progress-fill {
  position: absolute;
  left: 2px; /* 向右 +2px */
  top: 50%;
  width: 2%;
  max-width: calc(100% - 2px);
  /* 56/65，与 GeneralProgress Bar 相对底框比例一致 */
  height: 86.1538%;
  /* 垂直居中后再上移 2px */
  transform: translateY(calc(-50% - 2px));
  overflow: hidden;
  /* 宽度由 JS 逐帧缓动，避免 CSS transition 造成跳跃感 */
  transition: none;
}

#splash-progress-bar {
  /* 宽度锁定为底框内容宽，由 fill 做左侧裁剪 */
  width: 100cqw;
  height: 100%;
  background: url("./sp_progress_bar.png") left center / 100% 100% no-repeat;
}

#splash-progress-tips {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8cqw;
  margin-top: 1.8cqw;
  color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  /* 40/985 ≈ 4.06% of bar width；无 cqw 时回退 */
  font-size: clamp(16px, 4.06cqw, 40px);
  line-height: 1.25;
  white-space: nowrap;
}

#splash-progress-text,
#splash-progress-percent {
  color: #ffffff;
}

#landscape-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  touch-action: none;
}

html.force-landscape {
  background: #000;
  overflow: hidden;
}

html.force-landscape body {
  overflow: hidden;
}

/* 竖屏兜底：JS 会用像素 + margin-left 覆盖，避免 translateY 半屏黑 */
html.force-landscape #landscape-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vh;
  height: 100vw;
  margin: 0;
  margin-left: 100vw;
  transform: rotate(90deg);
  transform-origin: top left;
  -webkit-transform: rotate(90deg);
  -webkit-transform-origin: top left;
}

html.force-landscape #GameDiv,
html.force-landscape #Cocos3dGameContainer,
html.force-landscape #GameCanvas {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  transform: none !important;
  -webkit-transform: none !important;
}

/* WebView：一出现就铺满宿主（JS 还会像素加固；不依赖 force-landscape） */
#webview-wrapper,
#webview-wrapper iframe,
iframe#webview {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  transform: none !important;
  -webkit-transform: none !important;
  box-sizing: border-box !important;
}

html.force-landscape #webview-wrapper,
html.force-landscape #webview-wrapper iframe,
html.force-landscape iframe#webview {
  position: absolute !important;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
}

/* Return/Shop：在 #landscape-wrapper 内，跟随 rotate(90deg) */
html.force-landscape #movableView {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  transform: none !important;
  -webkit-transform: none !important;
  z-index: 10001 !important;
}

#rotate-hint {
  display: none;
}

html.force-landscape #rotate-hint {
  display: none;
}
