* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== CG 覆盖层 ===== */
.cg-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s;
}
.cg-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
#cg-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}
.cg-text {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  font-size: 18px;
  letter-spacing: 2px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
  text-align: center;
  width: 80%;
  opacity: 0;
  transition: opacity 1s;
  line-height: 1.8;
}
.cg-text.show { opacity: 1; }
.cg-skip {
  position: absolute;
  top: 50px;
  right: 30px;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  cursor: pointer;
  z-index: 10;
  letter-spacing: 1px;
}

/* ===== 主菜单 ===== */
.menu-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #2a1a0a 0%, #0a0502 100%);
  transition: opacity 0.8s;
}
.menu-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.menu-title {
  font-size: 56px;
  color: #e8c888;
  letter-spacing: 12px;
  text-shadow: 0 0 20px rgba(232,200,136,0.4), 0 4px 8px rgba(0,0,0,0.8);
  margin-bottom: 8px;
  font-weight: 300;
}
.menu-subtitle {
  font-size: 12px;
  color: rgba(232,200,136,0.5);
  letter-spacing: 6px;
  margin-bottom: 60px;
}
.menu-btn {
  padding: 14px 48px;
  background: linear-gradient(180deg, #c9a65a, #8b6b2a);
  border: 1px solid #e8c888;
  color: #fff;
  font-size: 16px;
  letter-spacing: 4px;
  cursor: pointer;
  border-radius: 2px;
  box-shadow: 0 4px 20px rgba(201,166,90,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}
.menu-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 10px rgba(201,166,90,0.3);
}
.menu-hint {
  margin-top: 40px;
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 2px;
}

/* ===== HUD ===== */
.hud {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}
.hud.hidden { display: none; }

.hud-top {
  position: absolute;
  top: env(safe-area-inset-top, 20px);
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hp-bar-wrap {
  flex: 0 1 200px;
  position: relative;
  height: 24px;
}
.hp-bar-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 2px;
}
.hp-bar {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d63031, #e74c3c);
  border-radius: 2px;
  transition: width 0.3s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2);
}
.hp-text {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  letter-spacing: 1px;
}

.level-info {
  text-align: right;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.level-name {
  font-size: 14px;
  letter-spacing: 2px;
  margin-bottom: 2px;
}
.kill-count {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 1px;
}

/* ===== 技能栏 ===== */
.skill-bar {
  position: absolute;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 20px) + 20px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}
.skill-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(60,50,40,0.85), rgba(30,25,20,0.9));
  border: 2px solid rgba(232,200,136,0.6);
  color: #e8c888;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transition: transform 0.15s;
}
.skill-btn:active {
  transform: scale(0.9);
}
.skill-btn.cooling {
  opacity: 0.5;
}
.skill-icon {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 6px rgba(232,200,136,0.6);
}
.skill-label {
  font-size: 10px;
  color: rgba(232,200,136,0.9);
  letter-spacing: 1px;
  margin-top: -2px;
}
.skill-cd {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  clip-path: inset(100% 0 0 0);
  pointer-events: none;
}

.mute-btn {
  position: absolute;
  top: env(safe-area-inset-top, 20px);
  right: 16px;
  top: calc(env(safe-area-inset-top, 20px) + 40px);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 关卡通过 / 游戏结束 ===== */
.level-clear, .game-over, .game-win {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}
.level-clear.hidden, .game-over.hidden, .game-win.hidden {
  display: none;
}
.clear-title, .over-title, .win-title {
  font-size: 42px;
  color: #e8c888;
  letter-spacing: 8px;
  text-shadow: 0 0 20px rgba(232,200,136,0.4);
  margin-bottom: 12px;
}
.over-title { color: #e74c3c; text-shadow: 0 0 20px rgba(231,76,60,0.4); }
.win-title { color: #f1c40f; text-shadow: 0 0 20px rgba(241,196,15,0.4); }
.clear-sub, .over-sub, .win-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 2px;
  margin-bottom: 40px;
}

.hidden { display: none !important; }
