:root {
  --bg-void: #0a0d10;
  --bg-panel: rgba(18, 23, 28, 0.92);
  --bg-panel-2: rgba(26, 33, 40, 0.95);
  --line: #263038;
  --text: #e8edf0;
  --muted: #6b7680;
  --cyan: #3df5c0;
  --amber: #f5a623;
  --magenta: #ff3d8a;
  --blue: #4d9fff;
  --danger: #ff4d4d;
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg-void); color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}

#map { position: absolute; inset: 0; z-index: 1; filter: saturate(0.35) brightness(0.55) contrast(1.15); }

/* ---------------- Boot screen ---------------- */
#boot-screen {
  position: fixed; inset: 0; z-index: 999;
  background: radial-gradient(ellipse at center, #10161b 0%, #05070a 100%);
  display: flex; align-items: center; justify-content: center;
}
.boot-inner { text-align: center; width: min(90vw, 380px); }
.boot-logo {
  font-family: var(--mono); font-weight: 700; font-size: 3rem; letter-spacing: 0.35em;
  color: var(--cyan); text-shadow: 0 0 24px rgba(61,245,192,0.5);
}
.boot-sub { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 2rem; letter-spacing: 0.05em; }
#join-form { display: flex; flex-direction: column; gap: 0.9rem; }
#username-input, #chat-input, #graffiti-message {
  background: #12171c; border: 1px solid var(--line); color: var(--text);
  padding: 0.8rem 1rem; font-family: var(--sans); font-size: 0.95rem; border-radius: 3px;
  outline: none;
}
#username-input:focus { border-color: var(--cyan); }
.color-row { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
  transition: transform 0.15s;
}
.swatch.selected { border-color: #fff; transform: scale(1.15); }
#join-form button, .panel-actions button, #btn-place-graffiti {
  background: var(--cyan); color: #06110d; border: none; padding: 0.85rem;
  font-family: var(--mono); font-weight: 700; letter-spacing: 0.08em; font-size: 0.85rem;
  border-radius: 3px; cursor: pointer; transition: filter 0.15s;
}
#join-form button:hover, .panel-actions button:hover { filter: brightness(1.15); }
.boot-note { color: var(--muted); font-size: 0.7rem; margin-top: 1.2rem; line-height: 1.4; }

