:root {
  --bg-outer: #070b14;
  --shell-bg: #0e1424;
  --topbar-bg: rgba(12, 18, 34, 0.94);
  --ink: #f8fafc;
  --muted: #94a3b8;
  --violet: #8b5cf6;
  --cyan: #38bdf8;
  --magenta: #ec4899;
  --gold: #fbbf24;
  --danger: #f43f5e;
  --emerald: #34d399;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 15%, #1c2444 0%, #070b14 72%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
}

/* 9:16 微信小游戏竖屏外壳 */
.phone-shell {
  width: min(100vw, 430px);
  height: min(100dvh, 860px);
  background: var(--shell-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(148, 163, 184, 0.22);
}

@media (min-width: 460px) and (min-height: 700px) {
  .phone-shell {
    border-radius: 26px;
  }
}

/* 顶部微信导航栏 */
.wx-topbar {
  height: 48px;
  flex-shrink: 0;
  background: var(--topbar-bg);
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  gap: 8px;
  z-index: 30;
}

.wx-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.12s ease;
}

.wx-back-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.wx-back-btn:active {
  transform: scale(0.95);
}

.wx-title {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  flex: 1;
}

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

.wx-cap-btn {
  border: none;
  background: transparent;
  color: #f8fafc;
  font-size: 14px;
  width: 28px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.wx-cap-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.wx-cap-div {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.2);
  margin: 0 2px;
}

/* 主舞台与画布 */
.stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: #cfd8e3;
  touch-action: none;
}

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

/* 游戏内 HUD */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

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

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.84);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 5px 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.24);
}

.hud-icon {
  font-size: 13px;
  line-height: 1;
}

.hud-val {
  font-size: 13.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.timer-pill.urgent {
  background: rgba(190, 18, 60, 0.9);
  border-color: rgba(254, 205, 211, 0.55);
  animation: pulseUrgent 0.7s ease-in-out infinite;
}

.timer-pill.boss-time {
  background: rgba(153, 27, 27, 0.9);
  border-color: rgba(251, 191, 36, 0.7);
}

@keyframes pulseUrgent {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.size-pill {
  padding-right: 6px;
}

.tier-chip {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #7c3aed, #38bdf8);
  color: #fff;
  letter-spacing: 0.2px;
}

/* 经验条 + Buff 栏 */
.xp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 4px 8px;
}

.lv-badge {
  font-size: 11px;
  font-weight: 900;
  color: #e9d5ff;
  background: rgba(139, 92, 246, 0.4);
  border: 1px solid rgba(167, 139, 250, 0.5);
  border-radius: 999px;
  padding: 1px 7px;
  white-space: nowrap;
}

.xp-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #ec4899, #38bdf8);
  border-radius: 999px;
  transition: width 0.14s ease-out;
}

.buff-strip {
  display: flex;
  align-items: center;
  gap: 3px;
}

.buff-tag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  white-space: nowrap;
}

.buff-tag.shield {
  background: rgba(56, 189, 248, 0.28);
  border: 1px solid rgba(56, 189, 248, 0.6);
  color: #bae6fd;
}

/* 连吞提示 */
.combo-badge {
  align-self: flex-end;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  font-size: 12.5px;
  font-weight: 900;
  padding: 4px 11px;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.45);
  animation: comboPop 0.22s ease-out;
}

