/* ========================================================
   赵云与阿斗 - 汉字塔防 样式表
   ======================================================== */

/* ===== 基础重置与水墨古风 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --paper: #f7f2e8;
  --paper-dark: #e8dfd0;
  --brown: #8b5a3c;
  --brown-dark: #6b4226;
  --white-tile: #fffbf2;
  --ink: #2b2b2b;
  --red: #c0392b;
  --green: #27ae60;
  --gold: #d4a017;
  --shadow: rgba(0,0,0,0.25);
}
body {
  font-family: "Microsoft YaHei", "SimSun", "STKaiti", serif;
  background: linear-gradient(180deg, #e6ddd0 0%, #d4c8b8 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  color: var(--ink);
  user-select: none;
}
#gameContainer {
  width: 920px;
  background: var(--paper);
  border: 4px solid var(--brown-dark);
  border-radius: 12px;
  box-shadow: 0 8px 30px var(--shadow);
  padding: 16px;
  position: relative;
}

/* ===== 顶部信息栏 ===== */
#topBar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #eaddcf, #dccfb8);
  border: 2px solid var(--brown);
  border-radius: 8px;
}
#topBar h1 {
  font-size: 26px;
  letter-spacing: 4px;
  color: var(--brown-dark);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.6);
}
.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  font-weight: bold;
}
.mantou-icon { font-size: 22px; }
.heart { color: var(--red); font-size: 22px; }

/* ===== 地图区域 ===== */
#mapWrap {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  position: relative;
}
#entrance {
  width: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--red);
  font-size: 28px;
  font-weight: bold;
  line-height: 1;
}
#grid {
  display: grid;
  grid-template-columns: repeat(9, 64px);
  grid-template-rows: repeat(6, 64px);
  gap: 3px;
  background: var(--brown-dark);
  border: 3px solid var(--brown-dark);
  border-radius: 4px;
  position: relative;
}
.cell {
  width: 64px;
  height: 64px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 28px;
  font-weight: bold;
  transition: transform 0.1s, box-shadow 0.1s;
  cursor: default;
}
.cell.brown {
  background: linear-gradient(145deg, #a06b4a, #7a4e32);
  border: 2px solid var(--brown-dark);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}
/* 弯曲行军道路：敌人专属通道，不可部署卡牌 */
.cell.path {
  background: repeating-linear-gradient(45deg, #c9b17e, #c9b17e 9px, #bda76c 9px, #bda76c 18px);
  border: 2px solid #8a7648;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
.cell.white {
  background: var(--white-tile);
  border: 2px solid #d9cdb8;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.8);
}
.cell.drop-target {
  outline: 3px dashed var(--gold);
  outline-offset: -3px;
}
.cell.invalid {
  animation: shake 0.3s;
}

/* 阿斗区域 */
#adouPanel {
  width: 70px;
  height: 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f7f2e8, #eaddcf);
  border: 3px solid var(--brown-dark);
  border-radius: 8px;
  margin-left: 4px;
}
#adouHearts {
  display: flex;
  gap: 2px;
  margin-bottom: 6px;
}
#adouChar {
  font-size: 48px;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
}

