:root {
  --page-bg: #cfcfc7;
  --panel-bg: #f2f0e8;
  --panel-alt: #dedbd0;
  --ink: #161616;
  --muted: #5b5b56;
  --rule: #77776f;
  --link: #003399;
  --link-visited: #553388;
  --square-light: #d8d1bd;
  --square-dark: #7e7769;
  --accent: #8b1a1a;
}

* { box-sizing: border-box; }

html { background: var(--page-bg); }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,.08), rgba(255,255,255,.08)),
    var(--page-bg);
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}

a { color: var(--link); text-decoration: underline; }
a:visited { color: var(--link-visited); }
a:hover { color: var(--accent); }

.site-shell {
  width: min(980px, calc(100% - 24px));
  margin: 18px auto 28px;
  border: 1px solid #4d4d49;
  background: var(--panel-bg);
  box-shadow: 0 2px 0 rgba(255,255,255,.55) inset, 0 0 0 1px #b8b8b0;
}

.masthead {
  padding: 18px 18px 12px;
  background: linear-gradient(#f6f4ec, #e3e0d6);
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.brand h1 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 31px;
  letter-spacing: -1px;
  font-weight: 700;
}
.brand .tagline { color: var(--muted); font-size: 12px; }

.topnav {
  margin-top: 11px;
  padding: 6px 8px;
  border: 1px solid #73736e;
  background: #d2d0c7;
  font-weight: 700;
  font-size: 12px;
}
.topnav a { margin-right: 16px; }

.content-grid {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.sidebar, .main { min-width: 0; }

.box {
  border: 1px solid #77776f;
  background: #f8f6ee;
  margin-bottom: 10px;
}
.box h2, .box h3 {
  margin: 0;
  padding: 5px 7px;
  font-family: Verdana, Arial, sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid #77776f;
  background: linear-gradient(#d9d6cc, #c2beb2);
}
.box .body { padding: 8px; }
.box ul { margin: 0; padding-left: 18px; }
.box li { margin: 4px 0; }

.article h2 {
  margin: 0 0 2px;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 23px;
  text-transform: none;
  letter-spacing: 0;
  background: none;
  border: 0;
  padding: 0;
}
.meta { color: var(--muted); font-size: 11px; margin-bottom: 8px; }
.rule { border-top: 1px solid #9b9b94; margin: 11px 0; }
.kicker { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 10px; letter-spacing: .08em; }

.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chess-preview {
  display: grid;
  grid-template-columns: minmax(260px, 390px) 1fr;
  gap: 14px;
  align-items: start;
}

.board-wrap {
  max-width: 480px;
  border: 2px solid #4b4943;
  background: #aaa59b;
  padding: 6px;
  box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #666 inset;
}
.chessboard {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1 / 1;
  border: 1px solid #3f3d39;
}
.square {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Arial Unicode MS', 'Segoe UI Symbol', serif;
  font-size: clamp(26px, 5vw, 48px);
  user-select: none;
  cursor: pointer;
  position: relative;
}
.square.light { background: var(--square-light); }
.square.dark { background: var(--square-dark); }
.square.selected { outline: 3px solid #222; outline-offset: -3px; }
.square.last::after {
  content: '';
  position: absolute;
  inset: 5px;
  border: 2px dotted rgba(255,255,255,.75);
  pointer-events: none;
}

.status-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.status-table td { border-bottom: 1px solid #c3c0b8; padding: 5px 3px; vertical-align: top; }
.status-table td:first-child { width: 86px; color: var(--muted); font-weight: 700; }

.retro-button {
  font: inherit;
  padding: 5px 9px;
  color: #111;
  background: #d8d6ce;
  border: 1px solid #585853;
  box-shadow: 1px 1px 0 #fff inset, -1px -1px 0 #8c8c86 inset;
  cursor: pointer;
}
.retro-button:active { box-shadow: -1px -1px 0 #fff inset, 1px 1px 0 #8c8c86 inset; }

.notice {
  border: 1px solid #8e8b80;
  background: #ece9dc;
  padding: 8px;
  margin: 8px 0;
}

.footer {
  border-top: 1px solid #77776f;
  padding: 8px 12px 12px;
  color: #55554f;
  font-size: 10px;
  text-align: center;
}

.timestamp { font-family: 'Courier New', monospace; font-size: 11px; }

@media (max-width: 720px) {
  .site-shell { width: calc(100% - 10px); margin-top: 5px; }
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .main { order: 1; }
  .two-up, .chess-preview { grid-template-columns: 1fr; }
  .topnav a { display: inline-block; margin: 3px 10px 3px 0; }
  .brand h1 { font-size: 27px; }
}

/* v0.2: live chess, keeping the v0.1 palette and panel treatment. */
.chess-preview { grid-template-columns: minmax(240px, 390px) minmax(140px, 1fr); }
.square { border: 0; padding: 0; min-width: 0; aspect-ratio: 1; color: #161616; }
.square img { width: 91%; height: 91%; pointer-events: none; }
.square .coordinate { position: absolute; bottom: 1px; left: 2px; font: bold 9px Verdana,sans-serif; color: #111; background: rgba(248,246,238,.7); padding: 0 1px; line-height: 1.15; }
.square.legal::before { content: ''; z-index: 2; position: absolute; inset: 30%; border-radius: 50%; background: #18372199; border: 2px solid #eff2c9; pointer-events: none; }
.square.selected { outline-color: #8b1a1a; z-index: 3; }
.square:focus-visible { outline: 3px solid #003399; outline-offset: -3px; z-index: 4; }
.square.last::after { border-color: #ffe8a5; inset: 3px; }
.board-tools, .replay-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.board-tools { margin-bottom: 6px; }
input { display: block; width: 100%; margin-top: 4px; padding: 6px; border: 1px solid #77776f; background: #fffdf5; font: inherit; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid #003399; outline-offset: 2px; }
.history-scroll { max-height: 300px; overflow-y: auto; margin-top: 8px; }
.history-table { table-layout: fixed; }
.history-table th { text-align: left; border-bottom: 1px solid #77776f; }
.history-table th:first-child, .history-table td:first-child { width: 48px; }
.history-table td { overflow-wrap: anywhere; }
.history-table button { border: 0; background: transparent; color: #003399; text-decoration: underline; padding: 2px; font: bold 13px 'Courier New',monospace; cursor: pointer; }
.history-table small { display: block; color: #5b5b56; }
#feedback { margin-top: 0; }
#feedback.error { border-color: #8b1a1a; }
#connection { font-size: 11px; margin-top: 6px; }
#archive li { margin: 8px 0; overflow-wrap: anywhere; }
dialog { max-width: calc(100% - 24px); border: 2px solid #4b4943; background: #f2f0e8; color: #161616; }
dialog h2 { font: bold 20px Georgia,serif; }
dialog::backdrop { background: #0008; }
.promotion-options { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-board { width: 160px; max-width: 100%; margin: 8px 0; }
.mini-board .square { cursor: default; }
.mini-board .square img { width: 95%; height: 95%; }
#live-preview-summary { font-size: 11px; }
@media (max-width: 850px) { .chess-preview { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .mini-board { width: 180px; } }
[hidden] { display: none !important; }

