:root {
  --fg: #1a1a1a;
  --muted: #666;
  --line: #ddd;
  --accent: #1a1a1a;
  --bg: #fff;
  --danger: #b00020;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 16px; }

.game { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: start; }
.board-col { min-width: 0; }
.board { width: 100%; max-width: min(640px, calc(100vh - 140px)); min-width: 240px; aspect-ratio: 1 / 1; touch-action: none; user-select: none; -webkit-user-select: none; }
.status { min-height: 1.4em; margin: 12px 0 0; font-weight: 500; }
.status.end { color: var(--danger); }

.panel { display: flex; flex-direction: column; gap: 16px; }
.row { margin: 0; padding: 0; border: 0; }
fieldset.row { display: flex; gap: 16px; flex-wrap: wrap; }
legend, .lbl { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.opt { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
select, button {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; min-height: 40px;
}
select { width: 100%; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--fg); }
button:disabled { color: #aaa; cursor: default; }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.buttons button { flex: 1 1 auto; }
#newGame { background: var(--accent); color: #fff; border-color: var(--accent); }

.moves {
  list-style: none; margin: 0; padding: 0;
  max-height: 320px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 6px;
  font-variant-numeric: tabular-nums; font-size: .95rem;
}
.moves:empty::before { content: "—"; display: block; padding: 6px 10px; color: var(--muted); }
.moves li { display: grid; grid-template-columns: 2.5em 1fr 1fr; padding: 3px 10px; }
.moves li:nth-child(odd) { background: #f6f6f6; }
.moves .n { color: var(--muted); }

.promo { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.promo[hidden] { display: none; }
.promo-box { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 16px; text-align: center; }
.promo-box p { margin: 0 0 12px; font-weight: 500; }
.promo-pieces { display: flex; gap: 8px; }
.promo-pieces button { width: 64px; height: 64px; padding: 4px; }
.promo-pieces svg { width: 100%; height: 100%; display: block; }
button.link { border: 0; background: none; color: var(--muted); margin-top: 8px; text-decoration: underline; }

/* last move + check markers */
.cm-chessboard .markers .marker.marker-last { fill: #f2d84b; opacity: .45; }
.cm-chessboard .markers .marker.marker-check { fill: var(--danger); opacity: .45; }

.foot { max-width: 980px; margin: 8px auto 24px; padding: 0 16px; font-size: .8rem; color: var(--muted); }
.foot a { color: var(--muted); }

@media (max-width: 760px) {
  .game { grid-template-columns: 1fr; gap: 16px; }
  .board { max-width: 100%; }
  .moves { max-height: 180px; }
  h1 { font-size: 1.2rem; margin-bottom: 12px; }
}

/* header + language switcher */
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 16px; }
.top h1 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
select.lang { width: auto; max-width: 100%; min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.credits p, .credits h2 { overflow-wrap: anywhere; }
.credits h2 { font-size: 1.1rem; margin: 24px 0 8px; }
@media (max-width: 760px) { .top { margin-bottom: 12px; } }