/* ===== 卡牌通用 ===== */
.card {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 30px;
  font-weight: bold;
  cursor: grab;
  position: relative;
  box-shadow: 0 3px 6px var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
  background: linear-gradient(145deg, #fffbf2, #eaddcf);
  border: 2px solid #bfa885;
  color: var(--ink);
  font-family: "STKaiti", "KaiTi", serif;
}
.card:active { cursor: grabbing; transform: scale(1.05); }
.card.dragging { opacity: 0.4; }
.card .level-badge {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 11px;
  color: var(--red);
  font-family: "Microsoft YaHei", sans-serif;
}
.card .level-badge.hero-badge {
  color: #c0392b;
  font-weight: bold;
  background: rgba(255,255,255,0.7);
  border-radius: 3px;
  padding: 0 2px;
}
.card.fragment {
  color: #999;
  background: linear-gradient(145deg, #f0ece4, #d9d2c4);
  border-color: #b8b0a0;
}
.card.hero {
  color: var(--gold);
  background: linear-gradient(145deg, #fff8e1, #f0d878);
  border-color: var(--gold);
  text-shadow: 0 0 4px rgba(212,160,23,0.4);
  animation: heroGlow 2s infinite;
}
.card.tool {
  background: linear-gradient(145deg, #e8f4f8, #b8dce8);
  border-color: #6ba3b8;
}
.card.normal { color: #4a3728; }

/* 攻击瞬间脉冲动画：让哪张卡在打一目了然 */
.card.attacking {
  animation: attackPulse 0.3s ease-out;
}
@keyframes attackPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.22); box-shadow: 0 0 16px rgba(212,160,23,0.9); }
  100% { transform: scale(1); }
}
@keyframes heroGlow {
  0%, 100% { box-shadow: 0 0 6px rgba(212,160,23,0.4); }
  50% { box-shadow: 0 0 14px rgba(212,160,23,0.8); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ===== 手牌区 ===== */
#handSection {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
#campIcon {
  width: 56px;
  height: 56px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(145deg, #5a4a3a, #3a2a20);
  color: #f7f2e8;
  font-size: 30px;
  border-radius: 6px;
  border: 2px solid var(--brown-dark);
  box-shadow: 0 3px 6px var(--shadow);
}
#handSlots {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(180deg, #dccfb8, #c9bba0);
  border: 2px solid var(--brown);
  border-radius: 8px;
  min-width: 340px;
  min-height: 78px;
}
.hand-slot {
  width: 60px;
  height: 60px;
  border: 2px dashed #a89a80;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.hand-slot .card { width: 54px; height: 54px; font-size: 28px; }

/* ===== 控制区 ===== */
#controlBar {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 12px;
}
#recruitBtn {
  padding: 10px 32px;
  font-size: 22px;
  font-weight: bold;
  font-family: "STKaiti", "KaiTi", serif;
  color: #fff;
  background: linear-gradient(180deg, #5a6b7a, #3a4a5a);
  border: 3px solid #2a3a4a;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 0 #2a3a4a, 0 6px 10px var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#recruitBtn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2a3a4a, 0 2px 4px var(--shadow);
}
#recruitBtn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#recruitCost { font-size: 14px; margin-top: 2px; }

/* ===== 战斗日志 ===== */
#logPanel {
  height: 110px;
  overflow-y: auto;
  background: #2b2620;
  color: #e8dfd0;
  border: 2px solid var(--brown-dark);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.5;
}
#logPanel .log-entry { margin-bottom: 2px; }
#logPanel .log-wave { color: #f0d878; }
#logPanel .log-hero { color: #f0d878; }
#logPanel .log-enemy { color: #e74c3c; }
#logPanel .log-good { color: #2ecc71; }

/* ===== 弹窗 ===== */
#modalOverlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
#modalOverlay.show { display: flex; }
#modalBox {
  background: var(--paper);
  border: 4px solid var(--brown-dark);
  border-radius: 12px;
  padding: 32px 48px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  min-width: 320px;
}
#modalTitle { font-size: 36px; margin-bottom: 12px; font-family: "STKaiti", serif; }
#modalText { font-size: 18px; margin-bottom: 24px; color: #4a3728; }
#modalBtn {
  padding: 10px 28px;
  font-size: 18px;
  background: var(--brown);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: "Microsoft YaHei", sans-serif;
}
#modalBtn:hover { background: var(--brown-dark); }

/* ===== 敌人生成点箭头 ===== */
.arrow { font-size: 32px; color: var(--red); }

/* ===== 敌人样式（可点击查看信息） ===== */
.enemy {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  background: #c0392b;
  border: 2px solid #7a241a;
  box-shadow: 0 2px 5px rgba(0,0,0,0.4);
  z-index: 10;
  transition: none;
  pointer-events: auto;
  cursor: pointer;
}
/* 被击中闪白 */
.enemy.hit {
  filter: brightness(1.9) saturate(1.4);
  transform: scale(1.12);
}
/* Boss 敌人：更大、暗红底、金色边框、呼吸光晕 */
.enemy.boss {
  width: 52px;
  height: 52px;
  font-size: 13px;
  background: radial-gradient(circle, #8b0000 0%, #4a0000 100%);
  border: 3px solid #ffcc44;
  box-shadow: 0 0 16px rgba(255,68,68,0.6), 0 2px 8px rgba(0,0,0,0.6);
  animation: bossGlow 1.5s infinite;
}
@keyframes bossGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(255,68,68,0.5), 0 2px 6px rgba(0,0,0,0.5); }
  50%      { box-shadow: 0 0 26px rgba(255,204,68,0.8), 0 2px 8px rgba(0,0,0,0.6); }
}
.enemy.boss .hp-bar {
  width: 44px;
  top: -9px;
  left: 4px;
  height: 5px;
}
.enemy.boss .hp-fill {
  background: linear-gradient(90deg, #ff4444, #ffcc44);
}
.enemy .enemy-name {
  font-size: 12px;
  font-family: "Microsoft YaHei", sans-serif;
  white-space: nowrap;
  line-height: 1.1;
  text-align: center;
  display: block;
}
.enemy .hp-bar {
  position: absolute;
  top: -7px;
  left: 3px;
  width: 30px;
  height: 4px;
  background: #555;
  border-radius: 2px;
  overflow: hidden;
}
.enemy .hp-fill {
  height: 100%;
  background: #2ecc71;
  transition: width 0.1s;
}

/* ===== 投射物：加大尺寸与光晕，飞行更清晰 ===== */
.projectile {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe9a0 0%, #d4a017 70%);
  box-shadow: 0 0 10px 3px rgba(212,160,23,0.75);
  z-index: 20;
  pointer-events: none;
}
.projectile.hero-shot {
  background: radial-gradient(circle, #ffd0c0 0%, #e74c3c 70%);
  box-shadow: 0 0 12px 4px rgba(231,76,60,0.8);
}

/* ===== 伤害飘字 ===== */
.damage-num {
  position: absolute;
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 2px #000;
  z-index: 30;
  pointer-events: none;
  animation: floatUp 0.8s ease-out forwards;
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px) scale(1.15); }
}

