:root {
  --accent: #1f6feb;
  --bg-panel: rgba(255, 255, 255, 0.97);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: #1a1a1a;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #e8eaed;
}

.hidden { display: none !important; }

.panel {
  position: absolute;
  z-index: 1000;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
}

/* ----- Man hinh nhap (setup) ----- */
.setup-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 380px);
  padding: 24px 22px;
  text-align: left;
}
.setup-panel h1 {
  margin: 0 0 18px;
  font-size: 1.5rem;
  text-align: center;
  color: var(--accent);
}
.setup-panel label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 12px 0 6px;
  color: #555;
}
.setup-panel input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  border: 1.5px solid #d0d4d9;
  border-radius: 10px;
  outline: none;
}
.setup-panel input:focus { border-color: var(--accent); }
.setup-panel button {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.setup-panel button:active { transform: scale(0.98); }
.hint { font-size: 0.8rem; color: #777; margin: 14px 0 0; }

/* ----- HUD khi dang chia se ----- */
.hud-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
}
.hud-row { display: flex; align-items: center; gap: 10px; }
.me-avatar { width: 40px; height: 40px; flex: none; }
.me-avatar img { width: 100%; height: 100%; }
.hud-info { flex: 1; min-width: 0; }
.me-name { font-weight: 700; font-size: 0.95rem; }
.status { font-size: 0.78rem; color: #777; }
.status.ok { color: #1a8a3a; }
.status.err { color: #c0392b; }

#recenterBtn {
  flex: none;
  width: 40px; height: 40px;
  font-size: 1.4rem;
  border: 1.5px solid #d0d4d9;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
}

.hud-share { gap: 8px; }
#shareLink {
  flex: 1; min-width: 0;
  padding: 9px 10px;
  font-size: 0.82rem;
  border: 1.5px solid #d0d4d9;
  border-radius: 8px;
  background: #f6f7f9;
}
#copyBtn, .stop-btn {
  padding: 9px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
#copyBtn { background: var(--accent); color: #fff; }
.stop-btn { background: #fde8e8; color: #c0392b; }

.peers-box { font-size: 0.85rem; }
.peers-box summary { cursor: pointer; font-weight: 600; color: #555; }
#peerList { list-style: none; margin: 8px 0 0; padding: 0; }
#peerList li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0;
}
#peerList li img { width: 26px; height: 26px; }
#peerList li .peer-name {
  cursor: pointer;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#peerList li .peer-name:hover { color: var(--accent); text-decoration: underline; }
#peerList li .off { color: #aaa; font-size: 0.75rem; margin-left: auto; }

/* ----- Responsive ----- */
/* Mobile: HUD bam day man hinh, full chieu ngang */
@media (max-width: 640px) {
  .hud-panel {
    left: 8px; right: 8px; bottom: 8px;
    border-radius: 16px;
  }
}
/* Desktop: HUD dang sidebar goc tren ben trai */
@media (min-width: 641px) {
  .hud-panel {
    top: 16px; left: 16px;
    width: 340px;
  }
}

/* Marker label (ten nho duoi avatar tren ban do) */
.peer-marker { background: none; border: none; }
.peer-marker .cap {
  margin-top: 2px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #222;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff;
  white-space: nowrap;
}
