/* Neutrální vzhled. Celý design desky a kamenů jde přestylovat přes
   proměnné níže a třídy .square*, .piece*. */
:root {
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #f4f4f2;
  --fg: #1d1d1b;
  --muted: #6b6b66;
  --panel-bg: #ffffff;
  --border: #c9c9c2;

  --cell: min(7vw, 54px);
  --square-bg: #e9e6dc;
  --square-border: #b8b3a2;
  --citadel-bg: #d6cfb8;
  --coord: #8a8678;

  --piece-w-bg: #fdfdfb;
  --piece-w-fg: #1d1d1b;
  --piece-b-bg: #2b2b29;
  --piece-b-fg: #f4f4f2;
  --piece-border: #1d1d1b;
  --piece-size: 82%;

  --hl-selected: #f1d36b;
  --hl-last: #f6e7a8;
  --hl-move: rgba(40, 110, 60, 0.55);
  --hl-capture: rgba(170, 40, 40, 0.75);
  --hl-swap: rgba(60, 80, 190, 0.75);
  --hl-deploy: rgba(140, 60, 170, 0.75);
  --hl-check: rgba(220, 40, 40, 0.45);
  --hl-movable: rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1b1a;
    --fg: #eeeeea;
    --muted: #a3a39c;
    --panel-bg: #242422;
    --border: #44443f;
    --square-bg: #3a3833;
    --square-border: #56534a;
    --citadel-bg: #5b5444;
    --coord: #8f8b7e;
    --hl-last: #6b5f2e;
    --hl-selected: #8f7a24;
    --hl-movable: rgba(255, 255, 255, 0.05);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); }

.layout {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 16px;
  align-items: flex-start;
  justify-content: center;
}

.board {
  display: grid;
  grid-template-columns: 20px repeat(13, var(--cell));
  grid-template-rows: repeat(10, var(--cell)) 20px;
  gap: 0;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  border: 1px solid var(--square-border);
  background: var(--square-bg);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.square--citadel { background: var(--citadel-bg); border-width: 2px; border-radius: 6px; }
.square--movable { box-shadow: inset 0 0 0 999px var(--hl-movable); }
.square--last { background: var(--hl-last); }
.square--selected { background: var(--hl-selected); }
.square--check { box-shadow: inset 0 0 0 999px var(--hl-check); }

.square--target::after {
  content: "";
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: var(--hl-move);
  pointer-events: none;
}
.square--capture::after { width: 88%; height: 88%; background: none; border: 4px solid var(--hl-capture); }
.square--target-swap::after { width: 88%; height: 88%; background: none; border: 4px dashed var(--hl-swap); border-radius: 4px; }
.square--target-deploy::after { background: var(--hl-deploy); border-radius: 2px; transform: rotate(45deg); }
.square--target-return::after { background: var(--hl-deploy); }

.coord { display: flex; align-items: center; justify-content: center; color: var(--coord); font-size: 12px; }

.piece {
  position: relative;
  width: var(--piece-size);
  height: var(--piece-size);
  border-radius: 50%;
  border: 2px solid var(--piece-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(var(--cell) * 0.34);
  pointer-events: none;
  user-select: none;
}
.piece--w { background: var(--piece-w-bg); color: var(--piece-w-fg); }
.piece--b { background: var(--piece-b-bg); color: var(--piece-b-fg); }
.piece--pawn { width: 66%; height: 66%; font-size: calc(var(--cell) * 0.24); }
.piece--K, .piece--I, .piece--A { border-width: 3px; border-style: double; }
.piece--dormant { opacity: 0.55; border-style: dotted; }
.piece__badge {
  position: absolute;
  right: -6px;
  top: -6px;
  font-size: 10px;
  background: var(--hl-deploy);
  color: #fff;
  border-radius: 8px;
  padding: 0 4px;
}

.status { min-height: 1.5em; font-weight: 600; }

.panel {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.group { border: 1px solid var(--border); background: var(--panel-bg); border-radius: 8px; display: flex; flex-direction: column; gap: 8px; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; }
button, select, textarea { font: inherit; }
button { padding: 6px 12px; border-radius: 6px; border: 1px solid var(--border); background: var(--panel-bg); color: var(--fg); cursor: pointer; }
.board button { border-radius: 0; }
textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; background: var(--bg); color: var(--fg); }
.history { max-height: 220px; overflow-y: auto; margin: 0; padding-left: 2.2em; font-family: ui-monospace, monospace; font-size: 13px; }
.engine-info { margin: 0; color: var(--muted); font-size: 13px; }
.rules { display: grid; gap: 6px; }
.rule { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.rule span { font-family: ui-monospace, monospace; }
