* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #0b131d;
  color: #dbe6f5;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: 18px 20px 28px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(120, 170, 220, 0.18);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #4ad991;
  box-shadow: 0 0 10px rgba(74, 217, 145, 0.8);
  align-self: center;
}

.title { font-size: 18px; font-weight: 700; letter-spacing: 0.5px; }
.sub { font-size: 12.5px; color: #7d90a8; }

.meta { display: flex; align-items: center; gap: 12px; }
#round { font-size: 13px; color: #9fb3ca; }

#endTurn {
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid rgba(90, 160, 255, 0.5);
  background: rgba(61, 126, 232, 0.16);
  color: #cfe4ff;
  cursor: pointer;
  transition: 0.15s;
}
#endTurn:hover:not(:disabled) { background: rgba(61, 126, 232, 0.32); }
#endTurn:disabled { opacity: 0.35; cursor: not-allowed; }

.mini-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid rgba(120, 170, 220, 0.35);
  background: rgba(22, 34, 50, 0.6);
  color: #9fb3ca;
  cursor: pointer;
  transition: 0.15s;
}
.mini-btn:hover { color: #dbe6f5; border-color: rgba(120, 170, 220, 0.6); }

/* ---------- 技能栏 ---------- */
.skill-btn {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
  border-radius: 7px;
  border: 1px solid rgba(70, 240, 205, 0.45);
  background: rgba(60, 220, 190, 0.10);
  color: #bff0e2;
  cursor: pointer;
  transition: 0.12s;
}
.skill-btn:hover:not(.out) { background: rgba(60, 220, 190, 0.22); }
.skill-btn.out { opacity: 0.35; cursor: not-allowed; }
.skill-btn.aiming {
  border-color: #46f0cd;
  background: rgba(60, 220, 190, 0.3);
  box-shadow: 0 0 10px rgba(70, 240, 205, 0.4);
}
.skill-left { float: right; color: #7d90a8; font-weight: 400; }
.skill-desc { font-size: 11.5px; color: #8b9fb6; line-height: 1.5; }

/* ---------- 主区 ---------- */
.stage {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

#board {
  display: block;
  border-radius: 10px;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  max-width: 100%;
}

.side {
  width: 260px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.panel {
  background: rgba(22, 34, 50, 0.75);
  border: 1px solid rgba(120, 170, 220, 0.14);
  border-radius: 10px;
  padding: 12px 14px;
}

.panel.grow { flex: 1; min-height: 160px; display: flex; flex-direction: column; }

.panel-title {
  font-size: 11.5px;
  letter-spacing: 1px;
  color: #6f86a0;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.hint {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: #9ad6c9;
  min-height: 20px;
  line-height: 1.5;
}

.tips {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: #8b9fb6;
  line-height: 1.75;
}
.tips li::marker { color: #3d7ee8; }

.log {
  margin: 0;
  flex: 1;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.65;
  color: #93a9c2;
  white-space: pre-wrap;
  font-family: inherit;
  max-height: 320px;
}

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12px;
  color: #8b9fb6;
}
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i {
  width: 12px; height: 12px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(255,255,255,0.12);
}

/* ---------- 整备面板 ---------- */
.prep-row { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px dashed rgba(120,170,220,0.15); }
.prep-row:last-child { border-bottom: none; }
.prep-name { font-size: 12.5px; margin-bottom: 6px; color: #cfe0f2; }
.prep-stats { color: #7d90a8; font-size: 11.5px; }
.prep-btns { display: flex; flex-direction: column; gap: 4px; }
.prep-btn {
  padding: 5px 9px;
  font-size: 12px;
  text-align: left;
  border-radius: 6px;
  border: 1px solid rgba(120,170,220,0.25);
  background: rgba(61,126,232,0.08);
  color: #cfe4ff;
  cursor: pointer;
  transition: 0.12s;
}
.prep-btn:hover { background: rgba(61,126,232,0.22); }
.prep-btn.on {
  border-color: rgba(74,217,145,0.7);
  background: rgba(74,217,145,0.14);
  color: #d9ffe9;
}

.start-btn {
  margin-top: 10px;
  width: 100%;
  padding: 9px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid rgba(74,217,145,0.6);
  background: rgba(74,217,145,0.16);
  color: #d9ffe9;
  cursor: pointer;
  transition: 0.15s;
}
.start-btn:hover { background: rgba(74,217,145,0.3); }

@media (max-width: 1180px) {
  .stage { flex-direction: column; }
  .side { width: 100%; }
  .panel.grow { min-height: 120px; }
  .log { max-height: 160px; }
}

/* 章节选择 chips（r8 · S1.4） */
.chip {
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid #3d7ee8;
  background: transparent;
  color: #8ab4ff;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.chip-ok { color: #7be38a; border-color: #2f7a4a; }
.chip-cur { background: #3d7ee8; color: #fff; }
.chip-lock { opacity: 0.35; cursor: not-allowed; border-color: #555; color: #888; }

/* ============ 手机浏览器适配（R18 · ≤900px 竖屏堆叠） ============ */
body { touch-action: manipulation; } /* 防双击缩放干扰战棋点选 */

@media (max-width: 900px) {
  /* 竖屏布局：canvas 在上占满宽，面板堆叠在下 */
  .stage { flex-direction: column; }
  .stage canvas { width: 100% !important; height: auto !important; display: block; margin: 0 auto; }
  aside.side { width: 100% !important; flex-direction: column; border-left: none; border-top: 1px solid #2a3a52; }
  header.topbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  header.topbar .brand span { font-size: 14px; }
  .topbar button { min-height: 44px; min-width: 44px; padding: 8px 12px; font-size: 14px; }
  .panel { padding: 10px 12px; }
  .panel-title { font-size: 13px; }
  button.skill-btn, button.prep-btn { min-height: 44px; font-size: 14px; }
  .chip { min-height: 38px; padding: 6px 14px; font-size: 13px; }
}

/* 竖屏提示横屏（战棋格子在小竖屏上过小） */
#rotateHint {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 9550;
  background: rgba(255, 179, 80, 0.95); color: #1a0e02;
  text-align: center; font-size: 13px; font-weight: 700; padding: 8px;
}
@media (orientation: portrait) and (max-width: 700px) {
  #rotateHint { display: block; }
}
