:root {
  --bg: #171a16;
  --bg-deep: #10120f;
  --panel: rgba(245, 239, 224, 0.08);
  --panel-strong: rgba(245, 239, 224, 0.13);
  --line: rgba(245, 239, 224, 0.18);
  --text: #f5efe0;
  --muted: #b7ad99;
  --gold: #dba95f;
  --gold-strong: #f0bf73;
  --sage: #6e8268;
  --sage-dark: #465743;
  --ivory: #eee4c9;
  --square-light: #eee4c9;
  --square-dark: #6e8268;
  --ink: #25281f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

body[data-theme="walnut"] {
  --square-light: #e8d5ad;
  --square-dark: #8b5f39;
  --gold: #d89a45;
  --gold-strong: #f0bd66;
}

body[data-theme="midnight"] {
  --square-light: #d9ddec;
  --square-dark: #495a72;
  --gold: #9fc5f8;
  --gold-strong: #c7dcff;
}

body[data-theme="jade"] {
  --square-light: #e7ead0;
  --square-dark: #3f806f;
  --gold: #76c893;
  --gold-strong: #b7f4c7;
}

body[data-theme="rose"] {
  --square-light: #f2d2c9;
  --square-dark: #9b555f;
  --gold: #f0a6a6;
  --gold-strong: #ffd0ce;
}

body[data-theme="mono"] {
  --square-light: #dad7cf;
  --square-dark: #5d5f5a;
  --gold: #d6d1c2;
  --gold-strong: #ffffff;
}

body[data-theme="ocean"] {
  --square-light: #d7e5e8;
  --square-dark: #5e8795;
  --gold: #80d4ff;
  --gold-strong: #c5f1ff;
}

body[data-theme="tourney"] {
  --square-light: #f0d9b5;
  --square-dark: #b58863;
  --gold: #e5a24c;
  --gold-strong: #ffd18a;
}

body[data-theme="lavender"] {
  --square-light: #efe5f8;
  --square-dark: #78618f;
  --gold: #caa7ff;
  --gold-strong: #eadcff;
}

body[data-theme="coffee"] {
  --square-light: #d9bd92;
  --square-dark: #6d4b33;
  --gold: #c8874a;
  --gold-strong: #f1c08b;
}

body[data-theme="frost"] {
  --square-light: #edf3f4;
  --square-dark: #8ba3a9;
  --gold: #aad7dd;
  --gold-strong: #ecffff;
}

body[data-theme="forest"] {
  --square-light: #e4dfbd;
  --square-dark: #536c44;
  --gold: #9eb86f;
  --gold-strong: #d8eca7;
}

* {
  box-sizing: border-box;
}

body {
  overflow-x: hidden;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(219, 169, 95, 0.18), transparent 32rem),
    linear-gradient(135deg, #20231c 0%, var(--bg) 48%, var(--bg-deep) 100%);
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 20.5rem);
  grid-template-rows: auto auto;
  gap: 1rem;
  width: min(1340px, calc(100vw - 1.5rem));
  min-height: 100vh;
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.game-stage,
.side-panel {
  border: 1px solid var(--line);
  background: rgba(18, 20, 16, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.game-stage {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  min-height: auto;
  padding: clamp(0.8rem, 1.2vw, 1.05rem);
  border-radius: 8px;
}

.bottom-settings {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(18rem, 0.85fr) minmax(20rem, 1fr) minmax(18rem, 0.9fr);
  gap: 1.15rem;
  align-items: start;
  padding: 0.2rem 0 2.75rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.45rem;
}

.eyeline {
  margin: 0 0 0.35rem;
  color: var(--gold-strong);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.45rem, 3.4vw, 2.85rem);
  font-weight: 600;
  line-height: 0.98;
}

.turn-pill {
  width: 100%;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(219, 169, 95, 0.4);
  border-radius: 6px;
  color: var(--gold-strong);
  background: rgba(219, 169, 95, 0.1);
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.board-wrap {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.22rem;
  min-height: 0;
}

.board-shell {
  position: relative;
  width: min(calc(100vh - 5.25rem), 100%, 900px);
  aspect-ratio: 1;
  padding: 0.72rem;
  border: 1px solid rgba(245, 239, 224, 0.24);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(245, 239, 224, 0.14), rgba(0, 0, 0, 0.16));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

body[data-frame-style="glow"] .board-shell {
  border-color: rgba(219, 169, 95, 0.48);
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.45), 0 0 42px rgba(219, 169, 95, 0.18);
}

body[data-frame-style="flat"] .board-shell {
  padding: 0.35rem;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 5px;
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-width: 0;
  min-height: 0;
  border: 0;
  color: var(--ink);
  cursor: pointer;
  transition: filter 150ms ease, box-shadow 150ms ease, transform 150ms ease, background 180ms ease;
}

.square.light {
  background: var(--square-light);
}

.square.dark {
  background: var(--square-dark);
}

.square:hover {
  filter: brightness(1.06);
}

.square.selected {
  box-shadow: inset 0 0 0 4px rgba(240, 191, 115, 0.88);
}

.square.last-from {
  box-shadow: inset 0 0 0 999px rgba(219, 169, 95, 0.16);
}

.square.last-to {
  animation: moveLand 360ms ease-out;
  box-shadow: inset 0 0 0 999px rgba(219, 169, 95, 0.24);
}

.square.hint-from,
.square.hint-to {
  animation: hintPulse 1200ms ease-in-out infinite;
}

.square.hint-from {
  box-shadow: inset 0 0 0 4px rgba(240, 191, 115, 0.92);
}

.square.hint-to {
  box-shadow: inset 0 0 0 999px rgba(240, 191, 115, 0.3), inset 0 0 0 4px rgba(240, 191, 115, 0.92);
}

.square.threatened::before,
.square.safe-candidate::before,
.square.danger-move::before {
  content: "";
  position: absolute;
  inset: 13%;
  z-index: 0;
  border-radius: 5px;
  pointer-events: none;
}

.square.threatened::before {
  background: radial-gradient(circle, rgba(155, 42, 38, 0.28), rgba(155, 42, 38, 0.08) 54%, transparent 58%);
}

.square.safe-candidate::before {
  border: 3px solid rgba(97, 146, 87, 0.65);
  background: rgba(97, 146, 87, 0.14);
}

.square.danger-move::before {
  border: 3px solid rgba(155, 42, 38, 0.72);
  background: rgba(155, 42, 38, 0.14);
  box-shadow: inset 0 0 24px rgba(155, 42, 38, 0.34);
}

.square.threatened.safe-candidate::before {
  border: 3px solid rgba(97, 146, 87, 0.62);
  background:
    radial-gradient(circle, rgba(155, 42, 38, 0.26), rgba(155, 42, 38, 0.08) 54%, transparent 58%),
    rgba(97, 146, 87, 0.08);
}

.square.legal::after {
  content: "";
  position: absolute;
  width: 24%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(37, 40, 31, 0.26);
}

.square.capture::after {
  width: 78%;
  background: transparent;
  border: 4px solid rgba(130, 64, 46, 0.55);
}

.square.analysis-target::after {
  content: "";
  position: absolute;
  width: 28%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(155, 42, 38, 0.72);
  box-shadow: 0 0 0 5px rgba(155, 42, 38, 0.14);
}

.piece {
  position: relative;
  z-index: 1;
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.25rem, 7vmin, 5.15rem);
  line-height: 1;
  transform: translateY(-0.04em);
  user-select: none;
  animation: pieceSettle 240ms ease-out;
}

.white-piece {
  color: #fff9e8;
  text-shadow: 0 2px 0 rgba(37, 40, 31, 0.3), 0 6px 14px rgba(0, 0, 0, 0.32);
}

.black-piece {
  color: #23261f;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.18), 0 8px 16px rgba(0, 0, 0, 0.22);
}

body[data-piece-set="glass"] .white-piece {
  color: #ffffff;
  text-shadow: 0 0 1px #ffffff, 0 4px 16px rgba(0, 0, 0, 0.42);
}

body[data-piece-set="glass"] .black-piece {
  color: #151714;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.26), 0 0 14px rgba(255, 255, 255, 0.18);
}

body[data-piece-set="ink"] .piece {
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", Georgia, serif;
  font-weight: 900;
}

body[data-piece-set="ink"] .white-piece {
  color: #fffdf2;
  -webkit-text-stroke: 1px rgba(37, 40, 31, 0.26);
}

body[data-piece-set="ink"] .black-piece {
  color: #10120f;
  -webkit-text-stroke: 1px rgba(255, 255, 255, 0.12);
}

body[data-piece-set="marble"] .piece {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
}

body[data-piece-set="marble"] .white-piece {
  color: #fff7df;
  text-shadow: 0 1px 0 #ffffff, 0 5px 0 rgba(193, 158, 92, 0.36), 0 12px 18px rgba(0, 0, 0, 0.34);
}

body[data-piece-set="marble"] .black-piece {
  color: #17130f;
  text-shadow: 0 1px 0 rgba(255, 224, 178, 0.22), 0 5px 0 rgba(0, 0, 0, 0.22), 0 12px 18px rgba(0, 0, 0, 0.3);
}

body[data-piece-set="carved"] .piece {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: clamp(2.45rem, 7.4vmin, 5.45rem);
}

body[data-piece-set="carved"] .white-piece {
  color: #f9e6c9;
  -webkit-text-stroke: 1.1px #171a16;
  text-shadow:
    0 1px 0 #fff4de,
    2px 3px 0 rgba(0, 0, 0, 0.42),
    0 10px 18px rgba(0, 0, 0, 0.32);
}

body[data-piece-set="carved"] .black-piece {
  color: #201811;
  -webkit-text-stroke: 0.7px rgba(245, 239, 224, 0.3);
  text-shadow:
    0 1px 0 rgba(255, 244, 222, 0.16),
    2px 4px 0 rgba(0, 0, 0, 0.34),
    0 12px 18px rgba(0, 0, 0, 0.34);
}

body[data-piece-set="steel"] .piece {
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", Georgia, serif;
  font-weight: 900;
  font-size: clamp(2.35rem, 7.25vmin, 5.35rem);
  filter: drop-shadow(0 6px 5px rgba(0, 0, 0, 0.36));
}

body[data-piece-set="steel"] .white-piece {
  color: #cfd8df;
  -webkit-text-stroke: 1px #111820;
  text-shadow:
    0 1px 0 #ffffff,
    0 3px 0 #778792,
    0 10px 16px rgba(0, 0, 0, 0.45);
}

body[data-piece-set="steel"] .black-piece {
  color: #202932;
  -webkit-text-stroke: 1px #aebbc4;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.2),
    0 4px 0 rgba(0, 0, 0, 0.28),
    0 10px 16px rgba(0, 0, 0, 0.45);
}

body[data-piece-set="flat"] .piece {
  font-family: "Arial Rounded MT Bold", "Segoe UI Symbol", sans-serif;
  font-weight: 900;
  font-size: clamp(2.5rem, 7.55vmin, 5.6rem);
  filter: none;
}

body[data-piece-set="flat"] .white-piece {
  color: #fffdf4;
  -webkit-text-stroke: 0;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.28);
}

