:root {
  --bg: #0b0b10;
  --panel: #15151c;
  --line: #2a2a35;
  --primary: #7c6cff;
  --red: #ff5c5c;
  --gold: #ffd23e;
  --green: #7ee787;
  --muted: #9a9aa8;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: #e8e8ee;
  font-family: var(--mono);
  user-select: none;
  -webkit-user-select: none;
}
#wrap { position: fixed; inset: 0; }

/* ---- 舞台：整个世界（页面 + 地面），相机用位移实现 ---- */
#stage { position: absolute; inset: 0; background: #0d0d13; overflow: hidden; }
#world { position: absolute; top: 0; left: 0; width: 100%; will-change: transform; }
#target {
  width: 100%; border: 0; display: block;
  pointer-events: none;
  background: var(--bg);
}
#fx { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 3; }
#floor {
  position: absolute; left: 0; right: 0; height: 56px; z-index: 2;
  background: linear-gradient(#17171f, #0e0e13);
  border-top: 3px solid var(--line);
}
#floor::before {
  content: ""; position: absolute; top: -34px; left: 0; right: 0; height: 34px;
  background: repeating-linear-gradient(90deg, #14141b 0 34px, #101018 34px 68px);
  opacity: .8;
}
#loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 8;
  font-size: 13px; letter-spacing: .2em; color: var(--muted);
}
#loading.done { display: none; }

/* ---- 玩家（clawd 本体，屏幕坐标定位：top = 世界 y - camY，由 JS 每帧更新） ---- */
#player {
  position: absolute; width: 28px; height: 40px; z-index: 4;
  left: 0; top: 0;
  will-change: left, top;
}
#sprite {
  position: absolute; left: 50%; bottom: -12px;
  height: 58px; width: auto; max-width: none;
  transform: translateX(-50%);
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 0 #000);
}
#player.flip #sprite { transform: translateX(-50%) scaleX(-1); }
#gun {
  position: absolute; left: 10px; top: 2px;
  transform-origin: 0 12px;
  line-height: 0;
}
#gun svg { display: block; }
#jetpack {
  position: absolute; left: -6px; top: 8px;
  width: 8px; height: 18px; background: #55556a; border-radius: 2px;
  opacity: 0; transition: opacity .1s;
}
#player.flying #jetpack { opacity: 1; }
#player.flying::after {
  content: ""; position: absolute; left: -6px; top: 34px;
  width: 6px; height: 12px;
  background: linear-gradient(var(--gold), var(--red));
  animation: jet .12s infinite alternate;
}
@keyframes jet { from { transform: scaleY(1); } to { transform: scaleY(1.6); } }

/* ---- HUD ---- */
#hud {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none;
}
#progressWrap { display: flex; flex-direction: column; align-items: center; gap: 4px; }
#progressLabel { font-size: 12px; letter-spacing: .12em; color: #cfcfda; }
#progressLabel b { color: var(--red); font-size: 15px; }
#progressLabel span { color: var(--muted); font-size: 11px; }
#progressBar {
  width: min(460px, 72vw); height: 14px; background: #0009;
  border: 2px solid var(--line); position: relative;
}
#progressFill {
  position: absolute; inset: 0; width: 0%;
  background: repeating-linear-gradient(45deg, var(--red) 0 8px, #ff8a8a 8px 16px);
  transition: width .25s;
}
#weapons { display: flex; gap: 5px; pointer-events: auto; flex-wrap: wrap; justify-content: center; }
.wslot {
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  color: var(--muted); background: #0009; border: 2px solid var(--line);
  padding: 4px 8px; cursor: pointer; transition: all .15s;
}
.wslot i { font-style: normal; color: var(--primary); margin-right: 4px; font-weight: 700; }
.wslot.active { color: #fff; border-color: var(--primary); background: #16162a; }
.wslot.active i { color: var(--gold); }
#hint { font-size: 11px; color: var(--muted); letter-spacing: .08em; text-shadow: 0 1px 0 #000; }
@media (max-width: 720px) { #hint { display: none; } .wslot { padding: 3px 5px; font-size: 10px; } }

/* ---- 触屏：虚拟摇杆（左下）+ 喷气 + 大开火键（右下） ---- */
/* 只在触屏设备上显示/启用 */
#touch { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; pointer-events: none; }
#touch button { font-family: var(--mono); }

#stickZone {
  position: absolute; left: calc(14px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom));
  width: 128px; height: 128px; z-index: 2;
  pointer-events: auto;
  touch-action: none;
}
#stick {
  position: absolute; left: 50%; top: 50%;
  width: 74px; height: 74px;
  border: 2px solid var(--line);
  background: #000a;
  box-shadow: 4px 4px 0 #000a;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#knob {
  position: absolute; left: 50%; top: 50%;
  width: 30px; height: 30px;
  background: var(--primary);
  border: 2px solid #000;
  box-shadow: 3px 3px 0 #000a;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#stickZone.active #knob { background: var(--gold); }

