:root {
  color-scheme: light;
  --ink: #273247;
  --muted: #667085;
  --sky: #9bd8ff;
  --sky-deep: #65b9f0;
  --grass: #63c56e;
  --grass-dark: #3f9f56;
  --earth: #87624a;
  --earth-dark: #604333;
  --coin: #ffd45a;
  --danger: #ec5b5b;
  --panel: #fff9e8;
  --panel-line: #e5c985;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, #d8f1ff 0%, #fff6d6 78%),
    var(--sky);
  color: var(--ink);
  font-family: "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
}

.game-shell {
  width: min(100vw - 24px, 1040px);
  display: grid;
  gap: 12px;
}

.topbar,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  background: var(--panel);
  border: 3px solid var(--panel-line);
  border-radius: 18px;
  box-shadow: 0 5px 0 rgba(96, 67, 51, 0.18);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 20px;
  height: 20px;
  display: inline-block;
  background:
    linear-gradient(90deg, transparent 0 4px, #ffcf4d 4px 16px, transparent 16px),
    linear-gradient(#ffcf4d 0 100%);
  border: 3px solid #a9762d;
  border-radius: 6px;
}

.version {
  color: var(--muted);
  font-size: 13px;
}

.hud,
.controls {
  font-size: 15px;
  font-weight: 700;
}

.hud {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.hud strong {
  color: #c35b34;
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #8ad1ff;
  border: 4px solid #5c7c91;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 8px 0 rgba(39, 50, 71, 0.16);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.message {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 24px 28px;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(170deg, rgba(20,35,68,0.92) 0%, rgba(44,62,102,0.88) 40%, rgba(26,45,82,0.94) 100%);
  backdrop-filter: blur(3px);
}

.message.is-visible {
  display: flex;
}

/* 动态渐变背景层 */
.menu-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(100,160,255,0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(180,120,255,0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(60,200,180,0.12) 0%, transparent 60%);
  animation: menuBgShift 12s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes menuBgShift {
  0%   { background-position: 0% 0%, 100% 100%, 50% 50%; }
  100% { background-position: 30% 20%, 70% 80%, 40% 60%; }
}

/* 粒子层（由 JS 填充圆点，纯装饰） */
.menu-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.menu-particles::before,
.menu-particles::after {
  content: "";
  position: absolute;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,0.6);
  animation: menuFloatA 6s linear infinite;
}
.menu-particles::before { left: 15%; top: 20%; animation-duration: 7s; }
.menu-particles::after  { left: 80%; top: 60%; animation-duration: 9s; }

@keyframes menuFloatA {
  0%, 100% { transform: translate(0,0); opacity: 0.4; }
  50%      { transform: translate(20px,-30px); opacity: 0.9; }
}

/* 内容容器 */
.menu-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 14px;
}

/* 标题区 */
.menu-header {
  text-align: center;
  padding-top: 4px;
}

.menu-title {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  line-height: 1;
}

.title-main {
  font-size: clamp(28px, 5.2vw, 56px);
  font-weight: 900;
  color: #fff8dc;
  text-shadow:
    0 0 12px rgba(255,200,80,0.5),
    0 3px 0 #c47a1f,
    0 6px 0 rgba(0,0,0,0.3);
  letter-spacing: 0.08em;
  animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  0%   { text-shadow: 0 0 12px rgba(255,200,80,0.4), 0 3px 0 #c47a1f, 0 6px 0 rgba(0,0,0,0.3); }
  100% { text-shadow: 0 0 20px rgba(255,220,120,0.8), 0 3px 0 #c47a1f, 0 6px 0 rgba(0,0,0,0.3); }
}

.title-sub {
  font-size: clamp(11px, 1.4vw, 16px);
  font-weight: 700;
  letter-spacing: 0.35em;
  color: rgba(255,230,180,0.7);
  margin-top: 4px;
}

.menu-desc {
  margin: 8px 0 0;
  color: rgba(255,255,255,0.75);
  font-size: clamp(12px, 1.4vw, 15px);
  font-weight: 600;
}

/* 三栏主体 */
.menu-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 14px;
  min-height: 0;
}

.menu-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.card-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255,220,140,0.85);
  margin-bottom: 6px;
}

