/* ============================================================
   火星小屋 · 样式
   HUD = SpaceX 直播风遥测；卡片 = 像素游戏风面板
   ============================================================ */
:root {
  --ink: #f4e9dd;
  --dim: #b8a794;
  --mars: #d96a45;
  --mars-deep: #8f3b26;
  --sky: #e8a26a;
  --panel: #241512e6;
  --line: #5c352a;
  --accent: #ffb36b;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: #0d0807;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

#world { position: fixed; inset: 0; }
#world canvas { display: block; }

/* 暗角:径向渐变压暗四角(中心完全透明),在画布之上、一切 UI 之下;
   纯合成层不吃 GPU,配合场景内的太阳/吊灯加色光晕做"轻泛光"观感 */
#vignette {
  position: fixed; inset: 0; z-index: 4;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 52%, rgba(18, 7, 3, .16) 78%, rgba(9, 3, 2, .36) 100%);
}
body.cinema-on #vignette { display: none; }

/* ---------------- HUD（着陆动画） ---------------- */
#hud {
  position: fixed; inset: 0; z-index: 20;
  pointer-events: none;
  display: flex; flex-direction: column;
  justify-content: space-between;
  font-family: var(--mono);
  opacity: 0; transition: opacity .5s;
}
#hud.on { opacity: 1; }
#hud.done { opacity: 0; transition: opacity .8s; }

.hud-top {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 18px 252px 0 22px;   /* 右侧留出时钟面板(218px)的位置,阶段徽标不压时钟 */
  text-shadow: 0 1px 0 #000a;
}
.hud-brand .hud-mission {
  font-size: 12px; letter-spacing: .18em; color: var(--dim); text-transform: uppercase;
}
.hud-brand .hud-mission b { color: var(--accent); font-weight: 700; margin: 0 2px; }
.hud-phase {
  font-size: 12px; color: var(--mars); letter-spacing: .25em; text-transform: uppercase;
  border: 1px solid var(--mars); padding: 4px 10px; border-radius: 2px;
  background: #00000055;
}

.hud-tel {
  display: flex; flex-wrap: wrap; gap: 34px; padding: 0 22px 14px;
  font-size: 13px;
}
.hud-tel-item { display: flex; flex-direction: column; gap: 2px; }
.hud-tel-item span { color: var(--dim); font-size: 10px; letter-spacing: .2em; }
.hud-tel-item b {
  font-size: 22px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; min-width: 5ch;
}
.hud-tel-item b small { font-size: 11px; color: var(--dim); margin-left: 2px; }

.hud-boot {
  position: absolute; left: 22px; top: 54px;
  font-size: 11px; line-height: 1.7; color: #7dc98f; white-space: pre;
  text-shadow: 0 1px 0 #000a;
}
.hud-status {
  position: absolute; left: 50%; top: 42%; transform: translateX(-50%);
  font-family: var(--mono); font-size: clamp(16px, 3.2vw, 26px);
  letter-spacing: .5em; text-indent: .5em; color: var(--accent);
  text-shadow: 0 2px 0 #000c, 0 0 22px #ff8c4a66;
  opacity: 0; transition: opacity .25s; text-align: center; width: 100%;
}
.hud-status.on { opacity: 1; }
.hud-status.big { font-size: clamp(20px, 4.5vw, 36px); color: #8ff0a4; }

#skipBtn {
  position: absolute; right: 22px; bottom: 118px;
  pointer-events: auto; cursor: pointer;
  font-family: var(--mono); font-size: 12px; letter-spacing: .2em;
  color: var(--dim); background: #00000066;
  border: 1px solid var(--line); border-radius: 2px;
  padding: 8px 14px;
  transition: color .2s, border-color .2s;
}
#skipBtn:hover { color: var(--ink); border-color: var(--accent); }

.hud-scanline {
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 2px, #00000012 2px 3px);
  mix-blend-mode: multiply;
}

/* 屏幕震动类（加在 body 上） */
@keyframes shake { 0%,100%{transform:translate(0,0)} 25%{transform:translate(2px,-2px)} 50%{transform:translate(-2px,1px)} 75%{transform:translate(1px,2px)} }
.shaking { animation: shake .18s linear infinite; }
.shaking-hard { animation: shake .1s linear infinite; }

/* ---------------- 场景提示 ---------------- */
.tip {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 15; pointer-events: none;
  font-size: 13px; color: var(--dim);
  background: #0b0705cc; border: 1px solid var(--line); border-radius: 3px;
  padding: 8px 16px; letter-spacing: .05em;
  opacity: 0; transition: opacity .6s;
}
.tip.on { opacity: 1; }

