/* CRUSH 网页版 · 外壳样式
 * 画布之外的一切:底色、居中框、首屏、胶囊、页脚。
 * 游戏画面本身全部由 Canvas 绘制,这里不参与。 */

:root {
  --ink: #07040c;
  --pink: #ff2f92;
  --pink-soft: #ffb3d9;
  --violet: #9f5cff;
  --text: #ffe9f4;
  --muted: rgba(255, 233, 244, 0.52);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* 三级兜底:JS 量出来的可视高度 > 动态视口高度 > 老式 vh。
     手机上必须用前两者 —— 100vh 在地址栏展开时比可视区还高,页脚会被顶出屏幕。 */
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100dvh);
  background: var(--ink);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  /* 游戏是全屏手势操作,页面本身不该滚动,也不要下拉刷新和双击缩放 */
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

/* 画布在上、页脚在下,整组垂直居中。
   页脚是正常流里的元素而不是浮层 —— 备案号必须实打实占版面,不能盖在画面上。 */
body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ---------- 舞台 ---------- */
#frame {
  position: relative;
  line-height: 0;
}

#stage {
  display: block;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* 宽屏(桌面/平板横屏)才有的"手机框":圆角、描边、外发光,
   让居中的竖屏画布看着像块屏幕而不是漂在黑底上的一个方块。 */
.is-inset #frame {
  border-radius: 26px;
  padding: 0;
  box-shadow:
    0 0 0 1px rgba(255, 47, 146, 0.28),
    0 0 60px rgba(255, 47, 146, 0.16),
    0 30px 80px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}
.is-inset #stage { border-radius: 26px; }

/* 宽屏时给页面铺一层氛围光,免得四周是一整片死黑 */
.is-inset body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60vw 60vw at 78% 8%, rgba(159, 92, 255, 0.16), transparent 70%),
    radial-gradient(50vw 50vw at 18% 92%, rgba(255, 47, 146, 0.13), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

/* ---------- 网页版胶囊 ---------- */
#capsule {
  position: fixed;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0;
  z-index: 20;
}

#capsule button {
  width: 44px;
  height: 32px;
  border: 1px solid rgba(255, 47, 146, 0.5);
  border-radius: 16px;
  background: rgba(10, 4, 16, 0.72);
  color: var(--pink-soft);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s, transform 0.1s;
}
#capsule button:hover { background: rgba(255, 47, 146, 0.22); }
#capsule button:active { transform: scale(0.94); }
#capsule button[hidden] { display: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 16%;
  transform: translate(-50%, 8px);
  max-width: 74vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 4, 16, 0.9);
  border: 1px solid rgba(255, 47, 146, 0.4);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 页脚(备案信息) ---------- */
/* 粤管局核查标准:任意打开网站页面,都能清晰看见备案号 + 工信部官方链接。
   所以这里有三条硬约束,改样式时别破坏:
     1. 所有屏幕尺寸常驻显示(不是只在宽屏出现,手机上同样要看得见)
     2. 正常流元素,不折叠、不放进弹窗
     3. 文字对比度足够(#e8dbe6 对近黑底约 14:1),不能调淡成"融进背景" */
#foot {
  flex: 0 0 auto;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 12px;
  align-items: center;
  justify-content: center;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  font-size: 11.5px;
  line-height: 1.5;
  color: #b9a8b6;
  background: var(--ink);
  text-align: center;
  z-index: 10;
}

#foot a {
  color: #c2b2c0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
#foot a:hover { color: #fff; }
#foot a[hidden] { display: none; }

/* 备案号排在最前。字号比正文略小、颜色比正文略暗(按要求),
   但仍是 #c2b2c0 对近黑底约 9:1 —— 远高于可读门槛,不算"浅色文字融合背景"。
   再往下调就会踩到核查红线了,别改。 */
#foot-icp {
  font-size: 10.5px;
  letter-spacing: 0.01em;
}

/* 窄屏放不下就换行,页脚高度是实测的(platform.js 的 footerRoom),
   多一行画布就自动少一行,不会把字挤出屏幕。 */
@media (max-width: 520px) {
  #foot { font-size: 10.5px; gap: 1px 8px; padding-top: 7px; }
  #foot-icp { font-size: 10px; }
}

/* ---------- 崩溃兜底 ---------- */
#fatal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 2, 8, 0.94);
}
#fatal[hidden] { display: none; }

.fatal-card {
  max-width: 330px;
  padding: 22px 20px;
  border: 1px solid rgba(255, 47, 146, 0.34);
  border-radius: 16px;
  background: rgba(18, 8, 28, 0.9);
  text-align: center;
}
.fatal-card h2 { margin: 0 0 10px; font-size: 16px; }
#fatal-msg {
  margin: 0 0 18px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  word-break: break-word;
}
.fatal-card button {
  padding: 10px 26px;
  border: 0;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
