/* [claude code] 2026-08-17 Phase 1:版面
 *
 * 🔴 尺寸固定原則:任何「內容數量 / 文字長度會變」的區塊都要先佔好位。
 * 會變的數字用 tabular-nums + min-width、可能為空的區塊給 min-height ——
 * 畫面一抖,使用者的手指就會點到跑掉的目標。
 */

:root {
  --bg: #14100c;
  --panel: rgba(28, 23, 18, 0.92);
  --panel-solid: #1d1813;
  --line: #3a3128;
  --ink: #ece3d6;
  --mute: #a79781;
  --accent: #c9a227;
  --accent-ink: #1a1410;
  --danger: #d1503f;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

.screen { position: fixed; inset: 0; overflow: auto; }
[hidden] { display: none !important; }

/* ── 按鈕 ───────────────────────────────────────────── */

.btn {
  border: 1px solid var(--line);
  background: #241d16;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  min-width: 84px;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #2f261d; border-color: #55483a; }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: #e3bb3d; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: #dcb531; }
.btn.ghost { background: transparent; min-width: 0; padding: 6px 10px; }

/* ── 大廳 ───────────────────────────────────────────── */

#lobby {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 28px 20px 20px;
  max-width: 780px;
  margin: 0 auto;
}

.lobby-head h1 { margin: 0; font-size: 30px; letter-spacing: 3px; }
.lobby-head h1 .sub { font-size: 17px; color: var(--accent); letter-spacing: 2px; margin-left: 8px; }
.lobby-head .tag { margin: 6px 0 0; color: var(--mute); font-size: 13px; letter-spacing: 1px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 15px; color: var(--accent); letter-spacing: 2px; }

.list { display: flex; flex-direction: column; gap: 10px; min-height: 72px; }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #201a14;
}
.row-main { flex: 1; min-width: 0; }
.row-main b { display: block; font-size: 15px; }
.row-main small { display: block; color: var(--mute); font-size: 12px; margin-top: 3px; line-height: 1.5; }

.lobby-foot {
  display: flex;
  justify-content: space-between;
  color: var(--mute);
  font-size: 12px;
  padding: 0 4px 8px;
}

/* ── 戰場 ───────────────────────────────────────────── */

#battle { background: #0f0c09; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hud-bar {
  position: absolute;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(#14100caa, #14100c00);
  pointer-events: none;
}
.hud-bar > * { pointer-events: auto; }
.hud-bar.bottom {
  top: auto; bottom: 0;
  background: linear-gradient(#14100c00, #14100cdd);
  justify-content: space-between;
}
#topBar { top: 0; }

.turn {
  flex: 1;
  text-align: center;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 120px; /* 「第 9 回合」→「第 10 回合」不要讓兩側按鈕位移 */
}

.hint {
  color: var(--mute);
  font-size: 13px;
  min-height: 20px; /* 空的時候位置也要留著 */
  flex: 1;
}

/* 側邊:選中部隊的資訊與行動 */
.side {
  position: absolute;
  top: 54px;
  right: 14px;
  width: 232px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: blur(3px);
}
.unit-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.unit-head .name { font-size: 19px; font-weight: 700; }
.unit-head .arms { font-size: 12px; color: var(--mute); }

.bars { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.bar { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.bar .lab { color: var(--mute); width: 30px; flex: none; }
.bar .track { flex: 1; height: 9px; background: #0d0a07; border-radius: 5px; overflow: hidden; }
.bar .track i { display: block; height: 100%; background: #5ad06a; transition: width .25s; }
.bar .track.tp i { background: #63a7ff; }
.bar .num {
  font-variant-numeric: tabular-nums;
  color: var(--mute);
  min-width: 84px;  /* 8000 / 8000 的最大寬度 —— 數字變動不要讓長條伸縮 */
  text-align: right;
  flex: none;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--mute);
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.stats span { font-variant-numeric: tabular-nums; min-width: 44px; }

.actions { display: flex; flex-direction: column; gap: 7px; min-height: 120px; }
.act {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #241d16;
  cursor: pointer;
  text-align: left;
  transition: background .15s, border-color .15s;
}
.act:hover:not(:disabled) { background: #33291f; border-color: var(--accent); }
.act:disabled { opacity: .38; cursor: not-allowed; }
.act b { font-size: 14px; }
.act small { color: var(--mute); font-size: 11px; }
.blocked { margin: 0; color: var(--mute); font-size: 13px; }

/* hover 預覽卡 —— 數字全部來自 server 的 plan */
.preview {
  position: absolute;
  left: 14px;
  bottom: 58px;
  width: 218px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 13px;
  font-size: 13px;
  backdrop-filter: blur(3px);
}
.pv-name { font-weight: 700; margin-bottom: 7px; }
.pv-name small { color: var(--mute); font-weight: 400; margin-left: 6px; font-size: 11px; }
.pv-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; color: var(--mute); }
.pv-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pv-row.warn b { color: #ff9a5a; }

/* 結算 */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 8, 6, .78);
}
.result-card {
  background: var(--panel-solid);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 30px 40px;
  text-align: center;
  min-width: 268px;
}
.result-card h2 { margin: 0 0 8px; font-size: 27px; letter-spacing: 3px; }
.result-card p { margin: 0 0 20px; color: var(--mute); font-size: 13px; min-height: 20px; }

/* 提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  background: #2b221a;
  border: 1px solid var(--accent);
  color: var(--ink);
  padding: 9px 18px;
  border-radius: 20px;
  font-size: 13px;
  z-index: 50;
  max-width: 82vw;
  text-align: center;
}

/* 窄螢幕:側邊面板改成貼在底部,不要蓋住棋盤 */
@media (max-width: 720px) {
  .side {
    top: auto;
    bottom: 52px;
    right: 8px;
    left: 8px;
    width: auto;
  }
  .actions { flex-direction: row; flex-wrap: wrap; min-height: 0; }
  .act { flex: 1 1 44%; }
  .preview { bottom: auto; top: 52px; left: 8px; width: 200px; }
}
