* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05070d;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#game-container { position: fixed; inset: 0; }
canvas { display: block; }

.hidden { display: none !important; }

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud-top {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.wave-info {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: #e8ecf4;
  text-shadow: 0 0 12px rgba(90, 140, 255, .8);
}

.wave-label { font-size: 13px; letter-spacing: 4px; color: #8fa3c8; }

#wave-num { font-size: 30px; font-weight: 800; }

.wave-enemies { font-size: 12px; color: #9fb0d0; letter-spacing: 2px; }

.hud-bottom-left {
  position: absolute;
  left: 26px;
  bottom: 26px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-wrap { display: flex; align-items: center; gap: 10px; }

.bar-label { font-size: 12px; font-weight: 800; color: #cfd8ea; width: 24px; letter-spacing: 1px; }

.bar {
  position: relative;
  width: 300px;
  height: 20px;
  background: rgba(10, 14, 26, .75);
  border: 1px solid rgba(140, 170, 220, .35);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 0 14px rgba(0, 0, 0, .5);
}

.bar-fill { height: 100%; width: 100%; transition: width .15s ease-out; }

.hp-bar .bar-fill {
  background: linear-gradient(180deg, #ff7a6b, #d92b1f 60%, #8f150c);
  box-shadow: 0 0 10px rgba(255, 90, 70, .6) inset;
}

.en-bar { height: 12px; }
.en-bar .bar-fill {
  background: linear-gradient(180deg, #7fe7ff, #1e9fd8 70%, #0d5f8f);
  box-shadow: 0 0 10px rgba(90, 210, 255, .6) inset;
}

.bar-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

.hud-top-right {
  position: absolute;
  top: 18px;
  right: 26px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.score-box { text-align: right; }

.score-label { font-size: 12px; letter-spacing: 3px; color: #8fa3c8; }

.score-value { font-size: 32px; font-weight: 800; color: #ffe9a8; text-shadow: 0 0 14px rgba(255, 200, 80, .55); }

.combo-box {
  text-align: right;
  color: #ffd25e;
  text-shadow: 0 0 12px rgba(255, 180, 60, .8);
}

#combo-num { font-size: 26px; font-weight: 900; display: block; }

.combo-label { font-size: 11px; letter-spacing: 4px; color: #d9a940; }

.combo-box.pop { animation: combo-pop .18s ease-out; }
@keyframes combo-pop { 0% { transform: scale(1.45); } 100% { transform: scale(1); } }

.skill-hint {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #7c8db0;
  display: flex;
  gap: 16px;
  align-items: center;
}

.key {
  display: inline-block;
  padding: 2px 8px;
  margin-right: 4px;
  border: 1px solid rgba(150, 180, 230, .4);
  border-radius: 4px;
  background: rgba(20, 28, 48, .7);
  color: #cfe0ff;
  font-size: 11px;
  font-weight: 700;
}

.center-msg {
  position: fixed;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 44px;
  font-weight: 900;
  color: #f2f6ff;
  text-shadow: 0 0 24px rgba(120, 170, 255, .9), 0 2px 8px rgba(0, 0, 0, .8);
  letter-spacing: 6px;
  z-index: 15;
  pointer-events: none;
  animation: msg-in .5s ease-out;
}

@keyframes msg-in { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(140, 10, 10, .55) 100%);
  opacity: 0;
  transition: opacity .3s;
}

#vignette.low-hp { opacity: 1; animation: lowhp-pulse 1.2s ease-in-out infinite; }
@keyframes lowhp-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

#damage-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  background: rgba(255, 40, 30, .28);
  opacity: 0;
}

#damage-flash.hit { animation: dmg-flash .25s ease-out; }
@keyframes dmg-flash { 0% { opacity: 1; } 100% { opacity: 0; } }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(12, 18, 36, .82), rgba(3, 5, 10, .95));
  backdrop-filter: blur(3px);
}

.overlay-box {
  text-align: center;
  padding: 48px 64px;
  border: 1px solid rgba(120, 160, 230, .25);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(20, 30, 58, .92), rgba(8, 12, 24, .95));
  box-shadow: 0 0 60px rgba(40, 90, 200, .25), 0 0 0 1px rgba(0, 0, 0, .6) inset;
  animation: msg-in .4s ease-out;
}

.game-title {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: 8px;
  color: #f0f5ff;
  text-shadow: 0 0 30px rgba(110, 170, 255, .9), 0 4px 10px rgba(0, 0, 0, .7);
}

.title-3d {
  margin-left: 10px;
  color: #59d9ff;
  text-shadow: 0 0 26px rgba(80, 210, 255, .95);
}

.game-sub { margin-top: 6px; font-size: 13px; letter-spacing: 10px; color: #7f92b8; }

.controls-list { margin: 30px 0 34px; display: flex; flex-direction: column; gap: 10px; }

.ctrl { display: flex; justify-content: space-between; gap: 40px; font-size: 14px; color: #b8c6e0; }
.ctrl .key { min-width: 130px; text-align: center; margin-right: 0; }

.btn {
  pointer-events: auto;
  padding: 13px 52px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 4px;
  color: #eaf2ff;
  background: linear-gradient(180deg, #2e63c8, #1a3a86);
  border: 1px solid rgba(140, 180, 255, .5);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(60, 120, 255, .45), 0 4px 0 rgba(0, 0, 0, .35);
  transition: transform .12s, box-shadow .12s, filter .12s;
}

.btn:hover { transform: translateY(-2px); filter: brightness(1.15); box-shadow: 0 0 36px rgba(90, 150, 255, .7), 0 6px 0 rgba(0, 0, 0, .35); }
.btn:active { transform: translateY(1px); }

.dead-title { font-size: 48px; font-weight: 900; letter-spacing: 8px; color: #ff5d4d; text-shadow: 0 0 30px rgba(255, 60, 40, .8); }

.pause-title { font-size: 42px; font-weight: 900; letter-spacing: 10px; color: #dfe8fa; text-shadow: 0 0 24px rgba(120, 170, 255, .8); }

.result-grid { margin: 30px 0 34px; display: grid; grid-template-columns: repeat(2, 150px); gap: 18px 24px; }

.result-item { padding: 12px 8px; border: 1px solid rgba(120, 160, 230, .2); border-radius: 8px; background: rgba(10, 16, 32, .6); }

.result-num { font-size: 26px; font-weight: 900; color: #ffd25e; text-shadow: 0 0 12px rgba(255, 190, 70, .6); }

.result-label { margin-top: 4px; font-size: 11px; letter-spacing: 2px; color: #8fa0c2; }

@media (max-width: 720px) {
  .game-title { font-size: 38px; }
  .overlay-box { padding: 30px 24px; }
  .bar { width: 200px; }
  .controls-list .ctrl { gap: 16px; font-size: 12px; }
}
