/* ===== 全局（森林像素风） ===== */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

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

body {
  background: #0a150a;
  color: #e8e8d8;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  overflow: hidden;
  height: 100vh;
  font-size: 14px;
  image-rendering: pixelated;
}

.hidden { display: none !important; }

/* 背景画布 */
#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  z-index: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ===== 菜单 ===== */
#menu-ui {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 18px;
}

#menu-ui h1 {
  font-size: 2.4rem;
  color: #ffe066;
  text-shadow: 3px 3px 0 #5a4a00, 0 0 20px rgba(255,224,102,0.4);
  margin-bottom: 24px;
  letter-spacing: 4px;
}

#menu-ui label {
  font-size: 0.85rem;
  color: #a8c890;
  letter-spacing: 2px;
}

#menu-ui select {
  width: 380px;
  padding: 12px 14px;
  background: #1a2e1a;
  color: #e8e8d8;
  border: 3px solid #4a6a3a;
  border-top-color: #2a3a1a;
  border-left-color: #2a3a1a;
  border-right-color: #6a9a5a;
  border-bottom-color: #6a9a5a;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  cursor: pointer;
}

#hero-select-label {
  font-size: 0.85rem;
  color: #a8c890;
  letter-spacing: 2px;
}

#hero-select-grid {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-card {
  width: 120px;
  padding: 12px;
  background: #1a2e1a;
  border: 3px solid #4a6a3a;
  border-top-color: #6a9a5a;
  border-left-color: #6a9a5a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s;
  position: relative;
}

.hero-card:hover {
  background: #2a4a2a;
}

.hero-card.selected {
  background: #2a5a2a;
  border-color: #ffe066;
  box-shadow: 0 0 10px rgba(255,224,102,0.3);
}

.hero-card canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 64px;
  height: 64px;
  display: block;
  margin: 0 auto 8px;
}

.hero-card .hero-card-name {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: #ffe066;
  text-shadow: 1px 1px 0 #000;
}

/* Tooltip */
.hero-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  padding: 12px;
  background: #0a1e0a;
  border: 3px solid #4a6a3a;
  border-top-color: #6a9a5a;
  border-left-color: #6a9a5a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
  font-family: 'Press Start 2P', monospace;
  z-index: 20;
  text-align: left;
  margin-bottom: 8px;
  pointer-events: none;
}

.hero-card:hover .hero-tooltip {
  display: block;
}

.hero-tooltip .tt-name {
  color: #ffe066;
  font-size: 0.7rem;
  margin-bottom: 6px;
}

.hero-tooltip .tt-desc {
  color: #a8c890;
  font-size: 0.5rem;
  line-height: 1.8;
  margin-bottom: 8px;
}

.hero-tooltip .tt-gems {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.hero-tooltip .tt-gem {
  width: 16px;
  height: 16px;
  border: 1px solid #4a6a3a;
}

.hero-tooltip .tt-lore {
  color: #7a9a6a;
  font-size: 0.45rem;
  line-height: 1.8;
  font-style: italic;
  border-top: 1px solid #2a3a1a;
  padding-top: 6px;
}

.hero-tooltip .tt-skills {
  margin-top: 6px;
  border-top: 1px solid #2a3a1a;
  padding-top: 6px;
}

.hero-tooltip .tt-skill {
  font-size: 0.45rem;
  color: #b8c8a0;
  line-height: 1.8;
  margin-bottom: 2px;
}

.hero-tooltip .tt-skill-name {
  color: #ffe066;
}

.hero-tooltip .tt-mana-cost {
  font-size: 0.4rem;
}

#start-btn {
  margin-top: 20px;
  padding: 16px 56px;
  font-size: 1.1rem;
  font-family: 'Press Start 2P', monospace;
  background: #2a7a2a;
  color: #ffe066;
  border: 4px solid #4a6a3a;
  border-top-color: #7aba6a;
  border-left-color: #7aba6a;
  border-right-color: #1a4a1a;
  border-bottom-color: #1a4a1a;
  cursor: pointer;
  text-shadow: 2px 2px 0 #1a3a0a;
  letter-spacing: 3px;
  transition: background 0.1s;
}
#start-btn:hover { background: #3a9a3a; }
#start-btn:active {
  border-top-color: #1a4a1a;
  border-left-color: #1a4a1a;
  border-right-color: #7aba6a;
  border-bottom-color: #7aba6a;
}

