/* ===== style.css =====
   祕法王國：深藍夜色 + 金色點綴的中世紀魔法風。 */

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

:root {
  --bg: #0b1020; --card: #141b33; --card-hover: #1b2444;
  --ink: #e8e6df; --ink-dim: #9aa3bf; --gold: #d4b26a; --line: #2a3457;
  --good: #7ec87e; --bad: #e07a7a;
}

body {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% -20%, #1a2547 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: "Noto Serif TC", "PMingLiU", Georgia, serif;
  padding: 10px 12px 30px;
  overflow-x: hidden;
}
a { color: var(--gold); text-decoration: none; }

/* ===== 頂部資源列 ===== */
#top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 14px; margin-bottom: 10px; position: sticky; top: 6px; z-index: 20;
}
#top .title { font-weight: 600; letter-spacing: .15em; color: var(--gold); margin-right: 6px; white-space: nowrap; }
.resItem { font-size: .92rem; white-space: nowrap; }
.resItem small { color: var(--ink-dim); font-size: .75rem; }
#taxBtn {
  margin-left: auto; background: linear-gradient(180deg, #e8c87e, #c8a250); color: #2a2008;
  border: none; border-radius: 8px; padding: 7px 16px; font-family: inherit; font-weight: 700;
  font-size: .95rem; cursor: pointer; letter-spacing: .05em; white-space: nowrap;
}
#taxBtn:active { transform: scale(.96); }
#homeLink { font-size: .8rem; color: var(--ink-dim); white-space: nowrap; }

/* ===== 主版面 ===== */
#wrap { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
#mapBox { flex: 1 1 540px; min-width: 300px; }
#map { width: 100%; display: block; border: 1px solid var(--line); border-radius: 10px; background: #152218; }
#panel {
  flex: 1 1 340px; min-width: 300px; max-width: 520px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px 12px;
}

/* ===== 分頁 ===== */
#tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
#tabs button {
  flex: 1; background: transparent; border: 1px solid var(--line); color: var(--ink-dim);
  border-radius: 7px; padding: 6px 4px; font-family: inherit; font-size: .85rem; cursor: pointer;
  white-space: nowrap; position: relative;
}
#tabs button.on { background: var(--card-hover); color: var(--gold); border-color: var(--gold); }
/* 有事情可做時點一顆金點（例如城堡到了可傳承的等級） */
#tabs button.badge::after {
  content: ""; position: absolute; top: 3px; right: 4px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
  box-shadow: 0 0 6px var(--gold); animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
#tabBody { min-height: 300px; }

/* ===== 列表列 ===== */
.row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px;
  border: 1px solid var(--line); margin-bottom: 6px; background: rgba(0, 0, 0, .15);
}
.row .ic { font-size: 1.3rem; width: 30px; text-align: center; flex-shrink: 0; }
.row .info { flex: 1; min-width: 0; }
.row .info b { font-size: .92rem; }
.row .info .sub { font-size: .76rem; color: var(--ink-dim); line-height: 1.5; }
.row .lv { color: var(--gold); font-size: .8rem; margin-left: 4px; }

