/* ============================================================================
   Palworld Live Map — refonte visuelle (PC + mobile)
   Tous les sélecteurs fonctionnels sont conservés : seul le style change.
   ========================================================================== */

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

:root {
  --bg: #0b0e15;
  --bg2: #0e1220;
  --panel: #151a26;
  --panel2: #1d2433;
  --panel3: #242c3f;
  --line: rgba(255, 255, 255, 0.07);
  --text: #edf1f7;
  --muted: #8b94a7;
  --accent: #4fc3f7;
  --accent-soft: rgba(79, 195, 247, 0.14);
  --gold: #e8b93b;
  --green: #55d97a;
  --red: #f06868;
  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 800px at 85% -10%, #14203a 0%, var(--bg) 55%) fixed;
  color: var(--text);
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Ascenseurs discrets partout */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--panel3);
  border-radius: 8px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #33405c; }

/* ============================== SIDEBAR ================================== */

#sidebar {
  width: 318px;
  min-width: 318px;
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  gap: 8px;
  padding-bottom: 6px;
}

#sidebar header {
  padding: 18px 16px 10px;
  position: relative;
}

#sidebar h1 {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.4px;
}
#sidebar h1 span {
  font-weight: 300;
  background: linear-gradient(90deg, var(--accent), #7ee0ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.status {
  margin-top: 9px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  padding: 4px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}
.status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.status.online { background: rgba(85, 217, 122, 0.12); color: var(--green); }
.status.offline { background: rgba(240, 104, 104, 0.12); color: var(--red); }

#whoami {
  width: 100%;
  margin-top: 12px;
  padding: 9px 11px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
#whoami:hover, #whoami:focus { border-color: var(--accent); }

/* Sections = cartes flottantes */
#sidebar section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 0 10px;
  padding: 12px 14px;
}

#sidebar h2 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--muted);
  margin-bottom: 9px;
  font-weight: 700;
}

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

.badge {
  background: var(--accent);
  color: #0a1b26;
  border-radius: 10px;
  padding: 1px 9px;
  font-size: 11px;
  font-weight: 800;
  vertical-align: middle;
  letter-spacing: 0;
}

.details { font-size: 13px; line-height: 1.75; }
.details .k { color: var(--muted); }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 13px; padding: 8px 2px; }

/* ---- Mon profil ---- */
#me-section {
  background: linear-gradient(160deg, #17233a, var(--panel));
  border-color: rgba(79, 195, 247, 0.22);
}
.me-online { color: var(--green); font-weight: 700; }
#me-content a { color: var(--accent); text-decoration: none; }
#me-content a:hover { text-decoration: underline; }

.prog-block { margin-top: 8px; }

/* Détail des tours dans le profil */
.tower-details { margin: 4px 0; font-size: 12px; }
.tower-details summary {
  cursor: pointer;
  padding: 2.5px 0;
  color: var(--text);
  list-style: none;
}
.tower-details summary::-webkit-details-marker { display: none; }
.tower-details summary::after { content: ' ▾'; color: var(--muted); }
.tower-details[open] summary::after { content: ' ▴'; }
.tower-row {
  padding: 2px 0 2px 14px;
  color: var(--muted);
  font-size: 11.5px;
}
.tower-row.ok { color: var(--text); }
.prog-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2.5px 0;
  font-size: 12px;
}
.prog-label { flex-shrink: 0; width: 112px; }
.prog-bar {
  flex: 1;
  height: 7px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  overflow: hidden;
}
.prog-bar div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 4px;
  transition: width 0.5s ease;
  box-shadow: 0 0 6px rgba(79, 195, 247, 0.5);
}
.prog-val { color: var(--muted); flex-shrink: 0; font-size: 11px; }

#me-chart, #history-chart {
  width: 100%;
  height: 64px;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
}

/* ---- Joueurs ---- */
.player-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 9px;
  border-radius: var(--radius-s);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.13s, transform 0.13s;
}
.player-row:hover { background: var(--panel2); transform: translateX(2px); }
.player-row.following {
  background: var(--accent-soft);
  outline: 1px solid rgba(79, 195, 247, 0.45);
}

