:root {
  --bg: #12100e;
  --bg2: #1c1814;
  --card: #241f19;
  --ink: #e8dfd0;
  --muted: #9a8f7e;
  --line: #3a3228;
  --accent: #c4a35a;
  --accent2: #8b6914;
  --crimson: #a83a3a;
  --crimson-hi: #c44a4a;
  --hp: #b85c38;
  --mind: #5a8f9a;
  --ok: #6a9e6a;
  --danger: #a84848;
  --font: "Songti SC", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --ui: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
}

/* Mobile portrait → fake landscape (physical portrait, UI rotated 90°) */
html.orient-portrait-lock,
html.orient-portrait-lock body {
  width: var(--phys-w, 100%);
  height: var(--phys-h, 100%);
  max-width: var(--phys-w, 100%);
  max-height: var(--phys-h, 100%);
  overflow: hidden;
  position: fixed;
  inset: 0;
  touch-action: none;
  background: #0a0908;
}
html.orient-portrait-lock #app {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--lvw, 100vh);
  height: var(--lvh, 100vw);
  min-height: var(--lvh, 100vw);
  transform: rotate(90deg) translateY(-100%);
  transform-origin: 0 0;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: #0a0908;
}
html.orient-portrait-lock #stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
html.orient-portrait-lock .screen {
  min-height: calc(var(--lvh, 100vw) - 3.5rem);
}
html.orient-portrait-lock #screen-title,
html.orient-portrait-lock #screen-battle,
html.orient-portrait-lock #screen-explore,
html.orient-portrait-lock #screen-explore.screen {
  min-height: var(--lvh, 100vw);
  height: var(--lvh, 100vw);
}
html.orient-portrait-lock body.mode-battle #screen-battle,
html.orient-portrait-lock body.mode-title #screen-title {
  min-height: var(--lvh, 100vw);
  height: var(--lvh, 100vw);
}
/* fixed is relative to transformed #app → covers full logical landscape shell */
html.orient-portrait-lock .screen.overlay {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
}
button {
  font: inherit; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 4px;
  padding: 0.4rem 0.75rem;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button:active { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent2); border-color: var(--accent); color: #f5ecd8; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#app { min-height: 100%; display: flex; flex-direction: column; }
#topbar {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  justify-content: space-between; padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line); background: var(--bg2);
  position: sticky; top: 0; z-index: 20;
}
.top-left { display: flex; flex-direction: column; gap: 0.15rem; min-width: 12rem; }
#place-label { font-family: var(--font); font-weight: 650; }
#quest-brief { font-size: 0.78rem; }
.top-stats { display: flex; gap: 0.85rem; font-size: 0.85rem; }
.top-nav { display: flex; flex-wrap: wrap; gap: 0.35rem; }

#stage { flex: 1; position: relative; }

.screen { min-height: calc(100vh - 3.5rem); }
.screen.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 8, 6, 0.82);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}

/* Enter-location / world→L2 loading veil (above explore, below nothing critical) */
#screen-loading.overlay {
  z-index: 55;
  flex-direction: column;
  justify-content: flex-end;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(58, 34, 28, 0.45) 0%, transparent 55%),
    rgba(8, 6, 4, 0.92);
  padding: 0 8vw 10vh;
}
.loading-shell {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
}
.loading-title {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
  font-size: 1.15rem;
  letter-spacing: 0.28em;
  color: #e8dfd0;
  text-align: center;
}
.loading-sub {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-align: center;
}
.loading-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(232, 223, 208, 0.12);
  overflow: hidden;
  border: 1px solid rgba(232, 223, 208, 0.18);
}
.loading-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8a3a32, #c4a574);
  transition: width 0.18s ease-out;
}
.loading-pct {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(232, 223, 208, 0.65);
  text-align: right;
}

/* Title — left vertical menu; crimson accent aligned with character menu */
body.mode-title #topbar { display: none !important; }
#screen-title {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  overflow: hidden;
  background: #0a0908;
}
#screen-title .title-bg {
  position: absolute; inset: 0;
  /* Map photo is set via JS (OSS progressive) — avoid CSS url() pulling 12MB PNG. */
  background:
    linear-gradient(115deg, rgba(8,6,4,0.55) 0%, rgba(8,6,4,0.15) 42%, rgba(8,6,4,0.35) 100%),
    radial-gradient(ellipse at 70% 40%, #3a221c 0%, transparent 55%),
    radial-gradient(ellipse at 18% 75%, #2a1414 0%, transparent 48%),
    var(--title-map, none) center / cover no-repeat,
    #12100e;
  filter: saturate(0.5) contrast(1.06) brightness(0.68);
  transform: scale(1.04);
  transition: background-image 0.35s ease;
}
#screen-title .title-veil {
  position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(6,5,4,0.88) 0%, rgba(6,5,4,0.42) 38%, rgba(6,5,4,0.28) 100%);
  pointer-events: none;
}
.title-brand {
  position: absolute;
  top: 8vh;
  left: 7vw;
  z-index: 2;
  pointer-events: none;
}
.title-brand .kicker {
  letter-spacing: 0.35em;
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.35rem;
}
.title-brand h1 {
  font-family: var(--font);
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-shadow: 0 2px 18px rgba(0,0,0,0.65);
}
.title-arc {
  margin: 0.45rem 0 0;
  font-family: var(--font);
  color: var(--crimson-hi);
  letter-spacing: 0.18em;
  font-size: 1.05rem;
}
.title-auth {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.65rem;
  margin: auto 0 auto 7vw;
  padding: 0;
  min-width: 14rem;
  max-width: min(22rem, 78vw);
}
.title-auth.hidden,
.title-menu.hidden {
  display: none !important;
}
.title-menu .title-auth-email {
  margin: 0 0 0.35rem;
  padding-left: 1.1rem;
}
.title-auth-status,
.title-auth-email {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: color-mix(in srgb, var(--muted) 90%, #fff);
  text-shadow: 0 1px 8px rgba(0,0,0,0.55);
}
.title-auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  width: 100%;
}
.title-auth-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.title-auth-field input {
  appearance: none;
  border: 1px solid rgba(242, 235, 224, 0.22);
  background: rgba(8, 6, 4, 0.55);
  color: #f2ebe0;
  font-family: var(--font);
  font-size: 1rem;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.75rem;
  border-radius: 2px;
  outline: none;
}
.title-auth-field input:focus {
  border-color: color-mix(in srgb, var(--crimson-hi) 70%, #fff);
  box-shadow: 0 0 0 1px rgba(168, 58, 58, 0.35);
}
.title-auth-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  margin-top: 0.25rem;
}
.title-auth-error {
  margin: 0;
  font-size: 0.8rem;
  color: #e8a0a0;
  letter-spacing: 0.04em;
}
.title-auth-msg {
  margin: 0;
  font-size: 0.8rem;
  color: #b8c9a8;
  letter-spacing: 0.04em;
  line-height: 1.45;
}
.title-auth-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--muted) 85%, #fff);
  font-family: var(--font);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.1rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}
.title-auth-link:hover {
  color: #f2ebe0;
}
.title-auth-code-row {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  width: 100%;
}
.title-auth-field-grow {
  flex: 1;
  min-width: 0;
}
.title-auth-send {
  flex: 0 0 auto;
  min-width: 6.5rem;
  padding-left: 0.7rem;
  padding-right: 0.7rem;
  font-size: 0.82rem;
}
.title-auth-form.hidden {
  display: none !important;
}
.title-menu {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  margin: auto 0 auto 7vw;
  padding: 0;
  min-width: 11rem;
}
#screen-title:has(#title-auth:not(.hidden)) .title-menu {
  margin-top: 0.5rem;
}
#screen-title:has(#title-menu:not(.hidden)) .title-auth {
  margin-bottom: 0;
}
.title-menu-item {
  appearance: none;
  border: none;
  background: transparent;
  color: #f2ebe0;
  font-family: var(--font);
  font-size: 1.35rem;
  letter-spacing: 0.18em;
  padding: 0.55rem 1.6rem 0.55rem 1.1rem;
  text-align: left;
  border-radius: 0;
  position: relative;
  text-shadow: 0 1px 8px rgba(0,0,0,0.55);
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.title-menu-item:hover,
.title-menu-item:focus-visible,
.title-menu-item.is-active {
  color: #fff;
  background:
    linear-gradient(90deg, transparent 0%, var(--crimson-hi) 6%, var(--crimson) 78%, transparent 100%);
  box-shadow: 0 0 18px rgba(168, 58, 58, 0.35);
  outline: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}
.title-menu-item:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  color: #cfc5b4;
}
.title-menu-item:disabled:hover {
  color: #cfc5b4;
  background: transparent;
  box-shadow: none;
  text-shadow: none;
}
.title-hint {
  position: absolute;
  z-index: 2;
  left: 7vw;
  bottom: 4vh;
  margin: 0;
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--muted) 80%, transparent);
  letter-spacing: 0.06em;
}
.title-actions { display: flex; gap: 0.6rem; justify-content: center; margin: 1.4rem 0 0.8rem; }
.hint { font-size: 0.75rem; color: var(--muted); }

/*
 * Title — phone / forced-landscape
 * Use column flex (no absolute brand/menu) so short --lvh cannot overlap.
 * Left column = brand + menu + hint; right side stays open for map art.
 */
html.ui-touch #stage:has(#screen-title:not(.hidden)),
html.ui-compact #stage:has(#screen-title:not(.hidden)) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
html.ui-touch #screen-title,
html.ui-compact #screen-title {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  box-sizing: border-box;
  padding:
    max(0.5rem, var(--ui-safe-t), calc(var(--lvh) * 0.03))
    max(0.75rem, var(--ui-safe-r))
    max(0.45rem, var(--ui-safe-b), calc(var(--lvh) * 0.025))
    max(0.75rem, var(--ui-safe-l), calc(var(--lvw) * 0.035));
  overflow: hidden;
}
html.ui-touch #screen-title .title-bg,
html.ui-touch #screen-title .title-veil,
html.ui-compact #screen-title .title-bg,
html.ui-compact #screen-title .title-veil {
  z-index: 0;
}
html.ui-touch .title-brand,
html.ui-compact .title-brand {
  position: relative;
  top: auto;
  left: auto;
  z-index: 2;
  flex: 0 0 auto;
  max-width: min(22rem, 70%);
  margin: 0 0 clamp(0.2rem, calc(var(--lvh) * 0.02), 0.55rem);
  pointer-events: none;
}
html.ui-touch .title-brand .kicker,
html.ui-compact .title-brand .kicker {
  font-size: clamp(0.58rem, calc(var(--lvh) * 0.032), 0.75rem);
  letter-spacing: 0.24em;
  margin: 0 0 0.12rem;
}
html.ui-touch .title-brand h1,
html.ui-compact .title-brand h1 {
  font-size: clamp(1.35rem, calc(var(--lvh) * 0.085), 2.4rem);
  letter-spacing: 0.18em;
  line-height: 1.12;
}
html.ui-touch .title-arc,
html.ui-compact .title-arc {
  margin-top: 0.15rem;
  font-size: clamp(0.72rem, calc(var(--lvh) * 0.038), 0.95rem);
  letter-spacing: 0.12em;
}
html.ui-touch .title-auth,
html.ui-compact .title-auth,
html.ui-touch .title-menu,
html.ui-compact .title-menu {
  position: relative;
  top: auto;
  left: auto;
  bottom: auto;
  z-index: 2;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: clamp(0.08rem, calc(var(--lvh) * 0.01), 0.35rem);
  margin: 0;
  padding: 0;
  min-width: min(12.5rem, 46%);
  max-width: min(18rem, 52%);
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
html.ui-touch .title-auth-field input,
html.ui-compact .title-auth-field input {
  min-height: 36px;
  font-size: 0.95rem;
}
html.ui-touch .title-menu-item,
html.ui-compact .title-menu-item {
  flex: 0 0 auto;
  font-size: clamp(0.92rem, calc(var(--lvh) * 0.048), 1.25rem);
  letter-spacing: 0.1em;
  min-height: clamp(36px, calc(var(--lvh) * 0.11), 48px);
  padding: 0.25rem 1rem 0.25rem 0.85rem;
  width: 100%;
  box-sizing: border-box;
}
html.ui-touch .title-menu-item:active,
html.ui-compact .title-menu-item:active {
  color: #fff;
  background:
    linear-gradient(90deg, transparent 0%, var(--crimson-hi) 6%, var(--crimson) 78%, transparent 100%);
}
html.ui-touch .title-hint,
html.ui-compact .title-hint {
  position: relative;
  left: auto;
  right: auto;
  bottom: auto;
  z-index: 2;
  flex: 0 0 auto;
  margin: clamp(0.25rem, calc(var(--lvh) * 0.02), 0.55rem) 0 0;
  max-width: min(22rem, 70%);
  font-size: clamp(0.6rem, calc(var(--lvh) * 0.03), 0.75rem);
  line-height: 1.35;
}
html.ui-touch .title-hint-editor,
html.ui-compact .title-hint-editor {
  margin-top: 0.15rem;
}
html.ui-touch .title-editor-toggle,
html.ui-compact .title-editor-toggle {
  z-index: 3;
  right: max(var(--ui-safe-r), var(--ui-pad));
  bottom: max(var(--ui-safe-b), var(--ui-pad));
  min-height: 36px;
  padding: 0.3rem 0.55rem;
  font-size: clamp(0.62rem, calc(var(--lvh) * 0.03), 0.75rem);
  opacity: 0.7;
}
/* Ultra-short logical height (~340–380px phone landscape) */
html.ui-compact.ui-touch .title-brand {
  margin-bottom: 0.15rem;
}
html.ui-compact.ui-touch .title-brand h1 {
  font-size: clamp(1.25rem, calc(var(--lvh) * 0.078), 1.75rem);
}
html.ui-compact.ui-touch .title-arc {
  font-size: clamp(0.68rem, calc(var(--lvh) * 0.034), 0.82rem);
}
html.ui-compact.ui-touch .title-menu {
  justify-content: space-evenly;
  gap: 0;
}
html.ui-compact.ui-touch .title-menu-item {
  font-size: clamp(0.88rem, calc(var(--lvh) * 0.045), 1.05rem);
  min-height: clamp(32px, calc(var(--lvh) * 0.095), 40px);
  padding: 0.15rem 0.85rem 0.15rem 0.7rem;
}

/* Saves / Load slots */
#screen-saves {
  align-items: stretch;
  justify-content: flex-start;
  background:
    linear-gradient(180deg, rgba(6,5,4,0.78), rgba(6,5,4,0.9)),
    radial-gradient(ellipse at 60% 30%, #2a1818 0%, transparent 55%),
    #0a0908;
  padding: 2.2rem clamp(1.2rem, 4vw, 3.5rem) 1.5rem;
}
.saves-shell {
  width: min(720px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 100%;
}
.saves-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.saves-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}
.saves-mode-tabs {
  display: flex;
  gap: 0.4rem;
}
.saves-mode-btn {
  min-width: 6.5rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid rgba(230, 220, 200, 0.16);
  background: rgba(36, 32, 28, 0.92);
  color: #e8e0d4;
  font-family: var(--font);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  border-radius: 2px;
  cursor: pointer;
}
.saves-mode-btn:hover:not(:disabled) {
  border-color: rgba(196, 74, 74, 0.4);
  color: #f4efe6;
}
.saves-mode-btn.is-on,
.saves-mode-btn.primary {
  background: linear-gradient(180deg, #8a6a32, #6a4e22);
  border-color: rgba(212, 179, 106, 0.45);
  color: #fff8ec;
}
.saves-mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.saves-head h2 {
  margin: 0;
  font-family: var(--font);
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
}
.saves-count { margin: 0.35rem 0 0; font-size: 0.85rem; }
.saves-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow: auto;
  padding-right: 0.25rem;
  max-height: calc(100vh - 9rem);
}
.save-slot {
  display: grid;
  grid-template-columns: 148px 1fr auto;
  gap: 0.85rem;
  align-items: stretch;
  min-height: 96px;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(230, 220, 200, 0.14);
  background: rgba(12, 10, 8, 0.72);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35);
  cursor: pointer;
  text-align: left;
  color: inherit;
  border-radius: 2px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}
