:root {
  --bg: #16182b;
  --bg2: #1e2138;
  --panel: #262a45;
  --panel2: #2f3454;
  --ink: #e9e6d8;
  --muted: #9aa0b8;
  --accent: #f4a261;
  --accent2: #e9c46a;
  --teal: #2a9d8f;
  --red: #e76f51;
  --green: #57cc99;
  --shadow: #0b0c17;
  --pixel-border: 3px solid #0b0c17;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Courier New", "SimSun", monospace;
  image-rendering: pixelated;
  overflow-x: hidden;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; display: flex; justify-content: center; padding: 16px; }
.screen { width: 100%; max-width: 980px; margin: 0 auto; animation: pop-in .18s steps(3) both; }
.screen.hidden { display: none; }
.hidden { display: none !important; }

@keyframes pop-in {
  0% { transform: translateY(8px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* 顶栏 */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px; background: var(--bg2);
  border-bottom: var(--pixel-border);
  box-shadow: 0 4px 0 var(--shadow);
}
.logo { font-size: 20px; font-weight: bold; color: var(--accent2); letter-spacing: 2px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.coins { color: var(--accent2); font-weight: bold; }
.nick { color: var(--teal); }

button, input, select {
  font-family: inherit; color: var(--ink);
  border: var(--pixel-border); background: var(--panel2);
  padding: 8px 14px; font-size: 15px; cursor: pointer;
  box-shadow: 0 4px 0 var(--shadow);
  outline: none; border-radius: 0;
}
button:active { transform: translateY(4px); box-shadow: 0 0 0 var(--shadow); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
input, select { background: #191c31; }
input:focus, select:focus { border-color: var(--accent); }
button.primary { background: var(--accent); color: #20140a; font-weight: bold; }
button.danger-btn { background: var(--red); color: #fff; }
button.mini-btn { padding: 5px 10px; font-size: 13px; box-shadow: 0 3px 0 var(--shadow); }
button.mini-btn:active { transform: translateY(3px); box-shadow: none; }
button.icon-btn { padding: 5px 10px; font-size: 16px; }
.btn-block { width: 100%; }

.panel {
  background: var(--panel);
  border: var(--pixel-border);
  box-shadow: 0 6px 0 var(--shadow), inset 0 0 0 3px #343a5e;
  padding: 22px; margin: 12px 0;
}
.panel h2 { margin: 0 0 14px; color: var(--accent2); letter-spacing: 1px; }
.panel h3 { margin: 16px 0 8px; color: var(--ink); }
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.6; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); margin: 10px 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }

/* 登录 */
.login-panel { max-width: 420px; margin: 40px auto; text-align: center; }
.game-title { font-size: 40px; margin: 8px 0 0; color: var(--accent2); text-shadow: 4px 4px 0 var(--shadow), 0 0 18px rgba(244,162,97,.35); }
.subtitle { color: var(--muted); margin: 6px 0 20px; }
.tabs { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.tab { background: var(--panel2); }
.tab.active { background: var(--teal); color: #fff; }
.login-panel form { display: flex; flex-direction: column; gap: 12px; }
.remember { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.remember input { box-shadow: none; }

/* 主菜单 */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-top: 40px; }
.menu-card {
  background: var(--panel); border: var(--pixel-border);
  box-shadow: 0 6px 0 var(--shadow), inset 0 0 0 3px #343a5e;
  padding: 22px; display: flex; flex-direction: column; gap: 8px; text-align: left;
  min-height: 150px;
}
.menu-card:hover { border-color: var(--accent); background: var(--panel2); }
.mc-icon { font-size: 34px; }
.mc-title { font-size: 20px; font-weight: bold; color: var(--accent2); }
.mc-desc { color: var(--muted); font-size: 13px; }

/* 大厅 */
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .lobby-grid { grid-template-columns: 1fr; } }
.card { background: var(--bg2); border: var(--pixel-border); padding: 14px; box-shadow: 0 4px 0 var(--shadow); }
.card h3 { margin-top: 0; }
.card input { width: 100%; margin: 8px 0; }
.room-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 10px 0; }
.room-item { background: var(--bg2); border: var(--pixel-border); padding: 10px; cursor: pointer; }
.room-item:hover { border-color: var(--accent); }
.room-item .code { font-size: 20px; color: var(--accent2); letter-spacing: 2px; }

/* 房间 */
.room-code-box { text-align: center; background: var(--bg2); border: var(--pixel-border); padding: 18px; box-shadow: 0 4px 0 var(--shadow); }
.room-code-label { color: var(--muted); font-size: 13px; }
.room-code { font-size: 48px; font-weight: bold; letter-spacing: 12px; color: var(--accent2); text-shadow: 3px 3px 0 var(--shadow); }
.room-status { display: inline-block; margin-top: 6px; padding: 3px 10px; background: var(--teal); border: 2px solid #0b0c17; font-size: 13px; }
.room-status.playing { background: var(--red); }
.room-host-row { display: flex; justify-content: center; gap: 18px; color: var(--muted); margin: 12px 0; }
.player-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.player-list li { background: var(--bg2); border: var(--pixel-border); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.player-list .crown { color: var(--accent2); }
.player-list .off { color: var(--red); font-size: 12px; }
.room-queue ol { padding-left: 22px; color: var(--muted); line-height: 1.9; }

/* 游戏界面 */
.game-top { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--bg2); border: var(--pixel-border); margin-bottom: 8px; }
.game-top .gt-title { font-size: 20px; color: var(--accent2); font-weight: bold; }
.game-top .gt-round { color: var(--muted); font-size: 13px; }
.game-canvas { background: var(--bg2); border: var(--pixel-border); box-shadow: 0 5px 0 var(--shadow); min-height: 420px; position: relative; }
.game-canvas canvas { display: block; margin: 0 auto; }
.game-canvas canvas { touch-action: none; user-select: none; -webkit-tap-highlight-color: transparent; }
.game-hud { margin-top: 10px; min-height: 60px; }
.god-battle-log {
  position: absolute; right: 8px; bottom: 38px; width: 230px; max-height: 132px;
  overflow-y: auto; pointer-events: none; z-index: 5;
  display: flex; flex-direction: column; gap: 3px;
}
.god-log-row { background: rgba(11, 12, 23, 0.78); border: 1px solid #0b0c17; color: #e9c46a; font-size: 12px; padding: 3px 6px; }
.god-log-toggle {
  position: absolute; right: 8px; bottom: 8px; z-index: 6;
  background: rgba(11, 12, 23, 0.85); border: 1px solid #3fbf7f; color: #e9c46a;
  border-radius: 8px; padding: 5px 10px; font-size: 13px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}
.hud-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; background: var(--panel); border: var(--pixel-border); padding: 10px 14px; box-shadow: 0 4px 0 var(--shadow); }
.hud-msg { color: var(--muted); font-size: 15px; flex: 1; min-width: 160px; }
.hud-big { font-size: 18px; color: var(--accent2); }
.score-strip { display: flex; gap: 8px; flex-wrap: wrap; }
.score-chip { background: var(--bg2); border: 2px solid #0b0c17; padding: 5px 10px; font-size: 14px; }
.score-chip.me { border-color: var(--accent); color: var(--accent2); }
.relic-chip { background: #3a2b17; border: 2px solid #0b0c17; padding: 3px 8px; font-size: 12px; color: var(--accent2); }
.timer-bar { width: 120px; height: 14px; border: 2px solid #0b0c17; background: #191c31; }
.timer-bar > div { height: 100%; background: var(--teal); transition: width .2s linear; }
.game-btn { font-size: 14px; padding: 6px 10px; }
.game-btn.hot { background: var(--red); color: #fff; animation: pulse .7s steps(2) infinite; }
@keyframes pulse { 50% { opacity: .6; } }

/* 商店 */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.chip { padding: 4px 10px; font-size: 13px; border: 2px solid #0b0c17; background: var(--panel2); }
.chip.active { background: var(--teal); }
.shop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.relic-card { background: var(--bg2); border: var(--pixel-border); padding: 12px; box-shadow: 0 4px 0 var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.relic-card.owned { opacity: .65; }
.relic-card .r-name { font-size: 17px; font-weight: bold; }
.relic-card .r-rarity { font-size: 12px; padding: 2px 8px; border: 2px solid #0b0c17; display: inline-block; width: fit-content; }
.relic-card .r-desc { color: var(--muted); font-size: 13px; min-height: 36px; }
.relic-card .r-game { color: var(--teal); font-size: 12px; }
.relic-card .r-buy { margin-top: auto; }

/* 装备 */
.equip-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .equip-grid { grid-template-columns: 1fr; } }
.slot-row { display: flex; gap: 8px; flex-wrap: wrap; min-height: 56px; }
.slot { width: 52px; height: 52px; border: 2px dashed var(--muted); display: flex; align-items: center; justify-content: center; font-size: 20px; background: #191c31; }
.slot.filled { border-style: solid; border-color: var(--accent); background: #3a2b17; }
.relic-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.pick-relic { padding: 6px 8px; font-size: 12px; border: 2px solid #0b0c17; background: var(--panel2); }
.pick-relic.picked { border-color: var(--accent); background: #3a2b17; color: var(--accent2); }

/* 战绩 */
.stat-overview { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.stat-box { background: var(--bg2); border: var(--pixel-border); padding: 12px 20px; text-align: center; }
.stat-box .num { font-size: 26px; color: var(--accent2); }
.stat-table { width: 100%; border-collapse: collapse; background: var(--bg2); border: var(--pixel-border); }
.stat-table th, .stat-table td { border: 2px solid #0b0c17; padding: 8px; text-align: center; font-size: 14px; }
.stat-table th { background: var(--panel2); color: var(--accent2); }

/* 图鉴 */
.game-dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.game-dex-card { background: var(--bg2); border: var(--pixel-border); padding: 12px; box-shadow: 0 4px 0 var(--shadow); }
.game-dex-card .gd-name { font-size: 18px; font-weight: bold; color: var(--accent2); display: flex; justify-content: space-between; }
.game-dex-card .gd-meta { color: var(--muted); font-size: 12px; margin: 4px 0; }
.game-dex-card ul { padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.7; margin: 6px 0; }
.badge { font-size: 12px; padding: 2px 8px; border: 2px solid #0b0c17; }
.badge.on { background: var(--green); color: #06281a; }
.badge.off { background: #555; color: #ddd; }

/* Toast & Modal */
#toast-wrap { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel2); border: var(--pixel-border); box-shadow: 0 4px 0 var(--shadow); padding: 10px 18px; font-size: 14px; animation: pop-in .15s steps(2) both; }
.toast.error { border-color: var(--red); color: #ffb3a0; }
.toast.ok { border-color: var(--green); color: #b7f5d5; }
#modal-mask { position: fixed; inset: 0; background: rgba(10,10,20,.82); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-box { background: var(--panel); border: var(--pixel-border); box-shadow: 0 8px 0 var(--shadow), inset 0 0 0 4px #343a5e; padding: 24px; max-width: 640px; width: 100%; max-height: 86vh; overflow-y: auto; }
.modal-title { font-size: 22px; color: var(--accent2); margin: 0 0 12px; }
.rank-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.rank-table th, .rank-table td { border: 2px solid #0b0c17; padding: 8px; text-align: center; }
.rank-table th { background: var(--panel2); }
.rank-1 { color: var(--accent2); font-weight: bold; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.result-banner { text-align: center; font-size: 18px; padding: 10px; border: 2px solid #0b0c17; background: var(--bg2); margin-bottom: 12px; }

/* 抓蛐蛐 */
.net-count { background: var(--bg2); border: 2px solid #0b0c17; padding: 5px 12px; font-size: 14px; }
.cricket-map {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  background: #1c2d22; border: var(--pixel-border); padding: 8px;
  box-shadow: 0 5px 0 var(--shadow); margin: 12px 0;
}
.cricket-tile {
  aspect-ratio: 1.15; display: flex; align-items: center; justify-content: center;
  font-size: 26px; border: 2px solid #0b0c17; cursor: pointer; user-select: none;
  background: #2f5d3a; transition: filter .1s;
}
.cricket-tile:hover { filter: brightness(1.25); }
.cricket-tile.flower { background: #357a44; }
.cricket-tile.water { background: #1d4f7a; }
.cricket-tile.rock { background: #6b6b6b; }
.cricket-tile.busy { pointer-events: none; filter: brightness(.6); }
.cricket-encounter {
  background: var(--bg2); border: var(--pixel-border); padding: 14px; margin: 10px 0;
  box-shadow: 0 4px 0 var(--shadow); animation: pop-in .18s steps(3) both;
}
.enc-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.enc-emoji { font-size: 44px; }
.enc-name { font-size: 22px; font-weight: bold; }
.enc-timer { margin-left: auto; font-size: 15px; color: var(--red); }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.stat-pill { background: #191c31; border: 2px solid #0b0c17; padding: 4px 10px; font-size: 13px; }
.skill-pill { background: #2f3454; border: 2px solid #0b0c17; padding: 3px 8px; font-size: 12px; color: var(--teal); }
.cricket-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.cricket-card { background: var(--bg2); border: var(--pixel-border); padding: 10px; box-shadow: 0 3px 0 var(--shadow); }
.cricket-card.in-team { border-color: var(--accent); }
.cricket-card .cc-name { font-size: 16px; font-weight: bold; }
.cricket-card .cc-meta { font-size: 12px; color: var(--muted); }
.game-select-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.game-pick { padding: 6px 10px; font-size: 13px; border: 2px solid #0b0c17; background: var(--panel2); }
.game-pick.picked { border-color: var(--accent); background: #3a2b17; color: var(--accent2); }
.game-pick.disabled { opacity: .45; cursor: not-allowed; }

/* 聊天面板 */
.chat-panel {
  position: fixed; right: 14px; bottom: 14px; width: 300px; height: 320px;
  background: var(--panel); border: var(--pixel-border);
  box-shadow: 0 6px 0 var(--shadow); z-index: 50;
  display: flex; flex-direction: column;
}
.chat-panel.collapsed { height: auto; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; background: var(--panel2); border-bottom: 2px solid #0b0c17;
  color: var(--accent2); font-size: 14px; font-weight: bold;
}
.chat-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.chat-msg { font-size: 13px; line-height: 1.4; word-break: break-word; }
.chat-msg .cm-nick { color: var(--teal); font-weight: bold; margin-right: 6px; }
.chat-msg.me .cm-nick { color: var(--accent2); }
.chat-msg .cm-scope { font-size: 11px; color: var(--muted); margin-right: 6px; }
.chat-send-row { display: flex; gap: 6px; padding: 8px; border-top: 2px solid #0b0c17; }
.chat-send-row input { flex: 1; min-width: 0; }
.friends-panel {
  position: fixed; right: 14px; bottom: 14px; width: 300px; height: 380px;
  background: var(--panel); border: var(--pixel-border);
  box-shadow: 0 6px 0 var(--shadow); z-index: 51;
  display: flex; flex-direction: column;
}

/* 炫舞手机端按键 */
.dance-pad {
  position: absolute; left: 0; right: 0; bottom: 8px;
  display: none; justify-content: center; gap: 12px; z-index: 6;
  pointer-events: none;
}
.dance-pad-btn {
  pointer-events: auto;
  width: 64px; height: 64px; font-size: 26px;
  touch-action: none; user-select: none; -webkit-tap-highlight-color: transparent;
  background: rgba(25, 28, 49, 0.88);
}
@media (hover: none) and (pointer: coarse), (max-width: 720px) {
  .dance-pad { display: flex; }
}

/* ---------- 斗蛐蛐战斗（红绿风格） ---------- */
.cricket-battle {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(8, 10, 20, 0.76);
  display: flex; align-items: center; justify-content: center;
  padding: 12px;
}
.battle-box {
  position: relative;
  width: min(680px, 98vw);
  max-height: 94vh;
  background: #1b1e2b;
  border: 3px solid #0b0c17;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  padding: 10px;
  display: flex; flex-direction: column; gap: 6px;
  overflow: hidden;
}
.battle-stage {
  position: relative;
  height: min(520px, 74vh);
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(180deg, #1d2f2a 0%, #1a2230 55%, #241d2c 100%);
  border: 2px solid #0b0c17;
  border-radius: 10px;
  padding: 12px;
  overflow: hidden;
}
.bside { display: flex; align-items: center; gap: 10px; min-height: 96px; }
.bside.enemy { justify-content: flex-start; }
.bside.player { justify-content: flex-end; }
.actor-wrap { display: flex; align-items: center; gap: 10px; position: relative; z-index: 2; }
.bside.enemy .actor-wrap { flex-direction: row; }
.bside.player .actor-wrap { flex-direction: row-reverse; }
.actor-sprite {
  font-size: 50px; width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.32); border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  flex: 0 0 auto;
}
.actor-panel { min-width: 190px; background: rgba(0, 0, 0, 0.38); border: 2px solid rgba(255, 255, 255, 0.1); border-radius: 10px; padding: 6px 10px; }
.actor-name { color: #e9c46a; font-size: 14px; font-weight: bold; }
.actor-meta { font-size: 11px; color: #aab3c5; margin-top: 2px; }
.battle-hp { width: 100%; height: 10px; background: #333; margin-top: 4px; border: 2px solid #0b0c17; border-radius: 4px; overflow: hidden; }
.battle-hp > div { height: 100%; background: #57cc99; transition: width .2s; }
.side-queue { display: flex; gap: 4px; flex-wrap: wrap; max-width: 240px; }
.sq-item { font-size: 10px; background: rgba(0, 0, 0, 0.42); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 6px; padding: 2px 5px; color: #cbd3e3; }
.sq-item.active { border-color: #57cc99; color: #fff; }
.sq-item.dead { opacity: 0.4; }
.battle-middle { display: flex; gap: 8px; align-items: stretch; }
.battle-log { flex: 1; height: 92px; background: #0b0c17; border: 2px solid #3fbf7f; color: #d7e8d7; font-size: 12px; overflow-y: auto; padding: 6px 8px; line-height: 1.5; border-radius: 8px; }
.battle-menu { flex: 1; display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; align-content: flex-start; background: #12152a; border: 2px solid #3fbf7f; padding: 8px; border-radius: 8px; max-height: 118px; overflow-y: auto; }
.battle-menu .mini-btn, .battle-menu .primary { min-width: 90px; }
.battle-menu.locked { pointer-events: none; opacity: 0.55; }
.battle-announce {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(11, 12, 23, 0.94); border: 2px solid #e9c46a; color: #e9c46a;
  padding: 6px 14px; border-radius: 10px; font-weight: bold; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 6;
  white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis;
}
.battle-announce.show { opacity: 1; }
.battle-result {
  position: absolute; inset: 0; background: rgba(8, 10, 20, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 8; opacity: 0; pointer-events: none; transition: opacity .3s;
  border-radius: 10px;
}
.battle-result.show { opacity: 1; pointer-events: auto; }
.br-box { text-align: center; max-width: 90%; max-height: 92%; overflow-y: auto; padding: 10px; }
.br-title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.br-row { font-size: 13px; color: #d7e8d7; margin: 4px 0; }
.br-row b { color: #e9c46a; }
.fx-emoji { position: absolute; font-size: 34px; z-index: 6; pointer-events: none; }
.fx-float {
  position: absolute;
  font-size: 20px;
  font-weight: 800;
  z-index: 7;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}
@keyframes slideInLeft { from { transform: translateX(-130%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(130%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.actor-wrap.enter-left { animation: slideInLeft .5s ease; }
.actor-wrap.enter-right { animation: slideInRight .5s ease; }
@keyframes bounceSpin { 0% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-40px) rotate(180deg); } 100% { transform: translateY(0) rotate(360deg); } }
.actor-sprite.bounce { animation: bounceSpin .55s ease; }
@keyframes hitFlash { 0%, 100% { filter: none; } 20%, 60% { filter: brightness(2.2) hue-rotate(-30deg); } 40% { filter: brightness(0.5); } }
.actor-sprite.hit { animation: hitFlash .42s ease; }
@keyframes leaveBack { to { transform: translateX(-70px) translateY(16px) rotate(-170deg); opacity: 0; } }
.actor-wrap.leave-back { animation: leaveBack .45s ease forwards; }
@keyframes rollIn { from { transform: translateX(70px) rotate(200deg); opacity: 0; } to { transform: none; opacity: 1; } }
.actor-wrap.roll-in { animation: rollIn .45s ease; }
@media (max-width: 720px) {
  .battle-stage { height: 58vh; padding: 8px; }
  .actor-sprite { font-size: 38px; width: 50px; height: 50px; }
  .actor-panel { min-width: 130px; padding: 4px 7px; }
  .actor-name { font-size: 12px; }
  .side-queue { max-width: 170px; }
  .battle-middle { flex-direction: column; }
  .battle-log { height: 64px; }
}

/* 斗地主 */
.ddz-wrap { background: var(--bg2); border: var(--pixel-border); padding: 12px; box-shadow: 0 5px 0 var(--shadow); }
.ddz-players { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ddz-player { background: var(--panel); border: 2px solid #0b0c17; padding: 6px 10px; font-size: 14px; }
.ddz-player.me { border-color: var(--accent); color: var(--accent2); }
.ddz-count { color: var(--muted); margin-left: 8px; }
.ddz-phase { text-align: center; color: var(--accent2); margin: 10px 0 6px; font-size: 15px; }
.ddz-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.ddz-landlord, .ddz-last { min-height: 64px; display: flex; align-items: center; justify-content: center; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.ddz-card { min-width: 44px; height: 62px; background: #f7f3e8; color: #1b1b1b; border: 2px solid #0b0c17; box-shadow: 0 3px 0 #0b0c17; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 6px; font-family: inherit; }
.ddz-card.red { color: #c0392b; }
.ddz-card.picked { transform: translateY(-12px); border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.ddz-card:disabled { cursor: default; opacity: .9; transform: none; box-shadow: 0 3px 0 #0b0c17; }
.dc-rank { font-size: 15px; font-weight: bold; }
.dc-suit { font-size: 12px; }
.ddz-actions { display: flex; justify-content: center; gap: 10px; margin: 8px 0; }
.ddz-hand { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 14px 6px 6px; min-height: 76px; }

/* 叶子戏 */
.ddz-card.leaf-wild { background: #f5d76e; color: #5b3a1e; }
.leaf-rank { border: 2px solid #0b0c17; background: var(--panel2); padding: 6px 8px; font-size: 14px; }
.leaf-last { color: var(--accent2); font-size: 15px; text-align: center; }

/* 麻将 */
.ddz-card.mj-drawn { border-color: #e9c46a; box-shadow: 0 0 0 2px #e9c46a, 0 3px 0 #0b0c17; position: relative; }
.mj-new { position: absolute; top: -10px; right: -6px; background: var(--red); color: #fff; font-size: 10px; padding: 1px 4px; border: 1px solid #0b0c17; }

/* 神人工坊 */
.god-skill-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; border: 2px solid #0b0c17; background: #191c31; padding: 6px; }
.god-skill-row .god-params { display: flex; gap: 6px; flex-wrap: wrap; }
.god-skill-row label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.god-skill-row input { width: 64px; padding: 3px 5px; font-size: 12px; box-shadow: none; }
.god-skill-row .god-cost { color: var(--accent2); font-size: 13px; margin-left: auto; }
.god-preview { width: 120px; height: 120px; image-rendering: pixelated; border: 2px solid #0b0c17; background: #191c31; object-fit: contain; margin: 4px 0; display: block; }
.god-preview.mini { width: 48px; height: 48px; margin: 0; }
.god-help { border: 2px solid #0b0c17; background: #12152a; padding: 8px 12px; margin: 8px 0; font-size: 12px; color: var(--muted); }
.god-help h4 { color: var(--accent2); margin: 0 0 4px; font-size: 13px; }
.god-help ul { margin: 0; padding-left: 16px; line-height: 1.6; }
.god-skill-row input[type="file"] { width: 170px; font-size: 11px; }
.god-skill-images { width: 100%; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.god-logic-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.god-logic-row select, .god-logic-row input { font-size: 12px; padding: 3px 5px; box-shadow: none; }
.god-thumb { width: 48px; height: 48px; image-rendering: pixelated; border: 2px solid #0b0c17; background: #191c31; object-fit: contain; display: block; }
.god-preset-card { display: inline-flex; align-items: center; gap: 8px; border: 2px solid #0b0c17; background: #191c31; padding: 6px; }
.god-char-card { background: var(--bg2); border: 2px solid #0b0c17; padding: 8px; }
.friend-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; border: 2px solid #0b0c17; background: #191c31; padding: 6px; margin: 4px 0; }
.friend-dot { width: 10px; height: 10px; border-radius: 50%; background: #555b78; display: inline-block; }
.friend-dot.on { background: #57cc99; box-shadow: 0 0 6px #57cc99; }

/* ---------------- 斗蛐蛐对战 ---------------- */
.crpvp-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

/* 斗蛐蛐 PvP 战斗舞台与特效 */
.crpvp-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 96px;
  background: rgba(11, 12, 23, 0.75);
  border: 2px solid rgba(63, 191, 127, 0.35);
  border-radius: 12px;
  padding: 10px 16px;
  overflow: hidden;
  flex: 0 0 auto;
}
.crpvp-actor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 2;
}
.crpvp-sprite {
  font-size: 46px;
  width: 62px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.32);
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
}
.crpvp-actorname {
  font-size: 11px;
  color: #cbd3e3;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.crpvp-stage-vs {
  color: #e9c46a;
  font-weight: 800;
  font-size: 18px;
  z-index: 2;
}
.crpvp-fx {
  position: absolute;
  font-size: 32px;
  z-index: 6;
  pointer-events: none;
}
.crpvp-float {
  font-size: 18px;
  font-weight: 800;
  z-index: 7;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}
@keyframes crpvpBounce { 0% { transform: translateY(0); } 50% { transform: translateY(-34px); } 100% { transform: translateY(0); } }
.crpvp-sprite.crpvp-bounce { animation: crpvpBounce .5s ease; }
@keyframes crpvpHit { 0%, 100% { filter: none; } 20%, 60% { filter: brightness(2.2) hue-rotate(-30deg); } 40% { filter: brightness(0.5); } }
.crpvp-sprite.crpvp-hit { animation: crpvpHit .42s ease; }
@keyframes crpvpEnter { from { transform: translateX(60px) scale(.5); opacity: 0; } to { transform: none; opacity: 1; } }
.crpvp-actor.crpvp-enter { animation: crpvpEnter .42s ease; }

/* 选择上场面板 */
.crpvp-pick {
  background: rgba(244, 162, 97, 0.12);
  border: 2px solid rgba(244, 162, 97, 0.5);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}
.crpvp-pick-title { color: #f4a261; font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.crpvp-pick-list { display: flex; gap: 6px; flex-wrap: wrap; }
.crpvp-pick-btn {
  background: rgba(87, 204, 153, 0.14);
  border: 1px solid rgba(87, 204, 153, 0.4);
  color: #d7e8d7;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 12px;
}
.crpvp-pick-btn:hover { background: rgba(87, 204, 153, 0.28); }
.crpvp-picking {
  margin-left: 6px;
  font-size: 11px;
  color: #f4a261;
  border: 1px solid rgba(244, 162, 97, 0.45);
  border-radius: 6px;
  padding: 1px 6px;
}

/* 斗蛐蛐 PVP 匹配与战斗界面 */
.pvp-rank-card {
  display: flex;
  align-items: center;
  background: rgba(17, 20, 38, 0.86);
  border: 2px solid rgba(63, 191, 127, 0.35);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 6px 0;
}
.pvp-rank-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 15px;
}
.pvp-rank-emoji { font-size: 22px; }
.pvp-rank-name { font-weight: 800; font-size: 18px; }
.pvp-rank-sub { color: #cbd3e3; }
.pvp-rank-points { color: #f4a261; font-weight: 700; }
.error-text { color: #e76f51 !important; }
.cricket-pvp-stage {
  height: calc(100vh - 160px);
  min-height: 460px;
  overflow-y: auto;
}
.cricket-pvp-stage .crpvp-wrap { height: auto; min-height: 100%; }

.crpvp-player {
  background: rgba(17, 20, 38, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px;
}

.crpvp-player.foe {
  border-color: rgba(231, 111, 81, 0.45);
}

.crpvp-player.me {
  border-color: rgba(87, 204, 153, 0.5);
}

.crpvp-player-name {
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.crpvp-alive {
  font-size: 12px;
  color: #f4a261;
}

.crpvp-active {
  background: rgba(0, 0, 0, 0.32);
  border-radius: 8px;
  padding: 8px;
}

.crpvp-active-empty {
  color: #8b93a7;
  font-size: 13px;
  padding: 6px 0;
}

.crpvp-active-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.crpvp-emoji {
  font-size: 26px;
}

.crpvp-active-name {
  font-weight: 700;
  font-size: 15px;
}

.crpvp-active-name em {
  font-style: normal;
  color: #8b93a7;
  font-size: 12px;
}

.crpvp-type {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11px;
  color: #16182b;
  margin-left: 4px;
}

.crpvp-hpbar {
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  overflow: hidden;
}

.crpvp-hpbar i {
  display: block;
  height: 100%;
  transition: width 0.3s;
}

.crpvp-hptext {
  font-size: 11px;
  color: #aab3c5;
  margin-top: 2px;
}

.crpvp-cost {
  font-size: 11px;
  color: #f4a261;
  margin-top: 4px;
}

.crpvp-team {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.crpvp-slot {
  flex: 1 1 82px;
  max-width: 110px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 5px 7px;
  font-size: 12px;
  cursor: default;
  position: relative;
}

.crpvp-player.me .crpvp-slot {
  cursor: pointer;
}

.crpvp-slot.active {
  border-color: #57cc99;
  background: rgba(87, 204, 153, 0.12);
}

.crpvp-slot.dead {
  opacity: 0.45;
}

.crpvp-slot.hidden-slot {
  color: #8b93a7;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04) 6px, transparent 6px, transparent 12px);
}

.crpvp-slot-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.crpvp-slot-hp {
  font-size: 11px;
  color: #aab3c5;
}

.crpvp-slot-tag {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 10px;
  color: #f4a261;
}

.crpvp-log {
  flex: 1 1 auto;
  min-height: 64px;
  max-height: 140px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.6;
}

.crpvp-statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding: 0 2px;
}

.crpvp-turn {
  font-weight: 700;
}

.crpvp-timer {
  color: #f4a261;
  font-variant-numeric: tabular-nums;
}

.crpvp-skills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.crpvp-skill {
  background: rgba(87, 204, 153, 0.14);
  border: 1px solid rgba(87, 204, 153, 0.35);
  border-radius: 8px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 12px;
  text-align: left;
}

.crpvp-skill.selected {
  border-color: #f4a261;
  background: rgba(244, 162, 97, 0.2);
}

.crpvp-skill.no-cost {
  opacity: 0.45;
}

.crpvp-skill:disabled {
  cursor: not-allowed;
}

.cs-name {
  display: block;
  font-weight: 700;
}

.cs-meta {
  display: block;
  font-size: 10px;
  color: #aab3c5;
}

/* ---------------- 蛐蛐道馆 ---------------- */
.gym-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.gym-card {
  background: var(--bg2);
  border: 2px solid #0b0c17;
  border-radius: 12px;
  padding: 12px;
}

.gym-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.gym-name {
  font-size: 16px;
  font-weight: 800;
}

/* ---------------- 蛐蛐背包 ---------------- */
.cricket-bag {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 8px 0;
}
.bag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 2px solid #0b0c17;
  border-radius: 10px;
  padding: 6px 10px;
  flex-wrap: wrap;
}
.bag-item.reserve {
  border-style: dashed;
  opacity: 0.85;
}
.bag-idx {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #3fbf7f;
  color: #16182b;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex: 0 0 auto;
}
.bag-item.reserve .bag-idx {
  background: #f4a261;
}
.bag-name {
  font-weight: 700;
  min-width: 90px;
}
.bag-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.bag-actions .mini-btn {
  padding: 3px 8px;
  font-size: 12px;
}

/* ---------- 手机端适配 ---------- */
@media (max-width: 720px) {
  main { padding: 8px; }
  .screen { padding: 0 4px; }
  .panel { padding: 12px; margin: 8px 0; }
  #topbar { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
  .logo { font-size: 16px; }
  .top-actions { gap: 6px; flex-wrap: wrap; }
  .top-actions .mini-btn, .top-actions .icon-btn { padding: 4px 7px; font-size: 12px; }
  #top-coins, #top-user { font-size: 12px; }
  .menu-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 18px; }
  .menu-card { padding: 12px; min-height: 110px; gap: 5px; }
  .mc-icon { font-size: 26px; }
  .mc-title { font-size: 16px; }
  .mc-desc { font-size: 11px; }
  .login-panel { margin: 18px auto; }
  .game-title { font-size: 30px; }
  .room-code { font-size: 30px; letter-spacing: 6px; }
  .game-canvas { min-height: 220px; }
  .game-canvas canvas { max-width: 100%; }
  .chat-panel, .friends-panel { width: calc(100% - 16px); right: 8px; bottom: 8px; max-height: 60vh; }
  .god-battle-log { width: min(210px, 56vw); bottom: 40px; }
  .god-log-toggle { padding: 4px 8px; font-size: 12px; }
  .player-list li { flex-wrap: wrap; gap: 6px; }
  .room-host-row, .room-code-box { padding: 10px; }
  .field { font-size: 13px; }
  button, input, select { font-size: 14px; padding: 7px 10px; }
  .hud-bar { flex-wrap: wrap; }
  .score-strip { flex-wrap: wrap; }
  .god-skill-row .god-params { width: 100%; }
  .god-logic-row, .friend-row { gap: 4px; }
}
