:root {
  color-scheme: dark;
  --ink: #f4efe4;
  --card: rgba(16, 18, 16, 0.82);
  --line: rgba(244, 239, 228, 0.16);
  --gold: #e2c27a;
  --felt: #1c3a2e;
  --light: #f0d9b5;
  --dark: #b58863;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(8, 10, 12, 0.35), rgba(8, 10, 12, 0.55)),
    url("/static/bg.jpg") center/cover no-repeat,
    #1a140f;
}
button, input, select { font: inherit; }
a { color: var(--gold); }
.card {
  width: min(420px, calc(100% - 32px));
  margin: 7vh auto;
  padding: 28px 26px 22px;
  background: rgba(255, 252, 247, 0.96);
  color: #1c1a17;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.card h1 { text-align: center; color: #163a8a; }
.card .sub { text-align: center; color: #5c564c; }
.card input[type="password"], .card input[type="text"] {
  background: #fff;
  color: #1c1a17;
  border: 1px solid #d9d3c7;
}
.card button[type="submit"] { width: 100%; margin-top: 8px; }
.logo {
  width: 112px;
  height: 112px;
  display: block;
  margin: 0 auto 8px;
  border-radius: 50%;
  object-fit: cover;
}
.brand { height: 42px; width: 42px; border-radius: 50%; object-fit: cover; }
h1 { margin: 0 0 6px; font-size: 32px; font-weight: 600; letter-spacing: 0.02em; }
.sub { margin: 0 0 18px; color: rgba(244, 239, 228, 0.72); }
label { display: block; margin: 12px 0 6px; font-size: 14px; }
input[type="text"], input[type="password"], select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}
.row { display: flex; gap: 10px; align-items: center; margin: 14px 0; }
.row label { margin: 0; }
button {
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  background: #2f6fed;
  color: white;
  cursor: pointer;
}
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: 0.55; cursor: default; }
.err { color: #ffb4a8; min-height: 1.2em; }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  width: min(1100px, calc(100% - 24px));
  margin: 16px auto;
}
.play {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 22px;
}
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  min-width: 0;
}
.stage {
  background: transparent;
  border: 0;
  padding: 8px 0;
  display: grid;
  place-items: center;
  min-width: 0;
}
.board {
  width: min(100%, 640px);
  margin: 0 auto;
  display: grid;
  padding: 14px;
  background: #312e2b;
  border-radius: 4px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  user-select: none;
}
.sq {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #ebecd0;
  cursor: pointer;
}
.sq:focus { outline: none; }
.board.chess .sq.dark { background: #739552; }
.board.draughts .sq { background: #f0d9b5; }
.board.draughts .sq.dark { background: #b58863; }
.board.chess .sq.last { background: #f5f682; }
.board.chess .sq.dark.last { background: #baca2b; }
.board.chess .sq.sel { background: #f6f669; }
.board.chess .sq.dark.sel { background: #baca44; }
.board.draughts .sq.last { background: #f3e08a; }
.board.draughts .sq.dark.last { background: #d7a441; }
.board.draughts .sq.sel { background: #f6f669; }
.board.draughts .sq.dark.sel { background: #c48a32; }
.sq img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  position: relative;
  z-index: 1;
}
.sq.dot::after, .sq.cap::after, .sq.hint::after {
  content: "";
  position: absolute;
  z-index: 2;
  border-radius: 50%;
  pointer-events: none;
}
.sq.dot::after {
  width: 28%;
  height: 28%;
  background: rgba(0, 0, 0, 0.2);
}
.sq.cap::after {
  width: 86%;
  height: 86%;
  background: transparent;
  box-shadow: inset 0 0 0 5px rgba(0, 0, 0, 0.2);
}
.sq.hint::after {
  width: 18%;
  height: 18%;
  background: #2f6fed;
}
.coord, .num {
  position: absolute;
  z-index: 3;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
}
.coord { font-size: 11px; }
.coord.rank { top: 2px; left: 3px; }
.coord.file { right: 3px; bottom: 2px; }
.board.chess .sq .coord { color: #ebecd0; }
.board.chess .sq:not(.dark) .coord { color: #739552; }
.num { top: 2px; left: 3px; font-size: 10px; color: rgba(255, 255, 255, 0.8); }
.man, .king {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 38%, #fffdf8 0 46%, #f0d7a2 47% 72%, #c4964a 73% 100%);
  box-shadow: 0 2px 0 #7a5a28, inset 0 2px 0 rgba(255, 255, 255, 0.8);
}
.man.black, .king.black {
  background:
    radial-gradient(circle at 50% 38%, #6d5648 0 46%, #32241c 47% 72%, #140e0b 73% 100%);
  box-shadow: 0 2px 0 #000, inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.king::after {
  content: "";
  width: 38%;
  height: 38%;
  border-radius: 50%;
  border: 3px solid #e8c56b;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, 0.15);
}
.status { min-height: 1.4em; margin: 8px 0; }
#share { overflow-wrap: anywhere; }
.code {
  display: block;
  margin: 6px 0 8px;
  font-family: ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
  overflow-wrap: anywhere;
  word-break: break-all;
}
@media (max-width: 1100px) {
  .play { grid-template-columns: 1fr; }
  .card { margin-top: 24px; }
}
