* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
  tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #82cc5e;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  color: #f3f7ff;
}

#game-canvas {
  display: block;
  position: fixed;
  inset: 0;
  cursor: default;
  outline: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

/* Translucent Pony Town HUD Glass */
.hud-glass {
  background: rgba(24, 29, 43, 0.82);
  border: 1px solid rgba(220, 236, 255, 0.24);
  border-radius: 9px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(10, 16, 30, 0.38);
}

/* ================= TOP-LEFT: LIVE ZONE + SPEED + COORDS ================= */
#hud-top-left {
  position: fixed;
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
}

.zone-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  font-size: 13.5px;
  font-weight: 700;
  color: #fffaf0;
  letter-spacing: 0.2px;
  pointer-events: auto;
  width: fit-content;
}

#zone-icon {
  font-size: 16px;
  line-height: 1;
}

.canon-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 99px;
  background: rgba(255, 214, 92, 0.2);
  border: 1px solid rgba(255, 214, 92, 0.45);
  color: #ffe27a;
  margin-left: 2px;
}

.sub-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(22, 27, 40, 0.76);
  border: 1px solid rgba(210, 228, 255, 0.18);
  font-size: 11px;
  color: #d6e6fa;
  pointer-events: auto;
}

#speed-pill {
  cursor: pointer;
  font-weight: 600;
  transition: background 0.14s, border-color 0.14s;
}
#speed-pill:hover {
  background: rgba(44, 58, 86, 0.9);
  border-color: rgba(160, 220, 255, 0.55);
}
#speed-pill.trot {
  background: rgba(46, 28, 12, 0.90);
  border-color: #ffd275;
  color: #fff4d4;
}

.character-status { position: relative; }
#coord-pill {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  font-family: Consolas, "Courier New", monospace;
  color: #a9c1de;
  white-space: nowrap;
  pointer-events: none;
}
.character-status:not([open]) #coord-pill { display: none; }

#active-char-pill {
  display: list-item;
  color: #ffe89e;
  font-weight: 600;
  cursor: pointer;
}

/* ================= TOP-RIGHT: NAV, ENV & ZOOM ================= */
#hud-top-right {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  z-index: 20;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 31px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid rgba(216, 232, 255, 0.26);
  background: rgba(24, 29, 43, 0.84);
  color: #f0f6ff;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 3px 10px rgba(10, 16, 30, 0.32);
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}

.hud-btn:hover {
  background: rgba(46, 58, 86, 0.94);
  border-color: rgba(154, 222, 255, 0.65);
  transform: translateY(-1px);
}

.hud-btn.active {
  background: rgba(48, 122, 198, 0.88);
  border-color: #9ce0ff;
  color: #ffffff;
}

.hud-btn.accent-pink {
  background: linear-gradient(135deg, rgba(196, 66, 134, 0.88), rgba(132, 74, 198, 0.88));
  border-color: rgba(255, 190, 230, 0.55);
}
.hud-btn.accent-pink:hover {
  filter: brightness(1.12);
}

.zoom-group {
  display: inline-flex;
  align-items: center;
  height: 31px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid rgba(216, 232, 255, 0.26);
  background: rgba(24, 29, 43, 0.84);
  box-shadow: 0 3px 10px rgba(10, 16, 30, 0.32);
}

.zoom-step {
  width: 28px;
  height: 100%;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.zoom-step:hover { background: rgba(74, 96, 138, 0.6); }
.season-btn { font-size: 13px; padding: 0; }
.season-btn.active { background: rgba(255, 196, 86, 0.34); box-shadow: inset 0 0 0 1px rgba(255, 224, 138, 0.65); }

#zoom-label {
  min-width: 28px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: #a8e1ff;
  border-left: 1px solid rgba(216, 232, 255, 0.14);
  border-right: 1px solid rgba(216, 232, 255, 0.14);
  line-height: 29px;
}

/* Bottom-right minimap with a 1:1 logical canvas. */
#minimap-card {
  position: absolute;
  left: calc(50% + 50vw - 12px - env(safe-area-inset-right, 0px));
  bottom: calc(100% + 8px);
  transform: translateX(-100%);
  width: max-content;
  z-index: 20;
  padding: 5px;
}

