body {
  margin: 0 auto;
  padding: 24px 16px 64px;
  max-width: 720px;
  background: #fff;
  color: #000;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
a { color: #00e; text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: #00e; }
footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid #ddd; }
.footer-credits { font-size: 14px; }
.footer-credits p { margin: 4px 0; }
nav { margin-bottom: 32px; }
nav a { margin-right: 16px; }
nav b { margin-right: 16px; }
h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 40px 0 8px; }
h3 { font-size: 16px; margin: 24px 0 4px; }
code, pre, textarea { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code { background: #f4f4f4; padding: 1px 4px; }
pre { background: #f4f4f4; padding: 12px; overflow-x: auto; }
pre code { background: none; padding: 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 4px 12px 4px 0; border-bottom: 1px solid #ddd; vertical-align: top; }
textarea { width: 100%; box-sizing: border-box; padding: 8px; border: 1px solid #999; }
input, select { font: inherit; padding: 4px 8px; border: 1px solid #999; border-radius: 3px; background: #fff; color: #000; }
select {
  appearance: none; padding-right: 28px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #00e; outline-offset: -1px; }
button { font: inherit; padding: 5px 14px; background: #00e; color: #fff; border: 0; border-radius: 3px; cursor: pointer; }
button:hover { background: #00b; }
button:disabled { background: #99f; cursor: default; }
.muted { color: #666; }
.bar { display: inline-block; height: 10px; background: #000; vertical-align: middle; }
.err { color: #c00; white-space: pre-wrap; }
table.probs { width: auto; }

/* demo */
body.wide { max-width: 1200px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
.cols h2 { margin-top: 8px; }
@media (max-width: 860px) { .cols { grid-template-columns: minmax(0, 1fr); } }
.controls { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.controls label { color: #666; }
.probs td { padding: 2px 10px 2px 0; border: 0; }
.probs .num { text-align: right; font-variant-numeric: tabular-nums; }
.probs tr.best { font-weight: bold; }
h2 .muted, h3 .muted { font-weight: normal; }
details summary { cursor: pointer; color: #00e; margin-top: 16px; }
.editor { position: relative; background: #fff; }
.editor textarea, #backdrop {
  display: block; width: 100%; box-sizing: border-box; margin: 0; padding: 8px; border: 1px solid #999;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: break-word; tab-size: 8;
}
#backdrop { position: absolute; inset: 0; color: transparent; border-color: transparent; overflow: hidden; pointer-events: none; }
.editor textarea { position: relative; background: transparent; resize: none; overflow: hidden; }
#backdrop mark { color: transparent; }
#backdrop mark.q, .answer.hl { background: #eef2ff; }
#backdrop mark.o, .probs tr.hl { background: #cfdbff; }
.track { position: relative; height: 1px; background: #999; margin: 12px 4px 4px; }
.track span { position: absolute; top: -6px; width: 2px; height: 13px; margin-left: -1px; background: #000; }
.track-ends { display: flex; justify-content: space-between; font-size: 13px; margin: 0 0 8px; }

/* chess */
.board { display: grid; grid-template-columns: 18px repeat(8, minmax(0, 1fr)); max-width: 480px; user-select: none; }
.board .coord { display: flex; align-items: center; justify-content: center; font-size: 12px; color: #666; }
.sq { position: relative; aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
      font-size: min(42px, 8.5vw); line-height: 1; background: #eee; cursor: pointer; }
.sq.dark { background: #bbb; }
.sq.last { background: #d6e0ff; }
.sq.dark.last { background: #aabdf5; }
.sq.check { background: #f2b8b8; }
.sq.sel, .sq.hover { box-shadow: inset 0 0 0 3px #00e; }
.sq.target::after { content: ""; position: absolute; width: 26%; height: 26%; border-radius: 50%; background: rgba(0, 0, 0, .25); }
.sq.capture::after { width: 84%; height: 84%; background: none; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .25); }
#pgn { font-size: 14px; }
.ok { color: #080; }

/* runner */
canvas.runner { display: block; width: 100%; max-width: 900px; image-rendering: pixelated; border-bottom: 1px solid #ddd; margin: 8px 0; }

/* Navigation and demo directory */
nav { display: flex; flex-wrap: wrap; gap: 8px 16px; }
nav a, nav b { margin-right: 0; }
nav a[aria-current="page"] { font-weight: bold; }
.demo-list { padding: 0; list-style: none; }
.demo-list li { padding: 16px 0; border-bottom: 1px solid #ddd; }
.demo-list h2 { margin: 0 0 8px; }
.demo-list p { margin: 0; }
.homepage-game { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; margin-top: 32px; padding-bottom: 16px; }
.homepage-game .cols { gap: 20px; }
.homepage-game .cols h3 { margin-top: 8px; }
#manual-controls button { touch-action: none; }
canvas.runner:focus-visible { outline: 2px solid #00e; outline-offset: 3px; }
[hidden] { display: none !important; }
