:root {
  --bg: #0f1115; --panel: #181b22; --line: #2a2f3a;
  --ink: #e7e9ee; --muted: #8b93a5; --accent: #7c9cff; --accent2: #59e0b8;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  display: flex; justify-content: center; padding: 32px 16px;
}
.wrap { width: 100%; max-width: 1000px; }
header h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.01em; }
header p { margin: 0 0 24px; color: var(--muted); }
a.back {
  display: inline-flex; align-items: center; gap: 8px; color: var(--ink);
  text-decoration: none; font-size: 15px; font-weight: 600; margin-bottom: 20px;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); transition: border-color .15s ease, transform .05s ease;
}
a.back:hover { border-color: var(--accent); transform: translateX(-2px); }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 20px; margin-bottom: 18px;
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.setupRow { justify-content: space-between; }
button {
  font: inherit; font-weight: 600; color: #0b0d12; background: var(--accent);
  border: 0; border-radius: 10px; padding: 11px 18px; cursor: pointer;
  transition: transform .05s ease, opacity .15s ease;
}
button:hover { transform: translateY(-1px); }
button.primary {
  background: linear-gradient(90deg, var(--accent2), var(--accent));
  color: #0b0d12; font-size: 15px; padding: 12px 22px;
}
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 10px; margin: 0; }
legend { color: var(--muted); font-size: 12.5px; padding: 0 4px; }
label.pick { display: block; font-size: 14px; padding: 3px 0; cursor: pointer; }
label.pick input { margin-right: 6px; }

.layout { display: grid; grid-template-columns: minmax(300px, 480px) 1fr; gap: 18px; align-items: start; }
.sidebar { display: flex; flex-direction: column; gap: 18px; }
.rulesCard h3, .moveCard h3 { margin: 0 0 10px; font-size: 15px; }
.rulesList { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.rulesList li { margin-bottom: 6px; }
.rulesList li::marker { color: var(--accent); }

.status { min-height: 20px; margin-bottom: 12px; font-size: 14.5px; font-weight: 600; }

.boardWrap { position: relative; display: flex; justify-content: center; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  width: min(100%, 440px); aspect-ratio: 1 / 1; border: 2px solid var(--line);
  border-radius: 8px; overflow: hidden; user-select: none;
}
.sq {
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transition: background-color .1s ease;
}
.sq.light { background: #ecdfc0; }
.sq.dark { background: #769656; }
.sq.selected { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.sq.target::after {
  content: ""; position: absolute; width: 26%; height: 26%; border-radius: 50%;
  background: var(--accent2); opacity: .75; z-index: 1;
}
.sq.target.capture::after {
  width: 82%; height: 82%; border-radius: 50%; background: transparent;
  border: 4px solid var(--danger); opacity: .85;
}

/* Real piece artwork (Cburnett set, see footer credit) — sidesteps every
   font/glyph-rendering problem entirely since it's just an image. */
.piece {
  width: 82%; height: 82%; position: relative; z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
}

.coord {
  position: absolute; bottom: 2px; left: 4px; font-size: 9px; font-weight: 600;
  pointer-events: none; user-select: none;
}
.sq.light .coord { color: rgba(0, 0, 0, .38); }
.sq.dark .coord { color: rgba(255, 255, 255, .4); }

.promoPicker {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  display: flex; gap: 8px; background: var(--panel); border: 1px solid var(--accent);
  border-radius: 12px; padding: 10px; z-index: 2; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
.promoPicker.hidden { display: none; }
.promoPicker button.promoBtn {
  width: 44px; height: 44px; border-radius: 8px; padding: 4px;
  background: var(--bg); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
}
.promoPicker button.promoBtn img { width: 100%; height: 100%; }
.promoPicker button.promoBtn:hover { transform: translateY(-2px); border-color: var(--accent); }

.moveLog { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 13.5px; }
.moveLog li { padding: 3px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.moveLog li.undo-note { color: var(--muted); font-style: italic; padding-left: 12px; }

.about { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.about h2 { font-size: 17px; margin: 0 0 10px; }
.about h3 { font-size: 14.5px; margin: 16px 0 6px; color: var(--accent2); }
.about p { color: var(--muted); font-size: 13.5px; margin: 0 0 10px; max-width: 720px; }

footer { color: var(--muted); font-size: 12.5px; text-align: center; margin-top: 8px; }
footer a { color: var(--muted); text-decoration: underline; }
footer a:hover { color: var(--accent); }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .setupRow { flex-direction: column; align-items: stretch; }
  .setupRow fieldset, .setupRow button { width: 100%; }
}
