:root {
  --panel-w: 336px;
  --ink: #14202b;
  --muted: #6b7a89;
  --line: #e4e9ee;
  --bg: #ffffff;
  --shadow: 0 6px 24px rgba(20, 32, 43, .16);
  --top14: #c0392b;
  --prod2: #1f6feb;
  --nationale: #2f855a;
  --nationale2: #8a5cf6;
  --federale1: #d97706;
  --federale2: #0d9488;
  --federale3: #be185d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}

#map {
  position: absolute;
  inset: 0 0 0 var(--panel-w);
  background: #eef2f5;
}

/* ---------------- side panel ---------------- */
#panel {
  position: absolute;
  z-index: 1000;
  top: 0; left: 0; bottom: 0;
  width: var(--panel-w);
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

#panel.collapsed { transform: translateX(calc(-1 * var(--panel-w))); }

#panel-toggle {
  position: absolute;
  top: 12px; right: -14px;
  width: 28px; height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 16px; line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}
#panel.collapsed #panel-toggle { transform: rotate(180deg); }

#panel header {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}
#panel h1 {
  margin: 0 0 6px;
  font-size: 16.5px;
  line-height: 1.25;
  letter-spacing: -.01em;
}
#panel .sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.block {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.block h2 {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  font-weight: 600;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  cursor: pointer;
  user-select: none;
}
.check input { accent-color: #1f6feb; }
.hint { margin: 8px 0 0; }

.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.league.top14 { background: var(--top14); }
.sw.league.prod2 { background: var(--prod2); }
.sw.league.nationale { background: var(--nationale); }
.sw.league.nationale2 { background: var(--nationale2); }
.sw.league.federale1 { background: var(--federale1); }
.sw.league.federale2 { background: var(--federale2); }
.sw.league.federale3 { background: var(--federale3); }

/* legend */
#legend { max-height: 42vh; overflow: auto; margin: -4px -6px; padding: 4px 6px;
  display: flex; flex-direction: column; }
.leg-section { display: flex; flex-direction: column; }
#legend h3 {
  margin: 8px 0 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.leg-item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 7px;
  cursor: pointer;
}
.leg-item:hover { background: #f2f6fa; }
.leg-item.off { opacity: .38; }
.leg-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }
.leg-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.leg-sub { font-size: 11px; color: var(--muted); line-height: 1.3; }
.leg-pct { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

#panel footer { padding: 12px 18px; margin-top: auto; }
.muted { color: var(--muted); }
.small { font-size: 11px; line-height: 1.5; }

/* ---------------- live readout ---------------- */
#readout {
  position: absolute;
  z-index: 900;
  left: calc(var(--panel-w) + 50%);
  transform: translateX(-50%);
  bottom: 22px;
  min-width: 260px;
  max-width: 88vw;
  background: rgba(255,255,255,.97);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 14px;
  pointer-events: none;
}
#readout.hidden { display: none; }
.ro-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.ro-club { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; margin: 2px 0 1px; }
#ro-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.ro-meta { font-size: 12px; color: #3f4c59; }
.ro-dist { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.ro-dist b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------------- leaflet tweaks ---------------- */
.leaflet-container { font: inherit; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-tooltip.club-tip {
  background: rgba(20,32,43,.92);
  border: 0;
  color: #fff;
  box-shadow: none;
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 8px;
}
.leaflet-tooltip.club-tip::before { border-top-color: rgba(20,32,43,.92); }
.leaflet-tooltip.club-tip b { font-size: 13px; }

.club-label {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: #10202c;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff, 0 0 4px #fff;
  white-space: nowrap;
}
.club-label::before { display: none; }
.club-label > span { display: inline-block; }

@media (max-width: 720px) {
  #map { inset: 0; }
  #panel { width: min(88vw, var(--panel-w)); }
  #readout { left: 50%; }
}