#btn-minimap-toggle {
  color: #d7e7fa;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
}
#btn-minimap-toggle:hover { color: #ffffff; }
#minimap-card:not([open]) #minimap-body { display: none; }

#minimap-body {
  position: relative;
  line-height: 0;
  margin-top: 4px;
}

#minimap-canvas {
  display: block;
  border-radius: 5px;
  outline: 1px solid rgba(12, 18, 30, 0.9);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
}

#minimap-landmark {
  position: absolute;
  top: 5px;
  left: 50%;
  max-width: calc(100% - 10px);
  transform: translateX(-50%);
  padding: 3px 7px;
  border-radius: 4px;
  background: #191e2c;
  color: #fff4d4;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}

.minimap-tip {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(16, 20, 32, 0.72);
  font-size: 9.5px;
  line-height: 1.2;
  color: #e4f0ff;
  pointer-events: none;
}

/* ================= BOTTOM-CENTER: COMPACT ACTION BAR + CHAT ================= */
#hud-bottom {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: calc(100vw - 20px);
}

.action-dock {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  flex-wrap: nowrap;
}

.act-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 44px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid rgba(215, 232, 255, 0.2);
  background: rgba(38, 46, 66, 0.78);
  color: #eef6ff;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
.act-btn:hover {
  background: rgba(58, 72, 102, 0.92);
  border-color: rgba(160, 224, 255, 0.6);
  transform: translateY(-1px);
}
.act-btn.active {
  background: rgba(54, 134, 210, 0.88);
  border-color: #a8e6ff;
  color: #ffffff;
}

.act-key {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 9px;
  color: rgba(210, 230, 255, 0.72);
  font-weight: 700;
}
.act-ico { font-size: 16px; line-height: 1.1; }
.act-lbl { font-size: 10px; margin-top: 2px; font-weight: 600; }

.dock-sep {
  width: 1px;
  height: 30px;
  background: rgba(215, 232, 255, 0.2);
  margin: 0 3px;
}

.chat-box {
  display: flex;
  align-items: center;
  gap: 5px;
}

#chat-input {
  width: 215px;
  height: 36px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid rgba(210, 230, 255, 0.26);
  background: rgba(14, 18, 28, 0.8);
  color: #ffffff;
  font-size: 12.5px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
#chat-input:focus {
  border-color: #82d4ff;
  background: rgba(18, 24, 38, 0.94);
}
#chat-input::placeholder { color: #8da2bd; }

#btn-chat-send {
  height: 36px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid rgba(154, 222, 255, 0.45);
  background: rgba(46, 128, 204, 0.88);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
#btn-chat-send:hover { background: rgba(62, 148, 224, 0.95); }