/* 角色预览卡片 */
.menu-preview-card,
.menu-stats-card,
.menu-skills-card,
.menu-level-select {
  background: rgba(255,250,230,0.08);
  border: 1.5px solid rgba(255,220,140,0.25);
  border-radius: 14px;
  padding: 12px;
  backdrop-filter: blur(4px);
}

.menu-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.menu-preview-canvas {
  background: linear-gradient(180deg, rgba(100,180,255,0.15), rgba(60,120,200,0.1));
  border-radius: 12px;
  border: 1.5px solid rgba(255,255,255,0.15);
  image-rendering: pixelated;
}

.menu-preview-skins {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

.menu-skin-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.menu-skin-btn:hover { transform: translateY(-2px); }
.menu-skin-btn.is-active {
  border-color: #ffe080;
  box-shadow: 0 0 10px rgba(255,220,120,0.6);
}
.menu-skin-btn.is-locked {
  opacity: 0.4;
  cursor: not-allowed;
}
.menu-skin-btn .skin-badge {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.menu-preview-name {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
}

/* 统计卡片 */
.menu-stats-card {
  flex: 1;
  min-height: 0;
}

.menu-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}
.stat-row strong {
  color: #ffe080;
  font-size: 14px;
}

/* 中央列 */
.menu-center {
  align-items: center;
  gap: 12px;
}

.menu-start-btn {
  position: relative;
  width: 240px;
  height: 64px;
  border: 3px solid #d48b2a;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffcf4d 0%, #f0a830 100%);
  color: #57351d;
  font-weight: 900;
  font-size: 22px;
  box-shadow: 0 6px 0 #b5752f, 0 0 20px rgba(255,200,80,0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.1s, box-shadow 0.1s;
  animation: startBtnPulse 2s ease-in-out infinite;
}

@keyframes startBtnPulse {
  0%, 100% { box-shadow: 0 6px 0 #b5752f, 0 0 20px rgba(255,200,80,0.4); }
  50%      { box-shadow: 0 6px 0 #b5752f, 0 0 35px rgba(255,220,120,0.7); }
}

.menu-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #b5752f, 0 0 30px rgba(255,220,120,0.6);
}

.menu-start-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b5752f;
  animation: none;
}

.menu-start-btn .btn-icon {
  font-size: 18px;
}

/* 关卡选择 */
.menu-level-select {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

.menu-level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex: 1;
  width: 100%;
  min-width: 0;
}

.level-card {
  position: relative;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,220,140,0.3);
  border-radius: 10px;
  padding: 8px 6px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  min-width: 0;
}
.level-card:hover {
  transform: translateY(-2px);
  background: rgba(255,220,140,0.15);
  border-color: rgba(255,220,140,0.6);
}
.level-card.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}
.level-card.is-locked:hover {
  transform: none;
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,220,140,0.3);
}
.level-card.is-cleared {
  border-color: rgba(120,220,130,0.5);
  background: rgba(120,220,130,0.1);
}

.level-card-num {
  font-size: 18px;
  font-weight: 900;
  color: #ffe080;
  line-height: 1;
}
.level-card-name {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.level-card-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  color: rgba(255,255,255,0.6);
}
.level-card-best {
  font-size: 9px;
  color: rgba(180,220,255,0.7);
  margin-top: 1px;
}

/* 技能列表 */
.menu-skills-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.menu-skills-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  text-align: left;
}

.skills-empty {
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  text-align: center;
  padding: 16px 0;
}

.menu-skill-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.9);
}
.menu-skill-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.menu-skill-info {
  flex: 1;
  min-width: 0;
}
.menu-skill-name {
  font-weight: 700;
  font-size: 12px;
}
.menu-skill-type {
  font-size: 10px;
  color: rgba(255,220,140,0.7);
}

/* 右侧操作按钮 */
.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 2px solid rgba(255,220,140,0.4);
  border-radius: 10px;
  background: rgba(255,250,230,0.1);
  color: rgba(255,255,255,0.9);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  box-shadow: none;
  min-width: auto;
}
.menu-action-btn:hover {
  background: rgba(255,220,140,0.2);
  border-color: rgba(255,220,140,0.7);
  transform: translateY(-1px);
}
.menu-action-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

