/* ===========================================================
   七星鲁王宫 · 3D盗墓手记
   视觉基调：玄黑 / 血锈 / 铜金 / 玉青
   =========================================================== */

:root {
  --ink: #05060a;
  --ink-2: #0b0d13;
  --gold: #c8a15a;
  --gold-dim: #8a6f3c;
  --blood: #8b2b23;
  --blood-bright: #c8402f;
  --jade: #7fae99;
  --paper: #d9d2c4;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "SimSun", "Source Han Serif SC", serif;
  --sans: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

#app { position: fixed; inset: 0; }

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #05060a;
}

/* ---------- 画面质感 ---------- */
#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 48%, rgba(0,0,0,0) 38%, rgba(0,0,0,0.55) 78%, rgba(0,0,0,0.9) 100%),
    linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0) 22%, rgba(0,0,0,0) 78%, rgba(0,0,0,0.45));
  mix-blend-mode: multiply;
}

#grain {
  position: absolute; inset: -50%;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='220' height='220' filter='url(%23n)'/></svg>");
  animation: grainShift 1.1s steps(3) infinite;
}
@keyframes grainShift {
  0% { transform: translate3d(0,0,0); }
  33% { transform: translate3d(-2%, 1.5%, 0); }
  66% { transform: translate3d(1.5%, -1%, 0); }
  100% { transform: translate3d(0,0,0); }
}

#harm {
  position: absolute; inset: 0; pointer-events: none; opacity: 0;
  transition: opacity 260ms ease-out;
  background: radial-gradient(ellipse at 50% 50%, rgba(120,10,0,0) 42%, rgba(150,16,4,0.55) 100%);
}
#harm.on { opacity: 1; transition: opacity 40ms linear; }

#fade {
  position: absolute; inset: 0; pointer-events: none;
  background: #000; opacity: 0;
  transition: opacity 1100ms ease;
}
#fade.on { opacity: 1; }

/* ---------- HUD ---------- */
.hidden { display: none !important; }

#hud { position: absolute; inset: 0; pointer-events: none; }

.hud-corner { position: absolute; }
.hud-corner.tl { top: 22px; left: 24px; display: flex; flex-direction: column; gap: 9px; }
.hud-corner.tr { top: 22px; right: 24px; text-align: right; }

.stat { display: flex; align-items: center; gap: 9px; }
.stat-name {
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.28em;
  color: rgba(217,210,196,0.62);
  width: 30px;
  text-shadow: 0 1px 3px #000;
}
.bar {
  width: 148px; height: 5px;
  background: rgba(255,255,255,0.07);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.7), 0 1px 4px rgba(0,0,0,0.6);
  position: relative;
  overflow: hidden;
  border-radius: 1px;
}
.bar i {
  position: absolute; inset: 0 auto 0 0;
  width: 100%;
  background: linear-gradient(90deg, #7d1f18, var(--blood-bright));
  box-shadow: 0 0 10px rgba(200,64,47,0.55);
  transition: width 180ms ease-out, background 300ms;
}
.bar.bat i { background: linear-gradient(90deg, #6b5426, var(--gold)); box-shadow: 0 0 10px rgba(200,161,90,0.5); }
.bar i.low { background: linear-gradient(90deg, #5a0f0a, #ff5a3c); }

.relic-title {
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.32em;
  color: rgba(217,210,196,0.55);
  margin-bottom: 7px;
}
.relic-row { display: flex; gap: 8px; justify-content: flex-end; }
.relic {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 15px;
  color: rgba(217,210,196,0.16);
  border: 1px solid rgba(200,161,90,0.18);
  background: rgba(8,9,12,0.5);
  border-radius: 2px;
  transition: all 320ms ease;
}
.relic.got {
  color: #ffe9b8;
  border-color: rgba(200,161,90,0.75);
  background: radial-gradient(circle at 50% 40%, rgba(120,85,30,0.55), rgba(10,9,6,0.7));
  box-shadow: 0 0 16px rgba(200,161,90,0.45), inset 0 0 10px rgba(255,215,140,0.18);
  text-shadow: 0 0 10px rgba(255,220,150,0.8);
}

.hud-objective {
  position: absolute;
  left: 26px; bottom: 62px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.1em;
  color: rgba(217,210,196,0.72);
  border-left: 2px solid rgba(139,43,35,0.85);
  padding: 3px 0 3px 12px;
  max-width: 380px;
  line-height: 1.7;
  text-shadow: 0 2px 6px #000;
  transition: opacity 400ms;
}

.hud-hint {
  position: absolute;
  right: 24px; bottom: 18px;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  color: rgba(217,210,196,0.28);
  text-shadow: 0 1px 4px #000;
}

#crosshair {
  position: absolute; left: 50%; top: 50%;
  width: 18px; height: 18px;
  transform: translate(-50%, -50%);
  opacity: 0.55;
}
#crosshair i {
  position: absolute; left: 50%; top: 50%;
  width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px;
  background: rgba(255,240,215,0.85);
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255,210,150,0.9);
}
#crosshair.hot i { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: #ffd98a; }

#prompt {
  position: absolute;
  left: 50%; top: calc(50% + 34px);
  transform: translateX(-50%);
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.12em;
  color: #f3e6cd;
  background: rgba(5,6,9,0.55);
  border: 1px solid rgba(200,161,90,0.32);
  padding: 7px 16px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 160ms;
  text-shadow: 0 1px 4px #000;
}
#prompt.on { opacity: 1; }
#prompt b {
  color: var(--gold);
  font-weight: 400;
  border: 1px solid rgba(200,161,90,0.6);
  padding: 0 5px;
  margin-right: 8px;
  font-size: 12px;
}

