/* =============================================
   MEMORY MATCH — Styles
   ============================================= */
:root {
  --mm-bg:            #0f172a;
  --mm-surface:       #1e293b;
  --mm-border:        #334155;
  --mm-accent:        #a78bfa;
  --mm-success:       #22c55e;
  --mm-error:         #ef4444;
  --mm-text:          #f1f5f9;
  --mm-muted:         #94a3b8;
  --mm-card-w:        130px;
  --mm-card-h:        165px;
}

/* ---- Bouton plein écran ---- */
.mm-fs-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--mm-border);
  color: var(--mm-muted);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.mm-fs-btn:hover {
  color: var(--mm-text);
  background: var(--mm-surface);
}

/* Conteneur fullscreen (scoring + jeu, sans le header titre/retour) */
#mm-fullscreen-wrap {
  position: relative;
}

#mm-wrapper {
  position: relative;
}

#mm-fullscreen-wrap.mm-fs--expanded {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--mm-bg);
  overflow-y: auto;
  padding: 24px 32px;
}

/* ---- Intro ---- */
.mm-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  background: var(--mm-bg);
  border-radius: 16px;
  margin-top: 24px;
}
.mm-intro__icon  { font-size: 48px; margin-bottom: 12px; }
.mm-intro__title { color: var(--mm-text); font-size: 22px; margin: 0 0 8px; }
.mm-intro__desc  { color: var(--mm-muted); font-size: 14px; margin: 0 0 24px; }

/* ---- Grid ---- */
#mm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  background: var(--mm-bg);
  border-radius: 16px;
  min-height: 240px;
  margin-top: 24px;
}

/* ---- Card base ---- */
.mm-card {
  width: var(--mm-card-w);
  height: var(--mm-card-h);
  position: relative;
  cursor: pointer;
  perspective: 800px;
}
.mm-card:hover { filter: brightness(1.18); }

/* ---- Memory mode: 3D flip ---- */
.mm-card__inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.45s ease;
}
.mm-card--flipped .mm-card__inner {
  transform: rotateY(180deg);
}

.mm-card__back,
.mm-card__front {
  position: absolute; /* NB: .mm-debug-group en absolute s'y positionne */
  inset: 0;
  border-radius: 10px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 10px;
  border: 2px solid transparent;
}
.mm-card__back {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);
  border-color: #818cf8;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.mm-card__back-icon { font-size: 34px; color: rgba(255,255,255,0.85); filter: drop-shadow(0 0 8px rgba(168,85,247,0.9)); }

.mm-card__front {
  background: linear-gradient(145deg, #1e3a5f 0%, #0f2744 100%);
  border-color: #3b82f6;
  box-shadow: inset 0 1px 0 rgba(99,179,237,0.12);
  transform: rotateY(180deg);
}

/* ---- Connections mode: cartes visibles ---- */
.mm-card--visible {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 10px;
  background: linear-gradient(145deg, #1e3a5f 0%, #0f2744 100%);
  border: 2px solid #3b82f6;
  box-shadow: inset 0 1px 0 rgba(99,179,237,0.12);
  border-radius: 10px;
  width: var(--mm-card-w);
  height: var(--mm-card-h);
}

/* ---- Contenu carte ---- */
.mm-card__emoji { font-size: 30px; line-height: 1.2; }
.mm-card__text  {
  font-size: 12px;
  font-weight: 600;
  color: var(--mm-text);
  text-align: center;
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  max-height: 90px;
  overflow: hidden;
}

/* ---- États ---- */
/* Bonne piste (memory) */
.mm-card--on-track .mm-card__front {
  border-color: var(--mm-success);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.45);
}

/* Sélectionné (connections) */
.mm-card--selected {
  border-color: var(--mm-accent) !important;
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.5);
}

/* Mauvais match (memory) */
.mm-card--wrong .mm-card__front {
  border-color: var(--mm-error);
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.55);
}

/* Trouvé — succès vert vif */
.mm-card--found {
  pointer-events: none;
}
.mm-card--found .mm-card__front,
.mm-card--found.mm-card--visible {
  border-color: var(--mm-success) !important;
  background: rgba(34, 197, 94, 0.18);
  box-shadow: 0 0 18px rgba(34, 197, 94, 0.65);
}

/* Disparition avec zoom + fondu */
@keyframes mm-vanish {
  0%   { opacity: 1;   transform: rotate(var(--mm-rot, 0deg)) translate(var(--mm-tx, 0px), var(--mm-ty, 0px)) scale(1); }
  30%  { opacity: 0.9; transform: rotate(var(--mm-rot, 0deg)) translate(var(--mm-tx, 0px), var(--mm-ty, 0px)) scale(1.15); }
  100% { opacity: 0;   transform: rotate(var(--mm-rot, 0deg)) translate(var(--mm-tx, 0px), var(--mm-ty, 0px)) scale(0.3); }
}
.mm-card--gone {
  animation: mm-vanish 0.6s ease-in forwards;
  pointer-events: none;
}

/* Shake (mauvais groupe connections) */
@keyframes mm-shake {
  0%, 100% { transform: translateX(var(--mm-tx, 0)) rotate(var(--mm-rot, 0deg)); }
  20%       { transform: translateX(calc(var(--mm-tx, 0) - 7px)) rotate(var(--mm-rot, 0deg)); }
  40%       { transform: translateX(calc(var(--mm-tx, 0) + 7px)) rotate(var(--mm-rot, 0deg)); }
  60%       { transform: translateX(calc(var(--mm-tx, 0) - 4px)) rotate(var(--mm-rot, 0deg)); }
  80%       { transform: translateX(calc(var(--mm-tx, 0) + 4px)) rotate(var(--mm-rot, 0deg)); }
}
.mm-card--shake { animation: mm-shake 0.5s ease; }

/* ---- Boutons ---- */
#mm-controls {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}
.mm-btn {
  padding: 10px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, opacity 0.2s;
  letter-spacing: 0.04em;
}
.mm-btn--start {
  background: var(--mm-accent);
  color: #fff;
}
.mm-btn--start:hover { background: #2563eb; }

.mm-btn--validate {
  background: var(--mm-success);
  color: #fff;
}
.mm-btn--validate:hover:not(:disabled) { background: #16a34a; }

.mm-btn--disabled,
.mm-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

/* ---- Écran de fin ---- */
.mm-complete {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--mm-text);
}
.mm-complete__icon  { font-size: 52px; margin-bottom: 16px; }
.mm-complete h3     { font-size: 22px; margin: 0 0 8px; }
.mm-complete p      { color: var(--mm-muted); margin: 0; }