/* 金星站特写镜头角标(导览飞到金星站时由 main.js 点亮) */
#closeupBadge {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 15; pointer-events: none;
  font-size: 12.5px; letter-spacing: .08em; color: #ffe9c0;
  background: #0b0705cc; border: 1px solid var(--accent); border-radius: 3px;
  padding: 6px 14px;
  opacity: 0; transition: opacity .6s;
}
#closeupBadge.on { opacity: 1; }

/* 太空视角飞行高度读数(上升/下降途中显示,顶部居中,特写角标下方) */
#spaceAlt {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  z-index: 15; pointer-events: none;
  font-family: var(--mono); font-size: 13px; letter-spacing: .1em; color: #ffe9c0;
  background: #0b0705cc; border: 1px solid var(--accent); border-radius: 3px;
  padding: 6px 14px; white-space: nowrap;
  opacity: 0; transition: opacity .6s;
}
#spaceAlt.on { opacity: 1; }

.tooltip {
  position: fixed; z-index: 16; pointer-events: none;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em;
  color: #fff; background: #170b08e0;
  border: 1px solid var(--mars); border-radius: 2px;
  padding: 5px 10px;
  opacity: 0; transition: opacity .12s;
  transform: translate(-50%, -160%);
}
.tooltip.on { opacity: 1; }
.tooltip i { color: var(--accent); font-style: normal; margin-right: 6px; }

/* ---------------- 头顶台词气泡（点击居民随机说话） ----------------
   z-index 45:高于人物卡遮罩(30),卡片开着时台词也读得到;
   位置由 ui.js 每 40ms 按角色头顶 3D 坐标投影写入 left/top。 */
.speech {
  position: fixed; z-index: 45; pointer-events: none;
  transform: translate(-50%, -115%);
  max-width: min(270px, 72vw);
  font-size: 13.5px; line-height: 1.55; color: #fff8ee;
  background: #170b08e8; border: 1px solid var(--accent); border-radius: 10px;
  padding: 8px 13px 9px;
  opacity: 0; transition: opacity .25s;
  box-shadow: 0 6px 22px #00000055;
}
.speech.on { opacity: 1; }
.speech::after {
  content: ''; position: absolute; left: 50%; bottom: -7px;
  width: 12px; height: 12px; transform: translateX(-50%) rotate(45deg);
  background: #170b08e8; border-right: 1px solid var(--accent); border-bottom: 1px solid var(--accent);
}
.speech b { display: block; font-size: 11.5px; letter-spacing: .08em; color: var(--accent); margin-bottom: 2px; }