/* ===== 战斗 UI ===== */
#battle-ui {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 200px auto 280px;
  grid-template-rows: auto 1fr;
  height: 100vh;
  gap: 0;
}

/* -- 顶部信息栏 -- */
#top-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(10, 30, 10, 0.92);
  border-bottom: 3px solid #3a5a2a;
  gap: 14px;
  flex-wrap: wrap;
}

#hero-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

#hero-name {
  color: #ffe066;
  font-size: 0.9rem;
  text-shadow: 1px 1px 0 #000;
}

#hero-hp-bar-bg {
  width: 180px;
  height: 18px;
  background: #1a1a0a;
  border: 3px solid #4a6a3a;
  border-top-color: #2a3a1a;
  border-left-color: #2a3a1a;
  overflow: hidden;
}

#hero-hp-bar {
  height: 100%;
  background: linear-gradient(180deg, #66dd66, #33aa33);
  transition: width 0.3s;
}

#hero-hp {
  font-size: 0.7rem;
  color: #b8c8a0;
}

#mana-display {
  display: flex;
  gap: 10px;
  font-size: 0.75rem;
}

.mana-item {
  text-shadow: 0 0 6px currentColor, 1px 1px 0 #000;
}

#turn-display {
  font-size: 0.85rem;
  color: #ffe066;
  text-shadow: 0 0 8px rgba(255,224,102,0.5), 1px 1px 0 #000;
  letter-spacing: 1px;
}

#combo-display {
  font-size: 0.9rem;
  color: #ffe066;
  text-shadow: 0 0 10px #ffe066;
}
#combo-display.flash {
  animation: comboFlash 0.5s;
}
@keyframes comboFlash {
  0% { transform: scale(1.8); color: #fff; text-shadow: 0 0 20px #fff; }
  100% { transform: scale(1); color: #ffe066; }
}

/* -- 左侧：技能栏 -- */
#left-panel {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-right: 3px solid #2a3a1a;
  background: rgba(10, 25, 10, 0.9);
  overflow-y: auto;
}

#left-panel h3 {
  color: #a8c890;
  font-size: 0.75rem;
  letter-spacing: 2px;
  text-align: center;
  padding: 6px 0;
}

.skill-btn {
  padding: 10px 8px;
  background: #1a2e1a;
  border: 3px solid #4a6a3a;
  border-top-color: #6a9a5a;
  border-left-color: #6a9a5a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
  color: #e8e8d8;
  cursor: pointer;
  text-align: left;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  line-height: 1.6;
  transition: background 0.1s;
}
.skill-btn:hover:not(:disabled) { background: #2a4a2a; }
.skill-btn:active:not(:disabled) {
  border-top-color: #1a3a1a;
  border-left-color: #1a3a1a;
  border-right-color: #6a9a5a;
  border-bottom-color: #6a9a5a;
}
.skill-btn:disabled { opacity: 0.5; cursor: default; }
.skill-btn.on-cd { border-color: #333; }

.skill-btn .skill-name {
  color: #ffe066;
  font-size: 0.6rem;
  margin-bottom: 5px;
  text-shadow: 1px 1px 0 #000;
}

.skill-btn .skill-cost {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.skill-btn .skill-cost-item {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.55rem;
  transition: opacity 0.2s;
}

.skill-btn .skill-cost-item.enough .mana-val {
  color: #e8e8d8;
}

.skill-btn .skill-cost-item.not-enough .mana-val {
  color: #555;
}

.skill-btn .mana-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
  image-rendering: pixelated;
}

.skill-btn .mana-val {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.5rem;
}

.skill-btn .skill-cd {
  color: #cc6644;
  font-size: 0.5rem;
  margin-bottom: 4px;
}

.skill-btn .skill-desc {
  color: #8aaa7a;
  font-size: 0.5rem;
  line-height: 1.6;
}

/* -- 中间：棋盘 -- */
#board-area {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#board-canvas {
  cursor: pointer;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* -- 右侧面板 -- */
#right-panel {
  display: flex;
  flex-direction: column;
  border-left: 3px solid #2a3a1a;
  background: rgba(10, 25, 10, 0.9);
}

#enemy-panel {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 45vh;
  overflow-y: auto;
}