#subtitle {
  position: absolute;
  left: 50%; bottom: 84px;
  transform: translateX(-50%) translateY(6px);
  max-width: min(760px, 74vw);
  text-align: center;
  font-family: var(--serif);
  font-size: clamp(14px, 1.35vw, 19px);
  line-height: 1.85;
  letter-spacing: 0.05em;
  color: #ece3d1;
  text-shadow: 0 2px 10px #000, 0 0 26px rgba(0,0,0,0.9);
  opacity: 0;
  transition: opacity 460ms ease, transform 460ms ease;
}
#subtitle.on { opacity: 1; transform: translateX(-50%) translateY(0); }
#subtitle .who { color: var(--gold); font-size: 0.82em; letter-spacing: 0.2em; display: block; margin-bottom: 2px; opacity: 0.75; }

#damageTag {
  position: absolute; left: 50%; top: 34%;
  transform: translate(-50%, -50%);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.3em;
  color: #ffb9a4;
  opacity: 0;
  pointer-events: none;
}
#damageTag.on { animation: dmgTag 900ms ease-out forwards; }
@keyframes dmgTag {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

/* ---------- 覆盖层 ---------- */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 45%, rgba(9,10,14,0.86), rgba(2,3,5,0.97));
  backdrop-filter: blur(3px);
  z-index: 10;
  animation: fadeIn 420ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* 标题页 */
#titleScreen { overflow: hidden; }
.title-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(139,43,35,0.20), transparent 42%),
    radial-gradient(circle at 82% 74%, rgba(200,161,90,0.13), transparent 46%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.014) 0 1px, transparent 1px 3px);
}
.title-bg::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.75), transparent 30%, transparent 62%, rgba(0,0,0,0.9));
}
.title-seal {
  position: absolute;
  right: 7vw; bottom: 8vh;
  width: 130px; height: 130px;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 74px;
  color: rgba(200,60,40,0.5);
  border: 2px solid rgba(200,60,40,0.35);
  transform: rotate(-7deg);
  pointer-events: none;
  mix-blend-mode: screen;
}
.title-main {
  position: relative;
  text-align: center;
  padding: 20px;
  animation: rise 900ms cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.title-kicker {
  font-size: 11px; letter-spacing: 0.55em;
  color: rgba(200,161,90,0.75);
  margin-bottom: 18px;
  text-indent: 0.55em;
}
.title-main h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(38px, 7.2vw, 92px);
  letter-spacing: 0.16em;
  margin: 0 0 6px;
  color: #f2e7d2;
  text-shadow: 0 0 60px rgba(200,161,90,0.28), 0 4px 24px rgba(0,0,0,0.9);
  text-indent: 0.16em;
}
.title-sub {
  font-family: var(--serif);
  font-size: 13px; letter-spacing: 0.42em;
  color: rgba(217,210,196,0.48);
  margin-bottom: 30px;
  text-indent: 0.42em;
}
.title-blurb {
  font-family: var(--serif);
  font-size: clamp(13px, 1.15vw, 16px);
  line-height: 2.1;
  color: rgba(217,210,196,0.66);
  margin: 0 auto 38px;
  letter-spacing: 0.08em;
}
.title-keys {
  margin-top: 34px;
  display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  font-size: 11px; color: rgba(217,210,196,0.36);
  letter-spacing: 0.1em;
}
.title-keys b { color: rgba(200,161,90,0.8); font-weight: 500; margin-right: 5px; }
.title-warn {
  margin-top: 26px;
  font-size: 10px; letter-spacing: 0.3em;
  color: rgba(139,43,35,0.85);
}