/* ---------------- 像素按钮（Minecraft 风） ---------------- */
.mc-button {
  display: inline-block; cursor: pointer;
  font-family: var(--sans); font-size: 14px; color: #fff;
  background: linear-gradient(180deg, #7d8894, #59636e 45%, #454e58);
  border: 1px solid #23282e; border-radius: 9px;
  box-shadow: 0 4px 14px #00000055, inset 0 1px 0 #ffffff38;
  padding: 9px 18px; text-decoration: none; text-shadow: 0 1px 0 #00000088;
  transition: filter .15s; user-select: none;
}
.mc-button:hover { filter: brightness(1.15); }
.mc-button:active { filter: brightness(.9); box-shadow: inset -2px -2px 0 #ffffff40, inset 2px 2px 0 #00000066; }

/* ---------------- 内容卡片 ---------------- */
#pages { display: none; }
.page { display: none; }

.card-backdrop {
  position: fixed; inset: 0; z-index: 30;
  background: #0a0504a8; backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.card-backdrop.on { opacity: 1; pointer-events: auto; }

.card {
  width: min(560px, 100%); max-height: min(82vh, 720px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 24px 60px #000c, inset 0 1px 0 #ffffff14;
  padding: 26px 28px 30px;
  transform: translateY(14px) scale(.97); transition: transform .28s cubic-bezier(.2,1.4,.4,1);
  scrollbar-width: thin; scrollbar-color: var(--mars-deep) transparent;
}
.card-backdrop.on .card { transform: none; }
@media (max-width: 480px) { .card { padding: 20px 18px 24px; } }

.card header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.page-icon { font-size: 26px; }
.card h2 { margin: 0; font-size: 22px; letter-spacing: .06em; }
.page-en { margin: 0 0 0 auto; font-family: var(--mono); font-size: 11px; letter-spacing: .3em; color: var(--dim); }
.page-desc { color: var(--dim); font-size: 13px; margin: 4px 0 18px; }
.dim { color: var(--dim); font-size: 13px; }

.card-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; line-height: 28px; text-align: center;
  cursor: pointer; color: var(--dim); background: #00000040;
  border: 1px solid var(--line); border-radius: 2px; font-size: 15px;
  font-family: var(--mono);
}
.card-close:hover { color: #fff; border-color: var(--accent); }

/* 关于我 */
.about { display: flex; gap: 22px; align-items: flex-start; }
@media (max-width: 520px) { .about { flex-direction: column; align-items: center; } }
.avatar {
  flex: 0 0 132px; width: 132px; height: 132px;
  background: #1a0d0a; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 10px 28px #00000066;
  overflow: hidden;
  padding: 0;
}
.avatar svg { display: block; width: 100%; height: 100%; }
.about-text { flex: 1; min-width: 0; }
.about-text p { margin: 0 0 12px; font-size: 14.5px; line-height: 1.8; }
.about-foot { display: flex; gap: 12px; margin-top: 16px; }

/* 作品 */
.works { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.works li {
  display: flex; gap: 16px; align-items: center;
  background: #00000038; border: 1px solid var(--line);
  padding: 14px 16px;
}
.work-icon {
  flex: 0 0 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  font-size: 30px; background: #170d0a; border: 2px solid var(--line);
  box-shadow: inset 0 0 0 1px #000;
}
.work-body h3 { margin: 0 0 4px; font-size: 16px; }
.work-body p { margin: 0 0 10px; font-size: 13.5px; color: var(--dim); line-height: 1.6; }

/* 关注 */
.contact { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .contact { grid-template-columns: 1fr; } }
.contact li {
  display: flex; flex-direction: column; gap: 3px;
  background: #00000038; border: 1px solid var(--line); padding: 12px 14px;
}
.contact span { font-size: 11px; letter-spacing: .2em; color: var(--dim); }
.contact a { color: var(--accent); font-size: 14.5px; text-decoration: none; word-break: break-all; }
.contact a:hover { text-decoration: underline; }

/* 留言 */
.mailbox { display: flex; flex-direction: column; gap: 10px; }
.mailbox input, .mailbox textarea {
  font-family: var(--sans); font-size: 14px; color: var(--ink);
  background: #00000048; border: 1px solid var(--line);
  padding: 11px 12px; outline: none; resize: vertical;
}
.mailbox input:focus, .mailbox textarea:focus { border-color: var(--mars); }
.mailbox input::placeholder, .mailbox textarea::placeholder { color: #8c7566; }
.mailbox-foot { margin-top: 4px; }
.mailbox-status { margin: 8px 0 0; font-size: 13px; color: #8ff0a4; min-height: 1em; }

/* 无 JS / 加载失败时的纯文本页面 */
#pages.fallback, #pages.fallback .page {
  display: block;
  position: relative; z-index: 5;
  background: transparent;
}
#pages.fallback {
  height: 100vh; overflow-y: auto; padding: 40px 20px 60px;
  display: block; background: linear-gradient(180deg, #2a130e, #0d0807);
}
#pages.fallback .page {
  max-width: 640px; margin: 0 auto 40px;
  padding: 24px 26px; background: var(--panel);
  border: 2px solid var(--line);
}
#pages.fallback .card-close { display: none; }
.plain-title { font-size: 24px; margin: 0 0 4px; text-align: center; }
.plain-sub { text-align: center; color: var(--dim); margin: 0 0 30px; }
.beian { text-align: center; color: #7c6a5c; font-size: 12px; padding: 14px 0 26px; }
.beian a { color: #7c6a5c; text-decoration: none; }

/* 兼容模式下的卡片关闭按钮隐藏 */
.card-close { position: absolute; }
.card { position: relative; }

/* 手机竖屏优化 */
@media (max-width: 640px) {
  .hud-tel { gap: 20px; }
  .hud-tel-item b { font-size: 17px; }
  /* 品牌文案在窄屏会换行成两行,自检清单下移到 96px 避开,不再互相压字 */
  .hud-boot { font-size: 10px; top: 96px; left: 14px; }
  .hud-brand .hud-mission { font-size: 10.5px; letter-spacing: .1em; }
  .hud-phase { font-size: 10px; letter-spacing: .15em; padding: 3px 8px; }
}

/* ---------------- 左下角导航地图 ---------------- */
#minimap {
  position: fixed; left: 16px; bottom: 16px; z-index: 18;
  width: 196px;
  background: #0a0f14d9;
  border: 1px solid #2a4a5a;
  box-shadow: 0 0 0 1px #000a, 0 10px 30px #000a, inset 0 0 24px #74d0ee08;
  border-radius: 4px;
  overflow: hidden;
  cursor: default;
  opacity: 0; transform: translateY(10px);
  transition: opacity .7s, transform .7s;
  pointer-events: none;
}
body.explore #minimap { opacity: 1; transform: none; pointer-events: auto; }
#minimap .minimap-title {
  font-family: var(--mono); font-size: 10px; letter-spacing: .25em;
  color: #8fd8f0;
  padding: 6px 10px 5px;
  border-bottom: 1px solid #1a2a34;
  background: linear-gradient(180deg, #10202a, #0a141a);
}
#minimap canvas { display: block; }
/* 小地图图层开关 + 重播着陆:固定按钮(与 fpvBtn/soundBtn 同系,
   叠在右下按钮列上方)。开场动画期间隐藏 —— 让入轨/下落段是
   干净的电影画面,只留着陆 HUD 与跳过按钮;着陆交接(body.explore,
   landing onDone 时加)后淡入,点跳过着陆也走同一交接、立即出现。
   不放进 #minimap 是沿用旧结构,显隐与小地图同绑 body.explore。 */
.layerBtn {
  position: fixed; right: 16px; z-index: 19;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em;
  color: #bfe8ff; cursor: pointer;
  background: #0a141ae6;
  border: 1px solid #2a4a5a; border-radius: 3px;
  padding: 10px 14px; min-height: 38px; min-width: 96px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .6s, visibility 0s .6s, border-color .2s, color .2s, background .2s;
}
body.explore .layerBtn {
  opacity: 1; visibility: visible; pointer-events: auto;
  transition: opacity .6s, border-color .2s, color .2s, background .2s;
}
#btnGridLayer { bottom: 160px; }
#btnPipeLayer { bottom: 112px; }
#replayBtn { bottom: 208px; }
.layerBtn:hover { border-color: #74d0ee; color: #fff; }
.layerBtn.on { color: #ffd98a; border-color: #ffb03a; background: #2a1f0de6; }
body.cinema-on .layerBtn { opacity: 0 !important; pointer-events: none; }
#minimap .minimap-hint {
  font-size: 10px; color: #4f6a78; text-align: center;
  padding: 4px 6px 6px; letter-spacing: .05em;
  border-top: 1px solid #12202a;
}
@media (max-width: 640px) {
  /* 小屏小地图再缩一号,给场景和提示条让位;缩放后实际占位 ≈163×133px */
  #minimap { transform: scale(.68); transform-origin: left bottom; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); }
  body.explore #minimap { transform: scale(.68); }
  #minimap .minimap-hint { display: none; }   /* 触屏没有"悬停",提示语隐藏省高度 */
}

/* ---------------- 图书室书目卡片 ---------------- */
.book-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.book-item {
  display: flex; align-items: center; gap: 12px;
  background: #00000038; border: 1px solid var(--line);
  padding: 8px 10px;
}
.book-item .book-spine {
  flex: 0 0 10px; width: 10px; height: 34px;
  border: 1px solid #00000088;
  box-shadow: inset -2px 0 0 #00000055;
}
.book-item .book-body { flex: 1; min-width: 0; }
.book-item h4 { margin: 0; font-size: 14px; }
.book-item p { margin: 2px 0 0; font-size: 12px; color: var(--dim); }
.book-item .book-link { flex: 0 0 auto; }
.book-item.book-todo { opacity: .78; }
.book-none {
  font-size: 11px; color: #7c6a5c; border: 1px dashed #5c352a;
  padding: 6px 10px; letter-spacing: .1em;
}

/* ---------------- 影院卡片配置区 ---------------- */
.cinema-config { display: flex; flex-direction: column; gap: 12px; }
.cinema-config .cinema-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.cinema-config-body {
  display: none; flex-direction: column; gap: 8px;
  background: #00000038; border: 1px solid var(--line); padding: 12px 14px;
}
.cinema-config.open .cinema-config-body, .cinema-config-body.open { display: flex; }
.cinema-config-body label { font-size: 12px; color: var(--dim); letter-spacing: .1em; }
.cinema-config-body input {
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: #00000048; border: 1px solid var(--line);
  padding: 10px 12px; outline: none;
}
.cinema-config-body input:focus { border-color: var(--mars); }
.cinema-status { margin: 0; font-size: 12.5px; color: var(--dim); min-height: 1em; word-break: break-all; }
.cinema-status.ok { color: #8ff0a4; }

/* ---------------- 影院放映层(全屏)---------------- */
.cinema-layer {
  position: fixed; inset: 0; z-index: 60;
  background: #050505f2;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.cinema-layer.on { opacity: 1; pointer-events: auto; }
.cinema-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: #0a0f14; border-bottom: 1px solid #1a2a34;
}
.cinema-bar .cinema-title {
  font-family: var(--mono); font-size: 12px; letter-spacing: .22em;
  color: #8fd8f0;
}
.cinema-bar .cinema-actions { display: flex; gap: 8px; }
.c-btn {
  font-family: var(--mono); font-size: 12px; cursor: pointer;
  color: var(--ink); background: #14202a;
  border: 1px solid #2a4a5a; border-radius: 2px; padding: 7px 12px;
  transition: background .2s, border-color .2s;
}
.c-btn:hover { background: #1a2a36; border-color: #74d0ee; }
.cinema-frame { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; padding: 14px; }
.cinema-frame iframe {
  width: 100%; height: 100%;
  border: 1px solid #1a2a34; background: #000;
}
.cinema-note {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: #b8a794; background: #0a0f14cc;
  border: 1px solid #2a4a5a; border-radius: 3px; padding: 8px 14px;
  max-width: 82%; text-align: center;
}
body.cinema-on #minimap { opacity: 0 !important; pointer-events: none; }

/* ---------------- 基地导览卡 ---------------- */
.tour { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 560px) { .tour { grid-template-columns: 1fr; } }
.tour li {
  display: flex; align-items: center; gap: 10px;
  background: #00000038; border: 1px solid var(--line);
  padding: 10px 12px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.tour li:hover { border-color: var(--accent); background: #1a0d08a0; }
.tour li i { font-style: normal; font-size: 20px; flex: 0 0 26px; text-align: center; }
.tour li div { flex: 1; min-width: 0; }
.tour li h4 { margin: 0; font-size: 13.5px; }
.tour li p { margin: 2px 0 0; font-size: 11.5px; color: var(--dim); }
.tour li span { font-family: var(--mono); font-size: 10px; color: var(--accent); letter-spacing: .15em; }

/* ---------------- 第一人称漫游 UI ---------------- */
#fpvBtn {
  position: fixed; right: 16px; bottom: 16px; z-index: 19;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em;
  color: #bfe8ff; cursor: pointer;
  background: #0a141ae6;
  border: 1px solid #2a4a5a; border-radius: 3px;
  padding: 10px 14px;
  /* 常驻可见:不再等 body.explore(着陆结束)才淡入 —— 触屏无 hover,
     opacity 0 期间按钮等于不存在,审计与真机都够不着 */
  opacity: 1; pointer-events: auto;
  transition: opacity .6s, border-color .2s, color .2s;
}
#fpvBtn:hover { border-color: #74d0ee; color: #fff; }
body.fpv #fpvBtn { color: #8ff0a4; border-color: #3a7a4a; }

/* 环境声开关(与第一人称按钮同系,叠在其上方;js/sound.js 驱动) */
#soundBtn {
  position: fixed; right: 16px; bottom: 64px; z-index: 19;
  font-family: var(--mono); font-size: 12px; letter-spacing: .12em;
  color: #bfe8ff; cursor: pointer;
  background: #0a141ae6;
  border: 1px solid #2a4a5a; border-radius: 3px;
  padding: 10px 14px; min-height: 38px;
  opacity: 1; pointer-events: auto;   /* 与 fpvBtn 同:常驻可见 */
  transition: opacity .6s, border-color .2s, color .2s;
}
#soundBtn:hover { border-color: #74d0ee; color: #fff; }
#soundBtn.on { color: #ffd9a0; border-color: #8a5a2a; }
body.cinema-on #soundBtn { opacity: 0 !important; pointer-events: none; }

#crosshair {
  position: fixed; left: 50%; top: 50%; z-index: 17;
  width: 16px; height: 16px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
}
body.fpv #crosshair { display: block; }
#crosshair::before {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; transform: translate(-50%, -50%);
  border: 1.5px solid #ffffffb8; border-radius: 50%;
  box-shadow: 0 0 4px #0009;
}
#crosshair::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 2.5px; height: 2.5px; transform: translate(-50%, -50%);
  background: #fff; border-radius: 50%;
  box-shadow: 0 0 3px #000a;
}

#fpvTip {
  position: fixed; top: 14px; left: 50%; z-index: 19;
  transform: translateX(-50%);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .1em;
  color: #bfe8ff; background: #0a141acc;
  border: 1px solid #2a4a5a; border-radius: 3px;
  padding: 7px 14px;
  display: none; pointer-events: none;
  white-space: nowrap;
}
body.fpv #fpvTip { display: block; }
@media (max-width: 640px) { #fpvTip { font-size: 10px; white-space: normal; max-width: 92vw; text-align: center; } }
body.fpv #minimap { opacity: 1; }

/* ---------------- 视角切换栏(左上角,探索模式显示) ---------------- */
#viewBar {
  position: fixed; left: 16px; top: calc(14px + env(safe-area-inset-top)); z-index: 21;
  display: none; gap: 4px; padding: 4px;
  background: #0a141ae6; border: 1px solid #2a4a5a; border-radius: 4px;
  box-shadow: 0 0 0 1px #000a, 0 10px 30px #000a;
}
body.explore #viewBar { display: flex; animation: uiIn .7s ease both; }
@keyframes uiIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
#viewBar button {
  font-family: var(--mono); font-size: 12px; letter-spacing: .08em;
  color: #bfe8ff; background: transparent; cursor: pointer;
  border: 1px solid transparent; border-radius: 3px;
  padding: 9px 11px; min-height: 42px; white-space: nowrap;
  transition: border-color .2s, color .2s, background .2s;
}
#viewBar button:hover { border-color: #74d0ee; color: #fff; }
#viewBar button.on { color: #ffd98a; border-color: #ffb03a; background: #2a1f0de6; }
#viewBar kbd {
  font-family: var(--mono); font-size: 9px; opacity: .55;
  border: 1px solid #ffffff38; border-radius: 2px; padding: 0 3px; margin-left: 2px;
}
@media (pointer: coarse) { #viewBar kbd { display: none; } }
@media (max-width: 640px) { #spaceAlt { top: auto; bottom: 110px; font-size: 12px; } }
@media (max-width: 640px) {
  #viewBar { left: 10px; top: calc(10px + env(safe-area-inset-top)); flex-wrap: wrap; max-width: calc(100vw - 20px); }
  #viewBar button { font-size: 11px; padding: 8px 7px; min-height: 40px; }
  /* 探索模式下时钟下移,给视角栏让出顶部横条(着陆阶段不影响) */
  body.explore #marsClock { top: calc(60px + env(safe-area-inset-top)); }
}
body.cinema-on #viewBar { opacity: 0 !important; pointer-events: none; }

/* ---------------- 实体第一视角:附身横幅 + 提示 ---------------- */
#possessBar {
  position: fixed; top: calc(14px + env(safe-area-inset-top)); left: 50%; z-index: 21;
  transform: translateX(-50%);
  display: none; align-items: center; gap: 10px;
  max-width: 94vw; white-space: nowrap;
  background: #0a141ae6; border: 1px solid #ffb03a; border-radius: 4px;
  box-shadow: 0 0 0 1px #000a, 0 10px 30px #000a;
  padding: 6px 8px 6px 14px;
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em; color: #ffd98a;
}
body.possess #possessBar { display: flex; }
#possessName { overflow: hidden; text-overflow: ellipsis; }
#possessExit {
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em;
  color: #ffe9c0; background: #2a1f0d; cursor: pointer;
  border: 1px solid #ffb03a; border-radius: 3px;
  padding: 8px 12px; min-height: 38px; flex: 0 0 auto;
}
#possessExit:hover { color: #fff; border-color: #ffd98a; }
#possessTip {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; z-index: 19;
  transform: translateX(-50%);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em;
  color: #bfe8ff; background: #0a141acc;
  border: 1px solid #2a4a5a; border-radius: 3px;
  padding: 7px 14px;
  display: none; pointer-events: none; white-space: nowrap;
}
body.possess #possessTip { display: block; }
body.possess #crosshair { display: block; }
@media (max-width: 640px) {
  /* 附身中:视角栏先让位(横幅自带退出按钮),横幅回顶部,时钟在右下方不冲突 */
  body.possess #viewBar { display: none; }
  #possessBar { top: calc(10px + env(safe-area-inset-top)); font-size: 11.5px; padding: 4px 6px 4px 10px; }
  #possessExit { min-height: 34px; padding: 6px 10px; }
  #possessTip { top: calc(64px + env(safe-area-inset-top)); left: 10px; transform: none; font-size: 10px; white-space: normal; max-width: 48vw; text-align: left; }
}
body.cinema-on #possessBar, body.cinema-on #possessTip { opacity: 0 !important; pointer-events: none; }

/* ---------------- 实体操作菜单(点选人/机器人弹出) ---------------- */
#entityMenu {
  position: fixed; z-index: 44; width: 200px;
  background: #0d1419f5; border: 1px solid #ffb03a; border-radius: 6px;
  box-shadow: 0 14px 34px #000d, 0 0 0 1px #000a;
  padding: 6px; display: none;
}
#entityMenu.on { display: block; }
#entityMenu .em-title {
  font-size: 12.5px; color: #ffd98a; letter-spacing: .05em;
  padding: 7px 10px 9px; margin-bottom: 6px;
  border-bottom: 1px solid #2a4a5a;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#entityMenu button {
  display: block; width: 100%; text-align: left;
  font-size: 13.5px; color: #e8f4ff; background: transparent;
  border: 0; border-radius: 4px; padding: 12px 10px; min-height: 46px;
  cursor: pointer;
}
#entityMenu button:hover { background: #1c303c; }
#entityMenu button[data-act="close"] { color: #8fa8b5; }

