* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; }
body { overflow: hidden; background: #0f172a; }

#header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: rgba(15, 23, 42, .92); backdrop-filter: blur(8px);
  color: #fff; border-bottom: 1px solid rgba(255,255,255,.08);
}
#header .title { font-size: 17px; font-weight: 700; letter-spacing: .5px; }
#header .title em { color: #fbbf24; font-style: normal; }
#stats { font-size: 13px; color: #cbd5e1; }
#stats b { color: #fff; }

#map { position: absolute; inset: 0; top: 46px; background: #dbeafe; }

#joinBtn {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 1100;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff; font-size: 17px; font-weight: 700;
  padding: 14px 40px; border-radius: 999px; border: none;
  cursor: pointer; box-shadow: 0 8px 24px rgba(239, 68, 68, .45);
  transition: transform .15s, box-shadow .15s;
  letter-spacing: 2px;
}
#joinBtn:hover { transform: translateX(-50%) scale(1.05); box-shadow: 0 10px 30px rgba(239,68,68,.6); }
#joinBtn:active { transform: translateX(-50%) scale(.97); }

/* 昵称弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5); backdrop-filter: blur(3px);
}
.modal-box {
  width: min(92vw, 360px); background: #fff; border-radius: 16px;
  padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-box h3 { font-size: 18px; margin-bottom: 8px; }
.modal-box .hint { font-size: 13px; color: #64748b; margin-bottom: 14px; line-height: 1.5; }
.modal-box input {
  width: 100%; padding: 10px 12px; font-size: 15px;
  border: 1.5px solid #e2e8f0; border-radius: 10px; outline: none;
  transition: border-color .15s;
}
.modal-box input:focus { border-color: #f59e0b; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  flex: 1; padding: 10px 0; border-radius: 10px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn.ghost { background: #f1f5f9; color: #334155; }
.btn.primary { background: linear-gradient(135deg, #f59e0b, #ef4444); color: #fff; }

/* 定位中 */
.locating {
  position: fixed; left: 50%; top: 60px; transform: translateX(-50%);
  z-index: 1150; background: #1e293b; color: #fff;
  padding: 10px 20px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.locating::before {
  content: ''; display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; background: #4ade80; margin-right: 8px;
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: .2; } }

/* toast */
#toast {
  position: fixed; left: 50%; top: 60px; transform: translateX(-50%);
  z-index: 1300; background: #1e293b; color: #fff;
  padding: 10px 18px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,.35); max-width: 86vw; text-align: center;
}
#toast.error { background: #dc2626; }
#toast.success { background: #16a34a; }

.hidden { display: none !important; }

/* 自定义标记 */
.marker-pin {
  display: flex; flex-direction: column; align-items: center;
  transform: translate(-50%, -100%);
}
.marker-pin .dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: #3b82f6; border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.marker-pin .name {
  background: rgba(15, 23, 42, .85); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  white-space: nowrap; margin-bottom: 3px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.marker-pin.me .dot { background: #f59e0b; border-color: #fff; box-shadow: 0 0 0 6px rgba(245,158,11,.35); }
.marker-pin.me .name { background: linear-gradient(135deg, #f59e0b, #ef4444); font-weight: 700; }
.marker-pin.offline .dot { background: #94a3b8; }
.marker-pin.offline .name { background: rgba(100,116,139,.8); }

.leaflet-popup-content { font-size: 13px; line-height: 1.6; }
.leaflet-popup-content .p-name { font-weight: 700; font-size: 15px; }
.leaflet-popup-content .p-tag { display:inline-block; font-size:11px; padding:1px 6px; border-radius:999px; margin-left:6px; }
.leaflet-popup-content .p-tag.gps { background:#dbeafe; color:#1d4ed8; }
.leaflet-popup-content .p-tag.ip { background:#fef3c7; color:#b45309; }
.leaflet-popup-content .p-online { color:#16a34a; font-weight:600; }
.leaflet-popup-content .p-offline { color:#94a3b8; }

#tileSwitch {
  position: fixed; right: 14px; bottom: 34px; z-index: 1100;
  background: #fff; border: none; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: #334155;
  cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
