:root {
  --bg-color: #0d1117;
  --panel-bg: rgba(22, 27, 34, 0.75);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(255, 255, 255, 0.25);
  
  --color-x: #00f2fe;
  --color-x-glow: rgba(0, 242, 254, 0.4);
  --color-x-dark: rgba(0, 242, 254, 0.12);
  
  --color-o: #ff007f;
  --color-o-glow: rgba(255, 0, 127, 0.45);
  --color-o-dark: rgba(255, 0, 127, 0.12);
  
  --color-tie: #f59e0b;
  --color-tie-glow: rgba(245, 158, 11, 0.4);
  
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Poppins', sans-serif;
  
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Arrière-plan animé */
.background-blobs {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}

.blob {
  position: absolute;
  filter: blur(90px);
  opacity: 0.35;
  border-radius: 50%;
  animation: float 14s infinite alternate ease-in-out;
}

.blob-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #00f2fe, #4facfe);
  top: -10%;
  left: -10%;
}

.blob-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #ff0844, #ffb199);
  bottom: -15%;
  right: -10%;
  animation-delay: -5s;
}

.blob-3 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #7928ca, #ff0080);
  top: 45%;
  left: 45%;
  transform: translate(-50%, -50%);
  animation-duration: 20s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.1); }
  100% { transform: translate(-30px, -40px) scale(0.95); }
}

/* Canvas Confettis */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 100;
}

/* Application Container */
.app-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 480px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Header */
.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.title-container {
  flex-grow: 1;
  text-align: center;
}

h1 {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(255, 255, 255, 0.2);
}

h1 span {
  background: linear-gradient(135deg, var(--color-x), var(--color-o));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

.sound-toggle-btn {
  background: var(--panel-bg);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.25s ease;
  position: absolute;
  right: 0;
}

.sound-toggle-btn:hover {
  color: var(--text-main);
  border-color: var(--border-focus);
  transform: scale(1.06);
}

.icon {
  width: 20px;
  height: 20px;
}

.hidden {
  display: none !important;
}

/* Contrôles et options */
.controls-panel {
  width: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.25s ease;
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.difficulty-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.difficulty-container select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.difficulty-container select:focus {
  border-color: var(--color-x);
}

/* Scoreboard */
.scoreboard {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 0.8fr 1fr;
  gap: 12px;
}

.score-card {
  background: var(--panel-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  position: relative;
  overflow: hidden;
}

.player-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.score-number {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
}

.card-x {
  border-bottom: 3px solid var(--color-x);
}

.card-x.active-turn {
  background: var(--color-x-dark);
  border-color: var(--color-x);
  box-shadow: 0 0 20px var(--color-x-glow);
  transform: translateY(-2px);
}

.card-o {
  border-bottom: 3px solid var(--color-o);
}

.card-o.active-turn {
  background: var(--color-o-dark);
  border-color: var(--color-o);
  box-shadow: 0 0 20px var(--color-o-glow);
  transform: translateY(-2px);
}

.card-ties {
  border-bottom: 3px solid var(--color-tie);
}

/* Symboles X et O */
.symbol-x {
  color: var(--color-x);
  text-shadow: 0 0 10px var(--color-x-glow);
  font-family: var(--font-heading);
  font-weight: 800;
}

.symbol-o {
  color: var(--color-o);
  text-shadow: 0 0 10px var(--color-o-glow);
  font-family: var(--font-heading);
  font-weight: 800;
}

/* Indicateur de tour */
.turn-indicator {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.current-turn-symbol {
  font-size: 1.1rem;
  display: inline-block;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Grille de jeu */
.board-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 380px;
  aspect-ratio: 1 / 1;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  padding: 14px;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  outline: none;
}

.cell:hover:not(.taken) {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-focus);
  transform: scale(0.97);
}

.cell.taken {
  cursor: not-allowed;
}

.cell.pop {
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
  0% { transform: scale(0.5); opacity: 0; }
  70% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.cell.winner-cell {
  background: rgba(255, 255, 255, 0.15) !important;
  animation: winningPulse 1.2s infinite alternate ease-in-out;
}

.cell.winner-cell.x {
  border-color: var(--color-x);
  box-shadow: inset 0 0 20px var(--color-x-glow), 0 0 25px var(--color-x-glow);
}

.cell.winner-cell.o {
  border-color: var(--color-o);
  box-shadow: inset 0 0 20px var(--color-o-glow), 0 0 25px var(--color-o-glow);
}

@keyframes winningPulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

/* Boutons d'actions */
.action-buttons {
  width: 100%;
  display: flex;
  gap: 12px;
}

.btn {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.25s ease;
  border: 1px solid transparent;
  outline: none;
}

.btn-svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-x), #0072ff);
  color: #fff;
  border: none;
  box-shadow: 0 4px 15px var(--color-x-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--color-x-glow);
}

/* Modale de résultat */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 150;
  animation: fadeIn 0.3s ease;
}

.modal-card {
  background: #161b22;
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  width: 90%;
  max-width: 360px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.modal-icon {
  font-size: 3.5rem;
  margin-bottom: 4px;
}

.modal-card h2 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.modal-actions {
  width: 100%;
}

.modal-actions button {
  width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Responsiveness */
@media (max-width: 420px) {
  .app-container {
    padding: 16px 12px;
    gap: 16px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .cell {
    font-size: 2.5rem;
  }

  .scoreboard {
    gap: 8px;
  }

  .score-number {
    font-size: 1.3rem;
  }
}

