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

:root {
  --gold: #ffd166;
  --red: #e63946;
  --cyan: #48cae4;
  --panel: rgba(12, 10, 18, 0.92);
  --border: rgba(255, 209, 102, 0.45);
}

body {
  background: #050508;
  overflow: hidden;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #f0e6d3;
  user-select: none;
}

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

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #12121a;
  cursor: crosshair;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

/* ── HUD 左上：血条 ── */
.hud-top-left {
  position: absolute;
  top: 14px;
  left: 14px;
}

.hud-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px 8px 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter: blur(8px);
}

.bar-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 6px rgba(230,57,70,0.6));
}

.bar-col { flex: 1; min-width: 140px; }

.bar-label {
  font-size: 10px;
  color: #999;
  letter-spacing: 2px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.bar-bg {
  position: relative;
  height: 14px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 7px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  transition: width 0.2s ease;
  border-radius: 6px;
  position: relative;
  z-index: 1;
}

.hp-fill {
  width: 100%;
  background: linear-gradient(180deg, #ff6b6b 0%, #c1121f 50%, #8b0000 100%);
  box-shadow: 0 0 8px rgba(230,57,70,0.5);
}

.xp-fill {
  width: 0%;
  background: linear-gradient(180deg, #7dd3fc 0%, #48cae4 50%, #1a6b8a 100%);
  box-shadow: 0 0 8px rgba(72,202,228,0.4);
}

.bar-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 50%);
  pointer-events: none;
  z-index: 2;
}

.bar-value {
  display: block;
  font-size: 11px;
  font-weight: bold;
  color: #ddd;
  margin-top: 3px;
  text-shadow: 0 1px 2px #000;
}

.stat-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.stat-badge {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
}

.stat-key { color: #888; margin-right: 4px; }
.stat-val { color: var(--gold); font-weight: bold; }

.combo-badge {
  border-color: rgba(230,57,70,0.5);
  animation: combo-glow 0.8s ease infinite alternate;
}

.combo-val {
  color: #ff6b6b;
  font-weight: bold;
  font-size: 12px;
}

.combo-badge.hidden { display: none; }

@keyframes combo-glow {
  from { box-shadow: 0 0 8px rgba(230,57,70,0.3); }
  to { box-shadow: 0 0 16px rgba(230,57,70,0.55); }
}

/* ── HUD 右上：计时 ── */
.hud-top-right {
  position: absolute;
  top: 14px;
  right: 14px;
}

.timer-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.timer-label {
  font-size: 10px;
  color: #888;
  letter-spacing: 2px;
}

.timer-value {
  font-size: 32px;
  font-weight: bold;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255,209,102,0.4);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.wave-label {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.wave-label span { color: var(--red); font-weight: bold; }

.zone-label {
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid rgba(255,209,102,0.25);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 12px;
  color: #bbb;
  text-align: center;
  backdrop-filter: blur(8px);
  letter-spacing: 2px;
}

.zone-label::before {
  content: '📍 ';
}

/* ── HUD 底部：经验条 ── */
.hud-bottom {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 88vw);
}

.xp-panel {
  background: var(--panel);
  border: 1px solid rgba(72,202,228,0.35);
  border-radius: 10px;
  padding: 10px 14px;
  backdrop-filter: blur(8px);
  margin-top: 8px;
}

.skill-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  flex-wrap: wrap;
}

.skill-slot {
  position: relative;
  width: 44px;
  height: 44px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,209,102,0.35);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: skill-pop 0.3s ease;
}

.skill-slot img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.skill-lv {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--cyan);
  color: #000;
  font-size: 9px;
  font-weight: bold;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes skill-pop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.xp-label { color: var(--cyan); }
.xp-bg { height: 12px; margin-top: 2px; }
.xp-value { color: var(--cyan); text-align: right; }

/* ── 遮罩层 ── */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.overlay.hidden { display: none; }

.overlay-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.88) 100%);
  backdrop-filter: blur(3px);
}

.overlay-panel {
  position: relative;
  z-index: 1;
  background: linear-gradient(160deg, rgba(28,24,38,0.98), rgba(10,8,16,0.98));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 36px;
  text-align: center;
  box-shadow: 0 0 60px rgba(255,209,102,0.08), 0 20px 60px rgba(0,0,0,0.7);
  max-width: 92vw;
}

.panel-glow {
  position: absolute;
  top: -1px; left: 20%; right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 2px;
}

/* ── 开始界面：宣传图全屏 ── */
.start-overlay {
  flex-direction: column;
  justify-content: space-between;
  padding: 0;
  overflow: hidden;
}

.start-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 40%;
  z-index: 0;
}

.start-gradient-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: linear-gradient(180deg,
    rgba(0,0,0,0.75) 0%,
    rgba(80,10,10,0.35) 40%,
    transparent 100%);
  z-index: 1;
  pointer-events: none;
}

.start-gradient-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 35%;
  background: linear-gradient(0deg,
    rgba(0,0,0,0.85) 0%,
    rgba(0,0,0,0.4) 50%,
    transparent 100%);
  z-index: 1;
  pointer-events: none;
}

