/* main.css — 双人联机合作塔防 界面样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1c2b1c 0%, #0b140b 100%);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #e8e8e8;
  user-select: none;
}

#stage {
  position: fixed; left: 50%; top: 50%;
  width: 1280px; height: 720px;
  transform-origin: center center;
  overflow: hidden;
}

/* ============ 大厅 ============ */
#app {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.lobbyCard {
  width: 860px; padding: 38px 48px;
  background: linear-gradient(160deg, #2a3a2a, #1a241a);
  border: 2px solid #3c5a3c; border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  text-align: center;
}
.lobbyCard h1 { font-size: 36px; color: #ffd23f; margin-bottom: 6px; letter-spacing: 2px; }
.lobbyCard .sub { color: #9ab89a; margin-bottom: 26px; font-size: 15px; }
.lobbyCard input {
  width: 100%; padding: 11px 14px; margin: 6px 0;
  border: 2px solid #4a6a4a; border-radius: 10px;
  background: #0f180f; color: #fff; font-size: 16px; outline: none;
}
.lobbyCard input:focus { border-color: #ffd23f; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.joinRow { margin-top: 8px; }
.joinRow input { flex: 1; }
button {
  padding: 11px 20px; border: none; border-radius: 10px;
  background: #4a8f3f; color: #fff; font-size: 15px; font-weight: bold;
  cursor: pointer; transition: all .15s;
}
button:hover { background: #5cab4f; filter: brightness(1.05); }
button:disabled { background: #3a4a3a; color: #889; cursor: not-allowed; }
button.big { width: 100%; padding: 13px; font-size: 17px; margin-top: 10px; }

.roomHead { font-size: 20px; margin: 4px 0 14px; color: #9ab89a; }
#roomCode { color: #ffd23f; font-size: 30px; letter-spacing: 6px; font-weight: bold; }
#players { display: flex; gap: 12px; margin-bottom: 14px; }
#p1, #p2 { flex: 1; background: #0f180f; border: 2px solid #3c5a3c; border-radius: 10px; padding: 10px; font-size: 13px; min-height: 64px; }
.pl b { color: #fff; }
.pl .hname { display: inline-block; margin-left: 4px; font-weight: bold; }
.pl .ok { color: #5aff7a; margin-left: 6px; }
.pl .hint { color: #889; font-size: 12px; }
.pl .warn { color: #ff6a5a; margin-left: 6px; }
.pl.offline { opacity: .5; }
.empty { color: #556; font-size: 12px; }

.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-bottom: 20px; }
.settings label { font-size: 14px; color: #9ab89a; text-align: left; display: block; white-space: nowrap; }
.settings select {
  width: 100%; padding: 8px 10px; margin-top: 4px;
  background: #0f180f; color: #fff; border: 2px solid #3c5a3c; border-radius: 8px; font-size: 14px;
}
.settings label.locked { opacity: .5; }

.heroPick { display: flex; gap: 16px; margin-bottom: 18px; }
.hcard {
  flex: 1; min-width: 0; padding: 18px 14px; border: 2px solid #3c5a3c; border-radius: 14px;
  background: #0f180f; cursor: pointer; transition: all .15s; text-align: center;
}
.hcard:hover { border-color: #7ad7ff; transform: translateY(-2px); }
.hcard.chosen { border-color: #ffd23f; box-shadow: 0 0 16px rgba(255,210,63,.4); }
.hcard .hIcon { font-size: 42px; }
.hcard b { display: block; font-size: 19px; margin: 6px 0; white-space: nowrap; }
.hcard span { display: block; color: #9ab89a; font-size: 13px; white-space: nowrap; }
.hcard small { color: #889; font-size: 12px; white-space: nowrap; }
.tip { margin-top: 10px; color: #778; font-size: 12px; }

#toast {
  position: absolute; top: 30px; left: 50%; transform: translateX(-50%);
  background: rgba(20,20,20,.92); color: #ff6a5a; font-weight: bold;
  padding: 10px 22px; border-radius: 20px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 60;
  border: 1px solid #ff6a5a55;
}
#toast.show { opacity: 1; }

/* ============ 对局 ============ */
#game { position: absolute; inset: 0; display: none; background: #0b140b; }

canvas#world { position: absolute; inset: 0; width: 1280px; height: 720px; }

#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 56px;
  display: flex; align-items: center; gap: 16px; padding: 0 14px;
  background: rgba(10,16,10,.85); border-bottom: 2px solid #3c5a3c;
  font-size: 15px; z-index: 20;
}
.tItem { color: #fff; }
.tItem span { font-weight: bold; margin-left: 2px; }
.tItem:nth-child(1) span { color: #ffd23f; }
.tItem:nth-child(2) span { color: #ff9de2; }
.tItem:nth-child(3) span { color: #7ad7ff; }
.tItem:nth-child(4) span { color: #ff8a8a; }

.crystalBox { display: flex; align-items: center; gap: 6px; }
.crystalBox .zTag { font-weight: bold; color: #7ad7ff; }
.crystalBox.right .zTag { color: #ff9d7a; }
.hpWrap { width: 90px; height: 14px; background: #222; border: 1px solid #3c6; border-radius: 7px; overflow: hidden; }
.hpWrap div { height: 100%; background: linear-gradient(90deg,#2aff6a,#b4ff5a); width: 100%; transition: width .2s; }
#hpA, #hpB { font-size: 12px; color: #aaa; }

.phaseInfo { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; }
#phaseLabel { font-size: 14px; font-weight: bold; color: #ffd23f; }
#phaseTime { font-size: 13px; color: #fff; }

#bottombar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100px;
  display: flex; align-items: center; gap: 18px; padding: 6px 14px;
  background: rgba(10,16,10,.9); border-top: 2px solid #3c5a3c; z-index: 20;
}
.buildCol { flex: 1; min-width: 0; }
#buildHint { font-size: 12px; color: #9ab89a; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#buildSlots { display: flex; gap: 7px; flex-wrap: nowrap; overflow: hidden; }
.slot {
  flex: 1 1 0; min-width: 0; max-width: 78px; height: 76px; border-radius: 10px;
  background: #162316; border: 2px solid #3c5a3c; text-align: center;
  cursor: pointer; position: relative; transition: all .12s; overflow: hidden;
}
.slot:hover { border-color: #7ad7ff; transform: translateY(-2px); }
.slot.active { border-color: #ffd23f; box-shadow: 0 0 12px rgba(255,210,63,.5); }
.slot.poor { opacity: .55; }
.slot .slotColor { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.slot .slotIcon { font-size: 24px; line-height: 34px; }
.slot .slotName { font-size: 11px; color: #eee; white-space: nowrap; }
.slot .slotCost { font-size: 10px; color: #ffd23f; }
.slot .slotKey { position: absolute; top: 2px; right: 5px; font-size: 10px; color: #9ab89a; background: rgba(0,0,0,.4); border-radius: 4px; padding: 1px 4px; }

.heroCol { display: flex; align-items: center; gap: 8px; }
#heroName { font-size: 13px; color: #7ad7ff; font-weight: bold; width: 60px; }
.herohp { width: 70px; height: 8px; background: #222; border-radius: 4px; overflow: hidden; }
.herohp div { height: 100%; background: #5aff7a; }
#heroHp { font-size: 11px; color: #aaa; }
.skill { position: relative; width: 62px; height: 62px; padding: 0; border-radius: 12px; background: #20303a; border: 2px solid #3a6a8a; overflow: hidden; }
.skill:hover { border-color: #7ad7ff; }
.skill .sName { font-size: 12px; font-weight: bold; color: #fff; }
.skill .cd {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7); font-size: 18px; color: #ffd23f; font-weight: bold; opacity: 0;
}

.opCol { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.opCol button { font-size: 13px; padding: 8px 14px; }
.recruitRow { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #9ab89a; }
.recruitRow button { background: #4a5a9f; padding: 6px 10px; font-size: 12px; }
.costHint { font-size: 11px; color: #778; }

#chat {
  position: absolute; left: 8px; bottom: 108px; width: 330px; height: 220px;
  display: flex; flex-direction: column; z-index: 25;
  background: rgba(10,16,10,.7); border-radius: 10px; padding: 8px;
  pointer-events: none;
}
#calloutRow { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; pointer-events: auto; }
.callout { font-size: 11px; padding: 4px 8px; border-radius: 12px; background: #2a3a4a; }
#chatList { flex: 1; overflow-y: auto; font-size: 12px; line-height: 1.7; }
.cl { color: #ddd; }
.cl b { color: #7ad7ff; }
.cl.sys { color: #ffd23f; }
.chatInputRow { display: flex; gap: 4px; pointer-events: auto; }
.chatInputRow input { flex: 1; font-size: 12px; padding: 6px 8px; background: #0f180f; border: 1px solid #3c5a3c; border-radius: 8px; color: #fff; }
.chatInputRow button { font-size: 12px; padding: 6px 12px; }

#phaseBanner {
  position: absolute; top: 70px; left: 50%; transform: translateX(-50%);
  font-size: 34px; font-weight: bold; text-shadow: 0 2px 10px rgba(0,0,0,.9);
  opacity: 0; transition: opacity .3s; z-index: 40; pointer-events: none; text-align: center;
}
#phaseBanner.show { opacity: 1; }

#dcBanner {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(120,20,20,.9); color: #fff; padding: 8px 20px;
  border-radius: 16px; font-size: 14px; z-index: 45;
}

#towerPanel {
  position: absolute; z-index: 30; width: 190px; padding: 12px;
  background: rgba(10,16,10,.94); border: 2px solid #ffd23f; border-radius: 12px;
  display: none; box-shadow: 0 8px 30px rgba(0,0,0,.6);
}
#panelName { font-size: 15px; font-weight: bold; color: #ffd23f; margin-bottom: 4px; }
#panelRole { font-size: 12px; color: #9ab89a; margin-bottom: 10px; }
#towerPanel button { display: block; width: 100%; margin: 5px 0; font-size: 13px; padding: 8px; }
#panelClose { position: absolute; top: 4px; right: 4px; width: 28px !important; padding: 2px !important; background: #333; }

.teamUltBox { display: flex; align-items: center; gap: 8px; }
.teamUltBox .tuLabel { font-size: 12px; color: #ff8a3f; white-space: nowrap; }
.tuBar { width: 120px; height: 14px; background: #222; border: 1px solid #ff8a3f; border-radius: 7px; overflow: hidden; }
.tuBar div { height: 100%; width: 0%; background: #ff8a3f; transition: width .2s; }
.teamUltBox button { padding: 6px 12px; font-size: 12px; background: #5a3a2a; border: 1px solid #ff8a3f; min-width: 58px; }
.teamUltBox button:not(:disabled) { background: #c96a2f; color: #fff; }

.uiBtns { display: flex; gap: 6px; margin-left: 10px; }
.uiBtns button { width: 34px; height: 34px; padding: 0; font-size: 16px; background: #2a3a2a; border: 1px solid #3c5a3c; }
.uiBtns button:hover { border-color: #7ad7ff; filter: brightness(1.2); }

#codex {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.65); z-index: 55;
}
.codexCard {
  width: 740px; max-height: 86%; overflow-y: auto;
  background: rgba(16,24,16,.97); border: 2px solid #ffd23f; border-radius: 16px; padding: 18px 22px;
}
.codexHead { font-size: 18px; font-weight: bold; color: #ffd23f; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.codexHead button { padding: 4px 14px; background: #3a4a3a; font-size: 15px; }
#codexList { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cxItem { display: flex; gap: 10px; background: #0f180f; border: 1px solid #3c5a3c; border-radius: 10px; padding: 10px; }
.cxIcon { width: 44px; height: 44px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 26px; flex-shrink: 0; }
.cxBody { font-size: 13px; }
.cxBody b { color: #fff; }
.cxDesc { color: #9ab89a; font-size: 12px; margin-top: 2px; }
.cxUp { color: #ffd23f; font-size: 11px; margin-top: 2px; }

#gameover {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.75); z-index: 50;
}
.goCard { text-align: center; padding: 40px 60px; background: rgba(20,20,20,.95); border-radius: 20px; border: 2px solid #ffd23f; }
#goTitle { font-size: 44px; font-weight: bold; color: #ffd23f; margin-bottom: 12px; }
#goSub { font-size: 18px; color: #ddd; margin-bottom: 10px; }
#goReplay { font-size: 14px; color: #9ab89a; }
