/* ===============================
   Clix – styles spécifiques
   =============================== */

:root {
  --cx-bleu: #1f5fbf;
  --cx-bleu-fonce: #174a96;
  --cx-fond: #2b313b;
}

/* ---------- Configuration ---------- */

.cx-panel {
  max-width: 600px;
  margin: 14px auto 36px auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 22px 32px 30px 32px;
  box-sizing: border-box;
}

.cx-row {
  margin-bottom: 18px;
}

.cx-label {
  font-weight: bold;
  font-size: 0.95em;
  margin-bottom: 10px;
  color: #3a4250;
}

.cx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.cx-chips button {
  border: 2px solid #d3dae2;
  background: #f5f7fa;
  color: #333;
  border-radius: 22px;
  padding: 9px 18px;
  min-width: 46px;
  font-size: 0.95em;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.cx-chips button:hover {
  border-color: #8fb1dc;
}

.cx-chips button.sel {
  background: var(--cx-bleu);
  border-color: var(--cx-bleu);
  color: #fff;
}

.cx-goal {
  margin-top: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f1f4f8;
  color: #3a4250;
  text-align: center;
  line-height: 1.5;
}

/* Aperçu des couleurs du niveau choisi */
.cx-swatches {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}

.cx-swatches .cx-in {
  position: relative;
  inset: auto;
  width: 26px;
  height: 26px;
}

.cx-start-row {
  text-align: center;
  padding-top: 22px;
}

.cx-start-row .cx-play {
  font-size: 1.1em;
  padding: 8px 34px;
}

/* Bouton principal (Jouer, Rejouer…) */
.cx-play {
  font-family: "Madimi One", sans-serif;
  font-size: 1.3em;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--cx-bleu);
  border: none;
  border-radius: 30px;
  padding: 12px 54px;
  cursor: pointer;
  box-shadow:
    0 4px 0 var(--cx-bleu-fonce),
    0 6px 14px rgba(31, 95, 191, 0.35);
  transition:
    transform 0.1s,
    box-shadow 0.1s,
    background 0.15s;
}

.cx-play:hover {
  background: #2a6fd6;
}

.cx-play:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 var(--cx-bleu-fonce),
    0 2px 6px rgba(31, 95, 191, 0.3);
}

/* Boutons secondaires */
.cx-btn {
  font-size: 0.95em;
  color: var(--cx-bleu);
  background: #fff;
  border: 2px solid #c9d6e8;
  border-radius: 22px;
  padding: 8px 16px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s;
}

.cx-btn:hover:not(:disabled) {
  background: #eef4fc;
  border-color: var(--cx-bleu);
}

.cx-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.cx-btn.actif {
  background: var(--cx-bleu);
  border-color: var(--cx-bleu);
  color: #fff;
}

.cx-btn-danger {
  color: #c62828;
  border-color: #ecc4c4;
}

.cx-btn-danger:hover {
  background: #fdeeee;
  border-color: #c62828;
}

/* ---------- Écran de jeu ---------- */

/* Barre commune (css/games.css) aux couleurs du jeu */
.cx-jeu {
  --mg-jeu-largeur: 924px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(30, 136, 229, 0.3), transparent 55%),
    radial-gradient(120% 160% at 100% 100%, rgba(229, 57, 53, 0.22), transparent 55%),
    linear-gradient(120deg, #172338, #2b3a57);
  --mgb-accent: #fbc02d;
  --mgb-titre: linear-gradient(100deg, #e53935, #fbc02d 35%, #43a047 65%, #1e88e5);
  --mg-fs-fond: #eef2f7;
  --mg-bulle-fond: #172338;
}

.cx-jeu .cx-panel {
  width: 100%;
  margin: 0 auto 26px auto;
}

#cx-game {
  padding: 0 8px;
}

.cx-jeu.mg-fs {
  justify-content: center;
}

/* Dans la colonne flexible du plein écran, les marges automatiques réduiraient
   le plateau à la largeur de son contenu */
.cx-jeu.mg-fs .cx-wrap {
  width: 100%;
  max-width: none;
}

.mg-stat b.cx-stat-rec {
  color: #ffd54f;
}

.cx-status {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 10px;
  min-height: 30px;
  margin: 8px auto 0 auto;
  font-weight: bold;
  color: #333;
  text-align: center;
  transition: color 0.15s;
}

.cx-status.erreur {
  color: #c62828;
}

.cx-status.aide {
  color: #b26a00;
}

.cx-status .cx-btn {
  padding: 3px 12px;
  font-size: 0.9em;
}

.cx-wrap {
  position: relative;
  max-width: 900px;
  margin: 6px auto 0 auto;
  user-select: none;
  -webkit-user-select: none;
}

/* Plateau : cadre sombre, les cases y sont posées en position absolue */
.cx-board {
  position: relative;
  margin: 0 auto;
  box-sizing: content-box;
  padding: 6px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.07), transparent 70%),
    var(--cx-fond);
  box-shadow:
    inset 0 2px 8px rgba(0, 0, 0, 0.45),
    0 4px 14px rgba(0, 0, 0, 0.18);
  width: fit-content;
  touch-action: manipulation;
}

.cx-board.attente {
  cursor: progress;
}

/* Zone des cases (sans la marge du cadre), dimensionnée par le script */
.cx-grid {
  position: relative;
}

.cx-board.isole .cx-grid {
  cursor: not-allowed;
}

.cx-board.jouable .cx-grid {
  cursor: pointer;
}

/* Case : l'élément extérieur porte la position (glissements animés),
   l'intérieur porte le dessin (apparition, disparition, secousse) */
.cx-tile {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell, 32px);
  height: var(--cell, 32px);
  transition: transform 0.26s cubic-bezier(0.5, 0, 0.75, 0);
  will-change: transform;
  pointer-events: none;
}

