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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 1rem;
}

/* Mobile: Réduire padding pour plus d'espace */
@media (max-width: 768px) {
  body {
    padding: 0.5rem;
  }
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

.header {
  text-align: center;
  color: white;
  margin-bottom: 2rem;
}

/* Mobile: Réduire la taille du header */
@media (max-width: 768px) {
  .header {
    margin-bottom: 0.5rem;
  }
  
  .header h1 {
    font-size: 1.5rem !important;
  }
  
  .header p {
    font-size: 0.85rem !important;
  }
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header p {
  font-size: 1.1rem;
  opacity: 0.9;
}

.game-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .game-layout {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
}

.board-container {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Mobile: Échiquier presque plein écran */
@media (max-width: 768px) {
  .board-container {
    padding: 0.5rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
  }
}

#chess-board {
  max-width: 600px;
  margin: 0 auto;
}

/* Mobile: Échiquier occupe presque tout l'écran */
@media (max-width: 768px) {
  #chess-board {
    max-width: 100%;
    width: 100%;
  }
}

.game-info {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Mobile: Réduire padding pour compacter */
@media (max-width: 768px) {
  .game-info {
    padding: 0.75rem;
    border-radius: 8px;
  }
}

.status-panel {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border-radius: 12px;
  margin-bottom: 1.5rem;
  text-align: center;
}

/* Mobile: Réduire l'espace */
@media (max-width: 768px) {
  .status-panel {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
  }
}

.status-panel h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  color: black;
}

.status-text {
  font-size: 1rem;
  opacity: 0.95;
  font-weight: 700;
  color: black;
}

/* Mobile: Labels plus petits */
@media (max-width: 768px) {
  .status-panel h3 {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
  }
  
  .status-text {
    font-size: 0.85rem;
  }
}

.controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.btn {
  flex: 1;
  min-width: 120px;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: black;
}

/* Mobile: Boutons plus compacts */
@media (max-width: 768px) {
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    min-width: 90px;
  }
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: black;
  font-weight: 700;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
  background: #f3f4f6;
  color: black;
  font-weight: 700;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

.btn-danger {
  background: #ef4444;
  color: black;
  font-weight: 700;
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 5px 15px rgba(239, 68, 68, 0.4);
}

.coach-section {
  border-top: 2px solid #e5e7eb;
  padding-top: 1.5rem;
}

/* Mobile: Réduire l'espace */
@media (max-width: 768px) {
  .coach-section {
    padding-top: 0.5rem;
  }
}

.coach-section h3 {
  font-size: 1.1rem;
  color: black;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Mobile: Titre plus compact */
@media (max-width: 768px) {
  .coach-section h3 {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
  }
}

.coach-advice {
  background: #f9fafb;
  border-left: 4px solid #667eea;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  min-height: 100px;
  max-height: 300px;
  overflow-y: auto;
}

/* Mobile: Réduire hauteur */
@media (max-width: 768px) {
  .coach-advice {
    padding: 0.5rem;
    min-height: 60px;
    max-height: 150px;
  }
}

.coach-advice.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  color: black;
  font-weight: 700;
}

.coach-advice p {
  line-height: 1.6;
  color: black;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.coach-advice strong {
  color: black;
  font-weight: 700;
}

.move-history {
  margin-top: 1.5rem;
}

/* Mobile: Compacter */
@media (max-width: 768px) {
  .move-history {
    margin-top: 0.5rem;
  }
}

.move-history h4 {
  font-size: 1rem;
  color: black;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

/* Mobile: Titre plus petit */
@media (max-width: 768px) {
  .move-history h4 {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
  }
}

.moves-list {
  background: #f9fafb;
  border-radius: 8px;
  padding: 1rem;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
}

/* Mobile: Réduire hauteur */
@media (max-width: 768px) {
  .moves-list {
    padding: 0.5rem;
    max-height: 100px;
    font-size: 0.75rem;
  }
}

.moves-list .move-pair {
  margin-bottom: 0.5rem;
  color: black;
  font-weight: 700;
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f4f6;
  border-top-color: #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-message {
  background: #fee2e2;
  color: black;
  font-weight: 700;
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  border-left: 4px solid #dc2626;
}

/* Chessboard customization */
.chess-board {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* Contour noir sur chaque case */
.square-55d63 {
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  border: 1px solid black !important;
  box-sizing: border-box;
}

.square-55d63:active {
  transform: scale(0.95);
}

/* Prevent page scroll on mobile when interacting with board */
#chess-board {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Analysis section */
.analysis-section {
  margin-top: 1.5rem;
  border-top: 2px solid #e5e7eb;
  padding-top: 1.5rem;
}

.evaluation-bar {
  height: 24px;
  background: #1f2937;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1rem;
  position: relative;
}

.evaluation-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  transition: width 0.3s ease;
}

.evaluation-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
}

/* Responsive adjustments for iOS 16 */
@media (max-width: 768px) {
  .header h1 {
    font-size: 2rem;
  }
  
  .game-layout {
    gap: 1rem;
  }
  
  .board-container,
  .game-info {
    padding: 1rem;
  }
  
  #chess-board {
    max-width: 100%;
  }
}


/* ==================== MODAL NIVEAU ==================== */

.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s ease;
}

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

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

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h2 {
  color: #1f2937;
  font-weight: 700;
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.modal-content h2 i {
  color: #667eea;
  margin-right: 0.5rem;
}

.modal-subtitle {
  color: #6b7280;
  font-weight: 600;
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.level-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 1rem 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 80px;
}

.level-btn span {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.9;
}

.level-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.level-btn:active {
  transform: translateY(0) scale(0.98);
}

.level-btn[data-level="1"], .level-btn[data-level="2"] {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.level-btn[data-level="3"], .level-btn[data-level="4"] {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.level-btn[data-level="5"], .level-btn[data-level="6"] {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.level-btn[data-level="7"], .level-btn[data-level="8"] {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.level-btn[data-level="9"], .level-btn[data-level="10"] {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.level-display {
  margin-top: 0.75rem;
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  font-weight: 700;
  text-align: center;
  font-size: 0.95rem;
}

.level-display i {
  margin-right: 0.5rem;
}

/* Mobile: modal responsive */
@media (max-width: 768px) {
  .level-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .modal-content {
    padding: 1.5rem;
  }
  
  .modal-content h2 {
    font-size: 1.5rem;
  }
}


/* ==================== MOBILE TOUCH IMPROVEMENTS ==================== */

/* Empêcher la sélection de texte sur les cases */
.square-55d63 {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}

/* Feedback visuel au toucher (mobile) */
@media (max-width: 768px) {
  .square-55d63:active {
    opacity: 0.8;
    transform: scale(0.95);
    transition: all 0.1s ease;
  }
}

/* Améliorer la zone de toucher pour les pièces */
.square-55d63 img {
  pointer-events: none; /* Les clics passent à travers l'image vers la case */
}

