/* ==========================================================================
   《5分钟防线：迷你背包》 - 9:16 WeChat Mini Game Portrait Stylesheet
   ========================================================================== */

:root {
  --bg-outer: #070b14;
  --bg-shell: #101727;
  --bg-panel: #162036;
  --bg-slot: #1c2842;
  --bg-slot-empty: #151f34;
  --border-subtle: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(248, 250, 252, 0.28);

  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --text-muted: #64748b;

  --gold: #fbbf24;
  --gold-deep: #d97706;
  --fire: #ff6b35;
  --ice: #38bdf8;
  --lightning: #a78bfa;
  --hp-green: #22c55e;
  --hp-warn: #f59e0b;
  --hp-danger: #ef4444;
  --shield-blue: #60a5fa;

  --lv1-border: #64748b;
  --lv1-bg: linear-gradient(155deg, #27344f 0%, #1a243b 100%);
  --lv2-border: #22c55e;
  --lv2-bg: linear-gradient(155deg, #164438 0%, #122931 100%);
  --lv3-border: #a855f7;
  --lv3-bg: linear-gradient(155deg, #3b1f5e 0%, #1f1938 100%);
  --lv4-border: #fbbf24;
  --lv4-bg: linear-gradient(155deg, #5c3a0e 0%, #2d1b0a 100%);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* {
  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%;
  background: radial-gradient(circle at 50% 20%, #1a2644 0%, var(--bg-outer) 72%);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* 9:16 WeChat Mini Game Portrait Container */
.wx-shell {
  position: relative;
  width: min(100vw, 430px);
  height: min(100dvh, 860px);
  background: linear-gradient(180deg, #111a2e 0%, #0d1424 100%);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (max-width: 450px) {
  .wx-shell {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: none;
  }
}

/* ==========================================================================
   WeChat Simulated Top Bar
   ========================================================================== */
.wx-topbar {
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  background: rgba(10, 15, 28, 0.92);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 20;
}

.wx-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, transform 0.12s;
}

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

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

.wx-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.wx-cap-btn {
  width: 28px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

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

.wx-cap-divider {
  width: 1px;
  height: 12px;
  background: rgba(255, 255, 255, 0.22);
}

/* ==========================================================================
   HUD Strip
   ========================================================================== */
.hud-bar {
  flex: 0 0 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(18, 27, 46, 0.94);
  border-bottom: 1px solid var(--border-subtle);
}

.hud-hp-group {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

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

.hud-hp-track {
  position: relative;
  flex: 1;
  height: 18px;
  background: #0b1120;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.hud-hp-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, #16a34a 0%, #4ade80 100%);
  transition: width 0.22s ease, background 0.2s;
}

.hud-hp-fill.warn {
  background: linear-gradient(90deg, #d97706 0%, #fbbf24 100%);
}

.hud-hp-fill.danger {
  background: linear-gradient(90deg, #b91c1c 0%, #f87171 100%);
}

.hud-shield-fill {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.72), rgba(147, 197, 253, 0.9));
  transition: width 0.22s ease;
}

.hud-hp-text {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}

.hud-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-gold {
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.32);
  background: rgba(251, 191, 36, 0.1);
  transition: transform 0.16s ease;
}

.hud-gold.pop {
  transform: scale(1.18);
}

.hud-wave.boss-wave {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.48);
  background: rgba(239, 68, 68, 0.18);
}

.hud-timer {
  color: #cbd5e1;
}

/* ==========================================================================
   Top Battle Arena (Canvas)
   ========================================================================== */
.arena-section {
  position: relative;
  flex: 1 1 200px;
  min-height: 150px;
  max-height: 230px;
  width: 100%;
  background: #0d1626;
  border-bottom: 2px solid rgba(251, 191, 36, 0.22);
  overflow: hidden;
}

#arena-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.boss-banner {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 82%;
  padding: 5px 9px;
  border-radius: 10px;
  background: rgba(15, 10, 22, 0.84);
  border: 1px solid rgba(239, 68, 68, 0.65);
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.25);
  pointer-events: none;
  z-index: 5;
}

.boss-banner-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
}

.boss-tag {
  padding: 1px 5px;
  border-radius: 4px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.boss-name {
  color: #fecaca;
}

.boss-hp-text {
  margin-left: auto;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

.boss-hp-track {
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #dc2626 0%, #f97316 100%);
  transition: width 0.12s linear;
}

.wave-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(251, 191, 36, 0.6);
  color: #fef08a;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.5px;
  white-space: nowrap;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 6;
  animation: toastPop 0.25s ease-out;
}

.wave-toast.boss-alert {
  background: rgba(127, 29, 29, 0.92);
  border-color: #f87171;
  color: #fff;
}

@keyframes toastPop {
  from {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.86);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ==========================================================================
   Inspector / Synergy Info Bar
   ========================================================================== */
.inspector-bar {
  flex: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  background: rgba(20, 30, 50, 0.96);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-hint {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-detail {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  overflow: hidden;
}

.inspector-name {
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.inspector-stats {
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inspector-buffs {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}

.buff-tag {
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.buff-tag.fire {
  background: rgba(255, 107, 53, 0.2);
  color: #fdba74;
  border: 1px solid rgba(255, 107, 53, 0.45);
}

.buff-tag.ice {
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.45);
}

.buff-tag.pot {
  background: rgba(251, 191, 36, 0.2);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.45);
}

/* ==========================================================================
   Middle 4x4 Mini Backpack Grid
   ========================================================================== */
.backpack-section {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px 6px;
  background: radial-gradient(circle at 50% 45%, rgba(30, 46, 78, 0.52), transparent 72%);
}

.backpack-wrap {
  position: relative;
  width: min(100%, 304px);
  aspect-ratio: 1 / 1;
  padding: 7px;
  border-radius: 16px;
  background: linear-gradient(160deg, #1b2740 0%, #11192b 100%);
  border: 2px solid rgba(251, 191, 36, 0.26);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.synergy-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.synergy-line {
  fill: none;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-dasharray: 5 5;
  opacity: 0.82;
  animation: synergyFlow 1.2s linear infinite;
}

.synergy-line.fire {
  stroke: #fb923c;
  filter: drop-shadow(0 0 4px rgba(255, 107, 53, 0.85));
}

.synergy-line.ice {
  stroke: #38bdf8;
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.85));
}

.synergy-line.pot {
  stroke: #fbbf24;
  filter: drop-shadow(0 0 4px rgba(251, 191, 36, 0.85));
}

@keyframes synergyFlow {
  to {
    stroke-dashoffset: -20;
  }
}

.backpack-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
  height: 100%;
}

.bp-slot {
  position: relative;
  border-radius: 11px;
  background: var(--bg-slot-empty);
  border: 1.5px dashed rgba(148, 163, 184, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  overflow: hidden;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.bp-slot.occupied {
  border-style: solid;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

.bp-slot.lv-1 {
  background: var(--lv1-bg);
  border-color: var(--lv1-border);
}

.bp-slot.lv-2 {
  background: var(--lv2-bg);
  border-color: var(--lv2-border);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.22);
}

.bp-slot.lv-3 {
  background: var(--lv3-bg);
  border-color: var(--lv3-border);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.34);
}

.bp-slot.lv-4 {
  background: var(--lv4-bg);
  border-color: var(--lv4-border);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.46);
}

.bp-slot.selected {
  outline: 2.5px solid #fff;
  outline-offset: -1px;
  transform: scale(1.04);
  z-index: 6;
}

.bp-slot.merge-target {
  border-color: #4ade80 !important;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.85), 0 0 16px rgba(74, 222, 128, 0.6) !important;
  animation: mergePulse 0.75s ease-in-out infinite alternate;
}

.bp-slot.buff-preview {
  box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.75);
}

.bp-slot.drag-over {
  transform: scale(1.06);
  border-color: #fff;
  z-index: 5;
}

.bp-slot.dragging-source {
  opacity: 0.35;
}

@keyframes mergePulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.05);
  }
}

.bp-slot.just-merged {
  animation: mergeBurst 0.38s cubic-bezier(0.2, 1.35, 0.4, 1);
}

@keyframes mergeBurst {
  0% {
    transform: scale(0.75);
    filter: brightness(1.9);
  }
  60% {
    transform: scale(1.13);
    filter: brightness(1.35);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

.bp-slot.firing {
  animation: weaponFire 0.22s ease-out;
}

@keyframes weaponFire {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  40% {
    transform: scale(1.1);
    filter: brightness(1.45);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

/* Live cooldown fill overlay during battle */
.slot-cd-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.26) 0%, rgba(56, 189, 248, 0.14) 100%);
  pointer-events: none;
  z-index: 1;
}

.slot-icon {
  position: relative;
  z-index: 2;
  font-size: 27px;
  line-height: 1;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.55));
  pointer-events: none;
}

.slot-lv {
  position: absolute;
  right: 3px;
  bottom: 2px;
  z-index: 3;
  padding: 0 4px;
  border-radius: 5px;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
  background: rgba(10, 15, 28, 0.82);
  color: #e2e8f0;
  pointer-events: none;
}

.lv-2 .slot-lv {
  color: #86efac;
}
.lv-3 .slot-lv {
  color: #d8b4fe;
}
.lv-4 .slot-lv {
  color: #fde047;
}

.slot-buffs {
  position: absolute;
  left: 2px;
  top: 2px;
  z-index: 3;
  display: flex;
  gap: 1px;
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

.slot-merge-hint {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  padding: 0 4px;
  border-radius: 4px;
  background: #22c55e;
  color: #052e16;
  font-size: 8.5px;
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}

/* ==========================================================================
   Bottom Dock (Prep Shop / Battle Controls)
   ========================================================================== */
.bottom-dock {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 4px 10px 10px;
  background: linear-gradient(180deg, rgba(16, 23, 39, 0.65) 0%, rgba(10, 15, 28, 0.98) 100%);
  border-top: 1px solid var(--border-subtle);
}

.prep-panel,
.battle-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* Sell / Trash Zone */
.sell-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 9px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px dashed rgba(239, 68, 68, 0.32);
  color: #fca5a5;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.sell-zone.active,
.sell-zone.drag-over {
  background: rgba(239, 68, 68, 0.26);
  border-style: solid;
  border-color: #f87171;
  color: #fff;
  transform: scale(1.015);
}

.sell-zone-val {
  font-weight: 800;
  color: #fde047;
}

/* Shop Cards */
.shop-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.shop-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 7px 5px 6px;
  border-radius: 12px;
  background: linear-gradient(165deg, #1e2c48 0%, #141e33 100%);
  border: 1.5px solid rgba(148, 163, 184, 0.26);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.12s ease, border-color 0.15s ease, opacity 0.15s;
}

.shop-card:hover:not(.sold):not(.cant-afford) {
  border-color: rgba(251, 191, 36, 0.65);
  transform: translateY(-1px);
}

.shop-card.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.45);
}

.shop-card.lv-2 {
  border-color: rgba(34, 197, 94, 0.6);
  background: linear-gradient(165deg, #193e36 0%, #12252d 100%);
}

.shop-card.cant-afford {
  opacity: 0.56;
}

.shop-card.sold {
  opacity: 0.25;
  pointer-events: none;
  border-style: dashed;
}

.shop-merge-badge {
  position: absolute;
  top: -6px;
  right: 4px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #22c55e;
  color: #052e16;
  font-size: 9px;
  font-weight: 900;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.5);
}

.shop-card-top {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.shop-icon {
  font-size: 24px;
  line-height: 1;
}

.shop-lv {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.45);
  color: #cbd5e1;
}

.shop-card.lv-2 .shop-lv {
  color: #86efac;
}

.shop-name {
  font-size: 12px;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.2;
}

.shop-stat {
  font-size: 10px;
  color: #94a3b8;
  margin: 1px 0 4px;
  text-align: center;
  line-height: 1.15;
}

.shop-price {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.42);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
}