/* 手机 FPV 虚拟摇杆:仅第一人称 + 粗指针(触屏)时出现,左下角大触控区 */
#joystick {
  position: fixed; left: 22px; bottom: calc(196px + env(safe-area-inset-bottom)); z-index: 19;
  width: 118px; height: 118px; border-radius: 50%;
  background: #0a141a99; border: 1.5px solid #2a4a5a;
  box-shadow: inset 0 0 24px #74d0ee14, 0 8px 24px #000a;
  display: none; touch-action: none;
}
#joyKnob {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; border-radius: 50%;
  background: #1c303cdd; border: 1.5px solid #74d0ee;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 10px #000c;
  pointer-events: none;
}
@media (pointer: coarse) {
  body.fpv #joystick, body.possess #joystick { display: block; }
}
@media (max-width: 640px) {
  /* 小屏 FPV 时小地图缩在左下,摇杆抬到它上方避免重叠 */
  #joystick { left: 16px; bottom: calc(158px + env(safe-area-inset-bottom)); width: 108px; height: 108px; }
}
body.cinema-on #fpvBtn { opacity: 0 !important; pointer-events: none; }

/* ---------------- 火星时间面板(martiantime.js 驱动)---------------- */
#marsClock {
  position: fixed; right: 16px; top: 16px; z-index: 18;
  width: 218px;
  background: #0a0f14d9;
  border: 1px solid #2a4a5a;
  box-shadow: 0 0 0 1px #000a, 0 10px 30px #000a, inset 0 0 24px #74d0ee08;
  border-radius: 4px;
  overflow: hidden;
  /* 开场动画期间隐藏(干净的电影画面,只留着陆 HUD 与跳过按钮);
     着陆交接(body.explore,landing onDone 时加)后淡入 —— 出现
     时机绑交接事件,不用固定延时;点跳过着陆也立即出现 */
  opacity: 0; visibility: hidden; transform: none;
  transition: opacity .7s, transform .7s, visibility 0s .7s;
  pointer-events: none;
}
body.explore #marsClock {
  opacity: 1; visibility: visible;
  transition: opacity .7s, transform .7s;
  pointer-events: auto;
}
#marsClock .mclk-head {
  font-family: var(--mono); font-size: 10px; letter-spacing: .25em;
  color: #8fd8f0; padding: 6px 10px 5px;
  border-bottom: 1px solid #1a2a34;
  background: linear-gradient(180deg, #10202a, #0a141a);
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
#marsClock .mclk-dot {
  flex: 0 0 6px; width: 6px; height: 6px; border-radius: 50%;
  background: #ffb36b; box-shadow: 0 0 6px #ffb36b;
  animation: mclkPulse 2s infinite;
}
@keyframes mclkPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
#marsClock .mclk-time { display: flex; align-items: baseline; gap: 8px; padding: 7px 10px 0; }
#marsClock .mclk-time b { font-family: var(--mono); font-size: 22px; color: #ffe9c0; letter-spacing: .04em; }
#marsClock .mclk-time i { font-style: normal; font-size: 10px; color: #4f6a78; letter-spacing: .08em; white-space: nowrap; }
#marsClock .mclk-row {
  display: flex; justify-content: space-between;
  padding: 3px 10px 0; font-family: var(--mono); font-size: 11px; color: #8fd8f0;
}
#marsClock .mclk-sun { padding: 5px 10px 2px; font-size: 12px; color: #ffd9a0; letter-spacing: .03em; white-space: nowrap; }
/* 通信链路行:深空通信站信号/过境(martiantime.js 驱动 #mcComm) */
#marsClock .mclk-comm {
  padding: 3px 10px 0; font-family: var(--mono); font-size: 10px;
  color: #8fd8f0; letter-spacing: .02em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
