:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --bg-color: #f3f4f6;
  --board-light: #f0d9b5;
  --board-dark: #b58863;
  --highlight-path: rgba(79, 70, 229, 0.6);
  --highlight-start: rgba(34, 197, 94, 0.7);
  --highlight-end: rgba(239, 68, 68, 0.7);
  --text-color: #1f2937;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.container {
  background: white;
  padding: 2rem;
  border-radius: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

header {
  text-align: center;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}

header p {
  color: #6b7280;
}

.controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: flex-end;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.input-group label {
  font-size: 0.875rem;
  font-weight: 600;
}

.input-group input {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  width: 80px;
  text-align: center;
  text-transform: uppercase;
  font-weight: bold;
}

button {
  padding: 0.5rem 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.2s;
}

button:hover {
  background-color: var(--primary-hover);
}

button.secondary {
  background-color: #9ca3af;
}

button.secondary:hover {
  background-color: #6b7280;
}

.board-container {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}

.chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border: 5px solid #5c4033;
  user-select: none;
}

.square {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
}

.square.light {
  background-color: var(--board-light);
}

.square.dark {
  background-color: var(--board-dark);
}

.square.selected-start {
  background-color: var(--highlight-start) !important;
}

.square.selected-end {
  background-color: var(--highlight-end) !important;
}

.square.path {
  position: relative;
}

.square.path::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: var(--highlight-path);
  z-index: 1;
}

.square span {
  z-index: 2;
  /* Ensure piece is above highlight */
}

.square .coord {
  position: absolute;
  font-size: 0.6rem;
  color: rgba(0, 0, 0, 0.5);
  bottom: 2px;
  right: 2px;
}

.info-panel {
  background-color: #f9fafb;
  padding: 1.5rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
}

.info-panel h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.status {
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.875rem;
  color: #6b7280;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.path-sequence p {
  font-family: monospace;
  background: #e5e7eb;
  padding: 0.5rem;
  border-radius: 0.25rem;
  word-break: break-all;
}

footer {
  text-align: center;
  font-size: 0.875rem;
  color: #9ca3af;
  margin-top: auto;
}

/* Animation for path */
@keyframes popIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.knight-mark {
  animation: popIn 0.3s ease-out forwards;
}

.step-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  z-index: 3;
  animation: popIn 0.3s ease-out forwards;
}