:root {
  --bg: #04070f;
  --bg-glow: #0b1a3a;
  --panel: rgba(10, 16, 32, 0.78);
  --panel-border: rgba(120, 150, 220, 0.14);
  --text: #e6ecf8;
  --muted: #8592ad;
  --faint: #4a5672;
  --attempt: #ffb454;
  --success: #ff4d6d;
  --target: #7cd4ff;
  --bar: rgba(255, 180, 84, 0.13);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at 35% 45%, var(--bg-glow) 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* Bandeau de démo (données simulées) : à retirer à l'étape 2 */
.demo-banner {
  flex: none; padding: 6px 16px; text-align: center; font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.02em; color: #1a1205; background: var(--attempt);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  flex: 1;
  min-height: 0;
}

/* ------------------------------------------------------------------ globe */
.stage { position: relative; min-height: 0; overflow: hidden; }
.globe { position: absolute; inset: 0; }
.globe canvas { display: block; outline: none; }

.overlay { position: absolute; left: 24px; right: 24px; pointer-events: none; z-index: 2; }
.overlay-top { top: 20px; display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.overlay-bottom { bottom: 20px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: 0.01em; }
.brand-title { font-size: 15px; }
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.6); animation: live 1.8s infinite;
}
@keyframes live {
  0% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(255, 77, 109, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0); }
}
.badge {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--attempt); border: 1px solid rgba(255, 180, 84, 0.45); border-radius: 999px; padding: 2px 8px;
}

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch-attempt { background: var(--attempt); }
.swatch-success { background: var(--success); }
.swatch-target { width: 8px; height: 8px; border-radius: 50%; background: var(--target); }

.ticker {
  margin: 0; display: inline-block; max-width: 100%;
  font-family: var(--mono); font-size: 12.5px; color: var(--text);
  background: rgba(6, 10, 22, 0.66); border: 1px solid var(--panel-border); border-radius: 8px;
  padding: 8px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.globe-error {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); max-width: 360px; margin: 0;
  text-align: center; color: var(--muted); font-size: 14px; line-height: 1.5;
}

/* Fiche du pays cliqué */
.country-card {
  position: absolute; left: 24px; top: 62px; z-index: 3; width: min(320px, calc(100% - 48px));
  padding: 14px 16px; border: 1px solid rgba(124, 212, 255, 0.35); border-radius: 12px;
  background: rgba(6, 10, 22, 0.8); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); animation: card-in 0.35s ease-out;
}
.country-card[hidden] { display: none; }
@keyframes card-in { from { opacity: 0; transform: translateY(-6px); } }
.cc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cc-name { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.cc-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 0; }
.cc-stats div { display: flex; flex-direction: column-reverse; gap: 1px; }
.cc-stats dt { font-size: 11px; color: var(--muted); }
.cc-stats dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cc-notes { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.cc-notes:empty { display: none; }
.btn.btn-small { padding: 4px 10px; font-size: 12px; flex: none; }
.btn.is-loading { opacity: 0.6; cursor: progress; }

/* ------------------------------------------------------------------ panneau */
.panel {
  display: flex; flex-direction: column; gap: 18px; min-height: 0; overflow-y: auto;
  padding: 20px 20px 16px; background: var(--panel); border-left: 1px solid var(--panel-border);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px;
  border: 1px solid var(--panel-border); border-radius: 10px; background: rgba(255, 255, 255, 0.02);
}
.stat-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-danger { color: var(--success); }
.stat-label { font-size: 11.5px; color: var(--muted); }

.block h2 {
  margin: 0 0 10px; font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
/* Les dernières commandes défilent dans leur bloc : les boutons restent visibles en bas */
.block-grow { flex: 1 1 0; min-height: 150px; display: flex; flex-direction: column; }
.block-grow .commands { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }

.rank { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank li {
  position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  border-radius: 6px; font-size: 13px; overflow: hidden;
}
.rank .bar { position: absolute; inset: 0 auto 0 0; background: var(--bar); border-radius: 6px; z-index: 0;
  transition: width 0.4s ease; }
.rank .pos { width: 14px; color: var(--faint); font-variant-numeric: tabular-nums; z-index: 1; }
.rank .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; z-index: 1; }
.rank .count { color: var(--muted); font-variant-numeric: tabular-nums; z-index: 1; }
.rank .mono { font-family: var(--mono); font-size: 12.5px; }
.rank .empty, .commands .empty { color: var(--faint); font-size: 13px; padding: 6px 0; }

.commands { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.commands li { display: flex; flex-direction: column; gap: 3px; padding-bottom: 8px; border-bottom: 1px solid var(--panel-border); }
.commands li:last-child { border-bottom: none; }
.commands li.is-new { animation: appear 0.6s ease; }
@keyframes appear { from { opacity: 0.35; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cmd { font-family: var(--mono); font-size: 12.5px; color: var(--text); word-break: break-all; }
.cmd::before { content: "$ "; color: var(--success); }
.cmd-meta { font-size: 11.5px; color: var(--muted); }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.speed { display: inline-flex; border: 1px solid var(--panel-border); border-radius: 8px; overflow: hidden; }
.btn {
  font: inherit; font-size: 12.5px; color: var(--text); background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border); border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); }
.btn:focus-visible { outline: 2px solid var(--target); outline-offset: 2px; }
.btn-speed { border: none; border-radius: 0; }
.btn-speed + .btn-speed { border-left: 1px solid var(--panel-border); }
.btn-speed.is-active, .btn[aria-pressed="true"] { background: rgba(124, 212, 255, 0.14); color: var(--target); }
.privacy { margin: 0; font-size: 11.5px; color: var(--faint); }

/* ------------------------------------------------------------------ connexion réussie */
/* Éclat rouge sur Paris : globe.gl positionne .impact-anchor (transform), l'enfant .impact-flash est animé */
.impact-anchor { width: 0; height: 0; pointer-events: none; }
.impact-flash {
  width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 220, 228, 0.95) 0%, rgba(255, 77, 109, 0.75) 22%,
    rgba(255, 77, 109, 0.25) 48%, rgba(255, 77, 109, 0) 70%);
  animation: impact 1.5s ease-out both;
}
@keyframes impact {
  0% { transform: scale(0.2); opacity: 0; }
  15% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.4); opacity: 0; }
}
.stat.is-hit { animation: hit 1.2s ease-out; }
@keyframes hit {
  0% { border-color: rgba(255, 77, 109, 0.9); box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.5); }
  100% { border-color: var(--panel-border); box-shadow: 0 0 0 12px rgba(255, 77, 109, 0); }
}

/* ------------------------------------------------------------------ petits écrans */
@media (max-width: 900px) {
  body { height: auto; }
  .layout { grid-template-columns: 1fr; grid-template-rows: 58vh auto; flex: none; }
  .stage { height: 58vh; }
  .panel { border-left: none; border-top: 1px solid var(--panel-border); overflow: visible; padding: 16px; }
  .block-grow { flex: none; }
  .block-grow .commands { overflow: visible; }
  .overlay { left: 16px; right: 16px; }
  .overlay-top { top: 14px; }
  .overlay-bottom { bottom: 14px; }
  .legend { display: none; }
  .country-card { left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; padding: 12px 14px; }
  .cc-stats dd { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .commands li.is-new, .stat.is-hit, .country-card { animation: none; }
  .impact-flash { animation-duration: 0.01s; }
}