body[data-piece-set="flat"] .black-piece {
  color: #111418;
  -webkit-text-stroke: 0;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.16);
}

body[data-piece-size="small"] .piece {
  font-size: clamp(1.85rem, 6vmin, 4.35rem);
}

body[data-piece-size="large"] .piece {
  font-size: clamp(2.55rem, 7.6vmin, 5.65rem);
}

body[data-guide-style="rings"] .square.legal::after {
  width: 62%;
  background: transparent;
  border: 4px solid rgba(37, 40, 31, 0.28);
}

body[data-guide-style="clean"] .square.legal::after {
  display: none;
}

body[data-guide-style="clean"] .square.legal {
  box-shadow: inset 0 0 0 999px rgba(219, 169, 95, 0.16);
}

.square.in-check {
  animation: dangerSquare 820ms ease-in-out infinite;
  box-shadow: inset 0 0 0 5px rgba(188, 40, 36, 0.95), 0 0 36px rgba(188, 40, 36, 0.72);
}

.square.in-check .piece {
  animation: kingCheck 560ms ease-in-out infinite alternate;
  color: #ffefdf;
  text-shadow: 0 0 8px rgba(255, 56, 48, 0.9), 0 0 22px rgba(255, 56, 48, 0.82), 0 4px 12px rgba(0, 0, 0, 0.38);
}