/* ===== 点击信息浮窗 ===== */
#infoPopup {
  position: fixed;
  display: none;
  min-width: 200px;
  max-width: 260px;
  background: #2b2620;
  color: #f0e8d8;
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.7;
  z-index: 2000;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
  pointer-events: auto;
}
#infoPopup .ip-title {
  font-size: 17px;
  font-weight: bold;
  color: var(--gold);
  border-bottom: 1px solid rgba(212,160,23,0.4);
  padding-bottom: 4px;
  margin-bottom: 6px;
  font-family: "STKaiti", serif;
}
#infoPopup .ip-lv { color: #e74c3c; font-size: 14px; }
#infoPopup .ip-row { display: flex; justify-content: space-between; gap: 12px; }
#infoPopup .ip-dim { color: #9a8f7d; }
#infoPopup .ip-hero { color: #f0d878; }
#infoPopup .ip-enemy { color: #ff8a7a; }

/* ===== 提示文字 ===== */
#hint {
  text-align: center;
  font-size: 13px;
  color: #6b5a48;
  margin-top: 6px;
}
/* ========================================================
   移动端竖屏适配 + 触摸拖拽 + 铲子图标（追加）
   ======================================================== */

/* 响应式容器：PC 920px，手机满宽 */
#gameContainer { width: min(920px, 100%); max-width: 920px; }

/* 网格缩放容器：#grid 用 transform 缩放，坐标系不变 */
#gridScaler { position: relative; overflow: visible; display: inline-block; width: 600px; height: 399px; }
#grid { transform-origin: top left; }

/* 铲子 SVG 样式 */
.shovel-icon { width: 72%; height: 72%; display: block; pointer-events: none; }

/* 触摸/鼠标统一：禁用浏览器默认滚动/拖拽手势干扰 */
.card, .hand-slot, .cell, .enemy, .drag-ghost {
  touch-action: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* 拖拽幻影：跟随手指/鼠标，不拦截事件 */
#dragGhost {
  position: fixed;
  display: none;
  z-index: 5000;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.08);
  opacity: 0.95;
  box-shadow: 0 10px 22px rgba(0,0,0,0.45);
  border-radius: 6px;
}
#dragGhost.shovel-icon { pointer-events: none; }

/* 竖屏手机适配 */
@media (max-width: 760px) {
  body { padding: 6px; align-items: flex-start; min-height: 100vh; }
  #gameContainer { padding: 8px; border-width: 3px; }
  #topBar { padding: 6px 8px; margin-bottom: 8px; flex-wrap: wrap; gap: 6px; }
  #topBar h1 { font-size: 18px; letter-spacing: 2px; }
  .stat { font-size: 13px; gap: 4px; }
  .mantou-icon, .heart { font-size: 16px; }
  #mapWrap { gap: 4px; margin-bottom: 10px; }
  #entrance { width: 16px; font-size: 16px; }
  #entrance .arrow { font-size: 16px; }
  #entrance > div:last-child { font-size: 11px; }
  #adouPanel { width: 42px; height: 92px; margin-left: 2px; }
  #adouHearts { gap: 1px; margin-bottom: 3px; }
  #adouHearts .heart { font-size: 12px; }
  #adouChar { font-size: 30px; }
  #handSection { gap: 6px; margin-bottom: 8px; flex-wrap: wrap; justify-content: center; }
  #campIcon { width: 40px; height: 40px; font-size: 20px; }
  #handSlots { gap: 5px; padding: 6px; min-width: 0; min-height: 56px; }
  .hand-slot { width: 44px; height: 44px; }
  .hand-slot .card { width: 90%; height: 90%; font-size: 22px; }
  #controlBar { margin-bottom: 8px; }
  #recruitBtn { padding: 8px 18px; font-size: 16px; }
  #recruitCost { font-size: 13px; }
  #logPanel { height: 64px; font-size: 12px; padding: 6px 8px; }
  #hint { font-size: 11px; line-height: 1.4; }
  #infoPopup { max-width: 210px; font-size: 12px; padding: 8px 10px; }
  #modalBox { padding: 20px 24px; min-width: 240px; }
  #modalTitle { font-size: 26px; }
  #modalText { font-size: 15px; }
}

/* 横屏手机：高度优先，网格按高度也能缩 */
@media (max-width: 900px) and (orientation: landscape) {
  body { padding: 4px; }
  #gameContainer { padding: 6px; }
  #logPanel { height: 54px; }
}