.save-slot:hover,
.save-slot:focus-visible,
.save-slot.is-active {
  border-color: rgba(196, 74, 74, 0.55);
  background: rgba(28, 16, 14, 0.9);
  box-shadow: inset 0 0 0 1px rgba(168, 58, 58, 0.18);
  outline: none;
}
.save-slot.is-empty {
  opacity: 0.72;
  cursor: default;
}
.save-slot.is-empty:not(.is-writable) { cursor: default; }
.save-slot.is-empty.is-writable { cursor: pointer; opacity: 0.9; }
.save-slot-thumb {
  width: 148px;
  height: 84px;
  object-fit: cover;
  background:
    linear-gradient(135deg, #2a241c, #151210);
  border: 1px solid rgba(255,255,255,0.08);
  filter: grayscale(0.35) contrast(1.05);
}
.save-slot-thumb.is-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}
.save-slot-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  min-width: 0;
}
.save-slot-place {
  font-family: var(--font);
  font-size: 1.25rem;
  letter-spacing: 0.12em;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.save-slot-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  font-size: 0.82rem;
  color: #d8d0c2;
}
.save-slot-stats .lab {
  color: var(--muted);
  margin-right: 0.35rem;
}
.save-slot-time {
  font-size: 0.78rem;
  color: var(--muted);
}
.save-slot-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 5.5rem;
}
.save-slot-index {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.save-slot-del {
  font-size: 0.72rem;
  padding: 0.2rem 0.45rem;
  background: transparent;
  border-color: rgba(168,72,72,0.45);
  color: #c98787;
}
.save-slot-del:hover { border-color: var(--danger); color: #f0c0c0; }
.saves-foot { margin: 0; font-size: 0.78rem; }
@media (max-width: 640px) {
  .save-slot { grid-template-columns: 110px 1fr; }
  .save-slot-thumb { width: 110px; height: 72px; }
  .save-slot-side { grid-column: 1 / -1; flex-direction: row; align-items: center; }
}

/* Saves overlay on touch / compact logical viewport */
html.ui-touch #screen-saves,
html.ui-compact #screen-saves {
  padding:
    max(var(--ui-pad), var(--ui-safe-t))
    max(var(--ui-pad), var(--ui-safe-r))
    max(var(--ui-pad), var(--ui-safe-b))
    max(var(--ui-pad), var(--ui-safe-l));
}
html.ui-touch .saves-shell,
html.ui-compact .saves-shell {
  width: min(720px, 100%);
  max-height: calc(var(--lvh, 100vh) - var(--ui-pad) * 2);
}
html.ui-touch .saves-list,
html.ui-compact .saves-list {
  max-height: calc(var(--lvh, 100vh) - 8rem);
}
html.ui-touch .save-slot,
html.ui-compact .save-slot {
  grid-template-columns: min(148px, 28vw) 1fr auto;
  min-height: max(72px, calc(var(--ui-hud-btn) * 1.8));
  gap: var(--ui-gap);
}
html.ui-touch .save-slot-thumb,
html.ui-compact .save-slot-thumb {
  width: 100%;
  height: auto;
  aspect-ratio: 148 / 84;
}
html.ui-touch .saves-head h2,
html.ui-compact .saves-head h2 {
  font-size: clamp(1.05rem, calc(var(--lvh) * 0.05), 1.35rem);
}
html.ui-touch #saves-close,
html.ui-compact #saves-close {
  min-height: max(40px, var(--ui-hud-btn));
  padding: 0.4rem 0.85rem;
}

/* Map */
#screen-map {
  display: grid; grid-template-columns: 1fr 240px; gap: 0;
  min-height: calc(100vh - 3.5rem);
}
@media (max-width: 860px) {
  #screen-map { grid-template-columns: 1fr; }
}
.map-wrap {
  position: relative; overflow: auto; background: #0a0908;
  border-right: 1px solid var(--line);
}
#world-map { display: block; width: 100%; height: auto; user-select: none; }
#hotspots { position: absolute; inset: 0; }
.hotspot {
  position: absolute; border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 4px; cursor: pointer;
}
.hotspot:hover, .hotspot:focus {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  outline: none;
}
.hotspot span {
  position: absolute; left: 4px; bottom: 4px;
  font-size: 0.68rem; padding: 0.1rem 0.3rem;
  background: rgba(0,0,0,0.55); color: var(--accent); white-space: nowrap;
}
.hotspot.locked { opacity: 0.35; border-style: dashed; }
.map-legend { padding: 1rem; background: var(--bg2); overflow: auto; }
.map-legend h3 { margin: 0 0 0.4rem; font-family: var(--font); }
#region-list { list-style: none; padding: 0; margin: 0.8rem 0 0; }
#region-list li { margin: 0.3rem 0; }
#region-list button { width: 100%; text-align: left; }

/* Location */
#screen-location { padding: 1rem 1.25rem 2rem; max-width: 720px; margin: 0 auto; }
.loc-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.loc-head h2 { margin: 0; font-family: var(--font); font-size: 1.25rem; }
.action-list { list-style: none; padding: 0; margin: 0 0 1rem; display: flex; flex-direction: column; gap: 0.45rem; }
.action-list li, .action-card {
  border: 1px solid var(--line); background: var(--card); border-radius: 6px;
  padding: 0.75rem 0.9rem; cursor: pointer;
}
.action-list li:hover, .action-card:hover { border-color: var(--accent); }
.action-list .title { font-weight: 600; }
.action-list .desc { font-size: 0.8rem; color: var(--muted); margin-top: 0.2rem; }
.action-list .locked-tag { color: var(--danger); font-size: 0.75rem; }

