:root {
  color-scheme: dark;
  --bg: #302e2b;
  --panel: #262522;
  --line: #45433f;
  --muted: #b3b1ac;
  --text: #f4f3ef;
  --accent: #81b64c;
  --light: #eeeed2;
  --dark: #769656;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
button,
input,
select {
  font: inherit;
}
button,
select,
summary {
  cursor: pointer;
}
button {
  color: inherit;
  touch-action: manipulation;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
h1,
h2,
p {
  margin-top: 0;
}
h1 {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 0;
}
h2 {
  font-size: 16px;
  font-weight: 650;
  margin-bottom: 0;
}
.topbar {
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.6px;
}
.brand-icon {
  width: 28px;
  height: 28px;
  fill: var(--accent);
}
.connection {
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.connection:before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d8ad6a;
}
.connection.online:before {
  background: var(--accent);
}
main {
  --board-width: min(720px, calc(100dvh - 220px));
  width: calc(100% - 48px);
  max-width: calc(var(--board-width) + 344px);
  margin: 24px auto;
  display: grid;
  grid-template-columns: minmax(0, var(--board-width)) 320px;
  gap: 24px;
  align-items: start;
}
.play-panel,
.details-panel {
  min-width: 0;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.badge {
  font-size: 11px;
  padding: 4px 7px;
  border-radius: 4px;
  color: var(--muted);
  background: #ffffff08;
  white-space: nowrap;
}
.muted,
.hint {
  color: var(--muted);
}
.board-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  color: var(--muted);
  margin-bottom: 5px;
}
.icon-button {
  display: grid;
  place-items: center;
  background: #ffffff09;
  border: 0;
  border-radius: 5px;
  width: 36px;
  height: 36px;
}
.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-button:hover {
  background: #ffffff12;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  min-height: 38px;
}
.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: #464440;
  color: #dbdad4;
  border-radius: 5px;
}
.avatar.light {
  background: #e5e4de;
  color: #55534e;
}
.avatar svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.player-row strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
}
.player-row small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.pill {
  margin-left: auto;
  font-size: 11px;
  font-weight: 550;
  color: #cfcdc6;
  background: #ffffff08;
  padding: 6px 9px;
  border-radius: 4px;
}
.board-wrap {
  position: relative;
}
#annotations {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
}
.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.square {
  border: 0;
  border-radius: 0;
  position: relative;
  padding: 0;
  background: var(--light);
  color: #597a3e;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  cursor: default;
}
.square.dark {
  background: var(--dark);
  color: #eeeed2;
}
.square.playable {
  cursor: pointer;
}
.square:focus-visible {
  outline: 3px solid #447ad3;
  outline-offset: -3px;
  z-index: 1;
}
.board.dragging,
.board.dragging .square {
  cursor: grabbing;
}
.piece {
  display: block;
  position: relative;
  width: 91%;
  height: 91%;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px #0002);
}
.piece[hidden] {
  display: none;
}
.piece svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.square.drag-source .piece {
  visibility: hidden;
}
.square.drop-target {
  outline: 3px solid #fff9;
  outline-offset: -3px;
}
.drag-piece {
  position: fixed !important;
  top: 0;
  left: 0;
  z-index: 1000 !important;
  pointer-events: none;
  filter: drop-shadow(0 3px 2px #0004);
}
.square.last {
  background: #f5f682;
}
.square.dark.last {
  background: #b9cc50;
}
.square.selected {
  background: #f6f669;
}
.square.dark.selected {
  background: #baca44;
}
.square.destination:after {
  content: "";
  position: absolute;
  background: #0003;
  width: 26%;
  height: 26%;
  border-radius: 50%;
}
.square.destination.occupied:after {
  width: 94%;
  height: 94%;
  background: transparent;
  border: 5px solid #0003;
}
.square.checked {
  background-image: radial-gradient(
    ellipse,
    #e44739 0%,
    #df5546b0 45%,
    transparent 75%
  );
}
.coord {
  position: absolute;
  font-size: clamp(10px, 1vw, 12px);
  font-weight: 650;
  z-index: 3;
  pointer-events: none;
}
.rank {
  top: 4px;
  left: 5px;
}
.file {
  bottom: 3px;
  right: 5px;
}
.game-status {
  font-size: 13px;
  line-height: 1.5;
  color: #d4d2cb;
  margin: 15px 0 10px;
}
.game-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 16px;
}
.text-button {
  background: none;
  border: 0;
  padding: 5px 0;
  font-size: 12px;
  color: var(--muted);
}
.text-button:hover {
  color: var(--text);
}
#copy-fen {
  margin-left: auto;
}
.board-setting {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  margin: 0 0 16px;
  color: var(--muted);
}
.board-setting input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}
#error {
  display: block;
  color: #f4a18c;
  font-size: 13px;
  line-height: 1.5;
}
#error:empty {
  display: none;
}
.fen-box {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  color: var(--muted);
  font-size: 12px;
}
.fen-box code {
  display: block;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.7;
  margin-top: 10px;
}
.card {
  background: var(--panel);
  border-radius: 7px;
  padding: 20px;
  margin-bottom: 16px;
}
form {
  margin-top: 18px;
}
label {
  display: block;
  font-size: 12px;
  color: #cfcdc6;
  margin-bottom: 7px;
}
select,
input {
  width: 100%;
  min-width: 0;
  background: #373530;
  color: var(--text);
  border: 1px solid #4b4943;
  border-radius: 5px;
  padding: 10px;
  font-size: 14px;
  outline-offset: 1px;
}
input {
  font-variant-numeric: tabular-nums;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}
