/* 我的世界枪战精英 —— 明亮简约（W18）。手机优先（W3）。 */
:root {
  --bg: #cfe3f2;
  --ink: #23313d;
  --ink-3: #6b7b88;
  --coral: #ef6f4d;
  --cream: #fff8ef;
  --tap: 44px;                     /* 最小触控尺寸（W3） */
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
#stage {
  display: block; width: 100vw; height: 100vh;
  touch-action: none;              /* 不然滑动会被浏览器抢走 */
}
.hide { display: none !important; }

/* ---------- 开屏 ---------- */
.boot {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  background: radial-gradient(120% 80% at 50% 34%, #fdfcfb 0%, #f4f7fa 60%, #e8eff6 100%);
  transition: opacity .5s ease, visibility .5s;
}
.boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-inner { text-align: center; padding-bottom: 56px; }
.boot-mark { margin: 0 auto 22px; width: 72px; animation: mark-in .7s cubic-bezier(.22,.86,.28,1) .05s both; }
.boot-mark img { width: 100%; height: auto; display: block; }
@keyframes mark-in {
  0% { opacity: 0; transform: translateY(12px) scale(.94); }
  100% { opacity: 1; transform: none; }
}
.boot-studio {
  font-size: 12.5px; font-weight: 500; letter-spacing: .34em; text-indent: .34em;
  color: var(--ink-3); animation: up .5s ease .4s both;
}
.boot-rule {
  width: 34px; height: 1px; margin: 18px auto 17px;
  background: #e3e9ee; transform-origin: center;
  animation: rule .55s cubic-bezier(.3,.9,.4,1) .54s both;
}
@keyframes rule { from { transform: scaleX(0); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
.boot-title {
  font-size: 25px; font-weight: 750; letter-spacing: .06em;
  color: var(--ink); animation: up .5s ease .64s both;
}
.boot-sub {
  margin-top: 7px; font-size: 12.5px; letter-spacing: .18em;
  color: var(--ink-3); animation: up .5s ease .78s both;
}
@keyframes up { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.boot-bar {
  position: absolute; left: 50%; bottom: 14%;
  transform: translateX(-50%);
  width: 92px; height: 3px; border-radius: 999px;
  background: #e3e9ee; overflow: hidden;
}
.boot-bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--coral); transition: width .25s ease; }
.boot-note {
  position: absolute; left: 0; right: 0; bottom: calc(14% - 34px);
  margin: 0; text-align: center; font-size: 12px; color: var(--ink-3);
}

/* ---------- 调试信息 ---------- */
.hud-debug {
  position: fixed; left: 10px; top: 10px; z-index: 50;
  padding: 8px 10px; border-radius: 10px;
  background: rgba(255,255,255,.82); backdrop-filter: blur(6px);
  font: 11px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink); white-space: pre;
  pointer-events: none;
}

/* ============================================================
   横屏触屏界面
   ============================================================
   手机横屏：左手管走、右手管打，两个大拇指各占一角。
   两条容易忽略的事：
     · 横屏时刘海在**左右两侧**，所以吃 safe-area-inset-left / right
     · 触摸区必须 touch-action:none，否则滑屏会被浏览器当成滚动/缩放抢走
   ============================================================ */

.touch-ui {
  position: fixed; inset: 0; z-index: 20;
  /* 横屏的刘海在左右两边 */
  padding: env(safe-area-inset-top) calc(env(safe-area-inset-right) + 4px)
           calc(env(safe-area-inset-bottom) + 4px) calc(env(safe-area-inset-left) + 4px);
  pointer-events: none;              /* 默认不吃事件，只有具体控件吃 */
  touch-action: none;
}

/* ---------- 两个触摸区 ---------- */

.t-zone {
  position: absolute; bottom: 0; top: 0;
  touch-action: none;
  pointer-events: auto;
}
.t-zone--stick { left: 0; width: 42%; }         /* 左手：走 */
.t-zone--look  { right: 0; width: 58%; }        /* 右手：看 */

/* 摇杆：手指落在哪就出现在哪，不做固定圆盘 */
.stick-knob {
  position: fixed; width: 92px; height: 92px; margin: -46px 0 0 -46px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .16);
  box-shadow: 0 6px 22px rgba(0, 0, 0, .18);
  pointer-events: none; z-index: 25;
  opacity: 0; transition: opacity .18s ease;
  backdrop-filter: blur(2px);
}
.t-zone--stick.active .stick-knob { opacity: 1; }

