* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg1: #1b2a4a;
  --bg2: #0e1630;
  --panel: #ffffff;
  --ink: #1c2536;
  --muted: #6b7689;
  --accent: #ffcb05;
  --accent2: #3b6fd6;
  --hp-good: #46c46a;
  --hp-mid: #f2c14e;
  --hp-low: #e3534a;
  --shadow: 0 8px 24px rgba(0,0,0,.28);
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 700px at 50% -10%, #2a3f6e 0%, var(--bg1) 40%, var(--bg2) 100%);
  color: var(--ink);
  min-height: 100vh;
  padding: 18px 14px 40px;
}

.wrap { max-width: 1080px; margin: 0 auto; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.title {
  display: flex; align-items: center; gap: 12px;
  color: #fff;
}
.title .logo {
  width: 42px; height: 42px; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff 0 30%, #e3534a 31% 100%);
  border: 3px solid #fff; box-shadow: var(--shadow);
  position: relative;
}
.title .logo::after {
  content: ""; position: absolute; left: -3px; right: -3px; top: 50%;
  height: 3px; background: #fff; transform: translateY(-50%);
}
.title h1 { font-size: 22px; letter-spacing: .5px; }
.title small { display:block; font-weight: 400; font-size: 12px; color: #b9c6e6; }

button.btn {
  cursor: pointer; border: none; border-radius: 10px;
  padding: 10px 16px; font-size: 14px; font-weight: 700;
  background: var(--accent); color: #3a2d00; transition: transform .08s, filter .15s;
  box-shadow: 0 4px 0 #c79a00;
}
button.btn:hover { filter: brightness(1.05); }
button.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 #c79a00; }
button.btn.ghost { background: #2b3c63; color: #fff; box-shadow: 0 4px 0 #16213c; }
button.btn:disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.4); box-shadow: none; }

/* Battle field */
.field {
  display: grid; grid-template-columns: 1fr 64px 1fr; gap: 10px; align-items: stretch;
  margin-bottom: 14px;
}
.side { display: flex; flex-direction: column; gap: 10px; }
.side.you { align-items: flex-start; }
.side.ai  { align-items: flex-end; }

.side-label {
  color:#fff; font-weight:700; font-size:13px; letter-spacing:1px;
  display:flex; align-items:center; gap:8px; opacity:.92;
}
.side-label .tag { background:#0006; padding:2px 8px; border-radius:20px; font-size:11px; }

.vs {
  display:flex; align-items:center; justify-content:center; color:#fff;
  font-weight:800; font-style:italic; font-size:22px; opacity:.8;
}

/* Active card */
.card {
  width: 240px; background: var(--panel); border-radius: 16px; overflow: hidden;
  box-shadow: var(--shadow); border: 3px solid #fff; position: relative;
}
.card .head {
  padding: 10px 12px; color:#fff; display:flex; justify-content:space-between; align-items:center;
}
.card .head .nm { font-weight: 800; font-size: 16px; text-shadow: 0 1px 2px #0006; }
.card .head .no { font-size: 12px; opacity:.85; font-weight:700; display:flex; align-items:center; gap:6px; }
.card .head .no .first {
  background:#ffd54a; color:#5a3d00; font-size:10px; padding:1px 6px; border-radius:10px;
  font-weight:800; letter-spacing:.5px; box-shadow:0 0 8px #ffd54a;
}
.card .spd-row { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); font-weight:700; margin-top:6px; }
.card .spd-row .fast { color:#e8a200; }
.card .stat-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 4px;
  margin-top: 6px; font-size: 11px; color: var(--muted); font-weight: 700;
}
.card .stat-row span {
  display: flex; align-items: center; justify-content: space-between;
  background: #f0f3fa; border-radius: 5px; padding: 2px 5px;
}
.card .stat-row b { color: var(--ink); font-size: 12px; }
.card .art {
  background: linear-gradient(180deg,#f3f5fb,#dfe5f2);
  height: 132px; display:flex; align-items:center; justify-content:center; position:relative;
}
.card .art img { width: 118px; height: 118px; object-fit: contain; image-rendering: pixelated; }
.card .art .fallback {
  display:none; width:96px; height:96px; border-radius:50%;
  background: radial-gradient(circle at 50% 38%, #fff 0 30%, #e3534a 31% 100%);
  border:4px solid #fff; align-items:center; justify-content:center;
  color:#fff; font-weight:800; font-size:18px;
}
.card .types { display:flex; gap:6px; padding: 8px 12px 4px; flex-wrap:wrap; }
.type-chip {
  font-size: 11px; font-weight:700; color:#fff; padding:3px 9px; border-radius:20px;
}
.card .body { padding: 4px 12px 12px; }
.hp-row { display:flex; align-items:center; gap:8px; font-size:12px; color:var(--muted); font-weight:700; }
.hp-bar { flex:1; height: 12px; background:#e6e9f0; border-radius:8px; overflow:hidden; }
.hp-fill { height:100%; background: var(--hp-good); transition: width .45s ease; }
.energy { display:flex; gap:5px; margin-top:8px; align-items:center; }
.energy .lbl { font-size:11px; color:var(--muted); font-weight:700; }
.energy .dot { width:13px; height:13px; border-radius:50%; background:#d7dce6; border:1px solid #c2c8d4; }
.energy .dot.on { background: radial-gradient(circle at 30% 30%, #ffe27a, #f0a800); border-color:#c98a00; box-shadow:0 0 6px #ffcf3a; }

.card .status-badge {
  display:inline-block; margin-top:6px; padding:2px 10px; border-radius:20px;
  color:#fff; font-size:11px; font-weight:800; letter-spacing:.5px;
  box-shadow:0 1px 4px #0003;
}
.mini .mini-status {
  display:inline-block; padding:0 5px; border-radius:8px; color:#fff; font-size:10px; font-weight:700;
}
.eff.status-hint { background:#fff4e0; color:#b9740a; border:1px solid #f0c98a; font-weight:700; }

/* Bench */
.bench { display:flex; gap:8px; flex-wrap:wrap; }
.mini {
  width: 92px; background: var(--panel); border-radius: 10px; overflow:hidden;
  box-shadow: 0 4px 10px rgba(0,0,0,.18); border:2px solid #fff; cursor: default;
  transition: transform .1s;
}
.mini.switchable { cursor: pointer; }
.mini.switchable:hover { transform: translateY(-3px); border-color: var(--accent); }
.mini .mh { padding:5px 7px; color:#fff; font-size:11px; font-weight:700; display:flex; justify-content:space-between; }
.mini .ma { height:54px; background:#eef1f8; display:flex; align-items:center; justify-content:center; }
.mini .ma img { width:48px; height:48px; object-fit:contain; image-rendering:pixelated; }
.mini .ma .fb { display:none; width:38px; height:38px; border-radius:50%; background: radial-gradient(circle at 50% 38%, #fff 0 30%, #e3534a 31% 100%); border:2px solid #fff; }
.mini .mb { padding:4px 7px 6px; }
.mini .mhp { height:7px; background:#e6e9f0; border-radius:5px; overflow:hidden; }
.mini .mhp i { display:block; height:100%; background:var(--hp-good); }
.mini .mname { font-size:10px; color:var(--ink); font-weight:700; margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* 12 格阵型：横向小卡片，紧凑高度 */
.formation { display:grid; grid-template-columns:repeat(4, 1fr); gap:5px; margin-top:8px; }
.fc {
  position:relative; border:2px solid #fff; border-radius:7px; overflow:hidden;
  background:var(--panel); box-shadow:0 2px 6px rgba(0,0,0,.15);
  display:flex; align-items:center; height:32px;
}
.fc .fc-art {
  width:42%; height:100%; flex-shrink:0; display:flex; align-items:center; justify-content:center; position:relative;
}
.fc .fc-art img { width:86%; height:86%; object-fit:contain; image-rendering:pixelated; }
.fc .fc-art .fb { display:none; width:22px; height:22px; border-radius:50%; background: radial-gradient(circle at 50% 38%, #fff 0 30%, #e3534a 31% 100%); border:2px solid #fff; }
.fc .fc-hp { position:absolute; bottom:3px; left:46%; right:4px; height:4px; background:#e6e9f0; border-radius:4px; overflow:hidden; }
.fc .fc-hp i { display:block; height:100%; }
.fc.active { border-color:var(--accent); box-shadow:0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,.2); }
.fc.active .fc-art { background:linear-gradient(180deg,#fff,#ffe9c2); }
.fc.switchable { cursor:pointer; }
.fc.switchable:hover { transform:translateY(-2px); border-color:var(--accent); }
.fc.dead { filter:grayscale(1) brightness(.7); opacity:.55; }
.fc.dead .fc-art { background:#cfd5e2; }
.fc.deck { background:repeating-linear-gradient(45deg,#3a4a6b,#3a4a6b 6px,#46597f 6px,#46597f 12px); border-color:#5a6b8f; }
.fc.deck span { position:absolute; inset:0; display:flex; align-items:center; justify-content:center; color:#cdd7ee; font-weight:800; font-size:14px; }
.fc-tag {
  position:absolute; top:1px; left:1px; background:var(--accent); color:#fff;
  font-size:8px; font-weight:800; padding:0 4px; border-radius:5px; z-index:2; line-height:12px;
}
.fc.dead .fc-tag { background:#888; }
.fc-st {
  position:absolute; top:1px; right:1px; color:#fff; font-size:7px; font-weight:800;
  padding:0 3px; border-radius:5px; z-index:2; line-height:12px;
}

.deck-pile {
  display:flex; align-items:center; gap:6px; color:#cdd7ee; font-size:12px; font-weight:700;
}
.deck-pile .pile {
  width:34px; height:46px; border-radius:6px; background:
    repeating-linear-gradient(45deg,#2b3c63 0 6px,#243457 6px 12px);
  border:2px solid #fff; box-shadow:0 3px 6px #0004;
}

/* Hover preview */
.pk-preview {
  position: fixed; z-index: 9999; width: 220px; background: var(--panel);
  border-radius: 14px; overflow: hidden; box-shadow: 0 12px 36px rgba(0,0,0,.35);
  border: 3px solid #fff; pointer-events: none; opacity: 0; visibility: hidden;
  transform: translateY(6px); transition: opacity .15s, transform .15s, visibility .15s;
}
.pk-preview.show { opacity: 1; visibility: visible; transform: translateY(0); }
.pk-preview .pv-art {
  height: 126px; display: flex; align-items: center; justify-content: center; position: relative;
}
.pk-preview .pv-art img { width: 112px; height: 112px; object-fit: contain; image-rendering: pixelated; }
.pk-preview .pv-head {
  padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; color: #fff;
}
.pk-preview .pv-nm { font-weight: 800; font-size: 15px; text-shadow: 0 1px 2px #0006; }
.pk-preview .pv-no { font-size: 12px; opacity: .85; font-weight: 700; }
.pk-preview .pv-types { display: flex; gap: 6px; padding: 6px 10px 2px; flex-wrap: wrap; }
.pk-preview .pv-body { padding: 4px 10px 10px; }
.pk-preview .pv-hp { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); font-weight: 700; }
.pk-preview .pv-hp .hp-bar { flex: 1; height: 10px; }
.pk-preview .pv-dead { font-size: 12px; font-weight: 800; color: var(--hp-low); margin-top: 4px; }
.pk-preview .pv-body .status-badge { margin-top: 4px; }
.pk-preview .pv-body .status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 1px 4px #0003;
}
.pk-preview .pv-stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 1fr; gap: 4px; margin-top: 8px;
  text-align: center;
}
.pk-preview .pv-stats div { background: #f0f3fa; border-radius: 6px; padding: 4px 2px; }
.pk-preview .pv-stats span { display: block; font-size: 10px; color: var(--muted); font-weight: 700; }
.pk-preview .pv-stats b { font-size: 13px; color: var(--ink); }
.pk-preview .pv-energy { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pk-preview .pv-energy .lbl { font-size: 11px; color: var(--muted); font-weight: 700; }

/* Evolution chain strip inside previews */
.pk-preview .pv-evo {
  display: flex; align-items: center; flex-wrap: wrap; gap: 5px;
  margin-top: 9px; padding-top: 9px; border-top: 1px dashed #d7dded;
}
.pk-preview .evo-node {
  display: inline-flex; flex-direction: column; align-items: center;
  background: #f4f6fc; border: 1px solid #e4e9f5; border-radius: 8px;
  padding: 3px 5px 2px; min-width: 44px;
}
.pk-preview .evo-node img {
  width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated;
}
.pk-preview .evo-node .evo-lab { font-size: 9px; color: var(--muted); font-weight: 700; line-height: 1.1; }
.pk-preview .evo-node b { font-size: 10px; color: var(--ink); line-height: 1.15; }
.pk-preview .evo-node.cur { background: #fff4d6; border-color: #f3d27a; }
.pk-preview .evo-arrow { color: #9aa3b8; font-weight: 800; font-size: 13px; }
.pk-preview .evo-tag { font-size: 10px; color: var(--muted); font-weight: 700; padding: 2px 6px; }

/* Action panel */
.actions {
  background: var(--panel); border-radius: 16px; padding: 14px;
  box-shadow: var(--shadow); display:grid; grid-template-columns: 1fr 280px; gap: 14px;
}
.move-area .ttl, .log-area .ttl { font-size:13px; font-weight:800; color:var(--muted); margin-bottom:8px; letter-spacing:1px; }
.moves { display:flex; gap:10px; flex-wrap:wrap; }
.move {
  flex:1; min-width: 200px; text-align:left; border:2px solid #e3e8f2; border-radius:12px;
  padding:10px 12px; background:#f7f9fd; cursor:pointer; transition: .12s;
}
.move:hover:not(:disabled) { border-color: var(--accent2); background:#eef3ff; }
.move:disabled { opacity:.5; cursor:not-allowed; }
.move .mn { font-weight:800; font-size:14px; display:flex; align-items:center; gap:8px; }
.move .md { font-size:12px; color:var(--muted); margin-top:4px; display:flex; gap:10px; }
.move .eff { font-size:11px; font-weight:800; margin-top:4px; }
.move .eff.sup { color:#d23b2e; }
.move .eff.weak { color:#2f8f4e; }
.move .cost { margin-left:auto; font-size:11px; color:#9aa3b5; }
.move.mega {
  border-color:#f0c33b; background:linear-gradient(180deg,#fff8e3,#ffeec2);
  box-shadow:0 0 0 1px #f3d27a inset;
}
.move.mega:hover:not(:disabled) { border-color:#e3a008; background:#fff0c4; }
.move.mega .mn { color:#8a5a00; }

/* Mega Evolution chip + floating text + flash */
.type-chip.mega { background:#f0c33b !important; color:#5b3d00; font-weight:800; }
.dmg-txt.mega { color:#ffd23b; font-size:18px; font-weight:900; text-shadow:0 2px 6px #0008; }
.mega-flash { animation: megaFlash .85s ease; }
@keyframes megaFlash {
  0% { box-shadow:0 0 0 0 #ffe27a; filter:brightness(1); }
  35% { box-shadow:0 0 26px 10px #ffe27a; filter:brightness(1.6) saturate(1.4); }
  100% { box-shadow:0 0 0 0 #ffe27a; filter:brightness(1); }
}

/* ---------- Dynamax (极巨化) ---------- */
.move.dynamax {
  border-color:#a06bff; background:linear-gradient(180deg,#f3ebff,#e7d6ff);
  box-shadow:0 0 0 1px #c4a3ff inset;
}
.move.dynamax:hover:not(:disabled) { border-color:#7c3aed; background:#ecdcff; }
.move.dynamax .mn { color:#5b2da8; }
.move.dynamax.is-active { opacity:.85; cursor:default; }

/* 超级有效招式：金色描边，引导玩家优先点击 */
.move.eff-sup { border-color:#ffcf4d; box-shadow:0 0 0 2px #ffcf4d55; }
.move.eff-sup:hover:not(:disabled) { background:#fff6dc; border-color:#f0b400; }
/* 大招就绪：脉冲高亮 */
.move.ready { border-color:#ffd54d; box-shadow:0 0 12px #ffd54d66; animation: readyPulse 1.1s ease-in-out infinite; }
.move.ready:hover:not(:disabled) { background:#fff3cf; }
@keyframes readyPulse {
  0%,100% { box-shadow:0 0 6px #ffd54d44; }
  50% { box-shadow:0 0 16px #ffd54daa; }
}
.type-chip.dynamax { background:#8b5cf6 !important; color:#fff; font-weight:800; }
.dmg-txt.dynamax { color:#b07bff; font-size:18px; font-weight:900; text-shadow:0 2px 6px #0008; }
.dynamax-flash { animation: dynamaxFlash .85s ease; }
@keyframes dynamaxFlash {
  0% { box-shadow:0 0 0 0 #c9a3ff; filter:brightness(1); transform:scale(1); }
  35% { box-shadow:0 0 30px 12px #b07bff; filter:brightness(1.5) saturate(1.5); transform:scale(1.05); }
  100% { box-shadow:0 0 0 0 #c9a3ff; filter:brightness(1); transform:scale(1); }
}
/* 极巨化中：卡面持续微微放大，并标注徽标 */
.card.dynamax { box-shadow:0 0 0 2px #8b5cf6 inset, 0 8px 22px #8b5cf644; }
.card.dynamax .art img { transform:scale(1.12); transition:transform .3s ease; }
.dmax-tag {
  background:#8b5cf6; color:#fff; font-size:10px; padding:1px 6px;
  border-radius:8px; margin-left:6px; font-weight:800; vertical-align:middle;
}

/* ===== 携带物（道具）===== */
.item-tag {
  background:#1f8a4c; color:#fff; font-size:10px; padding:1px 6px;
  border-radius:8px; margin-left:6px; font-weight:800; vertical-align:middle;
  white-space:nowrap;
}
.pv-item {
  display:flex; align-items:center; gap:6px; font-size:12px; font-weight:700;
  color:#1f8a4c; padding:3px 8px; margin:6px 0 2px; background:#eafaf0; border-radius:8px;
}
.pv-item-ic { font-size:14px; }
.pv-item small { color:#6b7280; font-weight:500; margin-left:4px; }

/* ===== 能力等级（强化/削弱）===== */
.buffs { display:flex; flex-wrap:wrap; gap:4px; margin:6px 0 2px; }
.buff {
  font-size:11px; font-weight:800; padding:1px 6px; border-radius:7px; line-height:1.5;
}
.buff.up { background:#d7f5db; color:#1a7f37; }
.buff.down { background:#fde0e0; color:#c0392b; }

/* ===== 天气 / 场地 ===== */
.weather-bar {
  grid-column:1 / -1; min-height:0; overflow:hidden;
  background:transparent; border-radius:10px; padding:0 12px;
  display:flex; align-items:center; gap:10px; font-weight:800; color:#cdd7ee;
  transition:background .3s, min-height .3s, padding .3s;
}
.weather-bar:not(:empty) { min-height:34px; padding:6px 12px; background:#0f1830; }
.weather-bar .wb-ic { font-size:18px; }
.weather-bar .wb-nm { font-size:14px; }
.weather-bar .wb-turn { font-size:12px; color:#9fb0d6; margin-left:auto; }
.weather-bar.sunny { background:linear-gradient(90deg,#7a3b00,#c9760f); color:#fff; }
.weather-bar.rain { background:linear-gradient(90deg,#0b3a6b,#1f6fb2); color:#fff; }
.weather-bar.sandstorm { background:linear-gradient(90deg,#6b5320,#b08a3e); color:#fff; }
.weather-bar.hail { background:linear-gradient(90deg,#1c4a5e,#3f9fc4); color:#fff; }
.field.w-sunny { box-shadow:0 0 0 1px #c9760f33, 0 0 40px #e08a1a22 inset; }
.field.w-rain { box-shadow:0 0 0 1px #1f6fb233, 0 0 40px #2b8fd322 inset; }
.field.w-sandstorm { box-shadow:0 0 0 1px #b08a3e33, 0 0 40px #b08a3e22 inset; }
.field.w-hail { box-shadow:0 0 0 1px #3f9fc433, 0 0 40px #3f9fc422 inset; }

/* ===== 技能冷却 ===== */
.move.on-cd { opacity:.55; filter:grayscale(.4); }
.eff.weather { background:#fff3d6; color:#a06a00; border:1px solid #f0c869; }
.eff.cd { background:#e6eefc; color:#3b6fd4; border:1px solid #aac4f0; }

.switch-hint { font-size:12px; color:var(--muted); margin-top:10px; }
.switch-hint b { color:var(--accent2); }

.log-area { background:#0f1830; border-radius:12px; padding:10px 12px; color:#cdd7ee; }
.log-area .ttl { color:#9fb0d6; }
.log { font-size:12px; line-height:1.7; max-height: 220px; overflow:auto; }
.log .e { padding:3px 0; border-bottom:1px dashed #ffffff14; display:flex; gap:7px; align-items:flex-start; }
.log .e .lg-ic { flex:0 0 auto; width:14px; text-align:center; opacity:.85; }
.log .e .lg-tx { flex:1 1 auto; }
.log .e.you { color:#ffe08a; }
.log .e.ai { color:#9fd0ff; }
.log .e.sys { color:#b6c2dd; }
.log .e.eff { color:#e0a0ff; }
.log .e.kill { color:#ff8a7a; font-weight:700; }

/* Game over */
.overlay {
  position: fixed; inset:0; background:#0a0f1fcc; display:none;
  align-items:center; justify-content:center; z-index:50; backdrop-filter: blur(3px);
}
.overlay.show { display:flex; }
.over-box {
  background:#fff; border-radius:18px; padding:28px 34px; text-align:center; box-shadow:var(--shadow);
  max-width: 360px;
}
.over-box h2 { font-size:26px; margin-bottom:8px; }
.over-box p { color:var(--muted); margin-bottom:18px; }
.over-box .emoji { font-size:54px; margin-bottom:6px; }
.over-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.foot { color:#9fb0d6; text-align:center; font-size:12px; margin-top:16px; }

/* ===== Setup screen ===== */
.overlay.setup { background:#0a0f1fdd; }
.setup-box {
  position: relative;
  display: flex; flex-direction: column;
  background: #fff; border-radius: 18px; padding: 16px 20px 14px;
  width: min(920px, 94vw); max-height: 96vh; overflow: hidden;
  box-shadow: var(--shadow);
}
.setup-box h2 { font-size: 20px; color: var(--ink); }
.setup-sub { color: var(--muted); font-size: 12px; margin: 2px 0 8px; }
.setup-close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  border: none; border-radius: 8px; background: #eef1f8; color: #6b7689;
  font-size: 15px; cursor: pointer; font-weight: 700;
}
.setup-close:hover { background: #e1e6f0; }

.setup-modes { display: flex; gap: 10px; margin-bottom: 8px; }
.seg {
  flex: 1; padding: 9px; border: 2px solid #e3e8f2; background: #f7f9fd;
  border-radius: 12px; font-size: 13px; font-weight: 800; color: var(--muted);
  cursor: pointer; transition: .12s;
}
.seg.active { border-color: var(--accent2); background: #eef3ff; color: var(--accent2); }

.picker-tools { display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.pk-search {
  flex: 1; min-width: 200px; padding: 7px 10px; border: 2px solid #e3e8f2;
  border-radius: 10px; font-size: 13px; outline: none;
}
.pk-search:focus { border-color: var(--accent2); }
.pk-tools-btns { display: flex; gap: 6px; }
.mini-btn {
  padding: 7px 10px; border: none; border-radius: 10px; font-size: 12px; font-weight: 700;
  background: var(--accent2); color: #fff; cursor: pointer; white-space: nowrap;
}
.mini-btn.ghost { background: #eef1f8; color: var(--muted); }
.mini-btn:hover { filter: brightness(1.05); }

.gen-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.gf {
  border: 2px solid #e3e8f2; border-radius: 20px; padding: 4px 12px; font-size: 12px;
  font-weight: 700; color: var(--muted); background: #f7f9fd; cursor: pointer;
  transition: .12s; white-space: nowrap;
}
.gf.on { border-color: var(--accent2); background: #eef3ff; color: var(--accent2); opacity: 1; }

.type-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tf {
  border: none; border-radius: 20px; padding: 3px 9px; font-size: 10px;
  font-weight: 700; color: #fff; background: #c2c8d4; cursor: pointer; opacity: .7;
}
.tf.on { opacity: 1; outline: 2px solid #fff; box-shadow: 0 0 0 2px #3b6fd6; }

.pk-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px; flex: 1; min-height: 0; overflow: auto; padding: 4px;
  background: #f4f6fb; border-radius: 12px;
}
.pk {
  position: relative; background: #fff; border: 2px solid #e3e8f2; border-radius: 12px;
  padding: 6px 4px 5px; text-align: center; cursor: pointer; transition: .12s; user-select: none;
}
.pk:hover { transform: translateY(-2px); border-color: var(--accent2); }
.pk.sel { border-color: var(--accent2); background: #eef3ff; box-shadow: 0 0 0 2px #3b6fd6 inset; }
.pk-check {
  position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent2); color: #fff; font-size: 13px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow);
}
.pk-art {
  height: 52px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 2px;
}
.pk-art img { width: 46px; height: 46px; object-fit: contain; image-rendering: pixelated; }
.pk-fb {
  display: none; width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #fff 0 30%, #e3534a 31% 100%);
  border: 2px solid #fff; color: #fff; font-weight: 800; font-size: 12px;
  align-items: center; justify-content: center;
}
.pk-name { font-size: 12px; font-weight: 700; color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.pk-types { display: flex; gap: 3px; justify-content: center; margin-top: 2px; flex-wrap: wrap; }
.pk-types .type-chip { font-size: 10px; padding: 2px 7px; }

.pick-foot { font-size: 12px; color: var(--muted); margin-top: 6px; text-align: center; }
.pick-foot b { color: var(--accent2); font-size: 14px; }

.setup-actions { display: flex; justify-content: center; flex-shrink: 0; margin-top: 10px; }

#custom-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#custom-panel.hidden { display: none; }
.hidden { display: none !important; }
.start-btn { font-size: 14px; padding: 10px 28px; }
.start-btn:disabled { background: #c9cfdb; color: #fff; box-shadow: none; cursor: not-allowed; }

/* ===== Battle animations ===== */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.dmg-num {
  position: absolute; transform: translate(-50%, -50%); font-weight: 900; font-size: 30px;
  color: #fff; text-shadow: 0 2px 0 #00000055, 0 0 8px #00000088;
  animation: floatUp 1s ease-out forwards;
}
.dmg-num.sup { color: #ffe14d; text-shadow: 0 2px 0 #b8860b, 0 0 12px #ffd400; }
.dmg-num.weak { color: #c8f0c8; text-shadow: 0 2px 0 #2f6b2f, 0 0 10px #4caf50; }
.dmg-num.crit { color: #ff6a3d; font-size: 40px; text-shadow: 0 2px 0 #7a2200, 0 0 16px #ff7a00; }
.dmg-txt {
  position: absolute; transform: translate(-50%, -50%); font-weight: 800; font-size: 15px;
  color: #fff; text-shadow: 0 1px 3px #0008; animation: floatUp 1.1s ease-out forwards;
  white-space: nowrap;
}
.dmg-txt.weak { color: #c8f0c8; }
.dmg-txt.energy { color: #ffe27a; font-size: 17px; }
.dmg-txt.ko {
  color: #ff5a4d; font-size: 30px; font-weight: 900; letter-spacing: 2px;
  text-shadow: 0 2px 6px #000a; animation: koPop 1.3s ease-out forwards;
}
.dmg-txt.crit-label {
  color: #ffae3d; font-size: 19px; font-weight: 900; letter-spacing: 1px;
  text-shadow: 0 2px 0 #7a3a00, 0 0 10px #ff7a00; animation: critPop 1s ease-out forwards;
}
@keyframes critPop {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.5) rotate(-6deg); }
  25% { opacity: 1; transform: translate(-50%, -60%) scale(1.25) rotate(3deg); }
  70% { opacity: 1; transform: translate(-50%, -90%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -130%) scale(1); }
}
.impact {
  position: absolute; width: 16px; height: 16px; transform: translate(-50%, -50%);
  border-radius: 50%; background: radial-gradient(circle, #fff 0 30%, #ffd400 40%, transparent 70%);
  animation: burst .38s ease-out forwards;
}
.impact.sup { background: radial-gradient(circle, #fff 0 30%, #ffd400 40%, transparent 70%); }
.impact.weak { background: radial-gradient(circle, #fff 0 30%, #4caf50 40%, transparent 70%); }
.impact.crit { background: radial-gradient(circle, #fff 0 20%, #ffd400 35%, #ff7a00 60%, transparent 75%); }
.flash {
  position: absolute; inset: 0; animation: flashfx .32s ease-out forwards;
}
.flash.sup { background: radial-gradient(circle, transparent 40%, #ffd40055 100%); }
.flash.weak { background: radial-gradient(circle, transparent 40%, #4caf5055 100%); }

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(.6); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}
@keyframes koPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.4) rotate(-8deg); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(3deg); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}
@keyframes burst {
  0% { opacity: .9; transform: translate(-50%, -50%) scale(.4); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(3.4); }
}
@keyframes flashfx {
  0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; }
}

/* attacker lunge */
.card.lunge-r { animation: lungeR .26s ease-out; }
.card.lunge-l { animation: lungeL .26s ease-out; }
@keyframes lungeR {
  0% { transform: translateX(0); } 45% { transform: translateX(26px) scale(1.04); } 100% { transform: translateX(0); }
}
@keyframes lungeL {
  0% { transform: translateX(0); } 45% { transform: translateX(-26px) scale(1.04); } 100% { transform: translateX(0); }
}
.card.hit-shake { animation: shake .42s ease-in-out; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-1deg); }
  40% { transform: translateX(6px) rotate(1deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(4px); }
}
.card.energy-gain { animation: glow .7s ease-out; }
@keyframes glow {
  0% { box-shadow: var(--shadow); }
  35% { box-shadow: 0 0 0 3px #ffd40088, 0 0 22px #ffd400cc, var(--shadow); }
  100% { box-shadow: var(--shadow); }
}
.card.slide-in { animation: slideIn .4s ease-out; }
@keyframes slideIn {
  0% { opacity: 0; transform: translateY(-18px) scale(.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.card.faint { animation: faint .7s ease-in forwards; }
@keyframes faint {
  0% { opacity: 1; transform: translateY(0) rotate(0); }
  25% { transform: translateX(-6px) rotate(-3deg); }
  55% { transform: translateX(6px) rotate(3deg); }
  100% { opacity: 0; transform: translateY(22px) scale(.85) rotate(-8deg); filter: grayscale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .card.lunge-r, .card.lunge-l, .card.hit-shake, .card.energy-gain,
  .card.slide-in, .card.faint, .dmg-num, .dmg-txt, .impact, .flash { animation-duration: .01s; }
}

/* ===================== 移动端适配 ===================== */
@media (max-width: 768px) {
  body { padding: 10px 8px 28px; }
  .wrap { max-width: 100%; }

  header.top { gap: 8px; }
  .title h1 { font-size: 18px; }
  .title small { font-size: 11px; }
  .title .logo { width: 34px; height: 34px; }
  header.top .btn { padding: 8px 12px; font-size: 12px; }

  /* 战场纵向堆叠：你在上、电脑在下 */
  .field { grid-template-columns: 1fr; gap: 12px; }
  .vs { display: none; }
  .side, .side.you, .side.ai { align-items: stretch; }

  /* 战斗卡满宽但限制最大宽度，居中更透气 */
  .card { width: 100%; max-width: 460px; margin: 0 auto; }
  .card .art { height: 116px; }
  .card .art img { width: 104px; height: 104px; }

  /* 操作区单列；招式两列排布，更大点按区域 */
  .actions { grid-template-columns: 1fr; gap: 12px; padding: 12px; }
  .move-area .ttl, .log-area .ttl { font-size: 12px; }
  .moves { gap: 8px; }
  .move { min-width: 0; flex: 1 1 calc(50% - 4px); }
  .move .md { flex-wrap: wrap; }

  .foot { font-size: 11px; }

  /* 触摸优化：去掉 300ms 延迟、禁用长按菜单与文本选中 */
  button, .btn, .move, .fc, .pk, .seg, .mini-btn, .pk-search, .gf, .tf, .type-chip {
    touch-action: manipulation;
  }
  .fc, .pk { -webkit-touch-callout: none; user-select: none; }
}

@media (max-width: 480px) {
  body { padding: 8px 6px 24px; }
  .title small { display: none; }
  header.top .btn { padding: 7px 10px; font-size: 11px; }

  .card .stat-row { gap: 3px; }
  .card .art { height: 104px; }
  .card .art img { width: 92px; height: 92px; }

  /* 狭屏招式单列，避免文字挤压 */
  .move { flex-basis: 100%; }
  .move .mn { font-size: 13px; }

  /* 后备/阵型 6 列，更好利用宽度 */
  .bench { gap: 6px; }
  .mini { width: 76px; }
  .mini .ma { height: 44px; }
  .mini .ma img { width: 38px; height: 38px; }
  .formation { grid-template-columns: repeat(6, 1fr); gap: 4px; }
  .fc { height: 30px; }
  .fc-tag, .fc-st { font-size: 7px; }

  .log { max-height: 150px; }
  .foot { font-size: 10px; text-align: left; }

  /* 组建界面：更紧凑的网格与内边距 */
  .setup-box { padding: 12px 12px 10px; }
  .setup-box h2 { font-size: 17px; }
  .pk-search { min-width: 140px; }
  .pk-grid { grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 6px; }
  .pk-art { height: 44px; }
  .pk-art img { width: 38px; height: 38px; }
  .pk-name { font-size: 11px; }
}

/* 小屏上悬浮预览改为贴边、可滚动显示 */
@media (max-width: 520px) {
  .pk-preview {
    width: min(220px, calc(100vw - 16px));
    max-height: 82vh; overflow: auto;
  }
}

/* ---------- 难度选择 ---------- */
.setup-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.setup-label { font-weight: 800; color: var(--muted); font-size: 12px; }
.diff-modes { display: flex; gap: 8px; }
.seg.diff { flex: 0 0 auto; min-width: 80px; padding: 7px 9px; font-size: 12px; }
.seg.diff.active { border-color: var(--accent2); background: #eef3ff; color: var(--accent2); box-shadow: 0 0 0 2px #cfe0ff inset; }
.setup-hint { font-size: 11px; color: var(--muted); opacity: .85; }

/* ---------- 战绩面板 ---------- */
.stats-panel {
  margin: 4px 0 8px; padding: 8px 10px;
  background: linear-gradient(180deg,#f7f9fd,#eef2fb);
  border: 2px solid #e3e8f2; border-radius: 10px;
}
.sp-title {
  font-size: 12px; font-weight: 800; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; flex-wrap: wrap;
  cursor: pointer; user-select: none;
}
.sp-title .sp-diff { font-size: 10px; color: var(--muted); font-weight: 500; }
.sp-title .sp-toggle { margin-left: auto; font-size: 10px; color: var(--muted); transition: transform .2s; }
.stats-panel.collapsed .sp-toggle { transform: rotate(-90deg); }
.sp-body {
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s, margin .2s;
  max-height: 200px; opacity: 1; margin-top: 4px;
}
.stats-panel.collapsed .sp-body {
  max-height: 0; opacity: 0; margin-top: 0;
}
.sp-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.sp-cell { background: #fff; border-radius: 6px; padding: 3px 2px; text-align: center; box-shadow: 0 1px 0 #e6ebf5; }
.sp-cell b { display: block; font-size: 14px; color: var(--accent2); }
.sp-cell span { font-size: 10px; color: var(--muted); }
.sp-ach { margin-top: 4px; font-size: 11px; font-weight: 700; color: #b8860b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-ach.muted { font-weight: 500; color: var(--muted); }

/* ---------- 轻量 toast ---------- */
.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast-item {
  background: #1d2540ee; color: #fff; padding: 11px 20px; border-radius: 999px; font-weight: 700; font-size: 14px;
  box-shadow: 0 8px 24px #0006; opacity: 0; transform: translateY(16px); transition: .3s;
}
.toast-item.show { opacity: 1; transform: translateY(0); }

/* ---------- 战斗回放 ---------- */
.overlay.replay { background: #0a0f1fdd; }
.replay-box {
  position: relative; width: min(560px, 92vw); background: #fff; border-radius: 20px;
  padding: 22px; box-shadow: 0 20px 60px #0008; max-height: 86vh; display: flex; flex-direction: column;
}
.replay-box h2 { font-size: 20px; color: var(--ink); margin-bottom: 12px; }
.replay-box .setup-close { top: 12px; right: 12px; }
.replay-bars { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.rb { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.rb-nm { width: 86px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rb.you .rb-nm { color: var(--accent2); }
.rb.ai .rb-nm { color: #e3534a; }
.rb-bar { flex: 1; height: 14px; background: #eceff6; border-radius: 8px; overflow: hidden; }
.rb-bar i { display: block; height: 100%; background: linear-gradient(90deg,#46c46a,#2f9e4f); transition: width .25s; }
.rb.ai .rb-bar i { background: linear-gradient(90deg,#ff7a6b,#e3534a); }
.rb-hp { width: 78px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.rb-w { font-size: 13px; font-weight: 700; color: #e08a00; align-self: flex-end; }
.replay-log { flex: 1; overflow-y: auto; max-height: 46vh; background: #f7f9fd; border: 1px solid #e3e8f2; border-radius: 12px; padding: 8px 10px; font-size: 13px; }
.rf { display: flex; gap: 8px; padding: 5px 6px; border-radius: 8px; align-items: baseline; }
.rf + .rf { border-top: 1px dashed #ffffff44; }
.rf .rf-i { color: var(--muted); font-weight: 700; min-width: 22px; }
.rf .rf-t { color: var(--ink); line-height: 1.4; }
.rf.cur { background: #fff4d6; box-shadow: 0 0 0 1px #ffd86a inset; }
.rf.cur .rf-t { font-weight: 700; }
.replay-ctrls { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; }
.replay-idx { font-size: 13px; color: var(--muted); min-width: 54px; text-align: center; }

