/* ============================================================
 * style.css —— 全部样式（独立抽离，不写在 HTML/JS 里）
 * 国风塔防合成界面的整体骨架样式。
 * ============================================================ */

/* ---------- 基础重置 ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --wp-bg: #20232a;
  --wp-panel: #2b2f3a;
  --wp-line: #3a4050;
  --gold: #ffd24d;
  --gold-dim: #a8893a;
  --red: #ff5a4d;
  --green-on: #57e06a;
}

html, body {
  height: 100%;
}

body {
  background: radial-gradient(1200px 600px at 50% -10%, #35404f, #1a1d24 70%);
  color: #e8e6df;
  font-family: 'GuoFeng', '仓耳周珂正大榜书', 'Microsoft YaHei', sans-serif;
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

/* ============================================================
 * 布局容器
 * ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------- 顶部信息栏 ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--wp-line);
  font-size: 15px;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

/* 暂停按钮 */
.btn-pause {
  font-family: inherit;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #5a6478;
  background: #2b303c;
  color: #dfe3ea;
  cursor: pointer;
}
.btn-pause:not(:disabled):hover { filter: brightness(1.2); }
.btn-pause:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
 * 开始页面（纯白简洁）
 * ============================================================ */
.start-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.start-inner { text-align: center; }
.start-logo {
  font-size: 64px;
  letter-spacing: 16px;
  color: #1a1a1a;
  margin-bottom: 12px;
  font-weight: bold;
}
.start-sub {
  font-size: 18px;
  letter-spacing: 6px;
  color: #888;
  margin-bottom: 48px;
}
.start-btn {
  font-family: inherit;
  font-size: 20px;
  letter-spacing: 4px;
  padding: 14px 56px;
  border-radius: 10px;
  border: 2px solid #1a1a1a;
  background: #ffffff;
  color: #1a1a1a;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.start-btn:hover { background: #1a1a1a; color: #ffffff; }
.start-tip {
  margin-top: 40px;
  font-size: 13px;
  color: #aaa;
  letter-spacing: 1px;
}

/* ============================================================
 * 暂停遮罩
 * ============================================================ */
.pause-box { text-align: center; }
.pause-title {
  font-size: 40px;
  color: #fff;
  letter-spacing: 10px;
  margin-bottom: 32px;
}

/* 游戏结束 */
.game-over-box {
  background: linear-gradient(165deg, #333a48, #232832);
  border: 1px solid var(--wp-line);
  border-top: 3px solid var(--red);
  border-radius: 14px;
  padding: 32px 48px;
  text-align: center;
}
.game-over-title {
  font-size: 36px;
  letter-spacing: 8px;
  color: #ff8a6a;
  margin-bottom: 20px;
}
.game-over-stats {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-bottom: 28px;
  font-size: 16px;
}
.game-over-stats .k { color: #9aa0ad; margin-right: 8px; }
.game-over-stats b { color: #fff; }

.gold-label b { color: var(--gold); font-size: 18px; margin-left: 4px; }

.stat-chip {
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 12px;
  border-radius: 999px;
  color: #c9c9d4;
  font-size: 13px;
}

/* 红心 */
#lives { display: flex; gap: 6px; font-size: 22px; }
#lives .heart { color: var(--red); text-shadow: 0 0 6px rgba(255,60,60,.5); }
#lives .heart.off { color: #555; filter: grayscale(1); text-shadow: none; }

/* 金币浮动提示 */
.gold-float {
  position: fixed;
  font-size: 15px;
  font-weight: bold;
  pointer-events: none;
  z-index: 120;
  text-shadow: 0 1px 2px #000;
  animation: float-up 0.7s ease-out forwards;
}
.gold-float.plus  { color: var(--gold); }
.gold-float.minus { color: var(--red); }

/* 屏幕中央提示（融合失败 / 金币不足等） */
.flash-hint {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translateX(-50%);
  padding: 8px 20px;
  background: rgba(20, 18, 14, 0.9);
  border: 1px solid var(--red);
  border-radius: 8px;
  color: #ffb3ab;
  font-size: 15px;
  z-index: 130;
  pointer-events: none;
  animation: hint-pop 1.2s ease-out forwards;
  white-space: nowrap;
}
@keyframes hint-pop {
  0%   { opacity: 0; transform: translate(-50%, 6px); }
  15%  { opacity: 1; transform: translate(-50%, 0); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}
@keyframes float-up {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-28px); opacity: 0; }
}

/* ============================================================
 * 主区域（地图 + 详情面板 + 浮动层）
 * ============================================================ */
#stage-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#map-host { position: relative; }

#map-canvas {
  display: block;
  border: 2px solid rgba(255, 210, 77, 0.25);
  border-radius: 6px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
  /* 等比缩放：高度撑满舞台仍按比例 */
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

/* 屏幕中央浮层（羁绊名 / 特效） */
#float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

/* ---------- 棋子详情面板 ---------- */
#detail-panel {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;               /* 高于棋子、羁绊框，低于拖拽提示 */
  width: 340px;
  max-width: 90%;
  background: linear-gradient(160deg, #333a48, #232832);
  border: 1px solid var(--wp-line);
  border-top: 2px solid var(--gold);
  border-radius: 10px;
  padding: 12px 16px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
  font-size: 14px;
}

.detail-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--wp-line);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.detail-title { font-size: 17px; font-weight: bold; color: var(--gold); }
.detail-color { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.detail-color.red   { background: rgba(255,90,77,.2); color: #ff8f80; }
.detail-color.black { background: rgba(140,120,255,.2); color: #b4a6ff; }
.detail-close {
  margin-left: auto;
  cursor: pointer;
  color: #999;
  font-size: 15px;
}
.detail-close:hover { color: #fff; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  margin: 4px 0;
}
.detail-grid > div { display: flex; justify-content: space-between; }
.detail-grid .k { color: #9aa0ad; }
.detail-grid b { color: #fff; }

.detail-exp { margin-top: 8px; }
.exp-label { font-size: 11px; color: #aab; margin-bottom: 3px; }
.exp-track {
  height: 8px;
  background: rgba(255,255,255,.1);
  border-radius: 4px;
  overflow: hidden;
}
.exp-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #57e06a, #8aef6b);
  border-radius: 4px;
}
.detail-cap { margin-top: 8px; color: var(--gold); font-size: 12px; }

/* ============================================================
 * 商店
 * ============================================================ */
#shop {
  padding: 10px 16px 14px;
  background: rgba(0, 0, 0, 0.4);
  border-top: 1px solid var(--wp-line);
}

.shop-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.btn-refresh {
  background: linear-gradient(#4a4330, #35301f);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-family: inherit;
  font-size: 15px;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
}
.btn-refresh:disabled {
  filter: grayscale(0.8) brightness(0.6);
  cursor: not-allowed;
  color: #999;
  border-color: #555;
}
.btn-refresh:not(:disabled):hover { filter: brightness(1.15); }

.shop-hint { color: #8d93a0; font-size: 13px; }

#shop-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.shop-slot {
  min-height: 96px;
  border: 1px dashed #444c5c;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.shop-slot.empty { background: rgba(255,255,255,.015); }

.shop-card {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: #2f3440;
  border: 1px solid #4a5264;
  border-radius: 8px;
  padding: 4px 6px;
  position: relative;
  cursor: grab;
}
.shop-card:active { cursor: grabbing; }

/* 点击选中（待放置）的卡位高亮边框 */
.shop-card.selected {
  border: 2px solid var(--gold);
  box-shadow: 0 0 12px rgba(255, 210, 77, 0.7), inset 0 0 8px rgba(255, 210, 77, 0.18);
  transform: translateY(-2px);
}

/* ---------- 商店棋子卡的完整信息（Lv/名称居中/融合计数/经验条） ---------- */
.piece-card-fig {
  position: relative;
  width: 56px;
  height: 56px;
  pointer-events: none;
  font-family: 'GuoFeng', 'Microsoft YaHei', sans-serif;
}
.piece-card-fig .piece-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.piece-card-fig .piece-lv {
  position: absolute;
  top: 1px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  color: #fff;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}
.piece-card-fig .piece-name-center {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000;
  line-height: 1;
}
.piece-card-fig .piece-merge {
  position: absolute;
  bottom: 3px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  color: #ffd75e;
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}
.piece-card-fig .piece-expbar {
  position: absolute;
  bottom: -7px;
  left: 4px;
  right: 4px;
  height: 3px;
  background: rgba(0,0,0,0.55);
  border-radius: 2px;
  overflow: hidden;
}
.piece-card-fig .piece-expbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #57e06a, #8aef6b);
  border-radius: 2px;
}
.piece-card-fig .piece-cap {
  position: absolute;
  bottom: -16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 7px;
  color: #ffd24d;
  text-shadow: 0 0 2px #000;
}

.shop-card .card-img {
  height: 46px;
  object-fit: contain;
  pointer-events: none;
}
.shop-card .card-img.piece-img { height: 56px; width: 56px; }
.shop-card .card-name { font-size: 13px; color: #fff; }
.shop-card .card-name.spell-name { color: var(--gold); font-size: 14px; }
.shop-card .card-desc {
  font-size: 9px;
  color: #9aa0ad;
  text-align: center;
  line-height: 1.3;
  max-height: 26px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* 价格文字：金币足够白色，不足红色（由 JS 切换 poor 类） */
.card-price {
  font-size: 13px;
  font-weight: bold;
  color: #fff;
}
.card-price.poor { color: var(--red); }

/* 商店棋子卡：为经验条 / 上限文字留出下方空间 */
.shop-card.from-board,
.shop-card:has(.piece-card-fig) {
  padding-bottom: 16px;
}

.card-tier {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,.5);
  color: #ffd;
}
.tier-1 { box-shadow: inset 0 0 0 1px #6a8a5a; }
.tier-2 { box-shadow: inset 0 0 0 1px #5a7a9a; }
.tier-3 { box-shadow: inset 0 0 0 1px #8a5ad0; }

/* ============================================================
 * 开局增益选择
 * ============================================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.bonus-box {
  width: 720px;
  max-width: 92%;
  text-align: center;
}

.bonus-title {
  font-size: 30px;
  color: var(--gold);
  letter-spacing: 6px;
  margin-bottom: 18px;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
}

.bonus-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.bonus-card {
  background: linear-gradient(165deg, #333a48, #232832);
  border: 1px solid var(--wp-line);
  border-top: 3px solid var(--gold);
  border-radius: 12px;
  padding: 22px 16px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.bonus-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.bonus-card-name { font-size: 20px; color: var(--gold); margin-bottom: 10px; }
.bonus-card-desc { font-size: 13px; color: #c6c9d2; line-height: 1.6; }