:root {
  --bg: #0f1120;
  --panel: #1a1d33;
  --panel-2: #242842;
  --text: #e8e9f3;
  --muted: #8a8fb0;
  --fire: #ff6b4a;
  --water: #4aa8ff;
  --earth: #c9a05a;
  --light: #ffd75a;
  --dark: #9b6bff;
  --primary: #5a7bff;
  --danger: #ff4a6a;
  --heal: #4aff8a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, #2a2f55 0%, var(--bg) 60%);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.screen { display: none; position: absolute; inset: 0; }
.screen.active { display: flex; }

/* ---------- 大厅 ---------- */
#lobby { align-items: center; justify-content: center; padding: 20px; }
.lobby-box {
  background: var(--panel);
  border-radius: 20px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.title {
  font-size: 28px;
  text-align: center;
  background: linear-gradient(135deg, #ffd75a, #ff6b4a, #9b6bff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}
.subtitle { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #34395e;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.field input:focus { border-color: var(--primary); }

.btn {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--text);
  transition: transform .06s, filter .15s;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: linear-gradient(135deg, #5a7bff, #7b5aff); color: #fff; width: 100%; }
.btn.single { background: linear-gradient(135deg, #22c1a8, #2bb673); color: #fff; width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 12px;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #34395e; }
.hint { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- 对战 ---------- */
#game { flex-direction: column; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--panel);
  font-size: 13px;
  flex-shrink: 0;
  gap: 8px;
}
.turn-label { color: var(--heal); font-weight: 600; }
.phase-label { color: var(--muted); }

.battlefield {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  overflow: hidden;
  gap: 6px;
}
.zone {
  background: var(--panel);
  border-radius: 14px;
  padding: 10px;
  flex-shrink: 0;
}
.zone.enemy { border-top: 3px solid var(--danger); }
.zone.mine { border-bottom: 3px solid var(--primary); }
.zone-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }

.player-info {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text);
  flex-wrap: wrap;
}
.player-info .hp { color: var(--heal); font-weight: 700; }
.player-info .energy { color: var(--water); font-weight: 700; }

.board { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; min-height: 70px; }

.spirit-card {
  width: 88px;
  padding: 8px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 2px solid #34395e;
  position: relative;
  cursor: pointer;
  transition: transform .08s, border-color .15s;
}
.spirit-card.selected { border-color: var(--primary); transform: translateY(-4px); }
.spirit-card .s-name { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.spirit-card .s-stat { font-size: 11px; color: var(--muted); line-height: 1.5; }
.spirit-card .s-hp { position: absolute; top: 6px; right: 6px; font-size: 11px; color: var(--heal); font-weight: 700; }
.spirit-card .elem-badge {
  display: inline-block;
  width: 18px; height: 18px; line-height: 18px;
  border-radius: 50%; text-align: center; font-size: 11px; color: #000; font-weight: 800;
}

.el-fire { background: var(--fire); }
.el-water { background: var(--water); }
.el-earth { background: var(--earth); }
.el-light { background: var(--light); }
.el-dark { background: var(--dark); color: #fff; }

.log {
  flex: 1;
  min-height: 48px;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.log .hl { color: var(--text); }
.log .dmg { color: var(--danger); }
.log .heal { color: var(--heal); }

.hand {
  display: flex;
  gap: 6px;
  padding: 10px;
  overflow-x: auto;
  flex-shrink: 0;
  min-height: 130px;
  background: rgba(26,29,51,.5);
}

.card {
  min-width: 84px;
  height: 112px;
  border-radius: 10px;
  padding: 8px;
  background: var(--panel-2);
  border: 2px solid #34395e;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: transform .08s, border-color .15s;
}
.card.selected { border-color: var(--heal); transform: translateY(-8px); }
.card .c-name { font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.card .c-type { font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.card .c-cost { position: absolute; top: 6px; left: 6px; font-size: 11px; color: var(--water); font-weight: 700; }
.card .c-body { font-size: 10px; color: var(--muted); line-height: 1.5; }
.card .rarity { position: absolute; bottom: 4px; right: 6px; font-size: 9px; }
.card .elem-badge { position: absolute; top: 6px; right: 6px; display: inline-block; width: 16px; height: 16px; line-height: 16px; border-radius: 50%; text-align: center; font-size: 10px; color: #000; font-weight: 800; }

.rar-common { color: #b8bccf; }
.rar-rare { color: #4aa8ff; }
.rar-super_rare { color: #c07bff; }
.rar-legendary { color: #ffd75a; }
.rar-limited { color: #ff6b4a; }

.actions {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  flex-shrink: 0;
  background: var(--panel);
}
.actions .btn { flex: 1; }

@media (max-width: 768px) {
  .spirit-card { width: 72px; }
  .card { min-width: 68px; height: 96px; }
}