.player-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}
.row-avatar {
  width: 28px; height: 28px;
  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: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-sub { color: var(--muted); font-size: 11px; line-height: 1.5; }

.follow-btn {
  background: transparent;
  border: 1px solid var(--panel3);
  color: var(--muted);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s;
}
.follow-btn:hover, .player-row.following .follow-btn {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---- Classements ---- */
.rank-block {
  border-radius: var(--radius-s);
  transition: background 0.15s;
}
.rank-block[open] { background: rgba(0, 0, 0, 0.22); }
.rank-block summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  padding: 6px 7px;
  list-style: none;
  user-select: none;
  border-radius: var(--radius-s);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.13s;
}
.rank-block summary::-webkit-details-marker { display: none; }
.rank-block summary::before { content: '▸ '; color: var(--muted); }
.rank-block[open] summary::before { content: '▾ '; }
.rank-block summary:hover { background: var(--panel2); }
.rank-body { padding: 0 8px 8px 20px; }

.today-title { font-size: 12px; color: var(--gold); margin-bottom: 3px; font-weight: 700; }
.today-row { font-size: 12px; padding: 1.5px 0; }
#today-list:not(:empty) { margin-bottom: 10px; }

#compare-open { color: var(--accent); text-decoration: none; font-size: 12px; font-weight: 600; }
#compare-open:hover { text-decoration: underline; }

/* ---- Collectables ---- */
#search, #hunt {
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 7px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#hunt { margin-top: 4px; margin-bottom: 0; }
#hunt:focus { border-color: #ff9800; box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.15); }

.search-hit {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 7px;
  cursor: pointer;
}
.search-hit:hover { background: var(--panel2); }

#hunt-row, #nearby-row { margin: 8px 0; font-size: 12px; color: var(--muted); }
#nearby-row select, #replay-bar select {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 7px;
  font-size: 12px;
  outline: none;
}

.cat-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 7px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  border-radius: 7px;
  transition: background 0.13s;
}
.cat-row:hover { background: var(--panel2); }
.cat-row input { accent-color: var(--accent); }
.cat-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
}
.cat-icon { width: 19px; height: 19px; flex-shrink: 0; }
.cat-label { flex: 1; }
.cat-count { color: var(--muted); font-size: 11px; }

/* ---- Chat ---- */
.chat-warning {
  background: linear-gradient(160deg, #3a2d10, #2e2410);
  border: 1px solid rgba(232, 185, 59, 0.35);
  border-radius: var(--radius-s);
  padding: 9px 11px;
  font-size: 12px;
  line-height: 1.55;
  margin-bottom: 9px;
  color: #ecd58c;
}
#chat-auth input, #chat-text {
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 7px;
  border-radius: var(--radius-s);
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
#chat-auth input:focus, #chat-text:focus { border-color: var(--accent); }
.chat-btns { display: flex; gap: 7px; }
.chat-btns button, #chat-send {
  padding: 9px 13px;
  border: none;
  border-radius: var(--radius-s);
  background: linear-gradient(160deg, var(--accent), #2fa8e0);
  color: #06202e;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.chat-btns button:hover, #chat-send:hover { filter: brightness(1.12); }
.chat-btns button:active, #chat-send:active { transform: scale(0.97); }
#chat-register { background: linear-gradient(160deg, var(--green), #37b25e); }
#chat-auth-msg { font-size: 12px; margin-top: 6px; min-height: 15px; }

#chat-messages {
  max-height: 230px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 9px 10px;
  margin-bottom: 7px;
  font-size: 13px;
  line-height: 1.55;
}
.chat-msg { padding: 1.5px 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: 7px; }
.chat-input-row input { margin-bottom: 0; flex: 1; }
#chat-section a { color: var(--accent); }

/* ---- Activité ---- */
.act-row { font-size: 12px; padding: 2.5px 0; }
.act-time { color: var(--muted); font-size: 10px; }
.act-join { color: var(--green); }
.act-leave { color: var(--red); }
.act-record { color: var(--gold); }

/* ---- Pied de la barre ---- */
#sidebar footer {
  padding: 4px 18px 12px;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  color: var(--muted);
  transition: color 0.13s;
}
.toggle:hover { color: var(--text); }
.toggle input { accent-color: var(--accent); }
#last-update { color: var(--muted); font-size: 11px; margin-top: 3px; }

