* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #dff1ff;
  touch-action: none;
  user-select: none;
}
body {
  display: flex;
  flex-direction: column;
}

#hud {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid #cfe6f7;
}
#progress-label { font-size: 14px; color: #2E6FA0; margin-bottom: 6px; }
#progress-bar {
  height: 12px;
  background: #d5e8f6;
  border-radius: 6px;
  overflow: hidden;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6BCB77, #4FB0F0);
  transition: width 0.3s ease;
}

#game {
  flex: 1;
  width: 100%;
  display: block;
}

/* 方向键:默认(手机/触屏)显示。
   方向键"悬浮"在画面左下角/右下角,不占屏:游戏画布铺满整屏,
   上下键竖排贴左下、左右键横排贴右下,中间与上方全是可玩区域。 */
#controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  display: none;            /* 默认隐藏,由 JS 检测到触屏后才显示 */
  justify-content: space-between;
  align-items: flex-end;
  background: none;         /* 不是底部白条,悬浮在画面上 */
  pointer-events: none;     /* 空白处触摸穿透到画布,只有按钮本身响应 */
}
/* 触屏设备(手机/平板):显示悬浮方向键 */
body.touch #controls { display: flex; }
.group { display: flex; gap: 12px; pointer-events: auto; }
.group.vert { flex-direction: column; }   /* 上 / 下 */
.group.horiz { flex-direction: row; }     /* 左 右 */
/* 浮动方向键:闲时半透明"隐入"画面、按下才点亮(手游浮动控制的通行做法),
   中性深色 + 白描边,在浅蓝背景和蓝色水潭上都清晰,不与水潭抢色。 */
.dir {
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(47, 82, 120, 0.30);        /* 闲时半透明,能看到身后水潭 */
  color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  cursor: pointer;
  transition: background 0.12s ease, transform 0.07s ease;
  -webkit-tap-highlight-color: transparent;
}
.dir:active {
  background: rgba(47, 82, 120, 0.85);        /* 按下点亮 */
  transform: scale(0.94);
}

/* 弹窗 */
#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}
#overlay.hidden { display: none; }
.card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 90%;
  width: 320px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.card h2 { margin: 0 0 12px; font-size: 20px; }
.card p { margin: 8px 0; color: #555; }
.card .hint { color: #999; font-size: 13px; }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
.card button {
  padding: 10px 16px;
  font-size: 15px;
  border: none;
  border-radius: 10px;
  background: #e6eef5;
  cursor: pointer;
}
.card button.primary { background: #4FB0F0; color: #fff; }
.card button:disabled { opacity: 0.5; cursor: not-allowed; }
.char-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.char {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  text-align: left;
}
.char.current { outline: 2px solid #4FB0F0; }
.swatch { width: 18px; height: 18px; border-radius: 50%; display: inline-block; }
.swatch.big { width: 40px; height: 40px; }
