:root {
  --ink: #2b2420;
  --paper: #f3ead6;
  --panel: rgba(38, 31, 27, 0.93);
  --edge: #6b5847;
  --accent: #e8b062;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #17130f;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #f0e6d4;
  user-select: none;
  -webkit-user-select: none;
}

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

#game {
  display: block; width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #17130f;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  padding: 14px 16px;
  pointer-events: none;
  display: flex; flex-direction: column; gap: 6px;
  text-shadow: 0 2px 4px rgba(0,0,0,.8);
}
#place {
  font-size: 15px; letter-spacing: .18em; color: #e9dcc4;
  opacity: .92;
}
#objective {
  font-size: 13px; color: var(--accent);
  max-width: 60ch; line-height: 1.5;
  opacity: .95;
}
#objective:empty { display: none; }

/* ---------- 交互提示 ---------- */
#prompt {
  position: absolute; left: 50%; bottom: 20%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px 7px 8px;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 3px;
  font-size: 14px;
  pointer-events: none;
  animation: pop .18s ease-out;
}
#prompt-key {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 5px;
  background: var(--accent); color: #2b2420;
  border-radius: 3px; font-weight: 700; font-size: 12px;
}
@keyframes pop { from { transform: translate(-50%, 6px); opacity: 0; } }

/* ---------- 虚拟摇杆 ---------- */
#joystick {
  position: absolute; left: 26px; bottom: 26px;
  width: 116px; height: 116px; border-radius: 50%;
  background: rgba(38,31,27,.35);
  border: 2px solid rgba(180,160,130,.35);
  pointer-events: auto; touch-action: none;
}
#stick {
  position: absolute; left: 50%; top: 50%;
  width: 48px; height: 48px; margin: -24px 0 0 -24px;
  border-radius: 50%;
  background: rgba(240, 226, 200, .55);
  border: 2px solid rgba(240,226,200,.75);
}

/* ---------- 对话框 ---------- */
#dialogue {
  position: absolute; left: 0; right: 0; bottom: 0;
  margin: 0 auto;
  width: min(720px, 94vw);
  padding: 16px 20px 14px;
  background: var(--panel);
  border: 2px solid var(--edge);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.55);
  pointer-events: auto;
  animation: rise .16s ease-out;
}
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }

#dlg-name {
  font-size: 14px; color: var(--accent);
  letter-spacing: .1em; margin-bottom: 8px; font-weight: 700;
}
#dlg-name:empty { display: none; }

#dlg-text {
  font-size: 16px; line-height: 1.75;
  min-height: 3.5em;
  white-space: pre-wrap;
}
#dlg-text .cursor {
  display: inline-block; width: 8px; margin-left: 2px;
  background: var(--accent); animation: blink .6s steps(1) infinite;
  vertical-align: bottom; height: 1em;
}
@keyframes blink { 50% { opacity: 0; } }

#dlg-options {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
#dlg-options:empty { display: none; }
#dlg-options li {
  padding: 8px 12px;
  background: rgba(232, 176, 98, .1);
  border-left: 3px solid var(--accent);
  font-size: 15px; cursor: pointer;
  transition: background .12s;
}
#dlg-options li:hover, #dlg-options li.sel {
  background: rgba(232, 176, 98, .26);
}
#dlg-options li .idx {
  color: var(--accent); margin-right: 8px; font-weight: 700;
}

#dlg-hint {
  margin-top: 10px; font-size: 11px; color: #a89880;
  text-align: right; letter-spacing: .08em;
}

.hidden { display: none !important; }

/* ---------- 启动画面 ---------- */
#boot {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; background: #17130f; z-index: 20;
}
#boot-title {
  font-size: 40px; letter-spacing: .5em; color: var(--paper);
  text-indent: .5em;
}
#boot-sub {
  font-size: 13px; letter-spacing: .3em; color: #8a7a64; text-indent: .3em;
}
#boot-status { margin-top: 18px; font-size: 12px; color: #6d6152; }
#boot.done { opacity: 0; pointer-events: none; transition: opacity .5s; }

@media (max-width: 600px) {
  #dlg-text { font-size: 15px; }
  #dialogue { width: 100vw; }
}

/* ---------- 建筑检查面板 ---------- */
#inspector {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 92vw);
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6);
  pointer-events: auto;
  z-index: 15;
  animation: pop2 .16s ease-out;
}
@keyframes pop2 { from { transform: translate(-50%, -46%); opacity: 0; } }

.insp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid rgba(180,160,130,.22);
  font-size: 15px; color: var(--accent); letter-spacing: .06em;
}
#insp-close {
  background: none; border: none; color: #b8a68c;
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 4px;
}
#insp-close:hover { color: var(--accent); }

#insp-body { padding: 12px 14px 4px; font-size: 13px; line-height: 1.9; }
#insp-body .row { display: flex; justify-content: space-between; gap: 12px; }
#insp-body .k { color: #9b8b74; }
#insp-body .v { color: #ecdfc8; text-align: right; }
#insp-body .tag {
  display: inline-block; margin-right: 5px; padding: 1px 7px;
  background: rgba(232,176,98,.16); border: 1px solid rgba(232,176,98,.4);
  border-radius: 2px; font-size: 12px; color: var(--accent);
}

.insp-note { padding: 8px 14px 14px; }
.insp-note label { display: block; font-size: 12px; color: #9b8b74; margin-bottom: 5px; }
#insp-note-input {
  width: 100%; resize: vertical;
  background: rgba(20,16,13,.7); color: #eee2cc;
  border: 1px solid rgba(180,160,130,.3); border-radius: 2px;
  padding: 7px 9px; font: inherit; font-size: 13px; line-height: 1.5;
}
#insp-note-input:focus { outline: none; border-color: var(--accent); }
.insp-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 9px; font-size: 12px; color: #9b8b74;
}
.chk { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.chk input { accent-color: var(--accent); }
.saved { opacity: 0; transition: opacity .2s; color: var(--accent); }
.saved.show { opacity: 1; }

/* ---------- 静音按钮 ---------- */
#mute {
  position: absolute; right: 14px; bottom: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--edge);
  color: var(--accent);
  font-size: 17px; line-height: 1;
  cursor: pointer;
  z-index: 12;
  pointer-events: auto;
}
#mute.off { color: #6d6152; border-color: #4a3f34; }
#mute:active { transform: scale(0.94); }