/* ---------- 右下角按钮群 ---------- */

.t-buttons {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 16px);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  width: 220px; height: 200px;
  pointer-events: none; z-index: 30;
}
.t-btn {
  position: absolute;
  display: grid; place-items: center;
  min-width: var(--tap); min-height: var(--tap);
  padding: 0;
  border: 2px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  background: rgba(31, 41, 51, .30);
  color: #fff;
  font: 600 14px/1 system-ui, -apple-system, "PingFang SC", sans-serif;
  opacity: .62;                       /* 挡不住画面，又看得见 */
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  transition: transform .08s ease, background .08s ease, opacity .08s;
}
.t-btn:active, .t-btn.on {
  transform: scale(.92);
  background: rgba(239, 111, 77, .85);
  border-color: #fff;
  opacity: 1;
}
/* 开火键最大，放最好按的位置 */
.t-btn--fire   { width: 88px; height: 88px; right: 0;    bottom: 6px;   font-size: 17px; opacity: .70; }
.t-btn--jump   { width: 64px; height: 64px; right: 100px; bottom: 22px; }
.t-btn--crouch { width: 58px; height: 58px; right: 62px;  bottom: 108px; }
.t-btn--reload { width: 58px; height: 58px; right: 148px; bottom: 106px; }
.t-btn--sprint { width: 54px; height: 54px; right: 174px; bottom: 30px; font-size: 13px; }

/* ---------- 血条 / 比分 / 弹药 ---------- */

.t-hud { position: absolute; pointer-events: none; z-index: 22; }
.t-hud--tl { left: calc(env(safe-area-inset-left) + 16px); top: calc(env(safe-area-inset-top) + 12px); }
.t-hud--tr { right: calc(env(safe-area-inset-right) + 16px); top: calc(env(safe-area-inset-top) + 12px); text-align: right; }

