:root {
  --light: #eeeed2;
  --dark: #769656;
  --sel: #f6f669;
  --target: rgba(20, 85, 30, 0.45);
  --last: rgba(255, 213, 79, 0.55);
  --check: rgba(231, 76, 60, 0.65);
  --bg: #2b2b2b;
  --card: #ffffff;
  --text: #222;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: #eee;
}

header {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
header h1 { font-size: 1.4rem; margin: 0; }

.banner {
  padding: 6px 14px;
  border-radius: 6px;
  background: #444;
  font-weight: 600;
}
.banner.check { background: #b9770e; }
.banner.over { background: #6c3483; }

main {
  display: flex;
  gap: 24px;
  padding: 0 20px 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board-area { flex: 0 0 auto; }

.board {
  width: min(80vw, 560px);
  height: min(80vw, 560px);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border: 4px solid #1b1b1b;
  border-radius: 4px;
  user-select: none;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(9vw, 60px);
  line-height: 1;
  cursor: default;
}
.square.light { background: var(--light); }
.square.dark { background: var(--dark); }
.square.selectable { cursor: pointer; }
.square.sel { background: var(--sel) !important; }
.square.last { box-shadow: inset 0 0 0 9999px var(--last); }
.square.check { box-shadow: inset 0 0 0 9999px var(--check); }

.square .coord {
  position: absolute;
  font-size: 10px;
  bottom: 1px;
  right: 2px;
  color: rgba(0,0,0,0.5);
  font-weight: 700;
}
.piece.white { color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.piece.black { color: #111; text-shadow: 0 0 2px #bbb; }

.square .dot {
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: var(--target);
}
.square .ring {
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 5px solid var(--target);
}

.board-controls {
  margin-top: 10px;
  display: flex;
  gap: 16px;
  align-items: center;
}
.captured { margin-top: 10px; font-size: 1.4rem; min-height: 2.4rem; }
.captured div { min-height: 1.6rem; }

.panel {
  flex: 1 1 320px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 14px;
}
.card h2 { margin: 0 0 8px; font-size: 1rem; }

.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 3px 4px; }
.kv td:first-child { color: #777; width: 38%; }

label { display: block; margin: 6px 0; font-size: 0.9rem; }
input, textarea, button { font: inherit; }
input[type=text], input:not([type]), input[type=password] {
  width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px;
}
button {
  padding: 7px 12px; border: 0; border-radius: 5px;
  background: #2e7d32; color: #fff; cursor: pointer; margin: 3px 0;
}
button:hover { background: #1b5e20; }
button:disabled { background: #aaa; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button { flex: 1 1 auto; }
#resign-btn { background: #b71c1c; }
#resign-btn:hover { background: #7f0000; }

.hint { color: #777; font-size: 0.82rem; margin: 4px 0; }
.error { color: #c0392b; font-size: 0.85rem; min-height: 1rem; }
.hidden { display: none; }

.moves { margin: 0; padding-left: 26px; max-height: 220px; overflow-y: auto; font-family: monospace; }
.moves li { padding: 1px 0; }

.mono-label { color: #777; font-size: 0.8rem; margin-top: 6px; }
.mono { width: 100%; font-family: monospace; font-size: 0.78rem; border: 1px solid #ccc; border-radius: 4px; padding: 6px; resize: vertical; }

footer { padding: 12px 20px; color: #aaa; font-size: 0.8rem; }
footer a { color: #9ccc65; }
