:root {
  color-scheme: dark;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #15191d;
  color: #e7ebed;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; display: grid; place-items: center; }
main { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px 12px; }
#arena {
  width: min(860px, calc(100vw - 24px), calc(100dvh - 96px));
  aspect-ratio: 1;
  position: relative;
  container-type: inline-size;
  border-radius: 6px;
  outline: 1px solid #41494f;
  background: #262d32;
}
#surface { position: absolute; inset: 0; transform: rotate(0deg); transition: transform 320ms ease; }
#arena.flipped #surface { transform: rotate(180deg); }
#ring { position: absolute; width: 100%; height: 100%; inset: 0; overflow: visible; }
#board {
  position: absolute;
  inset: 16.6666667%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  outline: max(2px, .35cqi) solid #0e1215;
  box-shadow: 0 0 0 max(4px, .6cqi) #535d63;
}
.cell {
  display: grid;
  place-items: center;
  position: relative;
  background: #adb7ba;
  color: #10171d;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}
.cell.dark { background: #65767c; }
.cell.last { box-shadow: inset 0 0 0 100px #d7bb5140; }
.cell.selected { box-shadow: inset 0 0 0 max(2px, .4cqi) #ecd36c; }
.cell.via { background: #b0a66c; }
.cell.check { background: #bd5962; }
.cell:focus-visible { outline: max(2px, .35cqi) solid #f8df79; outline-offset: -3px; z-index: 5; }
.cell.legal::after {
  content: '';
  position: absolute;
  width: 24%; height: 24%;
  border-radius: 50%;
  background: #16232b85;
  pointer-events: none;
}
.cell.legal.occupied::after { width: 91%; height: 91%; background: transparent; border: max(2px,.4cqi) solid #edd16c; }
.piece {
  width: 88%; height: 84%;
  border-radius: 12%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2%;
  position: relative;
  pointer-events: none;
  font-size: clamp(8px, 1.6cqi, 14px);
  line-height: 1.1;
  font-weight: 650;
  text-align: center;
  letter-spacing: -.025em;
  box-shadow: 0 1px 2px #0005;
  transform: rotate(0deg);
  transition: transform 320ms ease;
}
#arena.flipped .piece { transform: rotate(180deg); }
.piece.w { background: #f1f3ef; color: #17537b; border: max(1px,.15cqi) solid #83adca; }
.piece.b { background: #242c34; color: #f0a0a0; border: max(1px,.15cqi) solid #8b6468; }
.piece .label { padding: 0 1px; }
.mobile-label { display: none; }
.pips { display: flex; gap: .27cqi; height: .45cqi; min-height: 2px; }
.pip { width: .4cqi; height: .4cqi; min-width: 2px; min-height: 2px; border-radius: 50%; background: currentColor; opacity: .6; }
.pip.used { opacity: .16; }
.piece.queen-captured { outline: 1px dashed currentColor; }
.track-cell { fill: #293238; stroke: #49545b; stroke-width: 1.2; }
.track-cell.alternate { fill: #303a40; }
.finish { fill: none; stroke-width: 4; stroke-dasharray: 9 7; opacity: .65; }
.finish.w { stroke: #7dbbe6; }
.finish.b { stroke: #eb9b9f; }
.route-arrow { fill: #82929b; opacity: .6; }
.marker { stroke: #15191d; stroke-width: 5; pointer-events: none; }
.marker.w { fill: #8bc9f3; }
.marker.b { fill: #ee929c; }
.marker.active { stroke: #f5e6a5; stroke-width: 5; }
.travel-target { cursor: pointer; outline: none; }
.travel-target .hit { fill: transparent; }
.travel-target .target { fill: #eed27435; stroke: #ecd783; stroke-width: 4; stroke-dasharray: 7 5; }
.travel-target:focus-visible .target, .travel-target:hover .target { fill: #eed27488; stroke: white; }
.travel-count { fill: #f3e7b8; font-size: 23px; font-weight: 700; pointer-events: none; }
#arena.flipped .travel-count { transform-box: fill-box; transform-origin: center; transform: rotate(180deg); }
#arena.busy { cursor: progress; }
#arena.busy #board { opacity: .88; }
#result {
  position: absolute; inset: 38% 10%; z-index: 10;
  background: #172027ed; border: 1px solid #9ba6ac;
  box-shadow: 0 10px 40px #0007; border-radius: 6px;
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  gap: 8px; font-size: clamp(16px, 3.6cqi, 30px); font-weight: 650; text-align: center;
}
#result small { font-size: .55em; font-weight: 400; color: #b8c4ca; }
[hidden] { display: none !important; }
#controls { display: flex; gap: 10px; }
button {
  border: 1px solid #53616b; border-radius: 5px; background: #252e35;
  color: #e7ecef; font: inherit; font-size: 14px; padding: 9px 19px;
  cursor: pointer; min-height: 40px;
}
button:hover { background: #35424b; }
button:focus-visible { outline: 2px solid #f8df79; outline-offset: 3px; }
button[aria-pressed="true"] { border-color: #94c0de; background: #2d4556; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@container (max-width: 480px) {
  .piece { font-size: 2.1cqi; }
  .full-label { display: none; }
  .mobile-label { display: inline; }
}
@media (prefers-reduced-motion: reduce) {
  #surface, .piece { transition: none; }
}
