/* ========================================================================
   仙剑奇侠传 · 网页复刻框架  样式表
   古典中式 RPG 风格:深蓝半透明文本框、宋体/楷体字、像素缩放画面
   ======================================================================== */

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

html, body {
  height: 100%;
  background: #0a0a14;
  color: #fff;
  font-family: "SimSun", "宋体", "STSong", "KaiTi", "楷体", serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  user-select: none;
  overflow: hidden;
}

/* 游戏外框:固定逻辑分辨率 480x352,整体放大 2 倍显示 */
#game-frame {
  position: relative;
  width: 960px;
  height: 704px;
  background: #000;
  border: 4px solid #2a3a6a;
  border-radius: 6px;
  box-shadow: 0 0 40px rgba(60, 90, 180, 0.4), inset 0 0 0 2px #111a33;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 960px;
  height: 704px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* UI 覆盖层 */
#ui-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 22px;
  line-height: 1.5;
}
#ui-layer .ui-box,
#ui-layer .screen { pointer-events: auto; }

.hidden { display: none !important; }

/* ---------- 通用文本框 ---------- */
.ui-box {
  position: absolute;
  background: linear-gradient(180deg, rgba(8, 18, 56, 0.92), rgba(4, 10, 34, 0.95));
  border: 3px solid #cdd8ff;
  border-radius: 8px;
  box-shadow: 0 0 0 2px #2a3a7a, 0 6px 18px rgba(0,0,0,0.6);
  padding: 14px 18px;
  color: #f4f7ff;
  text-shadow: 1px 1px 0 #000;
}

/* ---------- 对话框 ---------- */
#dialogue-box {
  left: 24px; right: 24px; bottom: 22px;
  min-height: 120px;
}
.dialogue-name {
  position: absolute;
  top: -22px; left: 18px;
  background: linear-gradient(180deg, #3a52b0, #20306e);
  border: 2px solid #cdd8ff;
  border-radius: 6px;
  padding: 2px 16px;
  font-size: 20px;
  color: #ffe9a8;
}
.dialogue-text { min-height: 70px; }
#dialogue-portrait {
  position: absolute;
  left: 14px; top: 14px;
  width: 80px; height: 80px;
  image-rendering: auto;
  border: 2px solid #cdd8ff;
  border-radius: 6px;
  box-shadow: 0 0 0 2px #2a3a7a;
  background: #10183a;
}
#dialogue-box.has-portrait .dialogue-text { margin-left: 100px; }
#dialogue-box.has-portrait .dialogue-name { left: 104px; }
#dialogue-cursor {
  position: absolute;
  right: 18px; bottom: 8px;
  color: #ffe9a8;
  font-size: 18px;
}
.blink { animation: blink 0.9s steps(2, start) infinite; }
@keyframes blink { to { opacity: 0; } }

/* ---------- 菜单与选择 ---------- */
.menu-box .menu-item {
  padding: 3px 10px 3px 30px;
  position: relative;
  white-space: nowrap;
  color: #e6ecff;
}
.menu-box .menu-item.selected {
  color: #fff;
}
.menu-box .menu-item.selected::before {
  content: "►";
  position: absolute;
  left: 8px;
  color: #ffe14d;
  animation: nudge 0.6s ease-in-out infinite alternate;
}
.menu-box .menu-item.disabled { color: #7c86ad; }
@keyframes nudge { from { transform: translateX(0);} to { transform: translateX(3px);} }

#choice-box {
  right: 40px;
  bottom: 160px;
  min-width: 160px;
}

/* ---------- 标题界面 ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(ellipse at 50% 30%, #1b2c66 0%, #060814 70%);
}
.game-title {
  font-family: "KaiTi", "楷体", "STKaiti", serif;
  font-size: 76px;
  letter-spacing: 14px;
  color: #ffe9a8;
  text-shadow: 0 0 18px rgba(255, 210, 120, 0.6), 3px 4px 0 #5a2a10;
  margin-left: 14px;
}
.game-subtitle { font-size: 20px; color: #9fb0e8; letter-spacing: 2px; }
#title-menu { position: static; margin-top: 18px; font-size: 26px; padding: 16px 40px; }
.hint { position: absolute; bottom: 28px; font-size: 16px; color: #6c79a8; }

/* ---------- 主菜单 ---------- */
.menu-left { left: 24px; top: 24px; min-width: 150px; font-size: 22px; }
.menu-panel {
  left: 190px; right: 24px; top: 24px; bottom: 24px;
  overflow: auto;
  font-size: 19px;
  line-height: 1.7;
}
.menu-panel h3 { color: #ffe9a8; font-size: 22px; margin-bottom: 8px; border-bottom: 1px solid #3a4a8a; padding-bottom: 4px; }
.menu-panel .row { display: flex; justify-content: space-between; padding: 2px 4px; }
.menu-panel .row.selected { background: rgba(120, 150, 255, 0.22); border-radius: 4px; }
.menu-panel .label { color: #cfd8ff; }
.menu-panel .val { color: #ffe9a8; }
.menu-panel .desc { color: #aeb8e0; font-size: 16px; margin-top: 10px; min-height: 44px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 24px; }

/* ---------- 战斗界面 ---------- */
.battle-status { left: 12px; right: 12px; bottom: 12px; padding: 8px 14px; font-size: 17px; }
.battle-row { display: flex; align-items: center; gap: 10px; padding: 1px 0; }
.battle-row .bname { width: 78px; color: #ffe9a8; }
.battle-row .bar-wrap { display: inline-flex; align-items: center; gap: 6px; }
.bar { width: 120px; height: 12px; background: #1a234a; border: 1px solid #4a5aa0; border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; }
.bar.hp > i { background: linear-gradient(90deg, #2ec16b, #7df0a8); }
.bar.mp > i { background: linear-gradient(90deg, #3a7ef0, #7db8ff); }
.battle-row .num { width: 96px; font-size: 15px; color: #cfd8ff; }
.battle-row.dead .bname { color: #888; text-decoration: line-through; }

.battle-menu { right: 14px; bottom: 120px; min-width: 130px; font-size: 21px; }
.battle-submenu { right: 160px; bottom: 120px; min-width: 150px; max-height: 240px; overflow:auto; font-size: 18px; }
.battle-message { left: 12px; top: 12px; right: 12px; min-height: 48px; font-size: 19px; }

/* 战斗中可被选中的目标高亮(画布上方的提示) */
.target-hint { position:absolute; color:#ffe14d; font-size: 26px; transform: translate(-50%,-50%); }

/* ---------- Toast 提示 ---------- */
.toast {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  background: rgba(8, 18, 56, 0.95);
  border: 2px solid #cdd8ff;
  border-radius: 20px;
  padding: 8px 22px;
  font-size: 18px;
  color: #ffe9a8;
  transition: opacity 0.3s;
}

/* ---------- 底部操作说明 ---------- */
.controls-legend {
  font-size: 14px;
  color: #8893bd;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.controls-legend b { color: #cfd8ff; }

/* 适配小屏:整体等比缩放 */
@media (max-width: 1000px), (max-height: 760px) {
  #game-frame { transform: scale(0.7); }
}
