* { 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; }

/* ---------- 登入 ---------- */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: #fffdf7; border: 1px solid #d9cdb4; border-radius: 14px;
  padding: 30px 28px; width: 360px; box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}
.login-card h1 { font-size: 23px; color: #7a3b2e; letter-spacing: 2px; }
.login-card .sub { color: #8a7a5c; margin: 6px 0 16px; font-size: 13px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab {
  flex: 1; padding: 8px; border: 1px solid #cbbfa3; background: #fff; border-radius: 8px;
  cursor: pointer; font-size: 14px; color: #5b4a32;
}
.tab.active { background: #7a3b2e; color: #fff; border-color: #7a3b2e; }
.tabpane input {
  width: 100%; padding: 10px 12px; border: 1px solid #cbbfa3; border-radius: 8px;
  font-size: 15px; background: #fff; margin-top: 8px;
}
.tabpane button {
  margin-top: 10px; width: 100%; padding: 11px; border: none; border-radius: 8px;
  background: #7a3b2e; color: #fff; font-size: 14px; cursor: pointer;
}
.tabpane button:hover { background: #8e4738; }
.tabpane .row { display: flex; gap: 10px; }
.tabpane .row button { margin-top: 12px; }
#regBtn { background: #fffdf7; color: #5b4a32; border: 1px solid #cbbfa3; }
#regBtn:hover { background: #efe7d6; }
.google {
  margin-top: 12px; width: 100%; padding: 11px; border: 1px solid #cbbfa3; border-radius: 8px;
  background: #fff; color: #3b3b3b; font-size: 14px; cursor: pointer;
}
.guestBtn, #guestBtn { margin-top: 10px; }

/* ---------- 錢包 ---------- */
.wallet { display: flex; align-items: center; gap: 12px; margin: 14px 0 4px; font-size: 14px; }
.wallet.small { font-size: 12px; gap: 8px; }
.wallet .coin { color: #b07a2e; font-weight: 700; }
.wallet .gem { color: #5b4a8e; font-weight: 700; }
.wallet .ghost.small { padding: 4px 10px; font-size: 12px; margin: 0; }
#lobby .wallet { margin-left: 0; }

/* ---------- 商店 ---------- */
.shop-card {
  background: #fffdf7; border-radius: 14px; padding: 24px 26px; width: 480px; max-width: 92vw;
  max-height: 86vh; overflow-y: auto;
}
.shop-card h2 { color: #7a3b2e; }
.shop-card .sub { color: #8a7a5c; font-size: 13px; margin: 4px 0 14px; }
.shop-card .sub b { color: #7a3b2e; }
.shop-list { display: flex; flex-direction: column; gap: 10px; }
.shop-item {
  display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid #cbbfa3;
  border-radius: 10px; padding: 10px 12px;
}
.shop-item .si-main { flex: 1; }
.shop-item .si-name { font-weight: 700; font-size: 14px; }
.shop-item .si-rar { font-size: 11px; color: #fff; background: #9c5a2e; padding: 1px 7px; border-radius: 8px; margin-left: 6px; }
.shop-item .si-desc { font-size: 12px; color: #6b5d44; margin-top: 3px; line-height: 1.4; }
.shop-item .si-price { font-size: 13px; color: #5b4a32; white-space: nowrap; }
.shop-item .si-buy {
  padding: 7px 16px; border: none; border-radius: 8px; background: #7a3b2e; color: #fff;
  font-size: 13px; cursor: pointer; white-space: nowrap;
}
.shop-item .si-buy:disabled { background: #c9c2b2; cursor: default; }
#shopClose { margin-top: 16px; }

/* ---------- 大廳動作列 ---------- */
.hub-actions { display: flex; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.hub-actions .ghost.small { flex: 1; margin: 0; }

/* ---------- 通用面板（章节 / 背包 / 任务） ---------- */
.panel-card {
  background: #fffdf7; border-radius: 14px; padding: 24px 26px;
  width: 520px; max-width: 92vw; max-height: 86vh; overflow-y: auto;
}
.panel-card h2 { color: #7a3b2e; }
.panel-card .sub { color: #8a7a5c; font-size: 13px; margin: 4px 0 14px; }
.panel-card .sub b { color: #7a3b2e; }

/* 章节 */
.chapter { margin-bottom: 16px; }
.ch-title { font-weight: 800; color: #7a3b2e; font-size: 16px; }
.ch-intro { font-size: 12px; color: #6b5d44; margin: 2px 0 8px; }
.stage-btn {
  display: block; width: 100%; margin: 6px 0; padding: 10px 12px; text-align: left;
  border: 1px solid #cbbfa3; border-radius: 9px; background: #fff; cursor: pointer; font-size: 14px;
  color: #5b4a32;
}
.stage-btn:hover { background: #efe7d6; }
.stage-reward { font-size: 11px; color: #b07a2e; margin-left: 8px; }

/* 背包 / 裝備 */
.equipped { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.eq-title { width: 100%; font-weight: 700; color: #7a3b2e; font-size: 13px; margin-bottom: 2px; }
.eq-slot {
  flex: 1 1 140px; background: #fff; border: 1px solid #cbbfa3; border-radius: 9px;
  padding: 8px 10px; display: flex; flex-direction: column;
}
.eq-slot-name { font-size: 12px; color: #6b5d44; }
.eq-slot-val { font-size: 13px; font-weight: 700; color: #5b4a32; word-break: break-all; }
.bag-list { display: flex; flex-direction: column; gap: 8px; }
.bag-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border: 1px solid #cbbfa3; border-radius: 9px; padding: 8px 12px;
}
.bi-name { font-size: 13px; font-weight: 600; word-break: break-all; }
.bag-empty { font-size: 13px; color: #9b8c6e; padding: 6px 0; }

/* 任務 */
.quest-list { display: flex; flex-direction: column; gap: 10px; }
.quest-item {
  background: #fff; border: 1px solid #cbbfa3; border-radius: 10px; padding: 10px 12px; position: relative;
}
.q-head { display: flex; justify-content: space-between; align-items: center; }
.q-name { font-weight: 700; font-size: 14px; }
.q-type { font-size: 11px; color: #fff; background: #9c5a2e; padding: 1px 8px; border-radius: 8px; }
.q-desc { font-size: 12px; color: #6b5d44; margin: 3px 0 6px; }
.q-bar { height: 8px; background: #e3dccb; border-radius: 5px; overflow: hidden; }
.q-bar > i { display: block; height: 100%; background: #5b8c5a; }
.q-foot { display: flex; justify-content: space-between; font-size: 12px; color: #5b4a32; margin-top: 4px; }
.q-reward { color: #b07a2e; font-weight: 700; }
.q-done { position: absolute; top: 10px; right: 12px; font-size: 12px; color: #5b8c5a; font-weight: 700; }

/* ---------- 事件流動畫 ---------- */
@keyframes summonIn { from { transform: translateY(14px) scale(.85); opacity: 0; } to { transform: none; opacity: 1; } }
.anim-summon { animation: summonIn .35s ease; }
@keyframes atkFlash { 0% { box-shadow: 0 0 0 0 rgba(176,58,46,0); } 30% { box-shadow: 0 0 0 4px rgba(176,58,46,.6); } 100% { box-shadow: none; } }
.anim-attacker { animation: atkFlash .3s; }
@keyframes hitShake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.anim-hit { animation: hitShake .3s; }
@keyframes deathFade { to { opacity: 0; transform: scale(.7); } }
.anim-death { animation: deathFade .45s forwards; }
@keyframes turnPulse { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }
.anim-turn { animation: turnPulse .3s; }

