* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #14161c;
  --panel: #1c1f28;
  --panel2: #242836;
  --text: #e8eaf0;
  --muted: #8a90a0;
  --accent: #4fc3f7;
  --green: #5ad26f;
  --red: #f06060;
}

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid #000;
  overflow-y: auto;
}

#sidebar header {
  padding: 16px;
  border-bottom: 1px solid #00000055;
}

#sidebar h1 {
  font-size: 20px;
  letter-spacing: 0.5px;
}
#sidebar h1 span { color: var(--accent); font-weight: 300; }

.status {
  margin-top: 8px;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 10px;
  display: inline-block;
}
.status.online { background: #1d3a24; color: var(--green); }
.status.offline { background: #3a1d1d; color: var(--red); }

#whoami {
  width: 100%;
  margin-top: 10px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid #00000088;
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
#whoami:focus { border-color: var(--accent); }

#me-section { background: #1a2230; }
.prog-block { margin-top: 6px; }
.prog-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  font-size: 12px;
}
.prog-label { flex-shrink: 0; width: 110px; }
.prog-bar {
  flex: 1;
  height: 7px;
  background: #10131a;
  border-radius: 4px;
  overflow: hidden;
}
.prog-bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #5ad26f);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.prog-val { color: var(--muted); flex-shrink: 0; font-size: 11px; }
.me-online { color: var(--green); font-weight: 600; }
#me-content a { color: var(--accent); text-decoration: none; }
#me-content a:hover { text-decoration: underline; }

/* Joueurs hors ligne */
.offline-icon .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid #666;
  background: #444;
  position: absolute;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}
.offline-icon .label {
  position: absolute;
  transform: translate(-50%, 10px);
  white-space: nowrap;
  font-size: 11px;
  color: #999;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

#sidebar section {
  padding: 12px 16px;
  border-bottom: 1px solid #00000055;
}

#sidebar h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Sections repliables */
.sec-head {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 2px 0;
}
.sec-head:hover { color: var(--text); }
.sec-head .chev {
  margin-left: auto;
  transition: transform 0.2s ease;
  font-size: 11px;
}
section.closed .chev { transform: rotate(-90deg); }
section.closed > *:not(h2) { display: none; }
section.closed h2 { margin-bottom: 0; }

.badge {
  background: var(--accent);
  color: #10222c;
  border-radius: 9px;
  padding: 1px 8px;
  font-size: 12px;
  vertical-align: middle;
}

.details { font-size: 13px; line-height: 1.7; }
.details .k { color: var(--muted); }

#players-section { flex: none; }

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.player-row:hover { background: var(--panel2); }
.player-row.following { background: #1d2e3a; outline: 1px solid var(--accent); }

.player-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

.row-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #fff;
  flex-shrink: 0;
  object-fit: cover;
  background: #222;
}

.player-meta { flex: 1; min-width: 0; }
.player-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { color: var(--muted); font-size: 11px; }

.follow-btn {
  background: none;
  border: 1px solid var(--muted);
  color: var(--muted);
  border-radius: 6px;
  font-size: 11px;
  padding: 2px 7px;
  cursor: pointer;
}
.follow-btn:hover, .player-row.following .follow-btn {
  border-color: var(--accent);
  color: var(--accent);
}

/* Graphique historique */
#history-chart {
  width: 100%;
  height: 64px;
  margin-top: 10px;
  background: #10131a;
  border-radius: 8px;
}

/* Recherche collectables */
#search {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  border: 1px solid #00000088;
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#search:focus { border-color: var(--accent); }
.search-hit {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 6px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
}
.search-hit:hover { background: var(--panel2); }

/* Collectables */
.cat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.cat-row:hover { background: var(--panel2); border-radius: 6px; }
.cat-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid #00000066;
  flex-shrink: 0;
}
.cat-label { flex: 1; }
.cat-count { color: var(--muted); font-size: 11px; }
.cat-icon { width: 18px; height: 18px; flex-shrink: 0; }

.collectible-icon {
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.8));
}

/* Activité */
.act-row { font-size: 12px; padding: 2px 0; }
.today-title { font-size: 12px; color: var(--accent); margin-bottom: 3px; font-weight: 600; }
.today-row { font-size: 12px; padding: 1px 0; }
#today-list:not(:empty) { margin-bottom: 10px; }

/* Zone de chasse */
#hunt-row { margin: 6px 0 8px; font-size: 12px; color: var(--muted); }
#hunt {
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid #00000088;
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#hunt:focus { border-color: #ff9800; }

/* Filtre rayon */
#nearby-row { margin: 6px 0 8px; font-size: 12px; color: var(--muted); }
#nearby-row select {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid #00000088;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}
.act-time { color: var(--muted); font-size: 11px; }
.act-join { color: var(--green); }
.act-leave { color: var(--red); }