.shop-card.cant-afford .shop-price {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.12);
}

/* Action Buttons */
.prep-actions,
.battle-actions {
  display: flex;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s ease, filter 0.15s ease, opacity 0.15s;
}

.btn:active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-refresh {
  flex: 0 0 38%;
  height: 40px;
  background: linear-gradient(180deg, #273759 0%, #1c2842 100%);
  border: 1px solid rgba(148, 163, 184, 0.34);
  color: #e2e8f0;
  font-size: 13px;
}

.btn-cost {
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.18);
  color: var(--gold);
  font-size: 11px;
}

.btn-start-wave,
.btn-primary {
  flex: 1;
  height: 40px;
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #1c1002;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.36);
}

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

.btn-secondary {
  flex: 1;
  height: 38px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #f8fafc;
  font-size: 13px;
}

.btn-speed {
  flex: 1.3;
  height: 38px;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  font-size: 13px;
}

.btn-speed.fast {
  background: linear-gradient(180deg, #9333ea 0%, #7e22ce 100%);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.45);
}

/* Battle Panel Specifics */
.battle-progress-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
}

.battle-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  animation: pulseDot 1s ease-in-out infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.battle-progress-label {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
}

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

.battle-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #a78bfa);
  transition: width 0.2s linear;
}

.talent-chips {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}