/* ================= SLIDE-OUT DRAWERS (LANDMARKS & CHARACTERS) ================= */
.drawer {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 344px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 86px);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transform: translateX(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  overflow: hidden;
}
.drawer.open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: rgba(16, 20, 32, 0.72);
  border-bottom: 1px solid rgba(215, 232, 255, 0.16);
}
.drawer-head h2 {
  font-size: 14.5px;
  font-weight: 700;
  color: #fff9e6;
}
.drawer-close {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid rgba(215, 232, 255, 0.2);
  background: rgba(40, 48, 68, 0.75);
  color: #e6f0ff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.drawer-close:hover { background: rgba(68, 80, 110, 0.9); }

.drawer-body {
  padding: 11px 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.drawer-body::-webkit-scrollbar { width: 6px; }
.drawer-body::-webkit-scrollbar-thumb { background: rgba(168, 198, 232, 0.3); border-radius: 3px; }

.sec-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #a9c6e8;
  letter-spacing: 0.4px;
  margin-top: 2px;
}

/* Landmark Teleport List */
.lm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lm-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  border: 1px solid rgba(215, 232, 255, 0.16);
  border-left: 3.5px solid var(--lm-accent, #ffd452);
  background: rgba(36, 44, 64, 0.75);
  color: #f3f7ff;
  cursor: pointer;
  text-align: left;
  transition: background 0.14s, transform 0.1s;
}
.lm-item:hover {
  background: rgba(54, 66, 94, 0.92);
  transform: translateX(-2px);
}
.lm-ico { font-size: 18px; width: 22px; text-align: center; }
.lm-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lm-title { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lm-sub { font-size: 10.5px; color: #9eb6d4; }
.lm-go {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(88, 174, 240, 0.22);
  color: #a8e4ff;
}

/* Character Switcher Drawer */
.cta-creator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(135deg, #e04d98, #8c52e0);
  border: 1px solid rgba(255, 210, 240, 0.55);
  box-shadow: 0 4px 14px rgba(176, 62, 160, 0.35);
  transition: transform 0.12s, filter 0.14s;
}
.cta-creator:hover { filter: brightness(1.1); transform: translateY(-1px); }

.char-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.char-tab {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(215, 232, 255, 0.2);
  background: rgba(34, 42, 60, 0.78);
  color: #c8dbf2;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.char-tab.active {
  background: rgba(54, 134, 210, 0.88);
  border-color: #9de0ff;
  color: #ffffff;
}

#chars-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}
.char-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 6px 7px;
  border-radius: 8px;
  border: 1.5px solid rgba(215, 232, 255, 0.18);
  background: rgba(34, 42, 62, 0.78);
  color: #f4f8ff;
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s, transform 0.1s;
}
.char-card:hover {
  border-color: #7cd4ff;
  background: rgba(50, 62, 90, 0.92);
  transform: translateY(-1px);
}
.char-card.active {
  border-color: #ffe066;
  background: rgba(74, 72, 46, 0.82);
}
.char-card.is-oc {
  border-color: rgba(255, 160, 220, 0.45);
}
.char-thumb {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.char-meta {
  text-align: center;
  margin-top: 2px;
  width: 100%;
}
.char-zh {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.char-en {
  font-size: 10px;
  color: #9cb4d1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.empty-tip {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 12px;
  color: #b8cde8;
  padding: 18px 10px;
  background: rgba(24, 30, 44, 0.6);
  border-radius: 8px;
  line-height: 1.6;
}

/* Floating Translucent Expression & Action Picker Popovers above Bottom Dock */
#expr-popover,
#action-popover {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 6px 8px;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  z-index: 30;
  max-width: min(560px, calc(100vw - 18px));
}
#expr-popover.open,
#action-popover.open {
  display: flex;
}
.pop-sep {
  width: 100%;
  height: 1px;
  background: rgba(215, 232, 255, 0.16);
  margin: 2px 0;
}
.ov-opt.active {
  background: rgba(214, 72, 138, 0.92);
  border-color: #ffb8dd;
  color: #ffffff;
}
.expr-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 42px;
  padding: 0 6px;
  border-radius: 7px;
  border: 1px solid rgba(215, 232, 255, 0.2);
  background: rgba(38, 46, 66, 0.84);
  color: #eef6ff;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
}
.expr-opt:hover {
  background: rgba(58, 72, 102, 0.96);
  border-color: rgba(160, 224, 255, 0.65);
  transform: translateY(-1px);
}
.expr-opt.active {
  background: rgba(54, 134, 210, 0.92);
  border-color: #a8e6ff;
  color: #ffffff;
}
.expr-ico { font-size: 16px; line-height: 1.1; }
.expr-lbl { font-size: 9.5px; margin-top: 2px; font-weight: 600; white-space: nowrap; }

/* Android App Back & Rotate Buttons (shown only inside PonyChat Android WebView) */
#btn-android-back,
#btn-android-rotate {
  display: none;
  align-items: center;
  gap: 4px;
  height: 31px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(220, 236, 255, 0.34);
  background: rgba(24, 29, 43, 0.88);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  box-shadow: 0 3px 10px rgba(10, 16, 30, 0.36);
}
body.android-app #btn-android-back,
body.android-app #btn-android-rotate {
  display: inline-flex;
}