.btn {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: rgba(230,220,202,0.82);
  background: rgba(12,13,17,0.7);
  border: 1px solid rgba(200,161,90,0.35);
  padding: 13px 34px;
  cursor: pointer;
  transition: all 220ms ease;
  margin: 0 6px;
}
.btn:hover { color: #fff3d8; border-color: rgba(200,161,90,0.9); background: rgba(52,36,16,0.6); box-shadow: 0 0 26px rgba(200,161,90,0.16); }
.btn-primary {
  color: #ffeccb;
  border-color: rgba(200,161,90,0.6);
  background: linear-gradient(180deg, rgba(72,46,16,0.75), rgba(24,16,8,0.85));
}
.btn-primary:hover { box-shadow: 0 0 36px rgba(200,161,90,0.32); }
.btn:active { transform: translateY(1px); }

/* 通用面板 */
.panel {
  position: relative;
  text-align: center;
  padding: 46px 62px;
  background: linear-gradient(180deg, rgba(14,15,20,0.92), rgba(6,7,10,0.96));
  border: 1px solid rgba(200,161,90,0.18);
  box-shadow: 0 30px 90px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.04);
  max-width: 640px;
}
.panel h2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  margin: 0 0 22px;
  color: #ecdfc6;
}
.muted { color: rgba(217,210,196,0.42); font-size: 12.5px; line-height: 1.9; letter-spacing: 0.05em; }
.panel .muted { margin: 0 0 26px; }
.panel .btn { margin-top: 10px; }