/* 时钟提醒行:火卫一升起 / 沙尘暴(martiantime.js 驱动 #mcAlert) */
#marsClock .mclk-alert {
  display: none; padding: 4px 10px 0;
  font-size: 11px; color: #9fe8ff; letter-spacing: .02em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
#marsClock .mclk-alert.on { display: block; }
#marsClock .mclk-alert.warn { color: #ff9a5e; }
#marsClock .mclk-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 9px; }
#marsClock .mclk-foot span { font-family: var(--mono); font-size: 10px; color: #6a8894; }
#mcSpeed {
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  color: #ffe9c0; background: #16242e; border: 1px solid #2a4a5a;
  border-radius: 2px; padding: 3px 8px; cursor: pointer;
}
#mcSpeed:hover { background: #1e3442; color: #fff; }
@media (max-width: 640px) {
  #marsClock { transform: scale(.8); transform-origin: right top; right: 10px; top: calc(10px + env(safe-area-inset-top)); }
  body.explore #marsClock { transform: scale(.8); }
}

/* ---------------- 移动端综合(小屏布局/触控目标/安全区)---------------- */
@media (max-width: 640px) {
  /* 右下按钮组:避开手势条安全区,保持 ≥38px 触控高度 */
  #fpvBtn { right: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 11px; padding: 10px 12px; min-height: 38px; }
  #soundBtn { right: 10px; bottom: calc(58px + env(safe-area-inset-bottom)); font-size: 11px; padding: 10px 12px; }
  /* 底部提示条:限宽居中,不与小地图/按钮重叠,长文案自动换行不溢出 */
  .tip {
    bottom: calc(168px + env(safe-area-inset-bottom));
    width: max-content; max-width: calc(100vw - 24px);
    text-align: center; font-size: 12px; padding: 7px 12px;
  }
  /* 着陆 HUD:标题字距收紧防溢出,遥测数字略缩 */
  .hud-status { letter-spacing: .28em; text-indent: .28em; }
  .hud-top { padding: 14px 192px 0 14px; }
  .hud-tel { padding: 0 14px 10px; }
  #skipBtn { right: 14px; bottom: calc(112px + env(safe-area-inset-bottom)); padding: 10px 14px; }
  .about-foot { flex-wrap: wrap; }
}
/* 粗指针(触屏):时钟面板的流速按钮也要够大,好点 */
@media (pointer: coarse) {
  #mcSpeed { min-height: 32px; padding: 6px 12px; font-size: 11px; }
  .card-close { width: 36px; height: 36px; line-height: 34px; }
}
/* ---------------- file:// 打开提示 + 模型加载失败提示 ----------------
   两者都只在出问题时才出现,正常托管打开不可见 */