/* Dialogue — 左下固定 3:4 半身（*_half）；「继续」靠右；手机放大立绘 */
#screen-dialogue.overlay {
  --dlg-bust-w: min(27vw, calc(62vh * 3 / 4), 480px);
  --dlg-bar-h: clamp(9.5rem, 26vh, 15rem);
  align-items: flex-end;
  justify-content: stretch;
  padding: 0;
  background: rgba(10, 8, 6, 0.22);
}
.dialogue-stage {
  position: relative;
  width: 100%;
  height: calc(var(--dlg-bust-w) * 4 / 3);
  max-height: 78vh;
  pointer-events: none;
}
.dialogue-stage .portrait {
  position: absolute;
  left: max(0.5rem, 1.2vw);
  bottom: 0;
  width: var(--dlg-bust-w);
  aspect-ratio: 3 / 4;
  height: auto;
  max-height: none;
  object-fit: contain;
  object-position: bottom center;
  border: none;
  border-radius: 0;
  background: transparent;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  transition: filter 0.4s ease, opacity 0.4s ease, transform 0.4s ease;
}
.dialogue-stage .portrait.img-soft {
  filter: blur(14px) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
  opacity: 0.78;
  transform: scale(1.03);
  transform-origin: bottom center;
}
.dialogue-stage .portrait.img-sharp {
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  opacity: 1;
  transform: scale(1);
  transform-origin: bottom center;
}
.dialogue-stage .portrait.hidden { display: none; }
.dialogue-box {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  width: 100%;
  min-height: var(--dlg-bar-h);
  margin: 0;
  border: none;
  border-radius: 0;
  background: linear-gradient(
    to top,
    rgba(8, 6, 4, 0.9) 0%,
    rgba(12, 10, 8, 0.78) 55%,
    rgba(12, 10, 8, 0.35) 100%
  );
  box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.28);
  /* 左让立绘 · 右让「继续」 */
  padding: 1.1rem 5.5rem 1.15rem calc(var(--dlg-bust-w) + 1.6rem);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.35rem;
  pointer-events: auto;
}
.dialogue-stage:has(.portrait.hidden) .dialogue-box {
  padding-left: 1.6rem;
}
.dlg-context {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted, #8a8070);
  background: rgba(0, 0, 0, 0.22);
  border-left: 3px solid var(--accent, #c4a35a);
  padding: 0.4rem 0.65rem;
  margin: 0 0 0.35rem;
}
.dlg-context strong { color: var(--accent, #c4a35a); font-weight: 650; }
.dlg-context .ctx-row { margin: 0.1rem 0; }
.dialogue-box .speaker {
  font-family: var(--font);
  color: var(--accent);
  font-weight: 650;
  font-size: 1.35rem;
  margin: 0 0 0.2rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

#screen-location {
  background-color: var(--bg);
  transition: background-image 0.3s ease;
}
.dialogue-box .text {
  line-height: 1.7;
  min-height: 3.2rem;
  white-space: pre-wrap;
  font-size: 1.2rem;
  flex: 1;
}
/* 任务推进关键词：地名 / NPC / 道具 / 任务术语 */
.kw-hint {
  color: #e24b3c;
  font-weight: 700;
  text-shadow: 0 0 0.01px currentColor;
}
.dlg-context .kw-hint { color: #f06050; }
.choices .kw-hint { color: #e24b3c; }
.dialogue-box .choices { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.35rem 0; }
.dialogue-box .choices button {
  text-align: left;
  font-size: 1.05rem;
  padding: 0.5rem 0.85rem;
  background: rgba(36, 31, 25, 0.85);
}
.dialogue-box #dlg-next {
  position: absolute;
  right: max(0.75rem, 1.2vw);
  bottom: 0.85rem;
  margin: 0;
  z-index: 4;
  font-size: 1.05rem;
  padding: 0.5rem 1.25rem;
  letter-spacing: 0.12em;
}
@media (max-width: 720px), (pointer: coarse) {
  #screen-dialogue.overlay {
    /* 手机：半身插图明显放大 */
    --dlg-bust-w: min(44vw, calc(78vh * 3 / 4), 320px);
    --dlg-bar-h: clamp(9rem, 32vh, 14rem);
  }
  .dialogue-box {
    padding-left: calc(var(--dlg-bust-w) + 0.75rem);
    padding-right: 4.8rem;
  }
  .dialogue-box .speaker { font-size: 1.15rem; }
  .dialogue-box .text { font-size: 1.05rem; min-height: 2.6rem; }
  .dialogue-box #dlg-next {
    right: 0.65rem;
    bottom: 0.7rem;
    font-size: 1rem;
    padding: 0.55rem 1.1rem;
  }
}
/* 竖屏假横屏：用逻辑视口放大 3:4 半身 */
html.orient-portrait-lock #screen-dialogue.overlay {
  --dlg-bust-w: min(
    calc(var(--lvw, 100vh) * 0.42),
    calc(var(--lvh, 100vw) * 0.78 * 3 / 4),
    360px
  );
  --dlg-bar-h: clamp(9rem, calc(var(--lvh, 100vw) * 0.34), 15rem);
}

.cinematic-box {
  max-width: 36rem; margin: 10vh auto; padding: 1.25rem 1.4rem;
  background: var(--panel, #1c1914); border: 1px solid var(--line, #3a342a);
  border-radius: 10px; text-align: center;
}
.cine-kind { color: var(--accent, #c4a35a); font-size: 0.78rem; letter-spacing: 0.06em; }
.cinematic-box h2 { margin: 0.35rem 0; font-family: var(--font); color: var(--text); }
.cine-id { display: inline-block; margin: 0.25rem 0 0.75rem; font-size: 0.75rem; color: var(--muted); }
.cine-video { width: 100%; max-height: 42vh; background: #000; border-radius: 6px; margin: 0.5rem 0; }
.cine-note { font-size: 0.88rem; line-height: 1.5; color: var(--text); margin: 0.5rem 0; }
.cine-resume { font-size: 0.8rem; margin: 0.25rem 0 0.9rem; }
.cine-actions { display: flex; gap: 0.6rem; justify-content: center; }

/* Battle — full scene */
#screen-battle {
  min-height: 100vh;
  padding: 0;
  max-width: none;
  margin: 0;
  overflow: hidden;
}
.battle-stage {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
}
.battle-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 60%;
  z-index: 0;
  filter: saturate(1.08) brightness(0.88) contrast(1.02);
}
.battle-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 55%, transparent 36%, rgba(8, 6, 4, 0.28) 100%),
    linear-gradient(180deg, rgba(10, 8, 6, 0.18), transparent 24%, transparent 64%, rgba(10, 8, 6, 0.62));
}

/* Field: enemies left / party right, staggered stands */
.battle-field {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.battle-side {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.battle-side .unit-card {
  pointer-events: auto;
}
.unit-card {
  --stand-x: 22%;
  --stand-y: 52%;
  position: absolute;
  left: var(--stand-x);
  top: var(--stand-y);
  width: 110px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  transform: translate(-50%, -85%);
  transition: filter 0.15s ease, opacity 0.2s ease;
  z-index: 2;
}
.battle-side.enemy .unit-card:nth-child(1) { --stand-x: 22%; --stand-y: 50%; z-index: 3; }
.battle-side.enemy .unit-card:nth-child(2) { --stand-x: 32%; --stand-y: 58%; z-index: 4; }
.battle-side.enemy .unit-card:nth-child(3) { --stand-x: 28%; --stand-y: 42%; z-index: 2; }
.battle-side.enemy .unit-card:nth-child(4) { --stand-x: 18%; --stand-y: 60%; z-index: 5; }
.battle-side.party .unit-card:nth-child(1) { --stand-x: 72%; --stand-y: 54%; z-index: 4; }
.battle-side.party .unit-card:nth-child(2) { --stand-x: 82%; --stand-y: 48%; z-index: 3; }
.battle-side.party .unit-card:nth-child(3) { --stand-x: 78%; --stand-y: 62%; z-index: 5; }
.battle-side.party .unit-card:nth-child(4) { --stand-x: 88%; --stand-y: 56%; z-index: 4; }

.unit-card .fighter-sprite-wrap {
  position: relative;
  width: 96px;
  height: 120px;
  margin: 0 auto;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.55));
}
.unit-card .fighter-sprite {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  display: block;
  user-select: none;
  pointer-events: none;
}
.unit-card .fighter-sprite-wrap.is-sheet-anim {
  background-position: 0% 100%;
  background-origin: border-box;
  image-rendering: auto;
}
.battle-side.party .fighter-sprite { transform: scaleX(-1); }
/* Sheet plays on wrap background — mirror whole wrap for party facing enemy */
.battle-side.party .fighter-sprite-wrap.is-sheet-anim { transform: scaleX(-1); }
.unit-card .fighter-fallback {
  width: 72px;
  height: 96px;
  margin: 0 auto;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #5a4030, #2a2018);
  border: 2px solid rgba(212, 175, 110, 0.45);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.85rem;
}
.unit-card .fighter-arrow {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 12px solid #e0c56a;
  filter: drop-shadow(0 0 4px rgba(224, 197, 106, 0.8));
  opacity: 0;
  pointer-events: none;
}
.unit-card.is-inspectable { cursor: pointer; }
.unit-card.is-inspectable:hover .fighter-sprite-wrap,
.unit-card.is-inspectable:hover .fighter-fallback {
  filter: drop-shadow(0 0 8px rgba(224, 197, 106, 0.55));
}
.unit-card.is-targetable .fighter-arrow,
.unit-card.active .fighter-arrow { opacity: 1; }
.unit-card.is-targetable .fighter-sprite-wrap,
.unit-card.is-targetable .fighter-fallback {
  outline: 2px solid rgba(110, 200, 120, 0.9);
  outline-offset: 2px;
  border-radius: 6px;
  animation: target-pulse 1.1s ease-in-out infinite;
  cursor: pointer;
}
.battle-active-panel[data-side="enemy"] .bap-head {
  color: #e8a090;
}
.unit-card.active .fighter-sprite-wrap {
  filter: drop-shadow(0 0 10px rgba(212, 175, 110, 0.75)) drop-shadow(0 8px 10px rgba(0, 0, 0, 0.55));
}
.unit-card.is-near-death .fighter-sprite-wrap { animation: near-death-pulse 0.9s ease-in-out infinite; }
.unit-card.is-down {
  opacity: 0.35;
  filter: grayscale(0.85);
}
.unit-card .fighter-plate {
  margin-top: 0.15rem;
  text-align: center;
  font-size: 0.72rem;
  color: #f0e6d4;
  text-shadow: 0 1px 3px #000;
  font-family: var(--font);
}
.unit-card .fighter-plate .mini-bar {
  height: 4px;
  margin: 0.2rem auto 0;
  width: 72px;
  background: rgba(20, 16, 12, 0.75);
  border-radius: 99px;
  overflow: hidden;
}
.unit-card .fighter-plate .mini-bar > i {
  display: block;
  height: 100%;
  background: var(--hp);
}
.unit-card .name { display: none; }
.unit-status { display: none; }

/* Top-left active stats */
.battle-active-panel {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 6;
  width: min(280px, 42vw);
  padding: 0.7rem 0.85rem 0.8rem;
  background: rgba(28, 22, 16, 0.88);
  border: 2px solid rgba(196, 163, 90, 0.65);
  box-shadow:
    inset 0 0 0 1px rgba(80, 60, 30, 0.8),
    0 8px 24px rgba(0, 0, 0, 0.45);
  color: #e8dcc8;
  font-size: 0.78rem;
  backdrop-filter: blur(4px);
}
.battle-active-panel .bap-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.45rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(196, 163, 90, 0.35);
  font-family: var(--font);
  color: var(--accent);
  letter-spacing: 0.06em;
}
.battle-active-panel .bap-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 0.85rem;
}
.battle-active-panel .bap-row {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  line-height: 1.45;
}
.battle-active-panel .bap-row span:first-child { color: #b8a890; }
.battle-active-panel .bap-empty { color: var(--muted); }

/* Top-right command wheel */
.battle-cmd-wrap {
  position: absolute;
  right: 1.1rem;
  top: 1rem;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
}
.battle-cmd-wheel {
  --wheel: 210px;
  position: relative;
  width: var(--wheel);
  height: var(--wheel);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(60, 44, 28, 0.2) 0 28%, transparent 29%),
    conic-gradient(from -90deg, rgba(70, 50, 30, 0.92) 0 100%);
  border: 3px solid rgba(212, 175, 110, 0.75);
  box-shadow:
    inset 0 0 0 2px rgba(40, 28, 16, 0.9),
    0 10px 28px rgba(0, 0, 0, 0.5);
}
.battle-cmd-wheel::before {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 110, 0.35);
  background: radial-gradient(circle, rgba(42, 32, 22, 0.95), rgba(22, 16, 12, 0.98));
  pointer-events: none;
}
.battle-cmd-wheel .wheel-seg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;
  margin-left: -32px;
  margin-top: -14px;
  transform: rotate(var(--a)) translateY(calc(var(--wheel) * -0.38)) rotate(calc(var(--a) * -1));
  border: none;
  background: transparent;
  color: #f0e2c8;
  font-family: var(--font);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 3px #000;
  cursor: pointer;
  padding: 0.2rem;
  z-index: 1;
}
.battle-cmd-wheel .wheel-seg:hover,
.battle-cmd-wheel .wheel-seg.primary {
  color: #ffe2a0;
  text-shadow: 0 0 8px rgba(255, 210, 120, 0.55), 0 1px 3px #000;
}
.battle-cmd-wheel .wheel-seg:disabled {
  opacity: 0.35;
  cursor: default;
}
.battle-cmd-wheel .wheel-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  border: 2px solid rgba(212, 175, 110, 0.7);
  background: radial-gradient(circle at 40% 35%, #5a4530, #2a2018);
  color: #e8d4a8;
  font-family: var(--font);
  font-size: 0.78rem;
  z-index: 2;
  cursor: pointer;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.45);
}
.battle-cmd-wheel .wheel-hub.is-on {
  color: #fff4d0;
  border-color: #e0c56a;
  box-shadow: 0 0 14px rgba(224, 197, 106, 0.45), inset 0 0 12px rgba(0, 0, 0, 0.45);
}
.battle-cmd-wheel.busy::after {
  content: "演出中…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(10, 8, 6, 0.55);
  color: var(--muted);
  font-size: 0.8rem;
  z-index: 3;
}
.battle-cmd-sub {
  min-width: 200px;
  max-width: 260px;
  padding: 0.55rem;
  background: rgba(22, 18, 14, 0.92);
  border: 2px solid rgba(196, 163, 90, 0.55);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}
.battle-cmd-sub.hidden { display: none; }
.battle-cmd-sub button {
  font-size: 0.78rem;
  padding: 0.3rem 0.55rem;
}

