/* ============================================================================
   NEXOO APP — BRIQUE 8 : NEXOO CHALLENGE & CLASSEMENTS (DARK MODE MOBILE-FIRST)
   ============================================================================ */

.ch-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: #080e1c;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  overscroll-behavior: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ch-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Barre supérieure fixe */
.ch-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(8, 14, 28, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ch-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ch-back-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(57, 255, 20, 0.45);
}

.ch-topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: 0.01em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ch-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.ch-icon-btn:hover {
  background: rgba(57, 255, 20, 0.14);
  border-color: rgba(57, 255, 20, 0.5);
}

/* Zone de défilement principale */
.ch-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px calc(28px + env(safe-area-inset-bottom, 0px));
}

.ch-container {
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Cartes de base */
.ch-card {
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
}

.ch-card-neon {
  background: linear-gradient(160deg, #111a2e 0%, #0d182b 100%);
  border: 1px solid rgba(57, 255, 20, 0.28);
}

.ch-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ch-section-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 7px;
}

.ch-section-sub {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

/* En-tête Challenge (Mois + Filtres Période / Périmètre + Barème rapide) */
.ch-hero {
  background: radial-gradient(circle at top right, rgba(57, 255, 20, 0.13), transparent 55%),
              #111a2e;
  border: 1px solid rgba(57, 255, 20, 0.25);
  border-radius: 18px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ch-hero-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.ch-hero-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
}

.ch-hero-month {
  font-size: 18px;
  font-weight: 700;
  color: #39ff14;
  font-style: italic;
}

.ch-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ch-segmented {
  display: inline-flex;
  background: rgba(8, 14, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}

.ch-seg-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.ch-seg-btn.is-active {
  background: #22c55e;
  color: #04130a;
}

.ch-bareme-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: #cbd5e1;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.ch-bareme-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ch-bareme-chip strong {
  color: #39ff14;
}

/* Carte Pseudo manquant (« Prêt pour le Challenge NEXOO ? / ENTRER DANS L'ARÈNE ») */
.ch-pseudo-gate {
  background: linear-gradient(145deg, rgba(57, 255, 20, 0.1), rgba(17, 26, 46, 0.96));
  border: 1px solid rgba(57, 255, 20, 0.55);
  border-radius: 16px;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ch-pseudo-gate-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #ffffff;
}

.ch-pseudo-gate-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #cbd5e1;
}

.ch-pseudo-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.ch-pseudo-input {
  width: 100%;
  box-sizing: border-box;
  background: #080e1c;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ch-pseudo-input:focus {
  border-color: #39ff14;
  box-shadow: 0 0 0 3px rgba(57, 255, 20, 0.15);
}

.ch-pseudo-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.ch-arena-btn {
  background: #39ff14;
  color: #04130a;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ch-arena-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(57, 255, 20, 0.45);
}

.ch-arena-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.ch-link-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 4px;
}

.ch-link-btn:hover {
  color: #f8fafc;
}

.ch-feedback {
  font-size: 12px;
  font-weight: 600;
  min-height: 16px;
}

.ch-feedback.is-error {
  color: #f87171;
}

.ch-feedback.is-ok {
  color: #39ff14;
}

/* Tableau de bord personnel */
.ch-my-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.ch-my-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ch-pseudo-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(57, 255, 20, 0.12);
  border: 1px solid rgba(57, 255, 20, 0.4);
  color: #f8fafc;
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 700;
}

.ch-club-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
}

.ch-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.ch-kpi {
  background: #18243f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 13px;
  padding: 12px 10px;
  text-align: center;
}

.ch-kpi-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.ch-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.15;
}

.ch-kpi-value.is-neon {
  color: #39ff14;
}