.btn {
  background: var(--card-hover); border: 1px solid var(--gold); color: var(--gold);
  border-radius: 7px; padding: 5px 10px; font-family: inherit; font-size: .8rem; cursor: pointer;
  white-space: nowrap; flex-shrink: 0;
}
.btn:hover { background: #243058; }
.btn:disabled { border-color: var(--line); color: #5a6483; cursor: default; background: transparent; }
.btn.small { padding: 3px 8px; font-size: .82rem; }
.btn.small small { font-size: .7rem; opacity: .8; margin-left: 2px; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.on { background: var(--gold); color: #2a2008; }

.hint { font-size: .78rem; color: var(--ink-dim); line-height: 1.7; margin: 4px 2px 8px; }
.sect { margin: 12px 2px 6px; font-size: .85rem; color: var(--gold); letter-spacing: .15em; }
.costOk { color: var(--good); }
.costNo { color: var(--bad); }
.warn { color: var(--bad); }
.gold { color: var(--gold); }
.dim { color: #6b7599; }

/* ===== 日誌 ===== */
#log {
  margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px;
  font-size: .76rem; color: var(--ink-dim); line-height: 1.8; max-height: 110px; overflow-y: auto;
}
#log .new { color: var(--ink); }

/* ===== 遮罩層 ===== */
.ov {
  position: fixed; inset: 0; background: rgba(5, 8, 18, .82); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.hidden { display: none !important; }
.box {
  background: var(--card); border: 1px solid var(--gold); border-radius: 12px;
  padding: 20px 22px; max-width: 560px; width: 100%; max-height: 92vh; overflow-y: auto;
}
.box.wide { max-width: 940px; }
.box h2 { color: var(--gold); font-size: 1.15rem; letter-spacing: .1em; margin-bottom: 10px; }
.box p { font-size: .88rem; line-height: 1.8; margin-bottom: 8px; }
.box textarea {
  width: 100%; height: 90px; background: #0d1226; color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px; font-size: .75rem; font-family: monospace; resize: vertical;
}
.boxBtns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.boxBtns.tight { margin-top: 4px; margin-bottom: 10px; }
.offBody { font-size: .9rem; line-height: 2; }

/* ===== 戰前部署 ===== */
.terrCard {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: rgba(0, 0, 0, .2);
}
.terrCard .tIc { font-size: 1.6rem; }
.terrCard .sub { font-size: .78rem; color: var(--ink-dim); line-height: 1.6; }

.uchip {
  display: inline-block; background: rgba(0, 0, 0, .3); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 8px; font-size: .88rem; white-space: nowrap; margin: 0 5px 5px 0;
}
.uchip small { color: var(--ink-dim); font-size: .7rem; margin-left: 5px; }

.dpSum {
  margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line);
  font-size: .86rem; line-height: 1.8;
}

/* 排別的三段按鈕 */
.seg { display: inline-flex; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segb {
  background: transparent; border: none; border-right: 1px solid var(--line);
  color: var(--ink-dim); font-family: inherit; font-size: .74rem;
  padding: 3px 9px; cursor: pointer;
}
.segb:last-child { border-right: none; }
.segb:hover { background: var(--card-hover); }
.segb.on { background: var(--gold); color: #2a2008; font-weight: 700; }

/* 陣型預覽 */
.formBox {
  border: 1px solid var(--line); border-radius: 8px;
  background: rgba(0, 0, 0, .2); padding: 8px 10px 4px;
}
.fRow { display: flex; align-items: baseline; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.fLb {
  flex-shrink: 0; width: 3.2em; font-size: .78rem; color: var(--gold);
  letter-spacing: .1em;
}
.formBox .hint { margin: 2px 0 4px; }

/* ===== 戰場 ===== */
#fieldWrap { position: relative; margin: 6px 0; }
#field {
  width: 100%; display: block; border: 1px solid var(--line); border-radius: 8px;
  background: #16281a;
}

/* 指令橫幅：真實時間播放，不隨 ×4 調速加快 */
.banner {
  position: absolute; left: 50%; top: 16%;
  transform: translateX(-50%);
  padding: 7px 20px; border-radius: 10px;
  background: rgba(20, 27, 51, .9); border: 1px solid var(--gold);
  color: var(--gold); font-size: 1.15rem; letter-spacing: .12em;
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 0 18px rgba(212, 178, 106, .35);
  animation: bannerIn 1.1s ease-out forwards;
}
.banner small { font-size: .68rem; color: var(--ink-dim); letter-spacing: 0; }
@keyframes bannerIn {
  0%   { opacity: 0; transform: translateX(-50%) translateY(-16px) scale(.9); }
  18%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  72%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px) scale(1); }
}
.hpWrap { margin: 6px 0; }
.hpWrap .lb { font-size: .78rem; color: var(--ink-dim); margin-bottom: 3px; display: flex; justify-content: space-between; }
.hpBar { height: 12px; background: #0d1226; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.hpBar i { display: block; height: 100%; transition: width .2s linear; }
#pHpFill { background: linear-gradient(90deg, #5a9e5a, #7ec87e); }
#eHpFill { background: linear-gradient(90deg, #a05050, #e07a7a); }

/* 戰術指令列 */
.tacBar { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tac {
  flex: 1 1 110px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: var(--card-hover); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 6px 4px; font-family: inherit; cursor: pointer; line-height: 1.4;
}
.tac .tIc { font-size: 1.15rem; }
.tac b { font-size: .82rem; }
.tac small { font-size: .7rem; color: var(--ink-dim); }
.tac:hover:not(.off) { border-color: var(--gold); }
.tac:active:not(.off) { transform: scale(.96); background: #37437a; }
.tac.on { border-color: var(--gold); background: #2c3660; box-shadow: 0 0 8px rgba(212, 178, 106, .35); }
/* 不可用時仍要能點 —— 點下去會說明原因，而不是靜默失效 */
.tac.off { opacity: .42; }

#bResult { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
#bResult .big { font-size: 1.3rem; letter-spacing: .2em; margin-bottom: 8px; }
#bResBody { font-size: .86rem; line-height: 1.9; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
