:root {
  --ui: rgba(20, 20, 22, 0.74);
  --ui-border: rgba(243, 239, 230, 0.16);
  --fg: #f3efe6;
  --paper: #f1e6cf;
  --ink: #2a251f;
  --accent: #d8a956;
  color-scheme: dark;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ui: rgba(250, 248, 242, 0.85);
    --ui-border: rgba(34, 34, 34, 0.14);
    --fg: #222;
    color-scheme: light;
  }
}

:root[data-theme="dark"] {
  --ui: rgba(20, 20, 22, 0.74);
  --fg: #f3efe6;
}

/* Remove browser default blue focus/tap highlight ring across all controls */
*, *::before, *::after {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

button, input, canvas {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button:focus {
  outline: none;
}

button:focus-visible {
  box-shadow: 0 0 0 1.5px var(--accent);
}

html, body {
  height: 100%;
  margin: 0;
  background: #14161a;
  overflow: hidden;
  font-family: "Songti SC", "Noto Serif SC", Georgia, serif;
  color: var(--fg);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

canvas {
  display: block;
  position: fixed;
  inset: 0;
  transition: filter 0.35s ease;
}

/* Dreamcore & Film Photo Mode CSS Filters */
body.filter-dream > canvas {
  filter: contrast(1.06) saturate(1.14) brightness(1.04) sepia(0.12);
}
body.filter-film > canvas {
  filter: contrast(1.12) saturate(0.88) sepia(0.24) brightness(0.98);
}
body.filter-pool > canvas {
  filter: contrast(1.08) saturate(1.18) hue-rotate(-10deg) brightness(1.02);
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 58%, rgba(12,11,10,0.38) 100%);
  z-index: 2;
  transition: opacity 0.25s ease;
}

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 248, 234, 0.65);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  z-index: 3;
  transition: transform 0.15s ease, background 0.15s ease;
}

#crosshair.target {
  transform: translate(-50%, -50%) scale(1.65);
  background: var(--accent);
}

#interact-prompt {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 92px);
  transform: translateX(-50%);
  background: var(--ui);
  border: 1px solid var(--accent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 7;
}

#interact-prompt.show { opacity: 1; }

#hud {
  position: fixed;
  left: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  background: var(--ui);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  letter-spacing: 0.02em;
  z-index: 5;
  max-width: 44vw;
}

#controls-bar {
  position: fixed;
  right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
  max-width: 52vw;
  z-index: 6;
}

#controls-bar button, #show-gui-btn, #photo-bar button {
  background: var(--ui);
  color: var(--fg);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 10px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.12s, border-color 0.2s;
}

#controls-bar button.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(216, 169, 86, 0.32);
}

#show-gui-btn {
  position: fixed;
  right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  z-index: 9;
  display: none;
  opacity: 0.3;
}

#show-gui-btn:hover { opacity: 0.92; }

/* Hide non-essential UI while KEEPING movement (#jb, #db) & sticky-note (#nb) controls! */
body.gui-hidden #hud,
body.gui-hidden #controls-bar,
body.gui-hidden #dev-panel,
body.gui-hidden #minimap-panel,
body.gui-hidden #photo-bar,
body.gui-hidden #crosshair {
  display: none !important;
}

body.gui-hidden #show-gui-btn { display: block; }

#controls-bar button:active, #show-gui-btn:active, #photo-bar button:active {
  transform: scale(0.95);
}

/* 3D Architectural Blueprint Minimap */
#minimap-panel {
  position: fixed;
  left: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  background: rgba(14, 18, 26, 0.82);
  border: 1px solid rgba(154, 198, 232, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 8px;
  z-index: 8;
  display: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

#minimap-panel.open { display: block; }

.mini-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #cfe4f7;
  margin-bottom: 5px;
  letter-spacing: 0.04em;
}

#mini-info { opacity: 0.65; font-size: 10px; }

#minimap-cv {
  position: static;
  display: block;
  width: 224px;
  height: 184px;
  border-radius: 6px;
  background: radial-gradient(circle at center, #182230 0%, #0e141c 100%);
  cursor: grab;
  touch-action: none;
}

/* Photo Mode & Dreamcore Filter Bar */
#photo-bar {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 22px);
  transform: translateX(-50%);
  display: none;
  gap: 6px;
  z-index: 9;
}

#photo-bar.open { display: flex; }

#dev-panel {
  position: fixed;
  right: 12px;
  top: calc(env(safe-area-inset-top, 0px) + 50px);
  width: min(276px, 86vw);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--ui);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 10px;
  padding: 10px;
  z-index: 8;
  display: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

