:root {
  --bg: #efe7d2;
  --bg-deep: #d4b58e;
  --panel: rgba(254, 250, 241, 0.88);
  --panel-strong: rgba(255, 251, 244, 0.98);
  --ink: #241712;
  --muted: #6f5a4c;
  --accent: #9f2d24;
  --accent-strong: #73150f;
  --shadow: rgba(36, 23, 18, 0.18);
  --board-dark: #3b251c;
  --board-light: #d8b68e;
  --red-piece: #d85647;
  --black-piece: #171515;
  --highlight: #ffd75c;
  --move: rgba(255, 215, 92, 0.28);
  --capture: rgba(216, 86, 71, 0.34);
  --line: rgba(36, 23, 18, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.72), transparent 36%),
    radial-gradient(circle at bottom right, rgba(159, 45, 36, 0.22), transparent 28%),
    linear-gradient(140deg, var(--bg), var(--bg-deep));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(36, 23, 18, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(36, 23, 18, 0.025) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
  display: grid;
  gap: 1.5rem;
}

.hero,
.control-bar,
.board-card,
.panel {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 20px 38px var(--shadow);
}

.hero {
  border-radius: 28px;
  padding: 1.75rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  animation: rise-in 420ms ease-out both;
}

.eyebrow,
.label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  color: var(--accent-strong);
}

.hero h1,
.board-card h2,
.panel h2 {
  margin: 0.35rem 0 0;
  font-family: "Avenir Next Condensed", "Arial Narrow Bold", sans-serif;
  font-stretch: condensed;
  font-size: clamp(2.4rem, 5vw, 4.6rem);
  line-height: 0.92;
  text-transform: uppercase;
}

.hero__lede {
  max-width: 58ch;
  margin: 1rem 0 0;
  font-size: 1.02rem;
  color: var(--muted);
}

.hero__badges {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge,
.pill,
.turn-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.84rem;
  letter-spacing: 0.03em;
}

.badge,
.pill {
  border: 1px solid rgba(159, 45, 36, 0.18);
  background: rgba(255, 245, 235, 0.9);
}

.turn-chip {
  background: var(--accent-strong);
  color: #fff8f4;
}

.control-bar {
  border-radius: 24px;
  padding: 1rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  animation: rise-in 520ms ease-out both;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 180px;
  font-size: 0.92rem;
}

.control select,
.button {
  border: 1px solid rgba(36, 23, 18, 0.12);
  border-radius: 14px;
  background: var(--panel-strong);
  color: var(--ink);
  font: inherit;
}

.control select {
  padding: 0.85rem 1rem;
  min-width: 180px;
}

.control--toggle {
  position: relative;
  padding-right: 4.2rem;
}

.control--toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-rail {
  position: absolute;
  right: 0;
  top: 1.35rem;
  width: 3.4rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(36, 23, 18, 0.14);
  transition: background 180ms ease;
}

.toggle-rail::after {
  content: "";
  position: absolute;
  top: 0.2rem;
  left: 0.22rem;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: white;
  box-shadow: 0 8px 18px rgba(36, 23, 18, 0.16);
  transition: transform 180ms ease;
}

.control--toggle input:checked + .toggle-rail {
  background: rgba(159, 45, 36, 0.82);
}

.control--toggle input:checked + .toggle-rail::after {
  transform: translateX(1.36rem);
}

.control--buttons {
  flex-direction: row;
  gap: 0.7rem;
  margin-left: auto;
  min-width: auto;
}

.button {
  padding: 0.9rem 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(36, 23, 18, 0.12);
}

.button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.button--primary {
  background: linear-gradient(180deg, #b43c31, var(--accent-strong));
  color: #fff8f4;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 1.5rem;
  align-items: start;
}

.board-card {
  border-radius: 32px;
  padding: 1.4rem;
  animation: rise-in 620ms ease-out both;
}

.board-card__header,
.panel__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.board-card__header h2,
.panel h2 {
  font-size: clamp(1.9rem, 3vw, 2.7rem);
}

.board-frame {
  margin-top: 1.15rem;
  padding: 1rem;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.16)),
    #704533;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.38),
    inset 0 -12px 24px rgba(36, 23, 18, 0.2);
}

.board {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  border: 3px solid rgba(255, 255, 255, 0.42);
  border-radius: 18px;
  overflow: hidden;
  aspect-ratio: 1;
}

.square {
  position: relative;
  border: 0;
  margin: 0;
  padding: 0;
  min-height: 52px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease;
}

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

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

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

.square--movable::before,
.square--target::before,
.square--capture::before {
  content: "";
  position: absolute;
  inset: 0.25rem;
  border-radius: 16%;
}

.square--movable::before {
  border: 2px dashed rgba(255, 215, 92, 0.36);
}

.square--target::before {
  background: var(--move);
}

.square--capture::before {
  background: var(--capture);
}

.square--selected {
  transform: scale(0.98);
  box-shadow: inset 0 0 0 3px rgba(255, 215, 92, 0.86);
}

.square__coord {
  position: absolute;
  right: 0.38rem;
  bottom: 0.32rem;
  font-size: 0.58rem;
  font-weight: 700;
  color: rgba(255, 250, 241, 0.34);
  pointer-events: none;
}

.square--light .square__coord {
  color: rgba(36, 23, 18, 0.3);
}

.piece {
  position: relative;
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow:
    inset 0 10px 18px rgba(255, 255, 255, 0.22),
    inset 0 -14px 20px rgba(0, 0, 0, 0.26),
    0 9px 18px rgba(0, 0, 0, 0.24);
  transition: transform 150ms ease;
}

.square--selected .piece,
.square--target .piece {
  transform: translateY(-1px) scale(1.03);
}

.piece--red {
  background: radial-gradient(circle at 30% 26%, #f4a398, var(--red-piece));
}

.piece--black {
  background: radial-gradient(circle at 30% 26%, #6a5e5a, var(--black-piece));
}

.piece--king::after {
  content: "K";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--highlight);
  font-weight: 800;
  font-size: clamp(0.8rem, 2vw, 1.25rem);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.36);
}

.board-note,
.status-copy {
  margin: 1rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.side-panel {
  display: grid;
  gap: 1rem;
  animation: rise-in 720ms ease-out both;
}

.panel {
  border-radius: 24px;
  padding: 1.15rem 1.15rem 1.25rem;
}

.stats-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.stat {
  padding: 0.95rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(36, 23, 18, 0.06);
}

.stat__label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 0.35rem;
  font-family: "Avenir Next Condensed", "Arial Narrow Bold", sans-serif;
  font-size: 2rem;
}

.move-log {
  margin: 1rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
}

.move-log li {
  color: var(--muted);
}

.move-log li strong {
  color: var(--ink);
}

.panel--rules ul {
  margin: 0.8rem 0 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.55;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

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

@media (max-width: 980px) {
  .game-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }

  .hero__badges {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 1rem, 720px);
    padding-top: 1rem;
  }

  .hero,
  .board-card,
  .panel {
    border-radius: 22px;
  }

  .control-bar {
    padding: 1rem;
  }

  .control,
  .control select {
    width: 100%;
  }

  .control--buttons {
    width: 100%;
    margin-left: 0;
  }

  .control--buttons .button {
    flex: 1;
  }

  .board-frame {
    padding: 0.7rem;
  }

  .stats-panel {
    grid-template-columns: 1fr 1fr;
  }
}