.dead-panel { border-color: rgba(139,43,35,0.4); box-shadow: 0 30px 90px rgba(0,0,0,0.85), inset 0 0 70px rgba(80,10,4,0.28); }
.dead-panel h2 { color: #d8b0a4; }
.dead-reason { font-family: var(--serif); color: rgba(217,180,170,0.72); font-size: 13.5px; letter-spacing: 0.08em; margin-bottom: 10px; }

.ending-panel { max-width: 680px; }
.ending-kicker { font-size: 10px; letter-spacing: 0.5em; color: rgba(200,161,90,0.6); margin-bottom: 16px; }
.ending-panel h2 { color: #ffeec9; text-shadow: 0 0 50px rgba(200,161,90,0.35); }
.ending-text {
  font-family: var(--serif);
  font-size: 14px;
  line-height: 2.15;
  color: rgba(232,222,203,0.78);
  letter-spacing: 0.06em;
  margin: 0 0 24px;
  text-align: left;
}
.ending-text em { color: var(--gold); font-style: normal; }

/* 手记 */
#journalScreen { background: rgba(3,4,6,0.94); }
.journal {
  width: min(940px, 88vw);
  max-height: 82vh;
  display: flex; flex-direction: column;
  background:
    linear-gradient(180deg, rgba(24,20,15,0.96), rgba(12,11,9,0.98));
  border: 1px solid rgba(200,161,90,0.22);
  box-shadow: 0 40px 120px rgba(0,0,0,0.9), inset 0 0 120px rgba(90,60,20,0.12);
  padding: 26px 34px 20px;
}
.journal-head { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid rgba(200,161,90,0.18); padding-bottom: 14px; margin-bottom: 18px; }
.journal-head h2 { font-family: var(--serif); font-weight: 400; letter-spacing: 0.3em; font-size: 22px; margin: 0; color: #eadcc0; }
.journal-close { font-size: 10.5px; letter-spacing: 0.2em; color: rgba(200,161,90,0.6); cursor: pointer; }
.journal-close:hover { color: #ffe6b6; }
.journal-body { display: grid; grid-template-columns: 260px 1fr; gap: 30px; overflow: hidden; }
.journal-col { overflow-y: auto; padding-right: 10px; }
.journal-col h3 { font-family: var(--serif); font-weight: 400; font-size: 12px; letter-spacing: 0.3em; color: rgba(200,161,90,0.55); margin: 0 0 14px; }
.journal-col ul { list-style: none; padding: 0; margin: 0; }
.journal-col li {
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.95;
  color: rgba(224,214,196,0.8);
  padding: 11px 0;
  border-bottom: 1px dashed rgba(200,161,90,0.12);
}
.journal-col li.empty { color: rgba(217,210,196,0.25); font-style: italic; border: 0; }
.journal-col li b { display: block; color: var(--gold); font-weight: 400; letter-spacing: 0.12em; margin-bottom: 4px; font-size: 13.5px; }
.journal-col li span { color: rgba(224,214,196,0.6); font-size: 12.5px; }
.journal-col::-webkit-scrollbar { width: 4px; }
.journal-col::-webkit-scrollbar-thumb { background: rgba(200,161,90,0.25); }

/* 载入 */
#loading {
  position: absolute; inset: 0;
  display: grid; place-items: center; gap: 16px;
  background: #040508;
  color: rgba(200,161,90,0.7);
  font-family: var(--serif);
  letter-spacing: 0.3em;
  font-size: 12px;
  z-index: 30;
  transition: opacity 700ms;
}
#loading.gone { opacity: 0; pointer-events: none; }
#loading .spin {
  width: 26px; height: 26px;
  border: 1px solid rgba(200,161,90,0.2);
  border-top-color: rgba(200,161,90,0.85);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading span { grid-row: 2; }

@media (max-width: 820px) {
  .journal-body { grid-template-columns: 1fr; }
  .bar { width: 100px; }
  .hud-hint { display: none; }
}

/* ===========================================================
   联机 UI
   =========================================================== */
.net-setup {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  margin: 0 0 24px;
}
.field {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-size: 11px; letter-spacing: 0.2em;
  color: rgba(217, 210, 196, 0.45);
}
.field input {
  width: 126px; padding: 9px 11px;
  background: rgba(8, 9, 12, 0.72);
  border: 1px solid rgba(200, 161, 90, 0.26);
  color: #f0e5cf; font-family: var(--serif); font-size: 14.5px; letter-spacing: 0.08em;
  outline: none; border-radius: 1px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus { border-color: rgba(200, 161, 90, 0.8); box-shadow: 0 0 20px rgba(200, 161, 90, 0.14); }
.field input::placeholder { color: rgba(217, 210, 196, 0.22); }

.title-buttons { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.net-status {
  margin-top: 15px; min-height: 16px;
  font-size: 11px; letter-spacing: 0.12em;
  color: rgba(217, 210, 196, 0.34);
}
.net-status.good { color: rgba(140, 200, 170, 0.82); }
.net-status.bad { color: rgba(205, 92, 72, 0.88); }
.net-status.pending { color: rgba(200, 161, 90, 0.82); }

.hud-net {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 5px 13px;
  background: rgba(5, 6, 9, 0.5);
  border: 1px solid rgba(200, 161, 90, 0.16);
  font-size: 10.5px; letter-spacing: 0.16em;
  color: rgba(217, 210, 196, 0.82);
}
.net-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: #6fd6a0; box-shadow: 0 0 9px #6fd6a0;
  animation: netPulse 2.4s ease-in-out infinite;
}
@keyframes netPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.net-ping { color: rgba(150, 200, 175, 0.55); font-size: 9.5px; letter-spacing: 0.05em; }

#chatLog {
  position: absolute; left: 26px; bottom: 118px;
  width: min(520px, 44vw);
  display: flex; flex-direction: column; gap: 4px;
  pointer-events: none;
}
.chat-line {
  font-size: 12px; line-height: 1.6;
  color: rgba(236, 228, 212, 0.9);
  text-shadow: 0 1px 6px #000, 0 0 14px rgba(0, 0, 0, 0.85);
  transition: opacity 0.9s ease;
}
.chat-line.fade { opacity: 0; }
.chat-line b { color: var(--gold); font-weight: 500; margin-right: 5px; }
.chat-line.sys { color: rgba(162, 182, 198, 0.6); font-size: 11px; }
.chat-line.me b { color: #9fd8c0; }

#chatBar {
  position: absolute; left: 50%; bottom: 116px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  width: min(620px, 72vw); padding: 9px 16px;
  background: rgba(6, 7, 10, 0.88);
  border: 1px solid rgba(200, 161, 90, 0.34);
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.7);
  z-index: 9;
}
.chat-caret { color: var(--gold); font-family: var(--serif); font-size: 15px; }
#chatInput {
  flex: 1; background: transparent; border: 0; outline: none;
  color: #f2e8d2; font-family: var(--serif); font-size: 14px; letter-spacing: 0.06em;
}
#chatInput::placeholder { color: rgba(217, 210, 196, 0.26); font-size: 12.5px; letter-spacing: 0.04em; }