#dev-panel.open { display: block; }

.dev-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
  opacity: 0.92;
}

#dev-coords {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  opacity: 0.85;
}

.dev-row { display: flex; gap: 6px; margin-bottom: 6px; }

.dev-row button {
  flex: 1;
  padding: 6px 5px;
  border-radius: 6px;
  border: 1px solid var(--ui-border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.dev-row button.on {
  background: rgba(216, 169, 86, 0.28);
  border-color: var(--accent);
}

.dev-sep { font-size: 11px; opacity: 0.72; margin: 6px 0 5px; }
.dev-rooms { flex-wrap: wrap; }
.dev-rooms button { flex: 1 1 22%; font-size: 11px; padding: 5px 3px; }
.dev-hint { font-size: 10px; line-height: 1.45; opacity: 0.74; margin-top: 4px; }

#toast {
  position: fixed;
  left: 50%;
  top: 17%;
  transform: translateX(-50%);
  background: var(--ui);
  border: 1px solid var(--ui-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
  text-align: center;
  max-width: 82vw;
  z-index: 10;
}

#nb, #jb, #db {
  position: fixed;
  right: 14px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(112, 98, 78, 0.45);
  border-radius: 15px;
  background: linear-gradient(155deg, #f6edd9 0%, #e7dac0 100%);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.65);
  cursor: pointer;
  z-index: 6;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

/* v3.0 拇指热区：跳跃在右下角最易按处，互动在其左，便签与下降向上排开 */
#jb { bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); }
#nb { bottom: calc(env(safe-area-inset-bottom, 0px) + 92px); }
#db { bottom: calc(env(safe-area-inset-bottom, 0px) + 166px); display: none; }

#nb:active, #jb:active, #db:active { transform: scale(0.93); }

/* v3.0 移动端可见虚拟摇杆（左半屏按下处浮现，不拦截事件） */
#joy {
  position: fixed;
  left: 0;
  top: 0;
  width: 108px;
  height: 108px;
  margin: -54px 0 0 -54px;
  border-radius: 50%;
  border: 1.5px solid rgba(243, 239, 230, 0.38);
  background: rgba(20, 20, 22, 0.26);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  pointer-events: none;
  z-index: 4;
}
#joy.show { display: block; }
#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(243, 239, 230, 0.55);
  border: 1px solid rgba(243, 239, 230, 0.72);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

#ed {
  position: fixed;
  inset: 0;
  background: rgba(12, 11, 10, 0.54);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#ed .c {
  background: var(--paper);
  color: var(--ink);
  padding: 14px;
  border-radius: 10px;
  width: min(312px, 88vw);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  border: 1px solid #c6b89e;
}

.ed-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 13px; color: #5a5143; }
.ed-hint { font-size: 11px; opacity: 0.8; }

#cv {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #f1e6cf;
  border: 1px solid #bba;
  border-radius: 5px;
  touch-action: none;
  position: static;
  display: block;
}

.r { display: flex; gap: 8px; margin-top: 9px; align-items: center; }

.r button {
  flex: 1;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #8a7f6a;
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.55);
  color: var(--ink);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.r button svg { pointer-events: none; }

