:root {
  --ember: #ff8a2b;
  --ember-soft: #ffb347;
  --blood: #b8342a;
  --ink: #0b0605;
  --panel: rgba(16, 9, 7, 0.82);
  --line: rgba(255, 150, 60, 0.35);
  --text: #f2e3cf;
  --dim: #b9a48d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  user-select: none;
}

html { background: #060303; }
body { background: transparent; }

#view {
  position: fixed;
  inset: 2px;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  display: block;
  cursor: crosshair;
  z-index: 1;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  transform: translateZ(0);
  will-change: transform;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 22px 26px;
  z-index: 10;
}

.hud-left {
  display: flex;
  gap: 14px;
  align-items: center;
  background: linear-gradient(180deg, rgba(20, 10, 6, 0.9), rgba(12, 6, 4, 0.72));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 0 26px rgba(255, 110, 30, 0.14) inset, 0 8px 24px rgba(0, 0, 0, 0.5);
}

#hud-icon {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  border: 1px solid rgba(255, 170, 80, 0.55);
  background: #0a0504;
  object-fit: cover;
  image-rendering: pixelated;
  box-shadow: 0 0 16px rgba(255, 120, 30, 0.4);
}

.hud-bars { min-width: 250px; }

.bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--dim);
  margin-bottom: 5px;
}
.bar-head b { color: var(--ember-soft); font-size: 15px; letter-spacing: 0.04em; }

.bar {
  height: 10px;
  border: 1px solid rgba(255, 160, 70, 0.4);
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7d1f13, #e2542a 55%, #ffb347);
  box-shadow: 0 0 12px rgba(255, 140, 40, 0.7);
  transition: width 0.12s linear;
}
.bar.ember i {
  background: linear-gradient(90deg, #5d3a08, #d7901d 55%, #ffe08a);
  box-shadow: 0 0 12px rgba(255, 210, 110, 0.7);
}

.hud-meta { margin-top: 7px; font-size: 12px; color: var(--dim); letter-spacing: 0.08em; }
.hud-meta b { color: var(--text); }

.hud-right {
  text-align: right;
  background: linear-gradient(180deg, rgba(20, 10, 6, 0.9), rgba(12, 6, 4, 0.72));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 16px;
  min-width: 250px;
}

.hint { margin-top: 8px; font-size: 11px; color: var(--dim); letter-spacing: 0.05em; }

/* ---------- NPC 面板 ---------- */
#npc {
  position: fixed;
  transform: translateZ(0);
  will-change: transform;
  left: 26px;
  bottom: 24px;
  width: min(560px, calc(100vw - 52px));
  display: flex;
  gap: 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.6);
  z-index: 11;
}

.portrait {
  position: relative;
  flex: 0 0 92px;
  height: 92px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 160, 70, 0.45);
  background: radial-gradient(circle at 50% 35%, #3a1a10, #120806 70%);
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.portrait.has-img img { display: block; }
.portrait-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  color: rgba(255, 170, 80, 0.55);
  font-family: "KaiTi", "STKaiti", serif;
}
.portrait.has-img .portrait-fallback { display: none; }

.npc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.npc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.npc-name { font-family: "KaiTi", "STKaiti", serif; font-size: 19px; color: var(--ember-soft); letter-spacing: 0.08em; }

