@font-face {
  font-family: Barlow;
  src: url("/fonts/barlow-regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: Barlow;
  src: url("/fonts/barlow-semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Serif";
  src: url("/fonts/instrument-serif.woff2") format("woff2");
  font-display: swap;
}
:root {
  --ink: #182c24;
  --paper: #f5f1e8;
  --line: #a7aa97;
  --muted: #4d5d51;
  --lobby-accent: #e2e8da;
  --light-square: #ebd9b2;
  --dark-square: #517561;
  --highlight: #a35425;
  --error: #9e3926;
  color: var(--ink);
  background: var(--paper);
  font: 400 1rem/1.45 Barlow, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
::selection { background: #e0bf82; color: var(--ink); }
:focus-visible { outline: 3px solid var(--highlight); outline-offset: 3px; }
a { color: inherit; text-underline-offset: .22em; }
button, input, select { font: inherit; color: inherit; }
button, select, input:not([type="radio"]) {
  min-height: 2.75rem;
  padding: .45rem .65rem;
  border: 1px solid var(--line);
  border-radius: .3rem;
  background: transparent;
}
button, select { cursor: pointer; }
button { font-weight: 600; }
button:disabled { cursor: default; }
button:not(:disabled):hover, select:hover { background: var(--lobby-accent); }
.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
  padding-inline: 1.1rem;
}
.primary:not(:disabled):hover { background: #345243; }
.primary:disabled { background: #e4e3d7; border-color: var(--line); color: var(--muted); }
.quiet { border-color: transparent; text-decoration: underline; text-underline-offset: .2em; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.masthead {
  min-height: 3.75rem;
  background: var(--ink);
  color: var(--paper);
  padding: .45rem max(1rem, calc((100vw - 68rem) / 2));
  display: flex;
  align-items: center;
  gap: .6rem;
}
.masthead .home { margin-right: auto; min-width: 0; font-weight: 600; text-decoration: none; }
.masthead .home span { margin-right: .3rem; }
.masthead select, .masthead button { border-color: #879589; }
.masthead select:hover, .masthead button:not(:disabled):hover, .masthead option { background: #345243; }
.masthead #chess-sound[aria-pressed="true"] {
  border-color: var(--paper);
  background: var(--paper);
  color: var(--ink);
}
.masthead #chess-sound[aria-pressed="true"]:hover { background: var(--lobby-accent); }
.masthead #chess-sound[aria-pressed="false"] { text-decoration: line-through; }
.table { max-width: 68rem; margin: auto; padding: 1.1rem 1rem 2.5rem; }
.table-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: .35rem .75rem;
  margin-bottom: .7rem;
}
h1, h2, p { margin: 0; }
h1, h2 { text-wrap: balance; }
h1 { font: 400 3.25rem/.95 "Instrument Serif", Georgia, serif; }
.table-title h1 { justify-self: start; }
h2 { font-size: 1.45rem; line-height: 1.15; font-weight: 600; margin-bottom: .75rem; }
.table-layout {
  display: grid;
  grid-template-columns: minmax(0, min(37rem, 56%, max(25rem, calc(100svh - 13rem)))) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 4rem);
}
.table-side {
  min-width: 0;
  align-self: start;
  padding: .85rem 0 0;
  border-top: 1px solid var(--line);
}
.field { display: grid; gap: .28rem; margin-bottom: .75rem; font-weight: 600; }
.field :is(input, select) { width: 100%; background: #fffdf7; font-size: 1rem; }
.table-side p:not(:empty), dialog p:not(:empty) { margin-block: .7rem; }
.clock {
  display: grid;
  justify-items: end;
  gap: .13rem;
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.1;
}
#match-time {
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
}
#connection { grid-column: 2; color: var(--muted); text-align: right; }
#error, #dialog-error { color: var(--error); font-weight: 600; }
#start-controls { margin-bottom: .9rem; }
#color-assignment { color: var(--muted); overflow-wrap: anywhere; }
#chess-record {
  margin-top: 1rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
}
#chess-record h3 { margin: 1rem 0 .35rem; font-size: 1rem; font-weight: 600; }
#no-moves { color: var(--muted); }
.move-log {
  max-height: 13rem;
  overflow: auto;
  scrollbar-color: #778878 var(--lobby-accent);
}
.move-log table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.move-log :is(th, td) { padding: .38rem .65rem; text-align: start; }
.move-log thead { position: sticky; top: 0; background: var(--lobby-accent); }
.move-log :is(th, td):first-child { width: 3rem; }
.move-log td { width: calc((100% - 3rem) / 2); }
.move-log tbody tr { border-bottom: 1px solid var(--line); }
.move-log tbody th { color: var(--muted); font-weight: 400; }
.captured {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: .35rem 1rem;
  margin: 0;
  color: var(--muted);
}
.captured dt { font-weight: 600; }
.captured dd { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem; margin: 0; }
.captured-piece { display: inline-flex; }
.captured-piece svg { width: 1.4rem; height: 1.4rem; }
.members { margin: 0 0 .85rem; padding: 0; list-style: none; }
.members li {
  padding: .3rem 0;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.lobby-code { font-family: ui-monospace, monospace; }
.lobby-url { width: 100%; }
.chessboard {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  border: 3px solid var(--ink);
  background: var(--ink);
}
.chessboard .square {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  color: var(--ink);
  background: var(--light-square);
  cursor: default;
  touch-action: manipulation;
}
.chessboard .square.dark { color: #fff4d8; background: var(--dark-square); }
.chessboard .square:hover { background: var(--light-square); }
.chessboard .square.dark:hover { background: var(--dark-square); }
.square[data-active] { cursor: pointer; }
.square[data-last] { box-shadow: inset 0 0 0 .21rem #e5ac4b; }
.square[data-selected] { box-shadow: inset 0 0 0 .24rem #b46622; }
.square[data-check] { box-shadow: inset 0 0 0 .25rem var(--error); }
.square[data-destination]::after {
  position: absolute;
  content: "";
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #142e25a8;
}
.square[data-destination]:has(svg)::after {
  width: 84%;
  background: transparent;
  border: .2rem solid #243d2c;
}
.square:focus-visible { outline: 0; }
.square:focus-visible::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--ink);
  pointer-events: none;
  z-index: 1;
}
.square svg { width: 80%; height: 80%; pointer-events: none; }
.coordinate {
  position: absolute;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
}
.rank { top: .2rem; left: .18rem; }
.file { bottom: .17rem; right: .15rem; }
.player {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 2.6rem;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.player::before {
  content: "";
  flex: 0 0 .85rem;
  aspect-ratio: 1;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--ink);
}
.player[data-color="white"]::before { background: #fffdf7; }
.player[data-turn] .player-color { color: var(--ink); font-weight: 600; }
.player-color { color: var(--muted); font-weight: 400; margin-left: auto; }
dialog {
  width: min(28rem, calc(100% - 2rem));
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: 1.25rem;
  color: var(--ink);
  background: var(--paper);
}
dialog::backdrop { background: #182c2490; }
#options-actions { display: grid; gap: .45rem; }
.promotion-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; }
.promotion-choices button { display: grid; justify-items: center; padding: .25rem; }
.promotion-choices svg { width: 2.3rem; }
@media (max-width: 46rem) {
  .table-layout { display: flex; flex-direction: column; gap: .9rem; }
  .table-side { align-self: stretch; }
  body:not([data-phase]) .table-side { order: -1; }
  body:not([data-phase]) .board-area, body[data-phase="waiting"]:not([data-display]) .board-area { max-width: 25rem; width: 100%; align-self: center; }
  body[data-phase="waiting"]:not([data-display]) .table-side { order: -1; }
  h1 { font-size: 2.75rem; }
}
@media (max-width: 24rem) {
  .masthead { padding-inline: .7rem; gap: .35rem; }
  .masthead .home { font-size: .9rem; }
  .masthead .home span { display: none; }
  .masthead :is(select, button) { padding-inline: .4rem; }
}