/* Bottom party strips */
.battle-party-hud {
  position: absolute;
  left: 50%;
  bottom: 0.85rem;
  transform: translateX(-50%);
  z-index: 6;
  display: flex;
  gap: 0.55rem;
  max-width: min(920px, 96vw);
}
.battle-strip {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 168px;
  padding: 0.4rem 0.55rem;
  background: rgba(24, 18, 14, 0.9);
  border: 2px solid rgba(196, 163, 90, 0.55);
  box-shadow: inset 0 0 0 1px rgba(60, 44, 28, 0.85);
}
.battle-strip.active {
  border-color: rgba(224, 197, 106, 0.95);
  box-shadow: 0 0 0 1px rgba(224, 197, 106, 0.35), inset 0 0 0 1px rgba(60, 44, 28, 0.85);
}
.battle-strip.is-down { opacity: 0.45; filter: grayscale(0.6); }
.battle-strip .strip-face {
  width: 48px;
  height: 48px;
  object-fit: cover;
  object-position: top;
  border: 1px solid rgba(196, 163, 90, 0.45);
  background: #1a1410;
  flex-shrink: 0;
}
.battle-strip .strip-face.fallback {
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 0.7rem;
  font-family: var(--font);
}
.battle-strip .strip-bars { flex: 1; min-width: 0; }
.battle-strip .strip-name {
  font-size: 0.72rem;
  color: #f0e6d4;
  font-family: var(--font);
  margin-bottom: 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.battle-strip .bar {
  height: 7px;
  background: #2a2420;
  border-radius: 2px;
  margin-top: 0.18rem;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.35);
}
.battle-strip .bar > i { display: block; height: 100%; background: linear-gradient(90deg, #a83828, #e06048); }
.battle-strip .bar.mind > i { background: linear-gradient(90deg, #285888, #4a90d0); }
.battle-strip .bar.turn > i { background: linear-gradient(90deg, #2d6a3a, #5cb86a); }
.battle-strip .strip-foot {
  margin-top: 0.15rem;
  font-size: 0.62rem;
  color: #c07060;
  letter-spacing: 0.08em;
}

.battle-meta {
  position: absolute;
  left: 1rem;
  bottom: 6.2rem;
  z-index: 5;
  max-width: min(280px, 40vw);
  text-shadow: 0 2px 6px #000;
}
.battle-title {
  font-family: var(--font);
  font-size: 1.05rem;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.battle-wave { font-size: 0.75rem; margin-top: 0.1rem; }
.battle-hint {
  margin-top: 0.25rem;
  font-size: 0.68rem;
  color: var(--muted);
  background: rgba(18, 16, 14, 0.55);
  border: 1px solid rgba(196, 163, 90, 0.3);
  padding: 0.2rem 0.45rem;
  display: inline-block;
}
.battle-log {
  position: absolute;
  right: 1rem;
  bottom: 6.2rem;
  z-index: 5;
  width: min(280px, 36vw);
  height: 88px;
  overflow: auto;
  font-size: 0.72rem;
  line-height: 1.4;
  border: 1px solid rgba(196, 163, 90, 0.35);
  background: rgba(10, 8, 6, 0.62);
  padding: 0.4rem 0.55rem;
  color: var(--muted);
}
.battle-log .hit { color: var(--hp); }
.battle-log .ok { color: var(--ok); }

/* Strike FX — dash to target (JS sets transform), impact, return */
.unit-card.fx-dashing {
  pointer-events: none;
  will-change: transform;
  filter: drop-shadow(0 0 10px rgba(224, 197, 106, 0.45));
}
.unit-card.fx-rush-party { animation: rush-party 0.28s ease-out; }
.unit-card.fx-rush-enemy { animation: rush-enemy 0.28s ease-out; }
.unit-card.fx-hit { animation: hit-shake 0.35s ease; }
.unit-card.fx-flash { animation: self-flash 0.35s ease; }

@keyframes rush-party {
  0% { transform: translate(-50%, -85%); }
  45% { transform: translate(calc(-50% - 36px), calc(-85% - 8px)); }
  100% { transform: translate(-50%, -85%); }
}
@keyframes rush-enemy {
  0% { transform: translate(-50%, -85%); }
  45% { transform: translate(calc(-50% + 36px), calc(-85% - 6px)); }
  100% { transform: translate(-50%, -85%); }
}
@keyframes hit-shake {
  0%, 100% { filter: brightness(1); }
  20% { filter: brightness(1.85) saturate(1.2); }
  40% { filter: brightness(1.25); }
  55% { filter: brightness(1.7); }
  100% { filter: brightness(1); }
}

/* Melee impact burst at target */
/* Sequence VFX from assets/VFX (battleVfx.json packs) */
.battle-vfx {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 10;
  pointer-events: none;
  overflow: visible;
}
.battle-vfx img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.battle-vfx.is-crit {
  filter: brightness(1.12) saturate(1.15);
}
.battle-vfx.is-miss {
  opacity: 0.72;
  filter: grayscale(0.25) brightness(1.05);
}

.battle-impact {
  position: absolute;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  z-index: 9;
  pointer-events: none;
}
.battle-impact .battle-slash,
.battle-impact .battle-burst,
.battle-impact .battle-spark {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}
.battle-impact .battle-slash {
  width: 110px;
  height: 6px;
  margin: -3px 0 0 -55px;
  border-radius: 3px;
  background: linear-gradient(90deg, transparent, #fff6c8 20%, #ffe08a 50%, #ff8a4a 80%, transparent);
  box-shadow: 0 0 12px rgba(255, 210, 120, 0.9), 0 0 22px rgba(255, 120, 60, 0.55);
  transform: rotate(-28deg) scaleX(0.2);
  animation: battle-slash 0.38s ease-out forwards;
}
.battle-impact .battle-burst {
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 240, 180, 0.85) 0%, rgba(255, 140, 60, 0.35) 40%, transparent 70%);
  animation: battle-burst 0.4s ease-out forwards;
}
.battle-impact .battle-spark {
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #fff8d8;
  box-shadow:
    0 0 10px #ffe08a,
    18px -12px 0 0 #ffd06a,
    -16px 10px 0 -2px #ffb050,
    10px 16px 0 -3px #fff0c0,
    -12px -14px 0 -2px #ffc878;
  animation: battle-spark 0.4s ease-out forwards;
}
.battle-impact.is-miss .battle-slash {
  background: linear-gradient(90deg, transparent, #c8c0b4 30%, #a8a090 70%, transparent);
  box-shadow: 0 0 8px rgba(200, 190, 170, 0.45);
  opacity: 0.65;
}
.battle-impact.is-miss .battle-burst,
.battle-impact.is-miss .battle-spark { opacity: 0.35; }
.battle-impact.is-crit .battle-slash {
  height: 8px;
  background: linear-gradient(90deg, transparent, #fff 15%, #ffe66a 45%, #ff6a3a 75%, transparent);
  box-shadow: 0 0 18px rgba(255, 220, 100, 1), 0 0 32px rgba(255, 100, 40, 0.7);
}
@keyframes battle-slash {
  0% { transform: rotate(-28deg) scaleX(0.15); opacity: 0; }
  35% { transform: rotate(-28deg) scaleX(1.05); opacity: 1; }
  100% { transform: rotate(-28deg) scaleX(1.2); opacity: 0; }
}
@keyframes battle-burst {
  0% { transform: scale(0.3); opacity: 0.9; }
  100% { transform: scale(1.55); opacity: 0; }
}
@keyframes battle-spark {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}
@keyframes self-flash {
  0%, 100% { filter: brightness(1); }
  40% { filter: brightness(1.55) saturate(1.2); }
}
@keyframes near-death-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}
@keyframes target-pulse {
  0%, 100% { outline-color: rgba(110, 200, 120, 0.4); }
  50% { outline-color: rgba(110, 200, 120, 0.95); }
}
@keyframes float-up {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.9); }
  15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -36px) scale(1); }
}

.battle-float-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  overflow: hidden;
}
.battle-float {
  position: absolute;
  transform: translate(-50%, 0);
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.15rem;
  text-shadow: 0 2px 4px #000, 0 0 8px rgba(0, 0, 0, 0.6);
  animation: float-up 0.65s ease-out forwards;
  white-space: nowrap;
}
.battle-float-damage { color: #ff6b5a; }
.battle-float-heal { color: #6ddea8; }
.battle-float-miss { color: #c8c0b4; font-size: 0.95rem; }
.battle-float-status { color: #d4a0ff; font-size: 0.95rem; }
.battle-float-crit { color: #ffd76a; font-size: 1.25rem; }
.battle-float-center {
  left: 50% !important;
  top: 38% !important;
  font-size: 1.6rem;
}

.battle-result {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgba(8, 6, 4, 0.45);
  pointer-events: none;
}
.battle-result.hidden { display: none; }
.battle-result-card {
  min-width: min(320px, 86vw);
  text-align: center;
  padding: 1.1rem 1.4rem 0.9rem;
  border-radius: 4px;
  border: 2px solid rgba(196, 163, 90, 0.55);
  background: rgba(22, 18, 14, 0.94);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
.battle-result-card.ok { border-color: rgba(212, 175, 110, 0.55); }
.battle-result-card.bad { border-color: rgba(180, 70, 60, 0.55); }
.battle-result-title {
  font-family: var(--font);
  font-size: 1.6rem;
  color: var(--accent);
  letter-spacing: 0.12em;
  margin-bottom: 0.45rem;
}
.battle-result-line {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0.15rem 0;
}
.battle-result-hint { margin-top: 0.55rem; font-size: 0.75rem; }

body.mode-battle #topbar { display: none !important; }
body.mode-battle .editor-root { display: none !important; }
@media (max-width: 820px) {
  .battle-stage { touch-action: none; }
  .battle-cmd-wrap {
    right: auto;
    left: 50%;
    top: auto;
    bottom: max(5.2rem, calc(env(safe-area-inset-bottom, 0px) + 4.6rem));
    transform: translateX(-50%);
    align-items: center;
    width: min(96vw, 420px);
  }
  .battle-cmd-wheel {
    --wheel: auto;
    width: 100%;
    height: auto;
    border-radius: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.45rem;
    background: rgba(28, 22, 16, 0.92);
  }
  .battle-cmd-wheel::before { display: none; }
  .battle-cmd-wheel .wheel-seg {
    position: static;
    left: auto;
    top: auto;
    width: auto;
    min-width: 4.2rem;
    min-height: 44px;
    margin: 0;
    transform: none;
    padding: 0.45rem 0.7rem;
    border: 1px solid rgba(196, 163, 90, 0.45);
    border-radius: 6px;
    background: rgba(42, 34, 24, 0.95);
    font-size: 0.82rem;
  }
  .battle-cmd-wheel .wheel-hub {
    position: static;
    margin: 0;
    width: auto;
    min-width: 4.2rem;
    height: 44px;
    border-radius: 6px;
  }
  .battle-cmd-wheel.busy::after {
    border-radius: 10px;
  }
  .battle-cmd-sub {
    max-width: 100%;
    justify-content: center;
  }
  .battle-cmd-sub button {
    min-height: 44px;
    padding: 0.45rem 0.75rem;
  }
  .battle-active-panel { width: min(220px, 46vw); font-size: 0.7rem; }
  .battle-party-hud { flex-wrap: wrap; justify-content: center; }
  .battle-log { display: none; }
}

/* Panel */
.panel-card {
  width: min(560px, 100%); max-height: 85vh; overflow: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1rem;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.panel-head h3 { margin: 0; font-family: var(--font); }
.kv { display: grid; grid-template-columns: 5rem 1fr; gap: 0.25rem 0.5rem; font-size: 0.85rem; margin-bottom: 0.8rem; }
.kv span:nth-child(odd) { color: var(--muted); }
.item-row, .quest-row {
  border-top: 1px solid var(--line); padding: 0.55rem 0; font-size: 0.85rem;
  display: flex; justify-content: space-between; gap: 0.5rem; align-items: center;
}

/* Player menu — mobile: full width + vertical scroll; desktop: centered contain */
#screen-player {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  box-sizing: border-box;
  position: fixed;
  inset: 0;
  z-index: 45;
  width: 100%;
  height: 100%;
  min-height: var(--lvh, 100%);
  padding: 0;
  margin: 0;
  background: #0a0908;
}
html.orient-portrait-lock #screen-player {
  width: var(--lvw, 100%);
  height: var(--lvh, 100%);
  min-height: var(--lvh, 100%);
}
/* Player menu — ref: cankao/角色菜单参考.png */
.player-menu {
  --pm-design-w: 1180px;
  --pm-design-h: 860px;
  width: var(--pm-scaled-w, calc(var(--pm-design-w) * var(--pm-scale-x, var(--pm-scale, 1))));
  height: var(--pm-scaled-h, calc(var(--pm-design-h) * var(--pm-scale-y, var(--pm-scale, 1))));
  max-width: none;
  max-height: none;
  margin: 0;
  overflow: hidden;
  flex: 0 0 auto;
  position: relative;
}
html:not(.ui-touch):not(.ui-compact) #screen-player {
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: auto;
}
html:not(.ui-touch):not(.ui-compact) .player-menu {
  max-width: 100%;
  max-height: 100%;
}
html.ui-touch .player-menu,
html.ui-compact .player-menu {
  width: 100%;
  max-width: 100%;
}
.pm-frame {
  --pm-gold: #d4b36a;
  --pm-gold-dim: #9a7a3e;
  --pm-ink: #e8e0d4;
  --pm-accent: #a83a3a;
  --pm-accent-hi: #c44a4a;
  --pm-panel: rgba(18, 16, 14, 0.78);
  --pm-panel2: rgba(10, 9, 8, 0.88);
  --pm-line: rgba(180, 160, 130, 0.22);
  --pm-line2: rgba(180, 160, 130, 0.35);
  width: var(--pm-design-w, 1180px);
  height: var(--pm-design-h, 860px);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem 0.9rem 0.8rem;
  color: var(--pm-ink);
  font-family: var(--ui);
  background:
    radial-gradient(ellipse at 50% 20%, rgba(60, 28, 24, 0.35), transparent 55%),
    linear-gradient(180deg, rgba(12, 11, 10, 0.94), rgba(6, 5, 4, 0.97));
  border: none;
  border-radius: 0;
  box-shadow: none;
  position: absolute;
  left: 0;
  top: 0;
  transform: scale(var(--pm-scale-x, var(--pm-scale, 1)), var(--pm-scale-y, var(--pm-scale, 1)));
  transform-origin: top left;
  box-sizing: border-box;
}
.pm-top {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.15rem 0.25rem 0.55rem;
  border-bottom: 1px solid var(--pm-line);
}
.pm-top-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.pm-top-seal {
  width: 0.55rem;
  height: 1.6rem;
  background: linear-gradient(180deg, var(--pm-accent-hi), var(--pm-accent));
  box-shadow: 0 0 10px rgba(168, 58, 58, 0.45);
}
.pm-top-title h2 {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: 0.28em;
  color: #f4efe6;
}
.pm-top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
}
.pm-nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: #b9aea0;
  font-family: var(--font);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.55rem;
  min-width: 0;
  white-space: nowrap;
}
.pm-frame-panel {
  min-height: 0;
}
.pm-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.6rem 0.35rem 0.4rem;
}
.pm-panel-foot {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.35rem;
  border-top: 1px solid var(--pm-line);
}
.pm-atlas-host {
  min-height: min(520px, 62vh);
  height: 100%;
}
.pm-atlas-host .atlas-frame {
  min-height: min(520px, 62vh);
  height: 100%;
}
.pm-map-panel h4 {
  margin: 0 0 0.6rem;
  font-family: var(--font);
  color: var(--pm-gold);
  letter-spacing: 0.12em;
}
.pm-nav-tab.is-on {
  color: #fff;
  background: linear-gradient(180deg, var(--pm-accent-hi), var(--pm-accent));
  border-color: rgba(255, 200, 180, 0.18);
  box-shadow: 0 0 14px rgba(168, 58, 58, 0.35);
}
.pm-nav-tab:hover:not(:disabled):not(.is-on) {
  color: #f0e8dc;
  border-color: var(--pm-line2);
}
.pm-nav-tab:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.pm-top-gold {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--pm-gold);
  font-family: var(--font);
  letter-spacing: 0.04em;
}
.pm-gold-ico {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #f5e6a8, #c9a44a 55%, #7a5a18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.pm-top-gold b { font-weight: 600; color: #f2e6c8; }

.pm-cols {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(230px, 0.95fr) minmax(240px, 1.05fr) minmax(260px, 1.15fr);
  gap: 0.65rem;
}
.pm-cols-main {
  grid-template-columns: minmax(280px, 1.1fr) minmax(300px, 1.2fr);
}
.pm-col {
  background: linear-gradient(180deg, var(--pm-panel), var(--pm-panel2));
  border: 1px solid var(--pm-line);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
  padding: 0.65rem 0.7rem;
  overflow: auto;
}
/* Fig.1 — character info at bottom */
.pm-bottom {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-shrink: 0;
  min-height: 0;
}
.pm-sheet {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(196, 150, 80, 0.35);
  box-shadow: inset 0 0 0 1px rgba(120, 80, 40, 0.35);
  background: rgba(0, 0, 0, 0.28);
  padding: 0.4rem 0.45rem 0.35rem;
}
.pm-sheet-bottom {
  display: grid;
  grid-template-columns: minmax(200px, 1.15fr) minmax(200px, 1.1fr) auto;
  gap: 0.55rem 0.75rem;
  align-items: start;
  max-height: min(260px, 34vh);
  overflow: auto;
}
.pm-sheet-col {
  min-width: 0;
}
.pm-sheet-radar {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  border-left: 1px solid rgba(180, 160, 130, 0.16);
  padding-left: 0.35rem;
}
.pm-sheet-head {
  margin-bottom: 0.3rem;
  padding-bottom: 0.28rem;
  border-bottom: 1px solid rgba(180, 160, 130, 0.2);
}
.pm-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.28rem;
}
.pm-sheet-name {
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: #f0d090;
}
.pm-sheet-lv {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: #e8c878;
  white-space: nowrap;
}
.pm-exp-row {
  display: grid;
  grid-template-columns: 2.6rem 1fr;
  align-items: center;
  gap: 0.3rem;
}
.pm-exp-lab {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #c9b89a;
}
.pm-exp-bar {
  position: relative;
  height: 0.85rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(180, 160, 130, 0.35);
  overflow: hidden;
}
.pm-exp-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #6a3030, var(--pm-accent-hi));
}
.pm-exp-bar span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #f0e8dc;
  letter-spacing: 0.04em;
}
.pm-vitals {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
  margin: 0.15rem 0 0.3rem;
  padding: 0.28rem 0.15rem;
  border-top: 1px solid rgba(180, 160, 130, 0.18);
  border-bottom: 1px solid rgba(180, 160, 130, 0.18);
}
.pm-vital {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--pm-ink);
  font-family: var(--ui);
  font-size: 0.82rem;
  padding: 0.1rem 0.1rem;
  text-align: left;
  cursor: help;
}
.pm-vital:hover,
.pm-vital:focus-visible {
  background: rgba(168, 58, 58, 0.12);
  outline: none;
}
.pm-vital-lab {
  color: #c9b89a;
  letter-spacing: 0.06em;
}
.pm-vital-track {
  position: relative;
  height: 0.72rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(180, 160, 130, 0.28);
  overflow: hidden;
}
.pm-vital-track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #5a2828, var(--pm-accent-hi));
}
.pm-vital-num {
  min-width: 3.6rem;
  text-align: right;
  font-weight: 600;
  color: #f0e8dc;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}
.pm-combat-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 0.3rem;
  border: 1px solid rgba(180, 160, 130, 0.22);
  background: rgba(0, 0, 0, 0.28);
}
.pm-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid rgba(180, 160, 130, 0.14);
}
.pm-pair:last-child {
  border-bottom: none;
}
.pm-pair .pm-statline {
  padding: 0.18rem 0.35rem;
  font-size: 0.82rem;
}
.pm-pair .pm-statline + .pm-statline {
  border-left: 1px solid rgba(180, 160, 130, 0.14);
}
.pm-attr-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.15rem 0.35rem;
  margin: 0.1rem 0 0.15rem;
}
.pm-status-block {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.35rem;
  align-items: stretch;
  margin: 0 0 0.3rem;
  min-height: 2.2rem;
  border: 1px solid rgba(180, 160, 130, 0.22);
  background: rgba(0, 0, 0, 0.22);
}
.pm-status-lab {
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: #c9b89a;
  border-right: 1px solid rgba(180, 160, 130, 0.18);
  background: rgba(40, 28, 18, 0.45);
}
.pm-status-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  padding: 0.25rem 0.35rem;
}
.pm-status-chip {
  border: 1px solid rgba(180, 160, 130, 0.28);
  background: rgba(0, 0, 0, 0.35);
  color: #f0e8dc;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  padding: 0.12rem 0.45rem;
  min-width: 3.2rem;
  text-align: center;
}
.pm-sheet-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem;
  margin-bottom: 0.25rem;
}
.pm-foot-cell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgba(180, 160, 130, 0.22);
  background: rgba(0, 0, 0, 0.28);
  color: var(--pm-ink);
  font-family: var(--ui);
  font-size: 0.82rem;
  padding: 0.22rem 0.4rem;
  text-align: left;
  cursor: help;
}
.pm-foot-cell span { color: #c9b89a; letter-spacing: 0.06em; }
.pm-foot-cell b { font-weight: 600; color: #f4efe6; }
.pm-foot-cell.has-pot b { color: #f0d090; }
.pm-foot-cell:hover,
.pm-foot-cell:focus-visible {
  background: rgba(168, 58, 58, 0.14);
  outline: none;
}
.pm-attr, .pm-statline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.3rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--pm-ink);
  font-family: var(--ui);
  font-size: 0.88rem;
  padding: 0.18rem 0.2rem;
  text-align: left;
}
.pm-attr {
  border-radius: 2px;
  border: 1px solid rgba(180, 160, 130, 0.12);
  background: rgba(0, 0, 0, 0.18);
  padding: 0.22rem 0.28rem;
}
.pm-attr-ico {
  width: 0.85rem;
  height: 0.85rem;
  flex-shrink: 0;
  border: 1px solid rgba(196, 74, 74, 0.55);
  background:
    linear-gradient(90deg, transparent 42%, rgba(220, 90, 80, 0.85) 42%, rgba(220, 90, 80, 0.85) 58%, transparent 58%),
    linear-gradient(0deg, transparent 42%, rgba(220, 90, 80, 0.85) 42%, rgba(220, 90, 80, 0.85) 58%, transparent 58%),
    rgba(255, 255, 255, 0.08);
}
.pm-attr:hover, .pm-statline:hover,
.pm-attr:focus-within, .pm-statline:focus-visible {
  background: rgba(168, 58, 58, 0.14);
  outline: none;
}
.pm-attr-btns {
  display: inline-flex;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}
.pm-pm {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 1px solid var(--pm-line2);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--pm-gold);
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}
.pm-pm:hover:not(:disabled) {
  background: rgba(168, 58, 58, 0.35);
  border-color: var(--pm-accent-hi);
  color: #fff4d4;
}
.pm-pm:disabled {
  opacity: 0.35;
  cursor: default;
}
.pm-attr-lab, .pm-statline span { color: #c9b89a; letter-spacing: 0.06em; }
.pm-attr-lab { flex: 1; min-width: 0; }
.pm-attr-val, .pm-statline b { font-weight: 600; color: #f4efe6; }
.pm-bonus {
  margin-left: 0.2rem;
  font-style: normal;
  font-size: 0.72rem;
  color: #8fd48a;
  font-weight: 500;
}
.pm-attr.can-spend {
  box-shadow: inset 0 0 0 1px rgba(168, 58, 58, 0.28);
}
.pm-radar-wrap {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: none;
}
.pm-radar {
  width: min(148px, 100%);
  height: auto;
}
/* Fig.1 bottom party cards */
.pm-party-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: stretch;
}
.pm-party-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}
.pm-party-card {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  min-width: 168px;
  flex: 0 1 200px;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(180, 160, 130, 0.28);
  background: rgba(8, 7, 6, 0.75);
  color: var(--pm-ink);
  font-family: var(--ui);
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.pm-party-card.is-on {
  border-color: rgba(212, 179, 106, 0.65);
  background: rgba(40, 24, 18, 0.85);
  box-shadow:
    0 0 0 1px rgba(212, 179, 106, 0.25),
    inset 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.pm-party-card:hover {
  border-color: rgba(196, 74, 74, 0.55);
}
.pm-party-face {
  width: 52px;
  height: 52px;
  object-fit: cover;
  object-position: top;
  flex-shrink: 0;
  border: 1px solid rgba(180, 160, 130, 0.35);
  background: #14110e;
}
.pm-party-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.14rem;
  justify-content: center;
}
.pm-party-name {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #e8dcc4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pm-party-bar {
  position: relative;
  height: 0.42rem;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(180, 160, 130, 0.22);
  overflow: hidden;
}
.pm-party-bar i {
  display: block;
  height: 100%;
}
.pm-party-bar.hp i {
  background: linear-gradient(90deg, #6a2020, #c44a4a);
}
.pm-party-bar.mp i {
  background: linear-gradient(90deg, #1a3a6a, #4a8ad4);
}
.pm-party-bar.xp i {
  background: linear-gradient(90deg, #2a5a28, #6cbc68);
}
.pm-party-status {
  align-self: flex-end;
  margin-top: 0.05rem;
  border: 1px solid rgba(180, 160, 130, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: #c9b89a;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  padding: 0.05rem 0.35rem;
}
.pm-radar-ring {
  fill: none;
  stroke: rgba(180, 160, 130, 0.22);
  stroke-width: 1;
}
.pm-radar-axis {
  stroke: rgba(180, 160, 130, 0.18);
  stroke-width: 1;
}
.pm-radar-fill {
  fill: rgba(168, 58, 58, 0.35);
  stroke: rgba(212, 100, 90, 0.85);
  stroke-width: 1.5;
}
.pm-radar-lab {
  fill: #c9b89a;
  font-size: 9px;
  font-family: var(--font);
}

.pm-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(ellipse at 50% 70%, rgba(50, 30, 24, 0.45), transparent 60%),
    linear-gradient(180deg, var(--pm-panel), var(--pm-panel2));
}
.pm-avatar-wrap {
  width: 100%;
  flex: 1;
  min-height: 340px;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  grid-template-rows: repeat(3, 1fr);
  gap: 0.45rem 0.55rem;
  align-items: center;
  padding: 0.35rem 0.15rem;
}
.pm-avatar-wrap .pm-avatar {
  grid-column: 2;
  grid-row: 1 / span 3;
  justify-self: center;
  align-self: end;
}
.pm-equip-l0 { grid-column: 1; grid-row: 1; }
.pm-equip-l1 { grid-column: 1; grid-row: 2; }
.pm-equip-l2 { grid-column: 1; grid-row: 3; }
.pm-equip-r0 { grid-column: 3; grid-row: 1; }
.pm-equip-r1 { grid-column: 3; grid-row: 2; }
.pm-equip-r2 { grid-column: 3; grid-row: 3; }
.pm-equip {
  width: 72px;
  height: 72px;
  aspect-ratio: 1 / 1;
  flex: 0 0 72px;
  border: 1px solid var(--pm-line2);
  background: rgba(8, 7, 6, 0.75);
  color: var(--pm-ink);
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  position: relative;
  justify-content: space-between;
  font-family: var(--ui);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  box-sizing: border-box;
}
.pm-equip.has-item { border-color: rgba(168, 58, 58, 0.65); }
.pm-equip.is-locked { opacity: 0.4; }
.pm-equip:hover, .pm-equip:focus-visible {
  border-color: var(--pm-accent-hi);
  outline: none;
}
.pm-equip-lab {
  position: relative;
  z-index: 1;
  font-size: 0.62rem;
  color: #8a8074;
  letter-spacing: 0.08em;
}
.pm-equip-icon {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 68%;
  height: 68%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  margin: 0;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}
.pm-equip-name {
  position: relative;
  z-index: 1;
  font-size: 0.62rem;
  color: var(--pm-gold);
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
}
.pm-equip.has-item:not(.no-icon) .pm-equip-name {
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.75));
  margin: 0 -0.25rem -0.25rem;
  padding: 0.1rem 0.2rem;
}
.pm-avatar {
  width: min(220px, 58%);
  aspect-ratio: 9 / 16;
  border: none;
  background: transparent;
  box-shadow: none;
  z-index: 1;
  overflow: hidden;
}
.pm-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: contrast(1.05) saturate(0.9) drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55));
}