.status { font-size: 11px; color: var(--dim); display: inline-flex; align-items: center; gap: 5px; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: #777; box-shadow: 0 0 6px currentColor; }
.status.up { color: #8fce9a; }
.status.up i { background: #8fce9a; }
.status.down { color: #cf7a6a; }
.status.down i { background: #cf7a6a; }

#mute {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255, 160, 70, 0.35);
  color: var(--ember-soft);
  width: 26px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
#mute.off { color: #6e5c4d; border-color: #4a3a2e; text-decoration: line-through; }

#npc-text {
  font-size: 14px;
  line-height: 1.62;
  color: var(--text);
  min-height: 44px;
  max-height: 88px;
  overflow-y: auto;
  border-left: 2px solid rgba(255, 140, 50, 0.4);
  padding-left: 10px;
}
#npc-text .you { color: var(--dim); font-size: 12px; display: block; margin-bottom: 3px; }
#npc-text .pending { color: var(--dim); font-style: italic; }

.npc-input { display: flex; gap: 8px; margin-top: 9px; }
.npc-input input {
  flex: 1;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 160, 70, 0.28);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
}
.npc-input input:focus { border-color: var(--ember); box-shadow: 0 0 10px rgba(255, 130, 40, 0.2); }
.npc-input button {
  background: linear-gradient(180deg, #7d2f16, #4a1a0c);
  border: 1px solid rgba(255, 150, 60, 0.5);
  color: var(--ember-soft);
  border-radius: 7px;
  padding: 0 16px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.1em;
}
.npc-input button:hover { filter: brightness(1.2); }

/* ---------- 遮罩 / 面板 ---------- */
.overlay {
  position: fixed;
  transform: translateZ(0);
  will-change: transform;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(60, 18, 6, 0.55), rgba(4, 2, 2, 0.92) 70%);
  backdrop-filter: blur(3px);
  transition: opacity 0.35s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  width: min(620px, calc(100vw - 48px));
  text-align: center;
  padding: 42px 44px;
  border: 1px solid rgba(255, 150, 60, 0.35);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(28, 13, 8, 0.92), rgba(10, 5, 4, 0.94));
  box-shadow: 0 0 80px rgba(255, 90, 20, 0.12), 0 30px 80px rgba(0, 0, 0, 0.7);
}

.kicker { margin: 0 0 10px; font-size: 11px; letter-spacing: 0.4em; color: var(--dim); }

.panel h1 {
  margin: 0 0 14px;
  font-family: "KaiTi", "STKaiti", serif;
  font-size: clamp(34px, 5vw, 52px);
  letter-spacing: 0.1em;
  color: #ffd9a3;
  text-shadow: 0 0 30px rgba(255, 110, 30, 0.55), 0 2px 0 #3a1206;
}

.sub { margin: 0 0 22px; color: var(--dim); line-height: 1.8; font-size: 14px; }

.controls { list-style: none; margin: 0 auto 26px; padding: 0; text-align: left; width: fit-content; }
.controls li { font-size: 13px; color: var(--dim); line-height: 2; }
.controls b { color: var(--ember-soft); margin-right: 8px; font-weight: 600; }

.panel button {
  font-family: inherit;
  font-size: 17px;
  letter-spacing: 0.25em;
  padding: 13px 44px;
  color: #1b0903;
  background: linear-gradient(180deg, #ffb24d, #d9681f);
  border: 1px solid #ffd28a;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(255, 120, 30, 0.45);
}
.panel button:hover { filter: brightness(1.1); transform: translateY(-1px); }

.credits { margin: 26px 0 0; font-size: 11px; color: #7d6a58; line-height: 1.7; }

.end-score { font-size: 16px; color: var(--dim); margin: 4px 0 24px; }
.end-score b { color: var(--ember-soft); font-size: 30px; margin-left: 8px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  transform: translate(-50%, -8px) translateZ(0);
  will-change: transform;
  top: 19%;
  left: 50%;
  transform: translate(-50%, -8px);
  font-family: "KaiTi", "STKaiti", serif;
  font-size: clamp(30px, 4.4vw, 46px);
  letter-spacing: 0.2em;
  color: #ffcf8a;
  text-shadow: 0 0 34px rgba(255, 100, 20, 0.75), 0 2px 0 #401505;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  z-index: 12;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  #hud { padding: 12px; }
  .hud-bars { min-width: 160px; }
  #hud-icon { width: 42px; height: 42px; }
  .hud-right { display: none; }
  #npc { left: 12px; bottom: 12px; width: calc(100vw - 24px); }
  .portrait { flex-basis: 70px; height: 70px; }
}