/* 自定义滚动条 */
.menu-skills-list::-webkit-scrollbar { width: 4px; }
.menu-skills-list::-webkit-scrollbar-track { background: transparent; }
.menu-skills-list::-webkit-scrollbar-thumb { background: rgba(255,220,140,0.3); border-radius: 2px; }

/* 响应式：窄屏适配 */
@media (max-width: 800px) {
  .menu-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .menu-level-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

button {
  min-width: 128px;
  border: 3px solid #8a5f34;
  border-radius: 14px;
  padding: 11px 18px;
  background: #ffcf4d;
  color: #57351d;
  box-shadow: 0 5px 0 #b5752f;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #b5752f;
}

.controls {
  justify-content: center;
  color: var(--muted);
}

.shop-btn {
  min-width: auto;
  padding: 7px 14px;
  border: 2px solid #b5752f;
  border-radius: 10px;
  background: #ffe08a;
  box-shadow: 0 3px 0 #b5752f;
  font-size: 14px;
  font-weight: 800;
  color: #57351d;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}

.shop-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #b5752f;
}

.shop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 26, 38, .72);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  z-index: 50;
}

.shop-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.shop-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.92);
  width: min(92vw, 560px);
  max-height: 86vh;
  overflow-y: auto;
  padding: 24px 24px 20px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow:
    0 24px 48px rgba(39, 50, 71, .28),
    0 8px 16px rgba(39, 50, 71, .16);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2, .8, .2, 1);
  z-index: 60;
}

.shop-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

body.shop-open {
  overflow: hidden;
}

.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.shop-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: #1d1d1f;
  letter-spacing: -0.02em;
}

.shop-close {
  width: 32px;
  height: 32px;
  min-width: auto;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .06);
  box-shadow: none;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  color: #1d1d1f;
  cursor: pointer;
  transition: background .15s;
}

.shop-close:hover {
  background: rgba(0, 0, 0, .12);
}

.shop-balance {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  color: #6e6e73;
}

.shop-balance strong {
  color: #ff9b2e;
  font-size: 18px;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skill-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #f5f5f7;
  border-radius: 12px;
  transition: background .15s;
}

.skill-card.is-owned {
  background: #eef9f0;
}

.skill-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 10px;
  font-size: 22px;
  box-shadow: 0 1px 3px rgba(39, 50, 71, .12);
}

.skill-info {
  flex: 1;
  min-width: 0;
}

.skill-name {
  font-size: 15px;
  font-weight: 800;
  color: #1d1d1f;
  margin-bottom: 2px;
}

.skill-desc {
  font-size: 13px;
  color: #6e6e73;
  line-height: 1.4;
}

.skill-buy {
  flex-shrink: 0;
  min-width: auto;
  padding: 8px 14px;
  border: none;
  border-radius: 10px;
  background: #0071e3;
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}

.skill-buy:active {
  transform: scale(.96);
}

.skill-buy:disabled {
  background: #d2d2d7;
  color: #86868b;
  cursor: not-allowed;
}

