/* 演绎精灵 · H5 同好位置 —— 样式
 *
 * 深色为主：这是给人在演唱会现场、天黑之后看的页面，亮底会晃眼。
 * 强调色用琥珀 #FFC107，和眼镜上队友标记的描边同色 —— 同一个概念在两端长得一样。
 */

:root {
  --bg:        #0e1116;
  --panel:     #161b22;
  --panel-2:   #1f2630;
  --line:      #2c3540;
  --fg:        #e6edf3;
  --fg-dim:    #8b98a5;
  --amber:     #ffc107;   /* 队友 */
  --self:      #22c55e;   /* 自己 */
  --danger:    #ef4444;
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;                 /* 页面本身不滚，滚动只发生在地图上 */
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC",
        "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;        /* 关掉下拉刷新，免得拖地图时把页面拉走 */
}

#map {
  position: absolute;
  inset: 0;
  background: var(--bg);
}

/* 瓦片拉不到时的兜底：网格底图。
 * 高德那个瓦片接口是非官方的、没有 SLA，被限了就是一片白/黑。
 * 但坐标系和标点逻辑完全不依赖瓦片，所以宁可画网格也要让位置功能活着。 */
#map.tile-dead {
  background-color: #10151b;
  background-image:
    linear-gradient(to right,  var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
}

/* ------------------------------------------------------------ 顶部横幅 */
.banner {
  position: absolute;
  z-index: 1200;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: 8px;
  right: 8px;
  padding: 10px 36px 10px 12px;
  border-radius: 10px;
  background: #3a2c05;
  border: 1px solid #6b5209;
  color: #ffe08a;
  font-size: 13px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
}
.banner[hidden] { display: none; }
.banner b { color: #ffd24d; }
.banner .x {
  position: absolute;
  top: 4px; right: 6px;
  width: 28px; height: 28px;
  border: 0; background: none;
  color: inherit; font-size: 18px; line-height: 1;
  cursor: pointer;
}
.banner.err { background: #3a1010; border-color: #7f1d1d; color: #fca5a5; }
.banner.err b { color: #fecaca; }

/* ------------------------------------------------------------ 右上角 HUD */
.hud {
  position: absolute;
  z-index: 1100;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(14, 17, 22, .82);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  font-size: 12px;
  text-align: right;
  pointer-events: none;
  min-width: 96px;
}
.hud #hudPeers { color: var(--amber); font-weight: 600; }
.hud .ago { color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.hud .ago.stale { color: var(--danger); font-weight: 600; }

/* ------------------------------------------------------------ 右下角按钮 */
.fab {
  position: absolute;
  z-index: 1100;
  right: 12px;
  bottom: calc(74px + var(--safe-b));
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--self);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
}
.fab:active { background: var(--panel-2); }

/* ------------------------------------------------------------ 底部面板 */
.panel {
  position: absolute;
  z-index: 1300;
  left: 0; right: 0; bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, .5);
  padding-bottom: var(--safe-b);
  max-height: 76vh;
  display: flex;
  flex-direction: column;
}

.handle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 8px 0 6px;
  border: 0;
  background: none;
  color: var(--fg-dim);
  font-size: 12px;
  cursor: pointer;
}
.handle .grip {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--line);
}
.handle[aria-expanded="true"] { color: var(--fg); }

.panel-body {
  display: none;
  padding: 4px 14px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.panel.open .panel-body { display: block; }
.panel.open .panel-body { animation: slide .16s ease-out; }
@keyframes slide { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.field { display: block; margin: 10px 0; }
.field .lab {
  display: block;
  margin-bottom: 4px;
  color: var(--fg-dim);
  font-size: 12px;
}
.field input[type="text"],
.field input[type="url"],
.field input[type="password"] {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--fg);
  font-size: 15px;              /* ≥16px 会阻止 iOS 聚焦缩放，但这里面板是固定宽的，15 够用且不跳 */
  font-family: inherit;
}
.field input:focus { outline: 2px solid #2f6feb; outline-offset: 0; border-color: #2f6feb; }

/* 槽位选择：一排可点的形状，直接长得像眼镜上会画出来的样子 */
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slots button {
  width: 38px; height: 38px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--amber);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.slots button.on {
  border-color: var(--amber);
  background: #2a2410;
  box-shadow: inset 0 0 0 1px var(--amber);
}
.slots button svg { display: block; }

.warn {
  margin: 6px 0 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: #3a2c05;
  border: 1px solid #6b5209;
  color: #ffe08a;
  font-size: 12px;
}
.warn[hidden] { display: none; }

.adv { margin: 12px 0 0; border-top: 1px solid var(--line); padding-top: 10px; }
.adv summary {
  color: var(--fg-dim);
  font-size: 12px;
  cursor: pointer;
  list-style: none;
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before { content: "▸ "; }
.adv[open] summary::before { content: "▾ "; }

.check { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0; font-size: 13px; }
.check input { margin-top: 3px; flex: none; }

.hint {
  margin: 10px 0 0;
  color: var(--fg-dim);
  font-size: 12px;
  line-height: 1.6;
}
.hint b { color: #ffd24d; }

/* ------------------------------------------------------------ 地图上的标记 */
/* 所有标记都用 L.divIcon 画的，不请求 Leaflet 自带的 PNG。
 * 我们给 divIcon 传了 className: 'go2-mk'，覆盖掉默认的 'leaflet-div-icon'，
 * 所以白色方块底和描边都不会出现；下面那条只是万一有人加了默认 marker 时的兜底。 */
.leaflet-div-icon { background: none; border: 0; }

.go2-mk { color: var(--amber); }   /* divIcon 里的 SVG 用 currentColor 取这个色 */

.mk { position: relative; }
.mk svg { display: block; overflow: visible; }
.mk .lab {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 1px;
  padding: 0 3px;
  font-size: 11px;
  line-height: 1.35;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 3px #000;   /* 底图有明暗，不描边读不清 */
  pointer-events: none;
}

/* 新鲜度：越旧越淡。三档对应 5s / 12s，15s 之后本地直接丢掉不画了 */
.mk.f1 { opacity: 1; }
.mk.f2 { opacity: .55; }
.mk.f3 { opacity: .3; filter: grayscale(1); }

/* 自己：实心绿点 + 白边，跟队友的空心琥珀形状刻意区分开 */
/* 宽高必须写死：精度圈用 left:50%/top:50% 定位，父元素没有尺寸的话 50% 就无从算起 */
.me { position: relative; width: 16px; height: 16px; }
.me .dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--self);
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .6);
}
.me .ring {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(34, 197, 94, .5);
  pointer-events: none;
}

/* 左下/右下那一整条控制区（缩放按钮 + 署名）默认贴着底边，会被折叠状态的设置面板
 * 压住。整条抬到面板上沿之上。 */
.leaflet-bottom { bottom: calc(46px + var(--safe-b)); }

/* 瓦片署名/缩放的默认样式太亮，压一压 */
.leaflet-control-attribution {
  background: rgba(14, 17, 22, .7) !important;
  color: var(--fg-dim) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--fg-dim) !important; }
.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--fg) !important;
  border-color: var(--line) !important;
}
