:root {
  --ink: #1f2328;
  --muted: #59636e;
  --blue: #0757ba;
  --border: #e3e6ea;
  --sidebar-bg: #f6f7f9;
  --code-bg: #f6f8fa;
}

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

body {
  color: var(--ink);
  background: #fff;
  font: 16px/1.6 -apple-system, "Segoe UI", Roboto, Helvetica, sans-serif;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 30px; letter-spacing: -0.02em; margin: 0 0 4px; }
h2 { font-size: 21px; margin: 36px 0 10px; }
h3 { font-size: 17px; margin: 28px 0 8px; }
p { margin: 10px 0; }
ul, ol { margin: 10px 0 10px 28px; }
li { margin: 4px 0; }

code {
  font: 13.5px/1.5 ui-monospace, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

pre {
  font: 13.5px/1.5 ui-monospace, Menlo, Consolas, monospace;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
  margin: 14px 0;
  overflow-x: auto;
}

pre code { background: none; border: 0; padding: 0; font: inherit; }

pre b { font-weight: 700; }

table { border-collapse: collapse; margin: 14px 0; }
th, td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: left;
  font-size: 15px;
}
th { background: var(--sidebar-bg); }

.note {
  border: 1px solid var(--border);
  border-left: 3px solid var(--blue);
  border-radius: 4px;
  padding: 10px 16px;
  margin: 14px 0;
  font-size: 15px;
}

.lead { font-size: 17px; color: var(--muted); margin: 0 0 24px; }

.toc {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--sidebar-bg);
  padding: 12px 18px;
  margin: 18px 0 28px;
  font-size: 14px;
}
.toc ul { margin: 4px 0 0 22px; }
.toc ul ul { margin-top: 0; }
.toc li { margin: 2px 0; }

h2 .anchor, h3 .anchor { visibility: hidden; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { visibility: visible; }

footer { color: var(--muted); font-size: 14px; }

/* Home page */

body.home { max-width: 82ch; margin: 0 auto; padding: 40px 20px 60px; }
body.home nav { font-size: 15px; }
body.home nav a { margin-right: 18px; }
body.home hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }

.pawn-home {
  background: none;
  border: 0;
  padding: 24px 0 0;
  font-size: 15px;
}

/* Docs pages */

body.docs { display: flex; min-height: 100vh; }

aside {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

aside .name {
  display: block;
  font-weight: 700;
  font-size: 17px;
  color: var(--ink);
  padding: 0 24px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
aside .name:hover { text-decoration: none; }

aside h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 14px 24px 6px;
  margin: 0;
}

aside a.item {
  display: block;
  padding: 5px 24px;
  color: var(--ink);
  font-size: 14px;
}
aside a.item:hover { background: #eceef1; text-decoration: none; }
aside a.item.active {
  color: var(--blue);
  font-weight: 600;
  border-left: 3px solid var(--blue);
  padding-left: 21px;
  background: #eaf1fb;
}

body.docs main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { max-width: 900px; padding: 48px 48px 64px; flex: 1; width: 100%; }

.pawn-float {
  float: right;
  margin: 0 0 16px 32px;
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted);
}

body.docs footer { padding: 20px 48px; border-top: 1px solid var(--border); }

@media (max-width: 760px) {
  body.docs { flex-direction: column; }
  aside {
    position: static;
    width: auto;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
  }
  .content { padding: 32px 24px; }
  .pawn-float { display: none; }
}

/* Home page call to action */

.cta { margin: 20px 0 8px; }
.button {
  display: inline-block;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 6px;
}
.button:hover { text-decoration: none; background: #0649a0; }

/* Play page */

body.play { max-width: 1040px; margin: 0 auto; padding: 40px 20px 60px; }
body.play nav { font-size: 15px; }
body.play nav a { margin-right: 18px; }
body.play h1 { margin-top: 24px; }
body.play hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 560px) minmax(260px, 1fr);
  gap: 32px;
  align-items: start;
}

.board-wrap { position: relative; }

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.square { position: relative; cursor: pointer; }
.square.light { background: #f0d9b5; }
.square.dark { background: #b58863; }
.square.last-move.light { background: #f6f269; }
.square.last-move.dark { background: #d8c33f; }
.square.selected.light, .square.selected.dark { background: #8fc7ff; }
.square.check { background: radial-gradient(circle, #ff5d5d 0%, #ff5d5d 35%, transparent 75%); }

.square img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 3%;
}

.square.target::after {
  content: '';
  position: absolute;
  left: 36%;
  top: 36%;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
}
.square.capture::after {
  content: '';
  position: absolute;
  inset: 4%;
  border-radius: 50%;
  border: 5px solid rgba(0, 0, 0, 0.18);
}

.coord {
  position: absolute;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.7;
  pointer-events: none;
}
.coord.rank { top: 2px; left: 3px; }
.coord.file { bottom: 1px; right: 4px; }

.promotion {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 12px 16px;
  font-size: 14px;
}
.promotion[hidden] { display: none; }
.promotion img { width: 56px; height: 56px; cursor: pointer; border-radius: 6px; }
.promotion img:hover { background: var(--sidebar-bg); }

.panel h3 { margin-top: 24px; }

.status { font-size: 17px; font-weight: 600; min-height: 1.6em; margin: 0 0 14px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.controls button, .controls select {
  font: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--sidebar-bg);
  color: var(--ink);
  cursor: pointer;
}
.controls button:hover:not(:disabled) { background: #eceef1; }
.controls button:disabled { opacity: 0.5; cursor: default; }
.controls label { font-size: 14px; color: var(--muted); }

.engine { min-height: 3.6em; white-space: pre-wrap; margin: 0; }

.moves {
  list-style-position: inside;
  margin: 0;
  max-height: 260px;
  overflow-y: auto;
  font: 14px/1.6 ui-monospace, Menlo, Consolas, monospace;
  columns: 2;
}
.moves li { margin: 0; break-inside: avoid; }

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