:root {
  --ink: #0b0c10;
  --paper: #f4f0e8;
  --gold: #e8c547;
  --sq-light: #ecd6b0;
  --sq-dark: #b58863;
  --font-display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  color: var(--paper);
  font-family: var(--font-body);
  background: var(--ink);
}
.atmosphere {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(232, 197, 71, 0.14), transparent 55%),
    linear-gradient(180deg, #0a0c10, #141218);
}

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2rem);
}
.back { color: rgba(244,240,232,.55); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--gold); }
h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 0.08em;
  font-weight: 400;
}
.ghost {
  appearance: none; border: 1px solid rgba(244,240,232,.25); background: transparent;
  color: var(--paper); font: inherit; padding: 0.5rem 0.9rem; border-radius: 8px; cursor: pointer;
}
.ghost:hover { border-color: var(--gold); color: var(--gold); }

main { padding: 0 1rem 2rem; }
.status {
  text-align: center; margin: 0.15rem 0 0.55rem;
  color: var(--gold); min-height: 1.4em; font-weight: 600;
}
.status.check { color: #ff6b4a; }
.hint {
  text-align: center; margin-top: 0.7rem;
  font-size: 0.82rem; color: rgba(244,240,232,.45);
}
.caps {
  min-height: 1.4rem;
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.35rem);
  letter-spacing: 0.08em;
  color: rgba(244,240,232,.7);
}

.board-wrap {
  width: min(92vw, 78vh, 620px);
  margin: 0 auto;
}
.files {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  padding-left: 1.15rem;
  font-size: 0.7rem;
  color: rgba(244,240,232,.4);
  text-align: center;
  font-weight: 600;
}
.board-row { display: flex; align-items: stretch; gap: 0.25rem; }
.ranks {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  width: 0.9rem;
  font-size: 0.7rem;
  color: rgba(244,240,232,.4);
  font-weight: 600;
  align-items: center;
  text-align: center;
}
.ranks span { display: grid; place-items: center; }

