#rush-board {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

#rush-board .rush-board-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(8, minmax(0, 1fr)) / repeat(8, minmax(0, 1fr));
}

#rush-board .rush-cell {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  box-shadow: none;
  cursor: default;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#rush-board .rush-cell.is-light {
  background: var(--rush-light, #e8ebcf);
  color: #4f683e;
}

#rush-board .rush-cell.is-dark {
  background: var(--rush-dark, #78915a);
  color: #fffdf2;
}

#rush-board:not(.rush-can-move), #rush-board:not(.rush-can-move) .rush-cell { touch-action: pan-y; }

#rush-board .rush-cell:focus-visible {
  outline: 2px solid #173733;
  outline-offset: -3px;
  box-shadow: inset 0 0 0 5px #f2ffeb;
  z-index: 2;
}

#rush-board .rush-cell::before,
#rush-board .rush-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#rush-board .rush-cell::before { z-index: 0; }
#rush-board .rush-cell::after { z-index: 1; }
#rush-board .rush-cell.is-source::before { background: #cbb36e96; }
#rush-board .rush-cell.is-pending::after { box-shadow: inset 0 0 0 3px #bbdef3; }
#rush-board .rush-cell.is-destination::before { background: #e6d38aaf; }
#rush-board .rush-cell.is-selected::before { background: #4aa9e6b8; }
#rush-board .rush-cell.is-hint::before { background: #28b9a0b8; }
#rush-board .rush-cell.is-manual::before { background: #da3c3f9c; }
#rush-board .rush-cell.is-wrong::before { background: #c36f6680; }
#rush-board .rush-cell.is-checked::after {
  background: radial-gradient(ellipse at center, #ff695ab5 0 22%, #e142387a 49%, #cf302132 76%, transparent 96%);
}

#rush-board .rush-coordinate {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  font: 700 clamp(9px, 1.3vw, 14px)/1 system-ui, sans-serif;
  opacity: .95;
}

#rush-board .rush-coordinate.is-rank { top: 5%; left: 6%; }
#rush-board .rush-coordinate.is-file { bottom: 5%; right: 6%; }

#rush-board .rush-piece-symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#rush-board .rush-piece {
  display: block;
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  user-select: none;
}

#rush-board.rush-can-move .rush-cell.is-movable { cursor: grab; }
#rush-board.rush-dragging .rush-cell { cursor: grabbing; }
#rush-board .rush-cell.is-drag-source .rush-piece { visibility: hidden; }

#rush-board .rush-piece-motion {
  position: absolute;
  z-index: 5;
  width: 12.5%;
  height: 12.5%;
  pointer-events: none;
  overflow: visible;
  will-change: transform;
}

#rush-board .rush-piece-motion[hidden] { display: none; }

#rush-board .rush-piece-motion.piece-motion-trail {
  z-index: 4;
  filter: blur(1.4px);
}

#rush-board .rush-drag-piece { z-index: 6; }

#rush-board .rush-king-flash::after {
  animation: rush-king-glow 480ms ease-out both;
}

#rush-board .rush-king-flash .rush-piece {
  animation: rush-king-shake 205ms ease-out both;
  transform-origin: 50% 66%;
}

@keyframes rush-king-glow {
  0% { opacity: .72; transform: scale(.84); }
  25% { opacity: 1; transform: scale(1.05); }
  100% { opacity: .84; transform: scale(1); }
}

@keyframes rush-king-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  18% { transform: translateX(-2px) rotate(-4deg); }
  39% { transform: translateX(2px) rotate(3deg); }
  58% { transform: translateX(-1px) rotate(-2deg); }
  79% { transform: translateX(1px) rotate(1deg); }
}

#rush-board .rush-move-mark {
  position: absolute;
  z-index: 4;
  top: 3%;
  right: 3%;
  display: grid;
  place-items: center;
  width: 35%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #32824e;
  color: #fff;
  box-shadow: 0 1px 3px #16332888;
  font: 850 clamp(10px, 2.5vw, 21px)/1 system-ui, sans-serif;
  pointer-events: none;
  animation: rush-marker-in 145ms ease-out both;
}

#rush-board .rush-move-mark[data-mark="wrong"] { background: #b53232; }

@keyframes rush-marker-in {
  from { transform: scale(.72); opacity: .25; }
  to { transform: scale(1); opacity: 1; }
}


#rush-board .rush-promotion {
  position: absolute;
  top: 0;
  left: calc(12.5% * var(--rush-promo-file, 0));
  z-index: 8;
  display: flex;
  flex-direction: column;
  width: 12.5%;
  overflow: hidden;
  border-radius: 5px;
  background: #f0f0de;
  box-shadow: 0 0 0 2px #203726bb, 0 4px 16px #18251e77;
}

#rush-board .rush-promotion[hidden] { display: none; }
#rush-board .rush-promotion.is-up { top: auto; bottom: 0; flex-direction: column-reverse; }

#rush-board .rush-promotion button {
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #203426;
  background: transparent;
  cursor: pointer;
}

#rush-board .rush-promotion-option { aspect-ratio: 1; }
#rush-board .rush-promotion button:is(:hover, :focus-visible) { background: #cce3ab; }
#rush-board .rush-promotion button:focus-visible { outline: 2px solid #2d673e; outline-offset: -2px; }
#rush-board .rush-promotion-cancel { min-height: 22px; font: 700 clamp(16px, 2.5vw, 25px)/1 system-ui, sans-serif; }
#rush-board .rush-promotion-cancel:not(:hover, :focus-visible) { background: #dedfca; }

@media (prefers-reduced-motion: reduce) {
  #rush-board .rush-king-flash::after,
  #rush-board .rush-king-flash .rush-piece,
  #rush-board .rush-move-mark { animation: none; }
}