.cx-board.sans-anim .cx-tile {
  transition: none;
}

.cx-in {
  position: absolute;
  inset: 1.5px;
  border-radius: 24%;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.08) 42%, rgba(0, 0, 0, 0.22)),
    var(--c, #888);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    filter 0.12s,
    transform 0.12s,
    box-shadow 0.12s;
}

/* Symbole (option « daltonisme ») */
.cx-in svg {
  display: none;
  width: 56%;
  height: 56%;
  fill: rgba(0, 0, 0, 0.32);
  stroke: rgba(255, 255, 255, 0.6);
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.cx-board.symboles .cx-in svg,
.cx-swatches.symboles .cx-in svg {
  display: block;
}

/* Bloc survolé */
.cx-tile.sel .cx-in {
  filter: brightness(1.2);
  transform: scale(0.92);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 8px rgba(255, 255, 255, 0.35);
}

/* Indice : le bloc à jouer clignote */
.cx-tile.indice .cx-in {
  animation: cx-indice 0.55s ease-in-out infinite alternate;
}

@keyframes cx-indice {
  to {
    filter: brightness(1.45);
    transform: scale(0.84);
    box-shadow:
      inset 0 0 0 3px #fff,
      0 0 12px rgba(255, 220, 120, 0.9);
  }
}

.cx-tile.pop .cx-in {
  animation: cx-pop 0.24s ease-in forwards;
}

@keyframes cx-pop {
  30% {
    transform: scale(1.12);
    filter: brightness(1.5);
  }
  to {
    transform: scale(0.1);
    opacity: 0;
  }
}

.cx-tile.apparait .cx-in {
  animation: cx-apparait 0.22s ease-out both;
}

@keyframes cx-apparait {
  from {
    transform: scale(0.2);
    opacity: 0;
  }
}

.cx-tile.secoue .cx-in {
  animation: cx-secoue 0.3s ease-in-out;
}

@keyframes cx-secoue {
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

/* Curseur clavier */
.cx-cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--cell, 32px);
  height: var(--cell, 32px);
  box-sizing: border-box;
  border: 3px solid #fff;
  border-radius: 26%;
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.5),
    0 0 10px rgba(255, 255, 255, 0.6);
  pointer-events: none;
  transition: transform 0.08s;
  z-index: 3;
}

/* Points gagnés, qui s'envolent depuis le bloc */
.cx-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: "Madimi One", sans-serif;
  font-size: 1.3em;
  color: #fff;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.45),
    0 0 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  z-index: 4;
  animation: cx-float 0.9s ease-out forwards;
}

@keyframes cx-float {
  from {
    opacity: 0;
    margin-top: 8px;
  }
  20% {
    opacity: 1;
  }
  to {
    opacity: 0;
    margin-top: -38px;
  }
}

/* Message au centre du plateau (création de la grille, grille vidée) */
.cx-msg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  font-family: "Madimi One", sans-serif;
  font-size: 1.4em;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
}

.cx-msg:empty {
  display: none;
}

/* ---------- Barre d'outils ---------- */

.cx-keys {
  text-align: center;
  font-size: 0.8em;
  color: #888;
  margin: 0 auto 14px auto;
}

.cx-keys b {
  color: #555;
}

@media (hover: none) {
  .cx-keys {
    display: none;
  }
}

/* ---------- Fenêtres (fin de partie, confirmation) ---------- */

.cx-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(15, 25, 45, 0.55);
  animation: cx-fade 0.25s ease-out;
  overflow: hidden;
}

.cx-modal-box {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 24px 26px 22px 26px;
  width: 100%;
  max-width: 440px;
  box-sizing: border-box;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: cx-pop-box 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.cx-modal-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.cx-modal-btns .cx-play {
  font-size: 1.15em;
  padding: 10px 34px;
}

.cx-modal-btns2 {
  margin-top: 14px;
}

.cx-end-title {
  font-family: "Madimi One", sans-serif;
  font-size: 2.2em;
  line-height: 1.1;
  color: #2a2f38;
}

.cx-end-sub {
  margin-top: 6px;
  color: #555;
  line-height: 1.45;
}

.cx-end-stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.cx-end-stats span {
  padding: 6px 14px;
  border-radius: 20px;
  background: #f1f4f8;
  font-family: "Madimi One", sans-serif;
  font-size: 1.1em;
  color: #333;
}

.cx-end-rec {
  margin-top: 12px;
  font-weight: bold;
  color: #2e7d32;
}

.cx-end-rec:empty {
  display: none;
}

/* Règles du jeu (bouton « i ») */
#cx-rules .cx-end-title {
  font-size: 1.8em;
}

.cx-confirm-txt {
  font-weight: bold;
  font-size: 1.05em;
  color: #333;
}

@keyframes cx-fade {
  from {
    opacity: 0;
  }
}

@keyframes cx-pop-box {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}

/* Confettis en forme de petites cases (victoire) */
.cx-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cx-confetti span {
  position: absolute;
  top: -30px;
  border-radius: 24%;
  animation: cx-confetti linear forwards;
}

@keyframes cx-confetti {
  to {
    transform: translate(var(--dx), 110vh) rotate(var(--rot));
  }
}

@media (max-width: 520px) {
  .cx-panel {
    padding: 16px 18px 24px 18px;
  }
  .cx-btn {
    padding: 7px 12px;
    font-size: 0.9em;
  }
  
  
  
  .cx-end-title {
    font-size: 1.8em;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cx-tile {
    transition: none;
  }
  .cx-tile.indice .cx-in {
    animation: none;
    filter: brightness(1.4);
    box-shadow: inset 0 0 0 3px #fff;
  }
}