.d { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.d.on { border-color: #000; transform: scale(1.1); }
.col-label { font-size: 12px; color: #5b5244; margin-left: 2px; }

#tx {
  width: 100%;
  margin-top: 9px;
  padding: 8px 9px;
  border: 1px solid #8a7f6a;
  border-radius: 5px;
  background: #fffaf0;
  color: #222;
  font-size: 15px;
  font-family: inherit;
}

/* Mobile Responsive UI Polish */
@media (max-width: 680px) {
  #hud { font-size: 11px; padding: 5px 8px; max-width: 44vw; }
  #controls-bar { gap: 4px; max-width: 52vw; }
  #controls-bar button { padding: 5px 7px; font-size: 11px; border-radius: 6px; }
  #nb, #jb, #db { width: 52px; height: 52px; right: 12px; border-radius: 13px; }
  #jb { bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
  #nb { bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); }
  #db { bottom: calc(env(safe-area-inset-bottom, 0px) + 152px); }
  #act-btn { width: 52px; height: 52px; right: 78px; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
  #minimap-cv { width: 176px; height: 146px; }
  #photo-bar { bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); gap: 4px; }
  #photo-bar button { padding: 5px 8px; font-size: 11px; }
}

/* v3.0 横屏（低矮视口）平等适配：压缩纵向占位，按钮内收不挡画面 */
@media (max-height: 480px) {
  #hud { font-size: 10.5px; padding: 4px 7px; max-width: 38vw; }
  #controls-bar { max-width: 46vw; }
  #controls-bar button { padding: 4px 7px; font-size: 10.5px; }
  #nb, #jb, #db { width: 46px; height: 46px; right: 10px; border-radius: 12px; }
  #jb { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
  #nb { bottom: calc(env(safe-area-inset-bottom, 0px) + 70px); }
  #db { bottom: calc(env(safe-area-inset-bottom, 0px) + 128px); }
  #act-btn { width: 46px; height: 46px; right: 66px; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
  #joy { width: 92px; height: 92px; margin: -46px 0 0 -46px; }
  #joy-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  #interact-prompt { bottom: calc(env(safe-area-inset-bottom, 0px) + 64px); }
}

#mini-close {
  background: transparent;
  border: 0;
  color: #cfe4f7;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
}

.bp-section {
  margin-top: 7px;
  border-top: 1px solid rgba(154, 198, 232, 0.18);
  padding-top: 6px;
}

.bp-head {
  font-size: 10px;
  color: #9ec0dc;
  margin-bottom: 4px;
}

#bp-code {
  width: 100%;
  resize: none;
  border-radius: 6px;
  border: 1px solid rgba(154, 198, 232, 0.25);
  background: rgba(8, 12, 18, 0.72);
  color: #eaf3fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 6px 7px;
  user-select: text;
  -webkit-user-select: text;
}

.bp-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.bp-actions button {
  flex: 1;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid rgba(154, 198, 232, 0.3);
  background: rgba(154, 198, 232, 0.14);
  color: #eaf3fc;
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.bp-actions button:active { transform: scale(0.96); }

#act-btn {
  position: fixed;
  right: 86px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  width: 56px;
  height: 56px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: linear-gradient(155deg, #f6edd9 0%, #e7dac0 100%);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  z-index: 6;
}

#act-btn.show { display: flex; }

#lantern-btn {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 56px);
  display: none;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid rgba(232, 188, 102, 0.55);
  border-radius: 999px;
  background: rgba(18, 15, 11, 0.84);
  color: #f6dca4;
  font-family: inherit;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  z-index: 8;
}
#lantern-btn.show { display: flex; }
#lantern-btn:active { transform: translateX(-50%) scale(0.96); }

#lore-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 12, 0.58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 22;
}

#lore-modal.open { display: flex; }

.lore-card {
  width: min(340px, 86vw);
  background: #f2e8d4;
  color: #29231c;
  padding: 18px 18px 14px;
  border-radius: 10px;
  border: 1px solid #c6b698;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.42);
}

.lore-title {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(90, 78, 60, 0.25);
  padding-bottom: 7px;
  margin-bottom: 10px;
}

.lore-body {
  font-size: 13.5px;
  line-height: 1.72;
  color: #3a3228;
  margin-bottom: 14px;
}

#lore-close {
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #8a7f6a;
  background: rgba(255, 250, 240, 0.65);
  color: #29231c;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* Mobile-friendly centered Blueprint overlay so it NEVER blocks gameplay when closed and is spacious when open */
@media (max-width: 680px) {
  #minimap-panel {
    left: 50%;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(92vw, 336px);
    padding: 10px;
    z-index: 18;
  }
  #minimap-cv {
    width: 100%;
    height: 190px;
  }
  #act-btn {
    width: 52px;
    height: 52px;
    right: 78px;
  }
}

.mini-zoom { display: flex; align-items: center; gap: 4px; }
.mini-zoom button {
  background: rgba(154, 198, 232, 0.16);
  border: 1px solid rgba(154, 198, 232, 0.28);
  color: #dff0ff;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
}
.mini-zoom button:active { transform: scale(0.92); }