#sidebar footer {
  padding: 12px 16px;
  font-size: 12px;
}
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.muted { color: var(--muted); margin-top: 6px; }

.empty { color: var(--muted); font-size: 13px; padding: 8px; }

/* ---------- Map ---------- */
#map { flex: 1; background: #10131a; }

.leaflet-container { background: #10131a; }

.player-icon .dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 10px 2px rgba(0,0,0,0.6);
  transform: translate(-50%, -50%);
  position: absolute;
}
.player-icon .heading {
  position: absolute;
  width: 54px;
  height: 54px;
  pointer-events: none;
  transition: transform 0.4s ease;
}
.player-icon .heading .tip {
  position: absolute;
  left: 50%;
  top: 2px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 11px solid #fff;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.7));
}

.player-icon .face {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  position: absolute;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px 2px rgba(0,0,0,0.6);
  object-fit: cover;
  background: #222;
}
.player-icon .label {
  position: absolute;
  transform: translate(-50%, 18px);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
  pointer-events: none;
}

.grid-label {
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  white-space: nowrap;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel2);
  color: var(--text);
}
.leaflet-popup-content { font-size: 13px; line-height: 1.6; }
.leaflet-popup-content b { color: var(--accent); }

/* Poignée du tiroir (mobile uniquement) */
#drawer-handle { display: none; }

/* Chat */
.chat-warning {
  background: #3a2d10;
  border: 1px solid #6e5a1e;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 8px;
  color: #e8d48a;
}
#chat-auth input, #chat-text {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 8px;
  border: 1px solid #00000088;
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#chat-auth input:focus, #chat-text:focus { border-color: var(--accent); }
.chat-btns { display: flex; gap: 6px; }
.chat-btns button, #chat-send {
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #10222c;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}
.chat-btns button:hover, #chat-send:hover { filter: brightness(1.1); }
#chat-register { background: var(--green); }
#chat-auth-msg { font-size: 12px; margin-top: 6px; min-height: 15px; }

#chat-messages {
  max-height: 220px;
  overflow-y: auto;
  background: #10131a;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.chat-msg { padding: 1px 0; word-wrap: break-word; }
.chat-msg .chat-author { font-weight: 700; }
.chat-msg .chat-time { color: var(--muted); font-size: 10px; margin-right: 4px; }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input { margin-bottom: 0; flex: 1; }
#chat-section a { color: var(--accent); }

/* Panneau Palbox */
#palbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#palbox-overlay[hidden] { display: none; }
.pb-card {
  background: var(--panel);
  border-radius: 14px;
  width: 100%;
  max-width: 420px;
  max-height: 80vh;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 50px rgba(0,0,0,0.6);
}
.pb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #00000055;
}
.pb-head h3 { font-size: 16px; }
#pb-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
#pb-close:hover { color: var(--text); }
#pb-content { overflow-y: auto; padding: 10px 16px; }
#pb-content h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  margin: 10px 0 6px;
}
.pb-pal {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 8px;
  font-size: 13px;
  border-radius: 6px;
}
.pb-pal:nth-child(odd) { background: var(--panel2); }
.pb-lvl { color: var(--muted); white-space: nowrap; }
#pb-footer { padding: 10px 16px; font-size: 11px; border-top: 1px solid #00000055; }

.palbox-link { color: var(--accent); text-decoration: none; }
.palbox-link:hover { text-decoration: underline; }

/* Mobile : carte plein écran + tiroir coulissant depuis le bas */
@media (max-width: 700px) {
  #map {
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh;
  }

  #sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1000;
    width: 100%;
    min-width: 0;
    max-height: 78vh;
    max-height: 78dvh;
    border-right: none;
    border-top: 1px solid #000;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.5);
    transform: translateY(calc(100% - 58px));
    transition: transform 0.25s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom);
  }
  #sidebar.open { transform: translateY(0); }

  #drawer-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 9px 16px 11px;
    height: 58px;
    cursor: pointer;
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 2;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  #drawer-handle .grip {
    width: 42px; height: 4px;
    border-radius: 2px;
    background: var(--muted);
    opacity: 0.6;
  }
  #drawer-summary { font-size: 14px; font-weight: 600; }

  #sidebar header { padding: 4px 16px 12px; }

  /* Cibles tactiles plus grandes */
  .sec-head { padding: 10px 0; font-size: 14px; }
  .sec-head .chev { font-size: 13px; }
  #sidebar section { padding: 6px 16px; }
  .player-row { padding: 11px 10px; font-size: 14px; }
  .follow-btn { padding: 7px 13px; font-size: 13px; }
  .cat-row { padding: 9px 4px; font-size: 14px; }
  .cat-row input { width: 18px; height: 18px; }

  #players-section { flex: none; overflow-y: visible; }

  .leaflet-control-zoom a {
    width: 38px !important;
    height: 38px !important;
    line-height: 38px !important;
    font-size: 20px !important;
  }
}
