/* --------- Layout général --------- */

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

body {
  margin: 0;
  padding: 20px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  background: radial-gradient(circle at top, #111827 0, #020617 55%, #000 100%);
  color: #e5e7eb;
}

/* Conteneur principal */

.main-layout {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

/* Panneaux (PGN, board, movelist) */

.pane {
  background: rgba(15, 23, 42, 0.96);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(148, 163, 184, 0.15);
  backdrop-filter: blur(12px);
}

.pgn-pane {
  max-width: 400px;
  flex: 1 1 280px;
}

.board-pane {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

/* --------- Zone PGN --------- */

#pgninput {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  width: 100%;
  resize: vertical;
  min-height: 480px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  padding: 10px 12px;
  background: #020617;
  color: #e5e7eb;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

#pgninput:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.65);
  background: #020617;
}

/* --------- Boutons --------- */

button {
  margin: 0;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: linear-gradient(135deg, #0f172a, #020617);
  color: #e5e7eb;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition:
    background 0.15s ease,
    transform 0.12s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

button:hover:not(:disabled) {
  background: radial-gradient(circle at top left, #1d4ed8, #020617 65%);
  border-color: #60a5fa;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.8);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

#controls {
  margin: 10px 0 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------- Loader --------- */

.loading {
  margin-bottom: 6px;
  font-size: 13px;
  color: #a5b4fc;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.loading::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid #6366f1;
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

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

/* --------- Info & debug --------- */

#info {
  min-height: 1.5em;
  font-weight: 600;
  color: #22c55e;
  font-size: 14px;
}

#debug {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  color: #9ca3af;
  font-size: 13px;
}

/* --------- Échiquier & captures --------- */

.chessground {
  width: 500px;
  height: 500px;
  margin-bottom: 10px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(100, 116, 139, 0.5);
}

/* Captured pieces */

.captured-line {
  display: flex;
  align-items: center;
  min-height: 24px;
  font-size: 18px;
  margin: 4px 0 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  color: #e5e7eb;
}

.captured-line span {
  margin-right: 6px;
}

.captured-line strong {
  margin-left: 4px;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(22, 163, 74, 0.1);
  color: #4ade80;
}

/* --------- Barre d'évaluation --------- */

#evalbar {
  width: 22px;
  height: 500px;
  background: linear-gradient(to bottom, #0b1120, #020617);
  margin-right: 6px;
  position: relative;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}

#evalfill {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: linear-gradient(to top, #e5e7eb, #f9fafb);
}

/* --------- Historique des coups --------- */

#movelist {
  max-height: 500px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  line-height: 1.5;
  margin-left: 6px;
  border-left: 1px solid rgba(75, 85, 99, 0.7);
  padding-left: 10px;
  font-size: 13px;
}

/* scroll discret */
#movelist::-webkit-scrollbar {
  width: 6px;
}

#movelist::-webkit-scrollbar-track {
  background: transparent;
}

#movelist::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.6);
  border-radius: 999px;
}

.moveRow {
  white-space: nowrap;
  margin-bottom: 2px;
}

.mnum {
  color: #6b7280;
  margin-right: 4px;
}

.mply {
  cursor: pointer;
  padding: 1px 4px;
  border-radius: 6px;
  transition:
    background 0.1s ease,
    color 0.1s ease,
    transform 0.08s ease;
}

.mply:hover {
  background: rgba(55, 65, 81, 0.9);
  color: #e5e7eb;
}

.mply.active {
  background: rgba(59, 130, 246, 0.18);
  color: #bfdbfe;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.6) inset;
}

/* Mauvais coups */

.mply.bad {
  color: #fecaca;
  font-weight: 600;
}

.mply.bad.active {
  background: rgba(220, 38, 38, 0.25);
  box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.7) inset;
}

/* Cercle rouge sur l’échiquier (Chessground) */

.cg-shape.red {
  fill: #ef4444;
  opacity: 0.7;
}

/* --------- Mate viewer --------- */

#mateViewer {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#mateBoard {
  width: 400px;
  height: 400px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(148, 163, 184, 0.4);
}

#mateControls {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

/* --------- Responsive --------- */

@media (max-width: 1024px) {
  .board-pane {
    justify-content: center;
  }

  .chessground {
    width: 420px;
    height: 420px;
  }

  #evalbar {
    height: 420px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  .chessground {
    width: 360px;
    height: 360px;
  }

  #evalbar {
    height: 360px;
  }

  .pgn-pane {
    max-width: 100%;
  }
}