/* ===== v2.6: start screen, settings, gravity chip ===== */
#qbtn { display: none !important; }
.menu-layer {
  position: fixed; inset: 0; display: none; align-items: center; justify-content: center;
  z-index: 60; padding: 16px; box-sizing: border-box;
}
.menu-layer.show { display: flex; }
#start-screen {
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 34, 26, 0.55), rgba(8, 7, 6, 0.9));
  -webkit-backdrop-filter: blur(7px) brightness(0.6); backdrop-filter: blur(7px) brightness(0.6);
}
.start-card { text-align: center; color: var(--fg); max-width: 420px; width: 100%; }
.start-kicker { letter-spacing: 0.42em; font-size: 12px; color: var(--accent); margin-bottom: 14px; }
.start-title { margin: 0; font-weight: 300; font-size: clamp(30px, 8vw, 54px); letter-spacing: 0.14em; line-height: 1.1; }
.start-title span { color: var(--accent); }
.start-sub { margin: 12px 0 30px; font-size: 13px; opacity: 0.7; letter-spacing: 0.12em; }
.start-actions { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.start-actions button {
  width: min(260px, 80vw); padding: 12px 0; font: inherit; font-size: 15px; letter-spacing: 0.2em;
  color: var(--fg); background: rgba(243, 239, 230, 0.06); border: 1px solid var(--ui-border); cursor: pointer;
}
.start-actions button.primary { background: rgba(216, 169, 86, 0.2); border-color: var(--accent); color: #f6dca4; }
.start-actions button:active { transform: scale(0.98); }
.start-help {
  margin: 20px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; text-align: left;
  font-size: 12px; opacity: 0.85; background: var(--ui); border: 1px solid var(--ui-border); padding: 12px 14px;
}
.start-help[hidden] { display: none; }
.start-help b { color: var(--accent); font-weight: 500; margin-right: 6px; }
.start-foot { margin-top: 22px; font-size: 11px; opacity: 0.45; letter-spacing: 0.1em; }
#settings-panel { background: rgba(0, 0, 0, 0.5); z-index: 70; }
.set-card {
  width: min(460px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: rgba(22, 20, 17, 0.96); color: var(--fg); border: 1px solid var(--ui-border);
}
.set-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--ui-border); letter-spacing: 0.2em; }
.set-head button, .set-foot button, .set-reload button { font: inherit; color: var(--fg); background: transparent; border: 1px solid var(--ui-border); padding: 5px 12px; cursor: pointer; }
.set-body { overflow-y: auto; padding: 4px 16px 12px; -webkit-overflow-scrolling: touch; }
.set-body section h3 { margin: 16px 0 6px; font-size: 12px; font-weight: 500; letter-spacing: 0.25em; color: var(--accent); }
.set-row { padding: 8px 0; border-bottom: 1px solid rgba(243, 239, 230, 0.06); }
.set-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.set-val { opacity: 0.7; }
.set-hint { font-size: 11px; opacity: 0.5; margin-top: 5px; }
.seg { display: flex; gap: 4px; }
.seg button, .toggle { flex: 1; padding: 7px 0; font: inherit; font-size: 12.5px; color: var(--fg); background: rgba(243, 239, 230, 0.05); border: 1px solid var(--ui-border); cursor: pointer; }
.toggle { flex: none; min-width: 64px; padding: 7px 14px; }
.seg button.on, .toggle.on { background: rgba(216, 169, 86, 0.22); border-color: var(--accent); color: #f6dca4; }
.set-row input[type=range] { width: 100%; accent-color: var(--accent); }
.set-row.slot { display: flex; flex-wrap: wrap; gap: 8px; }
.set-row.slot button { position: static !important; display: inline-block !important; font: inherit; font-size: 12.5px; color: var(--fg); background: rgba(243, 239, 230, 0.05); border: 1px solid var(--ui-border); padding: 7px 14px; cursor: pointer; }
.set-reload { padding: 8px 16px; font-size: 12px; background: rgba(216, 169, 86, 0.14); border-top: 1px solid var(--accent); }
.set-reload[hidden] { display: none; }
.set-foot { padding: 10px 16px; border-top: 1px solid var(--ui-border); text-align: right; }
#grav-chip {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 12px);
  display: none; padding: 5px 14px; font-size: 12px; letter-spacing: 0.1em; color: var(--fg);
  background: var(--ui); border: 1px solid var(--ui-border); z-index: 9; pointer-events: none;
}
#grav-chip.show { display: block; }
#grav-chip.inv { border-color: #c8402a; color: #ffb9a4; }

#minimap-panel {
  inset: auto auto max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  transform: none; width: min(540px, calc(100vw - 24px)); box-sizing: border-box;
  max-height: 88dvh; overflow: auto; padding: 12px; background: #101b27; color: #e1ecf4;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
#minimap-panel .mini-head { align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; }
#minimap-panel #minimap-cv { width: 100%; height: clamp(130px, 37dvh, 350px); }
.mini-route { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.mini-route select { flex: 1; min-width: 0; }
.mini-route select, .mini-route button, #minimap-panel .mini-zoom button {
  color: #dfebf5; background: #213342; border: 1px solid #476075;
  border-radius: 4px; padding: 5px 8px; min-height: 32px; width: auto;
}
#mini-plan[aria-pressed=true] { outline: 1px solid #f0c86e; }
.bp-section summary { cursor: pointer; padding: 6px 0; }
