:root {
  --ink: #e8f1ff;
  --dim: #9fb4c9;
  --blue: #8fd2ff;
  --deep: #0a1520;
  --gold: #e8c887;
  --blood: #c03a44;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: #04070c; overflow: hidden;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
#app {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #0d1a26 0%, #04070c 70%);
}
canvas#game {
  display: block;
  max-width: 100vw; max-height: 100vh;
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: auto;
  cursor: crosshair;
}
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.bars {
  position: absolute; left: 34px; top: 28px;
  display: flex; flex-direction: column; gap: 7px; width: 320px;
}
.bar {
  position: relative; height: 15px; border-radius: 2px;
  background: rgba(4, 10, 16, .78);
  border: 1px solid rgba(160, 200, 235, .28);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), inset 0 0 18px rgba(0,0,0,.8);
  overflow: hidden;
}
.bar i {
  position: absolute; inset: 0; width: 100%;
  transform-origin: left center;
  transition: transform .16s cubic-bezier(.2,.8,.3,1);
}
.bar.hp { height: 18px; }
.bar.hp i { background: linear-gradient(90deg, #7a1f28, #c9454f 70%, #e0707a); }
.bar.hp i::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(180deg, #ffd9dd, #ff8a96);
  opacity: .6;
}
.bar.st { height: 9px; }
.bar.st i { background: linear-gradient(90deg, #2b6b62, #57b596); }
.bar.echo { height: 7px; }
.bar.echo i { background: linear-gradient(90deg, #1d4a76, #69b8e8 60%, #bfe9ff); box-shadow: 0 0 12px rgba(120,200,255,.6); }
#hpText {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; letter-spacing: .06em; color: #f4dfe2;
  font-family: ui-monospace, monospace; text-shadow: 0 1px 3px #000;
}
.echoLabel {
  position: absolute; right: 8px; top: -14px; font-size: 9px;
  letter-spacing: .3em; color: rgba(150,205,240,.7);
}

#soulBox {
  position: absolute; right: 34px; top: 26px;
  display: flex; align-items: baseline; gap: 7px;
  padding: 7px 16px;
  background: rgba(4, 10, 16, .72);
  border: 1px solid rgba(160, 200, 235, .22);
  border-radius: 2px;
  font-family: ui-monospace, monospace;
}
.soulIcon { color: var(--blue); font-size: 13px; text-shadow: 0 0 10px var(--blue); animation: pulse 3s infinite ease-in-out; }
#soulText { font-size: 19px; color: #dff0ff; letter-spacing: .04em; }
.soulName { font-size: 10px; color: var(--dim); letter-spacing: .2em; }
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }

#bossBar {
  position: absolute; left: 50%; bottom: 62px; transform: translateX(-50%);
  width: 720px; max-width: 70vw; text-align: center;
  animation: bossIn .9s ease;
}
@keyframes bossIn { from { opacity: 0; transform: translate(-50%, 14px); } }
.bossName { font-size: 20px; letter-spacing: .32em; color: #efe0c8; margin-bottom: 7px; text-shadow: 0 2px 14px #000, 0 0 30px rgba(200,160,100,.35); }
.bossTrack { height: 9px; background: rgba(3,7,11,.85); border: 1px solid rgba(200,170,120,.32); overflow: hidden; }
#bossFill { display: block; height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, #6a2620, #c25a3c, #e8a35b); transition: transform .22s ease; }

#zoneName {
  position: absolute; left: 50%; top: 96px; transform: translateX(-50%);
  font-size: 25px; letter-spacing: .55em; color: #d9e8f5;
  text-shadow: 0 0 26px rgba(120,190,255,.5);
  opacity: 0; transition: opacity 1s; white-space: nowrap;
}
#zoneName.show { opacity: 1; }

#tips {
  position: absolute; left: 50%; bottom: 118px; transform: translateX(-50%);
  font-size: 13px; letter-spacing: .16em; color: rgba(220,235,250,.82);
  text-shadow: 0 2px 8px #000; text-align: center; line-height: 1.8;
  transition: opacity .5s;
}

/* ---------- Prompt ---------- */
#prompt {
  position: absolute; left: 50%; bottom: 176px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px 8px 10px;
  background: rgba(6, 12, 18, .82);
  border: 1px solid rgba(160, 200, 235, .3);
  border-radius: 3px;
  font-size: 14px; letter-spacing: .12em; color: #e6f2ff;
  animation: fadeIn .25s;
}
#prompt .key {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 3px;
  background: rgba(143, 210, 255, .16);
  border: 1px solid rgba(143, 210, 255, .5);
  color: var(--blue); font-size: 13px; font-family: ui-monospace, monospace;
}
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ---------- Dialog ---------- */
#dialog { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; pointer-events: none; }
.dBox {
  width: 900px; max-width: 88vw; margin-bottom: 54px;
  padding: 22px 30px 18px;
  background: linear-gradient(180deg, rgba(8,16,24,.94), rgba(4,9,14,.97));
  border: 1px solid rgba(150, 195, 230, .26);
  border-left: 3px solid rgba(143, 210, 255, .6);
  box-shadow: 0 20px 60px rgba(0,0,0,.7), inset 0 0 40px rgba(20,50,80,.3);
  animation: fadeIn .22s;
}
.dName { font-size: 14px; letter-spacing: .34em; color: var(--gold); margin-bottom: 10px; }
.dName:empty { display: none; }
.dText { font-size: 17px; line-height: 2; color: #dceaf7; letter-spacing: .05em; min-height: 68px; white-space: pre-wrap; }
.dNext { text-align: right; font-size: 11px; color: rgba(160,190,215,.5); letter-spacing: .18em; animation: pulse 2s infinite; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(10,22,34,.82), rgba(2,4,7,.96));
  backdrop-filter: blur(3px);
  z-index: 20;
  animation: fadeIn .4s;
}
.titleWrap { text-align: center; max-width: 720px; padding: 20px; }
.tKicker { font-size: 13px; letter-spacing: .5em; color: rgba(150, 200, 235, .72); margin-bottom: 18px; }
h1 {
  margin: 0; font-size: 68px; letter-spacing: .16em; font-weight: 400;
  color: #eaf4ff;
  text-shadow: 0 0 40px rgba(110, 180, 240, .55), 0 0 90px rgba(60, 120, 200, .3);
}
h1 .dot { color: var(--blue); margin: 0 .08em; }
h2 { margin: 0 0 10px; font-size: 38px; letter-spacing: .4em; font-weight: 400; color: #e8f3ff; text-shadow: 0 0 30px rgba(120,190,255,.45); }
.tSub { font-size: 11px; letter-spacing: .34em; color: rgba(140, 175, 205, .62); margin: 14px 0 34px; }
.tDesc { font-size: 15px; line-height: 2.1; color: #b9cddd; letter-spacing: .07em; margin-bottom: 38px; }
.tDesc em { color: var(--blue); font-style: normal; text-shadow: 0 0 16px rgba(143,210,255,.6); }
.btn {
  font-family: inherit; font-size: 16px; letter-spacing: .3em;
  padding: 15px 44px; color: #eaf4ff; cursor: pointer;
  background: rgba(20, 45, 70, .55);
  border: 1px solid rgba(143, 210, 255, .45);
  border-radius: 2px;
  transition: all .22s;
  box-shadow: 0 0 0 0 rgba(143,210,255,.4);
}
.btn:hover { background: rgba(40, 85, 120, .7); border-color: rgba(180, 230, 255, .9); box-shadow: 0 0 34px rgba(120, 190, 255, .35); letter-spacing: .38em; }
.btn.ghost { background: transparent; border-color: rgba(130,165,190,.3); color: #a8c0d2; font-size: 13px; padding: 12px 30px; }
.btn.ghost:hover { border-color: rgba(180,210,235,.6); color: #dceaf7; }
.keys {
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: center;
  margin-top: 40px; font-size: 12px; color: rgba(150, 180, 205, .72); letter-spacing: .1em;
}
.keys b { color: var(--blue); font-family: ui-monospace, monospace; font-weight: 500; }
.tNote { margin-top: 22px; font-size: 11px; letter-spacing: .22em; color: rgba(120, 150, 175, .5); }

.deathWrap { text-align: center; }
#deathWord { font-size: 62px; letter-spacing: .2em; color: #d6404b; text-shadow: 0 0 50px rgba(200, 40, 55, .75); animation: deathIn 1.6s ease; }
@keyframes deathIn { 0% { opacity: 0; letter-spacing: .8em; filter: blur(14px); } 100% { opacity: 1; letter-spacing: .2em; filter: blur(0); } }
#deathSub { margin-top: 26px; font-size: 14px; letter-spacing: .16em; color: rgba(200, 170, 170, .7); }
.deathPrompt { margin-top: 48px; font-size: 14px; letter-spacing: .3em; color: rgba(210, 225, 240, .8); animation: pulse 2s infinite; }

.fireBtns { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 30px; }
#fireStats { margin-top: 26px; font-size: 12px; line-height: 2; color: rgba(150, 180, 205, .65); letter-spacing: .1em; }

#toast {
  position: absolute; left: 50%; top: 132px; transform: translateX(-50%);
  padding: 10px 26px; background: rgba(6, 12, 18, .9);
  border: 1px solid rgba(160, 200, 235, .3); border-left: 2px solid var(--gold);
  font-size: 14px; letter-spacing: .16em; color: #f0e4cc;
  opacity: 0; pointer-events: none; transition: opacity .4s, transform .4s;
  z-index: 30; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(4px); }

#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: #dff1ff; z-index: 25; transition: opacity .1s; }

/* ---------- 标题按钮组 / 存档信息 ---------- */
.btnRow { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.saveInfo {
  margin-top: 16px; font-size: 12px; letter-spacing: .14em;
  color: rgba(150, 190, 220, .7);
}
.saveInfo b { color: var(--blue); font-weight: 500; }
