/* Base styles */
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

#app {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  margin-top: 0;
  font-size: 2rem;
  text-align: center;
}

.subheading {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #555;
}

/* Layout for game container */
#game-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

/* Chessboard styling */
#board {
  width: 400px;
  height: 400px;
  max-width: 90vw;
  max-height: 90vw;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
}

/* Individual squares */
.square {
  position: relative;
  width: 100%;
  height: 100%;
}
.white-square {
  background-color: #f0d9b5;
  color: #b58863;
}
.black-square {
  background-color: #b58863;
  color: #f0d9b5;
}
.square img {
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

/* Controls panel */
.controls {
  flex: 1 1 280px;
  background-color: #ffffff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-width: 320px;
}

.controls h2,
.controls h3 {
  margin-top: 0;
}

.form-group {
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.form-group select,
.form-group input {
  padding: 0.4rem;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

button {
  display: inline-block;
  padding: 0.5rem 0.75rem;
  margin-right: 0.5rem;
  margin-top: 0.5rem;
  background-color: #1976d2;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

button:hover {
  background-color: #1565c0;
}

button:disabled {
  background-color: #9e9e9e;
  cursor: not-allowed;
}

.start-button {
  background-color: #388e3c;
}

.start-button:hover {
  background-color: #2e7d32;
}

/* Instruction table */
#instructions-list {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

#instructions-list th,
#instructions-list td {
  border: 1px solid #ddd;
  padding: 0.25rem 0.4rem;
  text-align: left;
}

#instructions-list thead {
  background-color: #eee;
}

/* Evaluation bar */
#eval-bar-container {
  width: 100%;
  height: 20px;
  border: 1px solid #ccc;
  margin-top: 1rem;
  background: linear-gradient(90deg, #ffffff 50%, #000000 50%);
  position: relative;
}

#eval-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background-color: #1976d2;
  width: 50%;
  transition: width 0.5s ease;
}

/* Log area */
.log {
  margin-top: 1rem;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 0.5rem;
  height: 150px;
  overflow-y: auto;
  font-size: 0.85rem;
}

.log p {
  margin: 0.25rem 0;
  line-height: 1.3;
}

/* Highlight selected squares on the chessboard */
.selected-square {
  box-shadow: inset 0 0 0 3px #ffa726;
}

/* Highlight target square or piece */
.target-square {
  box-shadow: inset 0 0 0 3px #66bb6a;
}

/* Highlight squares that already have instructions */
.instructed-square {
  box-shadow: inset 0 0 0 3px rgba(255, 193, 7, 0.6);
}

/* Action buttons styling */
.action-btn {
  flex: 1 1 45%; /* Allow two buttons per row */
  margin: 0.25rem;
}

#action-attack { background-color: #d32f2f; }
#action-attack:hover { background-color: #c62828; }
#action-defend { background-color: #1976d2; }
#action-defend:hover { background-color: #1565c0; }
#action-hold { background-color: #616161; }
#action-hold:hover { background-color: #424242; }
#action-evade { background-color: #388e3c; }
#action-evade:hover { background-color: #2e7d32; }

#target-selection-buttons button {
  flex: 1 1 45%;
  margin: 0.25rem;
  background-color: #757575;
}
#target-selection-buttons button:hover {
  background-color: #616161;
}

/* Highlighting for pieces with instructions, by order type */
.instructed-attack { box-shadow: inset 0 0 0 3px #d32f2f; }
.instructed-defend { box-shadow: inset 0 0 0 3px #1976d2; }
.instructed-hold { box-shadow: inset 0 0 0 3px #616161; }
.instructed-evade { box-shadow: inset 0 0 0 3px #388e3c; }