.top-left-row {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

/* Mobile Full-Screen Dynamic Floating Virtual Thumb Joystick (summoned wherever finger drags!) */
#touch-joystick {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  bottom: auto;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(24, 30, 46, 0.34) 0%, rgba(20, 26, 40, 0.56) 100%);
  border: 2px solid rgba(224, 238, 255, 0.28);
  box-shadow: 0 6px 20px rgba(8, 12, 24, 0.36), inset 0 0 18px rgba(255, 255, 255, 0.06);
  z-index: 25;
  pointer-events: none;
  touch-action: none;
  backdrop-filter: blur(4px);
}
#touch-joystick.visible {
  display: block;
}
#touch-joystick.active {
  border-color: rgba(154, 224, 255, 0.68);
  background: radial-gradient(circle, rgba(32, 48, 76, 0.42) 0%, rgba(20, 28, 46, 0.66) 100%);
}
.joy-ring {
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px dashed rgba(210, 232, 255, 0.22);
  pointer-events: none;
}
#touch-stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, rgba(255, 255, 255, 0.92), rgba(164, 214, 255, 0.78));
  border: 2px solid rgba(30, 44, 72, 0.72);
  box-shadow: 0 4px 12px rgba(8, 14, 28, 0.45);
  pointer-events: none;
  transform: translate3d(0, 0, 0);
  transition: transform 0.06s ease-out;
}
#touch-joystick.active #touch-stick-knob {
  transition: none;
}

@media (hover: none) and (pointer: coarse) {
  .act-key { display: none; }
}
body.android-app .act-key { display: none; }

/* ================= HELD ITEM PILL & CLEAN PHOTO MODE ================= */
#held-item-pill {
  cursor: pointer;
  font-weight: 600;
  color: #fff5d4;
  background: rgba(46, 34, 16, 0.88);
  border: 1px solid rgba(255, 212, 102, 0.74);
  box-shadow: 0 2px 8px rgba(255, 198, 72, 0.2);
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}
#held-item-pill:hover {
  background: rgba(68, 52, 22, 0.95);
  border-color: #ffe285;
  transform: translateY(-1px);
}
#held-item-pill[hidden] {
  display: none;
}

#hud-top-left,
#hud-top-right,
#hud-bottom,
#touch-joystick,
#ponyville-sign-hint {
  transition: opacity 0.22s ease;
}

body.photo-mode #hud-top-left,
body.photo-mode #hud-top-right,
body.photo-mode #hud-bottom,
body.photo-mode #touch-joystick,
body.photo-mode .drawer,
body.photo-mode #ponyville-sign-hint {
  opacity: 0;
  pointer-events: none;
}
body.photo-mode #hud-top-left *,
body.photo-mode #hud-top-right *,
body.photo-mode #hud-bottom *,
body.photo-mode .drawer * {
  pointer-events: none !important;
}

#photo-exit-pill {
  display: none;
  position: fixed;
  right: calc(14px + env(safe-area-inset-right, 0px));
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  opacity: 0.45;
  transition: opacity 0.2s ease, background 0.14s, border-color 0.14s, transform 0.1s;
}
body.photo-mode #photo-exit-pill {
  display: inline-flex;
}
#photo-exit-pill:hover,
#photo-exit-pill:focus-visible {
  opacity: 1;
}

@media (max-width: 920px), (max-height: 540px) {
  #hud-top-left {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(10px + env(safe-area-inset-left, 0px));
    gap: 4px;
  }
  #hud-top-right {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(10px + env(safe-area-inset-right, 0px));
    gap: 5px;
  }
  #hud-bottom {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .zone-pill { padding: 5px 10px; font-size: 12px; gap: 6px; }
  .canon-tag { display: none; }
  .mini-pill { padding: 3px 7px; font-size: 10.5px; }
  .hud-btn { height: 28px; padding: 0 8px; font-size: 11px; gap: 4px; }
  .zoom-group { height: 28px; }
  .zoom-step { width: 25px; font-size: 14px; }
  #zoom-label { min-width: 24px; font-size: 10.5px; line-height: 26px; }
  .action-dock { padding: 4px 6px; gap: 3px; }
  .act-btn { min-width: 38px; height: 38px; padding: 0 4px; }
  .act-ico { font-size: 14px; }
  .act-lbl { font-size: 9px; }
  #expr-popover { flex-wrap: wrap; justify-content: center; padding: 5px 6px; gap: 3px; }
  .expr-opt { min-width: 42px; height: 38px; padding: 0 5px; }
  #chat-input { width: 112px; height: 32px; font-size: 11.5px; padding: 0 8px; }
  #btn-chat-send { height: 32px; padding: 0 9px; font-size: 11px; }
  #touch-joystick { width: 102px; height: 102px; }
  #touch-stick-knob { width: 40px; height: 40px; margin-left: -20px; margin-top: -20px; }
  .drawer { top: calc(8px + env(safe-area-inset-top, 0px)); right: calc(8px + env(safe-area-inset-right, 0px)); max-height: calc(100vh - 64px); width: 308px; }
}

