:root {
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-synthesis: none;
  color-scheme: dark;
  --bg: #181a1d;
  --panel: #202327;
  --line: #ffffff0f;
  --text: #e9e9e7;
  --muted: #92979c;
  --accent: #e8bb94;
  --light: #c7cfd2;
  --dark: #6c7e88;
  --board-size: min(100%, calc(var(--viewport-height, 100dvh) - 154px));
  background: var(--bg);
  color: var(--text);
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
button,
input {
  font: inherit;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  cursor: pointer;
  transition:
    background 0.16s,
    color 0.16s,
    border-color 0.16s,
    opacity 0.16s,
    transform 0.16s;
}
button:disabled {
  opacity: 0.38;
  cursor: default;
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  gap: 9px;
  align-items: center;
  font-size: 20px;
  letter-spacing: -0.8px;
  font-weight: 650;
  color: var(--text);
  text-decoration: none;
}
.brand > span {
  font-size: 31px;
  color: var(--accent);
  font-weight: 400;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 27px;
}
.theme-picker select {
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 7px;
  cursor: pointer;
  max-width: 96px;
}
.theme-picker select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.tools-link > .tools-name {
  margin-left: 0;
}
.tools-link {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}
.tools-link:hover {
  color: var(--text);
}
.tools-link > span {
  margin-left: 9px;
}
.connection {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}
.connection i {
  width: 5px;
  height: 5px;
  background: #b88f5d;
  border-radius: 50%;
}
.connection.online i {
  background: #9bae95;
}
.workspace {
  height: calc(var(--viewport-height, 100dvh) - 48px);
  max-width: min(100%, calc(var(--viewport-height, 100dvh) + 222px));
  margin: 0 auto;
  padding: 6px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  min-height: 0;
}
.arena {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 28px auto 28px 20px;
  align-content: center;
  gap: 6px;
  justify-items: center;
  align-items: center;
}
.board-wrap {
  position: relative;
  width: var(--board-size);
  aspect-ratio: 1;
  border-radius: 5px;
  box-shadow: 0 12px 35px #0002;
  isolation: isolate;
  align-self: center;
}
.board {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.square {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: var(--light);
  cursor: default;
}
.square.dark {
  background: var(--dark);
}
.square.interactive {
  cursor: grab;
}
.square:active {
  transform: none !important;
}
.square:before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  transition: background 0.14s;
  z-index: 0;
}
.square.last:before {
  background: #e9c38242;
}
.square.selected:before {
  background: #f3c8899c;
}
.square.premove:before {
  background: #9aa5e39c;
}
.square.check:before {
  background: radial-gradient(ellipse, #f08a78a6, transparent 75%);
}
.square.legal:after {
  position: absolute;
  content: "";
  width: 22%;
  height: 22%;
  top: 39%;
  left: 39%;
  border-radius: 50%;
  background: #16263144;
  z-index: 4;
  pointer-events: none;
}
.square.legal.occupied:after {
  width: 90%;
  height: 90%;
  top: 5%;
  left: 5%;
  background: none;
  border: 5px solid #14273155;
}
.square.prelegal:after {
  background: #35458559;
}
.square:focus-visible {
  outline: 2px solid #f3c486;
  outline-offset: -3px;
  z-index: 4;
}
.coord {
  position: absolute;
  font-size: 10px;
  font-weight: 600;
  color: #5c707c;
  pointer-events: none;
  z-index: 5;
}
.dark .coord {
  color: #d4dce0;
}
.rank-label {
  left: 5px;
  top: 4px;
}
.file-label {
  right: 5px;
  bottom: 3px;
}
.piece-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
.piece-node {
  position: absolute;
  top: 0;
  left: 0;
  width: 12.5%;
  height: 12.5%;
  display: grid;
  place-items: center;
  will-change: transform;
  pointer-events: none;
}
.piece {
  display: block;
  width: 91%;
  height: 91%;
  pointer-events: none;
  filter: drop-shadow(0 2px 1px #13212a38);
}
.piece.white {
  --piece-fill: #f8f5ea;
  --piece-line: #3f4548;
}
.piece.black {
  --piece-fill: #293136;
  --piece-line: #151c21;
}
.piece .shape {
  fill: inherit;
  stroke: var(--piece-line);
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.piece .detail {
  stroke: var(--piece-line);
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.piece.black .detail {
  stroke: #89979c;
}
.piece-node.captured {
  z-index: 1;
}
.piece-node.drag-source {
  opacity: 0;
}
.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 8px 4px #0004);
}
.drag-hover {
  box-shadow: inset 0 0 0 3px #fff7;
}
.match-flash {
  position: absolute;
  inset: -2px;
  pointer-events: none;
  border: 2px solid transparent;
  border-radius: 6px;
  z-index: 7;
}
.match-flash.arriving {
  animation: match-found 1.1s ease-out;
}
.player-row {
  width: var(--board-size);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.player-info {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-info > div {
  min-width: 0;
}
.player-info strong {
  font-size: 13px;
  font-weight: 550;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-info span:not(.side-marker) {
  font-size: 10px;
  color: var(--muted);
  display: block;
  margin-top: 4px;
}
.side-marker {
  height: 20px;
  width: 20px;
  border-radius: 50%;
  flex-shrink: 0;
}
.white-side {
  background: #e8e7de;
  border: 1px solid #ffffffe0;
  box-shadow: inset 0 -3px 0 #0001;
}
.black-side {
  background: #30373c;
  border: 1px solid #7b878c;
  box-shadow: inset 0 -3px 0 #0002;
}
.clock {
  min-width: 112px;
  padding: 3px 12px;
  border-radius: 5px;
  background: #24282c;
  color: #929a9f;
  font:
    500 23px/1.1 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition:
    background 0.2s,
    color 0.2s;
}
.clock.active {
  color: #202326;
  background: var(--accent);
}
.clock.low {
  color: #f3a895;
  background: #482d2b;
}
.clock.active.low {
  color: #291615;
  background: #efa18f;
}
.board-tools {
  width: var(--board-size);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
  min-width: 0;
}
.board-tools > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.board-tools > div {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.icon-button {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 5px;
  border-radius: 4px;
  display: grid;
  place-items: center;
}
.icon-button:hover {
  color: var(--text);
  background: #ffffff0a;
}
.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.game-summary {
  padding: 23px 22px 21px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}
.summary-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 21px;
  gap: 15px;
}
.eyebrow {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #90989d;
  font-weight: 600;
}
.time-badge {
  color: #aeb6ba;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 47px;
  margin-bottom: 21px;
}
h1 {
  font-size: 21px;
  font-weight: 500;
  letter-spacing: -0.65px;
  margin: 0 0 7px;
}
#panel-description {
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0;
}
.time-controls {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
.time-controls button {
  flex: 1;
  min-width: 0;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px solid #ffffff0c;
  background: #272b30;
  color: #c5cbce;
  border-radius: 5px;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.time-controls button > span {
  font-size: 9px;
  color: #899299;
  font-weight: 400;
}
.time-controls button:hover {
  border-color: #ffffff30;
}
.time-controls button.selected {
  background: #e8bb9412;
  color: var(--accent);
  border-color: #e8bb9480;
}
.time-controls button.selected > span {
  color: #c8a384;
}
.primary {
  height: 44px;
  border: 0;
  border-radius: 5px;
  background: var(--accent);
  color: #242627;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  width: 100%;
}
.primary:hover {
  background: #f1c8a3;
}
.primary > span:last-child {
  font-size: 18px;
  font-weight: 400;
}
.searching .primary {
  background: #2a2e32;
  color: #c7cccf;
  border: 1px solid #ffffff15;
}
.searching .primary:hover {
  background: #33383d;
}
.searching h1 {
  font-size: 18px;
}
.hourglass {
  width: 30px;
  height: 38px;
  flex-shrink: 0;
}
.hourglass svg {
  display: block;
  width: 100%;
  height: 100%;
  animation: hourglass-turn 3s cubic-bezier(0.6, 0, 0.3, 1) infinite;
}
.glass-outline,
.glass-rim {
  stroke: #d6b99b;
  stroke-width: 1.8;
  stroke-linecap: round;
  fill: none;
}
.sand-top,
.sand-bottom {
  fill: var(--accent);
  transform-box: fill-box;
  transform-origin: bottom;
}
.sand-top {
  animation: sand-empty 3s linear infinite;
}
.sand-bottom {
  animation: sand-fill 3s linear infinite;
}
.sand-stream {
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-dasharray: 1 2;
  animation: sand-flow 0.25s linear infinite;
}
.activity {
  min-height: 0;
  flex: 1 0 140px;
  display: flex;
  flex-direction: column;
}
.tabs {
  display: flex;
  align-items: stretch;
  gap: 24px;
  padding: 0 22px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  height: 48px;
}
.tabs button {
  color: var(--muted);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tabs button[aria-selected="true"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}
#move-count {
  color: #79838b;
  font-size: 10px;
}
.unread {
  border-radius: 9px;
  background: var(--accent);
  color: #222;
  min-width: 15px;
  font-size: 9px;
  line-height: 15px;
  text-align: center;
  padding: 0 4px;
}
.tab-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.move-list,
.chat-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #3f474e transparent;
  min-height: 0;
  flex: 1;
}
.empty-state {
  height: 100%;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 18px;
  color: #758088;
  font-size: 11px;
  gap: 7px;
}
.empty-state > p {
  margin: 0;
  color: #a6afb4;
  font-size: 12px;
}
.empty-board {
  font-size: 30px;
  color: #63717b;
  margin-bottom: 4px;
}
.empty-state > span:last-child {
  font-size: 10px;
  line-height: 1.5;
}
.move-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr;
  min-height: 34px;
  align-items: center;
  padding: 0 22px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: #c7cdd0;
}
.move-row:nth-child(even) {
  background: #ffffff03;
}
.move-row > span:first-child {
  color: #707b83;
  font-size: 10px;
}
.move-row .latest-move {
  color: var(--accent);
}
.game-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 13px 15px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.action-button {
  border: 0;
  background: transparent;
  color: #b2bbc1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  height: 32px;
  flex: 1;
  font-size: 11px;
  border-radius: 4px;
}
.action-button:hover {
  color: var(--text);
  background: #ffffff08;
}
.action-button > span {
  font-size: 19px;
}
.action-button > svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.lobby-note {
  font-size: 10px;
  color: #707d85;
  text-align: center;
  padding: 14px;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
}
.draw-response {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  padding-top: 14px;
  border-top: 1px solid #e8bb9420;
  font-size: 11px;
  color: var(--accent);
}
.draw-response > div {
  display: flex;
  gap: 8px;
}
.small-primary,
.secondary,
.danger-button {
  border: 1px solid #ffffff16;
  border-radius: 5px;
  background: #323a40;
  color: var(--text);
  padding: 8px 12px;
  font-size: 12px;
}
.small-primary {
  background: var(--accent);
  color: #242627;
  border: 0;
  font-size: 11px;
  padding: 7px 10px;
}
.quiet-button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  padding: 6px 0;
}
.quiet-button:hover {
  color: var(--text);
}
#cancel-premove {
  color: #b1bced;
  font-size: 10px;
}
#cancel-premove > span {
  margin-left: 4px;
}
.chat-list {
  padding: 12px 16px;
}
.chat-message {
  margin: 0 0 12px;
  padding: 9px 11px;
  max-width: 96%;
  border-radius: 6px;
  background: #ffffff08;
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  animation: message-in 0.18s ease-out;
}
.chat-message .chat-author {
  font-size: 11px;
  letter-spacing: 0.2px;
  color: #88949c;
  display: block;
  margin-bottom: 4px;
}
.chat-message p {
  margin: 0;
  color: #d1d7da;
  white-space: pre-wrap;
}
.chat-message.mine .chat-author {
  color: #cba681;
}
.chat-message.mine {
  margin-left: auto;
  background: #e8bb9412;
}
.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 14px 4px;
  flex-shrink: 0;
}
.chat-form input {
  min-width: 0;
  width: 100%;
  height: 36px;
  border: 1px solid #ffffff14;
  border-radius: 5px;
  background: #191d20;
  color: var(--text);
  font-size: 16px;
  padding: 0 10px;
}
.chat-form input::placeholder {
  color: #728089;
}
.chat-form button {
  height: 36px;
  min-width: 48px;
  border: 0;
  border-radius: 5px;
  background: #e8bb941c;
  color: var(--accent);
  font-size: 12px;
}
.chat-feedback {
  min-height: 0;
  padding: 0 14px 5px;
  font-size: 9px;
  color: #cda99e;
}
.chat-feedback:empty {
  display: none;
}
.chat-notice {
  flex-shrink: 0;
  display: grid;
  gap: 4px;
  margin: 8px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 5px;
  text-align: left;
  background: #ffffff0a;
  color: var(--text);
  font-size: 13px;
}
.chat-notice strong,
.chat-notice-open {
  font-size: 11px;
}
#chat-notice-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-notice-open {
  color: var(--muted);
}
.chat-jump {
  align-self: center;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 5px 12px;
  margin: 4px;
  font-size: 12px;
}
.tabs #close-chat {
  display: none;
}
.tabs #expand-chat {
  margin-left: auto;
  padding: 0 8px;
  font-size: 20px;
  border: 0;
}
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #eef0ee;
  color: #283238;
  border-radius: 6px;
  padding: 11px 18px;
  font-size: 12px;
  max-width: min(450px, 90vw);
  box-shadow: 0 8px 30px #0004;
  z-index: 200;
  text-align: center;
  animation: toast-in 0.2s ease-out;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
