:root {
  color-scheme: light;
  --light-square: #f0d9b5;
  --dark-square: #b58863;
  --selected: rgba(250, 204, 21, .72);
  --target: rgba(22, 101, 52, .72);
  --ink: #25221e;
  --panel: #fffdf8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: #e9e4dc;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.app {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(12px, 2vw, 24px);
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(220px, 285px);
  align-items: center;
  gap: clamp(16px, 2.5vw, 32px);
}
.board-panel { min-width: 0; }
.board {
  width: min(100%, calc(100vh - 100px));
  aspect-ratio: 1;
  margin-inline: auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  border: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.16);
  background-image: url("assets/board.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  user-select: none;
  touch-action: manipulation;
}
.square {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  aspect-ratio: auto;
}
.square.light,
.square.dark {
  background: transparent;
}
.square.selected { box-shadow: inset 0 0 0 5px var(--selected); }
.square.last-move { box-shadow: inset 0 0 0 4px rgba(250, 204, 21, .38); }
.square.target::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--target);
  pointer-events: none;
}
.square.target.has-piece::after {
  width: 84%; height: 84%;
  background: transparent;
  border: 5px solid var(--target);
}
.piece {
  display: block;
  width: 92%;
  height: 92%;
  object-fit: contain;
  margin: auto;
  pointer-events: none;
  -webkit-user-drag: none;
}
.square.drag-source .piece { opacity: .25; }
.coord {
  position: absolute;
  z-index: 1;
  left: 3px;
  top: 1px;
  font-size: clamp(8px, 1vw, 12px);
  line-height: 1;
  font-weight: 700;
  pointer-events: none;
}
.light .coord { color: #876044; }
.dark .coord { color: #f4e6d4; }
.status {
  min-height: 1.5em;
  margin: 12px 2px 0;
  font-weight: 650;
  text-align: center;
}
.controls {
  background: var(--panel);
  border: 1px solid #d8cec0;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 8px 24px rgba(0,0,0,.07);
}
h1 { margin: 0; font-size: 1.8rem; }
.subtitle { margin: 2px 0 22px; color: #71685f; font-size: .9rem; }
label { display: block; font-weight: 650; margin-bottom: 7px; }
select, button {
  width: 100%;
  min-height: 44px;
  border: 1px solid #c9bbaa;
  border-radius: 9px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
  font: inherit;
}
select { margin-bottom: 12px; }
button { cursor: pointer; font-weight: 700; margin-top: 10px; }
button:hover:not(:disabled) { filter: brightness(.97); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: #5b3c29; color: white; border-color: #5b3c29; }
.info { min-height: 1.3em; color: #66584b; font-size: .9rem; }
.help { border-top: 1px solid #e4dbd0; margin-top: 20px; padding-top: 12px; }
h2 { margin: 0 0 8px; font-size: 1rem; }
.help p { font-size: .88rem; line-height: 1.4; margin: 6px 0; }
.error { min-height: 1em; color: #9b2626; font-size: .88rem; }
.asset-note { font-size: .8rem; color: #71685f; margin-bottom: 0; }
code { background: #eee8df; border-radius: 4px; padding: 2px 4px; }
@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .board { width: min(100%, calc(100vw - 28px)); }
  .controls { padding: 16px; }
  .subtitle { margin-bottom: 14px; }
}