@media (max-width: 720px) and (orientation: landscape) {
  #hud-bottom { left: auto; right: calc(10px + env(safe-area-inset-right, 0px)); transform: none; }
  #minimap-card { left: auto; right: 0; transform: none; }
  #chat-input { width: 90px; }
}

/* Portrait Phone Responsive Layout (Zero HUD Overlap & Lifted Joystick!) */
@media (orientation: portrait) and (max-width: 600px) {
  #hud-top-left {
    top: calc(8px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    gap: 4px;
  }
  .top-left-row { flex-wrap: nowrap; gap: 4px; }
  #btn-android-back,
  #btn-android-rotate {
    height: 28px;
    padding: 0 7px;
    font-size: 11px;
    flex-shrink: 0;
  }
  .zone-pill {
    padding: 4px 8px;
    font-size: 11.5px;
    max-width: 100%;
    overflow: hidden;
  }
  #zone-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #speed-pill,
  .character-status { display: none; }

  #hud-top-right {
    top: calc(44px + env(safe-area-inset-top, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    align-items: flex-end;
    gap: 4px;
  }
  .tool-row { gap: 4px; justify-content: flex-end; }
  .hud-btn { height: 26px; padding: 0 7px; font-size: 10.5px; }
  .zoom-group { height: 26px; }
  .zoom-step { width: 22px; font-size: 13px; }
  #zoom-label { min-width: 22px; font-size: 10px; line-height: 24px; }

  #hud-bottom {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: calc(100vw - 14px);
    max-width: calc(100vw - 14px);
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .action-dock {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 5px 6px;
  }
  .act-btn {
    flex: 1 1 0;
    min-width: 40px;
    max-width: 56px;
    height: 38px;
    padding: 0 3px;
  }
  .dock-sep { display: none; }
  .chat-box {
    width: 100%;
    margin-top: 2px;
  }
  #chat-input {
    flex: 1;
    width: auto;
    min-width: 0;
    height: 32px;
  }
  #btn-chat-send {
    height: 32px;
    flex-shrink: 0;
  }
  #touch-joystick {
    width: 96px;
    height: 96px;
  }
  #touch-stick-knob {
    width: 38px;
    height: 38px;
    margin-left: -19px;
    margin-top: -19px;
  }
  .drawer {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    width: auto;
    max-height: calc(100vh - 130px);
  }
}
#btn-exit-interior {
  padding: 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 214, 102, 0.55);
  background: linear-gradient(135deg, rgba(242, 166, 70, 0.92), rgba(217, 118, 52, 0.92));
  color: #fffdf5;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, filter 0.12s ease;
}
#btn-exit-interior:hover { filter: brightness(1.08); transform: translateY(-1px); }
#btn-exit-interior[hidden] { display: none !important; }
#interact-prompt {
  position: fixed;
  left: 50%;
  bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 42;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 224, 130, 0.72);
  background: rgba(20, 24, 42, 0.90);
  backdrop-filter: blur(8px);
  color: #fff6d6;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 14px rgba(255, 212, 102, 0.25);
  transition: transform 0.12s ease, filter 0.12s ease;
  white-space: nowrap;
}
#interact-prompt:hover { filter: brightness(1.1); transform: translateX(-50%) translateY(-1px); }
#interact-prompt[hidden] { display: none !important; }
body.photo-mode #interact-prompt { display: none !important; }
.lm-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.lm-enter {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid rgba(255, 212, 102, 0.55);
  background: rgba(255, 198, 84, 0.2);
  color: #ffe99e;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.lm-enter:hover { background: rgba(255, 198, 84, 0.38); }
.lm-go { border: 0; cursor: pointer; }

/* ================= BGM MUSIC CONTROL BUTTON & DRAWER ================= */
#btn-bgm.bgm-playing {
  border-color: rgba(255, 214, 102, 0.62);
  background: rgba(46, 36, 18, 0.86);
  color: #fff2be;
}
#btn-bgm.bgm-muted {
  opacity: 0.78;
  color: #a7b8d0;
}
.bgm-card {
  padding: 11px 12px;
  border-radius: 10px;
  background: rgba(16, 22, 36, 0.72);
  border: 1px solid rgba(210, 228, 255, 0.16);
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.bgm-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.bgm-switch-btn {
  flex: 1;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(128, 224, 152, 0.55);
  background: rgba(46, 146, 82, 0.34);
  color: #d8ffdf;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, opacity 0.14s;
}
.bgm-switch-btn:hover { background: rgba(56, 168, 96, 0.48); }
.bgm-switch-btn.off {
  border-color: rgba(210, 224, 245, 0.25);
  background: rgba(54, 62, 82, 0.55);
  color: #b4c3d8;
}
.bgm-step-btn {
  width: 34px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(210, 228, 255, 0.22);
  background: rgba(38, 48, 70, 0.72);
  color: #eef6ff;
  font-size: 13px;
  cursor: pointer;
}
.bgm-step-btn:hover { background: rgba(58, 74, 108, 0.9); border-color: rgba(160, 224, 255, 0.55); }
.bgm-vol-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bgm-vol-ico {
  font-size: 15px;
  width: 22px;
  text-align: center;
  cursor: pointer;
  background: none;
  border: 0;
  color: #ffe8a3;
}
#bgm-volume {
  flex: 1;
  height: 6px;
  accent-color: #ffd266;
  cursor: pointer;
}
#bgm-volume-label {
  min-width: 36px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
  color: #ffe8a3;
  font-variant-numeric: tabular-nums;
}
.bgm-now {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(28, 36, 56, 0.75);
  border: 1px solid rgba(255, 218, 122, 0.24);
}
.bgm-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
  width: 14px;
  flex-shrink: 0;
}
.bgm-eq i {
  display: block;
  width: 3px;
  height: 5px;
  border-radius: 1px;
  background: #ffd466;
  transition: height 0.2s;
}
.bgm-eq.playing i:nth-child(1) { animation: bgmBar 0.75s ease-in-out infinite alternate; }
.bgm-eq.playing i:nth-child(2) { animation: bgmBar 0.55s ease-in-out 0.2s infinite alternate; }
.bgm-eq.playing i:nth-child(3) { animation: bgmBar 0.85s ease-in-out 0.1s infinite alternate; }
@keyframes bgmBar {
  0%   { height: 4px; opacity: 0.6; }
  100% { height: 15px; opacity: 1; }
}
.bgm-now-meta {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.bgm-now-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #fff6d6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bgm-now-sub {
  font-size: 11px;
  color: #a9c0dc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bgm-mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.bgm-mode-btn {
  padding: 6px 8px;
  border-radius: 7px;
  border: 1px solid rgba(210, 228, 255, 0.2);
  background: rgba(34, 42, 62, 0.65);
  color: #c2d4eb;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.bgm-mode-btn.active {
  border-color: rgba(255, 214, 102, 0.68);
  background: rgba(255, 198, 84, 0.22);
  color: #fff2be;
}
.bgm-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.bgm-track-item {
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid rgba(210, 228, 255, 0.14);
  background: rgba(28, 35, 52, 0.68);
  color: #e8f1ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.12s, border-color 0.12s;
}
.bgm-track-item:hover {
  background: rgba(46, 58, 84, 0.88);
  border-color: rgba(160, 220, 255, 0.45);
}
.bgm-track-item.active {
  border-color: rgba(255, 214, 102, 0.72);
  background: rgba(74, 58, 24, 0.56);
}
.bgm-tr-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.bgm-tr-zh {
  font-size: 12px;
  font-weight: 700;
  color: #f6f9ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bgm-track-item.active .bgm-tr-zh { color: #ffe799; }
.bgm-tr-en {
  font-size: 10.5px;
  color: #9cb4d1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bgm-tr-dur {
  font-size: 10.5px;
  color: #9ab0cc;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