.primary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-top: 17px;
  padding: 12px 14px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-bottom: 3px solid #5b8a33;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
}
.primary:hover:not(:disabled) {
  background: #90c65a;
}
.primary:active:not(:disabled) {
  transform: translateY(1px);
}
.games-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  max-height: 220px;
  overflow-y: auto;
}
.game-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 10px 12px;
  text-align: left;
  background: #ffffff04;
}
.game-item:hover {
  background: #ffffff0b;
}
.game-item.active {
  background: #81b64c14;
  border-color: #81b64c66;
}
.game-number {
  display: block;
  margin-bottom: 5px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.3px;
}
.game-item strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.game-item small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}
.hint {
  font-size: 12px;
  line-height: 1.6;
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}
.telemetry .eyebrow {
  margin-top: 18px;
}
.big-timing {
  display: flex;
  align-items: baseline;
  gap: 0;
  font-size: 13px;
  color: var(--muted);
}
.big-timing > span:first-child {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.8px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.timing-details {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted);
}
.telemetry dl {
  margin: 8px 0 0;
  font-size: 12px;
}
.telemetry dl > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
  color: var(--text);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.timing-fault {
  font-size: 12px;
  color: #f0aa7e;
  line-height: 1.5;
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}
.timing-fault:empty {
  display: none;
}
.move-list {
  max-height: 230px;
  overflow: auto;
  font-size: 14px;
  margin-top: 14px;
}
.move-list > p {
  font-size: 12px;
}
.move-row {
  display: grid;
  grid-template-columns: 24px 1fr 1fr;
  padding: 9px 6px;
  gap: 5px;
  font-variant-numeric: tabular-nums;
  border-radius: 3px;
}
.move-row:nth-child(odd) {
  background: #ffffff05;
}
.move-number {
  color: var(--muted);
  font-size: 12px;
}
.move-entry {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.move-entry small {
  color: var(--muted);
  font-size: 10px;
}
footer {
  max-width: 1064px;
  margin: 0 auto;
  padding: 0 24px 24px;
  font-size: 11px;
  line-height: 1.5;
  color: #a8a59e;
}
dialog {
  width: min(420px, calc(100% - 32px));
  max-width: none;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 12px 50px #0006;
}
dialog::backdrop {
  background: #0009;
}
dialog h2 {
  font-size: 20px;
}
dialog p {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}
.promotion-options {
  display: flex;
  gap: 8px;
  margin: 20px 0 12px;
}
.promotion-options button {
  flex: 1;
  min-width: 0;
  padding: 10px 4px;
  font-size: 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #ffffff08;
}
.promotion-options button:hover {
  background: #81b64c22;
  border-color: var(--accent);
}
.promotion-options .piece {
  width: 48px;
  height: 48px;
  max-width: 100%;
  margin: 0 auto 7px;
}
@media (max-width: 800px) {
  main {
    width: calc(100% - 32px);
    max-width: 640px;
    grid-template-columns: 1fr;
    gap: 18px;
    margin-top: 20px;
  }
  .details-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }
  .card {
    margin-bottom: 0;
  }
}
@media (max-width: 600px) {
  .topbar {
    height: 58px;
    padding: 0 16px;
  }
  .brand {
    font-size: 19px;
    gap: 8px;
  }
  .brand-icon {
    width: 24px;
    height: 24px;
  }
  .connection {
    font-size: 11px;
  }
  main {
    width: calc(100% - 24px);
    margin-top: 16px;
  }
  .details-panel {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 23px;
  }
  .board-heading {
    margin-bottom: 12px;
  }
  .player-row strong {
    font-size: 13px;
  }
  .player-row small {
    font-size: 11px;
  }
  .pill {
    font-size: 10px;
    padding: 5px 7px;
  }
  .card {
    padding: 18px;
  }
  dialog {
    padding: 20px;
  }
  footer {
    padding: 0 16px 20px;
  }
}

[hidden] { display: none !important; }
.game-type { display: flex; gap: 4px; margin-bottom: 18px; padding: 4px; background: #ffffff08; border-radius: 6px; }
.game-type button { flex: 1; border: 0; background: transparent; border-radius: 4px; padding: 9px 4px; font-size: 12px; }
.game-type button[aria-pressed="true"] { background: #55534b; }
#new-game.engine-match .form-row { grid-template-columns: 1fr; }
#black-mode { margin-bottom: 4px; }
label[for="black-mode"] { margin-top: 14px; }
.player-row > div { min-width: 0; overflow-wrap: anywhere; }
.avatar { flex-shrink: 0; }