.start-content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: clamp(32px, 6vh, 64px) 24px clamp(40px, 8vh, 72px);
}

.start-title-area {
  text-align: center;
  animation: title-in 0.8s ease;
}

.start-en {
  font-size: clamp(11px, 1.5vw, 14px);
  letter-spacing: 6px;
  color: rgba(255,200,150,0.7);
  margin-bottom: 8px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.start-title {
  font-size: clamp(48px, 10vw, 88px);
  font-weight: 900;
  color: #fff;
  line-height: 1;
  letter-spacing: 8px;
  text-shadow:
    0 0 40px rgba(230,57,70,0.8),
    0 0 80px rgba(180,20,20,0.5),
    0 4px 0 #8b0000,
    0 6px 20px rgba(0,0,0,0.9);
  margin-bottom: 8px;
}

.start-subtitle {
  font-size: clamp(18px, 3vw, 28px);
  color: var(--gold);
  letter-spacing: 12px;
  font-weight: 300;
  text-shadow: 0 2px 12px rgba(0,0,0,0.9);
}

.btn-start-game {
  pointer-events: auto;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  min-width: clamp(200px, 30vw, 280px);
  padding: clamp(14px, 2vh, 18px) clamp(48px, 8vw, 72px);
  background: linear-gradient(180deg, #e63946 0%, #9d0208 60%, #6a0404 100%);
  border: 2px solid var(--gold);
  border-radius: 6px;
  box-shadow:
    0 0 30px rgba(230,57,70,0.5),
    0 8px 32px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: btn-in 1s ease 0.3s both;
}

.btn-start-text {
  position: relative;
  z-index: 1;
  font-size: clamp(18px, 2.5vw, 24px);
  font-weight: 900;
  letter-spacing: 6px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.btn-start-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,0.2) 50%, transparent 65%);
  animation: btn-shine 3s infinite;
}

.btn-start-game:hover {
  transform: scale(1.06);
  box-shadow:
    0 0 50px rgba(230,57,70,0.7),
    0 12px 40px rgba(0,0,0,0.7);
}

@keyframes title-in {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes btn-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 升级选择 ── */
.upgrade-panel {
  width: min(720px, 95vw);
  padding: 28px 24px 32px;
  animation: panel-in 0.35s ease;
}

.upgrade-header { margin-bottom: 20px; }

.level-up-badge {
  display: inline-block;
  background: linear-gradient(135deg, var(--gold), #ff9f1c);
  color: #1a1000;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 3px;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 10px;
  animation: badge-pulse 1.5s ease infinite;
}

.upgrade-panel h2 {
  font-size: 28px;
  color: #fff;
  margin-bottom: 6px;
}

.upgrade-panel .subtitle {
  color: #888;
  font-size: 13px;
  margin: 0;
}

.upgrade-cards {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.upgrade-card {
  pointer-events: auto;
  cursor: pointer;
  width: 190px;
  padding: 0;
  background: linear-gradient(180deg, rgba(40,36,55,0.95), rgba(18,16,28,0.95));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.upgrade-card:hover {
  transform: translateY(-6px);
  border-color: var(--gold);
  box-shadow: 0 12px 32px rgba(255,209,102,0.2), 0 0 20px rgba(255,209,102,0.1);
}

.upgrade-card .card-icon-wrap {
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(255,209,102,0.08), transparent 70%);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.upgrade-card .card-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
  transition: transform 0.2s;
}

.upgrade-card:hover .card-icon {
  transform: scale(1.1);
}

.upgrade-card .card-body {
  padding: 12px 14px 14px;
}

.upgrade-card .name {
  font-size: 16px;
  font-weight: bold;
  color: var(--gold);
  margin-bottom: 4px;
}

.upgrade-card .desc {
  font-size: 11px;
  color: #999;
  line-height: 1.5;
  min-height: 32px;
}

.upgrade-card .level-bar {
  margin-top: 10px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.upgrade-card .level-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), #7dd3fc);
  border-radius: 2px;
  transition: width 0.3s;
}

.upgrade-card .level-text {
  font-size: 10px;
  color: var(--cyan);
  margin-top: 4px;
  text-align: right;
}

/* ── 按钮 ── */
.btn-primary {
  pointer-events: auto;
  cursor: pointer;
  background: linear-gradient(180deg, #e63946 0%, #9d0208 100%);
  color: #fff;
  border: 1px solid var(--gold);
  border-radius: 10px;
  font-weight: bold;
  letter-spacing: 2px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(230,57,70,0.4);
}

.btn-primary:hover {
  transform: scale(1.04);
  box-shadow: 0 6px 28px rgba(230,57,70,0.55);
}

/* ── 结算 ── */
.gameover-overlay {
  flex-direction: column;
  overflow: hidden;
}

.gameover-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(80,15,15,0.45) 0%, transparent 55%),
    radial-gradient(ellipse at center, rgba(20,12,18,0.6) 0%, rgba(5,4,8,0.95) 100%);
  z-index: 0;
}

.gameover-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 20%, rgba(0,0,0,0.75) 100%);
  z-index: 1;
  pointer-events: none;
}