dialog {
  border: 1px solid #ffffff19;
  border-radius: 10px;
  padding: 28px;
  background: #22272b;
  color: var(--text);
  box-shadow: 0 20px 90px #0007;
  text-align: center;
  max-width: calc(100vw - 32px);
}
dialog::backdrop {
  background: #0b1013a6;
  backdrop-filter: blur(6px);
}
dialog[open] {
  animation: dialog-in 0.2s ease-out;
}
dialog h2 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.5px;
  margin: 0 0 14px;
}
dialog p {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 24px;
}
.promotion-choices {
  display: flex;
  gap: 8px;
  margin: 20px 0 12px;
}
.promotion-choices button {
  width: 64px;
  height: 68px;
  background: #6c7e8850;
  border: 1px solid #ffffff0f;
  border-radius: 6px;
  padding: 0;
  display: grid;
  place-items: center;
}
.promotion-choices button:hover {
  background: #e8bb9440;
}
.confirm-actions {
  display: flex;
  gap: 10px;
}
.confirm-actions button {
  flex: 1;
}
.danger-button {
  background: #ac6859;
  color: #fff;
  border-color: transparent;
}
.danger-button:hover {
  background: #be7666;
}
@keyframes hourglass-turn {
  0%,
  68% {
    transform: rotate(0);
  }
  88%,
  100% {
    transform: rotate(180deg);
  }
}
@keyframes sand-empty {
  0% {
    transform: scaleY(1);
  }
  65%,
  100% {
    transform: scaleY(0.08);
  }
}
@keyframes sand-fill {
  0% {
    transform: scaleY(0.08);
  }
  65%,
  100% {
    transform: scaleY(1);
  }
}
@keyframes sand-flow {
  to {
    stroke-dashoffset: -3;
  }
}
@keyframes match-found {
  0% {
    border-color: #e8bb9400;
    box-shadow: 0 0 0 0 #e8bb9450;
  }
  20% {
    border-color: #e8bb94bb;
  }
  100% {
    border-color: transparent;
    box-shadow: 0 0 0 12px #e8bb9400;
  }
}
@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes toast-in {
  from {
    opacity: 0;
    translate: 0 5px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@keyframes dialog-in {
  from {
    opacity: 0;
    scale: 0.97;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}
@media (max-width: 960px) {
  .workspace {
    padding: 6px 16px;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) 268px;
  }
  .game-summary {
    padding: 20px 18px;
  }
  .tabs {
    padding: 0 18px;
  }
  .topbar {
    padding: 0 24px;
  }
  .clock {
    font-size: 25px;
    min-width: 100px;
  }
  :root {
    --board-size: min(100%, calc(var(--viewport-height, 100dvh) - 154px));
  }
}
@media (max-width: 680px) and (orientation: portrait) {
  :root {
    --board-size: min(100%, calc(var(--viewport-height, 100dvh) - 194px));
  }
  .topbar {
    height: 48px;
    padding: 0 16px;
  }
  .brand {
    font-size: 17px;
  }
  .brand > span {
    font-size: 27px;
  }
  .topbar-right {
    gap: 10px;
  }
  .theme-picker select {
    font-size: 11px;
    max-width: 79px;
    padding: 4px;
  }
  .tools-home .tools-name {
    display: none;
  }
  .connection {
    font-size: 0;
    gap: 0;
  }
  .tools-link {
    font-size: 10px;
  }
  .tools-link > span {
    margin-left: 4px;
  }
  .workspace {
    height: calc(var(--viewport-height, 100dvh) - 48px);
    padding: 8px;
    gap: 8px;
    display: flex;
    flex-direction: column;
  }
  .arena {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 4px;
    align-items: center;
  }
  .board-wrap {
    align-self: center;
  }
  .player-row {
    height: 28px;
  }
  .player-info strong {
    font-size: 12px;
  }
  .player-info span:not(.side-marker) {
    font-size: 9px;
    margin-top: 2px;
  }
  .side-marker {
    width: 16px;
    height: 16px;
  }
  .clock {
    font-size: 22px;
    min-width: 94px;
    height: 28px;
    padding: 2px 10px;
  }
  .board-tools {
    height: 22px;
    font-size: 9px;
  }
  .icon-button {
    height: 24px;
    width: 24px;
    padding: 4px;
  }
  .sidebar {
    flex: 1;
    min-height: 0;
    border-radius: 7px;
    display: flex;
    flex-direction: column;
  }
  .game-summary {
    padding: 12px 14px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    align-items: center;
  }
  .summary-heading {
    display: none;
  }
  .status-line {
    margin: 0;
    min-height: 32px;
    gap: 8px;
  }
  h1,
  .searching h1 {
    font-size: 15px;
    margin: 0 0 3px;
    letter-spacing: -0.3px;
  }
  #panel-description {
    font-size: 10px;
    line-height: 1.35;
  }
  .time-controls {
    grid-column: 1;
    grid-row: 2;
    margin: 8px 0 0;
    gap: 5px;
  }
  .time-controls button {
    height: 30px;
    font-size: 14px;
  }
  .time-controls button > span {
    font-size: 8px;
  }
  .primary {
    grid-column: 2;
    grid-row: 1/3;
    width: 94px;
    align-self: stretch;
    height: auto;
    min-height: 36px;
    font-size: 11px;
    padding: 8px;
    gap: 0;
  }
  .primary > span:last-child {
    display: none;
  }
  .hourglass {
    width: 23px;
    height: 30px;
  }
  .activity {
    min-height: 0;
  }
  .tabs {
    height: 35px;
    padding: 0 14px;
    gap: 24px;
  }
  .tabs button {
    font-size: 11px;
  }
  .empty-state {
    padding: 8px;
    min-height: 48px;
    gap: 4px;
  }
  .empty-board {
    display: none;
  }
  .empty-state p {
    font-size: 11px;
  }
  .empty-state > span:last-child {
    font-size: 9px;
  }
  .move-row {
    min-height: 27px;
    font-size: 12px;
    padding: 0 15px;
  }
  .lobby-note {
    display: none;
  }
  .game-actions {
    padding: 6px 10px;
    gap: 5px;
  }
  .action-button {
    height: 27px;
  }
  .draw-response {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    padding: 0;
    border: 0;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
  }
  .draw-response > span {
    font-size: 9px;
  }
  .draw-response > div {
    gap: 6px;
  }
  .small-primary {
    padding: 5px 8px;
    font-size: 10px;
  }
  .draw-response .quiet-button {
    font-size: 10px;
  }
  .chat-list {
    padding: 9px 13px;
  }
  .chat-message {
    margin-bottom: 10px;
    font-size: 15px;
  }
  .chat-form {
    padding: 6px 10px 3px;
    gap: 6px;
  }
  .chat-form input {
    height: 42px;
    font-size: 16px;
  }
  .chat-form button {
    height: 42px;
  }
  .chat-feedback {
    min-height: 0;
    font-size: 9px;
    padding: 0 10px 3px;
  }
  .chat-pane .empty-state {
    min-height: 30px;
  }
  .coord {
    font-size: 8px;
    left: 3px;
  }
  .file-label {
    left: auto;
    right: 3px;
    bottom: 2px;
  }
  .rank-label {
    top: 2px;
  }
  .square.legal.occupied:after {
    border-width: 3px;
  }
  .promotion-choices button {
    width: 54px;
    height: 59px;
  }
  .toast {
    bottom: 12px;
    font-size: 11px;
  }
  body.in-game .game-summary {
    display: none;
  }
  body.in-game .activity {
    flex: 1 0 58px;
  }
  body.chat-open .sidebar {
    position: fixed;
    z-index: 30;
    top: var(--chat-top);
    left: 8px;
    right: 8px;
    height: var(--chat-height);
    box-shadow: 0 -12px 40px #0007;
    border-radius: 10px 10px 3px 3px;
  }
  body.chat-open .game-summary,
  body.chat-open .lobby-note {
    display: none;
  }
  body.chat-open .activity {
    flex: 1 1 0;
    min-height: 0;
  }
  body.chat-open .tabs {
    height: 42px;
  }
  body.chat-open .tabs #close-chat {
    display: block;
    margin-left: auto;
    font: 25px/1 sans-serif;
    padding: 0 8px;
    border: 0;
  }
  body.chat-open .chat-form {
    padding-bottom: 8px;
  }
  body.chat-open #chat-pane {
    min-height: 0;
  }
  body.in-game .chat-notice {
    margin: 4px 8px;
    padding: 7px 10px;
    grid-template-columns: minmax(0, 1fr) auto;
  }
  body.in-game #chat-notice-author,
  body.in-game .chat-notice-open {
    display: none;
  }
  body.in-game .chat-notice::after {
    content: "↗";
  }
}
@media (max-height: 620px) and (orientation: landscape) {
  :root {
    --board-size: min(100%, calc(var(--viewport-height, 100dvh) - 142px));
  }
  .topbar {
    height: 44px;
    padding: 0 20px;
  }
  .workspace {
    height: calc(var(--viewport-height, 100dvh) - 44px);
    padding: 6px 16px;
    gap: 24px;
    grid-template-columns: minmax(0, 1fr) 265px;
  }
  .arena {
    grid-template-rows: 29px minmax(0, 1fr) 29px 18px;
    gap: 6px;
  }
  .player-row {
    height: 29px;
  }
  .player-info span:not(.side-marker) {
    display: none;
  }
  .clock {
    font-size: 21px;
    min-width: 90px;
    padding: 3px 8px;
  }
  .game-summary {
    padding: 11px 15px;
  }
  .summary-heading {
    display: none;
  }
  .status-line {
    min-height: 30px;
    margin-bottom: 9px;
  }
  h1,
  .searching h1 {
    font-size: 16px;
    margin-bottom: 3px;
  }
  #panel-description {
    font-size: 10px;
  }
  .time-controls {
    margin-bottom: 8px;
  }
  .time-controls button {
    height: 31px;
    font-size: 14px;
  }
  .primary {
    height: 32px;
  }
  .tabs {
    height: 34px;
  }
  .game-actions {
    padding: 5px 10px;
  }
  .lobby-note {
    display: none;
  }
  .hourglass {
    height: 29px;
    width: 23px;
  }
  .board-tools {
    font-size: 9px;
  }
  .board-tools .icon-button {
    width: 23px;
    height: 23px;
  }
  .empty-state {
    min-height: 45px;
    padding: 8px;
  }
  .empty-board {
    display: none;
  }
  .draw-response {
    margin-top: 7px;
    padding-top: 6px;
  }
  .coord {
    font-size: 8px;
  }
  .side-marker {
    width: 15px;
    height: 15px;
  }
  .chat-form {
    padding-top: 4px;
  }
  .chat-form input {
    height: 30px;
  }
  .chat-form button {
    height: 30px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Classic: Walnut, ivory and a quiet off-white work surface. */
:root[data-theme="classic"] {
  color-scheme: light;
  --bg: #f3f0ea;
  --panel: #faf8f4;
  --line: #43382116;
  --text: #302e28;
  --muted: #898274;
  --accent: #756149;
  --light: #eedcba;
  --dark: #af865f;
}
[data-theme="classic"] .topbar {
  background: #f7f5f0;
  border-color: #43382113;
}
[data-theme="classic"] .brand > span {
  color: #66543c;
}
[data-theme="classic"] .board-wrap {
  padding: 7px;
  background: linear-gradient(100deg, #634b37, #856247 48%, #634b37);
  border-radius: 5px;
  box-shadow:
    0 8px 26px #48392315,
    0 0 0 1px #4c362226,
    inset 0 1px 0 #bca285;
}
[data-theme="classic"] .board {
  box-shadow: 0 0 0 1px #38282070;
  border-radius: 1px;
}
[data-theme="classic"] .square {
  background-image:
    repeating-linear-gradient(
      6deg,
      #ffffff04 0 2px,
      #63492104 3px 4px,
      transparent 5px 9px
    ),
    linear-gradient(95deg, #ffffff04, #8c65240b, #ffffff06);
}
[data-theme="classic"] .square.dark {
  background-image:
    repeating-linear-gradient(
      7deg,
      #ffffff03 0 2px,
      #52321306 3px 5px,
      transparent 6px 11px
    ),
    linear-gradient(105deg, #6d481f08, #ffffff07);
}
[data-theme="classic"] .square.last:before {
  background: #ede08359;
}
[data-theme="classic"] .square.selected:before {
  background: #e4b657aa;
}
[data-theme="classic"] .coord {
  color: #94724c;
}
[data-theme="classic"] .dark .coord {
  color: #f2e3c8;
}
[data-theme="classic"] .piece {
  filter: drop-shadow(0 2px 1px #372b272e);
}
[data-theme="classic"] .piece.white {
  --piece-fill: #fff9e8;
  --piece-line: #625142;
}
[data-theme="classic"] .piece.black {
  --piece-fill: #493b32;
  --piece-line: #271f19;
}
[data-theme="classic"] .piece.black .detail {
  stroke: #ba9e7f;
}
[data-theme="classic"] .white-side {
  background: #f9f4e4;
  border-color: #c8bdad;
}
[data-theme="classic"] .black-side {
  background: #574a3c;
  border-color: #453c32;
}
[data-theme="classic"] .clock {
  background: #e7e2d9;
  color: #9c9383;
}
[data-theme="classic"] .clock.active {
  background: #504738;
  color: #fff4df;
}
[data-theme="classic"] .clock.low {
  background: #f3dfd4;
  color: #b5543d;
}
[data-theme="classic"] .sidebar {
  box-shadow: 0 4px 12px #49392304;
  border-color: #dcd5c9;
}
[data-theme="classic"] .eyebrow {
  color: #99907f;
}
[data-theme="classic"] .time-badge {
  color: #9e937f;
}
[data-theme="classic"] .time-controls button {
  background: #f0ece4;
  border-color: #e5ded2;
  color: #665847;
}
[data-theme="classic"] .time-controls button > span {
  color: #a19684;
}
[data-theme="classic"] .time-controls button.selected {
  background: #eae2d3;
  border-color: #ab9472;
  color: #5c4831;
}
[data-theme="classic"] .time-controls button.selected > span {
  color: #8e775b;
}
[data-theme="classic"] .primary {
  background: #63513d;
  color: #fff7e9;
}
[data-theme="classic"] .primary:hover {
  background: #51412f;
}
[data-theme="classic"] .searching .primary {
  background: #ede7dc;
  color: #7f6c51;
  border-color: #dacfbb;
}
[data-theme="classic"] .glass-outline,
[data-theme="classic"] .glass-rim {
  stroke: #8a7455;
}
[data-theme="classic"] .tabs button[aria-selected="true"] {
  border-bottom-color: #8e7551;
}
[data-theme="classic"] #move-count {
  color: #aaa08d;
}
[data-theme="classic"] .empty-state {
  color: #b0a691;
}
[data-theme="classic"] .empty-state > p {
  color: #918570;
}
[data-theme="classic"] .empty-board {
  color: #c0b196;
}
[data-theme="classic"] .move-list,
[data-theme="classic"] .chat-list {
  scrollbar-color: #d6cdbd transparent;
}
[data-theme="classic"] .move-row {
  color: #685c4b;
}
[data-theme="classic"] .move-row:nth-child(even) {
  background: #75614906;
}
[data-theme="classic"] .move-row > span:first-child {
  color: #b4a892;
}
[data-theme="classic"] .move-row .latest-move {
  color: #594226;
  font-weight: 600;
}
[data-theme="classic"] .action-button {
  color: #8b795f;
}
[data-theme="classic"] .action-button:hover,
[data-theme="classic"] .icon-button:hover {
  color: #493821;
  background: #7561490b;
}
[data-theme="classic"] .lobby-note {
  color: #b0a58f;
}
[data-theme="classic"] .draw-response {
  color: #7b633f;
  border-color: #a58a582a;
}
[data-theme="classic"] .small-primary {
  background: #776145;
  color: #fff9ee;
}
[data-theme="classic"] .chat-message .chat-author {
  color: #a19583;
}
[data-theme="classic"] .chat-message.mine .chat-author {
  color: #866540;
}
[data-theme="classic"] .chat-message p {
  color: #625442;
}
[data-theme="classic"] .chat-form input {
  background: #f4f0e8;
  color: #443a2d;
  border-color: #dfd6c8;
}
[data-theme="classic"] .chat-form input::placeholder {
  color: #b1a48d;
}
[data-theme="classic"] .chat-form button {
  background: #e9e1d2;
  color: #8a704b;
}
[data-theme="classic"] .unread {
  background: #8d7451;
  color: #fff;
}
[data-theme="classic"] .chat-feedback {
  color: #a65d48;
}
[data-theme="classic"] dialog {
  background: #f7f3ea;
  border-color: #d8c9b3;
  color: #433a2d;
}
[data-theme="classic"] dialog::backdrop {
  background: #30271965;
}
[data-theme="classic"] .secondary {
  background: #ece5d8;
  border-color: #d8cbb7;
  color: #746044;
}
[data-theme="classic"] .promotion-choices button {
  background: #e8dcc4;
  border-color: #cbbb9e;
}
[data-theme="classic"] .promotion-choices button:hover {
  background: #d6c5a5;
}
[data-theme="classic"] .toast {
  background: #4c4030;
  color: #fff5e5;
}

/* Citadel is the default on desktop and mobile; all themes remain selectable. */
:root[data-theme="citadel"] {
  --bg: #201b15;
  --panel: #2e261c;
  --line: #ddbd7630;
  --text: #e5d6b8;
  --muted: #ac9978;
  --accent: #d5b379;
  --light: #d7c19a;
  --dark: #87704e;
  background: #201b15 url("/chess/art/citadel.webp") center/cover fixed;
}
[data-theme="citadel"] body {
  background: linear-gradient(
    90deg,
    #15110940,
    #15110915 30%,
    #15110915 70%,
    #15110940
  );
}
[data-theme="citadel"] .topbar {
  background: linear-gradient(#211c16dd, #17130fe8);
  border-bottom: 1px solid #c0a26a55;
  box-shadow: 0 2px 10px #0005;
}
[data-theme="citadel"] .brand {
  font-family: Georgia, serif;
  font-variant: small-caps;
  font-size: 25px;
  letter-spacing: 1.5px;
  font-weight: 400;
  color: #e1c99a;
}
[data-theme="citadel"] .topbar .brand > span {
  color: #c1a674;
  font-size: 34px;
}
[data-theme="citadel"] .workspace {
  gap: 24px;
}
[data-theme="citadel"] .board-wrap {
  padding: 12px;
  background: repeating-linear-gradient(
    2deg,
    #60452b 0 3px,
    #583d27 4px 7px,
    #644b33 8px 10px
  );
  border: 1px solid #b79a6699;
  border-radius: 1px;
  box-shadow:
    0 16px 40px #0009,
    inset 0 0 0 2px #281c1266,
    inset 0 0 0 5px #b0956230;
}
[data-theme="citadel"] .board-wrap:before,
[data-theme="citadel"] .board-wrap:after {
  content: "◆";
  position: absolute;
  z-index: 10;
  font-size: 10px;
  line-height: 12px;
  color: #d0ad72;
  pointer-events: none;
  top: -1px;
  left: 0;
  text-shadow: 0 1px 1px #000;
}
[data-theme="citadel"] .board-wrap:after {
  top: auto;
  left: auto;
  bottom: -1px;
  right: 0;
}
[data-theme="citadel"] .board {
  border-radius: 0;
  box-shadow: 0 0 0 1px #231b0e;
}
[data-theme="citadel"] .square {
  background-image:
    repeating-linear-gradient(11deg, #634b2810 0 1px, transparent 2px 6px),
    linear-gradient(105deg, #eadab415, #65431710);
}
[data-theme="citadel"] .square.dark {
  background-image:
    repeating-linear-gradient(13deg, #4a362410 0 1px, transparent 2px 7px),
    linear-gradient(95deg, #12090117, #f8e5ab09);
}
[data-theme="citadel"] .piece.white {
  --piece-fill: #f2e2bf;
  --piece-line: #584735;
}
[data-theme="citadel"] .piece.black {
  --piece-fill: #483627;
  --piece-line: #20170f;
}
[data-theme="citadel"] .piece.black .detail {
  stroke: #ac9166;
}
[data-theme="citadel"] .coord {
  color: #88704b;
}
[data-theme="citadel"] .dark .coord {
  color: #e7d2aa;
}
[data-theme="citadel"] .sidebar {
  border: 1px solid #b0925888;
  border-radius: 2px;
  background: linear-gradient(105deg, #e0cfa8, #d0bd91 53%, #dacaa5);
  box-shadow:
    0 8px 35px #0008,
    inset 0 0 0 3px #a88a5d60,
    inset 0 0 30px #6f542126;
  color: #453625;
  --text: #463725;
  --muted: #897251;
  --line: #76532330;
}
[data-theme="citadel"] .game-summary {
  position: relative;
  border-bottom: 1px solid #93723c77;
  padding-top: 25px;
}
[data-theme="citadel"] .summary-heading {
  padding-bottom: 12px;
  border-bottom: 1px solid #74562d30;
  margin-bottom: 16px;
}
[data-theme="citadel"] .eyebrow {
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 2px;
  color: #8a6a3e;
}
[data-theme="citadel"] h1 {
  font-family: Georgia, serif;
  font-size: 23px;
  font-weight: 400;
  letter-spacing: -0.4px;
  color: #4a3520;
}
[data-theme="citadel"] .time-badge {
  color: #8a6a3e;
  font-family: Georgia, serif;
}
[data-theme="citadel"] .time-controls button {
  background: linear-gradient(#f0dfb34a, #a78c5440);
  border: 1px solid #92734377;
  border-radius: 2px;
  color: #62451f;
  box-shadow: inset 0 1px 0 #fff5;
  font-family: Georgia, serif;
}
[data-theme="citadel"] .time-controls button > span {
  color: #947745;
  font-family: inherit;
}
[data-theme="citadel"] .time-controls button.selected {
  background: linear-gradient(#826540, #5c432b);
  border-color: #3d2a17;
  color: #e3c795;
  box-shadow:
    inset 0 0 0 1px #b99c7066,
    0 1px 2px #5436133b;
}
[data-theme="citadel"] .time-controls button.selected > span {
  color: #c0a278;
}
[data-theme="citadel"] .primary {
  background: linear-gradient(#786443, #55432b);
  border: 1px solid #452e17;
  border-radius: 2px;
  box-shadow:
    inset 0 0 0 1px #cab07a66,
    0 2px 3px #4b361740;
  color: #f1dfb5;
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.3px;
}
[data-theme="citadel"] .primary:hover {
  background: linear-gradient(#90784d, #6a5334);
}
[data-theme="citadel"] .tabs {
  background: linear-gradient(#90724418, #7d613528);
  border-bottom: 1px solid #91714055;
}
[data-theme="citadel"] .tabs button {
  font-family: Georgia, serif;
  font-size: 13px;
  color: #8d744d;
}
[data-theme="citadel"] .tabs button[aria-selected="true"] {
  color: #503920;
  border-bottom-color: #785c2c;
}
[data-theme="citadel"] #move-count {
  color: #9c8155;
}
[data-theme="citadel"] .empty-state {
  color: #a08a64;
}
[data-theme="citadel"] .empty-state > p {
  color: #816b48;
  font-family: Georgia, serif;
  font-size: 14px;
}
[data-theme="citadel"] .empty-board {
  color: #aa956f;
}
[data-theme="citadel"] .move-row {
  color: #604b30;
  font-family: Georgia, serif;
  font-size: 14px;
}
[data-theme="citadel"] .move-row > span:first-child {
  color: #a18a63;
}
[data-theme="citadel"] .move-row .latest-move {
  color: #6d361c;
  font-weight: bold;
}
[data-theme="citadel"] .move-row:nth-child(even) {
  background: #6d4b1b07;
}
[data-theme="citadel"] .game-actions {
  border-top: 1px solid #876a3f55;
  background: #63451110;
}
[data-theme="citadel"] .action-button {
  color: #816540;
  font-family: Georgia, serif;
  font-size: 12px;
}
[data-theme="citadel"] .action-button:hover {
  background: #593e2312;
  color: #503317;
}
[data-theme="citadel"] .lobby-note {
  color: #9b825a;
  font-family: Georgia, serif;
}
[data-theme="citadel"] .player-info strong {
  font-family: Georgia, serif;
  font-size: 15px;
  color: #d2bf99;
  text-shadow: 0 1px 2px #000;
}
[data-theme="citadel"] .player-info span:not(.side-marker) {
  color: #ab9877;
}
[data-theme="citadel"] .white-side {
  background: linear-gradient(110deg, #f0dfb5, #c9ad7d);
  border: 1px solid #dfc697;
}
[data-theme="citadel"] .black-side {
  background: linear-gradient(#55432f, #332519);
  border: 1px solid #a28a5b;
}
[data-theme="citadel"] .clock {
  background: linear-gradient(#30281ee8, #251c13e8);
  border: 1px solid #80674088;
  border-radius: 2px;
  color: #a2937c;
  font-family: Georgia, serif;
  letter-spacing: 0.5px;
  box-shadow: inset 0 1px 2px #0007;
}
[data-theme="citadel"] .clock.active {
  background: linear-gradient(#d6c293, #ac9465);
  color: #34281b;
  border-color: #cab07a;
  box-shadow: inset 0 0 0 2px #71532933;
}
[data-theme="citadel"] .board-tools {
  color: #a89776;
  text-shadow: 0 1px 2px #000;
}
[data-theme="citadel"] .chat-message .chat-author {
  color: #6b4f2d;
}
[data-theme="citadel"] .chat-message.mine .chat-author {
  color: #755129;
}
[data-theme="citadel"] .chat-message p {
  color: #392b1c;
}
[data-theme="citadel"] .chat-message {
  background: #fff8e459;
}
[data-theme="citadel"] .chat-message.mine {
  background: #76512315;
}
[data-theme="citadel"] .chat-notice {
  background: #fff5d940;
  border-color: #8e704844;
}
[data-theme="citadel"] .chat-jump {
  background: #eee0bc;
  color: #4b3720;
}
[data-theme="citadel"] .chat-form input {
  background: #f0deb24a;
  border: 1px solid #9b7e4e77;
  border-radius: 2px;
  color: #533e21;
}
[data-theme="citadel"] .chat-form input::placeholder {
  color: #a1875f;
}
[data-theme="citadel"] .chat-form button {
  background: #80623930;
  color: #695029;
  border-radius: 2px;
  border: 1px solid #aa8a5370;
}
[data-theme="citadel"] .draw-response {
  color: #7b5930;
}
[data-theme="citadel"] .small-primary {
  background: #7c6440;
  color: #f0deba;
  border-radius: 2px;
}
[data-theme="citadel"] .unread {
  background: #7c5f34;
  color: #f3e5c3;
}
[data-theme="citadel"] .move-list,
[data-theme="citadel"] .chat-list {
  scrollbar-color: #ac9060 transparent;
}
@media (max-width: 680px) and (orientation: portrait) {
  [data-theme="citadel"] .workspace {
    gap: 8px;
  }
  [data-theme="citadel"] .board-wrap {
    padding: 7px;
  }
  [data-theme="citadel"] .game-summary {
    padding: 12px 14px;
  }
  [data-theme="citadel"] h1 {
    font-size: 17px;
  }
  [data-theme="citadel"] .primary {
    font-size: 12px;
  }
  [data-theme="citadel"] .player-info strong {
    font-size: 13px;
  }
}
@media (max-height: 620px) and (orientation: landscape) {
  [data-theme="citadel"] .workspace {
    padding: 6px 16px;
    gap: 24px;
  }
  [data-theme="citadel"] .board-wrap {
    padding: 6px;
  }
  [data-theme="citadel"] .game-summary {
    padding: 11px 15px;
  }
  [data-theme="citadel"] h1 {
    font-size: 17px;
  }
}

.piece.white {
  --piece-highlight: #fffdf5;
  --piece-shade: #d9d5c6;
}
.piece.black {
  --piece-highlight: #52616a;
  --piece-shade: #171e23;
}
[data-theme="classic"] .piece.white {
  --piece-highlight: #fffdf4;
  --piece-shade: #ded1b4;
}
[data-theme="classic"] .piece.black {
  --piece-highlight: #756353;
  --piece-shade: #2f261f;
}
[data-theme="citadel"] .piece.white {
  --piece-highlight: #fff0cc;
  --piece-shade: #c7ae7e;
}
[data-theme="citadel"] .piece.black {
  --piece-highlight: #766044;
  --piece-shade: #2c2016;
}

/* A software keyboard floats the conversation above it without changing the board. */
body.chat-keyboard .sidebar {
  position: fixed;
  z-index: 30;
  top: var(--chat-top);
  left: max(8px, calc(100vw - 380px));
  right: 8px;
  height: var(--chat-height);
  box-shadow: 0 -12px 40px #0007;
}
body.chat-keyboard .game-summary,
body.chat-keyboard .game-actions,
body.chat-keyboard .lobby-note {
  display: none;
}
body.chat-keyboard .activity {
  flex: 1 1 0;
  min-height: 0;
}
body.chat-keyboard .tabs {
  height: 34px;
}
body.chat-keyboard .tabs #close-chat {
  display: block;
  margin-left: auto;
  padding: 0 8px;
  font: 25px/1 sans-serif;
  border: 0;
}

/* Quiet, fixed board markings; charge lives inside each ordinary piece silhouette. */
.power-mark {
  position: absolute;
  inset: 4%;
  pointer-events: none;
  z-index: 1;
}
.power-mark svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: #765521;
  stroke-width: 1.8;
  opacity: 0.75;
}
.dark .power-mark svg {
  stroke: #f3d797;
  opacity: 0.9;
}
.power-rune {
  opacity: 0.65;
  stroke-width: 1.3;
}
.power-square {
  background-image: radial-gradient(
    ellipse at center,
    #e7c06b30,
    transparent 75%
  );
}
.wizard-star {
  fill: #c99e55;
  stroke: var(--piece-line);
  stroke-width: 0.7;
}
.piece .charge-fill .shape {
  fill: #dca846;
  stroke: none;
  opacity: 0.78;
}
.piece .charge-fill .detail {
  display: none;
}
.charge-level {
  transition: y 0.45s cubic-bezier(0.2, 0.75, 0.2, 1);
}
.charge-badge {
  position: absolute;
  right: 6%;
  bottom: 5%;
  padding: 1px 4px;
  border-radius: 5px;
  background: #302617;
  border: 1px solid #bfa370;
  color: #f5d998;
  font:
    650 clamp(8px, 1.1vw, 11px) / 1.3 system-ui,
    sans-serif;
  box-shadow: 0 1px 4px #0003;
}
@media (prefers-reduced-motion: reduce) {
  .charge-level {
    transition: none;
  }
}

.piece-accent {
  fill: #cda555;
  stroke: var(--piece-line);
  stroke-width: 0.8;
  stroke-linejoin: round;
}
.piece .antlers {
  stroke-width: 2.4;
}
.square.legal.swap-target:after {
  border: 3px dashed #e7cb8a;
  box-shadow: inset 0 0 0 1px #59442188;
}
/* The introduction is a self-contained field guide; the game never reflows. */
.introduction-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.introduction-button:hover {
  color: var(--text);
  border-color: var(--line);
}
.introduction-button svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
dialog.introduction {
  --intro-surface: #24292e;
  --intro-ink: #eeeae3;
  --intro-muted: #b5b7b9;
  --intro-line: #ffffff1c;
  --intro-wash: #ffffff06;
  --intro-gold: #e0ba78;
  width: 800px;
  height: min(700px, calc(100dvh - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(800px, calc(100dvh - 32px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--intro-line);
  border-radius: 16px;
  background: var(--intro-surface);
  color: var(--intro-ink);
  text-align: left;
  box-shadow: 0 24px 100px #0008;
}
dialog.introduction[open] {
  display: flex;
  flex-direction: column;
}
[data-theme="citadel"] dialog.introduction {
  --intro-surface: #2b241c;
  --intro-ink: #f2e5ce;
  --intro-muted: #c5b69d;
  --intro-line: #d8b47430;
  --intro-wash: #d8b47409;
  --intro-gold: #e0ba78;
}
[data-theme="classic"] dialog.introduction {
  --intro-surface: #fbf8f1;
  --intro-ink: #342d24;
  --intro-muted: #6d6151;
  --intro-line: #806c4e30;
  --intro-wash: #806c4e09;
  --intro-gold: #7b5929;
}
.intro-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px 10px 30px;
  flex: 0 0 auto;
}
.intro-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--intro-muted);
}
.intro-eyebrow > span {
  margin: 0 8px;
  color: var(--intro-gold);
}
.intro-close {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 8px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: none;
  color: var(--intro-muted);
}
.intro-close:hover {
  border-color: var(--intro-line);
  background: var(--intro-wash);
  color: var(--intro-ink);
}
.intro-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.intro-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding: 0 26px;
  flex: 0 0 auto;
  border-bottom: 1px solid var(--intro-line);
}
.intro-tabs button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--intro-muted);
  font-size: 11px;
}
.intro-tabs button:hover {
  color: var(--intro-ink);
  background: var(--intro-wash);
}
.intro-tabs button[aria-current="step"] {
  color: var(--intro-gold);
  border-bottom-color: var(--intro-gold);
}
.intro-tabs .piece {
  width: 24px;
  height: 28px;
  filter: none;
}
.intro-power-icon {
  width: 23px;
  height: 23px;
  margin-right: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}
.intro-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--intro-line) transparent;
}
.intro-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  align-items: center;
  gap: 34px;
  padding: 32px;
  min-height: 100%;
}
.intro-visual {
  min-width: 0;
}
.intro-board {
  display: grid;
  grid-template-columns: repeat(var(--guide-size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--guide-size), minmax(0, 1fr));
  aspect-ratio: 1;
  width: 100%;
  padding: 7px;
  background: #342b21;
  border: 1px solid #b9995f66;
  border-radius: 5px;
  box-shadow:
    0 6px 24px #0003,
    inset 0 0 0 3px #1715114d;
}
.intro-cell {
  min-height: 0;
  overflow: hidden;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  background: var(--light);
}
.intro-cell.dark {
  background: var(--dark);
}
.intro-cell:after,
.intro-cell:before {
  pointer-events: none;
}
.intro-cell .piece {
  width: 92%;
  height: 92%;
}
.intro-power-cell {
  box-shadow: inset 0 0 0 2px #e3b854;
  z-index: 1;
}
.intro-power-cell:after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 1px solid #5f49197a;
}
.intro-square-name {
  position: absolute;
  left: 2px;
  top: 1px;
  font: 600 8px/1.2 system-ui;
  color: #49341e;
  z-index: 2;
}
.dark .intro-square-name {
  color: #fff0c9;
}
#intro-charging-piece {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}
.intro-destination:after {
  content: "";
  width: 27%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f6d587;
  border: 2px solid #6c4f22;
  box-shadow: 0 0 0 4px #f6d58736;
}
.intro-safe-path:after {
  content: "";
  width: 18%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px dashed #65512c;
}
.intro-charge {
  display: grid;
  grid-template-columns: repeat(var(--charge-steps, 4), minmax(0, 1fr));
  gap: 5px;
  margin-top: 14px;
}
.intro-charge button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--intro-line);
  border-radius: 5px;
  color: var(--intro-muted);
  background: none;
  font-size: 11px;
}
.intro-charge button > span {
  font-variant-numeric: tabular-nums;
  color: var(--intro-gold);
}
.intro-charge button[aria-pressed="true"] {
  background: var(--intro-wash);
  border-color: var(--intro-gold);
  color: var(--intro-ink);
}
.introduction .intro-caption {
  margin: 14px 0 0;
  color: var(--intro-muted);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}
.intro-kicker {
  display: block;
  font-size: 10px;
  line-height: 1.6;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--intro-gold);
  margin-bottom: 12px;
}
.introduction h2 {
  color: var(--intro-ink);
  font:
    400 31px/1.12 Georgia,
    serif;
  letter-spacing: -0.7px;
  margin: 0 0 14px;
}
.introduction h2:focus {
  outline: none;
}
.introduction .intro-lead {
  font-size: 14px;
  line-height: 1.6;
  color: var(--intro-ink);
  margin: 0 0 20px;
}
.intro-description p {
  color: var(--intro-muted);
  font-size: 13px;
  line-height: 1.65;
  margin: 0 0 12px;
}
.intro-description strong {
  color: var(--intro-ink);
  font-weight: 600;
}
.intro-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--intro-line);
  margin-top: 20px;
}
.intro-note > span {
  color: var(--intro-gold);
  font-size: 21px;
  line-height: 1;
}
.intro-note p {
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
  color: var(--intro-muted);
}
.intro-footer {
  flex: 0 0 auto;
  padding: 18px 28px;
  border-top: 1px solid var(--intro-line);
  background: var(--intro-wash);
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
}
.intro-footer p {
  font-size: 10px;
  line-height: 1.5;
  color: var(--intro-muted);
  margin: 0;
  max-width: 150px;
}
.intro-navigation {
  display: flex;
  align-items: center;
  gap: 12px;
}
.intro-counter {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--intro-muted);
  white-space: nowrap;
}
.intro-back,
.intro-next {
  height: 40px;
  border-radius: 5px;
  font-size: 12px;
}
.intro-back {
  padding: 0 12px;
  border: 1px solid var(--intro-line);
  background: transparent;
  color: var(--intro-ink);
}
.intro-next {
  min-width: 142px;
  padding: 0 16px;
  border: 1px solid #e2c38a;
  background: linear-gradient(#e7cea0, #c5a46c);
  color: #302719;
  box-shadow: inset 0 1px 0 #fff4;
  font-weight: 600;
}
.intro-next:hover {
  background: #e7cea0;
}
.intro-next > span {
  margin-left: 10px;
}
.introduction button:focus-visible {
  outline-color: var(--intro-gold);
  outline-offset: -3px;
}
@media (max-width: 600px) {
  dialog.introduction {
    width: 430px;
    height: min(820px, calc(100dvh - 20px));
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: 12px;
  }
  .intro-header {
    padding: 10px 12px 4px 20px;
  }
  .intro-eyebrow {
    font-size: 9px;
    letter-spacing: 1px;
  }
  .intro-tabs {
    padding: 0 14px;
    gap: 2px;
  }
  .intro-tabs button {
    flex-direction: column;
    gap: 3px;
    padding: 7px 0 9px;
    font-size: 9px;
  }
  .intro-tabs .piece {
    width: 23px;
    height: 25px;
  }
  .intro-content {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 22px;
    min-height: 0;
  }
  .intro-board {
    width: min(100%, 190px);
    margin: 0 auto;
  }
  .intro-charge {
    max-width: 280px;
    margin: 12px auto 0;
  }
  .intro-kicker {
    margin-bottom: 7px;
    font-size: 9px;
  }
  .introduction h2 {
    font-size: 27px;
    margin-bottom: 10px;
  }
  .introduction .intro-lead {
    margin-bottom: 12px;
    font-size: 13px;
  }
  .intro-description p {
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 10px;
  }
  .intro-note {
    padding-top: 12px;
    margin-top: 14px;
  }
  .intro-note p {
    font-size: 11px;
  }
  .intro-footer {
    padding: 12px 18px;
    flex-direction: column-reverse;
    gap: 8px;
  }
  .intro-footer p {
    max-width: none;
    font-size: 9px;
  }
  .intro-navigation {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
  .intro-next {
    min-width: 138px;
    padding: 0 10px;
  }
}
@media (max-width: 360px) {
  .intro-tabs button > span {
    font-size: 8px;
  }
  .intro-content {
    padding: 18px;
  }
  .intro-board {
    width: 150px;
  }
  .intro-eyebrow > span {
    margin: 0 3px;
  }
  .intro-counter {
    font-size: 10px;
  }
  .intro-next {
    min-width: 125px;
    font-size: 11px;
  }
}
@media (max-height: 500px) and (min-width: 601px) {
  .intro-header {
    padding-top: 5px;
    padding-bottom: 0;
  }
  .intro-tabs button {
    padding-top: 4px;
    padding-bottom: 6px;
  }
  .intro-content {
    padding: 20px 28px;
    gap: 28px;
    min-height: 0;
  }
  .intro-board {
    max-width: 210px;
    margin: auto;
  }
  .intro-footer {
    padding-top: 10px;
    padding-bottom: 10px;
  }
}

.intro-board .charge-level {
  transition: none;
}
.intro-diagram-label {
  display: block;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.6px;
  color: var(--intro-muted);
  margin-bottom: 12px;
}
.intro-power-board .intro-square-name {
  top: 4px;
  left: 5px;
  font-size: 10px;
}
@media (max-width: 600px) {
  .intro-copy {
    display: contents;
  }
  .intro-content {
    gap: 10px;
  }
  .intro-kicker {
    grid-row: 1;
    margin: 0;
  }
  .introduction h2 {
    grid-row: 2;
    margin: 0;
  }
  .introduction .intro-lead {
    grid-row: 3;
    margin: 0;
  }
  .intro-visual {
    grid-row: 4;
    margin: 10px 0;
  }
  .intro-description {
    grid-row: 5;
  }
  .intro-note {
    grid-row: 6;
    margin: 0;
  }
}

.intro-target:after {
  content: "";
  position: absolute;
  inset: 5%;
  border: 2px dashed #fae0a0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #533e2380;
}
.intro-demo {
  width: 100%;
  min-height: 36px;
  margin-top: 14px;
  padding: 8px 10px;
  border: 1px solid var(--intro-line);
  border-radius: 6px;
  background: var(--intro-surface);
  color: var(--intro-ink);
  font:
    600 12px/1.4 system-ui,
    sans-serif;
  cursor: pointer;
}
.intro-demo:hover {
  border-color: var(--accent);
}
.intro-demo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* A compact opponent selector shares the existing lobby, without changing board sizing. */
.opponent-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
}
.opponent-choice {
  display: flex;
  flex: 1;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #00000008;
}
.opponent-choice button {
  flex: 1;
  padding: 8px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition:
    background 0.18s,
    color 0.18s;
}
.opponent-choice button[aria-pressed="true"] {
  background: #ffffff22;
  color: var(--text);
  box-shadow: 0 1px 3px #0002;
}
.bot-color {
  display: grid;
  gap: 3px;
  font-size: 9px;
  color: var(--muted);
}
.bot-color select {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 2px 12px 2px 0;
  cursor: pointer;
}
[data-theme="citadel"] .opponent-choice button[aria-pressed="true"] {
  background: #f1dfb58c;
  color: #4a3520;
}
@media (max-width: 680px) and (orientation: portrait) {
  .opponent-controls {
    grid-column: 1 / -1;
    grid-row: 1;
    margin: 0 0 3px;
    gap: 16px;
  }
  .opponent-choice {
    max-width: 230px;
  }
  .opponent-choice button {
    padding: 5px 10px;
    font-size: 11px;
  }
  .bot-color {
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .game-summary:has(.opponent-controls:not([hidden])) .status-line {
    grid-row: 2;
  }
  .game-summary:has(.opponent-controls:not([hidden])) .time-controls {
    grid-row: 3;
  }
  .game-summary:has(.opponent-controls:not([hidden])) .primary {
    grid-row: 2 / 4;
  }
}

.opponent-choice small {
  font-size: 8px;
  opacity: 0.75;
  margin-left: 3px;
}
@media (max-width: 680px) and (max-height: 720px) and (orientation: portrait) {
  body:not(.in-game) .sidebar {
    overflow-y: auto;
  }
  body:not(.in-game):not(.finished):not(.searching) .activity {
    display: none;
  }
  .game-summary {
    flex-shrink: 0;
  }
}
@media (max-width: 680px) and (max-height: 620px) and (orientation: portrait) {
  .game-summary:has(.opponent-controls:not([hidden])) .status-line {
    display: none;
  }
  .game-summary:has(.opponent-controls:not([hidden])) .time-controls {
    grid-row: 2;
  }
  .game-summary:has(.opponent-controls:not([hidden])) .primary {
    grid-row: 2;
  }
  .opponent-controls {
    gap: 8px;
  }
}

/* Ready is an option, never an automatic transformation. */
.upgrade-ready .charge-badge {
  background: #e4c369;
  color: #30230f;
}
.upgrade-button {
  color: var(--accent, #e4c369);
  font-weight: 700;
  border: 1px solid #ae8c49;
  border-radius: 3px;
  padding: 3px 8px;
}

.upgrade-ready .charge-fill .shape {
  opacity: 0.38;
}
