:root {
  --bg-outer: #091119;
  --shell-bg: #12231a;
  --header-bg: rgba(12, 22, 18, 0.94);
  --panel-bg: rgba(15, 25, 22, 0.94);
  --panel-border: rgba(132, 232, 174, 0.24);
  --accent: #39e58c;
  --accent-2: #22d3ee;
  --gold: #fbbf24;
  --danger: #fb7185;
  --text-main: #f3faf6;
  --text-dim: #9ec0ae;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #16302a 0%, var(--bg-outer) 72%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* 9:16 微信小游戏竖屏外壳 */
#app-shell {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: min(100dvh, 860px);
  background: var(--shell-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

@media (min-width: 460px) and (min-height: 700px) {
  #app-shell {
    border-radius: 24px;
  }
}

/* 微信顶栏 */
#wx-header {
  height: 48px;
  flex-shrink: 0;
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  z-index: 30;
  backdrop-filter: blur(8px);
}

.wx-back {
  color: #dff7eb;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: transform 0.12s ease, background 0.15s ease;
  white-space: nowrap;
}

.wx-back:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.16);
}

.wx-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #f4fff9;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 6px;
}

.wx-capsule {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  height: 30px;
  padding: 0 4px;
}

.wx-icon-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14px;
  width: 30px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 999px;
}

.wx-icon-btn:active {
  background: rgba(255, 255, 255, 0.18);
}

.wx-divider {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.18);
}

/* 主画布区域 */
#game-stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 顶部 HUD */
#hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
}

#xp-bar-wrap {
  position: relative;
  width: 100%;
  height: 16px;
  background: rgba(7, 15, 13, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

#xp-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #06b6d4 0%, #39e58c 60%, #fde047 100%);
  box-shadow: 0 0 10px rgba(57, 229, 140, 0.6);
  transition: width 0.14s ease-out;
}

#xp-level-label {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.4px;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 4px;
  gap: 6px;
}

.hud-pill {
  background: rgba(10, 20, 17, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #e4f8ed;
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  gap: 4px;
}

.hud-wave-pill {
  max-width: 146px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-timer {
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.75);
  padding: 0 4px;
}

.hud-timer.danger {
  color: #ff6b81;
  animation: pulseTimer 0.7s infinite alternate;
}

@keyframes pulseTimer {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.hud-kills-pill {
  min-width: 66px;
  justify-content: center;
  color: #fde68a;
}

/* Boss 血条 */
#boss-bar-wrap {
  margin: 4px 12px 0;
  padding: 6px 10px 7px;
  border-radius: 12px;
  background: rgba(29, 9, 20, 0.86);
  border: 1px solid rgba(251, 113, 133, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

.boss-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fecdd3;
  margin-bottom: 4px;
}

.boss-bar-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

#boss-hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e11d48 0%, #fb7185 55%, #f59e0b 100%);
  box-shadow: 0 0 10px rgba(244, 63, 94, 0.7);
  transition: width 0.12s linear;
}

/* 大事件提示条 */
#banner-toast {
  position: absolute;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  pointer-events: none;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 28, 0.88);
  border: 1px solid rgba(251, 191, 36, 0.55);
  color: #fef3c7;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: bannerPop 0.25s ease-out;
}

#banner-toast.danger {
  background: rgba(88, 12, 28, 0.92);
  border-color: rgba(251, 113, 133, 0.85);
  color: #ffe4e6;
}

@keyframes bannerPop {
  from { opacity: 0; transform: translate(-50%, -10px) scale(0.9); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* 底部武器栏 */
#hud-bottom {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 14px;
  background: rgba(9, 19, 15, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}

.slot-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.slot-sep {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.14);
  margin: 0 2px;
}

.item-slot {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.item-slot.empty {
  opacity: 0.32;
  font-size: 13px;
  color: #7da08d;
}

.item-slot.owned {
  background: rgba(29, 55, 45, 0.82);
  border-color: rgba(57, 229, 140, 0.45);
}

.item-slot.evolved {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.75), rgba(234, 179, 8, 0.45));
  border-color: #fde047;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.5);
}

.slot-lvl {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: #0d1d17;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #e2fbe9;
  font-size: 9px;
  font-weight: 800;
  padding: 0 4px;
  border-radius: 6px;
  line-height: 14px;
}

.item-slot.evolved .slot-lvl {
  background: #f59e0b;
  color: #1f1300;
  border-color: #fef08a;
}

/* 通用弹窗覆盖层 */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(6, 14, 12, 0.54);
  backdrop-filter: blur(4px);
}

/* 开始界面 */
.start-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, rgba(16, 31, 25, 0.92) 0%, rgba(10, 20, 17, 0.95) 100%);
  border: 1px solid rgba(110, 231, 183, 0.3);
  border-radius: 22px;
  padding: 18px 16px 16px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.game-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  color: #052e16;
  background: linear-gradient(90deg, #4ade80, #22d3ee);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.game-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 4px 16px rgba(57, 229, 140, 0.35);
}

.game-sub {
  margin-top: 4px;
  font-size: 12px;
  color: #a7f3d0;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 10px 8px;
  color: #d1fae5;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  transition: all 0.16s ease;
}

.mode-btn.active {
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.28), rgba(6, 182, 212, 0.18));
  border-color: #39e58c;
  box-shadow: 0 0 18px rgba(57, 229, 140, 0.24);
}

.mode-name {
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
}

.mode-desc {
  font-size: 10px;
  color: #9ec0ae;
  line-height: 1.3;
}

