:root {
  --light: #f0d9b5;
  --dark: #b58863;
  --bg: #1f2124;
  --panel: #2a2d31;
  --accent: #7c9473;
  --text: #e8e6e3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  padding: 1rem;
}

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

.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.controls {
  display: flex;
  gap: 0.5rem;
}

.controls button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #444;
  border-radius: 6px;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
}

.controls button:hover { background: #3a3d42; }
.controls button:disabled { opacity: 0.4; cursor: default; }

#undoBtn, #redoBtn {
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.4rem 0.9rem;
}

#suggestBtn.active { background: var(--accent); color: #16201a; border-color: var(--accent); }
#suggestBtn.active:hover { background: #8ba682; }

.board-frame {
  position: relative;
}

.eval-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 10;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: rgba(20, 21, 23, 0.85);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.eval-badge.eval-positive { color: #9fd88f; }
.eval-badge.eval-negative { color: #e08a7d; }
.eval-badge.eval-neutral { color: var(--text); }

.arrow-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.best-move-arrow {
  stroke: rgba(255, 176, 59, 0.9);
  stroke-width: 0.06;
  stroke-linecap: round;
}

.arrowhead-fill { fill: rgba(255, 176, 59, 0.9); }

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(560px, 88vw);
  height: min(560px, 88vw);
  border: 4px solid var(--panel);
  border-radius: 4px;
  overflow: hidden;
  touch-action: none;
}

.square {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

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

.piece {
  font-size: clamp(24px, 7vw, 48px);
  line-height: 1;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.piece-w {
  color: #fafafa;
  -webkit-text-stroke: 0.5px #1a1a1a;
}

.piece-b {
  color: #0a0a0a;
  -webkit-text-stroke: 0.5px #fafafa;
}

.piece.dragging-source { opacity: 0.25; }

.piece.ghost {
  position: fixed;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
  cursor: grabbing;
}

.hint {
  max-width: min(560px, 88vw);
  text-align: center;
  font-size: 0.85rem;
  color: #9a9a9a;
  margin: 0;
}

.tray {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--panel);
  border-radius: 8px;
  flex-shrink: 0;
  justify-content: center;
}

.tray-piece {
  font-size: clamp(22px, 5vw, 36px);
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.tray-piece:hover { filter: brightness(1.3); }