.skill-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.skill-act {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 6px 12px;
  font: 700 12px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  color: #1d1d1f;
  background: #f2f2f7;
  cursor: pointer;
  transition: opacity .15s, transform .1s, background .15s;
}
.skill-act:not(:disabled):hover { background: #e5e5ea; }
.skill-act:active { transform: scale(.96); }
.skill-act:disabled {
  background: #f7f7f9;
  color: #a1a1a6;
  cursor: not-allowed;
}

.skill-type-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font: 700 11px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  vertical-align: middle;
}
.skill-type-tag.is-passive { background: #e7f3ff; color: #1d6fd9; }
.skill-type-tag.is-active  { background: #fff2d9; color: #a35900; }

.skill-card.is-owned .skill-buy {
  background: #34c759;
  color: #fff;
}
.skill-card.is-owned .skill-buy.is-unequip {
  background: #ff6b6b;
  color: #fff;
}
.skill-card .skill-buy[data-kind="skill"]:not(:disabled) { box-shadow: 0 2px 0 rgba(0, 113, 227, .2); }
.skill-card.is-owned .skill-buy.is-unequip:not(:disabled) { box-shadow: 0 2px 0 rgba(255, 80, 80, .2); }

/* ============== HUD 技能 3 格槽（Q / E / R） ============== */
.skill-bar {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
/* 被动胶囊条（无上限），放在主动技能栏下面一行，HUD 内 */
.passive-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.passive-chip {
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  border: 1.5px solid rgba(29, 111, 217, .2);
  background: linear-gradient(180deg, #ffffff, #eef6ff);
  box-shadow:
    inset 0 -1px 0 rgba(29, 111, 217, .05),
    0 2px 4px rgba(29, 111, 217, .08);
  transition: transform .08s, border-color .2s, box-shadow .2s;
  color: #1d1d1f;
  line-height: 1;
}
.passive-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 113, 227, .4);
  box-shadow: 0 4px 12px rgba(0, 113, 227, .16);
}
.passive-chip:active { transform: translateY(0) scale(.985); }
.passive-chip .pc-icon {
  font-size: 14px;
  line-height: 1;
  display: inline-grid; place-items: center;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(29, 111, 217, .1);
}
.passive-chip .pc-name {
  font: 800 11px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  color: #1d6fd9;
  white-space: nowrap;
}
.passive-chip.big {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 32px 1fr;
  grid-template-rows: auto auto;
  grid-template-areas:
    "icon meta"
    "icon meta";
  gap: 0 10px;
  align-items: start;
  border-radius: 14px;
  text-align: left;
  background: linear-gradient(180deg, #ffffff, #eef6ff);
}
.passive-chip.big.is-equipped {
  border-color: rgba(52, 199, 89, .55);
  background: linear-gradient(180deg, #ffffff, #eefbf2);
  box-shadow: 0 2px 0 rgba(52, 199, 89, .2);
}
.passive-chip.big .pc-icon {
  grid-area: icon;
  width: 32px; height: 32px;
  font-size: 18px;
  border-radius: 10px;
  background: #fff;
}
.passive-chip.big .pc-meta { grid-area: meta; display: grid; gap: 3px; min-width: 0; }
.passive-chip.big .pc-name {
  font: 800 13px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  color: #1d1d1f;
}
.passive-chip.big .pc-desc {
  font-size: 12px;
  color: #6e6e73;
  line-height: 1.45;
}
.equip-passives {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}
.sk-slot {
  position: relative;
  width: 78px;
  height: 68px;
  padding: 6px 4px 4px;
  border-radius: 14px;
  border: 1.5px solid rgba(39, 50, 71, .08);
  background: linear-gradient(180deg, #ffffff 0%, #f4f6fb 100%);
  box-shadow:
    inset 0 -2px 0 rgba(39, 50, 71, .04),
    0 2px 6px rgba(39, 50, 71, .08);
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 14px 24px 18px;
  justify-items: center;
  gap: 2px;
  transition: transform .1s, border-color .2s, box-shadow .2s;
  font-family: inherit;
}
.sk-slot:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 113, 227, .35);
  box-shadow:
    inset 0 -2px 0 rgba(0, 113, 227, .05),
    0 6px 18px rgba(0, 113, 227, .14);
}
.sk-slot:active { transform: translateY(0) scale(.98); }
.sk-slot.is-empty { opacity: .7; }
.sk-slot.is-empty .sk-slot-icon { color: #c7c7cc; }
.sk-slot.is-passive { background: linear-gradient(180deg, #ffffff 0%, #eef7ff 100%); border-color: rgba(29, 111, 217, .25); }
.sk-slot.is-active  { background: linear-gradient(180deg, #ffffff 0%, #fff6e0 100%); border-color: rgba(255, 149, 0, .3); }

.sk-slot-key {
  position: absolute;
  top: 2px; left: 4px;
  font: 700 10px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  color: #8e8e93;
  letter-spacing: .5px;
}
.sk-slot-icon {
  margin-top: 10px;
  font-size: 20px;
  line-height: 24px;
  font-weight: 700;
  color: #1d1d1f;
}
.sk-slot-name {
  font: 700 11px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  color: #1d1d1f;
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sk-slot-cd {
  position: absolute;
  inset: auto 0 0 0;
  height: 6px;
  background: rgba(39, 50, 71, .08);
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}
.sk-slot-cd-fill {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(255, 149, 0, .95), rgba(255, 94, 0, .95));
  transition: height .1s linear;
}
.sk-slot.is-passive .sk-slot-cd-fill {
  background: linear-gradient(180deg, rgba(29, 111, 217, .55), rgba(20, 80, 180, .55));
}
.sk-slot-cd-text {
  position: absolute;
  top: -14px; right: 3px;
  font: 800 10px "SFMono-Regular", Consolas, monospace;
  color: #8e8e93;
}

/* ============== 商城内装备面板 ============== */
.equip-panel {
  margin-top: 22px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(242, 242, 247, .7);
  border: 1px solid rgba(120, 120, 128, .12);
  display: grid;
  gap: 12px;
}
.equip-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}
.equip-head-title {
  font-size: 14px;
  color: #1d1d1f;
}
.equip-head-title b { font-weight: 800; }
.equip-head-slot-label {
  font-size: 12px;
  color: #8e8e93;
}
.equip-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.equip-slot-btn {
  appearance: none;
  padding: 14px 10px;
  border: 1.5px solid rgba(120, 120, 128, .16);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "key  icon tag"
    "name name name";
  gap: 2px 8px;
  align-items: center;
  text-align: left;
  font-family: inherit;
  transition: transform .08s, border-color .2s, background .2s;
}
.equip-slot-btn:hover { border-color: rgba(0, 113, 227, .4); background: #f7faff; }
.equip-slot-btn:active { transform: scale(.985); }
.equip-slot-btn.empty { opacity: .7; }
.equip-slot-btn.has-skill.is-active  { background: linear-gradient(180deg, #fff, #fff3e0); border-color: rgba(255, 149, 0, .45); }
.equip-slot-btn.has-skill.is-passive { background: linear-gradient(180deg, #fff, #eef6ff); border-color: rgba(29, 111, 217, .35); }
.eq-key {
  grid-area: key;
  font: 800 11px "SFMono-Regular", Consolas, monospace;
  padding: 2px 7px;
  border-radius: 8px;
  background: rgba(120, 120, 128, .12);
  color: #1d1d1f;
}
.eq-icon { grid-area: icon; font-size: 22px; justify-self: center; }
.eq-name { grid-area: name; font: 700 13px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif; color: #1d1d1f; }
.eq-tag {
  grid-area: tag;
  font: 700 10px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  padding: 2px 7px;
  border-radius: 999px;
  color: #1d1d1f;
  background: rgba(120, 120, 128, .1);
  justify-self: end;
}
.equip-slot-btn.has-skill.is-active  .eq-tag { background: #fff2d9; color: #a35900; }
.equip-slot-btn.has-skill.is-passive .eq-tag { background: #e7f3ff; color: #1d6fd9; }
.eq-empty-tag { background: #f2f2f7; color: #8e8e93; }

.equip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.equip-card {
  appearance: none;
  font-family: inherit;
  padding: 12px;
  border: 1.5px solid rgba(120, 120, 128, .15);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  text-align: left;
  transition: transform .08s, border-color .2s, background .2s, box-shadow .2s;
}
.equip-card:hover {
  border-color: rgba(0, 113, 227, .4);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 113, 227, .08);
}
.equip-card:active { transform: translateY(0) scale(.99); }
.equip-card.is-equipped {
  border-color: rgba(52, 199, 89, .55);
  background: linear-gradient(180deg, #ffffff, #f1fbf4);
  box-shadow: 0 2px 0 rgba(52, 199, 89, .2);
}
.ec-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: #f5f5f7;
  display: grid; place-items: center;
  font-size: 22px;
  box-shadow: inset 0 0 0 1px rgba(120, 120, 128, .08);
}
.equip-card.is-active  .ec-icon { background: #fff7dd; }
.equip-card.is-passive .ec-icon { background: #eaf3ff; }
.ec-meta { display: grid; gap: 3px; min-width: 0; }
.ec-name { font: 800 14px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif; color: #1d1d1f; }
.ec-desc { font-size: 12px; color: #6e6e73; line-height: 1.45; }
.ec-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.ec-tag {
  font: 700 10px "Trebuchet MS", "Microsoft YaHei", system-ui, sans-serif;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(120, 120, 128, .08);
  color: #3a3a3c;
}
.ec-tag.ec-active    { background: #fff2d9; color: #a35900; }
.ec-tag.ec-passive   { background: #e7f3ff; color: #1d6fd9; }
.ec-tag.ec-equipped  { background: #d7f5de; color: #0a7a2b; }
.ec-tag.ec-free      { background: #f2f2f7; color: #8e8e93; }
.ec-tag.ec-cd        { background: #f7e7ff; color: #6a2aa0; }

.equip-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 22px 16px;
  border-radius: 14px;
  background: #fff;
  color: #8e8e93;
  font-size: 13px;
  border: 1.5px dashed rgba(120, 120, 128, .2);
}

.shop-tabs {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: rgba(120, 120, 128, 0.08);
  border-radius: 12px;
  width: fit-content;
}
.shop-tab {
  appearance: none;
  border: 0;
  padding: 8px 18px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  color: #1d1d1f;
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}
.shop-tab:hover { background: rgba(255, 255, 255, 0.6); }
.shop-tab.is-active {
  background: #fff;
  color: #1d1d1f;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.shop-tip {
  margin: 14px 0 0;
  font-size: 12px;
  color: #86868b;
  line-height: 1.5;
}

.hud #timerLabel {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  letter-spacing: .5px;
  color: #1d1d1f;
}
.hud #timerBest {
  font-size: 11px;
  color: #86868b;
  margin-left: 4px;
  font-weight: normal;
}
.hud #timerBest b {
  color: #2b64e6;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-weight: 700;
}
.hud #timerBest.is-record b {
  color: #e28a20;
}
.timer-record-flash {
  animation: timer-pulse 1.2s ease-out;
}
@keyframes timer-pulse {
  0%   { transform: scale(1);   color: #1d1d1f; }
  25%  { transform: scale(1.1); color: #e28a20; }
  60%  { transform: scale(1);   color: #e28a20; }
  100% { transform: scale(1);   color: #1d1d1f; }
}

.stage-wrap {
  position: relative;
}

.editor-overlay {
  position: absolute;
  inset: 14px 14px 14px 14px;
  border-radius: 18px;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .04), rgba(30, 40, 80, .06)),
    repeating-linear-gradient(45deg, rgba(110, 135, 255, .06) 0 10px, rgba(110, 135, 255, .02) 10px 20px);
  box-shadow: inset 0 0 0 2px rgba(91, 117, 255, .35);
  backdrop-filter: blur(0.4px);
  z-index: 5;
  transition: opacity .2s ease;
}
.editor-overlay.is-hidden { opacity: 0; pointer-events: none; }

.editor-panel {
  position: absolute;
  left: 26px;
  top: 26px;
  right: 26px;
  z-index: 6;
  max-width: 760px;
  margin: 0 auto;
  background: rgba(255, 255, 255, .96);
  color: #1d1d1f;
  border-radius: 16px;
  padding: 10px 14px 12px;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, .2),
    0 2px 8px rgba(15, 23, 42, .08),
    inset 0 0 0 1px rgba(15, 23, 42, .06);
  font-family: -apple-system, "SF Pro Text", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: opacity .25s ease, transform .25s ease;
  transform-origin: top center;
}
.editor-panel.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(.985);
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(15, 23, 42, .07);
  margin-bottom: 8px;
}
.editor-head h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: .2px;
  font-weight: 700;
}
.editor-hint {
  font-size: 11px;
  color: #6b7280;
}
.editor-hint kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eef0f5;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  border: 1px solid rgba(15, 23, 42, .07);
  color: #111827;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .05);
}

.editor-tools {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 6px;
}
.editor-tools button {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, .09);
  background: #fff;
  color: #1d1d1f;
  border-radius: 11px;
  padding: 8px 6px 7px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  line-height: 1.1;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.editor-tools button:hover {
  background: #f5f7ff;
  border-color: rgba(91, 117, 255, .35);
}
.editor-tools button:active { transform: scale(.97); }
.editor-tools button.is-active {
  background: linear-gradient(180deg, #4f7bff, #3357e0);
  border-color: #2a48c4;
  color: #fff;
  box-shadow: 0 4px 10px rgba(51, 87, 224, .28), inset 0 -1px 0 rgba(0, 0, 0, .1);
}
.editor-tools button.is-active .sw {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .55), 0 1px 2px rgba(0, 0, 0, .15);
}

.sw {
  width: 22px;
  height: 14px;
  border-radius: 5px;
  background: #999;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .1);
  display: inline-block;
}
.sw-platform { background: linear-gradient(180deg, #7fc96f 0 40%, #87624a 40% 100%); }
.sw-pit      { background: linear-gradient(180deg, #d7e3ff, #0c1333); border: 1px solid rgba(15, 23, 42, .2); }
.sw-trap     { background: linear-gradient(180deg, transparent 50%, #d0d7e2 50%); clip-path: polygon(0 100%, 12% 50%, 25% 100%, 37% 50%, 50% 100%, 62% 50%, 75% 100%, 87% 50%, 100% 100%); background-color: #c4cad8; border: none; }
.sw-coin     { background: radial-gradient(circle at 35% 35%, #fff5b8, #f0b229 70%); border-radius: 50%; width: 16px; height: 16px; }
.sw-enemy    { background: linear-gradient(180deg, #ff9494, #b94040); border-radius: 5px; }
.sw-flyer    { background: linear-gradient(180deg, #a98bff, #562fc2); border-radius: 50% 50% 45% 45%; }
.sw-shooter  { background: linear-gradient(180deg, #9b6aff, #2c1f63); }
.sw-spring   { background: linear-gradient(180deg, #ffd173 0 30%, #b48236 30% 100%); }
.sw-powerup  { background: radial-gradient(circle at 40% 30%, #ffffff, #53e0ff 70%); border-radius: 40%; }
.sw-spawn    { background: linear-gradient(180deg, #4a9eff, #2a6ecf); height: 18px; clip-path: polygon(20% 100%, 20% 40%, 50% 10%, 80% 40%, 80% 100%); }
.sw-finish   { background: repeating-linear-gradient(45deg, #fff9e8 0 4px, #273247 4px 8px); }
.sw-erase    { background: repeating-linear-gradient(45deg, #fff 0 4px, #e64a6c 4px 7px); border-color: #e64a6c; }

.editor-foot {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(15, 23, 42, .07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.editor-save, .editor-reset {
  appearance: none;
  border: 1px solid rgba(15, 23, 42, .1);
  background: #fff;
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.editor-save {
  background: linear-gradient(180deg, #1fb77a, #158e5f);
  border-color: #0e6e4a;
  color: #fff;
  box-shadow: 0 4px 10px rgba(31, 183, 122, .25), inset 0 -1px 0 rgba(0, 0, 0, .1);
  font-weight: 700;
}
.editor-save:hover { filter: brightness(1.04); }
.editor-save:active { transform: scale(.97); }
.editor-reset:hover { background: #fef1ef; color: #b92644; border-color: #e6b6bf; }
.editor-reset:active { transform: scale(.97); }
.editor-status {
  margin-left: auto;
  font-size: 11.5px;
  color: #4b5563;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(17, 24, 39, .04);
  min-width: 120px;
  text-align: center;
}
.editor-status.is-ok    { background: #e6faf1; color: #137954; }
.editor-status.is-err   { background: #fde8ec; color: #b92644; }
.editor-status.is-warn  { background: #fff3dc; color: #a76914; }

@media (max-width: 620px) {
  body {
    align-items: start;
    padding-top: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .hud {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
  }

  .controls {
    font-size: 13px;
  }
}