.weapon-preview-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 12px 0 10px;
}

.weapon-preview-strip span {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.controls-tip {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.5;
  color: #cde8da;
  text-align: left;
}

.controls-tip b {
  color: #fde68a;
}

.best-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0 14px;
}

.best-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.best-label {
  font-size: 10px;
  color: var(--text-dim);
}

.best-item strong {
  font-size: 15px;
  font-weight: 800;
  color: #fef08a;
}

/* 按钮 */
.primary-btn, .secondary-btn, .ghost-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
  text-align: center;
  text-decoration: none;
  display: inline-block;
}

.primary-btn {
  background: linear-gradient(135deg, #22c55e 0%, #10b981 48%, #06b6d4 100%);
  color: #032114;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.42);
}

.primary-btn.gold-btn {
  background: linear-gradient(135deg, #fde047 0%, #f59e0b 100%);
  color: #2c1500;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.45);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ecfdf5;
  font-size: 14px;
  padding: 11px 14px;
}

.ghost-btn {
  background: transparent;
  color: #9ec0ae;
  font-size: 13px;
  padding: 9px 12px;
}

.primary-btn:active, .secondary-btn:active {
  transform: scale(0.97);
}

/* 弹窗面板 */
.modal-panel {
  width: 100%;
  max-width: 382px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  padding: 18px 15px 16px;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.modal-header {
  margin-bottom: 12px;
}

.modal-kicker {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #39e58c;
  margin-bottom: 3px;
}

.gold-kicker {
  color: #fde047;
}

.modal-panel h2 {
  font-size: 21px;
  font-weight: 900;
  color: #ffffff;
}

.modal-header p {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

/* 升级卡片 */
.upgrade-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-card {
  position: relative;
  width: 100%;
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  color: #f4fff9;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.upgrade-card:hover {
  border-color: #39e58c;
  background: rgba(57, 229, 140, 0.11);
}

.upgrade-card:active {
  transform: scale(0.98);
}

.upgrade-card.evolve-card {
  background: linear-gradient(135deg, rgba(161, 98, 7, 0.36), rgba(234, 179, 8, 0.16));
  border-color: #facc15;
  box-shadow: 0 0 20px rgba(250, 204, 21, 0.25);
}

.upg-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 25px;
}

.upgrade-card.evolve-card .upg-icon {
  border-color: #fde047;
  background: rgba(234, 179, 8, 0.24);
}

.upg-body {
  flex: 1;
  min-width: 0;
}

.upg-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}

.upg-name {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
}

.upg-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(57, 229, 140, 0.2);
  color: #6ee7b7;
  white-space: nowrap;
}

.upg-tag.tag-new {
  background: rgba(34, 211, 238, 0.24);
  color: #67e8f9;
}

.upg-tag.tag-evolve {
  background: linear-gradient(90deg, #facc15, #f97316);
  color: #221000;
}

.upg-desc {
  font-size: 12px;
  line-height: 1.4;
  color: #bfe0cf;
}

/* 宝箱弹窗 */
.chest-panel {
  position: relative;
  overflow: hidden;
  border-color: rgba(250, 204, 21, 0.55);
}

.chest-glow {
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 220px;
  height: 140px;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.35) 0%, transparent 72%);
  pointer-events: none;
}

.chest-emoji {
  font-size: 56px;
  margin: 4px 0 8px;
  position: relative;
  animation: floatChest 1.5s ease-in-out infinite alternate;
}

@keyframes floatChest {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-6px) scale(1.06); }
}

.chest-desc {
  margin: 8px 0 12px;
  font-size: 13px;
  color: #fde68a;
  line-height: 1.5;
}

.chest-heal-tag {
  display: inline-block;
  margin-bottom: 14px;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: #86efac;
  font-size: 12px;
  font-weight: 700;
}

/* 暂停面板 */
.pause-stats {
  margin: 12px 0 16px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: #cde8da;
  line-height: 1.65;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* 结算界面 */
.rank-badge {
  width: 68px;
  height: 68px;
  margin: 0 auto 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  font-weight: 900;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
}

.rank-s {
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 55%, #ea580c 100%);
  color: #2b1200;
  border: 2px solid #fef9c3;
}

.rank-a {
  background: linear-gradient(135deg, #a78bfa 0%, #6366f1 100%);
  color: #ffffff;
  border: 2px solid #ddd6fe;
}

.rank-b {
  background: linear-gradient(135deg, #34d399 0%, #059669 100%);
  color: #022c22;
  border: 2px solid #a7f3d0;
}

.rank-c {
  background: linear-gradient(135deg, #94a3b8 0%, #475569 100%);
  color: #f8fafc;
  border: 2px solid #cbd5e1;
}

.end-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 3px;
}

.new-best-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.2);
  border: 1px solid rgba(250, 204, 21, 0.55);
  color: #fde047;
  font-size: 11px;
  font-weight: 800;
}

.end-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}

.end-stat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.end-stat span {
  font-size: 11px;
  color: var(--text-dim);
}

.end-stat strong {
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
}

.loadout-section {
  text-align: left;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 9px 10px;
  margin-bottom: 14px;
}

.loadout-title {
  font-size: 11px;
  font-weight: 700;
  color: #9ec0ae;
  margin-bottom: 7px;
}

.end-loadout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.loadout-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 11px;
  font-weight: 700;
  color: #ecfdf5;
}

.loadout-chip.evolved {
  background: rgba(234, 179, 8, 0.24);
  border-color: #facc15;
  color: #fef08a;
}