.pm-right {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.pm-right-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pm-right-title {
  font-family: var(--font);
  letter-spacing: 0.16em;
  color: #f0e8dc;
}
.pm-right-meta {
  font-size: 0.78rem;
  color: #8a8074;
}
.pm-filters {
  display: flex;
  gap: 0.25rem;
}
.pm-filter {
  border: 1px solid var(--pm-line);
  background: rgba(0, 0, 0, 0.3);
  color: #b9aea0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.45rem;
  font-family: var(--font);
}
.pm-filter.is-on {
  color: #fff;
  background: rgba(168, 58, 58, 0.55);
  border-color: rgba(196, 74, 74, 0.65);
}
.pm-grid {
  --pm-gap: 4px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  /* JS sets grid-auto-rows to column width; CSS fallback below */
  grid-auto-rows: auto;
  gap: var(--pm-gap);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--pm-line);
  padding: 4px;
  flex: 1;
  min-height: 220px;
  align-content: start;
  align-items: stretch;
  justify-items: stretch;
  overflow: auto;
}
/* Beat global `button { padding }` — slots are square boxes */
button.pm-grid-cell,
.pm-grid-cell {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 !important;
  border: 1px solid rgba(180, 160, 130, 0.2);
  border-radius: 0;
  background: rgba(14, 12, 10, 0.9);
  color: var(--pm-ink);
  font-family: var(--ui);
  font-size: 0.68rem;
  line-height: 1.2;
  overflow: hidden;
  box-sizing: border-box;
  display: block;
  appearance: none;
  -webkit-appearance: none;
}
/* In-flow square sizer (absolute icon/name do not contribute height) */
.pm-grid-sizer {
  display: block;
  width: 100%;
  height: 0;
  padding-bottom: 100%;
  pointer-events: none;
  visibility: hidden;
}
.pm-grid-icon {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 72%;
  height: 58%;
  max-width: 72%;
  max-height: 58%;
  margin: 0;
  transform: translate(-50%, -50%);
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  z-index: 0;
}
.pm-grid-cell.has-item:not(.no-icon) .pm-grid-name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  margin: 0;
  font-size: 0.58rem;
  line-height: 1.1;
  -webkit-line-clamp: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.72));
  padding: 0.15rem 0.2rem 0.1rem;
}
.pm-grid-cell.has-item:not(.no-icon) .pm-grid-qty {
  position: absolute;
  right: 3px;
  bottom: 1.15rem;
  z-index: 2;
  font-size: 0.62rem;
  font-weight: 600;
  color: #fff4d4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.pm-grid-cell.no-icon .pm-grid-icon { display: none; }
.pm-grid-cell.is-quest {
  border-color: rgba(196, 90, 74, 0.55);
  box-shadow: inset 0 0 0 1px rgba(196, 90, 74, 0.25);
}
.pm-cat-badges {
  position: absolute;
  top: 2px;
  right: 2px;
  z-index: 2;
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 70%;
}
.pm-cat-badge,
.pm-quest-badge {
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  padding: 0 0.22rem;
  border-radius: 2px;
  border: 1px solid rgba(196, 90, 74, 0.85);
  color: #f0c0b0;
  background: rgba(90, 28, 22, 0.92);
  line-height: 1.35;
}
.pm-cat-badge.pm-cat-weapon {
  border-color: rgba(138, 158, 184, 0.9);
  color: #d0dceb;
  background: rgba(40, 52, 72, 0.92);
}
.pm-cat-badge.pm-cat-pill {
  border-color: rgba(122, 158, 106, 0.9);
  color: #d0e8c4;
  background: rgba(36, 56, 30, 0.92);
}
.pm-cat-badge.pm-cat-quest {
  border-color: rgba(196, 90, 74, 0.85);
  color: #f0c0b0;
  background: rgba(90, 28, 22, 0.92);
}
.pm-cat-badge.pm-cat-artifact {
  border-color: rgba(196, 163, 90, 0.9);
  color: #f0e0b0;
  background: rgba(72, 56, 24, 0.92);
}
.pm-grid-cell.empty { pointer-events: none; opacity: 0.4; }
.pm-grid-cell.has-item:hover,
.pm-grid-cell.has-item:focus-visible {
  border-color: var(--pm-accent-hi);
  background: rgba(40, 22, 18, 0.95);
  outline: none;
}
.pm-grid-name {
  position: absolute;
  left: 0.2rem;
  right: 0.2rem;
  bottom: 0.2rem;
  z-index: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #e8dcc4;
}
.pm-grid-qty {
  position: absolute;
  right: 3px;
  bottom: 1.15rem;
  z-index: 2;
  color: #f0e8dc;
}
.pm-grid-cell.can-upgrade {
  box-shadow: inset 0 0 0 1px rgba(168, 58, 58, 0.45);
}
.pm-grid-cell.can-upgrade:hover {
  background: rgba(168, 58, 58, 0.16);
}
.pm-up-cost {
  display: block;
  font-style: normal;
  font-size: 0.68rem;
  color: #c9b06a;
  font-weight: 500;
}
.pm-page {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  color: #b9aea0;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
}
.pm-page-btn {
  border: 1px solid var(--pm-line2);
  background: rgba(0, 0, 0, 0.35);
  color: #e8dcc4;
  padding: 0.1rem 0.4rem;
  font-size: 0.75rem;
}
.pm-page-btn:disabled { opacity: 0.35; }
.pm-bottom .pm-desc {
  border: 1px solid var(--pm-line);
  background: rgba(8, 7, 6, 0.72);
  min-height: 2.2rem;
  max-height: 3.2rem;
  overflow: auto;
  padding: 0.4rem 0.65rem;
  color: #d8cfc0;
  font-size: 0.82rem;
  line-height: 1.45;
}
.pm-back {
  min-width: 6.5rem;
  font-family: var(--font);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  color: #f0e8dc;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--pm-line2);
  padding: 0.45rem 0.9rem;
  align-self: stretch;
}
.pm-back kbd {
  font-family: var(--ui);
  font-size: 0.78rem;
  letter-spacing: 0;
  color: var(--pm-gold);
  margin-right: 0.2rem;
}
.pm-back:hover {
  border-color: var(--pm-accent-hi);
  background: rgba(168, 58, 58, 0.28);
}
/* Menu stays desktop layout; phones full-width scale + #screen-player vertical scroll. */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  z-index: 50; background: var(--card); border: 1px solid var(--accent);
  padding: 0.55rem 1rem; border-radius: 6px; font-size: 0.85rem;
}

