:root {
  --bg-color: #302e2b;
  --text-color: #ffffff;
  --board-light: #ebecd0;
  --board-dark: #779556;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  touch-action: manipulation;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  gap: 8px;
  padding: 10px;
  position: relative;
}

/* Controls */
.controls-bar {
  display: flex;
  gap: 5px;
  width: 100%;
  justify-content: space-between;
}
.icon-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 4px;
  background: #45423e;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  font-size: 13px;
}
.icon-btn:active {
  transform: scale(0.96);
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  width: 100%;
  background: #262421;
  padding: 8px 12px;
  border-radius: 4px;
  box-sizing: border-box;
}
.status-text {
  color: #fff;
  font-weight: bold;
  font-size: 14px;
}
.status-text.alert {
  color: #ff5555;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
}
.ai-text {
  color: #4cd137;
  font-size: 13px;
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 95vw;
  height: 95vw;
  max-width: 500px;
  max-height: 500px;
  border: 3px solid #333;
  user-select: none;
  background: #333;
  position: relative;
}
.board.flipped {
  transform: rotate(180deg);
}

/* --- BLINDFOLD MODE (New Feature) --- */
/* When this class is active, pieces become invisible */
.board.blindfold .piece {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.square {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
.square.light {
  background-color: var(--board-light);
}
.square.dark {
  background-color: var(--board-dark);
}

/* Highlights */
.square.selected {
  background-color: rgba(255, 255, 0, 0.5);
}
.square.best-move {
  box-shadow: inset 0 0 0 4px #00a8ff;
}
.square.check {
  background: radial-gradient(circle, #ff4444 0%, transparent 80%);
  box-shadow: inset 0 0 10px #ff0000;
}

/* Pieces */
.piece {
  width: 100%;
  height: 100%;
  font-size: clamp(24px, 8.5vw, 50px);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  z-index: 10;
  line-height: 1;
  font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif;
  pointer-events: auto;
  transition: opacity 0.3s; /* Smooth hide/show */
}
.board.flipped .piece {
  transform: rotate(180deg);
}
.piece.w {
  color: #fff;
  filter: drop-shadow(0 0 1px #000) drop-shadow(0 0 2px #000);
  text-shadow: 0 0 2px #000;
}
.piece.b {
  color: #000;
}

.dragging-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  font-size: 50px;
  opacity: 0.9;
  transform: translate(-50%, -50%);
}

/* Coordinates */
.coord-num {
  position: absolute;
  font-size: 9px;
  font-weight: bold;
  color: #333;
  pointer-events: none;
}
.square.dark .coord-num {
  color: #eee;
}
.coord-tl {
  top: 1px;
  left: 1px;
}
.coord-tr {
  top: 1px;
  right: 1px;
}
.coord-bl {
  bottom: -1px;
  left: 1px;
}
.coord-br {
  bottom: -1px;
  right: 1px;
}

/* Spares */
.spares-area {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: #262421;
  padding: 5px;
  border-radius: 6px;
  width: 100%;
}
.spare-row {
  display: flex;
  justify-content: space-around;
}
.spare-piece {
  font-size: clamp(28px, 8vw, 40px);
  width: clamp(32px, 10vw, 45px);
  height: clamp(32px, 10vw, 45px);
  display: flex;
  justify-content: center;
  align-items: center;
}

.hint-dot {
  position: absolute;
  width: 25%;
  height: 25%;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 50%;
  pointer-events: none;
}
.capture-ring {
  position: absolute;
  width: 85%;
  height: 85%;
  border: 5px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  pointer-events: none;
}

/* MODALS */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}
.modal-content {
  background: #262421;
  border: 2px solid #779556;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  color: white;
  min-width: 250px;
}
.modal-content h2 {
  margin-top: 0;
  color: #ff5555;
}
.close-btn {
  background: #555;
  margin-top: 15px;
}

.promo-options {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.promo-btn {
  background: #444;
  border: 2px solid #666;
  border-radius: 5px;
  width: 50px;
  height: 50px;
  font-size: 35px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}
.promo-btn:hover {
  background: #666;
  border-color: #fff;
}
