/* 移动端优先 + 彻底禁用误触(双击缩放/长按菜单/选中/滚动) */
* { box-sizing: border-box; margin: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none; user-select: none;
    touch-action: none; }
html, body { height: 100%; overscroll-behavior: none; touch-action: none; }
body {
  background: #101018; color: #eee;
  font-family: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  position: fixed; inset: 0; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; }

h1 { color: #ffd740; text-align: center; font-size: 40px;
  text-shadow: 3px 3px 0 #b71c1c, 0 0 18px rgba(255,215,64,.35); letter-spacing: 6px; margin-top: 8vh; }
.sub { text-align: center; color: #999; margin: 10px 0 22px; font-size: 14px; }
h2 { color: #4ca6ff; font-size: 16px; margin: 12px 0 8px; }

/* 屏幕显隐: 用 :not(.hidden) 保证 hidden 永远生效(避免被 ID 选择器的 display 覆盖) */
.screen { display: none; }
.screen:not(.hidden) { display: block; flex: 1; overflow-y: auto; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
#screen-game { padding: 0; background: #000; }
#screen-game:not(.hidden) { display: flex; flex-direction: column; }

.card { background: #1a1a28; border: 1px solid #2a2a40; border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
label { font-size: 13px; color: #bbb; display: flex; align-items: center; gap: 5px; }
.check { margin: 6px 0 4px; }

input[type=text], select {
  width: 100%; padding: 14px 12px; margin: 6px 0; border-radius: 10px;
  border: 1px solid #333; background: #232338; color: #eee; font-size: 16px;
}
button {
  display: block; width: 100%; padding: 15px 12px; border-radius: 12px;
  border: 1px solid #333; background: #2c2c4a; color: #eee; font-size: 16px; cursor: pointer;
}
button:active { transform: translateY(1px); background: #3a3a60; }
button.primary { background: #e65100; border-color: #ff9800; font-weight: 700; }
button.primary:active { background: #ff8c1a; }
.start-btn { background: #2e7d32; border-color: #66bb6a; }
.start-btn:active { background: #43a047; }
button.hidden { display: none; }
#room-id { color: #ffd740; }

ul { list-style: none; }
#room-list li { padding: 4px 0; border-bottom: 1px dashed #2c2c40; }
li button { text-align: left; background: #222238; }
.dim { color: #666; }
.hint { color: #8bc34a; margin-top: 10px; font-size: 13px; }
.hint:empty { display: none; }
.hint.error { color: #ff8a80; }

/* ---------- 对局 ---------- */
#hud-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px; font-size: 15px; font-weight: 700;
  background: rgba(0,0,0,.55); color: #ffd740; z-index: 5;
}
#game-wrap { position: relative; flex: 1; min-height: 0; }
canvas#cv {
  width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated;
  background: #000; display: block;
}
#hud-kills {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  background: rgba(0,0,0,.55); z-index: 5; font-size: 13px;
}
.kill-chip { padding: 3px 10px; border-radius: 20px; background: rgba(255,255,255,.08); }
.kill-chip b { color: #4caf50; }

#name-layer { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.name-tag {
  position: absolute; transform: translateX(-50%); white-space: nowrap;
  font-size: 11px; font-weight: 800; color: #fff; line-height: 1;
  background: rgba(0,0,0,.55); border-radius: 7px; padding: 1px 6px;
  border: 2px solid #fff; pointer-events: none;
}

/* 触控 */
#controls { position: absolute; inset: 0; pointer-events: none; z-index: 4; }

/* 左半屏: 隐形浮动轮盘区域(按下任意处才呼出轮盘) */
#joy-zone {
  position: absolute; left: 0; top: 0; width: 55%; height: 100%;
  pointer-events: none; touch-action: none;
}
#controls.active #joy-zone { pointer-events: auto; }

#joystick {
  position: absolute; display: none; width: 130px; height: 130px;
  border: 2px solid rgba(255,255,255,.4); border-radius: 50%;
  background: rgba(255,255,255,.10); pointer-events: none; touch-action: none;
  opacity: 0; transform: scale(.5); transition: opacity .12s ease, transform .12s ease;
}
#joystick.on { display: block; opacity: 1; transform: scale(1); }
#joy-knob {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px;
  margin: -22px 0 0 -22px; border-radius: 50%; background: rgba(255,255,255,.55);
}

/* 攻击组(王者式): 大拳 + 周围小技能, 整体靠右 */
#btns { position: absolute; right: 12px; bottom: 24px; width: 168px; height: 168px; display: none; }
#controls.active #btns { display: block; pointer-events: auto; }
.act-btn {
  position: absolute;
  border-radius: 50%; border: 3px solid rgba(255,255,255,.55); color: #fff;
  font-weight: 800; pointer-events: auto; touch-action: none;
  box-shadow: 0 4px 10px rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center;
}
#btn-a {  /* 大拳: 右下主攻击 */
  right: 0; bottom: 0; width: 100px; height: 100px; font-size: 30px;
  background: radial-gradient(circle at 50% 35%, #ff6b4a, #d32f2f);
}
#btn-b {  /* 踢: 拳的左上方 */
  right: 108px; bottom: 62px; width: 64px; height: 64px; font-size: 18px;
  background: radial-gradient(circle at 50% 35%, #4fc3f7, #0277bd);
}
#btn-jump {  /* 跳: 拳的正上方偏左 */
  right: 58px; bottom: 112px; width: 58px; height: 58px; font-size: 16px;
  background: radial-gradient(circle at 50% 35%, #ffd740, #f57f17);
}
.act-btn.pressed { transform: translateY(2px) scale(.92); filter: brightness(1.25); }

/* ---------- 结算 ---------- */
#result-list li { font-size: 17px; padding: 8px 4px; border-bottom: 1px dashed #2c2c40; }

/* ---------- 造人 ---------- */
.cc-label { display: block; margin-bottom: 10px; color: #bbb; font-size: 14px; }
.cc-label input { margin-top: 6px; }
#screen-create .row label { flex: 1; }
#screen-create .row select { margin-top: 6px; }
.cc-stats { list-style: none; padding: 0; margin: 12px 0; }
.cc-stats li { display: flex; justify-content: space-between; padding: 7px 10px; margin-bottom: 6px; background: #222238; border-radius: 8px; font-size: 15px; }
.cc-stats li b { color: #ffd740; font-size: 17px; }
.cc-pw-row { text-align: center; margin: 10px 0 4px; font-size: 14px; color: #bbb; }
.cc-pw { display: inline-block; letter-spacing: 3px; font: bold 20px monospace; color: #69f0ae; background: #10202a; padding: 6px 12px; border-radius: 8px; margin-top: 6px; }
#cc-result { border-top: 1px dashed #2c2c40; margin-top: 12px; padding-top: 6px; }
.cc-tag { color: #69f0ae; font-size: 13px; }

/* ---------- FPS 显示 ---------- */
#fps-display {
  position: fixed; top: 4px; right: 4px; z-index: 99;
  background: rgba(0,0,0,0.7); color: #0f0; font: bold 12px monospace;
  padding: 2px 6px; border-radius: 4px; pointer-events: none;
}
