:root {
  --bg-color: #12151a;
  --card-bg: #1c2028;
  --card-border: #2d333f;
  --text-main: #f0f3f8;
  --text-muted: #8c96a8;
  --accent-green: #38b000;
  --accent-gold: #ffaa00;
  --square-light: #ebecd0;
  --square-dark: #739552;
  --square-selected: rgba(246, 235, 107, 0.7);
  --square-highlight: rgba(187, 203, 43, 0.6);
  --dot-color: rgba(20, 85, 30, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 12px;
}

.chess-card {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
.card-header {
  padding: 16px 20px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.sub-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.main-title {
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  margin-top: 2px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #d1d5db;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  transition: all 0.3s ease;
}

.status-dot.bot-thinking {
  background-color: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { opacity: 0.4; transform: scale(0.9); }
  100% { opacity: 1; transform: scale(1.2); }
}

/* Chess Board Wrapper */
.board-container {
  padding: 8px 16px 14px;
  display: flex;
  justify-content: center;
}

.chess-board {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  position: relative;
}

.square {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

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

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

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

.square.last-move {
  background-color: var(--square-highlight) !important;
}

/* Legal Move Dot Hint */
.legal-dot {
  position: absolute;
  width: 32%;
  height: 32%;
  background-color: var(--dot-color);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

.legal-capture {
  position: absolute;
  width: 90%;
  height: 90%;
  border: 4px solid var(--dot-color);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
}

/* Pieces */
.piece {
  width: 88%;
  height: 88%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  z-index: 2;
  transition: transform 0.1s ease;
  pointer-events: none;
}

.square:active .piece {
  transform: scale(0.92);
}

/* Notation labels (rank & file) */
.coord-rank {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.8;
}

.coord-file {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0.8;
}

.square.dark .coord-rank, .square.dark .coord-file {
  color: var(--square-light);
}

.square.light .coord-rank, .square.light .coord-file {
  color: var(--square-dark);
}

/* Footer Controls */
.card-footer {
  padding: 12px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid var(--card-border);
}

.log-status {
  font-size: 13px;
  color: #cbd5e1;
  text-align: center;
  min-height: 18px;
}

.btn-group {
  display: flex;
  gap: 10px;
}

.btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: #232832;
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn:hover {
  background: #2d3442;
  border-color: #475569;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}

.btn-primary:hover {
  background: #1d4ed8;
}