/* ================================ CARTE ================================== */

#map { flex: 1; background: #0a1220; }
.leaflet-container { background: #0a1220; font-family: inherit; }

.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
  width: 34px !important;
  height: 32px !important;
  line-height: 32px !important;
  font-size: 16px !important;
}
.leaflet-control-zoom a:first-child { border-radius: 10px 10px 0 0 !important; }
.leaflet-control-zoom a:last-child { border-radius: 0 0 10px 10px !important; }
.leaflet-control-zoom a:hover { background: var(--panel2) !important; color: var(--accent) !important; }

/* Marqueurs joueurs */
.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 12px 3px rgba(0, 0, 0, 0.6);
  object-fit: cover;
  background: #222;
}
.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 .label {
  position: absolute;
  transform: translate(-50%, 18px);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px #000, 0 0 7px #000;
  pointer-events: none;
}

.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;
}

.guild-icon .flag {
  position: absolute;
  transform: translate(-50%, -60%);
  font-size: 22px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.8));
}
.guild-icon .label {
  position: absolute;
  transform: translate(-50%, 8px);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 3px #000, 0 0 7px #000;
  pointer-events: none;
}

.admin-marker .pin {
  position: absolute;
  transform: translate(-50%, -80%);
  font-size: 26px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.85));
  animation: pin-bounce 2.2s ease-in-out infinite;
}
@keyframes pin-bounce {
  0%, 100% { transform: translate(-50%, -80%); }
  50% { transform: translate(-50%, -95%); }
}
.admin-marker .label {
  position: absolute;
  transform: translate(-50%, 6px);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 8px;
  border-radius: 8px;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.replay-ghost .dot {
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 2px solid #fff;
  position: absolute;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}
.replay-ghost .label {
  position: absolute;
  transform: translate(-50%, 9px);
  white-space: nowrap;
  font-size: 11px;
  color: #ddd;
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
}

.collectible-icon { filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8)); }
.grid-label { color: rgba(255, 255, 255, 0.35); font-size: 11px; white-space: nowrap; }

/* Popups Leaflet */
.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { font-size: 13px; line-height: 1.65; margin: 12px 16px; }
.leaflet-popup-content b { color: var(--accent); }
.palbox-link { color: var(--accent); text-decoration: none; }
.palbox-link:hover { text-decoration: underline; }
a.leaflet-popup-close-button { color: var(--muted) !important; }

/* Horloge du monde */
.world-clock {
  background: rgba(21, 26, 38, 0.9);
  backdrop-filter: blur(6px);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.4px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  pointer-events: none;
}

/* Mini-toast */
#mini-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-size: 13px;
  z-index: 3000;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  max-width: 90vw;
}
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Barre de replay */
#replay-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 11px;
  background: rgba(21, 26, 38, 0.94);
  backdrop-filter: blur(8px);
  padding: 11px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  z-index: 2500;
  box-shadow: var(--shadow);
}
#replay-bar[hidden] { display: none; }
#replay-play {
  background: linear-gradient(160deg, var(--accent), #2fa8e0);
  border: none;
  border-radius: var(--radius-s);
  width: 36px; height: 32px;
  font-size: 14px;
  cursor: pointer;
  color: #06202e;
}
#replay-slider { width: 220px; accent-color: var(--accent); }
#replay-time { font-size: 13px; font-weight: 700; min-width: 44px; }

/* ============================ SUPERPOSITIONS ============================= */