.enemy-card {
  padding: 8px 10px;
  background: #122012;
  border: 3px solid #3a5a2a;
  border-top-color: #5a7a4a;
  border-left-color: #5a7a4a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
}
.enemy-card.dead { opacity: 0.2; }

.enemy-name {
  font-size: 0.65rem;
  text-shadow: 1px 1px 0 #000;
}

.enemy-hp-bar-bg {
  height: 10px;
  background: #1a1a0a;
  border: 2px solid #3a5a2a;
  overflow: hidden;
  margin: 5px 0;
}

.enemy-hp-bar-fill {
  height: 100%;
  transition: width 0.3s;
}

.enemy-hp-text { font-size: 0.55rem; color: #8aaa7a; }

#log-panel {
  flex: 1;
  padding: 8px 10px;
  overflow-y: auto;
  border-top: 3px solid #2a3a1a;
  font-size: 0.5rem;
  color: #7a9a6a;
  line-height: 1.8;
}

.log-line {
  padding: 3px 0;
  border-bottom: 1px solid rgba(30,50,20,0.5);
}

/* ===== 帮助按钮与面板 ===== */
#help-btn {
  position: fixed;
  top: 8px; right: 8px;
  z-index: 10;
  width: 36px; height: 36px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8rem;
  background: #2a5a2a;
  color: #ffe066;
  border: 3px solid #4a6a3a;
  border-top-color: #6a9a5a;
  border-left-color: #6a9a5a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
  cursor: pointer;
  line-height: 30px;
  text-align: center;
}
#help-btn:hover { background: #3a7a3a; }

#help-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

#help-panel {
  background: #122a12;
  border: 4px solid #4a6a3a;
  border-top-color: #6a9a5a;
  border-left-color: #6a9a5a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
  padding: 24px 32px;
  max-width: 680px;
  max-height: 80vh;
  overflow-y: auto;
  color: #d8d8c8;
}

#help-panel h2 {
  color: #ffe066;
  font-size: 1.1rem;
  margin-bottom: 16px;
  text-align: center;
  text-shadow: 2px 2px 0 #000;
}

#help-panel h3 {
  color: #88cc66;
  font-size: 0.75rem;
  margin: 14px 0 8px;
}

#help-panel p, #help-panel li {
  font-size: 0.6rem;
  line-height: 2;
  color: #b8c8a0;
}

#help-panel .gem-help-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #2a3a1a;
}

#help-panel .gem-icon {
  width: 36px; height: 36px;
  border: 2px solid #4a6a3a;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

#help-panel .gem-desc {
  font-size: 0.55rem;
  line-height: 1.8;
}

#help-panel .gem-name { color: #ffe066; }

#help-close-btn {
  display: block;
  margin: 20px auto 0;
  padding: 10px 32px;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.7rem;
  background: #2a5a2a;
  color: #ffe066;
  border: 3px solid #4a6a3a;
  border-top-color: #6a9a5a;
  border-left-color: #6a9a5a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
  cursor: pointer;
}

/* ===== 结果 ===== */
#result-ui {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 24px;
}

#result-title {
  font-size: 2.2rem;
  text-shadow: 3px 3px 0 #000;
}
#result-score {
  font-size: 1rem;
  color: #a8c890;
}

#restart-btn {
  padding: 16px 48px;
  font-size: 0.85rem;
  font-family: 'Press Start 2P', monospace;
  background: #1a3a1a;
  color: #e8e8d8;
  border: 4px solid #4a6a3a;
  border-top-color: #6a9a5a;
  border-left-color: #6a9a5a;
  border-right-color: #1a3a1a;
  border-bottom-color: #1a3a1a;
  cursor: pointer;
  letter-spacing: 2px;
}
#restart-btn:hover { background: #2a5a2a; }