.talent-chips::-webkit-scrollbar {
  display: none;
}

.talent-chip-empty {
  font-size: 11px;
  color: var(--text-muted);
}

.talent-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.16);
  border: 1px solid rgba(167, 139, 250, 0.36);
  color: #e9d5ff;
  font-size: 10.5px;
  font-weight: 700;
}

/* ==========================================================================
   Overlays & Modals
   ========================================================================== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 20, 0.84);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.start-card,
.modal-card {
  width: 100%;
  max-width: 372px;
  max-height: 92%;
  overflow-y: auto;
  padding: 20px 16px 18px;
  border-radius: 20px;
  background: linear-gradient(170deg, #1b2742 0%, #10182b 100%);
  border: 1.5px solid rgba(251, 191, 36, 0.35);
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.start-badge,
.modal-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.16);
  border: 1px solid rgba(251, 191, 36, 0.42);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 10px;
}

.start-logo {
  font-size: 27px;
  line-height: 1.22;
  font-weight: 900;
  color: #fff;
  margin-bottom: 6px;
}

.start-logo span {
  background: linear-gradient(90deg, #fde047, #fb923c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.start-tagline {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

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

.mode-card {
  padding: 10px 8px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.05);
  border: 1.5px solid rgba(148, 163, 184, 0.24);
  color: var(--text-main);
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.mode-card.active {
  background: rgba(251, 191, 36, 0.16);
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.22);
}

.mode-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 3px;
}

.mode-desc {
  font-size: 10.5px;
  color: var(--text-dim);
}

.rules-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-bottom: 16px;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  line-height: 1.35;
  color: #cbd5e1;
}

.rule-item strong {
  color: #f8fafc;
}

.rule-ico {
  font-size: 20px;
  flex-shrink: 0;
}

.btn-play {
  width: 100%;
  height: 46px;
  font-size: 16px;
  border-radius: 14px;
}

/* Talent Modal */
.modal-title {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  margin-bottom: 4px;
}

