/* ==========================================================================
   《5分钟抓宠：极速自走棋》 — 9:16 WeChat Mini Game Portrait Styles
   ========================================================================== */

:root {
  --bg-outer: #0d1d2b;
  --shell-bg: #f4faf6;
  --topbar-bg: linear-gradient(135deg, #164e63 0%, #1d6b7a 100%);
  --ink: #1a2d3b;
  --ink-soft: #526b7a;
  --gold: #f59e0b;
  --gold-bright: #fbbf24;
  --gold-soft: #fef3c7;
  --emerald: #10b981;
  --emerald-dark: #059669;
  --coral: #f43f5e;
  --sky: #0ea5e9;
  --fire: #f97316;
  --ice: #38bdf8;
  --electric: #eab308;
  --armor: #64748b;
  --card-shadow: 0 4px 12px rgba(15, 40, 60, 0.1);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: radial-gradient(circle at 30% 20%, #1d4e63 0%, #0d1d2b 65%, #07111a 100%);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==================== 9:16 WeChat Phone Shell ==================== */
.phone-shell {
  width: 100%;
  max-width: 430px;
  height: min(100dvh, 860px);
  background: var(--shell-bg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.14);
}

@media (min-width: 460px) {
  .phone-shell {
    border-radius: 28px;
    border: 3px solid rgba(255, 255, 255, 0.16);
  }
}

/* Simulated WeChat Top Bar */
.wx-topbar {
  height: 46px;
  flex-shrink: 0;
  background: var(--topbar-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  box-shadow: 0 2px 8px rgba(10, 35, 50, 0.22);
  z-index: 20;
}

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

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

.wx-title {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.wx-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.2);
  padding: 3px 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.wx-icon-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.15s;
}

.wx-icon-btn:active {
  transform: scale(0.9);
  background: rgba(255, 255, 255, 0.3);
}

/* ==================== Screen Host ==================== */
.screen-host {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* ==================== START SCREEN ==================== */
.screen-start {
  background: linear-gradient(180deg, #dff7ea 0%, #f1fcf6 45%, #fffbeb 100%);
  padding: 14px 16px 16px;
  justify-content: space-between;
  overflow-y: auto;
  gap: 10px;
}

.start-bg-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.deco-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.45;
}

.orb-1 {
  width: 170px;
  height: 170px;
  top: -50px;
  right: -40px;
  background: radial-gradient(circle, #fde68a 0%, transparent 70%);
}

.orb-2 {
  width: 150px;
  height: 150px;
  top: 120px;
  left: -55px;
  background: radial-gradient(circle, #7dd3fc 0%, transparent 70%);
}

.orb-3 {
  width: 190px;
  height: 190px;
  bottom: -60px;
  right: -45px;
  background: radial-gradient(circle, #6ee7b7 0%, transparent 70%);
}

.start-hero {
  text-align: center;
  position: relative;
  z-index: 1;
}

.hero-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f97316, #f59e0b);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.6px;
  box-shadow: 0 3px 10px rgba(249, 115, 22, 0.35);
  margin-bottom: 6px;
}

.hero-title {
  font-size: 27px;
  line-height: 1.15;
  font-weight: 900;
  color: #134e4a;
  text-shadow: 0 2px 0 #ffffff;
}

.hero-title span {
  background: linear-gradient(90deg, #ea580c, #d97706, #059669);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-mascot-stage {
  margin: 8px auto 4px;
  width: 100%;
  max-width: 350px;
  height: 112px;
  border-radius: 18px;
  background: linear-gradient(180deg, #bae6fd 0%, #d9f99d 64%, #4ade80 65%, #22c55e 100%);
  border: 2.5px solid #ffffff;
  box-shadow: 0 8px 18px rgba(16, 120, 80, 0.18), inset 0 -6px 10px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.hero-subtitle {
  font-size: 12px;
  font-weight: 700;
  color: #2b5b6c;
  margin-top: 2px;
}

/* Mode Selector */
.mode-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.mode-card {
  width: 100%;
  text-align: left;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  border: 2px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  transition: all 0.16s ease;
  box-shadow: 0 3px 8px rgba(15, 40, 60, 0.06);
}

.mode-card.selected {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  box-shadow: 0 5px 14px rgba(245, 158, 11, 0.25);
  transform: translateY(-1px);
}

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

.mode-name {
  font-size: 14px;
  font-weight: 800;
  color: #1e293b;
}

.mode-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: #10b981;
  color: #ffffff;
}

.mode-tag.fast-tag {
  background: #f97316;
}

.mode-desc {
  font-size: 11.5px;
  color: #475569;
  font-weight: 500;
}

/* Rules Card */
.rules-card {
  background: rgba(255, 255, 255, 0.88);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border: 1.5px solid #d1fae5;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  z-index: 1;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11.5px;
  line-height: 1.38;
  color: #334155;
}

.rule-icon {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

.start-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.best-record-bar {
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: #0f766e;
  background: rgba(204, 251, 241, 0.72);
  border-radius: 10px;
  padding: 6px 10px;
  border: 1px solid #99f6e4;
}

.btn-primary-cta {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 13px 18px;
  background: linear-gradient(180deg, #fb923c 0%, #ea580c 100%);
  color: #ffffff;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 0 #c2410c, 0 10px 20px rgba(234, 88, 12, 0.35);
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-primary-cta:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #c2410c, 0 5px 10px rgba(234, 88, 12, 0.3);
}

/* ==================== GAMEPLAY SCREEN ==================== */
.screen-game {
  background: linear-gradient(180deg, #e7f6ee 0%, #dcefe6 100%);
}

/* Top Compact HUD */
.game-hud {
  flex-shrink: 0;
  padding: 6px 8px 5px;
  background: #ffffff;
  border-bottom: 1.5px solid #cde4d8;
  box-shadow: 0 2px 6px rgba(15, 50, 40, 0.06);
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 10;
}

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

.hud-pill {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.round-pill {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.hearts-pill {
  background: #ffe4e6;
  color: #be123c;
  border: 1px solid #fecdd3;
  letter-spacing: 1px;
  font-size: 11px;
}

.cap-pill {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.cap-pill.full {
  background: #fef3c7;
  color: #b45309;
  border-color: #fde68a;
}

.gold-pill {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border: 1px solid #f59e0b;
  min-width: 58px;
  justify-content: center;
}

/* Synergy Pills Bar */
.synergy-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.syn-pill {
  padding: 3px 4px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.syn-pill.tier-1 {
  background: linear-gradient(135deg, #fef9c3 0%, #fde047 100%);
  border-color: #eab308;
  color: #713f12;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.35);
}

.syn-pill.tier-2 {
  background: linear-gradient(135deg, #ffedd5 0%, #fb923c 55%, #f59e0b 100%);
  border-color: #ea580c;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 2px 10px rgba(234, 88, 12, 0.45);
}

/* ==================== Arena Section ==================== */
.arena-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 5px 8px 4px;
  gap: 4px;
}

.opponent-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 10px;
  border-radius: 9px;
  background: linear-gradient(90deg, #fff1f2 0%, #ffe4e6 100%);
  border: 1px solid #fecdd3;
  font-size: 11.5px;
}

.opponent-banner.boss-banner {
  background: linear-gradient(90deg, #fef3c7 0%, #fed7aa 50%, #fecaca 100%);
  border-color: #f97316;
}

.opp-badge {
  background: #e11d48;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 6px;
}

.boss-banner .opp-badge {
  background: linear-gradient(90deg, #d97706, #dc2626);
}

.opp-name {
  font-weight: 800;
  color: #881337;
  margin-left: 6px;
  margin-right: auto;
}

.opp-hint {
  font-size: 10.5px;
  color: #9f1239;
  opacity: 0.85;
  font-weight: 600;
}

.arena-canvas-box {
  flex: 1;
  min-height: 185px;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 2.5px solid #ffffff;
  box-shadow: 0 6px 16px rgba(15, 65, 50, 0.16);
  background: #3aa76d;
}

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

/* Overlays inside Arena */
.arena-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(15, 23, 42, 0.88);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 15;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

.arena-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.starup-banner {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.7);
  background: linear-gradient(135deg, #fef08a 0%, #f59e0b 55%, #ea580c 100%);
  color: #ffffff;
  border: 2.5px solid #ffffff;
  border-radius: 16px;
  padding: 8px 18px;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(120, 40, 0, 0.45);
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.65);
  pointer-events: none;
  opacity: 0;
  transition: all 0.28s cubic-bezier(0.22, 1.3, 0.36, 1);
  z-index: 16;
  white-space: nowrap;
}

.starup-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.round-result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 25, 35, 0.56);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 18;
  padding: 16px;
}

.round-result-overlay.show {
  display: flex;
}

.round-result-card {
  width: 90%;
  max-width: 280px;
  background: #ffffff;
  border-radius: 18px;
  padding: 16px 16px 14px;
  text-align: center;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.35);
  border: 3px solid #fbbf24;
  animation: popIn 0.28s cubic-bezier(0.2, 1.35, 0.4, 1);
}

.round-result-card.defeat {
  border-color: #fb7185;
}

.rr-title {
  font-size: 20px;
  font-weight: 900;
  color: #b45309;
  margin-bottom: 5px;
}

.round-result-card.defeat .rr-title {
  color: #e11d48;
}

.rr-sub {
  font-size: 12.5px;
  color: #475569;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 12px;
}

.rr-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #10b981, #059669);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 0 #047857;
}

.rr-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #047857;
}

/* Quick Inspect Strip */
.inspect-strip {
  flex-shrink: 0;
  min-height: 40px;
  background: #ffffff;
  border-radius: 11px;
  border: 1.5px solid #d1e7dc;
  padding: 5px 9px;
  display: flex;
  align-items: center;
}

.inspect-placeholder {
  width: 100%;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: #5b7885;
}

.inspect-details {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.inspect-left {
  min-width: 0;
  flex: 1;
}

.inspect-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  color: #1e293b;
}

.inspect-stars {
  color: #d97706;
  font-size: 12px;
}

.inspect-traits {
  font-size: 10.5px;
  color: #0f766e;
  background: #ccfbf1;
  padding: 0 5px;
  border-radius: 5px;
}

.inspect-stats {
  font-size: 10.5px;
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.inspect-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-sell {
  border: none;
  border-radius: 8px;
  padding: 5px 9px;
  background: linear-gradient(180deg, #f59e0b, #d97706);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 0 #b45309;
}

.btn-sell:active {
  transform: translateY(1px);
}

.btn-close-ins {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: #e2e8f0;
  color: #475569;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

/* ==================== Battle Phase Control Bar ==================== */
.battle-control-bar {
  flex-shrink: 0;
  background: #ffffff;
  border-top: 2px solid #cbd5e1;
  padding: 10px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 -4px 12px rgba(15, 30, 45, 0.08);
}

.battle-hp-summary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.b-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.b-enemy {
  text-align: right;
}

.b-label {
  font-size: 11.5px;
  font-weight: 800;
  color: #334155;
}

.b-bar-track {
  height: 9px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.b-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.2s ease;
}

.b-bar-fill.ally {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.b-bar-fill.enemy {
  background: linear-gradient(90deg, #fb7185, #e11d48);
  margin-left: auto;
}

.b-vs {
  font-size: 12px;
  font-weight: 900;
  color: #f97316;
  background: #fff7ed;
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid #fed7aa;
}

.battle-ticker-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.battle-ticker {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
  background: #f1f5f9;
  padding: 7px 10px;
  border-radius: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-speed {
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  padding: 7px 12px;
  background: linear-gradient(180deg, #38bdf8, #0284c7);
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #0369a1;
}

.btn-speed.fast {
  background: linear-gradient(180deg, #fb923c, #ea580c);
  box-shadow: 0 3px 0 #c2410c;
}

.btn-speed:active {
  transform: translateY(2px);
}

/* ==================== Prep Dock (Bench + Catch Shop) ==================== */
.prep-dock {
  flex-shrink: 0;
  background: #ffffff;
  border-top: 2px solid #cbe4d6;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 -4px 12px rgba(15, 55, 45, 0.08);
}

/* Bench Row */
.bench-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bench-label {
  width: 28px;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  color: #475569;
  text-align: center;
  line-height: 1.2;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 6px 2px;
}

.bench-slots {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.bench-slot {
  height: 54px;
  border-radius: 11px;
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.14s ease;
  overflow: hidden;
}

.bench-slot.occupied {
  border-style: solid;
  border-color: #94a3b8;
  background: linear-gradient(180deg, #ffffff 0%, #f1f5f9 100%);
}

.bench-slot.star-2 {
  border-color: #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #fef3c7 100%);
}

.bench-slot.star-3 {
  border-color: #ea580c;
  background: linear-gradient(180deg, #fff7ed 0%, #fed7aa 100%);
  box-shadow: 0 0 10px rgba(249, 115, 22, 0.35);
}

.bench-slot.selected {
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2.5px rgba(14, 165, 233, 0.45);
  transform: translateY(-2px);
}

.bench-slot.target-hint {
  border-color: #10b981;
  background: #ecfdf5;
}

.bench-slot-canvas {
  width: 34px;
  height: 34px;
  display: block;
}

.bench-slot-name {
  font-size: 9.5px;
  font-weight: 800;
  color: #1e293b;
  line-height: 1;
  margin-top: 1px;
}

.bench-slot-star {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9px;
  font-weight: 900;
  color: #d97706;
  text-shadow: 0 1px 0 #ffffff;
}

.bench-slot-empty {
  font-size: 10px;
  color: #94a3b8;
  font-weight: 700;
}

/* Shop Section */
.shop-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.shop-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.shop-card {
  position: relative;
  border-radius: 12px;
  border: 2px solid #cbd5e1;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  padding: 5px 4px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s;
  min-height: 92px;
  justify-content: space-between;
}

.shop-card.cost-2 {
  border-color: #60a5fa;
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
}

.shop-card.cost-3 {
  border-color: #c084fc;
  background: linear-gradient(180deg, #faf5ff 0%, #ffffff 100%);
}

.shop-card.can-upgrade {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45), 0 4px 10px rgba(245, 158, 11, 0.25);
  animation: pulseGold 1.4s infinite;
}

.shop-card:active:not(.sold):not(.unaffordable) {
  transform: scale(0.95);
}

.shop-card.sold {
  opacity: 0.38;
  background: #f1f5f9;
  border-style: dashed;
  border-color: #cbd5e1;
  cursor: default;
  animation: none;
  box-shadow: none;
}

.shop-card.unaffordable:not(.sold) {
  filter: grayscale(0.35);
  opacity: 0.72;
}

.shop-badge {
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.shop-badge.upgrade {
  background: linear-gradient(90deg, #f59e0b, #ea580c);
  color: #ffffff;
}

.shop-badge.pair {
  background: #0ea5e9;
  color: #ffffff;
}

.shop-pet-canvas {
  width: 42px;
  height: 42px;
  display: block;
  margin-top: 2px;
}

.shop-pet-name {
  font-size: 11px;
  font-weight: 900;
  color: #1e293b;
  line-height: 1.1;
}

.shop-pet-meta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 800;
  padding: 0 2px;
}

.shop-traits {
  letter-spacing: -1px;
}

.shop-cost {
  color: #b45309;
  background: #fef3c7;
  padding: 1px 5px;
  border-radius: 6px;
}

.shop-sold-text {
  margin: auto;
  font-size: 11px;
  font-weight: 800;
  color: #64748b;
}

/* Shop Action Buttons */
.shop-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1.35fr;
  gap: 6px;
}

.ctrl-btn {
  border: none;
  border-radius: 12px;
  padding: 7px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  cursor: pointer;
  color: #ffffff;
  transition: transform 0.1s, opacity 0.15s;
}

.ctrl-btn:active:not(:disabled) {
  transform: translateY(2px);
}

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

.ctrl-main {
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
}

.ctrl-sub {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.92;
}

.ctrl-refresh {
  background: linear-gradient(180deg, #10b981, #059669);
  box-shadow: 0 3px 0 #047857;
}

.ctrl-cap {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  box-shadow: 0 3px 0 #1d4ed8;
}

.ctrl-fight {
  background: linear-gradient(180deg, #fb923c, #ea580c);
  box-shadow: 0 3px 0 #c2410c;
}

/* ==================== END SCREEN ==================== */
.screen-end {
  background: linear-gradient(180deg, #fef9c3 0%, #ecfdf5 48%, #e0f2fe 100%);
}

.end-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.end-header-card {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border: 2.5px solid #f59e0b;
  border-radius: 18px;
  padding: 14px 14px 13px;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.22);
  position: relative;
}

.end-header-card.defeat {
  background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
  border-color: #fb7185;
  box-shadow: 0 8px 20px rgba(244, 63, 94, 0.18);
}

.end-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.end-report-tag {
  font-size: 11.5px;
  font-weight: 800;
  color: #92400e;
  background: rgba(255, 255, 255, 0.75);
  padding: 3px 9px;
  border-radius: 999px;
}

.end-rank-stamp {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #dc2626);
  color: #ffffff;
  font-size: 24px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid #ffffff;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.35);
  transform: rotate(-8deg);
}

.end-title {
  font-size: 22px;
  font-weight: 900;
  color: #78350f;
  margin-bottom: 3px;
}

.end-header-card.defeat .end-title {
  color: #9f1239;
}

.end-subtitle {
  font-size: 12px;
  font-weight: 600;
  color: #57534e;
}

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

.end-stat-box {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 12px;
  padding: 9px 10px;
  border: 1.5px solid #e2e8f0;
  text-align: center;
  box-shadow: 0 3px 8px rgba(15, 40, 60, 0.05);
}

.es-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 3px;
}

.es-val {
  font-size: 14px;
  font-weight: 900;
  color: #0f172a;
}

.end-section {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  padding: 10px 12px;
  border: 1.5px solid #d1fae5;
}

.end-section-title {
  font-size: 12.5px;
  font-weight: 900;
  color: #0f766e;
  margin-bottom: 7px;
}

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

.end-syn-chip {
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  background: linear-gradient(135deg, #fef08a, #fbbf24);
  color: #713f12;
  border: 1px solid #f59e0b;
}

.end-syn-chip.none {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.end-team-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.end-pet-card {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 12px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.end-pet-card.star-2 {
  border-color: #f59e0b;
  background: #fffbeb;
}

.end-pet-card.star-3 {
  border-color: #ea580c;
  background: linear-gradient(180deg, #fff7ed, #ffedd5);
}

.end-pet-name {
  font-size: 11px;
  font-weight: 800;
  color: #1e293b;
}

.end-pet-stars {
  font-size: 10.5px;
  font-weight: 900;
  color: #d97706;
}

.end-best-box {
  background: rgba(204, 251, 241, 0.8);
  border: 1.5px solid #5eead4;
  border-radius: 12px;
  padding: 8px 10px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 800;
  color: #115e59;
}

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

.btn-secondary-link {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  padding: 11px 16px;
  border-radius: 14px;
  background: #ffffff;
  color: #1e293b;
  font-size: 14px;
  font-weight: 800;
  border: 2px solid #cbd5e1;
}

/* ==================== GUIDE MODAL ==================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 40;
}

.modal-sheet {
  width: 100%;
  max-height: 86%;
  background: #ffffff;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  animation: popIn 0.22s ease;
}

.modal-header {
  padding: 12px 14px;
  background: var(--topbar-bg);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 900;
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.modal-body {
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-section-title {
  font-size: 13px;
  font-weight: 900;
  color: #0f766e;
  margin-bottom: 6px;
}

.guide-syn-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-syn-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 11.5px;
  line-height: 1.4;
}

.guide-syn-head {
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 2px;
}

.guide-pet-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.guide-pet-card {
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.guide-pet-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.guide-pet-info {
  font-size: 10.5px;
  line-height: 1.3;
  color: #475569;
}

.guide-pet-info strong {
  font-size: 12px;
  color: #0f172a;
}

/* ==================== Animations ==================== */
@keyframes pulseGold {
  0%, 100% { box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45), 0 4px 10px rgba(245, 158, 11, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.7), 0 6px 15px rgba(245, 158, 11, 0.45); }
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.86); }
  100% { opacity: 1; transform: scale(1); }
}

/* Compact adjustments for shorter mobile viewports (e.g. iPhone SE 667px) */
@media (max-height: 700px) {
  .wx-topbar { height: 40px; }
  .game-hud { padding: 4px 6px; gap: 3px; }
  .hud-pill { font-size: 11px; padding: 2px 6px; }
  .bench-slot { height: 46px; }
  .bench-slot-canvas { width: 28px; height: 28px; }
  .shop-card { min-height: 80px; padding: 4px 3px; }
  .shop-pet-canvas { width: 34px; height: 34px; }
  .ctrl-btn { padding: 5px 4px; }
  .hero-mascot-stage { height: 92px; }
  .hero-title { font-size: 23px; }
}