.ch-kpi-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.ch-sources-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ch-source-item {
  background: rgba(8, 14, 28, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 11px;
  padding: 9px 8px;
  text-align: center;
}

.ch-source-name {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 3px;
  font-weight: 600;
}

.ch-source-pts {
  font-size: 14px;
  font-weight: 800;
  color: #e2e8f0;
}

.ch-source-count {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

/* Podium Top 3 */
.ch-podium {
  display: grid;
  grid-template-columns: 1fr 1.12fr 1fr;
  align-items: end;
  gap: 8px;
  margin: 4px 0 16px;
}

.ch-podium-slot {
  background: #18243f;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 14px;
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.ch-podium-slot.rank-1 {
  background: linear-gradient(180deg, rgba(57, 255, 20, 0.16), #18243f 72%);
  border-color: rgba(57, 255, 20, 0.65);
  padding: 16px 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.ch-podium-slot.rank-2 {
  border-color: rgba(203, 213, 225, 0.35);
}

.ch-podium-slot.rank-3 {
  border-color: rgba(251, 146, 60, 0.35);
}

.ch-podium-slot.is-me {
  box-shadow: 0 0 0 2px #39ff14;
}

.ch-podium-slot.is-empty {
  opacity: 0.35;
  border-style: dashed;
}

.ch-podium-medal {
  font-size: 22px;
  line-height: 1;
}

.ch-podium-slot.rank-1 .ch-podium-medal {
  font-size: 26px;
}

.ch-podium-pseudo {
  font-size: 13px;
  font-weight: 700;
  color: #f8fafc;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ch-podium-pts {
  font-size: 14px;
  font-weight: 800;
  color: #39ff14;
}

/* Liste Top 10 */
.ch-rank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ch-rank-row {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  align-items: center;
  gap: 10px;
  background: #18243f;
  border: 1px solid rgba(57, 255, 20, 0.22);
  border-radius: 12px;
  padding: 11px 14px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ch-rank-row.is-top3 {
  background: linear-gradient(90deg, rgba(57, 255, 20, 0.09), #18243f 48%);
  border-color: rgba(57, 255, 20, 0.42);
}

.ch-rank-row.is-me {
  background: rgba(57, 255, 20, 0.15);
  border-color: #39ff14;
  box-shadow: 0 0 14px rgba(57, 255, 20, 0.18);
}

.ch-rank-pos {
  font-size: 14px;
  font-weight: 800;
  color: #cbd5e1;
  white-space: nowrap;
}

.ch-rank-pseudo {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ch-me-badge {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  background: #39ff14;
  color: #04130a;
  padding: 2px 7px;
  border-radius: 999px;
  flex-shrink: 0;
}

.ch-rank-pts {
  font-size: 14px;
  font-weight: 800;
  color: #39ff14;
  white-space: nowrap;
}

.ch-outside-rank {
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(57, 255, 20, 0.09);
  border: 1px dashed rgba(57, 255, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: #e2e8f0;
}

.ch-outside-rank strong {
  color: #39ff14;
}

.ch-empty-state {
  text-align: center;
  padding: 22px 14px;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
  background: rgba(8, 14, 28, 0.45);
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
}

/* Calendrier d'assiduité (Heatmap mensuelle) */
.ch-cal-month {
  color: #39ff14;
  font-size: 14px;
  font-weight: 800;
}

.ch-weekdays,
.ch-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 7px;
  text-align: center;
}

.ch-weekdays div {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  padding-bottom: 6px;
}

.ch-day {
  aspect-ratio: 1;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  color: #b0c4de;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.ch-day:hover:not(.is-empty) {
  transform: scale(1.05);
  border-color: #39ff14;
}

.ch-day.is-empty {
  background: transparent;
  cursor: default;
  pointer-events: none;
}

.ch-day.lvl-1 {
  background: rgba(57, 255, 20, 0.24);
  color: #ffffff;
  border-color: rgba(57, 255, 20, 0.48);
}

.ch-day.lvl-2 {
  background: rgba(57, 255, 20, 0.55);
  color: #04130a;
  border-color: #39ff14;
}

.ch-day.lvl-3 {
  background: #39ff14;
  color: #04130a;
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.45);
}

.ch-day.is-today {
  box-shadow: inset 0 0 0 2px #f8fafc;
}

.ch-day.is-selected {
  border-color: #ffffff;
  transform: scale(1.06);
}

.ch-day-detail {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(8, 14, 28, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  color: #e2e8f0;
  text-align: center;
  line-height: 1.4;
}

.ch-cal-legend {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 11px;
  color: #94a3b8;
}

.ch-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 3px;
}

.ch-legend-dot.l0 { background: rgba(255, 255, 255, 0.08); }
.ch-legend-dot.l1 { background: rgba(57, 255, 20, 0.28); }
.ch-legend-dot.l2 { background: rgba(57, 255, 20, 0.58); }
.ch-legend-dot.l3 { background: #39ff14; }

/* Studio de Partage Instagram & LinkedIn (natif HTML5 Canvas) */
.ch-share-wrap {
  text-align: center;
}

.ch-share-title {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.ch-share-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.ch-share-tab {
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ch-share-tab.is-active {
  background: rgba(57, 255, 20, 0.15);
  color: #39ff14;
  border-color: #39ff14;
}

.ch-share-formats {
  display: inline-flex;
  background: rgba(8, 14, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}

.ch-format-btn {
  background: transparent;
  color: #94a3b8;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ch-format-btn.is-active {
  background: #39ff14;
  color: #04130a;
}

.ch-share-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 390px;
  margin-bottom: 14px;
}

.ch-canvas {
  border-radius: 14px;
  border: 1px solid rgba(57, 255, 20, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  display: block;
  transition: width 0.2s ease, height 0.2s ease;
}

.ch-canvas.format-story {
  width: 225px;
  height: 400px;
}

.ch-canvas.format-post {
  width: 296px;
  height: 370px;
}

.ch-share-cta {
  background: #39ff14;
  color: #04130a;
  border: none;
  border-radius: 25px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  max-width: 330px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ch-share-cta:hover {
  transform: scale(1.02);
  box-shadow: 0 0 16px rgba(57, 255, 20, 0.5);
}

.ch-share-status {
  margin-top: 10px;
  font-size: 12px;
  color: #94a3b8;
  min-height: 16px;
  line-height: 1.4;
}

/* Règles & plafonds journaliers */
.ch-rules-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ch-rules-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  background: rgba(8, 14, 28, 0.52);
  border-radius: 10px;
  font-size: 13px;
  color: #cbd5e1;
}

.ch-rules-list li strong {
  color: #39ff14;
  white-space: nowrap;
}

/* Chargement & Erreur */
.ch-loading-box {
  padding: 36px 16px;
  text-align: center;
  color: #94a3b8;
  font-size: 14px;
}

.ch-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(57, 255, 20, 0.2);
  border-top-color: #39ff14;
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: ch-spin 0.8s linear infinite;
}

@keyframes ch-spin {
  to { transform: rotate(360deg); }
}

.ch-retry-btn {
  margin-top: 12px;
  background: #22c55e;
  color: #04130a;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* Ajustements petits écrans */
@media (max-width: 480px) {
  .ch-scroll {
    padding: 12px 10px calc(24px + env(safe-area-inset-bottom, 0px));
  }
  .ch-card,
  .ch-hero {
    padding: 14px 12px;
  }
  .ch-kpi-value {
    font-size: 19px;
  }
  .ch-share-stage {
    min-height: 360px;
  }
  .ch-canvas.format-story {
    width: 205px;
    height: 364px;
  }
  .ch-canvas.format-post {
    width: 268px;
    height: 335px;
  }
  .ch-share-tab {
    font-size: 11px;
    padding: 6px 10px;
  }
}

/* Mise en page élargie sur Desktop */
@media (min-width: 760px) {
  .ch-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
}