.modal-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.talent-choices {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.talent-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(150deg, #24355a 0%, #18243f 100%);
  border: 1.5px solid rgba(167, 139, 250, 0.42);
  color: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.talent-card:hover {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.25);
  transform: translateY(-1px);
}

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

.talent-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.talent-info {
  flex: 1;
}

.talent-name {
  font-size: 14px;
  font-weight: 800;
  color: #fde68a;
  margin-bottom: 2px;
}

.talent-desc {
  font-size: 11.5px;
  color: #cbd5e1;
  line-height: 1.35;
}

/* Help Modal */
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.modal-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.help-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: left;
  margin-bottom: 10px;
}

.help-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 11.5px;
  line-height: 1.35;
  color: #cbd5e1;
}

.help-row span {
  font-size: 18px;
  line-height: 1.1;
}

.help-row strong {
  color: #fff;
}

.help-tip {
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.32);
  color: #bae6fd;
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
}

/* End Screen */
.end-icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 6px;
}

.end-title {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 4px;
}

.end-title.win {
  color: #fde047;
}

.end-title.lose {
  color: #fca5a5;
}

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

.end-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 12px;
}

.stat-box {
  padding: 8px 6px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.stat-val {
  font-size: 16px;
  font-weight: 900;
  color: #fff;
}

.stat-lbl {
  font-size: 10.5px;
  color: var(--text-dim);
}

.snapshot-section {
  margin-bottom: 14px;
}

.snapshot-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.end-snapshot {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  width: 176px;
  margin: 0 auto;
  padding: 6px;
  border-radius: 12px;
  background: rgba(10, 15, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.snap-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
}

.snap-cell.lv-1 { border-color: var(--lv1-border); background: #22304a; }
.snap-cell.lv-2 { border-color: var(--lv2-border); background: #153c33; }
.snap-cell.lv-3 { border-color: var(--lv3-border); background: #361c56; }
.snap-cell.lv-4 { border-color: var(--lv4-border); background: #59380d; }

.snap-lv {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 8px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}

.end-actions {
  display: flex;
  gap: 8px;
}

.btn-hub {
  height: 40px;
}

/* Floating Drag Ghost */
.drag-ghost {
  position: fixed;
  width: 64px;
  height: 64px;
  border-radius: 13px;
  background: rgba(30, 41, 59, 0.94);
  border: 2px solid #fbbf24;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 999;
  transform: translate(-50%, -50%) scale(1.08);
}

.drag-ghost .ghost-ico {
  font-size: 30px;
  line-height: 1;
}

.drag-ghost .ghost-lv {
  font-size: 10px;
  font-weight: 800;
  color: #fde047;
  margin-top: 2px;
}
