:root {
  --bg: #0d0f1a;
  --panel: #1a1e30;
  --panel2: #232842;
  --line: #3d4470;
  --text: #e8eaf6;
  --dim: #9aa0c3;
  --gold: #ffd76a;
  --green: #6ee787;
  --red: #ff6b6b;
  --blue: #6cb6ff;
  --purple: #b48cff;
  --shadow: 0 6px 0 rgba(0,0,0,.35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Courier New", ui-monospace, monospace;
  overflow: hidden;
  image-rendering: pixelated;
}
#app { height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ===== 屏幕 ===== */
.screen { display: none; flex: 1; min-height: 0; flex-direction: column; }
.screen.active { display: flex; }

/* ===== 按钮 ===== */
.btn {
  font-family: inherit;
  background: var(--panel2);
  color: var(--text);
  border: 2px solid var(--line);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .05s, filter .15s;
  user-select: none;
}
.btn:hover { filter: brightness(1.25); }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: #2d5aa8; border-color: #4d7ad0; }
.btn-success { background: #1f7a3d; border-color: #3aa85f; }
.btn-danger { background: #a83232; border-color: #d05050; }
.btn-gold { background: #a8821f; border-color: #d0ac4d; color: #fff8e0; }
.btn-blue { background: #2d6fa8; border-color: #4d95d0; }
.btn-purple { background: #6b3fa0; border-color: #9a6bd0; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== 标题屏 ===== */
#screen-title { align-items: center; justify-content: center; }
.title-box { text-align: center; max-width: 560px; padding: 20px; }
.title-logo { font-size: 44px; font-weight: bold; color: var(--gold); text-shadow: 0 0 18px rgba(255,215,106,.5), 3px 3px 0 #000; letter-spacing: 4px; }
.title-sub { color: var(--dim); letter-spacing: 6px; margin-top: 8px; font-size: 13px; }
.title-desc { margin: 26px 0; line-height: 1.9; color: var(--text); }
.title-btns { display: flex; gap: 14px; justify-content: center; }
.title-btns .btn { padding: 14px 28px; font-size: 16px; }
.title-tips { margin-top: 30px; color: var(--dim); font-size: 12px; letter-spacing: 2px; }

/* ===== 职业选择 ===== */
#screen-create { align-items: center; justify-content: center; }
.create-box { width: min(680px, 94vw); max-height: 92vh; overflow-y: auto; background: var(--panel); border: 2px solid var(--line); padding: 24px; }
.create-box h2 { text-align: center; color: var(--gold); margin-bottom: 16px; letter-spacing: 3px; }
.name-input { width: 100%; background: var(--bg); border: 2px solid var(--line); color: var(--text); padding: 10px 12px; font-family: inherit; font-size: 14px; margin-bottom: 16px; }
.name-input:focus { outline: none; border-color: var(--gold); }
#class-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.class-card { display: flex; gap: 14px; background: var(--panel2); border: 2px solid var(--line); padding: 14px; cursor: pointer; transition: border-color .15s; }
.class-card:hover { border-color: var(--dim); }
.class-card.selected { border-color: var(--gold); box-shadow: 0 0 12px rgba(255,215,106,.35); }
.class-icon { font-size: 40px; }
.class-info { flex: 1; }
.class-name { font-weight: bold; font-size: 16px; color: var(--gold); }
.class-desc { color: var(--dim); font-size: 12px; margin: 4px 0 6px; line-height: 1.5; }
.class-stats { font-size: 12px; color: var(--text); }
.class-skills { font-size: 11px; color: var(--blue); margin-top: 4px; }
.create-btns { display: flex; justify-content: space-between; }

/* ===== HUD ===== */
#hud { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border-bottom: 2px solid var(--line); padding: 8px 14px; gap: 10px; flex-wrap: wrap; }
.hud-left { display: flex; align-items: center; gap: 10px; }
#hud-icon { font-size: 30px; }
#hud-name { font-weight: bold; }
#hud-name small { color: var(--gold); font-size: 11px; margin-left: 4px; }
.hud-lv { font-size: 11px; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.mini-bar { display: inline-block; width: 70px; height: 8px; background: #000; border: 1px solid var(--line); }
.mini-bar i { display: block; height: 100%; background: var(--purple); }
.hud-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.bar-row { display: flex; align-items: center; gap: 6px; }
.bar-label { font-size: 11px; color: var(--dim); width: 20px; }
.bar { width: 120px; height: 14px; background: #000; border: 2px solid var(--line); }
.bar.big { width: 100%; }
.bar i { display: block; height: 100%; transition: width .3s; }
.bar.hp i { background: linear-gradient(180deg, #ff8a8a, #e04848); }
.bar.mp i { background: linear-gradient(180deg, #8ac6ff, #4890e0); }
.bar.exp i { background: linear-gradient(180deg, #d0a8ff, #9a5ae0); }
.bar-text { font-size: 11px; color: var(--dim); }
#hud-gold { color: var(--gold); font-weight: bold; }

/* ===== 主舞台 ===== */
#stage { flex: 1; min-height: 0; position: relative; overflow-y: auto; }
.scene { display: none; padding: 20px; animation: fadeIn .25s; }
.scene.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none;} }
.scene-title { font-size: 20px; color: var(--gold); margin-bottom: 10px; letter-spacing: 2px; }
.scene-art { font-size: 34px; text-align: center; line-height: 1.6; margin: 14px 0; text-shadow: 0 3px 0 rgba(0,0,0,.5); }
.scene-desc { text-align: center; color: var(--dim); font-size: 13px; line-height: 1.8; margin-bottom: 18px; }

.zone-map { display: flex; flex-direction: column; gap: 10px; max-width: 560px; margin: 0 auto; }
.zone-btn { display: flex; align-items: center; gap: 12px; background: var(--panel2); border: 2px solid var(--line); padding: 12px 14px; cursor: pointer; font-family: inherit; color: var(--text); text-align: left; transition: border-color .15s; }
.zone-btn:hover:not(:disabled) { border-color: var(--gold); }
.zone-btn:disabled { opacity: .45; cursor: not-allowed; }
.zone-icon { font-size: 28px; }
.zone-info { flex: 1; }
.zone-name { font-weight: bold; }
.zone-sub { font-size: 11px; color: var(--dim); margin-top: 2px; }
.zone-state { font-size: 12px; }
.zone-state.cleared { color: var(--green); }
.zone-state.locked { color: var(--red); }
.village-actions, .world-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

/* ===== 底部导航 ===== */
#navbar { display: flex; background: var(--panel); border-top: 2px solid var(--line); }
.nav-btn { flex: 1; background: none; border: none; border-right: 1px solid var(--line); color: var(--text); padding: 8px 4px; cursor: pointer; font-family: inherit; font-size: 20px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.nav-btn:last-child { border-right: none; }
.nav-btn span { font-size: 11px; color: var(--dim); }
.nav-btn:hover { background: var(--panel2); }

/* ===== 战斗 ===== */
#screen-battle { background: linear-gradient(180deg, #141024 0%, #0d0f1a 100%); }
.battle-head { display: flex; align-items: flex-start; justify-content: space-around; padding: 18px 10px 6px; gap: 6px; }
.battle-enemy, .battle-player { width: min(260px, 40vw); text-align: center; }
.battle-vs { font-size: 22px; color: var(--red); font-weight: bold; align-self: center; text-shadow: 2px 2px 0 #000; }
.battle-icon { font-size: 54px; margin: 6px 0; filter: drop-shadow(0 4px 0 rgba(0,0,0,.5)); }
.battle-icon.hurt { animation: shake .3s; }
@keyframes shake { 0%,100%{transform:none} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }
.battle-name { font-weight: bold; margin-bottom: 4px; }
#battle-log { flex: 1; min-height: 80px; overflow-y: auto; background: rgba(0,0,0,.35); border: 2px solid var(--line); margin: 8px 14px; padding: 10px 12px; font-size: 13px; line-height: 1.9; }
#battle-log .l-sys { color: var(--dim); }
#battle-log .l-me { color: var(--blue); }
#battle-log .l-foe { color: var(--red); }
#battle-log .l-win { color: var(--gold); font-weight: bold; }
#battle-log .l-heal { color: var(--green); }
#battle-actions { padding: 10px 14px 16px; }
.battle-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 520px; margin: 0 auto; }
.battle-menu .btn { padding: 14px 8px; font-size: 15px; }
.sub-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.sub-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--panel2); border: 2px solid var(--line); padding: 10px 12px; cursor: pointer; font-size: 13px; }
.sub-item:hover { border-color: var(--gold); }
.sub-item.disabled { opacity: .45; cursor: not-allowed; }
.sub-item .si-name { color: var(--text); }
.sub-item .si-desc { color: var(--dim); font-size: 11px; margin-top: 2px; }
.sub-item .si-cost { color: var(--blue); white-space: nowrap; }

#player-status, #enemy-status { min-height: 22px; font-size: 12px; }
.st-tag { display: inline-block; padding: 1px 6px; margin: 0 2px; border: 1px solid var(--line); font-size: 11px; }
.st-buff { color: var(--green); }
.st-debuff { color: var(--red); }

/* 飘字 */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 200; }
.float-text { position: absolute; font-size: 22px; font-weight: bold; text-shadow: 2px 2px 0 #000; animation: floatUp 1s forwards; }
@keyframes floatUp { 0% { opacity: 0; transform: translateY(0);} 15% {opacity: 1;} 100% { opacity: 0; transform: translateY(-60px);} }

/* ===== 模态框 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { width: min(560px, 94vw); max-height: 86vh; display: flex; flex-direction: column; background: var(--panel); border: 2px solid var(--line); box-shadow: 0 0 30px rgba(0,0,0,.6); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 2px solid var(--line); color: var(--gold); font-weight: bold; letter-spacing: 2px; }
.modal-body { padding: 16px; overflow-y: auto; line-height: 1.7; }
.m-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--panel2); border: 2px solid var(--line); padding: 10px 12px; margin-bottom: 8px; font-size: 13px; }
.m-row .grow { flex: 1; }
.m-name { font-weight: bold; }
.m-desc { color: var(--dim); font-size: 11px; margin-top: 2px; }
.m-section { color: var(--gold); font-size: 12px; letter-spacing: 2px; margin: 14px 0 8px; border-bottom: 1px dashed var(--line); padding-bottom: 4px; }
.m-section:first-child { margin-top: 0; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 13px; }
.stat-cell { background: var(--panel2); border: 1px solid var(--line); padding: 8px 10px; }
.equip-slot { font-size: 12px; color: var(--dim); }
.q-done { color: var(--green); }
.q-doing { color: var(--gold); }
.q-locked { color: var(--dim); }

/* ===== toast ===== */
#toast-wrap { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--panel); border: 2px solid var(--gold); color: var(--text); padding: 10px 18px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.5); animation: toastIn .25s; max-width: 80vw; }
.toast.warn { border-color: var(--red); }
.toast.good { border-color: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px);} to { opacity: 1; transform: none;} }

/* 滚动条 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); }

@media (max-width: 560px) {
  .title-logo { font-size: 30px; }
  .bar { width: 80px; }
  .battle-icon { font-size: 38px; }
  .scene { padding: 12px; }
}