#fileProtoBanner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  display: none;
  background: #4a2408; color: #ffd9a8;
  border-bottom: 2px solid #e07b2a;
  padding: calc(10px + env(safe-area-inset-top)) 48px 10px 16px;
  font-size: 13px; line-height: 1.65;
}
#fileProtoBanner.show { display: block; }
#fileProtoBanner b { color: #ffb35c; }
#fileProtoBanner code {
  background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 4px;
  font-size: 12px; color: #ffe1bd; white-space: nowrap;
}
#fileProtoBanner .fp-close {
  position: absolute; top: calc(6px + env(safe-area-inset-top)); right: 10px;
  width: 32px; height: 32px; border: 0; border-radius: 6px;
  background: rgba(0,0,0,.3); color: #ffd9a8; font-size: 16px; cursor: pointer;
}
#modelWarn {
  position: fixed; left: 228px; bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 46; max-width: min(430px, calc(100vw - 244px));
  display: none;
  background: rgba(43, 18, 8, .94); color: #f3d9c8;
  border: 1px solid #b3541e; border-radius: 10px;
  padding: 12px 38px 12px 14px; font-size: 12.5px; line-height: 1.65;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
}
#modelWarn.show { display: block; }
#modelWarn b { color: #ffb35c; }
#modelWarn ul { margin: 4px 0 0; padding-left: 18px; }
#modelWarn .mw-close {
  position: absolute; top: 6px; right: 6px;
  width: 30px; height: 30px; border: 0; border-radius: 6px;
  background: rgba(0,0,0,.35); color: #f3d9c8; font-size: 15px; cursor: pointer;
}
@media (max-width: 640px) {
  #modelWarn {
    left: 50%; transform: translateX(-50%); bottom: auto;
    top: calc(118px + env(safe-area-inset-top));
    width: calc(100vw - 20px); max-width: calc(100vw - 20px); font-size: 12px;
  }
}