.board {
  position: relative;
  flex: 1;
  aspect-ratio: 1;
  border: 10px solid #5a3a1c;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  user-select: none;
  touch-action: manipulation;
}
.squares {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  height: 100%;
}
.sq {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  margin: 0;
  appearance: none;
  display: block;
  cursor: pointer;
  font: inherit;
}
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last { box-shadow: inset 0 0 0 3px rgba(232, 197, 71, .45); }
.sq.sel { box-shadow: inset 0 0 0 3px #e8c547; }
.sq.check { box-shadow: inset 0 0 0 3px #e23d2a, inset 0 0 18px rgba(226, 61, 42, .35); }
.sq.dest::after {
  content: "";
  position: absolute; inset: 36%;
  border-radius: 50%;
  background: rgba(20, 40, 20, .38);
  pointer-events: none;
}
.sq.cap::after {
  content: "";
  position: absolute; inset: 6%;
  border-radius: 50%;
  border: 3px solid rgba(226, 61, 42, .7);
  background: transparent;
  pointer-events: none;
}

.pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pc {
  --lean: 1;
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: grid;
  place-items: center;
  font-size: clamp(1.45rem, 7.2vw, 3.15rem);
  line-height: 1;
  z-index: 2;
  overflow: visible;
  will-change: left, top;
  transition: left 0.4s linear, top 0.4s linear;
}
.pc.no-anim { transition: none !important; }
.pc.moving { z-index: 6; }
.pc.face-l { --lean: -1; }
.pc.w { color: #f7f4ee; filter: drop-shadow(0 2px 1px rgba(0,0,0,.55)); }
.pc.b { color: #161311; filter: drop-shadow(0 1px 0 rgba(255,255,255,.25)) drop-shadow(0 2px 2px rgba(0,0,0,.45)); }

.shadow {
  position: absolute;
  left: 28%; right: 28%;
  bottom: 6%;
  height: 12%;
  background: rgba(0,0,0,.28);
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}
.glyph {
  position: relative;
  z-index: 1;
  display: block;
  transform-origin: 50% 88%;
  animation: idle 2.6s ease-in-out infinite;
  animation-delay: var(--idle, 0s);
}
.pc.moving .glyph { animation: none; }

@keyframes idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4%); }
}

.pc.walk .glyph { animation: walk .28s ease-in-out infinite; }
.pc.stride .glyph { animation: walk .36s ease-in-out infinite; }
@keyframes walk {
  0%, 100% { transform: translateY(0) rotate(calc(var(--lean) * 6deg)) scaleY(1); }
  25% { transform: translateY(-14%) rotate(calc(var(--lean) * 8deg)) scaleY(1.05); }
  50% { transform: translateY(0) rotate(calc(var(--lean) * 5deg)) scaleY(0.94); }
  75% { transform: translateY(-12%) rotate(calc(var(--lean) * 8deg)) scaleY(1.04); }
}

.pc.leap .glyph { animation: leap .52s cubic-bezier(.2,.8,.25,1); }
.pc.leap .shadow { animation: squash .52s ease; }
@keyframes leap {
  0% { transform: translateY(0) rotate(calc(var(--lean) * -8deg)) scaleY(0.96); }
  40% { transform: translateY(-38%) rotate(calc(var(--lean) * 10deg)) scaleY(1.08); }
  100% { transform: translateY(0) rotate(calc(var(--lean) * 4deg)) scaleY(1); }
}
@keyframes squash {
  0%, 100% { transform: scaleX(1); opacity: .28; }
  40% { transform: scaleX(.4); opacity: .1; }
}

.pc.captured { z-index: 1; }
.pc.captured .glyph { animation: fall .42s ease-in forwards; }
.pc.captured .shadow { opacity: 0; }
@keyframes fall {
  0% { transform: rotate(0) translateY(0); opacity: 1; }
  70% { transform: rotate(calc(var(--lean) * -80deg)) translateY(12%) scale(.9); opacity: 1; }
  100% { transform: rotate(calc(var(--lean) * -100deg)) translateY(22%) scale(.7); opacity: 0; }
}

.promo {
  position: fixed; inset: 0;
  background: rgba(8, 10, 14, .62);
  display: grid; place-items: center;
  z-index: 20;
}
.promo.hidden { display: none; }
.promo p {
  text-align: center; margin-bottom: 0.7rem;
  font-weight: 600; color: var(--gold);
}
.promo-row {
  display: flex; gap: 0.55rem;
  background: #1a1612;
  padding: 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(232,197,71,.35);
}
.promo-row button {
  width: 3.4rem; height: 3.4rem;
  font-size: 2rem;
  border: 0; border-radius: 8px;
  background: var(--sq-light);
  color: #161311;
  cursor: pointer;
}
.promo-row button:hover { background: var(--gold); }

@media (max-width: 520px) {
  .board { border-width: 6px; }
  .ranks, .files { font-size: 0.62rem; }
}
:root {
  --ink: #0b0c10;
  --paper: #f4f0e8;
  --gold: #e8c547;
  --sq-light: #ecd6b0;
  --sq-dark: #b58863;
  --font-display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  color: var(--paper);
  font-family: var(--font-body);
  background: var(--ink);
}
.atmosphere {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse 70% 45% at 50% 0%, rgba(232, 197, 71, 0.14), transparent 55%),
    linear-gradient(180deg, #0a0c10, #141218);
}

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2rem);
}
.back { color: rgba(244,240,232,.55); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--gold); }
h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 0.08em;
  font-weight: 400;
}
.ghost {
  appearance: none; border: 1px solid rgba(244,240,232,.25); background: transparent;
  color: var(--paper); font: inherit; padding: 0.5rem 0.9rem; border-radius: 8px; cursor: pointer;
}
.ghost:hover { border-color: var(--gold); color: var(--gold); }

main { padding: 0 1rem 2rem; }
.status {
  text-align: center; margin: 0.15rem 0 0.55rem;
  color: var(--gold); min-height: 1.4em; font-weight: 600;
}
.status.check { color: #ff6b4a; }
.hint {
  text-align: center; margin-top: 0.7rem;
  font-size: 0.82rem; color: rgba(244,240,232,.45);
}
.caps {
  min-height: 1.4rem;
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.35rem);
  letter-spacing: 0.08em;
  color: rgba(244,240,232,.7);
}

.board-wrap {
  width: min(92vw, 78vh, 620px);
  margin: 0 auto;
}
.files {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  padding-left: 1.15rem;
  font-size: 0.7rem;
  color: rgba(244,240,232,.4);
  text-align: center;
  font-weight: 600;
}
.board-row { display: flex; align-items: stretch; gap: 0.25rem; }
.ranks {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  width: 0.9rem;
  font-size: 0.7rem;
  color: rgba(244,240,232,.4);
  font-weight: 600;
  align-items: center;
  text-align: center;
}
.ranks span { display: grid; place-items: center; }