#palbox-overlay, #compare-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.72);
  backdrop-filter: blur(3px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#palbox-overlay[hidden], #compare-overlay[hidden] { display: none; }

.pb-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  width: 100%;
  max-width: 430px;
  max-height: 82vh;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
  animation: card-in 0.22s ease;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.pb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.pb-head h3 { font-size: 16px; font-weight: 800; }
#pb-close, #compare-close {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 30px; height: 30px;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
#pb-close:hover, #compare-close:hover { color: var(--text); border-color: var(--accent); }
#pb-content { overflow-y: auto; padding: 10px 18px; }
#pb-content h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--accent);
  margin: 12px 0 6px;
  font-weight: 800;
}
.pb-pal {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5.5px 9px;
  font-size: 13px;
  border-radius: 7px;
}
.pb-pal:nth-child(odd) { background: rgba(0, 0, 0, 0.25); }
.pb-lvl { color: var(--muted); white-space: nowrap; }
#pb-footer { padding: 10px 18px; font-size: 11px; border-top: 1px solid var(--line); color: var(--muted); }

#compare-overlay select {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 8px;
  font-size: 13px;
  outline: none;
}
#compare-content { padding: 12px 18px 18px; overflow-y: auto; }
.cmp-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  padding: 7px 4px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.cmp-row span:first-child { text-align: right; }
.cmp-label { color: var(--muted); font-size: 12px; min-width: 112px; text-align: center; }
.cmp-win { color: var(--green); font-weight: 800; text-shadow: 0 0 12px rgba(85, 217, 122, 0.35); }

/* ============================== ANIMATIONS =============================== */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Entrée en cascade des sections au chargement */
#sidebar header { animation: fadeUp 0.4s ease backwards; }
#sidebar section { animation: fadeUp 0.45s ease backwards; }
#sidebar section:nth-of-type(1) { animation-delay: 0.05s; }
#sidebar section:nth-of-type(2) { animation-delay: 0.1s; }
#sidebar section:nth-of-type(3) { animation-delay: 0.15s; }
#sidebar section:nth-of-type(4) { animation-delay: 0.2s; }
#sidebar section:nth-of-type(5) { animation-delay: 0.25s; }
#sidebar section:nth-of-type(6) { animation-delay: 0.3s; }
#sidebar section:nth-of-type(7) { animation-delay: 0.35s; }
#sidebar footer { animation: fadeUp 0.45s ease 0.4s backwards; }

/* Sections qui se soulèvent légèrement au survol */
#sidebar section { transition: transform 0.18s ease, box-shadow 0.18s ease; }
#sidebar section:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }

/* Point de statut qui pulse */
.status.online::before { animation: dot-pulse 2.2s ease-out infinite; }
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(85, 217, 122, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(85, 217, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(85, 217, 122, 0); }
}

/* Onde radar autour des joueurs EN LIGNE sur la carte */
.player-icon:not(.offline-icon):not(.replay-ghost)::after {
  content: '';
  position: absolute;
  left: -22px; top: -22px;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(79, 195, 247, 0.55);
  animation: radar 2.6s ease-out infinite;
  pointer-events: none;
}
@keyframes radar {
  0% { transform: scale(0.45); opacity: 0.9; }
  70% { transform: scale(1.15); opacity: 0; }
  100% { transform: scale(1.15); opacity: 0; }
}

/* GLISSEMENT des marqueurs : les joueurs se déplacent en douceur entre deux
   mises à jour au lieu de se téléporter (suspendu pendant les zooms) */
.leaflet-marker-icon.player-icon { transition: transform 0.95s linear; }
.leaflet-marker-icon.replay-ghost { transition: transform 0.3s linear, opacity 0.3s; }
.leaflet-zoom-anim .leaflet-marker-icon,
.no-marker-anim .leaflet-marker-icon { transition: none !important; }

/* Nouveaux messages et événements qui apparaissent en fondu */
.chat-msg { animation: fadeUp 0.25s ease backwards; }
.act-row { animation: fadeUp 0.3s ease backwards; }
.search-hit { animation: fadeUp 0.2s ease backwards; }