.gameover-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(24px, 5vh, 48px) 24px;
  animation: panel-in 0.5s ease;
  max-width: 560px;
  width: 92vw;
}

.gameover-header {
  text-align: center;
  margin-bottom: clamp(20px, 4vh, 32px);
}

.gameover-en {
  font-size: 11px;
  letter-spacing: 6px;
  color: rgba(230,57,70,0.7);
  margin-bottom: 8px;
}

.gameover-title {
  font-size: clamp(36px, 8vw, 52px);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 0 30px rgba(230,57,70,0.8),
    0 4px 0 #6a0404;
  margin-bottom: 16px;
}

.grade-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(160deg, rgba(40,20,25,0.9), rgba(15,10,15,0.95));
  border: 1px solid rgba(255,209,102,0.4);
  border-radius: 14px;
  padding: 12px 28px;
  box-shadow: 0 0 40px rgba(230,57,70,0.2);
}

.grade-letter {
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(180deg, #ffd166, #ff9f1c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.grade-title {
  font-size: 13px;
  color: #aaa;
  margin-top: 4px;
  letter-spacing: 2px;
}

.gameover-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  margin-bottom: clamp(24px, 5vh, 36px);
}

.stat-card {
  background: rgba(12,10,18,0.85);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  backdrop-filter: blur(6px);
}

.stat-card-label {
  display: block;
  font-size: 10px;
  color: #777;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.stat-card-value {
  display: block;
  font-size: clamp(20px, 4vw, 28px);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(255,209,102,0.3);
}

.btn-restart-game {
  pointer-events: auto;
  position: relative;
  cursor: pointer;
  overflow: hidden;
  min-width: 220px;
  padding: 14px 56px;
  background: linear-gradient(180deg, #e63946 0%, #9d0208 60%, #6a0404 100%);
  border: 2px solid var(--gold);
  border-radius: 6px;
  box-shadow:
    0 0 30px rgba(230,57,70,0.45),
    0 8px 32px rgba(0,0,0,0.5);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-restart-game:hover {
  transform: scale(1.05);
  box-shadow:
    0 0 50px rgba(230,57,70,0.65),
    0 12px 40px rgba(0,0,0,0.6);
}

@media (max-width: 420px) {
  .gameover-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Toast ── */
.toast {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10,8,16,0.92);
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 14px 28px;
  font-size: 17px;
  font-weight: bold;
  color: var(--gold);
  z-index: 30;
  pointer-events: none;
  animation: toast-pop 0.4s ease;
  box-shadow: 0 0 30px rgba(255,209,102,0.2);
}

.toast.hidden { display: none; }

@keyframes panel-in {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes btn-shine {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(120%); }
}

@keyframes badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,209,102,0.4); }
  50% { box-shadow: 0 0 16px 4px rgba(255,209,102,0.25); }
}

@keyframes toast-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.start-hint {
  margin-top: 20px;
  font-size: clamp(10px, 2vw, 13px);
  color: rgba(255,220,180,0.75);
  text-align: center;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  pointer-events: none;
  max-width: 90vw;
  line-height: 1.6;
}

/* ── 手游触控 ── */
#touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

#touch-controls.visible {
  display: block;
}

.joystick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 42vw;
  height: 42vw;
  max-width: 200px;
  max-height: 200px;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  position: absolute;
  left: 24px;
  bottom: 100px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 209, 102, 0.35);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  margin-left: -24px;
  margin-top: -24px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #666, #222);
  border: 2px solid rgba(255, 209, 102, 0.5);
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.skill-buttons {
  position: absolute;
  right: 16px;
  bottom: 90px;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
}

.skill-btn {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 2px solid rgba(255, 209, 102, 0.5);
  background: rgba(12, 10, 18, 0.85);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: transform 0.1s;
}

.skill-btn.skill-ult {
  width: 80px;
  height: 80px;
  border-color: rgba(255, 107, 53, 0.7);
  background: radial-gradient(circle, rgba(80,20,10,0.9), rgba(20,8,8,0.95));
}

.skill-btn.skill-dash {
  border-color: rgba(72, 202, 228, 0.6);
}

.skill-btn.skill-magnet {
  border-color: rgba(72, 202, 228, 0.5);
}

.skill-btn:active,
.skill-btn.pressed {
  transform: scale(0.92);
}

.skill-btn.on-cd {
  opacity: 0.55;
  filter: grayscale(0.5);
}

.skill-icon {
  font-size: 22px;
  line-height: 1;
}

.skill-ult .skill-icon { font-size: 26px; }

.skill-name {
  font-size: 9px;
  color: #aaa;
  letter-spacing: 1px;
}

.skill-cd {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 8px #000;
}

@media (max-width: 900px) {
  .hud-bottom {
    bottom: 8px;
    width: 96vw;
  }
  .hud-top-left { top: 8px; left: 8px; }
  .hud-top-right { top: 8px; right: 8px; }
}
