:root {
  font-family: "Poppins", "Segoe UI", sans-serif;
  color: #12263a;
  background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 40%, #84fab0 100%);
}

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

body {
  margin: 0;
  min-height: 100vh;
}

#root {
  min-height: 100vh;
}

:root {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-x: #2dd4bf;
  /* Turquoise */
  --accent-o: #fb7185;
  /* Rose */
  --cell-bg: #334155;
  --cell-hover: #475569;
}

.center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.ttt-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: var(--bg-color);
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text-main);
  padding: 20px;
}

.ttt-card {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.ttt-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  font-weight: 800;
  background: linear-gradient(to right, var(--accent-x), var(--accent-o));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ttt-status {
  margin-bottom: 1.5rem;
  font-weight: 500;
  color: var(--text-muted);
  height: 1.5rem;
}

/* La Grille Responsive */
.ttt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 2rem;
}

.ttt-cell {
  aspect-ratio: 1 / 1;
  /* Garde la case carrée */
  background: var(--cell-bg);
  border: none;
  border-radius: 0.75rem;
  font-size: 2.5rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ttt-cell:hover:not(:disabled) {
  background: var(--cell-hover);
  transform: translateY(-2px);
}

.ttt-cell:disabled {
  cursor: default;
}

/* Couleurs des symboles */
.ttt-X {
  color: var(--accent-x);
  text-shadow: 0 0 15px rgba(45, 212, 191, 0.4);
}

.ttt-O {
  color: var(--accent-o);
  text-shadow: 0 0 15px rgba(251, 113, 133, 0.4);
}

/* Conteneur pour s'assurer que la ligne ne déborde pas de la grille */
.ttt-grid-container {
  position: relative;
  width: 100%;
}

.ttt-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  stroke: var(--text-muted);
  stroke-width: 2;
  fill: none;
}

.win-line {
  position: absolute;
  background-color: var(--text-main);
  border-radius: 10px;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
  /* Animation d'apparition */
  animation: grow 0.3s ease-out forwards;
}

/* --- LIGNES HORIZONTALES --- */
/* On centre sur 1/6, 3/6 (50%) et 5/6 de la hauteur totale */
.win-line.h-1 {
  top: calc(100% / 6.3);
  left: 5%;
  width: 90%;
  height: 6px;
  transform: translateY(-50%);
}

.win-line.h-2 {
  top: 50.5%;
  left: 5%;
  width: 90%;
  height: 6px;
  transform: translateY(-50%);
}

.win-line.h-3 {
  top: calc(500% / 5.875);
  left: 5%;
  width: 90%;
  height: 6px;
  transform: translateY(-50%);
}

/* --- LIGNES VERTICALES --- */
.win-line.v-1 {
  left: calc(93% / 6);
  top: 5%;
  height: 90%;
  width: 6px;
  transform: translateX(-50%);
}

.win-line.v-2 {
  left: 50%;
  top: 5%;
  height: 90%;
  width: 6px;
  transform: translateX(-50%);
}

.win-line.v-3 {
  left: calc(500% / 5.92);
  top: 5%;
  height: 90%;
  width: 6px;
  transform: translateX(-50%);
}

/* --- DIAGONALES --- */
/* Pour les diagonales, on part du centre exact d'un coin vers l'autre */
.win-line.d-1 {
  top: 0;
  left: 0;
  width: 141%;
  height: 6px;
  /* 141% = hypoténuse d'un carré de 100 */
  transform: rotate(45deg);
  transform-origin: top left;
}

.win-line.d-2 {
  top: 0;
  right: 0;
  width: 141%;
  height: 6px;
  transform: rotate(-45deg);
  transform-origin: top right;
}

.ttt-board {
  position: relative;
  width: 300px;
  height: 300px;
  margin: 2rem auto;
}

@keyframes grow {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(-50%);
  }

  /* Ajuste selon le type si besoin */
  to {
    opacity: 1;
    scale: 1;
  }
}

.menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #0B132B;
  padding: 30px;
  border-radius: 0px;
  justify-content: center;
  text-align: center;
  align-items: center;
}

.playAgainst {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  gap: 20px;
}

.cell {
  transition: background 0.3s;
}

.menu {
  z-index: 10;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
}

#message {
  height: 30px;
  margin: 10px;
  font-size: 1.5rem;
  color: #00D4FF;
}

/* =========================================
   BOUTON PARAMÈTRES (Principal)
   ========================================= */
#settings {
  width: 100%;
  padding: 0.75rem;
  margin-top: 0.75rem;
  /* Espace avec le bouton Recommencer */
  border-radius: 0.75rem;
  border: 1px solid var(--text-muted);
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

#settings:hover {
  background: var(--cell-hover);
  color: var(--text-main);
  border-color: var(--text-main);
}

/* =========================================
   MENU SUPERPOSÉ (Modal)
   ========================================= */
.menu {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card-bg);
  /* Cohérent avec la carte principale */
  padding: 2.5rem 2rem;
  border-radius: 1.5rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.1);
  text-align: center;
  z-index: 100;
  width: 90%;
  max-width: 320px;
}

.menu h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.playAgainst>div {
  position: relative;
  flex: 1;
  /* Les deux boutons prennent la même largeur */
}

/* Cacher l'input radio classique */
.playAgainst input[type="radio"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.playAgainst label:hover {
  background: var(--cell-hover);
  color: var(--text-main);
}

/* État Actif (Quand le radio est coché) */
.playAgainst input[type="radio"]:checked+label {
  background: rgba(45, 212, 191, 0.1);
  /* Fond légèrement turquoise */
  color: var(--accent-x);
  border: 2px solid var(--accent-x);
  box-shadow: 0 0 15px rgba(45, 212, 191, 0.2);
}

#startGame {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: none;
  background: linear-gradient(to right, var(--accent-x), #3b82f6);
  /* Dégradé turquoise vers bleu */
  color: #000;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

#startGame:hover {
  opacity: 0.9;
}

#startGame:active {
  transform: scale(0.98);
  /* Petit effet d'enfoncement au clic */
}

/* =========================================
   BOUTONS PRINCIPAUX (Commencer & Recommencer)
   ========================================= */
.ttt-reset,
#startGame {
  width: 100%;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: none;
  /* Le dégradé stylé */
  background: linear-gradient(to right, var(--accent-x), #3b82f6);
  color: #12263a;
  /* Texte foncé pour le contraste */
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  display: block;
  margin-bottom: 10px;
}

.ttt-reset:hover,
#startGame:hover {
  opacity: 0.9;
}

.ttt-reset:active,
#startGame:active {
  transform: scale(0.98);
}

.playAgainst label {
  display: block;
  width: 100%;
  /* Remplit tout le conteneur flex */
  padding: 0.75rem 0;
  /* Padding vertical uniquement */
  text-align: center;
  /* Centre le texte (Homme / IA) */
  background: var(--cell-bg);
  color: var(--text-muted);
  border-radius: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  white-space: nowrap;
  /* Évite que le texte ne saute de ligne */
}

/* État coché */
.playAgainst input[type="radio"]:checked+label {
  background: rgba(45, 212, 191, 0.1);
  color: var(--accent-x);
  border: 2px solid var(--accent-x);
  box-shadow: 0 0 15px rgba(45, 212, 191, 0.2);
}

/* On cache l'input radio par défaut */
.playAgainst input[type="radio"] {
  display: none;
}

#loader {
  display: flex;
  flex-direction: column;
  text-align: center;
  justify-content: center;
  align-items: center;
  position: absolute;
  width: 100vh;
  height: 100vh;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 10px;
  background: var(--bg-color);
  border-radius: 10px;
  z-index: 999;
  display: none;
}

#loading-detail {
  color: gray;
}
