:root {
  --bg: #070a10;
  --panel: rgba(15, 19, 27, 0.86);
  --panel-2: rgba(22, 27, 38, 0.92);
  --line: #2b3442;
  --text: #d9d2c4;
  --muted: #8b8f99;
  --gold: #e8b45a;
  --teal: #7fd4c1;
  --red: #d05a5a;
  --green: #7fbf7a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
#app { position: fixed; inset: 0; }
#world { position: absolute; inset: 0; display: block; cursor: crosshair; }
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud button, #hud .panel-title, #hud .modal, #hud .handover { pointer-events: auto; }

.hidden { display: none !important; }
.loading { position: fixed; inset: 0; background: rgba(4,6,10,.82); z-index: 40; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(3px); }
.loading-card { width: min(420px, 86vw); background: #10151f; border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; text-align: center; }
.loading-title { color: var(--gold); font-size: 15px; letter-spacing: 2px; margin-bottom: 14px; }
.loading-track { height: 6px; background: #1b212c; border-radius: 4px; overflow: hidden; }
.loading-track i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8a6a3a, var(--gold)); transition: width .2s; }
.loading-sub { margin-top: 10px; font-size: 11px; color: var(--muted); }

/* 顶部 */
#topbar { position: relative; z-index: 25;
  position: absolute; top: 0; left: 0; right: 0; height: 66px;
  display: flex; align-items: center; gap: 22px; padding: 0 18px;
  background: linear-gradient(180deg, rgba(8, 11, 17, 0.92), rgba(8, 11, 17, 0.55) 70%, transparent);
  pointer-events: auto;
}
.clock { display: flex; align-items: baseline; gap: 10px; font-variant-numeric: tabular-nums; min-width: 180px; }
#day { font-size: 15px; color: var(--gold); letter-spacing: 1px; }
#time { font-size: 22px; font-weight: 600; letter-spacing: 1px; }
.fire-meter { font-size: 11px; color: #ffb35c; border: 1px solid rgba(255, 179, 92, .35); border-radius: 999px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.fire-meter.low { color: #ff6a5a; border-color: rgba(255, 106, 90, .5); }
.weather { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.bars { display: flex; gap: 10px; flex: 1; flex-wrap: nowrap; min-width: 0; }
.bar { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.bar label { font-size: 11px; width: auto; white-space: nowrap; }
.bar .track { width: 60px; height: 6px; border-radius: 4px; background: #1b212c; overflow: hidden; }
.bar .track i { display: block; height: 100%; width: 50%; border-radius: 4px; transition: width .15s linear; }
.bar .track i.hp { background: linear-gradient(90deg, #b54545, #e07a6a); }
.bar.danger label, .bar.danger span { color: #ff6a5a; }
.bar.danger .track i { animation: dangerPulse 1s ease-in-out infinite; }
@keyframes dangerPulse { 50% { filter: brightness(1.6); } }
.bar .track i.hunger { background: linear-gradient(90deg, #a86c2e, #e0a95a); }
.bar .track i.thirst { background: linear-gradient(90deg, #2f6f8f, #5fb3d0); }
.bar .track i.warmth { background: linear-gradient(90deg, #8a5a2b, #ffb35c); }
.bar .track i.stamina { background: linear-gradient(90deg, #3f7a55, #82c98f); }
.bar span { width: 22px; text-align: right; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; gap: 8px; }
.top-actions button { background: var(--panel); color: var(--text); border: 1px solid var(--line); min-width: 38px; height: 32px; padding: 0 8px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.top-actions button:hover { border-color: var(--gold); color: var(--gold); }

/* 侧栏 */
aside {
  position: absolute; top: 84px; width: 300px; padding: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
#ai-panel { left: 18px; }
#right-panel { right: 18px; width: 202px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--gold); letter-spacing: 1px; margin-bottom: 10px; }
.badge { font-size: 10px; color: var(--teal); border: 1px solid rgba(127, 212, 193, 0.4); border-radius: 999px; padding: 2px 7px; letter-spacing: 0; }
.badge.player { color: var(--gold); border-color: rgba(232, 180, 90, 0.5); }
.ai-plan { display: flex; gap: 8px; font-size: 13px; line-height: 1.5; min-height: 22px; }
.ai-plan .label { color: var(--muted); flex: none; }
#ai-plan { color: var(--text); }
.ai-dayplan { font-size: 10.5px; color: #8fa08f; letter-spacing: .3px; margin: -4px 0 8px; line-height: 1.6; min-height: 16px; }
.ai-thought { margin: 8px 0 12px; padding: 8px 10px; font-size: 12px; color: #b9b3a6; background: rgba(255, 255, 255, 0.03); border-left: 2px solid var(--gold); border-radius: 0 6px 6px 0; line-height: 1.55; min-height: 34px; }
.trust-row { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.trust-row .track { flex: 1; height: 5px; background: #1b212c; border-radius: 4px; overflow: hidden; }
.trust-row .track i { display: block; height: 100%; width: 35%; background: linear-gradient(90deg, #8a6a3a, var(--gold)); transition: width .3s; }
.defects { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.defects span { font-size: 10px; color: #c9a27a; border: 1px dashed rgba(201, 162, 122, 0.4); padding: 2px 6px; border-radius: 4px; }
.endless-line { margin-top: 6px; font-size: 10.5px; color: #d6a96a; letter-spacing: .5px; }
.brain-mode { margin-top: 8px; font-size: 10px; color: var(--muted); }
.ai-actions { display: flex; gap: 8px; margin-top: 12px; }
.ai-actions button { flex: 1; font-size: 12px; padding: 7px 6px; border-radius: 8px; border: 1px solid var(--line); background: #1a202b; color: var(--text); cursor: pointer; }
.ai-actions button:hover { border-color: var(--gold); }
button.primary { background: linear-gradient(180deg, #c99745, #a97a30); border-color: #d9a95a; color: #1a1206; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: #e58a8a; border-color: rgba(208, 90, 90, 0.5); }
button.mini { font-size: 10px; padding: 2px 6px; background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 5px; cursor: pointer; }
button.mini:hover { color: var(--gold); border-color: var(--gold); }

.inventory { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 10px; margin-bottom: 14px; }
.inv-item { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #bfb8aa; border-bottom: 1px dashed rgba(255, 255, 255, 0.06); padding-bottom: 3px; }
.inv-item b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
#minimap { display: block; width: 168px; height: 168px; border-radius: 8px; border: 1px solid var(--line); }
.legend { margin-top: 7px; font-size: 10px; color: var(--muted); line-height: 1.5; }
.muted { color: var(--muted); font-size: 11px; }

/* 底部 */
#bottombar { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; background: linear-gradient(0deg, rgba(6, 9, 14, 0.75), transparent); }
#hints { font-size: 12px; color: #aab3c4; letter-spacing: .3px; text-shadow: 0 1px 2px rgba(0,0,0,.8); }
#toasts { display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 20px; }
.toast { font-size: 12px; color: var(--text); background: rgba(20, 25, 35, 0.92); border: 1px solid var(--line); border-left: 3px solid var(--gold); padding: 7px 12px; border-radius: 8px; animation: toastIn .25s ease; }
.toast.good { border-left-color: var(--green); }
.toast.bad { border-left-color: var(--red); }
.toast.teach { border-left-color: var(--teal); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.help-banner { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: rgba(40, 26, 18, .94); border: 1px solid rgba(232, 180, 90, .55); border-radius: 999px; box-shadow: 0 8px 30px rgba(0,0,0,.5); animation: pulseHelp 1.4s ease-in-out infinite; }
.hb-name { font-size: 11px; color: var(--gold); letter-spacing: 2px; }
#help-text { font-size: 12px; color: #e6d6b8; }
.help-banner button { border: 1px solid rgba(232, 180, 90, .6); background: rgba(232, 180, 90, .16); color: var(--gold); border-radius: 999px; padding: 4px 10px; font-size: 11px; cursor: pointer; }
@keyframes pulseHelp { 0%,100% { box-shadow: 0 0 0 0 rgba(232,180,90,.25); } 50% { box-shadow: 0 0 0 8px rgba(232,180,90,0); } }
.rr-body { font-size: 13px; line-height: 2; color: #cfc8ba; }
.rr-body b { color: var(--gold); font-weight: 600; }
.rr-line { border-bottom: 1px dashed rgba(255,255,255,.06); padding: 3px 0; }

/* 交接卡 */
.handover { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); width: min(560px, 86vw); background: var(--panel-2); border: 1px solid rgba(232, 180, 90, 0.35); border-radius: 12px; padding: 12px 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.handover-title { font-size: 10px; color: var(--gold); letter-spacing: 2px; margin-bottom: 5px; }
#handover-text { font-size: 13px; line-height: 1.6; }

/* 弹窗 */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(3, 5, 10, 0.62); backdrop-filter: blur(2px); z-index: 40; }
.modal-card { width: min(560px, 92vw); background: #10141d; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.modal-card.wide { width: min(720px, 92vw); }
.modal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 17px; letter-spacing: 2px; color: var(--gold); font-weight: 600; }
.modal-head .close { background: none; border: none; color: var(--muted); font-size: 24px; line-height: 1; cursor: pointer; }
.modal-head .close:hover { color: var(--text); }
.modal-foot { margin-top: 16px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); }
.modal-foot button, .pause-actions button { padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: #1a202b; color: var(--text); cursor: pointer; font-size: 13px; }
.modal-foot button:hover, .pause-actions button:hover { border-color: var(--gold); }
button.big { padding: 11px 26px; font-size: 14px; }

.build-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.build-item { text-align: left; background: #161c26; border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; color: var(--text); }
.build-item:hover { border-color: var(--gold); background: #1b2230; }
.build-item.locked { opacity: .45; cursor: not-allowed; }
.build-item .bi-name { font-size: 14px; color: var(--gold); margin-bottom: 4px; }
.build-item .bi-cost { font-size: 11px; color: var(--muted); }
.build-item .bi-desc { font-size: 10px; color: #7e8492; margin-top: 6px; line-height: 1.5; }
.build-item .learn { font-size: 9px; color: var(--teal); margin-left: 6px; }

.journal-list { max-height: 62vh; overflow: auto; padding-right: 6px; }
.journal-entry { border-bottom: 1px solid rgba(255, 255, 255, .06); padding: 12px 4px; }
.journal-entry h3 { margin: 0 0 6px; font-size: 12px; color: var(--gold); letter-spacing: 1px; font-weight: 500; }
.journal-entry p { margin: 4px 0; font-size: 13px; line-height: 1.7; color: #cbc4b6; }
.journal-empty { color: var(--muted); font-size: 12px; padding: 20px 0; text-align: center; }

.tutorial-card .lead { font-size: 14px; line-height: 1.8; color: #cfc8ba; margin: 6px 0; }
.tut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin: 16px 0; }
.tut-grid div { display: flex; gap: 10px; align-items: baseline; font-size: 12px; color: var(--muted); }
.tut-grid b { display: inline-block; min-width: 54px; color: var(--gold); font-weight: 600; }
.tip { margin-top: 12px; font-size: 12px; color: #9aa0ac; border-left: 2px solid var(--line); padding-left: 10px; }

.pause-actions { display: flex; flex-direction: column; gap: 9px; }
.pause-actions button { width: 100%; text-align: left; }

.seal-card { background: radial-gradient(120% 120% at 50% 0%, #1d1a13, #0d1017 70%); border-color: rgba(232, 180, 90, 0.35); }
.seal-text { white-space: pre-wrap; font-family: "Songti SC", "Noto Serif SC", serif; font-size: 15px; line-height: 2; color: #ded3b8; background: rgba(0, 0, 0, .25); border: 1px solid rgba(232, 180, 90, .2); border-radius: 8px; padding: 16px 18px; margin: 0; }

@media (max-width: 980px) {
  aside { width: 250px; }
  #right-panel { width: 180px; }
  .bars { gap: 8px; }
  .bar .track { width: 52px; }
}

/* 声音 / 谜题 / 遗物 / 羊皮纸日记 */
#btn-audio { width: 38px; }
.mystery-line { margin-top: 6px; font-size: 10px; color: #b7a06a; letter-spacing: .4px; }
.legacy-start { margin-top: 12px; padding: 10px 12px; border: 1px dashed rgba(232,180,90,.35); border-radius: 8px; font-size: 11px; color: #cbb98d; line-height: 1.7; background: rgba(232,180,90,.04); }
.legacy-info { margin-top: 12px; font-size: 11px; color: #b9ae95; line-height: 1.8; border-top: 1px dashed rgba(255,255,255,.08); padding-top: 10px; }
.legacy-info b { color: var(--gold); }
.seal-relic { margin-top: 12px; font-size: 13px; color: #e2c98f; border: 1px dashed rgba(232,180,90,.4); border-radius: 8px; padding: 10px 12px; background: rgba(232,180,90,.05); }
.heart-card { background: radial-gradient(120% 120% at 50% 0%, #1d1a13, #0d1017 70%); border-color: rgba(232,180,90,.4); }
.heart-text { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 15px; line-height: 2; color: #ded3b8; }
.diary-card { background:
  radial-gradient(80% 60% at 30% 10%, rgba(255,240,200,.08), transparent 60%),
  repeating-linear-gradient(0deg, rgba(120,95,60,.06) 0 1px, transparent 1px 26px),
  linear-gradient(160deg, #1b1710, #13110c 60%, #0f0d09);
  border-color: rgba(232,180,90,.35);
}
.journal-list { font-family: "Songti SC", "Noto Serif SC", serif; }
.journal-entry { border-bottom: 1px dashed rgba(232,180,90,.18); }
.journal-entry h3 { font-family: var(--font-sans, inherit); color: #d9b56c; }
.journal-entry p { color: #d8cdb4; }
.journal-seal { float: right; width: 34px; height: 34px; border: 1px solid rgba(190,70,50,.5); border-radius: 50%; color: #c06a55; display: flex; align-items: center; justify-content: center; font-size: 10px; transform: rotate(-12deg); margin: 4px 0 0 12px; }
.mystery-note { margin: 8px 0 16px; padding: 10px 12px; border-left: 2px solid rgba(232,180,90,.5); background: rgba(232,180,90,.04); }
.mystery-note h4 { margin: 0 0 4px; font-size: 12px; color: #e2c98f; letter-spacing: 1px; }
.mystery-note p { margin: 0; font-size: 13px; line-height: 1.8; color: #cfc3a8; }

.ai-level { margin-top: 7px; font-size: 10px; color: #8f9b86; letter-spacing: .3px; }

.watch-line { margin-top: 6px; font-size: 10.5px; color: #ffcf7a; letter-spacing: .4px; }

.alerts { position: absolute; top: 76px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; flex-direction: column; align-items: center; pointer-events: none; }
.alert { font-size: 12px; padding: 6px 12px; border-radius: 999px; background: rgba(40,26,18,.92); border: 1px solid rgba(232,180,90,.45); color: #ffd7a0; box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.alert.danger { border-color: rgba(220,80,70,.7); color: #ff9b8f; background: rgba(45,16,16,.94); animation: dangerPulse 1.2s ease-in-out infinite; }
.first-day { margin-top: 10px; font-size: 10px; color: #9aa38c; letter-spacing: .3px; line-height: 1.6; }
.first-day b { color: var(--gold); font-weight: 500; }

.forecast { font-size: 11px; color: #b9c0a8; border: 1px solid rgba(185,192,168,.25); border-radius: 999px; padding: 2px 8px; }
.forecast.warn { color: #ff9b8f; border-color: rgba(220,80,70,.5); }

.settings-card { width: min(520px, 92vw); }
.settings-grid { display: grid; gap: 14px; font-size: 13px; color: #cfc8ba; }
.settings-grid label { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.settings-grid input[type=range] { width: 220px; accent-color: #e8b45a; }
.settings-grid select, .settings-grid input[type=checkbox] { accent-color: #e8b45a; background: #1a202b; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.settings-grid .check { justify-content: flex-start; gap: 10px; }
body.large-text { font-size: 15px; }
body.large-text .bar label, body.large-text #hints, body.large-text .legend, body.large-text .defects span, body.large-text .ai-level, body.large-text .muted { font-size: 13px; }
body.large-text .ai-plan, body.large-text .ai-thought, body.large-text #hints { font-size: 15px; }
body.large-text .journal-entry p { font-size: 16px; }
body.high-contrast { --line: #56617a; --muted: #c3c9d6; --text: #f2ead8; }
body.high-contrast .panel, body.high-contrast aside, body.high-contrast #topbar { background: rgba(8, 11, 17, .96); }

.relations { margin-top: 12px; font-size: 11px; color: #b9ae95; line-height: 1.8; border-top: 1px dashed rgba(255,255,255,.08); padding-top: 10px; }
.relations b { color: var(--gold); }

.branch-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.branch-row button { flex: 1; min-width: 150px; padding: 9px 10px; border-radius: 8px; border: 1px solid rgba(232,180,90,.35); background: #1a202b; color: var(--text); cursor: pointer; font-size: 12px; }
.branch-row button:hover { border-color: var(--gold); color: var(--gold); }

button:focus-visible, select:focus-visible, input:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 760px) {
  #topbar { height: auto; min-height: 56px; flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
  #topbar .bars { display: flex; flex-wrap: wrap; width: 100%; gap: 3px 6px; }
  #topbar .bars .bar { min-width: 64px; flex: 1 1 64px; }
  #topbar .bars .bar label { font-size: 9px; }
  #ai-panel { left: 8px; right: 8px; top: 118px; width: auto; max-height: 28vh; overflow: auto; }
  #alerts { top: 118px; }
  #right-panel { display: none; }
  #hints { display: none; }
  .alerts { top: 64px; width: 90vw; }
  .alert { font-size: 11px; }
}

.ai-memory { margin-top: 6px; font-size: 10px; color: #9a8f7a; line-height: 1.6; min-height: 14px; }
.suggest-row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 8px; font-size: 10px; color: #8b8f99; }
.suggest-row button { font-size: 10px; padding: 3px 6px; border-radius: 5px; border: 1px solid var(--line); background: #1a202b; color: #cfc8ba; cursor: pointer; }
.suggest-row button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold); }
.suggest-row button:disabled { opacity: .35; cursor: not-allowed; }
.suggest-row .comfort { margin-left: auto; border-color: rgba(200,120,120,.4); }

.promise-card { position: absolute; left: 50%; bottom: 84px; transform: translateX(-50%); width: min(560px, 88vw); background: rgba(30,24,16,.96); border: 1px solid rgba(232,180,90,.55); border-radius: 12px; padding: 12px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.promise-name { font-size: 10px; color: var(--gold); letter-spacing: 2px; margin-bottom: 4px; }
#promise-text { font-size: 13px; line-height: 1.6; color: #e8ddc6; }
.promise-actions { display: flex; gap: 8px; margin-top: 8px; }
.promise-actions button { padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: #1a202b; color: var(--text); font-size: 12px; cursor: pointer; }
.promise-progress { margin-top: 6px; font-size: 10px; color: #b7a06a; }

.treat-btn { width: 100%; margin-bottom: 8px; }

.slot-row { display: flex; gap: 6px; align-items: center; font-size: 12px; color: #b9ae95; flex-wrap: wrap; }
.slot-row button { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: #1a202b; color: var(--text); cursor: pointer; font-size: 11px; }
.fatal { position: fixed; inset: 0; background: rgba(5,7,12,.94); z-index: 99; display: flex; align-items: center; justify-content: center; }
.fatal-card { width: min(560px, 92vw); background: #11151f; border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.fatal-card h2 { color: var(--gold); margin: 0 0 10px; font-size: 16px; }
.fatal-card pre { color: #d8cdb4; white-space: pre-wrap; font-size: 12px; }

#touch-ui { display: none; position: fixed; inset: 0; pointer-events: none; z-index: 30; }
@media (pointer: coarse), (max-width: 760px) {
  #touch-ui { display: block; }
  #t-joystick { position: absolute; pointer-events: auto; left: 18px; bottom: 18px; width: 108px; height: 108px; border-radius: 50%; background: rgba(20,26,36,.7); border: 1px solid rgba(232,180,90,.35); touch-action: none; z-index: 30; }
  #t-knob { position: absolute; left: 34px; top: 34px; width: 40px; height: 40px; border-radius: 50%; background: rgba(232,180,90,.55); border: 1px solid rgba(232,180,90,.8); transition: transform .05s; }
  #t-buttons { position: absolute; pointer-events: auto; right: 14px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
  #t-buttons button { width: 64px; height: 44px; border-radius: 10px; border: 1px solid rgba(232,180,90,.35); background: rgba(20,26,36,.82); color: #e8dcc4; font-size: 12px; touch-action: manipulation; }
  #touch-ui button:active { background: rgba(232,180,90,.25); }
}

.ending-card { background: radial-gradient(120% 120% at 50% 0%, #1d1a13, #0d1017 70%); border-color: rgba(232,180,90,.4); width: min(620px,92vw); }
.ending-text { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 15px; line-height: 2; color: #ded3b8; white-space: pre-wrap; }

.chapter-chip { font-size: 10px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(232,180,90,.3); background: rgba(20,26,36,.6); color: #d9c08a; cursor: pointer; }
.story-card { width: min(640px, 92vw); background: radial-gradient(120% 120% at 50% 0%, #201c14, #0d1017 70%); border-color: rgba(232,180,90,.4); }
.story-speaker { font-size: 11px; letter-spacing: 3px; color: var(--gold); margin-bottom: 8px; }
.story-text { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 15px; line-height: 2; color: #e4d8bf; white-space: pre-wrap; }
.chapter-card { width: min(620px, 92vw); }
.chapter-tagline { color: #b9ae95; font-size: 12px; line-height: 1.7; }
.chapter-objectives { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; max-height: 46vh; overflow: auto; }
.chapter-obj { display: flex; gap: 8px; font-size: 12px; line-height: 1.6; color: #cfc8ba; }
.chapter-obj.done { color: #8fbf8f; }
.chapter-obj .mark { color: var(--gold); width: 14px; flex: 0 0 14px; }

.event-card { width: min(640px,92vw); background: radial-gradient(120% 120% at 50% 0%, #1b1712, #0c0f16 70%); border-color: rgba(220,150,90,.45); }
.event-kicker { font-size: 10px; letter-spacing: 3px; color: #d98a5a; margin-bottom: 6px; }
.event-body { font-family: "Songti SC", "Noto Serif SC", serif; font-size: 14px; line-height: 1.9; color: #ded3b8; white-space: pre-wrap; }
.event-options { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.event-opt { text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #161c26; color: #e2d8c2; cursor: pointer; }
.event-opt:hover { border-color: var(--gold); }
.event-opt b { display: block; font-size: 13px; margin-bottom: 3px; color: #f0d9a8; }
.event-opt span { font-size: 11px; color: #a99f8c; line-height: 1.5; }

.recipes-card { width: min(700px,94vw); }
.recipes-list { display: flex; flex-direction: column; gap: 7px; max-height: 58vh; overflow: auto; }
.recipe-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #141a23; text-align: left; color: #d9cfba; cursor: pointer; }
.recipe-item:hover:not(:disabled) { border-color: var(--gold); }
.recipe-item:disabled { opacity: .42; cursor: not-allowed; }
.recipe-item b { font-size: 12px; color: #f0d9a8; }
.recipe-item span { font-size: 10.5px; color: #a99f8c; }

.logo { height: 38px; width: auto; opacity: .92; margin-right: 4px; }
.portrait { width: 34px; height: 34px; border-radius: 50%; border: 1px solid rgba(232,180,90,.35); object-fit: cover; background: #11151f; }
.panel-title { display: flex; align-items: center; gap: 8px; }
.inv-icon { display: inline-block; width: 16px; height: 16px; margin-right: 6px; background-size: contain; background-repeat: no-repeat; background-position: center; vertical-align: -3px; image-rendering: auto; }

.final-card { width: min(680px,94vw); background: radial-gradient(120% 120% at 50% 0%, #211a12, #0c0f16 70%); border-color: rgba(232,180,90,.45); }
.final-text { color: #ded3b8; line-height: 1.9; font-size: 14px; }
.final-options { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.final-options button { text-align: left; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #161c26; color: #e2d8c2; cursor: pointer; }
.final-options button:hover { border-color: var(--gold); }
.final-options button b { display: block; color: #f0d9a8; margin-bottom: 2px; }
.final-options button span { font-size: 11px; color: #a99f8c; }

#app::after { content: ''; position: fixed; inset: 0; background: url(assets/art/ui/vignette.svg) center/cover no-repeat; pointer-events: none; opacity: .24; z-index: 4; }
aside, .panel, .modal-card { background-image: linear-gradient(rgba(12,16,23,.68), rgba(12,16,23,.68)), url(assets/art/ui/paper-texture.svg); background-size: cover, 128px 128px; }

@media (max-width: 760px) {
  body.mobile-bag #right-panel { display: block; position: fixed; right: 8px; top: 118px; bottom: 92px; width: min(280px, 82vw); z-index: 35; overflow: auto; }
}

button { transition: background .12s ease, border-color .12s ease, transform .08s ease, color .12s ease; }
button:hover:not(:disabled) { border-color: var(--gold); }
button:active:not(:disabled) { transform: translateY(1px); }
.inv-item { transition: background .12s ease; border-radius: 4px; }
.inv-item:hover { background: rgba(232,180,90,.08); }
.event-opt, .recipe-item { transition: background .12s ease, border-color .12s ease, transform .08s ease; }
.event-opt:hover, .recipe-item:hover:not(:disabled) { background: rgba(232,180,90,.06); }
#ai-panel { transition: box-shadow .2s ease; }
#ai-panel:hover { box-shadow: 0 10px 40px rgba(0,0,0,.28); }

.bar label { display: inline-flex; align-items: center; gap: 3px; width: auto; white-space: nowrap; }
.bar label::before { content: ''; width: 13px; height: 13px; display: inline-block; background-size: contain; background-repeat: no-repeat; background-position: center; opacity: .9; }
.bar:nth-child(1) label::before { background-image: url(assets/art/ui/heart.svg); }
.bar:nth-child(2) label::before { background-image: url(assets/art/ui/berry.svg); }
.bar:nth-child(3) label::before { background-image: url(assets/art/ui/water.svg); }
.bar:nth-child(4) label::before { background-image: url(assets/art/ui/fire.svg); }
.bar:nth-child(5) label::before { background-image: url(assets/art/v2/ui/icon-stamina.svg); opacity: .8; }

canvas { cursor: url(assets/art/v2/ui/cursor.svg) 4 2, crosshair; }
.panel-title::after { content: ''; flex: 1; height: 7px; min-width: 24px; background: url(assets/art/v2/ui/title-ornament.svg) center/contain no-repeat; opacity: .55; }

/* v2 UI 皮肤：按钮四态 / 滚动条 */
.modal-foot button, .build-item, .event-opt, .recipe-item {
  background-image: url(assets/art/v2/ui/button-normal.svg);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-color: transparent;
  border-color: transparent;
}
.modal-foot button:hover, .build-item:hover, .event-opt:hover, .recipe-item:hover:not(:disabled) {
  background-image: url(assets/art/v2/ui/button-hover.svg);
}
.modal-foot button:active, .build-item:active {
  background-image: url(assets/art/v2/ui/button-active.svg);
}
button:disabled { background-image: url(assets/art/v2/ui/button-disabled.svg); opacity: .55; }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #0d1117; }
::-webkit-scrollbar-thumb { background: #3a4a3a; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #5b6a4a; }

/* v2 9-slice 弹窗面板 */
.modal-card {
  border: 14px solid transparent;
  border-image: url(assets/art/v2/ui/panel-9slice.svg) 24 fill / 14px / 0 stretch;
  background: transparent;
}

.simple-panel { position: absolute; left: 50%; bottom: 74px; transform: translateX(-50%); width: min(560px, 92vw); padding: 12px 16px; background: rgba(12,16,23,.92); border: 1px solid rgba(232,180,90,.45); border-radius: 12px; z-index: 18; box-shadow: 0 10px 34px rgba(0,0,0,.42); }
.simple-head { display: flex; justify-content: space-between; align-items: center; color: #b9ae95; font-size: 11px; letter-spacing: 2px; }
.simple-head b { color: var(--gold); font-weight: 500; }
.simple-fire-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.simple-fire-row > span { color: #ffb35c; font-size: 11px; }
.simple-fire-track { flex: 1; height: 8px; border-radius: 5px; background: #1b212c; overflow: hidden; }
.simple-fire-track i { display: block; height: 100%; width: 50%; background: linear-gradient(90deg, #a8442a, #ffb35c); transition: width .2s; }
.simple-crisis { font-size: 11px; color: #ffb28a; margin: 2px 0 4px; }
.simple-plan { font-size: 13px; color: #e8dcc4; line-height: 1.6; min-height: 22px; }
.simple-note { font-size: 10px; color: #b9ae95; margin-top: 4px; }
.simple-actions { display: flex; gap: 8px; margin-top: 8px; }
.simple-actions button { flex: 1; padding: 8px 6px; border-radius: 8px; border: 1px solid var(--line); background: #1a202b; color: var(--text); font-size: 11px; cursor: pointer; }
.simple-actions button:hover:not(:disabled) { border-color: var(--gold); }
.simple-actions button:disabled { opacity: .35; cursor: not-allowed; }
.simple-menu-body { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.simple-menu-body button { text-align: left; padding: 9px 10px; border-radius: 7px; border: 1px solid var(--line); background: #161c26; color: #e2d8c2; cursor: pointer; font-size: 12px; }
.simple-menu-body button:hover { border-color: var(--gold); }
body.simple-mode #ai-panel, body.simple-mode #right-panel, body.simple-mode #chapter-chip, body.simple-mode #promise-card { display: none !important; }
body.simple-mode #topbar .bars { display: none; }
body.simple-mode #alerts { top: 72px; }
body.simple-mode #bottombar { display: none; }
@media (max-width: 760px) { .simple-panel { bottom: 88px; padding: 10px 12px; } .simple-actions { flex-wrap: wrap; } .simple-actions button { flex: 1 1 45%; } }

.ai-say { font-size: 12px; color: #ece0c8; line-height: 1.55; margin: 0 0 8px; padding-left: 8px; border-left: 2px solid rgba(232,180,90,.45); }
.ai-emotion { font-size: 10px; color: #a99d86; letter-spacing: .3px; margin: 2px 0 8px; min-height: 14px; }
.talk-card { width: min(470px, 92vw); }
.talk-line { margin: 6px 0 16px; color: #ede2ca; font-size: 15px; line-height: 1.8; }
.talk-options { display: flex; flex-direction: column; gap: 8px; }
.talk-options button { text-align: left; min-height: 44px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #161c26; color: #e2d8c2; cursor: pointer; font-size: 12px; }
.talk-options button:hover { border-color: var(--gold); background: #1d2530; }

.crisis-chip { animation: crisisPulse 1.8s ease-in-out infinite; font-size: 10px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(255,120,80,.55); background: rgba(70,28,20,.72); color: #ffb28a; cursor: pointer; white-space: nowrap; }
.crisis-chip:hover { border-color: #ffb28a; }
#crisis.modal { z-index: 46; }
.crisis-card { width: min(460px, 92vw); max-height: 86vh; overflow: auto; }
.crisis-text { color: #e5d8c2; line-height: 1.7; font-size: 13px; }
.crisis-needs { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 4px; font-size: 12px; }
.crisis-need { display: flex; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: 6px; background: #151b24; border: 1px solid #2a3324; }
.crisis-need.ok { color: #9fd0b2; border-color: rgba(120,200,160,.35); }
.crisis-need.miss { color: #ffb28a; border-color: rgba(255,120,80,.35); }

@media (max-width: 600px) {
  #crisis-chip { font-size: 9px; padding: 1px 5px; max-width: 82px; overflow: hidden; text-overflow: ellipsis; }
  .crisis-card { width: 94vw; }
  .crisis-needs { font-size: 11px; }
}
.high-contrast .crisis-need.miss { background: #3a1812; color: #ffd0b8; }
.high-contrast .crisis-need.ok { background: #10261a; color: #c6ffe0; }

@media (max-width: 600px) {
  .suggest-row button, .ai-actions button, .panel-title .mini { min-height: 38px; }
  .simple-actions button { min-height: 42px; }
  .talk-options button { min-height: 46px; }
}

@media (max-width: 600px) {
  #topbar .bars { gap: 4px; overflow: hidden; }
  #topbar .bar { min-width: 0; }
  #topbar .bar label { width: auto; font-size: 9px; gap: 2px; }
  #topbar .bar .track { width: 38px; }
  #topbar .bar b { font-size: 9px; }
}

.debug { position: fixed; left: 10px; bottom: 10px; z-index: 60; max-width: 360px; padding: 8px 10px; border: 1px solid #3d4a37; border-radius: 8px; background: rgba(8,12,16,.9); color: #9fd0b2; font: 10px/1.5 ui-monospace, monospace; white-space: pre-wrap; pointer-events: none; }

#npc .talk-card { width: min(470px, 92vw); }
.npc-portrait { width: 34px; height: 34px; object-fit: contain; margin-right: 6px; image-rendering: auto; }

.map-legend { display: flex; gap: 6px; margin-top: 6px; font-size: 9px; color: #9a9284; }
.map-legend .lg { display: inline-flex; align-items: center; gap: 2px; }
.map-legend .lg::before { content: ''; width: 7px; height: 7px; border-radius: 2px; background: var(--c); }
.map-legend .grass { --c: #4f6b3a; } .map-legend .forest { --c: #30492a; } .map-legend .rock { --c: #6d6b64; } .map-legend .sand { --c: #8a7a52; } .map-legend .water { --c: #2c5b73; }

@keyframes crisisPulse { 0%,100% { box-shadow: 0 0 0 rgba(255,120,80,0); } 50% { box-shadow: 0 0 12px rgba(255,120,80,.35); } }
.crisis-need { position: relative; overflow: hidden; }
.crisis-need .fill { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(255,120,80,.12); z-index: 0; }
.crisis-need > * { position: relative; z-index: 1; }

.item-card { width: min(380px, 92vw); }
.item-desc { color: var(--text); line-height: 1.7; font-size: 13px; margin: 4px 0 12px; }
.item-use { color: #b9ae95; font-size: 11px; line-height: 1.7; }
.recipe-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.recipe-filters button { font-size: 10px; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: #151b24; color: #b9ae95; cursor: pointer; }
.recipe-filters button.active { border-color: var(--gold); color: var(--gold); }

.sound-caption { position: fixed; left: 50%; bottom: 112px; transform: translateX(-50%); z-index: 31; background: rgba(8,12,16,.82); border: 1px solid rgba(232,180,90,.35); color: #e8d8b0; padding: 5px 10px; border-radius: 6px; font-size: 11px; pointer-events: none; }

html[lang="en"] body { font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
html[lang="ja"] body { font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 8px; top: -60px; z-index: 100; background: var(--gold); color: #1a1206; padding: 8px 12px; border-radius: 6px; font-size: 12px; }
.skip-link:focus { top: 8px; }
:focus-visible { outline: 2px solid #ffd27a; outline-offset: 2px; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid #ffd27a; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

.ai-main-goal { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #d7c79f; margin: 2px 0 5px; min-height: 18px; }
.ai-main-goal .label { color: var(--gold); flex: none; }
.ai-main-goal #ai-main-goal { flex: 1; line-height: 1.45; }
.ai-main-goal .mini { flex: none; }
.goal-card { width: min(440px, 92vw); }
.goal-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.goal-list button { text-align: left; padding: 9px 10px; border-radius: 8px; border: 1px solid var(--line); background: #151b24; color: var(--text); cursor: pointer; }
.goal-list button:hover { border-color: var(--gold); }
.goal-list button b { color: var(--gold); display: block; margin-bottom: 2px; }
.goal-list button span { color: var(--muted); font-size: 11px; }

.story-feed { margin: 4px 0 5px; padding: 5px 7px; border-left: 2px solid rgba(232,180,90,.35); background: rgba(255,255,255,.025); border-radius: 0 5px 5px 0; font-size: 10px; line-height: 1.55; color: #a9a18f; max-height: 52px; overflow: hidden; }
.story-feed:empty { display: none; }
.story-feed b { color: #d7c79f; font-weight: 500; }

.ai-policy { font-size: 10px; color: #8fa08f; margin: -1px 0 4px; min-height: 13px; }
.policy-group { margin: 10px 0; }
.policy-group > b { display: block; font-size: 11px; color: var(--gold); margin-bottom: 5px; }
.policy-row { display: flex; flex-wrap: wrap; gap: 6px; }
.policy-row button { font-size: 11px; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--line); background: #151b24; color: var(--text); cursor: pointer; }
.policy-row button.active { border-color: var(--gold); color: var(--gold); background: rgba(232,180,90,.08); }
.ai-promise { font-size: 10px; color: #d7c79f; margin: 1px 0 4px; min-height: 13px; line-height: 1.4; }

.ai-arc { font-size: 10px; color: #c9a27a; margin: -1px 0 4px; min-height: 13px; }

.raid-prep { margin: 3px 0 0; padding: 3px 8px; border: 1px solid rgba(190,80,60,.45); background: rgba(70,20,16,.55); color: #f0b090; font-size: 10px; border-radius: 3px; letter-spacing: .2px; }

.season { font-size: 10px; color: #b7c7d9; opacity: .85; }

.season-goal { margin: 2px 0 0; padding: 2px 8px; color: #b8d8e8; font-size: 10px; border-left: 2px solid rgba(140,190,220,.45); }

.story-log h4 { color: #c9a27a; }
.story-log p { margin: 3px 0; }

.shelter { font-size: 10px; color: #b7c7d9; opacity: .75; }

/* 减少动态：系统开启 reduced motion 时，保留反馈但去掉持续动画 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  #world { scroll-behavior: auto; }
}

/* 窄屏顶栏：让五条状态条真正排成第二行，而不是挤在右上角 */
@media (max-width: 760px) {
  #topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    align-items: center;
    gap: 4px 8px;
    height: auto;
    min-height: 0;
    padding: 6px 10px 8px;
  }
  #topbar .logo { grid-column: 1; grid-row: 1; }
  #topbar .clock { grid-column: 2; grid-row: 1; min-width: 0; flex-wrap: wrap; gap: 4px 8px; }
  #topbar .bars { grid-column: 1 / -1; grid-row: 2; width: 100%; flex-wrap: nowrap; gap: 4px; }
  #topbar .bars .bar { flex: 1 1 0; min-width: 0; }
  #topbar .bars .bar .track { width: 100%; min-width: 26px; }
  #topbar .bars .bar span { font-size: 9px; }
  #topbar .top-actions { grid-column: 3; grid-row: 1; }
  #ai-panel { top: 142px; }
  #alerts { top: 142px; }
}

/* 触屏：交接卡不要压住摇杆和动作按钮 */
@media (max-width: 760px) {
  .handover { bottom: 146px; width: 92vw; }
}

/* 触屏：交接卡靠左，避开右侧动作列 */
@media (max-width: 760px) {
  .handover { left: 18px; right: auto; transform: none; width: min(72vw, 360px); }
}
