* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: #f3ede1;
  color: #2b2b2b;
  min-height: 100vh;
}
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- 大廳 ---------- */
.lobby { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.lobby-card {
  background: #fffdf7; border: 1px solid #d9cdb4; border-radius: 14px;
  padding: 32px 28px; width: 340px; box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}
.lobby-card h1 { font-size: 24px; color: #7a3b2e; letter-spacing: 2px; }
.lobby-card .sub { color: #8a7a5c; margin: 6px 0 18px; font-size: 13px; }
.lobby-card label { display: block; font-size: 13px; color: #6b5d44; margin: 12px 0 4px; }
.lobby-card input {
  width: 100%; padding: 10px 12px; border: 1px solid #cbbfa3; border-radius: 8px;
  font-size: 15px; background: #fff;
}
.lobby-card button {
  margin-top: 18px; width: 100%; padding: 12px; border: none; border-radius: 8px;
  background: #7a3b2e; color: #fff; font-size: 15px; cursor: pointer;
}
.lobby-card button:hover { background: #8e4738; }
.msg { margin-top: 12px; font-size: 13px; color: #b03a2e; min-height: 16px; }
.hint { margin-top: 14px; font-size: 12px; color: #9b8c6e; line-height: 1.5; }

/* ---------- 對戰 ---------- */
.game { display: flex; flex-direction: column; min-height: 100vh; padding: 10px 14px 14px; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.turn { font-size: 16px; font-weight: 700; color: #7a3b2e; }
button.ghost {
  padding: 7px 14px; border: 1px solid #cbbfa3; background: #fffdf7;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: #5b4a32;
}
button.ghost:hover { background: #efe7d6; }

.opponents { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.enemy {
  flex: 1 1 140px; background: #fffdf7; border: 1px solid #d9cdb4; border-radius: 10px;
  padding: 10px 12px; position: relative; cursor: default;
}
.enemy.targetable { outline: 2px solid #b03a2e; cursor: pointer; }
.enemy .ename { font-weight: 700; font-size: 14px; }
.enemy .ehp { font-size: 13px; color: #444; margin-top: 4px; }
.bar { height: 8px; background: #e3dccb; border-radius: 5px; margin-top: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: #5b8c5a; }
.shield-badge {
  position: absolute; top: 8px; right: 10px; background: #cbbfa3; color: #4a3b22;
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
}
.eliminated { opacity: 0.45; }
.eliminated::after {
  content: "淘汰"; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 20px; font-weight: 800; color: #b03a2e;
}

.mid { display: flex; gap: 12px; flex: 1; min-height: 0; }
.log {
  flex: 0 0 220px; background: #fffdf7; border: 1px solid #d9cdb4; border-radius: 10px;
  padding: 10px; font-size: 12px; color: #5b4a32; overflow-y: auto; max-height: 46vh;
  line-height: 1.6;
}
.mystatus { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.myinfo { background: #fffdf7; border: 1px solid #d9cdb4; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.myinfo b { color: #7a3b2e; }
.field { display: flex; gap: 8px; flex-wrap: wrap; min-height: 96px; align-content: flex-start; }
.field.mine { background: #fffdf7; border: 1px dashed #cbbfa3; border-radius: 10px; padding: 10px; }

/* 單位卡 */
.unit {
  width: 92px; background: #fff; border: 1px solid #cbbfa3; border-radius: 9px;
  padding: 7px 8px; position: relative;
}
.unit .uname { font-size: 13px; font-weight: 700; }
.unit .ustats { font-size: 12px; color: #444; margin-top: 3px; display: flex; justify-content: space-between; }
.unit .uatk { color: #b03a2e; font-weight: 700; }
.unit .uhp { color: #2e6b8e; font-weight: 700; }
.unit.canattack { border-color: #5b8c5a; box-shadow: 0 0 0 2px rgba(91,140,90,0.25); }
.unit.targetable { outline: 2px solid #b03a2e; cursor: pointer; }
.unit .actin { margin-top: 6px; width: 100%; padding: 4px; font-size: 11px; border: none;
  border-radius: 6px; background: #5b8c5a; color: #fff; cursor: pointer; }
.unit .actin:disabled { background: #c9c2b2; cursor: default; }

/* 手牌 */
.hand { display: flex; gap: 9px; overflow-x: auto; padding: 12px 4px 4px; min-height: 168px; }
.card {
  flex: 0 0 116px; width: 116px; background: #fff; border-radius: 11px; border: 2px solid #cbbfa3;
  padding: 9px 10px; display: flex; flex-direction: column;
}
.card .cname { font-size: 14px; font-weight: 800; }
.card .cfac { font-size: 11px; color: #fff; display: inline-block; padding: 1px 7px; border-radius: 8px; margin: 4px 0; }
.card .cstats { font-size: 12px; color: #444; display: flex; justify-content: space-between; margin-top: 2px; }
.card .cskill { font-size: 11px; color: #6b5d44; margin-top: 5px; line-height: 1.4; min-height: 30px; }
.card .cost { position: absolute; }
.card .playbtn {
  margin-top: auto; padding: 6px; border: none; border-radius: 7px; background: #7a3b2e;
  color: #fff; font-size: 12px; cursor: pointer;
}
.card .playbtn:disabled { background: #c9c2b2; cursor: default; }
.card .costbadge {
  position: absolute; top: -8px; left: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: #2e6b8e; color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; border: 2px solid #fff;
}

/* 陣營色 */
.fac-神 { background: #2e6b8e; }
.fac-魔 { background: #7a2e2e; }
.fac-妖 { background: #4a7a3a; }
.fac-巫 { background: #9c5a2e; }

.attackbar {
  margin: 8px 0; padding: 9px 12px; background: #f7e7d6; border: 1px solid #d9a06a;
  border-radius: 9px; display: flex; align-items: center; gap: 12px; font-size: 13px; color: #7a3b2e;
}

.overlay {
  position: fixed; inset: 0; background: rgba(40,30,20,0.5); display: flex;
  align-items: center; justify-content: center;
}
.overlay-card { background: #fffdf7; border-radius: 14px; padding: 30px 36px; text-align: center; }
.overlay-card h2 { color: #7a3b2e; margin-bottom: 10px; }
.overlay-card p { color: #5b4a32; margin-bottom: 18px; }