.auth-tabs { display: flex; gap: 4px; margin-bottom: 1rem; background: #0d1216; border-radius: 4px; padding: 4px; }
.auth-tab {
  flex: 1; background: none; border: none; color: var(--muted); padding: 8px;
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; cursor: pointer; border-radius: 3px;
}
.auth-tab.active { background: rgba(61,245,192,0.12); color: var(--cyan); }
.auth-form { display: flex; flex-direction: column; gap: 0.9rem; }
.auth-error {
  color: var(--danger); font-size: 0.75rem; background: rgba(255,77,77,0.1);
  border: 1px solid rgba(255,77,77,0.3); padding: 6px 10px; border-radius: 3px;
}
#alliance-list li { display: flex; justify-content: space-between; font-size: 0.78rem; padding: 6px 0; border-bottom: 1px dashed var(--line); list-style: none; margin: 0; }
#alliance-list { padding: 0; margin: 8px 0 0; }
#alliance-list button { font-family: var(--mono); font-size: 0.65rem; background: var(--cyan); border: none; color: #06110d; padding: 3px 8px; border-radius: 3px; cursor: pointer; }

/* ---------------- HUD shared ---------------- */
.hud {
  position: absolute; z-index: 500;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  border-radius: 4px;
}
.corner { position: absolute; width: 10px; height: 10px; border-color: var(--cyan); border-style: solid; opacity: 0.8; }
.corner.tl { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.corner.tr { top: -1px; right: -1px; border-width: 2px 2px 0 0; }
.corner.bl { bottom: -1px; left: -1px; border-width: 0 0 2px 2px; }
.corner.br { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

/* ---------------- Player capsule ---------------- */
.hud-player {
  top: 16px; left: 16px; padding: 10px 16px;
  font-family: var(--mono); font-size: 0.8rem;
}
.player-row { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: 0.04em; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px currentColor; }
.player-stats { margin-top: 6px; display: flex; gap: 14px; color: var(--muted); font-size: 0.75rem; }
.player-stats b { color: var(--text); }

/* ---------------- Leaderboard ---------------- */
.hud-leaderboard-toggle {
  position: absolute; top: 16px; right: 16px; z-index: 500;
  background: var(--bg-panel); border: 1px solid var(--line); color: var(--text);
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em;
  padding: 10px 14px; border-radius: 4px; cursor: pointer;
}
.hud-leaderboard {
  top: 60px; right: 16px; width: 240px; max-height: 50vh; overflow-y: auto;
  padding: 12px 14px 14px;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 0.78rem; letter-spacing: 0.06em;
  padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}
.panel-head button { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
#leaderboard-list { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
#leaderboard-list li {
  counter-increment: rank; display: flex; justify-content: space-between;
  font-size: 0.8rem; padding: 5px 0; border-bottom: 1px dashed var(--line);
}
#leaderboard-list li::before { content: counter(rank) "."; color: var(--muted); margin-right: 6px; }

/* ---------------- Side panels ---------------- */
.side-panel {
  top: 16px; left: 50%; transform: translateX(-50%);
  width: min(92vw, 340px); max-height: 62vh; overflow-y: auto;
  padding: 12px 16px 16px;
}
@media (min-width: 700px) {
  .side-panel { left: 16px; transform: none; top: 90px; }
}
.accent-territory { color: var(--cyan); }
.accent-hunter { color: var(--amber); }
.accent-graffiti { color: var(--magenta); }
.accent-social { color: var(--blue); }

.panel-hint { font-size: 0.8rem; color: var(--muted); line-height: 1.4; margin: 0 0 10px; }
.panel-actions button, #btn-place-graffiti { width: 100%; }
.selected-box {
  margin-top: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 3px;
  font-size: 0.78rem; color: var(--text);
}
.panel-divider { height: 1px; background: var(--line); margin: 12px 0; }
.panel-subhead { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }

.style-row, .color-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.style-chip {
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 3px; font-size: 0.72rem;
  cursor: pointer; color: var(--muted); font-family: var(--mono);
}
.style-chip.selected { color: var(--text); border-color: var(--magenta); background: rgba(255,61,138,0.1); }

#graffiti-message { width: 100%; margin-bottom: 10px; }
#graffiti-trending, #nearby-players { list-style: none; margin: 0; padding: 0; }
#graffiti-trending li, #nearby-players li {
  font-size: 0.78rem; padding: 6px 0; border-bottom: 1px dashed var(--line);
  display: flex; justify-content: space-between; gap: 8px;
}

/* ---------------- Chat ---------------- */
#chat-log { height: 200px; overflow-y: auto; margin-bottom: 8px; font-size: 0.8rem; }
#chat-log .msg { padding: 4px 0; border-bottom: 1px dashed var(--line); line-height: 1.35; }
#chat-log .msg .who { color: var(--blue); font-weight: 600; }
#chat-log .msg .far { opacity: 0.45; }
#chat-form { display: flex; gap: 6px; }
#chat-form input { flex: 1; }
#chat-form button {
  background: var(--blue); border: none; color: #06121f; width: 40px; border-radius: 3px; cursor: pointer;
  font-size: 1rem;
}

/* ---------------- Bottom dock ---------------- */
.dock {
  bottom: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; padding: 6px;
}
.dock-btn {
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 16px; border-radius: 3px; font-family: var(--mono);
  transition: background 0.15s, color 0.15s;
}
.dock-icon { font-size: 1.15rem; }
.dock-label { font-size: 0.62rem; letter-spacing: 0.05em; }
.dock-btn.active { background: rgba(255,255,255,0.06); color: var(--text); }
.dock-btn.accent-territory.active { color: var(--cyan); }
.dock-btn.accent-hunter.active { color: var(--amber); }
.dock-btn.accent-graffiti.active { color: var(--magenta); }
.dock-btn.accent-social.active { color: var(--blue); }

/* ---------------- Toasts ---------------- */
#toast-stack {
  position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  z-index: 600; display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--bg-panel-2); border: 1px solid var(--line); padding: 8px 14px;
  border-radius: 3px; font-family: var(--mono); font-size: 0.75rem;
  animation: toast-in 0.2s ease-out, toast-out 0.3s ease-in 2.7s forwards;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* ---------------- Map markers ---------------- */
.self-marker {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--cyan); border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(61,245,192,0.6);
  animation: radar-pulse 2s infinite;
}
@keyframes radar-pulse {
  0% { box-shadow: 0 0 0 0 rgba(61,245,192,0.55); }
  70% { box-shadow: 0 0 0 22px rgba(61,245,192,0); }
  100% { box-shadow: 0 0 0 0 rgba(61,245,192,0); }
}
.player-marker { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; }
.chest-marker { font-size: 20px; filter: drop-shadow(0 0 4px rgba(245,166,35,0.8)); }
.chest-marker.claimed { opacity: 0.25; filter: grayscale(1); }
.graffiti-marker { font-size: 18px; filter: drop-shadow(0 0 4px currentColor); }
.territory-circle-label {
  font-family: var(--mono); font-size: 0.65rem; color: #fff; text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.leaflet-popup-content-wrapper {
  background: var(--bg-panel-2); color: var(--text); border: 1px solid var(--line);
  font-family: var(--sans); border-radius: 4px;
}
.leaflet-popup-tip { background: var(--bg-panel-2); }
.leaflet-popup-content button {
  margin-top: 6px; background: var(--cyan); border: none; color: #06110d;
  padding: 6px 10px; border-radius: 3px; font-family: var(--mono); font-size: 0.72rem;
  cursor: pointer; font-weight: 700;
}
.leaflet-popup-content .popup-danger { background: var(--danger); color: #fff; }
.leaflet-control-attribution { background: rgba(10,13,16,0.7) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