.board {
  position: relative;
  flex: 1;
  aspect-ratio: 1;
  border: 10px solid #5a3a1c;
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  user-select: none;
  touch-action: manipulation;
}
.squares {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%;
  height: 100%;
}
.sq {
  position: relative;
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  margin: 0;
  appearance: none;
  display: block;
  cursor: pointer;
  font: inherit;
}
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last { box-shadow: inset 0 0 0 3px rgba(232, 197, 71, .45); }
.sq.sel { box-shadow: inset 0 0 0 3px #e8c547; }
.sq.check { box-shadow: inset 0 0 0 3px #e23d2a, inset 0 0 18px rgba(226, 61, 42, .35); }
.sq.dest::after {
  content: "";
  position: absolute; inset: 36%;
  border-radius: 50%;
  background: rgba(20, 40, 20, .38);
  pointer-events: none;
}
.sq.cap::after {
  content: "";
  position: absolute; inset: 6%;
  border-radius: 50%;
  border: 3px solid rgba(226, 61, 42, .7);
  background: transparent;
  pointer-events: none;
}

.pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.pc {
  --lean: 1;
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  display: grid;
  place-items: center;
  font-size: clamp(1.45rem, 7.2vw, 3.15rem);
  line-height: 1;
  z-index: 2;
  overflow: visible;
  will-change: left, top;
  transition: left 0.4s linear, top 0.4s linear;
}
.pc.no-anim { transition: none !important; }
.pc.moving { z-index: 6; }
.pc.face-l { --lean: -1; }
.pc.w { color: #f7f4ee; filter: drop-shadow(0 2px 1px rgba(0,0,0,.55)); }
.pc.b { color: #161311; filter: drop-shadow(0 1px 0 rgba(255,255,255,.25)) drop-shadow(0 2px 2px rgba(0,0,0,.45)); }

.shadow {
  position: absolute;
  left: 28%; right: 28%;
  bottom: 6%;
  height: 12%;
  background: rgba(0,0,0,.28);
  border-radius: 50%;
  filter: blur(1px);
  pointer-events: none;
}
.glyph {
  position: relative;
  z-index: 1;
  display: block;
  transform-origin: 50% 88%;
  animation: idle 2.6s ease-in-out infinite;
  animation-delay: var(--idle, 0s);
}
.pc.moving .glyph { animation: none; }

@keyframes idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4%); }
}

.pc.walk .glyph { animation: walk .28s ease-in-out infinite; }
.pc.stride .glyph { animation: walk .36s ease-in-out infinite; }
@keyframes walk {
  0%, 100% { transform: translateY(0) rotate(calc(var(--lean) * 6deg)) scaleY(1); }
  25% { transform: translateY(-14%) rotate(calc(var(--lean) * 8deg)) scaleY(1.05); }
  50% { transform: translateY(0) rotate(calc(var(--lean) * 5deg)) scaleY(0.94); }
  75% { transform: translateY(-12%) rotate(calc(var(--lean) * 8deg)) scaleY(1.04); }
}

.pc.leap .glyph { animation: leap .52s cubic-bezier(.2,.8,.25,1); }
.pc.leap .shadow { animation: squash .52s ease; }
@keyframes leap {
  0% { transform: translateY(0) rotate(calc(var(--lean) * -8deg)) scaleY(0.96); }
  40% { transform: translateY(-38%) rotate(calc(var(--lean) * 10deg)) scaleY(1.08); }
  100% { transform: translateY(0) rotate(calc(var(--lean) * 4deg)) scaleY(1); }
}
@keyframes squash {
  0%, 100% { transform: scaleX(1); opacity: .28; }
  40% { transform: scaleX(.4); opacity: .1; }
}

.pc.captured { z-index: 1; }
.pc.captured .glyph { animation: fall .42s ease-in forwards; }
.pc.captured .shadow { opacity: 0; }
@keyframes fall {
  0% { transform: rotate(0) translateY(0); opacity: 1; }
  70% { transform: rotate(calc(var(--lean) * -80deg)) translateY(12%) scale(.9); opacity: 1; }
  100% { transform: rotate(calc(var(--lean) * -100deg)) translateY(22%) scale(.7); opacity: 0; }
}

.promo {
  position: fixed; inset: 0;
  background: rgba(8, 10, 14, .62);
  display: grid; place-items: center;
  z-index: 20;
}
.promo.hidden { display: none; }
.promo p {
  text-align: center; margin-bottom: 0.7rem;
  font-weight: 600; color: var(--gold);
}
.promo-row {
  display: flex; gap: 0.55rem;
  background: #1a1612;
  padding: 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(232,197,71,.35);
}
.promo-row button {
  width: 3.4rem; height: 3.4rem;
  font-size: 2rem;
  border: 0; border-radius: 8px;
  background: var(--sq-light);
  color: #161311;
  cursor: pointer;
}
.promo-row button:hover { background: var(--gold); }

@media (max-width: 520px) {
  .board { border-width: 6px; }
  .ranks, .files { font-size: 0.62rem; }
}