#tJet {
  position: absolute; right: calc(96px + env(safe-area-inset-right)); bottom: calc(34px + env(safe-area-inset-bottom));
  width: 58px; height: 46px;
  font-size: 13px; font-weight: 700;
  color: #fff; background: #000a; border: 2px solid var(--line);
  box-shadow: 3px 3px 0 #000a;
  pointer-events: auto;
  touch-action: none;
}
#tJet:active { background: var(--green); color: #000; }

#tFire {
  position: absolute; right: calc(14px + env(safe-area-inset-right)); bottom: calc(12px + env(safe-area-inset-bottom));
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 3px solid var(--red);
  background: rgba(255, 92, 92, .18);
  color: var(--red);
  font-size: 17px; font-weight: 700; letter-spacing: .1em;
  box-shadow: 4px 4px 0 #000a, inset 0 0 18px rgba(255, 92, 92, .25);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
#tFire.down {
  background: var(--red);
  color: #fff;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000a, inset 0 0 18px rgba(255, 255, 255, .35);
}
#touch button:active { filter: brightness(1.25); }

/* 触屏上隐藏元素选择光标、防止长按选中 */
html.has-touch #wrap { -webkit-tap-highlight-color: transparent; }
/* 触屏上把底部提示换成触控提示 */
html.has-touch #hint { display: none; }

/* 桌面（精细指针）完全不显示触控层，键盘鼠标行为与旧版一致 */
@media (hover: hover) and (pointer: fine) { #touch { display: none !important; } }

/* ---- 面板 ---- */
#intro, #win {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 5, 9, .78); backdrop-filter: blur(3px);
}
#intro .panel, #win .panel {
  width: min(580px, 92vw);
  background: var(--panel); border: 2px solid var(--line);
  box-shadow: 8px 8px 0 #000a;
  padding: 28px 30px; text-align: center;
}
#intro h1, #win h1 { font-size: 26px; letter-spacing: .06em; margin-bottom: 14px; }
#intro p, #win p { font-size: 13px; line-height: 1.9; color: #c9c9d6; }
#intro .keys { color: var(--muted); font-size: 12px; margin: 10px 0 18px; }
#intro .fine { color: var(--muted); font-size: 11px; margin-top: 16px; line-height: 1.7; }
#intro b { color: var(--gold); }
#startBtn, #againBtn {
  font-family: var(--mono); font-size: 15px; font-weight: 700; letter-spacing: .15em;
  background: var(--red); color: #fff; border: 0; padding: 12px 34px;
  cursor: pointer; box-shadow: 4px 4px 0 #000a; transition: transform .1s;
}
#startBtn:disabled { background: #3a3a4a; color: #888; cursor: wait; }
#startBtn:not(:disabled):hover, #againBtn:hover { transform: translate(-1px, -1px); }
.urlrow { display: flex; gap: 8px; margin: 0 0 18px; }
.urlrow input {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; color: #e8e8ee;
  background: #0b0b10; border: 2px solid var(--line); padding: 10px 12px; outline: none;
}
.urlrow input:focus { border-color: var(--primary); }
.urlrow button {
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em; white-space: nowrap;
  background: var(--red); color: #fff; border: 0; padding: 10px 14px; cursor: pointer;
}
#win .row { display: flex; gap: 10px; justify-content: center; margin-top: 20px; }
#win .ghost {
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em; text-decoration: none;
  color: var(--muted); border: 2px solid var(--line); padding: 11px 16px;
}
#win .ghost:hover { color: #fff; border-color: var(--primary); }
#winStats { color: var(--gold) !important; font-size: 15px !important; }

#wrap.shake { animation: shk .3s; }
@keyframes shk {
  0%,100% { transform: translate(0, 0); }
  25% { transform: translate(-5px, 3px); }
  50% { transform: translate(4px, -4px); }
  75% { transform: translate(-3px, -2px); }
}

/* 目标页内被打光的元素（整块碎完才隐藏） */
.dm-done { visibility: hidden !important; }
