/* The chess page: the board on the left, the moves and the chat on the right. */

.chess {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: clamp(16px, 3vw, 44px) var(--pad-x) 80px;
}
.table {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(280px, 420px);
  justify-content: start;
  align-items: start;
  gap: 36px clamp(28px, 5vw, 72px);
}
.board-col { width: min(calc(100vw - 2 * var(--pad-x)), 620px, max(300px, calc(100vh - 250px))); display: grid; gap: 6px; }
@media (max-width: 940px) {
  .table { grid-template-columns: minmax(0, 1fr); }
  .board-col { width: min(100%, 620px); }
}

/* Who sits where, and whose move it is */
.seat { display: flex; align-items: center; gap: 10px; min-height: 30px; padding: 0 12px; font-size: 14px; }
.seat .lamp { width: 8px; height: 8px; background: var(--line); flex: none; }
.seat.turn .lamp { background: var(--blue); }
.seat .who { font-weight: 600; }
.seat .note { font-size: 13px; color: var(--muted); }

/* The board, held by four corner marks like the page itself */
.board-frame { position: relative; padding: 12px; }
.board-frame .corner.tl { top: 0; left: 0; }
.board-frame .corner.tr { top: 0; right: 0; }
.board-frame .corner.bl { bottom: 0; left: 0; }
.board-frame .corner.br { bottom: 0; right: 0; }
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  border: 1px solid var(--bracket);
  background: var(--paper);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: #F6F7FC;
  font: inherit;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
}
.sq.dark { background-color: #CBD3EC; }
.sq.last { background-color: #E6EAFF; }
.sq.dark.last { background-color: #B3BFF3; }
.sq.movable { cursor: pointer; }
.sq.sel { box-shadow: inset 0 0 0 3px var(--blue); }
.sq.check { background-image: radial-gradient(circle, rgba(200, 16, 46, 0.6) 0%, rgba(200, 16, 46, 0) 70%); }
.sq.target { cursor: pointer; }
.sq.target::after { content: ''; position: absolute; width: 26%; height: 26%; border-radius: 50%; background: rgba(31, 59, 255, 0.4); z-index: 2; }
.sq.target.capture::after { width: 88%; height: 88%; border: 4px solid rgba(31, 59, 255, 0.45); background: none; }
.sq:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; z-index: 3; }
.piece { position: relative; z-index: 1; display: block; width: 86%; height: 86%; pointer-events: none; }
.piece.slide { transition: transform 0.22s ease; }
.piece.dragging { z-index: 6; filter: drop-shadow(0 6px 6px rgba(11, 15, 26, 0.25)); }
.sq.lifted { z-index: 5; }
.coord { position: absolute; font-size: 10px; line-height: 1; color: var(--muted); pointer-events: none; }
.coord.file { right: 3px; bottom: 3px; }
.coord.rank { left: 3px; top: 3px; }

/* Choosing what a pawn becomes */
.promo { position: absolute; inset: 12px; z-index: 8; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.72); }
.promo-box { display: grid; gap: 8px; padding: 14px 16px 16px; background: var(--paper); border: 1px solid var(--bracket); }
.promo-box p { margin: 0; font-size: 13px; color: var(--muted); }
.promo-row { display: flex; gap: 6px; }
.promo-row button { width: 60px; height: 60px; padding: 0; border: 1px solid var(--line); background: #F6F7FC; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.promo-row button:hover { background: var(--open); border-color: var(--blue); }

#record { padding: 0 12px; }
#note { padding: 0 12px; }
.owner { display: grid; gap: 4px; padding: 6px 12px 0; }
.owner .row.tools { gap: 0 20px; }
#son-form { max-width: 380px; }

/* The right-hand column */
.side { display: grid; gap: 20px; min-width: 0; padding-top: 42px; }
@media (max-width: 940px) { .side { padding-top: 0; max-width: 620px; } }
.panel { display: grid; gap: 12px; padding: 16px 18px 18px; background: var(--paper); border: 1px solid var(--line); min-width: 0; }
.panel h2 { margin: 0; font-size: 13px; font-weight: 600; }

.moves { max-height: 128px; overflow: auto; display: grid; grid-template-columns: 2.4em 5.5em 5.5em; gap: 4px 8px; font-size: 14px; font-variant-numeric: tabular-nums; align-content: start; }
.moves > .small { grid-column: 1 / -1; }
.moves .num { color: var(--muted); }
.moves .ply { justify-self: start; padding: 0 5px; margin-left: -5px; }
.moves .ply.now { background: var(--open); color: var(--blue); }

.log { display: flex; flex-direction: column; gap: 12px; min-height: 96px; max-height: 340px; overflow: auto; padding-right: 4px; }
.msg .meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; font-size: 12px; color: var(--muted); }
.msg .who { font-size: 13px; font-weight: 600; color: var(--ink); }
.msg.son .who { color: var(--blue); }
.msg .email { color: var(--ink); overflow-wrap: anywhere; }
.msg .text { margin: 2px 0 0; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.msg .textbtn { min-height: 24px; font-size: 12px; color: var(--muted); }
.chat-form { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--wash); }
.textbtn.inline { min-height: 0; font-size: 13px; color: var(--muted); text-underline-offset: 3px; }