/* —— 2.5D Explore —— */
#screen-explore {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  padding: 0;
  max-width: none;
  margin: 0;
}
#explore-root {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0a0908;
  touch-action: none;
}
.explore-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}
.explore-move-marker {
  position: absolute;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  border: 2px solid rgba(232, 210, 140, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(40, 28, 12, 0.35), 0 0 12px rgba(196, 163, 90, 0.55);
  pointer-events: none;
  z-index: 4;
  animation: move-marker-pulse 0.9s ease-out infinite;
}
@keyframes move-marker-pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.55); opacity: 0.25; }
}
.explore-world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.explore-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #1a1612;
}
/* Dual-layer OSS progressive: LQIP blur under, sharp mid/playable on top. */
.explore-bg-lqip,
.explore-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  user-select: none;
}
.explore-bg-lqip {
  z-index: 0;
  transform: scale(1.08);
  filter: saturate(1.05) contrast(1.05);
  transition: opacity 0.35s ease;
}
.explore-bg-lqip.is-hidden {
  opacity: 0;
}
.explore-bg-img {
  z-index: 1;
  filter: saturate(1.05) contrast(1.05);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.explore-bg-img.is-shown,
.explore-bg.img-sharp .explore-bg-img {
  opacity: 1;
}
/* Local/non-OSS fallback: CSS soft→sharp on single layer */
.explore-bg.img-soft:not(:has(.explore-bg-lqip[src])) .explore-bg-img {
  filter: blur(18px) saturate(1.05) contrast(1.05);
  transform: scale(1.045);
  opacity: 0.9;
}
.explore-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 70%, transparent 30%, rgba(10, 8, 6, 0.45) 100%),
    linear-gradient(180deg, rgba(18, 16, 14, 0.15), rgba(18, 16, 14, 0.35));
  pointer-events: none;
  z-index: 1;
}
.explore-ground {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 40% 55%, rgba(60, 90, 50, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 40%, rgba(80, 70, 40, 0.12) 0%, transparent 45%);
  pointer-events: none;
}
.explore-player {
  position: absolute;
  width: 56px;
  height: 72px;
  transform: translate(-50%, -85%);
  pointer-events: none;
}
.explore-player .player-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 36px;
  height: 12px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.4);
  border-radius: 50%;
  filter: blur(1px);
}
.explore-player .player-sprite {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 48px;
  height: 60px;
  object-fit: cover;
  object-position: top;
  transform: translateX(-50%);
  border-radius: 6px 6px 4px 4px;
  border: 1px solid rgba(196, 163, 90, 0.55);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  background: #1c1814;
  image-rendering: auto;
}
.explore-player.is-walk-sheet {
  width: 72px;
  height: 88px;
}
.explore-player.is-walk-sheet .player-sprite {
  width: 64px;
  height: 80px;
  object-fit: contain;
  object-position: bottom center;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
.explore-player.face-left .player-sprite {
  transform: translateX(-50%) scaleX(-1);
}
.explore-player .player-name {
  position: absolute;
  left: 50%;
  top: -1.1rem;
  transform: translateX(-50%);
  font-size: 0.68rem;
  white-space: nowrap;
  padding: 0.05rem 0.35rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 3px;
  color: #e8dfd0;
}
.explore-ent {
  position: absolute;
  width: 72px;
  height: 92px;
  transform: translate(-50%, -85%);
}
.explore-ent .ent-shadow {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 40px;
  height: 12px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
}
.explore-ent .ent-sprite {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 52px;
  height: 64px;
  object-fit: cover;
  object-position: top;
  transform: translateX(-50%);
  border-radius: 6px;
  border: 1px solid rgba(90, 143, 154, 0.5);
  background: #1c1814;
}
.explore-ent .ent-sprite.is-fullbody {
  width: 64px;
  height: 80px;
  object-fit: contain;
  object-position: bottom center;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  transform: translateX(-50%) scale(var(--icon-scale, 1));
  transform-origin: bottom center;
  transition: filter 0.35s ease, opacity 0.35s ease;
}
.explore-ent .ent-sprite.img-soft {
  filter: blur(8px);
  opacity: 0.75;
}
.explore-ent .ent-sprite.img-sharp {
  filter: none;
  opacity: 1;
}
.explore-ent.kind-enemy .ent-sprite {
  border-color: rgba(184, 92, 56, 0.65);
}
.explore-ent.locked {
  filter: grayscale(0.55) brightness(0.75);
}
.explore-ent.near .ent-sprite,
.explore-ent.near .ent-marker {
  box-shadow: 0 0 0 2px var(--accent);
}
.explore-ent .ent-label {
  position: absolute;
  left: 50%;
  top: -1.15rem;
  transform: translateX(-50%);
  font-size: 0.66rem;
  white-space: nowrap;
  padding: 0.05rem 0.3rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 3px;
  color: #d8c9a8;
}
.explore-ent .ent-hp {
  position: absolute;
  left: 50%;
  top: -1.85rem;
  width: 42px;
  height: 5px;
  transform: translateX(-50%);
  background: #2a2420;
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid #3a3228;
}
.explore-ent .ent-hp > i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--hp);
}
.explore-ent .ent-marker {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: 44px;
  height: 44px;
  transform: translateX(-50%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #f5ecd8;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent2) 80%, #000);
}
.explore-ent .ent-marker.exit { background: #2a4030; border-color: var(--ok); }
.explore-ent .ent-marker.enemy { background: #40241c; border-color: var(--hp); }
.explore-ent .ent-marker.rest { background: #1c3040; border-color: var(--mind); }
.explore-ent .ent-marker.shop { background: #3a3018; border-color: var(--pm-gold, #e0c56a); font-size: 0.75rem; }
.explore-ent .ent-marker.npc { display: none; }

/* Shop panel */
.shop-frame { display: flex; flex-direction: column; gap: 0.65rem; }
.shop-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.shop-tabs { display: flex; gap: 0.35rem; }
.shop-tab {
  border: 1px solid rgba(196, 154, 74, 0.45);
  background: rgba(0, 0, 0, 0.25);
  color: var(--pm-gold, #e0c56a);
  font-family: var(--font);
  padding: 0.35rem 0.85rem;
  cursor: pointer;
}
.shop-tab.is-on,
.shop-tab:hover:not(:disabled) {
  background: rgba(224, 197, 106, 0.2);
  border-color: var(--pm-gold, #e0c56a);
}
.shop-tab:disabled { opacity: 0.4; cursor: default; }
.shop-gold { color: #fff4d4; letter-spacing: 0.06em; }
.shop-gold b { color: var(--pm-gold, #e0c56a); }
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: min(48vh, 360px);
  overflow: auto;
}
.shop-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.75rem;
  text-align: left;
  border: 1px solid rgba(196, 154, 74, 0.35);
  background: rgba(0, 0, 0, 0.28);
  color: #f5ecd8;
  font-family: var(--font);
  padding: 0.55rem 0.7rem;
  cursor: pointer;
}
.shop-row:hover { border-color: #f0df9a; background: rgba(60, 36, 16, 0.9); }
.shop-row.is-poor { opacity: 0.55; }
.shop-name { grid-column: 1; color: var(--pm-gold, #e0c56a); font-weight: 600; }
.shop-desc { grid-column: 1; font-size: 0.82rem; color: #b9a57a; }
.shop-price { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: #fff4d4; white-space: nowrap; }
.shop-tip { margin: 0.2rem 0 0; min-height: 1.4em; }
.explore-ent.kind-exit .ent-sprite.hidden { display: none; }

/* Exploration chests — small, quiet markers; label only when near */
.explore-ent.kind-chest,
.explore-ent.kind-chest-open {
  width: 40px;
  height: 48px;
  opacity: 0.78;
}
.explore-ent.kind-chest .ent-marker,
.explore-ent.kind-chest-open .ent-marker {
  width: 28px;
  height: 24px;
  border-radius: 3px;
  font-size: 0.62rem;
  font-weight: 650;
  color: #d8c9a8;
  letter-spacing: 0.02em;
  bottom: 6px;
}
.explore-ent .ent-marker.chest {
  background: #3a2e22;
  border-color: rgba(138, 112, 80, 0.75);
}
.explore-ent .ent-marker.chest-open {
  background: #2a2620;
  border-color: rgba(90, 80, 64, 0.7);
  color: #8a8070;
}
.explore-ent.kind-chest .ent-label,
.explore-ent.kind-chest-open .ent-label {
  display: none;
  font-size: 0.68rem;
  opacity: 0.9;
}
.explore-ent.kind-chest.near,
.explore-ent.kind-chest-open.near {
  opacity: 1;
}
.explore-ent.kind-chest.near .ent-label,
.explore-ent.kind-chest-open.near .ent-label {
  display: block;
}
.explore-ent.kind-chest-open {
  filter: grayscale(0.35) brightness(0.85);
}

/* World-map buildings — art icon replaces CSS pin when loaded */
.explore-ent.kind-building {
  --icon-scale: 1;
  width: calc(96px * var(--icon-scale, 1));
  height: calc(108px * var(--icon-scale, 1));
}
.explore-ent.kind-building.has-icon {
  width: calc(104px * var(--icon-scale, 1));
  height: calc(116px * var(--icon-scale, 1));
}
.building-icon {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: calc(84px * var(--icon-scale, 1));
  height: calc(84px * var(--icon-scale, 1));
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}
.explore-ent.kind-building.near .building-icon {
  filter: drop-shadow(0 0 8px var(--accent)) drop-shadow(0 3px 8px rgba(0, 0, 0, 0.5));
}
.building-pin {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%) scale(var(--icon-scale, 1));
  transform-origin: bottom center;
  width: 44px;
  height: 52px;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}
.explore-ent.kind-npc,
.explore-ent.kind-enemy,
.explore-ent.kind-rest,
.explore-ent.kind-shop {
  --icon-scale: 1;
}
.explore-ent.kind-chest,
.explore-ent.kind-chest-open {
  --icon-scale: 1;
  transform: scale(var(--icon-scale, 1));
  transform-origin: bottom center;
}
.ed-hint {
  font-size: 0.65rem;
  margin: 0 0 0.35rem;
  line-height: 1.35;
}
.building-roof {
  display: block;
  width: 0;
  height: 0;
  margin: 0 auto;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-bottom: 18px solid #8b6914;
}
.building-body {
  display: block;
  width: 36px;
  height: 28px;
  margin: 0 auto;
  background: linear-gradient(180deg, #3a3228, #241f19);
  border: 1px solid var(--accent);
  border-top: none;
  position: relative;
}
.building-body::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 10px;
  height: 14px;
  background: #1a1612;
  border: 1px solid #5a4a30;
}
.explore-ent.kind-building.near .building-pin {
  filter: drop-shadow(0 0 6px var(--accent)) drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
}
/* Buildings painted into world.png: hotspot only, no schematic pin art. */
.explore-ent.kind-building.baked-in-map {
  width: 1px;
  height: 1px;
  overflow: visible;
}
.explore-ent.kind-building.baked-in-map .ent-label {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.explore-ent.kind-building.baked-in-map.near .ent-label,
.explore-ent.kind-building.baked-in-map.ed-selected .ent-label {
  opacity: 1;
}
.explore-ent.kind-building .ent-label {
  top: -0.35rem;
  background: rgba(18, 16, 14, 0.82);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
}

.explore-viewport.mode-world .explore-bg-img,
.explore-viewport.mode-scene .explore-bg-img {
  filter: saturate(1.08) contrast(1.06) brightness(0.95);
}
.explore-viewport.mode-scene .explore-bg::after {
  background:
    radial-gradient(ellipse at 50% 70%, transparent 40%, rgba(10, 8, 6, 0.28) 100%),
    linear-gradient(180deg, rgba(18, 16, 14, 0.08), rgba(18, 16, 14, 0.2));
}
.explore-prompt {
  position: absolute;
  left: 50%;
  bottom: 3.2rem;
  transform: translateX(-50%);
  z-index: 5;
  padding: 0.45rem 0.9rem;
  background: rgba(20, 16, 12, 0.82);
  border: 1px solid var(--accent);
  border-radius: 6px;
  font-size: 0.85rem;
  pointer-events: none;
}
.explore-hint {
  position: absolute;
  left: 50%;
  bottom: 0.7rem;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  pointer-events: none;
}
.minimap {
  position: absolute;
  top: 5.6rem;
  right: 1rem;
  z-index: 6;
  width: 180px;
  height: 140px;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  background: #1a1612;
}
.minimap.hidden {
  display: none !important;
}

/* Explore HUD (reference-style) */
.explore-hud {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.explore-hud .hud-left,
.explore-hud .hud-quest-panel {
  pointer-events: auto;
}
/* Non-combat: hide portrait / HP / mind; battle uses #battle-party-hud */
.explore-hud .hud-left {
  display: none !important;
}
.hud-left {
  position: absolute;
  top: max(0.85rem, env(safe-area-inset-top, 0px));
  left: max(0.85rem, env(safe-area-inset-left, 0px));
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  background: rgba(18, 16, 14, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px 8px 8px 999px;
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
  min-width: 240px;
}
.hud-portrait {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
  border: 2px solid var(--accent);
  background: #1c1814;
}
.hud-vitals { flex: 1; min-width: 0; padding-top: 0.1rem; }
.hud-name-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
  margin-bottom: 0.25rem;
}
#hud-name { font-family: var(--font); font-weight: 650; }
.hud-realm { color: var(--muted); font-size: 0.72rem; }
.hud-bar {
  position: relative;
  height: 12px;
  background: #2a2420;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 0.2rem;
  border: 1px solid #3a3228;
}
.hud-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--hp);
  transition: width 0.2s ease;
}
.hud-bar.mind > i { background: var(--mind); }
.hud-bar > span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  color: #f5ecd8;
  text-shadow: 0 1px 2px #000;
}
/* Bottom-right column: 菜 → (手机)交互/返回，同一竖列不重叠 */
.explore-corner-br {
  position: absolute;
  right: max(0.85rem, env(safe-area-inset-right, 0px), var(--ui-safe-r, 0px));
  bottom: max(1.2rem, env(safe-area-inset-bottom, 0px), var(--ui-safe-b, 0px));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  pointer-events: none;
}
.explore-corner-br > * {
  pointer-events: auto;
}
.hud-menu-toggle {
  width: var(--ui-btn, 62px);
  height: var(--ui-btn, 62px);
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  padding: 0;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  font-weight: 650;
  background: radial-gradient(circle at 35% 30%, #4a3a28, #1c1610);
  border: 2px solid rgba(196, 163, 90, 0.75);
  color: var(--accent);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  touch-action: manipulation;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}
.hud-menu-toggle:hover,
.hud-menu-toggle:active {
  border-color: rgba(232, 212, 154, 0.9);
  color: #ffe8b0;
}
.hud-quest-panel {
  position: absolute;
  top: max(0.85rem, env(safe-area-inset-top, 0px), var(--ui-safe-t, 0px));
  left: max(0.85rem, env(safe-area-inset-left, 0px), var(--ui-safe-l, 0px));
  right: auto;
  bottom: auto;
  margin-top: 0;
  width: min(240px, 42vw);
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  text-align: left;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 8px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease, transform 0.35s ease;
}
.hud-quest-panel.is-flash {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Mobile explore chrome: stick + action buttons */
.mobile-controls {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}
.mobile-stick {
  position: absolute;
  left: max(0.85rem, env(safe-area-inset-left, 0px));
  bottom: max(1.1rem, env(safe-area-inset-bottom, 0px));
  width: 132px;
  height: 132px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}
.mobile-stick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(70, 56, 40, 0.55), rgba(20, 16, 12, 0.72));
  border: 2px solid rgba(196, 163, 90, 0.55);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.35);
}
.mobile-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #d4b878, #8a6a30);
  border: 2px solid rgba(255, 236, 190, 0.65);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  will-change: transform;
}
.mobile-actions {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.55rem;
  pointer-events: auto;
}
.mobile-actions.hidden {
  display: none !important;
}
.mobile-btn {
  width: var(--ui-btn, 68px);
  height: var(--ui-btn, 68px);
  min-width: 56px;
  min-height: 56px;
  border-radius: 50%;
  padding: 0;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  background: radial-gradient(circle at 35% 30%, #4a3a28, #1c1610);
  border: 2px solid rgba(196, 163, 90, 0.75);
  color: #f0e2c8;
  touch-action: manipulation;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}
.mobile-btn:active {
  background: radial-gradient(circle at 35% 30%, #6a5234, #2a2018);
  color: #ffe8b0;
}
.mobile-btn-back {
  width: var(--ui-btn-sm, 56px);
  height: var(--ui-btn-sm, 56px);
  min-width: 48px;
  min-height: 48px;
  font-size: 0.75rem;
  align-self: flex-end;
  opacity: 0.92;
}
body.has-mobile-controls .explore-prompt {
  bottom: 7.2rem;
}
body.has-mobile-controls .explore-hint {
  bottom: 5.6rem;
  max-width: min(70vw, 320px);
  text-align: center;
  right: max(7rem, 22vw);
}
@media (max-width: 720px) {
  .hud-quest-panel {
    width: min(200px, 48vw);
    font-size: 0.72rem;
    top: max(0.55rem, env(safe-area-inset-top, 0px), var(--ui-safe-t, 0px));
    left: max(0.55rem, env(safe-area-inset-left, 0px), var(--ui-safe-l, 0px));
    right: auto;
    bottom: auto;
  }
  .minimap {
    width: 140px;
    height: 110px;
    top: max(5.2rem, calc(env(safe-area-inset-top, 0px) + 4.4rem));
    right: max(0.55rem, env(safe-area-inset-right, 0px));
  }
  .hud-left { min-width: 0; max-width: min(260px, 70vw); }
}
.hud-quest-title {
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
}
.hud-quest-body { line-height: 1.4; min-height: 2.4rem; font-size: 0.78rem; }
.hud-quest-name {
  color: var(--ink, #e8e0d0);
  margin-bottom: 0.35rem;
}
.hud-quest-tip {
  color: #c9b896;
  font-size: 0.72rem;
  line-height: 1.45;
  max-height: 5.6rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}
.quest-tip-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(180, 160, 120, 0.18);
  color: #c9b896;
  font-size: 0.9rem;
  line-height: 1.55;
}
.quest-tip-row:last-child { border-bottom: none; }

/* —— Quest journal (任务日志) —— */
.pm-panel-body.is-quest-journal {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding-top: 0.35rem;
}
.qj-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(11rem, 15rem) 1fr;
  gap: 0;
  border: 1px solid var(--pm-line, rgba(180, 160, 130, 0.22));
  background: rgba(8, 7, 6, 0.45);
}
.qj-list {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--pm-line, rgba(180, 160, 130, 0.22));
  padding: 0.65rem 0.4rem 0.8rem;
  background: rgba(12, 10, 9, 0.55);
}
.qj-section + .qj-section {
  margin-top: 1.1rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(180, 160, 130, 0.14);
}
.qj-sec-label {
  margin: 0 0 0.45rem;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: #8a7d6c;
}
.qj-item {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: #c9beb0;
  font-family: var(--font);
  font-size: 0.98rem;
  letter-spacing: 0.12em;
  padding: 0.5rem 0.45rem;
  margin: 0.1rem 0;
  cursor: pointer;
}
.qj-item:hover {
  color: #f0e8dc;
  background: rgba(180, 140, 80, 0.08);
}
.qj-item.is-on {
  color: #f4efe6;
  border-color: rgba(212, 179, 106, 0.35);
  background: linear-gradient(
    90deg,
    rgba(168, 58, 58, 0.22),
    rgba(180, 140, 80, 0.08)
  );
  box-shadow: inset 3px 0 0 var(--pm-accent, #a83a3a);
}
.qj-item-mark {
  flex: 0 0 auto;
  color: var(--pm-gold, #d4b36a);
  font-size: 0.8rem;
  min-width: 0.9rem;
}
.qj-item-title {
  flex: 1 1 auto;
  min-width: 0;
}
.qj-empty {
  margin: 0.35rem 0.2rem;
  font-size: 0.8rem;
  color: #7a7064;
}
.qj-detail {
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.25rem 1.2rem;
}
.qj-detail-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 0.55rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid rgba(180, 160, 130, 0.18);
}
.qj-detail-head h3 {
  margin: 0;
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.45rem;
  letter-spacing: 0.2em;
  color: #f4efe6;
}
.qj-badge {
  display: inline-block;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  padding: 0.2rem 0.45rem;
  border: 1px solid rgba(180, 160, 130, 0.28);
  color: #a89880;
}
.qj-badge.is-now {
  color: #e8c98a;
  border-color: rgba(212, 179, 106, 0.45);
  background: rgba(168, 58, 58, 0.18);
}
.qj-badge.is-done {
  color: #8a9a7a;
  border-color: rgba(120, 140, 100, 0.35);
}
.qj-stage {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  color: #d2c4ae;
  line-height: 1.5;
}
.qj-stage b {
  color: #f0e4ce;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.qj-memory-trail {
  margin: 0 0 1.15rem;
}
.qj-trail {
  margin: 0.35rem 0 0;
  padding: 0 0 0 1.1rem;
  color: #a89880;
  font-size: 0.88rem;
  line-height: 1.7;
}
.qj-clues {
  margin-top: 0.25rem;
}
.qj-detail-empty {
  padding: 2rem 1rem;
  max-width: 28rem;
}
@media (max-width: 720px) {
  .qj-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .qj-list {
    border-right: none;
    border-bottom: 1px solid var(--pm-line, rgba(180, 160, 130, 0.22));
    max-height: 10.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    align-content: flex-start;
  }
  .qj-section {
    display: contents;
  }
  .qj-sec-label {
    width: 100%;
    margin-top: 0.35rem;
  }
  .qj-item {
    width: auto;
    margin: 0;
  }
}
.hud-place { margin-top: 0.45rem; font-size: 0.7rem; }

body.mode-explore #topbar { display: none !important; }
#screen-explore.screen { min-height: 100vh; }

/* —— Editor mode —— */
.title-editor-toggle {
  position: absolute;
  right: 1.2rem;
  bottom: 1.2rem;
  font-size: 0.75rem;
  opacity: 0.75;
}
.title-hint-editor {
  color: #c4a35a;
}
.editor-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}
.editor-root > * {
  pointer-events: auto;
}
.ed-badge {
  position: absolute;
  top: 0.55rem;
  left: 0.7rem;
  z-index: 45;
  padding: 0.2rem 0.65rem;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  font-weight: 700;
  color: #1a1410;
  background: #c4a35a;
  border-radius: 3px;
  pointer-events: none;
}
.ed-jumpbar {
  position: absolute;
  top: 0.45rem;
  left: 4.2rem;
  right: 0.7rem;
  z-index: 45;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  background: rgba(18, 16, 14, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-width: calc(100% - 5rem);
}
.ed-jump-label {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  flex-shrink: 0;
}
.ed-jump-filter {
  width: 7.5rem;
  background: #1a1612;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 3px;
  padding: 0.25rem 0.4rem;
  font-size: 0.72rem;
}
.ed-jump-select {
  flex: 1;
  min-width: 12rem;
  max-width: 28rem;
  background: #1a1612;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 3px;
  padding: 0.25rem 0.4rem;
  font-size: 0.72rem;
}
.ed-jump-go {
  border-color: var(--accent);
  color: var(--accent);
}
.ed-jump-cur {
  font-size: 0.68rem;
  margin-left: 0.15rem;
  white-space: nowrap;
}
.ed-toolbar {
  position: absolute;
  left: 0.7rem;
  top: 3.4rem;
  width: 132px;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  padding: 0.5rem;
  background: rgba(18, 16, 14, 0.9);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: calc(100vh - 5rem);
  overflow: auto;
}
.ed-battle-select {
  width: 100%;
  background: #1a1612;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 3px;
  padding: 0.25rem 0.2rem;
  font-size: 0.65rem;
}
.ed-inspect {
  position: absolute;
  right: 0.7rem;
  top: 3.4rem;
  width: 220px;
  padding: 0.55rem 0.65rem;
  background: rgba(18, 16, 14, 0.92);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: calc(100vh - 5.5rem);
  overflow: auto;
  font-size: 0.78rem;
}
.ed-test {
  position: absolute;
  left: 140px;
  top: 3.4rem;
  width: 260px;
  padding: 0.55rem 0.65rem;
  background: rgba(18, 16, 14, 0.94);
  border: 1px solid var(--line);
  border-radius: 6px;
  z-index: 46;
  font-size: 0.78rem;
}
.ed-section {
  color: var(--accent);
  font-size: 0.72rem;
  margin: 0.2rem 0 0.35rem;
  letter-spacing: 0.06em;
}
.ed-tool {
  width: 100%;
  padding: 0.35rem 0.4rem;
  font-size: 0.72rem;
  text-align: left;
  background: #221c18;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px;
  cursor: pointer;
}
.ed-tool.is-on,
.ed-tool.ed-primary {
  border-color: var(--accent);
  color: var(--accent);
}
.ed-tool.ed-primary {
  background: #2a2418;
  font-weight: 650;
}
.ed-mini {
  padding: 0.15rem 0.4rem;
  font-size: 0.7rem;
  background: #2a2418;
  border: 1px solid var(--line);
  color: var(--accent);
  border-radius: 3px;
  cursor: pointer;
}
.ed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}
.ed-row span {
  min-width: 3.5rem;
  color: var(--muted, #8a8070);
}
.ed-row select,
.ed-row input,
.ed-field input,
.ed-field select {
  flex: 1;
  min-width: 0;
  background: #1a1612;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 3px;
  padding: 0.2rem 0.35rem;
  font-size: 0.72rem;
}
.ed-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
  color: var(--muted, #8a8070);
  font-size: 0.7rem;
}
.ed-check {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.25rem 0;
  font-size: 0.75rem;
}
.ed-flags {
  font-size: 0.68rem;
  max-height: 4.5rem;
  overflow: auto;
  margin-bottom: 0.4rem;
  word-break: break-all;
}
.ed-kind {
  font-weight: 650;
  color: var(--accent);
  margin-bottom: 0.4rem;
}
.ed-inspect-body.muted {
  color: #8a8070;
}
.explore-ent.ed-selected {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}
.explore-ent.kind-trigger {
  width: 48px;
  height: 48px;
}
.explore-ent.kind-trigger .trigger-ring,
.explore-ent .portal-ring,
.explore-ent.kind-collider .collider-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--trig-r, 180px);
  height: var(--trig-r, 180px);
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(154, 106, 154, 0.75);
  border-radius: 50%;
  background: rgba(154, 106, 154, 0.12);
  pointer-events: none;
}
.explore-ent .portal-ring {
  border-color: rgba(90, 160, 120, 0.85);
  background: rgba(90, 160, 120, 0.14);
}
.explore-ent.kind-exit {
  width: 48px;
  height: 48px;
}
.explore-ent .ent-marker.trigger {
  background: #3a2440;
  border-color: #9a6a9a;
  color: #e8d0e8;
  font-size: 0.65rem;
}
.explore-ent.kind-spawn {
  width: 40px;
  height: 40px;
}
.explore-ent .ent-marker.spawn {
  background: #243a28;
  border-color: #6a9e6a;
  color: #d0e8d0;
  font-size: 0.65rem;
}
body.mode-editor .hud-quest-panel {
  opacity: 0.55;
}
.explore-viewport.is-editor {
  cursor: crosshair;
}
.explore-viewport.is-editor.is-panning {
  cursor: grabbing;
}
.explore-walkmask {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
  image-rendering: pixelated;
}
.explore-walkmask.hidden {
  display: none;
}
body.mode-editor .explore-viewport.is-editor.is-mask-tool,
.explore-viewport.is-editor.tool-mask {
  cursor: cell;
}

/* —— Scene atlas (任务追踪式节点图) —— */
#screen-atlas.atlas-overlay {
  z-index: 45;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: rgba(8, 6, 4, 0.42);
  backdrop-filter: blur(6px) saturate(0.85);
  -webkit-backdrop-filter: blur(6px) saturate(0.85);
}
.atlas-root {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  display: flex;
  padding: 1.1rem 1.25rem 1.25rem;
}
.atlas-frame {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(200px, 22%) 1fr minmax(180px, 20%);
  gap: 0.75rem;
  min-height: 0;
  border: 1px solid #5a4a32;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(36, 28, 20, 0.92), rgba(22, 18, 14, 0.94));
  box-shadow: inset 0 0 0 1px rgba(212, 179, 106, 0.12), 0 12px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}
.atlas-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.9rem;
}
.atlas-quests {
  border-right: 1px solid rgba(90, 74, 50, 0.85);
  background: linear-gradient(180deg, rgba(48, 36, 24, 0.55), transparent 40%);
}
.atlas-side {
  border-left: 1px solid rgba(90, 74, 50, 0.85);
  background: linear-gradient(180deg, rgba(48, 36, 24, 0.45), transparent 35%);
}
.atlas-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font);
  font-weight: 650;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 0.85rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(90, 74, 50, 0.7);
}
.atlas-collapse {
  padding: 0.15rem 0.45rem;
  font-size: 0.75rem;
}
.atlas-quest-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
}
.atlas-q-tag {
  flex: 0 0 auto;
  width: 1.45rem;
  height: 1.45rem;
  border-radius: 3px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid #7a5a28;
  background: linear-gradient(160deg, #c9a44a, #7a5a18);
  color: #1a140c;
}
.atlas-q-title {
  font-family: var(--font);
  font-weight: 650;
  color: #f0e6d0;
}
.atlas-q-sub {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  line-height: 1.45;
}
.atlas-q-tip {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #c9b896;
}
.atlas-hint {
  margin-top: auto;
  padding-top: 1rem;
  font-size: 0.72rem;
  line-height: 1.4;
}
.atlas-graph-wrap {
  padding: 0.6rem;
  position: relative;
  flex: 1;
  min-width: 0;
}
.atlas-graph {
  position: relative;
  flex: 1;
  min-height: 420px;
  border-radius: 4px;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(70, 52, 32, 0.35), transparent 55%),
    linear-gradient(180deg, rgba(18, 14, 10, 0.25), rgba(10, 8, 6, 0.55));
  overflow: hidden;
}
.atlas-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.atlas-link {
  stroke: rgba(196, 163, 90, 0.55);
  stroke-width: 0.35;
  stroke-dasharray: 1.2 1.1;
  fill: none;
}
.atlas-node {
  position: absolute;
  z-index: 2;
  transform: translate(-50%, -50%);
  width: 5.6rem;
  padding: 0;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  color: inherit;
}
.atlas-node:hover { color: inherit; border: none; }
.atlas-tile {
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 6px;
  border: 2px solid #6a5430;
  background:
    linear-gradient(160deg, #6a5840 0%, #3a3024 55%, #2a2218 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 180, 0.18),
    0 4px 10px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.atlas-node:hover .atlas-tile {
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 180, 0.28),
    0 0 0 1px rgba(196, 163, 90, 0.35),
    0 6px 14px rgba(0, 0, 0, 0.4);
}
.atlas-node.is-here .atlas-tile {
  border-color: #e0c56a;
  box-shadow:
    0 0 0 2px rgba(224, 197, 106, 0.35),
    inset 0 0 12px rgba(224, 197, 106, 0.15);
}
.atlas-node-icon {
  width: 86%;
  height: 86%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}
.atlas-node-fallback {
  font-family: var(--font);
  font-size: 1.35rem;
  color: var(--accent);
}
.atlas-node-name {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: #efe4cc;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  white-space: nowrap;
  max-width: 6.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.atlas-here-mark {
  position: absolute;
  top: 0.15rem;
  right: 0.35rem;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe9a8, #c9a44a 60%, #6a4a12);
  box-shadow: 0 0 6px rgba(224, 197, 106, 0.7);
}
.atlas-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}
.atlas-log {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-right: 0.2rem;
  margin-bottom: 0.75rem;
}
.atlas-log-line {
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 0.35rem 0.45rem;
  border-left: 2px solid rgba(196, 163, 90, 0.45);
  background: rgba(0, 0, 0, 0.18);
}
.atlas-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: auto;
}
.atlas-act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.65rem 0.4rem;
  border-color: #5a4a32;
  background: linear-gradient(180deg, #3a3024, #241c14);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}
.atlas-act-ico {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid #7a5a28;
  background: radial-gradient(circle at 35% 30%, #5a4830, #2a2218);
  color: var(--accent);
  font-family: var(--font);
  font-weight: 700;
}
@media (max-width: 900px) {
  .atlas-frame {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(280px, 1fr) auto;
  }
  .atlas-quests, .atlas-side { border: none; }
  .atlas-quests { border-bottom: 1px solid rgba(90, 74, 50, 0.85); }
  .atlas-side { border-top: 1px solid rgba(90, 74, 50, 0.85); }
}

/* —— Puzzle overlay (机缘解密) —— */
#screen-puzzle.overlay {
  z-index: 42;
  background: rgba(8, 6, 4, 0.88);
  align-items: center;
  justify-content: center;
}
.puzzle-root {
  width: min(36rem, 94vw);
  max-height: min(90vh, 40rem);
  overflow: auto;
}
.puzzle-card {
  background:
    linear-gradient(165deg, rgba(42, 34, 24, 0.96), rgba(18, 14, 10, 0.98));
  border: 1px solid #6a5438;
  box-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.45);
  padding: 1.25rem 1.35rem 1rem;
  color: #e8dcc8;
}
.puzzle-title {
  margin: 0 0 0.45rem;
  font-family: var(--font);
  font-size: 1.35rem;
  letter-spacing: 0.14em;
  color: #f0e0c0;
}
.puzzle-prompt {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.55;
  color: #d8cbb4;
}
.puzzle-hint {
  margin: 0.65rem 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #a89878;
  border-left: 2px solid #8a6a38;
  padding-left: 0.7rem;
}
.puzzle-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.puzzle-identify {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.puzzle-opt {
  text-align: left;
  font-size: 1.02rem;
  padding: 0.65rem 0.9rem;
  background: rgba(36, 31, 25, 0.9);
  border: 1px solid #5a4a32;
  color: #eadfca;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.puzzle-opt:hover:not(:disabled) {
  border-color: #c4a060;
  background: rgba(52, 42, 30, 0.95);
}
.puzzle-opt:disabled,
.puzzle-opt.is-picked {
  opacity: 0.45;
  cursor: default;
}
.puzzle-opt strong {
  display: block;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}
.puzzle-opt-desc {
  display: block;
  font-size: 0.88rem;
  color: #a89878;
}
.puzzle-order-status {
  margin-bottom: 0.65rem;
  font-size: 0.95rem;
  color: #c4b498;
}
.puzzle-order {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
}
.puzzle-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(90, 74, 50, 0.55);
}
@media (max-width: 720px), (pointer: coarse) {
  .puzzle-card { padding: 1.1rem 1rem 0.9rem; }
  .puzzle-title { font-size: 1.2rem; }
  .puzzle-identify { grid-template-columns: 1fr; }
  .puzzle-order { grid-template-columns: 1fr; }
}

/* mechanism / board puzzle UI */
.puzzle-clues {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.75rem 0.55rem 1.25rem;
  background: rgba(28, 22, 16, 0.85);
  border: 1px solid #5a4a32;
  color: #c4b498;
  font-size: 0.9rem;
  line-height: 1.5;
}
.puzzle-clues li { margin: 0.2rem 0; }
.puzzle-mechanism {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.puzzle-trap {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed rgba(140, 60, 40, 0.55);
}
.puzzle-opt.is-danger {
  border-color: #8a4030;
  color: #e8b0a0;
  background: rgba(60, 24, 18, 0.9);
}
.puzzle-opt.is-danger:hover:not(:disabled) {
  border-color: #c05038;
  background: rgba(80, 30, 22, 0.95);
}
.puzzle-board {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: min(52vh, 22rem);
  overflow: auto;
  padding-right: 0.15rem;
}
.puzzle-board-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 0.65rem;
  row-gap: 0.15rem;
  text-align: left;
  padding: 0.7rem 0.85rem;
  background: rgba(32, 26, 20, 0.94);
  border: 1px solid #5a4a32;
  color: #eadfca;
  cursor: pointer;
}
.puzzle-board-card:hover {
  border-color: #c4a060;
  background: rgba(48, 38, 28, 0.96);
}
.puzzle-board-card.tier-gold { border-left: 3px solid #c9a24a; }
.puzzle-board-card.tier-silver { border-left: 3px solid #9aa0a8; }
.puzzle-board-tier {
  grid-row: 1 / span 3;
  align-self: center;
  writing-mode: vertical-rl;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: #c4a060;
  border: 1px solid #6a5438;
  padding: 0.35rem 0.15rem;
  background: rgba(20, 16, 12, 0.8);
}
.puzzle-board-card.tier-silver .puzzle-board-tier { color: #b0b6be; border-color: #6a7078; }
.puzzle-board-title {
  font-size: 1.02rem;
  letter-spacing: 0.06em;
}
.puzzle-board-desc {
  font-size: 0.88rem;
  color: #a89878;
}
.puzzle-board-code {
  font-size: 0.82rem;
  color: #d4b878;
  letter-spacing: 0.04em;
}
.puzzle-board-code.hidden { display: none; }
.puzzle-type-seek .puzzle-identify {
  grid-template-columns: 1fr 1fr;
}
