*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: linear-gradient(135deg, #022c22, #064e3b, #0f3d2e);
  color: #e0e0e0;
  padding: 16px;
  padding-top: 60px;
  touch-action: none;
}

#app {
  position: relative;
  z-index: 1;
  background: rgba(20, 20, 35, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  padding: 32px 28px 28px;
  max-width: 700px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.header { text-align: center; margin-bottom: 32px; }
.header h1 {
  font-size: 2rem; font-weight: 800;
  background: linear-gradient(90deg, #34d399, #10b981, #059669);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 8px;
}
.header .date-jour { font-size: 1rem; color: #94a3b8; }

.back-link {
  display: inline-block; margin-bottom: 20px; text-align: left;
  color: #34d399; text-decoration: none; font-size: 0.85rem; font-weight: 600;
  align-self: flex-start;
}
.back-link:hover { color: #6ee7b7; }

/* Cartes difficulté */
.defis-grille {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: 16px; margin-bottom: 32px;
}
.defi-carte {
  background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px; padding: 24px 20px; text-align: center; width: 180px;
  transition: all 0.3s ease; cursor: pointer;
}
.defi-carte:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(52, 211, 153, 0.4); transform: translateY(-3px); }
.defi-carte.active { border-color: rgba(16, 185, 129, 0.7); background: rgba(16, 185, 129, 0.15); }
.defi-carte.gagne { border-color: rgba(16, 185, 129, 0.5); cursor: default; }
.defi-carte.gagne:hover { transform: none; background: rgba(255, 255, 255, 0.07); border-color: rgba(16, 185, 129, 0.5); }
.defi-carte-icone { font-size: 2rem; margin-bottom: 8px; }
.defi-carte h3 { font-size: 1rem; font-weight: 700; color: #6ee7b7; margin-bottom: 4px; }
.defi-carte .dims { font-size: 0.78rem; color: #64748b; margin-bottom: 8px; }
.defi-carte .defi-statut {
  font-size: 0.82rem; font-weight: 600; padding: 4px 12px; border-radius: 8px; display: inline-block;
}
.defi-statut.non-tente { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.defi-statut.en-cours { background: rgba(234, 179, 8, 0.2); color: #fbbf24; }
.defi-statut.gagne { background: rgba(16, 185, 129, 0.2); color: #34d399; }

/* Non connecté */
.non-connecte {
  text-align: center; padding: 40px 20px;
  background: rgba(255, 255, 255, 0.06); border-radius: 16px; margin-bottom: 32px;
}
.non-connecte p { color: #94a3b8; margin-bottom: 16px; font-size: 0.95rem; }

/* « Déjà un compte ? Se connecter » sous le bouton d'inscription (audit plateforme du 01/11/2026) */
.non-connecte .non-connecte-deja { margin: 14px 0 0; font-size: 0.9rem; }
.non-connecte-deja a { color: #c4b5fd; font-weight: 600; }

.btn {
  font-family: 'Inter', sans-serif; font-size: 0.9rem; font-weight: 700;
  padding: 10px 24px; border: none; border-radius: 10px; cursor: pointer;
  color: #fff; text-decoration: none; display: inline-block;
  transition: transform 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: #059669; box-shadow: none; }

/* Zone de jeu */
#zone-jeu { display: none; margin-bottom: 32px; }
.jeu-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.jeu-info { font-size: 0.85rem; color: #94a3b8; }
.jeu-timer { font-size: 1.2rem; font-weight: 700; color: #34d399; font-variant-numeric: tabular-nums; }
.coups-defi { font-size: 0.9rem; font-weight: 700; color: #6ee7b7; }

/* Grille Taquin */
.grid-container {
  display: inline-block;
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  gap: 6px;
}

.cell {
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
}

.cell.numbered {
  background: linear-gradient(145deg, rgba(52,211,153,0.35), rgba(16,185,129,0.25));
  border: 1px solid rgba(52,211,153,0.3);
  color: #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.cell.numbered:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 16px rgba(52,211,153,0.3);
}

.cell.empty {
  background: rgba(255, 255, 255, 0.03);
  border: 2px dashed rgba(255,255,255,0.08);
  cursor: default;
}

.cell.correct {
  background: linear-gradient(145deg, rgba(34,197,94,0.4), rgba(22,163,74,0.3));
  border-color: rgba(34,197,94,0.5);
}

.cell.slide {
  animation: tile-slide 0.15s ease;
}
@keyframes tile-slide {
  0% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

/* Message fin */
.msg-fin {
  text-align: center; padding: 20px; margin-top: 16px; border-radius: 12px;
  font-size: 1.1rem; font-weight: 700; display: none;
}
.msg-fin.victoire { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }

/* Classement */
.classement-section { margin-top: 32px; }
.classement-section h2 { font-size: 1.2rem; font-weight: 700; color: #6ee7b7; text-align: center; margin-bottom: 16px; }
.onglets-diff { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.onglet-diff {
  font-family: 'Inter', sans-serif; font-size: 0.82rem; font-weight: 600;
  padding: 8px 16px; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 10px;
  cursor: pointer; background: rgba(255, 255, 255, 0.06); color: #cbd5e1; transition: all 0.2s;
}
.onglet-diff:hover { background: rgba(255, 255, 255, 0.12); }
.onglet-diff.active { background: rgba(16, 185, 129, 0.3); border-color: rgba(16, 185, 129, 0.6); color: #6ee7b7; }

.podium { display: flex; justify-content: center; gap: 16px; margin-bottom: 16px; }
.podium-item { text-align: center; padding: 16px; background: rgba(255, 255, 255, 0.06); border-radius: 12px; min-width: 100px; }
.podium-rang { font-size: 1.5rem; margin-bottom: 4px; }
.podium-pseudo { font-size: 0.85rem; font-weight: 700; color: #6ee7b7; }
.podium-score { font-size: 0.78rem; color: #94a3b8; margin-top: 2px; }

.classement-liste { max-width: 500px; margin: 0 auto; }
.classement-ligne {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-size: 0.85rem;
}
.classement-rang { color: #64748b; width: 30px; }
.classement-pseudo { flex: 1; color: #e0e0e0; font-weight: 600; }
.classement-score-val { color: #34d399; font-weight: 700; font-variant-numeric: tabular-nums; }
.classement-vide { text-align: center; color: #64748b; font-style: italic; padding: 20px; font-size: 0.85rem; }

.lien-classement { display: block; text-align: center; margin-top: 16px; color: #34d399; text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.lien-classement:hover { color: #6ee7b7; }

.confetti {
  position: fixed;
  top: -10px;
  z-index: 200;
  pointer-events: none;
  font-size: 1.2rem;
  animation: confetti-fall 3s ease-in forwards;
}
@keyframes confetti-fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

footer { font-size: 0.78rem; color: #64748b; margin-top: 32px; text-align: center; }
footer a { color: #34d399; text-decoration: none; }
footer a:hover { color: #6ee7b7; }

@media (max-width: 480px) {
  #app { padding: 24px 14px 20px; border-radius: 18px; }
  .header h1 { font-size: 1.5rem; }
  .defi-carte { width: 100%; }
  .podium { flex-direction: column; align-items: center; }
}
