/* Custom utility classes for color palette and theme */
.bg-wood {
  background-image: url("../assets/images/board.jpg");
}

.text-cream {
  color: #f5e5d8;
}

.text-heading {
  color: #d7b89e;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
}

.text-subheading {
  color: #c8b59e;
}

.bg-panel {
  background-color: #4e342e;
}

.border-panel {
  border-color: #6d4c41;
}

.text-green {
  color: #a1c990;
}

.text-red {
  color: #c98b94;
}

.text-blue {
  color: #8ba9c7;
}

.text-yellow {
  color: #d9c79e;
}

.text-orange {
  color: #d19e83;
}

.text-gray {
  color: #a0a0a0;
}

/* --- Base Styling --- */
body {
  background-color: #5d4037;
  color: #f5e5d8;
  min-height: 100vh;
}

/* --- Header and Titles --- */
.header-main {
  background-color: #4e342e;
  border-bottom: 2px solid #8d6e63;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.section-title {
  color: #d7b89e;
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #8d6e63;
}

/* --- Buttons and Controls --- */
.btn-action {
  background-color: #8d6e63;
  color: #f5e5d8;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  transition: all 0.2s ease;
  border: 2px solid #6d4c41;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn-action:hover {
  background-color: #9d7f72;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.btn-game {
  font-weight: bold;
  padding: 1rem 2rem;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
  border: 2px solid;
}

.btn-green {
  background-color: #a1c990;
  border-color: #7a9a6e;
  color: #333;
}

.btn-green:hover {
  background-color: #b1d9a0;
}

.btn-red {
  background-color: #c98b94;
  border-color: #9a6e76;
  color: #333;
}

.btn-red:hover {
  background-color: #d99ba4;
}

.btn-subtle {
  background-color: #6d4c41;
  border-color: #4e342e;
  color: #f5e5d8;
}

.btn-subtle:hover {
  background-color: #7d5c51;
}

.select-field {
  background-color: #4e342e;
  color: #f5e5d8;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 2px solid #6d4c41;
}

.control-box {
  background-color: #6d4c41;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 2px solid #4e342e;
}

/* --- Info Panels --- */
.info-panel {
  background-color: #4e342e;
  border: 2px solid #6d4c41;
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.stat-box {
  background-color: #6d4c41;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 2px solid #4e342e;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-green {
  border-color: #a1c990;
}

.stat-red {
  border-color: #c98b94;
}

.stat-blue {
  border-color: #8ba9c7;
}

.stat-purple {
  border-color: #9d83c7;
}

.stat-subtle {
  border-color: #d7b89e;
}

/* --- Turn Indicator --- */
.turn-indicator {
  background-color: #6d4c41;
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 2px solid #4e342e;
}

.turn-sente {
  color: #8ba9c7 !important;
}

.turn-gote {
  color: #c98b94 !important;
}

/* --- Board Styling --- */
.shogi-board-container {
  background-color: #c89666;
  padding: 2rem;
  border-radius: 1.5rem;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.4);
  border: 4px solid #8b5a2b;
}

.shogi-board-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
  background-color: #c89666;
  border-radius: 0.5rem;
  border: 2px solid #8b5a2b;
}

.board-square {
  aspect-ratio: 1;
  border: 1px solid #8b5a2b;
  position: relative;
  transition: all 0.2s ease-in-out;
  min-height: 48px;
}

.board-square:hover {
  background-color: rgba(200, 150, 102, 0.3) !important;
}

/* Selection and highlighting states */
.board-square.highlighted {
  background-color: rgba(161, 201, 144, 0.4) !important;
  box-shadow: inset 0 0 0 2px #a1c990;
}

.board-square.selected {
  background-color: rgba(139, 179, 204, 0.5) !important;
  box-shadow: inset 0 0 0 3px #8ba9c7;
  transform: scale(1.02);
}

.board-square.drop-zone {
  background-color: rgba(161, 201, 144, 0.3) !important;
  border: 2px dashed #a1c990;
}

/* --- Piece Styling and Animations --- */
.shogi-piece {
  font-size: 1.5rem;
  line-height: 1;
  transition: all 0.2s ease-in-out;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  font-weight: 900;
  cursor: grab;
  user-select: none;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shogi-piece:active {
  cursor: grabbing;
}

.shogi-piece.dragging {
  opacity: 0.7;
  transform: scale(1.1) rotate(5deg);
  z-index: 1000;
  pointer-events: none;
}

/* SVG piece styling */
.piece-svg {
  width: 36px;
  height: 42px;
  filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
  transition: all 0.2s ease;
}

.piece-svg:hover {
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.4));
  transform: scale(1.05);
}

/* Enhanced piece styling for better readability */
.piece-svg text {
  text-rendering: optimizeLegibility;
  font-variant: small-caps;
  letter-spacing: -0.5px;
}

/* Pieces with a more natural wood look and flat colors */
.shogi-piece .piece-svg path {
  fill: #f0e6d8 !important; /* Off-white wood tone */
  stroke: #4a4a4a !important;
}

.shogi-piece .piece-svg text {
  text-rendering: optimizeLegibility;
  font-variant: small-caps;
  letter-spacing: -0.5px;
  fill: #333 !important; /* Dark text for kanji */
}

/* Promoted pieces get a red fill instead of a golden border */
.shogi-piece[data-promoted="true"] .piece-svg text {
  fill: #dc143c !important;
}

/* Player vs AI piece distinction (more subtle) */
.shogi-piece[data-owner="sente"] .piece-svg {
  border-bottom: 2px solid #8ba9c7;
}

.shogi-piece[data-owner="gote"] .piece-svg {
  border-bottom: 2px solid #c98b94;
}

/* --- Captured Pieces Area --- */
.captured-area {
  min-height: 64px;
  border: 2px dashed #6d4c41;
  border-radius: 8px;
  padding: 16px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
  background-color: #4e342e;
}

/* Individual captured piece styling */
.captured-piece {
  flex-shrink: 0;
  width: 40px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.captured-piece .piece-svg {
  width: 32px;
  height: 38px;
}

/* --- Move History and Log Panels --- */
.log-panel {
  background-color: #4e342e;
  padding: 1rem;
  border-radius: 0.75rem;
  height: 20rem;
  overflow-y: auto;
  border: 2px solid #6d4c41;
}

.move-entry {
  padding: 0.25rem 0.5rem;
  margin: 0.125rem 0;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.move-entry:hover {
  background-color: #6d4c41;
  border-left-color: #d19e83;
}
