/* 魔塔 V1.12 H5 复刻 - 样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: #1a1a22;
  background-image: radial-gradient(ellipse at 50% 30%, #262633 0%, #12121a 70%);
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #eee;
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; overflow: auto;
}

#game {
  display: flex; gap: 10px; padding: 14px;
  background: #000;
  border: 3px solid #fa7600;
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(250,118,0,.25), inset 0 0 20px rgba(0,0,0,.8);
}

/* ---------- 左侧状态栏 ---------- */
#sidebar {
  width: 128px; padding: 10px 8px;
  background: #0a0a0f;
  border: 2px solid #333;
  border-radius: 4px;
  font-size: 13px; line-height: 1.5;
  display: flex; flex-direction: column;
}
.sb-title {
  text-align: center; font-weight: bold; font-size: 14px;
  color: #fa7600; letter-spacing: 1px; margin-bottom: 6px;
  text-shadow: 0 0 6px rgba(250,118,0,.6);
}
.sb-floor {
  text-align: center; font-size: 15px; font-weight: bold;
  color: #ffd700; margin-bottom: 8px; padding: 3px 0;
  border-top: 1px solid #333; border-bottom: 1px solid #333;
}
.sb-row { display: flex; justify-content: space-between; padding: 1px 2px; }
.sb-k { color: #999; }
.sb-v { color: #fff; font-weight: bold; }
.sb-v.hp { color: #ff6a6a; }
.sb-v.money { color: #ffd700; }
.sb-v.exp { color: #7ec8ff; }
.sb-keys { margin: 8px 0 4px; padding-top: 6px; border-top: 1px solid #333; }
.sb-key { display: flex; align-items: center; gap: 6px; padding: 1px 2px; color: #fff; }
.keyicon {
  width: 12px; height: 12px; display: inline-block; border-radius: 2px;
}
.keyicon.yellow { background: #ffcc33; box-shadow: 0 0 4px #ffcc33; }
.keyicon.blue { background: #6688ff; box-shadow: 0 0 4px #6688ff; }
.keyicon.red { background: #ff5555; box-shadow: 0 0 4px #ff5555; }
.sb-items { font-size: 11px; color: #9be79b; min-height: 40px; margin-top: 4px; }
.sb-help { margin-top: auto; font-size: 10px; color: #666; line-height: 1.7; border-top: 1px solid #222; padding-top: 6px; }

/* ---------- 游戏区 ---------- */
#stage { display: flex; flex-direction: column; gap: 8px; }
#toolbar { display: flex; gap: 6px; }
#toolbar button {
  background: linear-gradient(#3a3a46, #22222c);
  color: #ddd; border: 1px solid #555; border-radius: 4px;
  padding: 4px 12px; font-size: 13px; cursor: pointer;
  font-family: inherit;
}
#toolbar button:hover { background: #4a4a5a; color: #fff; border-color: #fa7600; }

#canvas-wrap { position: relative; width: 624px; height: 624px; }
#canvas {
  width: 624px; height: 624px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border: 2px solid #444; border-radius: 2px;
  cursor: pointer;
}

/* ---------- 对话框 ---------- */
#msgbox {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  min-height: 84px;
  background: rgba(0,0,0,.88);
  border: 2px solid #fa7600; border-radius: 6px;
  padding: 8px 12px 20px;
  cursor: pointer; z-index: 5;
}
#msgbox.hidden { display: none; }
#msg-speaker { color: #ffd700; font-weight: bold; font-size: 14px; margin-bottom: 2px; }
#msg-speaker:empty { display: none; }
#msg-text { font-size: 15px; line-height: 1.55; color: #fff; white-space: pre-wrap; }
#msg-next {
  position: absolute; right: 10px; bottom: 4px;
  color: #fa7600; font-size: 12px;
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .2; } }

/* ---------- 轻提示 ---------- */
#tip {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.85); border: 1px solid #ffd700; border-radius: 4px;
  color: #ffd700; font-size: 14px; padding: 4px 14px; z-index: 6;
  white-space: nowrap;
}
#tip.hidden { display: none; }

/* ---------- 遮罩与弹窗 ---------- */
#overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(0,0,0,.82);
  display: flex; align-items: center; justify-content: center;
}
#overlay.hidden { display: none; }
.panel {
  background: #14141c;
  border: 3px solid #fa7600; border-radius: 10px;
  padding: 24px 30px; max-width: 660px; max-height: 88vh; overflow: auto;
  box-shadow: 0 0 30px rgba(0,0,0,.9);
}
.panel h2 {
  color: #ffd700; text-align: center; font-size: 22px; margin-bottom: 14px;
  letter-spacing: 2px;
}
.panel .close-hint { text-align: center; color: #666; font-size: 12px; margin-top: 12px; }

/* 标题画面 */
#title-panel { text-align: center; min-width: 380px; }
#title-panel .big-title {
  font-size: 52px; font-weight: bold; color: #ffd700; letter-spacing: 6px;
  text-shadow: 0 0 18px rgba(255,215,0,.5), 3px 3px 0 #7a4a00;
  margin: 10px 0 2px;
}
#title-panel .sub { color: #999; font-size: 13px; margin-bottom: 24px; letter-spacing: 3px; }
.menu-item {
  font-size: 22px; padding: 10px 40px; margin: 8px auto;
  color: #ccc; cursor: pointer; border-radius: 6px; width: 240px;
  border: 2px solid transparent;
}
.menu-item.sel { color: #fff; background: #2a2a3a; border-color: #ffd700; text-shadow: 0 0 8px rgba(255,215,0,.8); }

/* 片头/结尾滚动 */
.scroll-text {
  font-size: 18px; line-height: 2.4; color: #ddd; text-align: center;
  min-width: 420px; min-height: 300px; display: flex; flex-direction: column;
  justify-content: center;
}
.scroll-text .hint { color: #666; font-size: 12px; margin-top: 24px; }

/* 怪物手册 */
.book-grid { display: flex; flex-direction: column; gap: 6px; min-width: 520px; }
.book-row {
  display: flex; align-items: center; gap: 12px;
  background: #1d1d28; border: 1px solid #333; border-radius: 6px; padding: 5px 12px;
}
.book-row canvas { width: 40px; height: 40px; image-rendering: pixelated; }
.book-name { width: 76px; font-weight: bold; color: #fff; }
.book-stats { color: #aaa; font-size: 13px; flex: 1; }
.book-dmg { font-weight: bold; font-size: 15px; }
.d-green { color: #11ff11; } .d-yellow { color: #ffff00; }
.d-orange { color: #ff9933; } .d-red { color: #ff2222; }

/* 楼层传送 */
.fly-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; min-width: 440px; }
.fly-item {
  background: #1d1d28; border: 1px solid #333; border-radius: 6px;
  padding: 8px 4px; text-align: center; cursor: pointer; font-size: 14px;
}
.fly-item:hover { border-color: #ffd700; color: #ffd700; }
.fly-item .fl-name { color: #999; font-size: 11px; }

/* 商店 */
.shop-text { color: #ddd; margin-bottom: 14px; font-size: 15px; }
.shop-opts { display: flex; flex-direction: column; gap: 8px; }
.shop-opt {
  background: #1d1d28; border: 1px solid #444; border-radius: 6px;
  padding: 9px 16px; cursor: pointer; font-size: 15px; color: #eee;
  display: flex; justify-content: space-between; gap: 20px;
}
.shop-opt:hover:not(.off) { border-color: #ffd700; background: #26263a; }
.shop-opt.off { opacity: .4; cursor: not-allowed; }
.shop-opt .cost { color: #ffd700; }

/* 存读档 */
.sl-grid { display: flex; flex-direction: column; gap: 10px; min-width: 480px; }
.sl-slot {
  background: #1d1d28; border: 1px solid #444; border-radius: 6px;
  padding: 12px 18px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.sl-slot:hover { border-color: #ffd700; }
.sl-slot .sl-name { font-weight: bold; color: #ffd700; width: 70px; }
.sl-slot .sl-info { color: #999; font-size: 13px; text-align: right; }
.sl-slot.empty .sl-info { color: #555; }

/* 战斗动画 */
#battle-panel {
  position: absolute; inset: 0; z-index: 8;
  background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center;
}
.battle-box {
  width: 500px; background: #20202c; border: 4px solid #cc6600; border-radius: 8px;
  padding: 18px; display: flex; gap: 18px; justify-content: center;
}
.bt-side { text-align: center; width: 190px; }
.bt-face {
  width: 96px; height: 96px; margin: 0 auto 8px;
  background: #000; border: 2px solid #555; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.bt-face canvas { width: 80px; height: 80px; image-rendering: pixelated; }
.bt-name { font-size: 17px; font-weight: bold; margin-bottom: 6px; }
.bt-hpbar { height: 14px; background: #3a1010; border: 1px solid #666; border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.bt-hpbar > div { height: 100%; background: linear-gradient(#5aff5a, #1a9a1a); transition: width .18s; }
.bt-hpbar.mon > div { background: linear-gradient(#ff7a7a, #c22); }
.bt-stat { font-size: 12px; color: #bbb; line-height: 1.7; }
.bt-float {
  position: absolute; font-weight: bold; font-size: 18px; pointer-events: none;
  text-shadow: 1px 1px 2px #000; animation: floatup .8s forwards;
}
@keyframes floatup { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-30px); } }
.bt-result {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 52px; font-weight: bold; pointer-events: none;
  opacity: 0; transition: opacity .4s;
  text-shadow: 0 0 20px rgba(255,0,0,.8);
}
.bt-result.show { opacity: 1; }
.battle-hint { text-align: center; color: #777; font-size: 12px; margin-top: 10px; }

/* 响应式 */
@media (max-width: 900px) {
  #canvas-wrap, #canvas { width: 468px; height: 468px; }
  #sidebar { width: 110px; }
}