@keyframes comboPop {
  0% { transform: scale(0.75); }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

/* Boss 降临横幅 */
.boss-banner {
  background: linear-gradient(135deg, rgba(153, 27, 27, 0.94), rgba(124, 45, 18, 0.94));
  border: 1.5px solid rgba(251, 191, 36, 0.85);
  border-radius: 14px;
  padding: 7px 10px;
  box-shadow: 0 8px 22px rgba(220, 38, 38, 0.4);
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: slideDown 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.boss-banner.ready {
  background: linear-gradient(135deg, rgba(6, 95, 70, 0.94), rgba(14, 116, 144, 0.94));
  border-color: #34d399;
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.45);
}

@keyframes slideDown {
  from { transform: translateY(-14px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.boss-banner-title {
  font-size: 11.5px;
  font-weight: 800;
  color: #fef3c7;
  text-align: center;
  line-height: 1.3;
}

.boss-progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.boss-progress-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.boss-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #f97316, #34d399);
  border-radius: 999px;
  transition: width 0.16s ease-out;
}

.boss-progress-label {
  font-size: 11px;
  font-weight: 800;
  color: #fde68a;
  white-space: nowrap;
}

/* 底部浮动 Toast */
.toast-msg {
  margin-top: auto;
  align-self: center;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(167, 139, 250, 0.5);
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 800;
  padding: 7px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.32);
  text-align: center;
  max-width: 92%;
}

/* 通用弹窗遮罩 */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.overlay[hidden] {
  display: none !important;
}

.start-overlay {
  background: radial-gradient(circle at 50% 30%, rgba(15, 23, 42, 0.45) 0%, rgba(7, 11, 20, 0.84) 75%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-overlay {
  background: rgba(7, 11, 20, 0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

/* 开始卡片 */
.start-card {
  width: 100%;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(139, 92, 246, 0.42);
  border-radius: 24px;
  padding: 20px 18px 18px;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-badge {
  display: flex;
  align-items: center;
  gap: 14px;
}

.vortex-emblem {
  width: 62px;
  height: 62px;
  border-radius: 18px;
  background: radial-gradient(circle, #3b0764 0%, #090d1a 75%);
  border: 1px solid rgba(167, 139, 250, 0.45);
  position: relative;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.vortex-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px dashed transparent;
}

.vortex-ring.r1 {
  width: 48px;
  height: 48px;
  border-top-color: #38bdf8;
  border-right-color: #a855f7;
  animation: spinCW 3.4s linear infinite;
}

.vortex-ring.r2 {
  width: 34px;
  height: 34px;
  border-bottom-color: #ec4899;
  border-left-color: #fbbf24;
  animation: spinCCW 2.1s linear infinite;
}

.vortex-core {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #030308;
  box-shadow: 0 0 10px 2px #a855f7, inset 0 0 4px #38bdf8;
}

@keyframes spinCW {
  to { transform: rotate(360deg); }
}

@keyframes spinCCW {
  to { transform: rotate(-360deg); }
}

.hero-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.2px;
  color: #38bdf8;
  margin-bottom: 2px;
}

.hero-titles h2 {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.15;
  background: linear-gradient(135deg, #fff 20%, #c4b5fd 70%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-sub {
  font-size: 12px;
  color: #cbd5e1;
  margin-top: 3px;
}

.best-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(251, 191, 36, 0.13);
  border: 1px solid rgba(251, 191, 36, 0.36);
  border-radius: 12px;
  padding: 7px 12px;
  font-size: 12px;
  color: #fde68a;
}

.best-strip strong {
  color: #fff;
  font-weight: 800;
}

/* 模式选择 */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mode-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  padding: 10px 8px;
  color: #cbd5e1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: all 0.16s ease;
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.34), rgba(56, 189, 248, 0.24));
  border-color: #a78bfa;
  color: #fff;
  box-shadow: 0 6px 18px rgba(139, 92, 246, 0.28);
}

.mode-name {
  font-size: 13px;
  font-weight: 900;
}

.mode-desc {
  font-size: 10.5px;
  color: #94a3b8;
  text-align: center;
}

.mode-btn.active .mode-desc {
  color: #e0f2fe;
}

/* 规则列表 */
.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 11px 12px;
}

.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.45;
  color: #cbd5e1;
}

.rules-list b {
  color: #fde68a;
}

.r-ico {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* 按钮体系 */
.btn-primary, .btn-secondary, .btn-ghost {
  border: none;
  border-radius: 15px;
  font-size: 15px;
  font-weight: 900;
  padding: 13px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.14s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed 0%, #ec4899 55%, #f59e0b 100%);
  box-shadow: 0 10px 26px rgba(124, 58, 237, 0.45);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

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

.btn-secondary {
  width: 100%;
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-ghost {
  width: 100%;
  color: #94a3b8;
  background: transparent;
  font-size: 13.5px;
  padding: 9px;
}

/* 三选一升级面板 */
.levelup-panel {
  width: 100%;
  background: rgba(15, 23, 42, 0.96);
  border: 1.5px solid rgba(167, 139, 250, 0.55);
  border-radius: 24px;
  padding: 18px 15px 16px;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 13px;
  animation: modalIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.levelup-header {
  text-align: center;
}

.lu-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 900;
  color: #fde68a;
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.45);
  border-radius: 999px;
  padding: 3px 11px;
  margin-bottom: 6px;
}

.levelup-header h3 {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
}

.lu-hint {
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 2px;
}

.upgrade-cards {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.upgrade-card {
  width: 100%;
  text-align: left;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.96), rgba(23, 32, 54, 0.96));
  border: 1.5px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  padding: 12px 13px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.14s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.upgrade-card:hover {
  border-color: #a78bfa;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(124, 58, 237, 0.3);
}

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

.uc-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 24px;
  flex-shrink: 0;
  background: rgba(139, 92, 246, 0.18);
  border: 1px solid rgba(167, 139, 250, 0.35);
}

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

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

.uc-name {
  font-size: 15px;
  font-weight: 900;
  color: #fff;
}

.uc-tag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
}

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

.uc-key {
  position: absolute;
  right: 10px;
  bottom: 7px;
  font-size: 10px;
  font-weight: 800;
  color: rgba(148, 163, 184, 0.55);
}

/* 暂停面板 */
.pause-panel {
  width: 88%;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 22px;
  padding: 22px 18px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pause-panel h3 {
  font-size: 22px;
  font-weight: 900;
}

.pause-sub {
  font-size: 13px;
  color: #94a3b8;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* 结算卡片 */
.end-card {
  width: 100%;
  background: rgba(15, 23, 42, 0.96);
  border: 1.5px solid rgba(167, 139, 250, 0.5);
  border-radius: 24px;
  padding: 20px 18px 18px;
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 13px;
  animation: modalIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.end-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rank-seal {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 900;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.45);
  border: 2px solid rgba(254, 243, 199, 0.65);
}

.rank-seal.rank-splus {
  background: linear-gradient(135deg, #fbbf24, #f43f5e, #8b5cf6);
}

.rank-seal.rank-s {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
}

.rank-seal.rank-a {
  background: linear-gradient(135deg, #8b5cf6, #38bdf8);
}

.rank-seal.rank-b {
  background: linear-gradient(135deg, #10b981, #0ea5e9);
}

.end-kicker {
  font-size: 11px;
  font-weight: 800;
  color: #38bdf8;
  letter-spacing: 0.6px;
}

.end-heading h2 {
  font-size: 22px;
  font-weight: 900;
  color: #fff;
  margin-top: 1px;
}

.boss-badge {
  display: inline-block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.22);
  border: 1px solid rgba(251, 191, 36, 0.6);
  color: #fde68a;
}

.record-banner {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
}

.record-banner.new-record {
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
}

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

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat-box.highlight {
  background: rgba(139, 92, 246, 0.16);
  border-color: rgba(167, 139, 250, 0.42);
}

.stat-label {
  font-size: 11px;
  color: #94a3b8;
}

.stat-value {
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.end-actions {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 9px;
  margin-top: 2px;
}

.link-btn {
  font-size: 14px;
}