/* Reflet qui balaie les barres de progression */
.prog-bar div { position: relative; overflow: hidden; }
.prog-bar div::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  transform: translateX(-100%);
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer { 60%, 100% { transform: translateX(100%); } }

/* Drapeaux de guilde qui flottent doucement */
.guild-icon .flag { animation: flag-float 3.4s ease-in-out infinite; }
@keyframes flag-float {
  0%, 100% { transform: translate(-50%, -60%); }
  50% { transform: translate(-50%, -70%); }
}

/* Accessibilité : si l'utilisateur demande moins de mouvement, on coupe
   uniquement les boucles décoratives — les fondus et glissements restent */
@media (prefers-reduced-motion: reduce) {
  .player-icon::after,
  .status.online::before,
  .prog-bar div::after,
  .guild-icon .flag,
  .admin-marker .pin {
    animation: none !important;
  }
}

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

/* ====================== NAVIGATION & BOUTONS CARTE ======================= */

.navrow { display: flex; gap: 6px; margin: 8px 0 2px; }
.navpill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.navpill:hover { border-color: var(--accent); transform: translateY(-1px); }
.navpill-mini {
  padding: 4px 8px;
  font-size: 11px;
  opacity: 0.55;
  margin-left: auto;   /* poussé à droite, discret */
}
.navpill-mini:hover { opacity: 1; }

/* Repli du panneau latéral (bureau) : languette au bord gauche de la carte */
#sb-toggle {
  position: fixed;
  left: 318px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  width: 20px;
  height: 64px;
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 10px 10px 0;
  background: rgba(21, 26, 38, 0.92);
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
  transition: left 0.2s ease, background 0.15s;
}
#sb-toggle:hover { background: var(--panel); }
body.nosb #sidebar { display: none; }
body.nosb #sb-toggle { left: 0; border-radius: 0 10px 10px 0; }

/* Recentrer sur les joueurs : bouton flottant en bas à droite de la carte */
#center-players {
  position: fixed;
  right: 14px;
  bottom: 18px;
  z-index: 900;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(21, 26, 38, 0.92);
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s, border-color 0.15s;
}
#center-players:hover { transform: scale(1.08); border-color: var(--accent); }

/* ================================ MOBILE ================================= */

@media (max-width: 700px) {
  #sb-toggle { display: none; }        /* le tiroir mobile remplace le repli */
  #center-players { bottom: 74px; }    /* au-dessus de la poignée du tiroir */

  #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: 80vh;
    max-height: 80dvh;
    border-right: none;
    border-top: 1px solid var(--line);
    border-radius: 22px 22px 0 0;
    background: rgba(11, 14, 21, 0.97);
    backdrop-filter: blur(10px);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.55);
    transform: translateY(calc(100% - 58px));
    transition: transform 0.28s cubic-bezier(0.25, 1, 0.4, 1);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
    gap: 8px;
  }
  #sidebar.open { transform: translateY(0); }

  #drawer-handle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 16px 11px;
    height: 58px;
    cursor: pointer;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 2;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  #drawer-handle .grip {
    width: 44px; height: 5px;
    border-radius: 3px;
    background: var(--panel3);
  }
  #drawer-summary { font-size: 14px; font-weight: 700; }

  #sidebar header { padding: 2px 16px 10px; }
  #sidebar section { margin: 0 10px; }

  /* Cibles tactiles généreuses */
  .sec-head { padding: 9px 0; font-size: 13px; }
  .sec-head .chev { font-size: 12px; }
  .player-row { padding: 11px 10px; font-size: 14px; }
  .follow-btn { padding: 7px 13px; font-size: 13px; }
  .cat-row { padding: 10px 7px; font-size: 14px; }
  .cat-row input { width: 18px; height: 18px; }
  .rank-block summary { padding: 9px 8px; font-size: 13px; }
  .toggle { padding: 3px 0; }
  #players-section { flex: none; overflow-y: visible; }

  .world-clock { font-size: 13px; padding: 7px 11px; }
  #replay-slider { width: 130px; }
  #replay-bar { bottom: 66px; }

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