:root {
  --light-square: #ebecd0;
  --dark-square: #739552;
  --panel-bg: #272522;
  --text-primary: #ffffff;
  --text-secondary: #bababa;
  --accent-green: #81b64c;
  --accent-green-dark: #5d8a34;
  --check-red: rgba(255, 45, 45, 0.85);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--page-bg);
  color: var(--text-primary);
  font-family: 'Segoe UI', Tahoma, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px;
}

.toolbar {
  display: flex;
  gap: 10px;
}

.toolbar button {
  background: var(--accent-green);
  border: none;
  border-bottom: 3px solid var(--accent-green-dark);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 6px;
  cursor: pointer;
}

.toolbar button:hover {
  filter: brightness(1.08);
}

.board-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.nav-btn {
  width: 46px;
  height: 34px;
  border-radius: 17px;
  border: none;
  background: #3d3d3d;
  color: #b0aca6;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.nav-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-btn:hover:not(:disabled) {
  background: #4b4b4b;
  color: #fff;
}

.nav-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.board {
  position: relative;
  width: min(92vmin, 560px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
  user-select: none;
  touch-action: none;
}

.square {
  position: relative;
}

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

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

.coord {
  position: absolute;
  font-size: clamp(8px, 1.9vmin, 13px);
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}

.coord.file {
  right: 4%;
  bottom: 3%;
}

.coord.rank {
  left: 5%;
  top: 4%;
}

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

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

/* Board overlay visuals (pieces, highlights, dots, rings, arrows, check) live in
   ../shared/board.css — single source of truth shared with analysis/board.html. */

/* ===== promotion picker (chess.com style: vertical column on the promotion square) ===== */
.promo-backdrop {
  position: absolute;
  inset: 0;
  z-index: 40;
  /* no dim: chess.com does NOT tint the board when the picker opens (bug 52) */
}
.promo-picker {
  position: absolute;
  z-index: 41;
  display: flex;
  flex-direction: column;
  background: #ffffff; /* APK: ColorDrawable(-1) — opaque pure white, square corners */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); /* APK: setElevation(16dp) shadow */
  overflow: hidden;
  -webkit-tap-highlight-color: transparent; /* bug 50: no blue flash when the picker opens under the finger */
}
.promo-choice {
  background-size: 78% 78%;
  background-repeat: no-repeat;
  background-position: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent; /* bug 50: 1:1 with drag-promo — no touch flash */
}
/* bug 50 follow-up (2026-08-28): on touch, Android sticks :hover onto the choice that
   was under the finger when the picker opened — a firm red tint on the QUEEN that drag
   promotion never shows. Real hover exists only on hover-capable pointers; tap-promo
   must match drag-promo 1:1 (user ruling). */
@media (hover: hover) {
  .promo-choice:hover {
    background-color: rgba(244, 42, 50, 0.25);
  }
}

/* APK spring placement: piece in flight above statics, NO css transition (rAF-driven) */
.piece.springing {
  z-index: 6;
  transition: none;
}