.t-score {
  display: flex; align-items: baseline; gap: 6px;
  font: 800 26px/1 system-ui, sans-serif; color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .45);
  margin-bottom: 8px;
}
.t-team--red  { color: #ff8a6b; }
.t-team--blue { color: #7fc4ff; }
.t-score i { font-style: normal; opacity: .7; font-size: 18px; }

.t-hp {
  position: relative; width: 132px; height: 10px;
  border-radius: 999px; overflow: hidden;
  background: rgba(0, 0, 0, .34);
  border: 1px solid rgba(255, 255, 255, .32);
}
.t-hp-bar {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #7ad07a, #3fae6a);
  transition: width .18s ease, background .2s ease;
}
.t-hp-bar.low { background: linear-gradient(90deg, #ff8f6b, #e04a3c); }
.t-hp-num {
  position: absolute; left: 0; right: 0; top: 13px;
  font: 700 12px/1 ui-monospace, monospace; color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}

.t-ammo {
  font: 800 30px/1 ui-monospace, SFMono-Regular, monospace;
  color: #fff; text-shadow: 0 2px 8px rgba(0, 0, 0, .5);
  display: flex; align-items: baseline; gap: 5px; justify-content: flex-end;
}
.t-ammo-mag.low { color: #ff9a7a; }
.t-ammo-res { font-size: 15px; opacity: .68; font-weight: 600; }
.t-weapon {
  margin-top: 3px; font: 600 12px/1.4 system-ui, sans-serif;
  color: rgba(255, 255, 255, .82); letter-spacing: .04em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}

/* ---------- 准星 ---------- */

.t-crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 36px; height: 36px; margin: -18px 0 0 -18px;
  pointer-events: none; z-index: 23;
}
.t-crosshair i { position: absolute; background: rgba(255, 255, 255, .88); box-shadow: 0 0 3px rgba(0, 0, 0, .6); }
.t-ch-dot { left: 50%; top: 50%; width: 2px; height: 2px; margin: -1px 0 0 -1px; border-radius: 50%; }
.t-ch-l { left: 0;  top: 50%; width: 9px; height: 2px; margin-top: -1px; }
.t-ch-r { right: 0; top: 50%; width: 9px; height: 2px; margin-top: -1px; }
.t-ch-t { top: 0;    left: 50%; height: 9px; width: 2px; margin-left: -1px; }
.t-ch-b { bottom: 0; left: 50%; height: 9px; width: 2px; margin-left: -1px; }

/* 命中：准星闪一下并收缩 */
.t-crosshair.hit { animation: ch-hit .16s ease; }
.t-crosshair.kill { animation: ch-kill .26s ease; }
@keyframes ch-hit {
  0% { transform: scale(1.5); filter: brightness(2); }
  100% { transform: scale(1); }
}
@keyframes ch-kill {
  0% { transform: scale(2.1) rotate(0deg); filter: brightness(2.4) hue-rotate(-25deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ---------- 击杀播报 ---------- */

.t-killfeed {
  position: absolute; right: calc(env(safe-area-inset-right) + 16px);
  top: calc(env(safe-area-inset-top) + 78px);
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  pointer-events: none; z-index: 22;
}
.t-kf {
  padding: 4px 10px; border-radius: 8px;
  background: rgba(0, 0, 0, .42); color: #fff;
  font: 600 12px/1.3 system-ui, sans-serif;
  animation: kf-in .18s ease both;
  transition: opacity .5s ease;
}
.t-kf.mine { background: rgba(239, 111, 77, .82); }
.t-kf.out { opacity: 0; }
@keyframes kf-in { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }

/* ---------- 中间提示 ---------- */

.t-toast {
  position: absolute; left: 50%; top: 28%;
  transform: translateX(-50%) translateY(-6px);
  padding: 7px 16px; border-radius: 999px;
  background: rgba(0, 0, 0, .5); color: #fff;
  font: 600 14px/1 system-ui, sans-serif;
  opacity: 0; pointer-events: none; z-index: 24;
  transition: opacity .18s ease, transform .18s ease;
}
.t-toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 竖屏提示 ---------- */

.rotate-hint {
  position: fixed; inset: 0; z-index: 9000;
  display: none; place-items: center;
  background: linear-gradient(170deg, #f7fafc, #e6eef6);
  color: var(--ink);
}
.rotate-hint.on { display: grid; }
.rotate-inner { text-align: center; padding: 0 24px; }
.rotate-icon { color: var(--coral); margin-bottom: 16px; animation: rot-wobble 2.2s ease-in-out infinite; }
@keyframes rot-wobble {
  0%, 60%, 100% { transform: rotate(0deg); }
  75% { transform: rotate(-88deg); }
  85% { transform: rotate(-92deg); }
}
.rotate-title { margin: 0; font-size: 19px; font-weight: 700; }
.rotate-sub { margin: 6px 0 0; font-size: 13px; color: var(--ink-3); }

/* ---------- 横屏窄高度时把 UI 收一收 ---------- */
@media (orientation: landscape) and (max-height: 420px) {
  .t-score { font-size: 22px; margin-bottom: 5px; }
  .t-hp { width: 112px; height: 8px; }
  .t-ammo { font-size: 25px; }
  .t-btn--fire { width: 78px; height: 78px; }
}

/* ---------- 自检面板（?selftest=1）---------- */
.selftest {
  position: fixed; left: 8px; top: 8px; z-index: 9500;
  max-width: min(560px, 96vw); max-height: 92vh; overflow: auto;
  padding: 10px 13px; border-radius: 12px;
  background: rgba(244, 249, 252, .96);
  border: 2px solid #9db4c4;
  font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #1f2b33;
  box-shadow: 0 10px 32px rgba(20, 40, 60, .22);
}
.selftest.all-ok { border-color: #4a9d6a; }
.selftest.has-bad { border-color: #d0563c; }
.st-head { font-size: 14px; font-weight: 800; margin-bottom: 6px; }
.selftest.all-ok .st-head { color: #2f7a4f; }
.selftest.has-bad .st-head { color: #b8442c; }
.st-body b { font-weight: 800; }
.st-body b.ok { color: #2f7a4f; }
.st-body b.bad { color: #c0402a; }
.st-body i { font-style: normal; color: #6b7b88; }

/* ---------- 加载状态（纯 DOM，任何环境都能读）---------- */
.app-status {
  position: fixed; left: 8px; bottom: 8px; z-index: 60;
  padding: 4px 9px; border-radius: 8px;
  background: rgba(0, 0, 0, .42); color: #fff;
  font: 11px/1.5 ui-monospace, monospace;
  pointer-events: none; opacity: .8;
  max-width: 92vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