.coordinates {
  position: absolute;
  color: rgba(245, 239, 224, 0.52);
  font-size: 0.72rem;
  font-weight: 800;
}

body[data-coordinates="minimal"] .coordinates {
  opacity: 0.46;
  font-size: 0.62rem;
}

body[data-coordinates="off"] .coordinates {
  display: none;
}

.files {
  left: 0.72rem;
  right: 0.72rem;
  bottom: -1.25rem;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  text-align: center;
}

.ranks {
  top: 0.72rem;
  bottom: 0.72rem;
  left: -1.05rem;
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  align-items: center;
}

.captured {
  min-height: 1.15rem;
  color: rgba(245, 239, 224, 0.74);
  font-size: 1.35rem;
  letter-spacing: 0.1rem;
}

.side-panel {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  display: grid;
  position: static;
  grid-template-rows: minmax(0, 1fr);
  gap: 0.5rem;
  height: 100%;
  min-height: 24rem;
  padding: 0.85rem;
  border-radius: 8px;
  overflow: hidden;
}

.panel-block {
  border: 1px solid rgba(245, 239, 224, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(245, 239, 224, 0.09), rgba(245, 239, 224, 0.035)),
    rgba(14, 16, 13, 0.5);
  padding: 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.settings-card {
  display: grid;
  grid-column: 1 / -1;
  grid-template-rows: auto auto;
  min-height: 0;
  background:
    radial-gradient(circle at top right, rgba(219, 169, 95, 0.1), transparent 32rem),
    linear-gradient(180deg, rgba(245, 239, 224, 0.1), rgba(245, 239, 224, 0.035)),
    rgba(14, 16, 13, 0.55);
  padding: 1.1rem;
}

.settings-scroll {
  display: grid;
  grid-template-columns: 1.12fr 0.95fr 1fr 0.9fr;
  gap: 1rem;
  min-height: 0;
  margin-top: 1rem;
  padding-right: 0.18rem;
  overflow: visible;
  scrollbar-color: rgba(219, 169, 95, 0.45) rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
}

.status-card {
  background:
    radial-gradient(circle at top right, rgba(219, 169, 95, 0.14), transparent 58%),
    linear-gradient(180deg, rgba(245, 239, 224, 0.11), rgba(245, 239, 224, 0.035));
}

.panel-title {
  display: grid;
  gap: 0.48rem;
}

.panel-title span,
.panel-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.panel-title strong {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.28rem;
  line-height: 1.05;
}

.settings-head,
.moves-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.setting-group {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  min-width: 0;
  padding: 0.95rem;
  border: 1px solid rgba(245, 239, 224, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.board-group {
  grid-row: auto;
}

.settings-head strong,
.moves-head strong {
  display: block;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.2;
}

.settings-head strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.22rem;
}

.moves-head span {
  min-width: 4.2rem;
  padding: 0.38rem 0.48rem;
  border: 1px solid rgba(219, 169, 95, 0.32);
  border-radius: 5px;
  color: var(--gold-strong);
  background: rgba(219, 169, 95, 0.09);
  font-size: 0.78rem;
  font-weight: 900;
  text-align: center;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-top: 0.68rem;
}

.side-choice {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.7rem;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(245, 239, 224, 0.1);
}

.side-choice span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.side-choice .seg {
  min-height: 2.2rem;
}

.mode-grid.three {
  grid-template-columns: repeat(3, 1fr);
}

.mode-grid.compact {
  margin-top: 0.55rem;
}

.piece-label {
  display: block;
  margin-top: 0.35rem;
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.72rem;
  margin-top: 0.2rem;
}

.swatch {
  display: grid;
  justify-items: center;
  gap: 0.5rem;
  min-height: 4.25rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  font-weight: 850;
  cursor: pointer;
  padding: 0.45rem;
}

.swatch span {
  width: 100%;
  height: 1.55rem;
  border-radius: 5px 5px 2px 2px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.swatch.active {
  border-color: rgba(219, 169, 95, 0.72);
  background: rgba(219, 169, 95, 0.13);
}

.swatch[data-theme="sage"] span {
  background: linear-gradient(90deg, #eee4c9 50%, #6e8268 50%);
}

.swatch[data-theme="walnut"] span {
  background: linear-gradient(90deg, #e8d5ad 50%, #8b5f39 50%);
}

.swatch[data-theme="midnight"] span {
  background: linear-gradient(90deg, #d9ddec 50%, #495a72 50%);
}

.swatch[data-theme="jade"] span {
  background: linear-gradient(90deg, #e7ead0 50%, #3f806f 50%);
}

.swatch[data-theme="rose"] span {
  background: linear-gradient(90deg, #f2d2c9 50%, #9b555f 50%);
}

.swatch[data-theme="mono"] span {
  background: linear-gradient(90deg, #dad7cf 50%, #5d5f5a 50%);
}

.swatch[data-theme="ocean"] span {
  background: linear-gradient(90deg, #d7e5e8 50%, #5e8795 50%);
}

.swatch[data-theme="tourney"] span {
  background: linear-gradient(90deg, #f0d9b5 50%, #b58863 50%);
}

.swatch[data-theme="lavender"] span {
  background: linear-gradient(90deg, #efe5f8 50%, #78618f 50%);
}

.swatch[data-theme="coffee"] span {
  background: linear-gradient(90deg, #d9bd92 50%, #6d4b33 50%);
}

.swatch[data-theme="frost"] span {
  background: linear-gradient(90deg, #edf3f4 50%, #8ba3a9 50%);
}

.swatch[data-theme="forest"] span {
  background: linear-gradient(90deg, #e4dfbd 50%, #536c44 50%);
}

.piece-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.72rem;
  margin-top: 0.2rem;
}

.piece-option {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  justify-items: start;
  gap: 0.55rem;
  min-height: 3.35rem;
  padding: 0.35rem 0.7rem;
  text-align: left;
}

.piece-option span {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1;
}

.piece-option[data-piece-set="carved"] span {
  color: #f9e6c9;
  -webkit-text-stroke: 0.8px #151713;
  text-shadow: 1px 2px 0 rgba(0, 0, 0, 0.45);
}

.piece-option[data-piece-set="steel"] span {
  color: #cfd8df;
  -webkit-text-stroke: 0.8px #111820;
}

.piece-option[data-piece-set="flat"] span {
  color: #fffdf4;
  background: rgba(219, 169, 95, 0.12);
  text-shadow: none;
}

.seg,
.primary,
.secondary,
.difficulty {
  border: 1px solid rgba(245, 239, 224, 0.16);
  border-radius: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.seg {
  min-height: 2.45rem;
  font-size: 0.9rem;
  font-weight: 800;
}

.seg.active,
.difficulty.active {
  border-color: rgba(219, 169, 95, 0.66);
  background: linear-gradient(180deg, rgba(219, 169, 95, 0.18), rgba(219, 169, 95, 0.08));
}

.seg:hover,
.primary:hover,
.secondary:hover,
.difficulty:hover {
  transform: translateY(-1px);
  border-color: rgba(245, 239, 224, 0.32);
}

.seg:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.seg:disabled:hover {
  transform: none;
}

.difficulty-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.difficulty {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.1rem 0.35rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  text-align: left;
}

.difficulty span {
  font-weight: 850;
}

.difficulty small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.78rem;
}

.difficulty:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.primary,
.secondary {
  min-height: 2.65rem;
  font-weight: 900;
}

.primary {
  border-color: rgba(219, 169, 95, 0.7);
  color: #211d14;
  background: linear-gradient(180deg, var(--gold-strong), var(--gold));
}

.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.secondary.toggle.active {
  border-color: rgba(188, 40, 36, 0.8);
  color: #ffe1d9;
  background: rgba(188, 40, 36, 0.2);
}

.moves-block {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.move-list {
  display: grid;
  gap: 0.35rem;
  max-height: none;
  min-height: 0;
  margin: 0.75rem 0 0;
  padding: 0 0.2rem 0 0;
  overflow: auto;
  list-style: none;
  scrollbar-color: rgba(219, 169, 95, 0.45) rgba(255, 255, 255, 0.06);
  scrollbar-width: thin;
}

.move-list li {
  display: grid;
  grid-template-columns: 2rem 1fr 1fr;
  gap: 0.45rem;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.45rem;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted);
  font-size: 0.88rem;
}

.move-list li.latest {
  border: 1px solid rgba(219, 169, 95, 0.28);
  background: rgba(219, 169, 95, 0.1);
}

.move-list li.empty-moves {
  opacity: 0.72;
}

.move-list b {
  color: var(--text);
  font-weight: 750;
}

.move-jump {
  min-width: 0;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  padding: 0.22rem 0.3rem;
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}

.move-jump:hover,
.move-jump.active {
  color: var(--gold-strong);
  background: rgba(219, 169, 95, 0.14);
}

.move-jump.active {
  box-shadow: inset 0 0 0 1px rgba(219, 169, 95, 0.38);
}

body[data-motion-style="snappy"] .piece {
  animation-duration: 130ms;
}

body[data-motion-style="snappy"] .square.last-to {
  animation-duration: 190ms;
}

body[data-motion-style="off"] *,
body[data-motion-style="off"] *::before,
body[data-motion-style="off"] *::after {
  animation: none !important;
  transition: none !important;
}

.game-over {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(8, 10, 8, 0.64);
  backdrop-filter: blur(8px);
}

.game-over[hidden] {
  display: none;
}

.game-over-card {
  width: min(420px, 100%);
  border: 1px solid rgba(219, 169, 95, 0.5);
  border-radius: 8px;
  padding: 1.35rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(31, 33, 27, 0.96), rgba(14, 16, 13, 0.98));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
  animation: modalIn 260ms ease-out;
}

.game-over-card span {
  color: var(--gold-strong);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.game-over-card h2 {
  margin: 0.4rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 9vw, 3.2rem);
  line-height: 1;
}

.game-over-card p {
  margin: 0.75rem 0 1rem;
  color: var(--muted);
}

.game-over-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

@keyframes pieceSettle {
  from {
    opacity: 0.72;
    transform: translateY(-0.04em) scale(0.86);
  }

  to {
    opacity: 1;
    transform: translateY(-0.04em) scale(1);
  }
}

@keyframes moveLand {
  0% {
    transform: scale(0.94);
    filter: brightness(1.18);
  }

  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes hintPulse {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.18);
  }
}

@keyframes dangerSquare {
  0%,
  100% {
    filter: saturate(1.1);
  }

  50% {
    filter: saturate(1.45) brightness(1.08);
  }
}

@keyframes kingCheck {
  from {
    transform: translateY(-0.04em) scale(1.06) rotate(-2deg);
  }

  to {
    transform: translateY(-0.04em) scale(1.18) rotate(2deg);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    width: min(100vw - 1rem, 720px);
    padding: 0.5rem 0;
  }

  .bottom-settings {
    grid-column: 1;
    grid-row: auto;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    order: 3;
  }

  .settings-scroll {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .board-group {
    grid-row: auto;
  }

  .game-stage,
  .side-panel {
    height: auto;
    min-height: auto;
  }

  .side-panel {
    grid-column: 1;
    grid-row: auto;
    position: static;
    grid-template-rows: auto;
    order: 2;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .turn-pill {
    width: 100%;
  }

  .board-shell {
    width: min(100%, 96vw);
  }

  .move-list {
    max-height: 16rem;
  }
}

@media (max-width: 520px) {
  .game-stage,
  .side-panel,
  .panel-block {
    border-radius: 6px;
  }

  .game-stage {
    padding: 0.8rem;
  }

  .mode-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .swatch-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .piece-grid {
    grid-template-columns: 1fr;
  }

  .mode-grid.three {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 0.8rem;
  }

  .setting-group {
    padding: 0.7rem;
  }

  .piece {
    font-size: clamp(1.85rem, 10vw, 3.1rem);
  }

  .coordinates {
    display: none;
  }
}
