:root {
  --bg: #0f1418;
  --bg-deep: #05080a;
  --panel: rgba(240, 246, 242, 0.08);
  --panel-line: rgba(255, 255, 255, 0.08);
  --ink: #152028;
  --muted: #8ea0ac;
  --accent: #c16b2d;
  --accent-strong: #88411d;
  --shadow: rgba(0, 0, 0, 0.34);
  --board-border: #3e2e25;
  --board-core: #1f2f37;
  --square-light: #efe1ca;
  --square-dark: #6c4d3d;
  --square-selected: rgba(90, 190, 255, 0.4);
  --square-target: rgba(255, 196, 102, 0.38);
  --square-preview: rgba(155, 244, 156, 0.28);
  --piece-white: #fffdf7;
  --piece-black: #121417;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: #eff7f2;
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(63, 177, 191, 0.17), transparent 34%),
    radial-gradient(circle at bottom right, rgba(193, 107, 45, 0.18), transparent 32%),
    linear-gradient(145deg, var(--bg), var(--bg-deep));
}

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

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

.hero,
.control-bar,
.board-card,
.panel,
.promotion-dialog__card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  box-shadow: 0 24px 44px var(--shadow);
  backdrop-filter: blur(14px);
}

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

.eyebrow,
.label,
.stat__label,
.square__coord {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: #9fd5df;
}

.hero h1,
.board-card h2,
.panel h2,
.promotion-dialog__card h2 {
  margin: 0.35rem 0 0;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  line-height: 0.96;
  color: #f7fcfb;
}

.hero h1 {
  font-size: clamp(2.6rem, 5vw, 4.9rem);
}

.hero__lede,
.status-copy,
.board-note,
.move-log li,
.panel--rules li {
  color: rgba(239, 247, 242, 0.82);
  line-height: 1.58;
}

.hero__lede {
  max-width: 60ch;
  margin-top: 1rem;
}

.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;
  padding: 0.55rem 0.88rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.badge,
.pill {
  color: var(--ink);
  background: rgba(237, 247, 243, 0.9);
}

.turn-chip {
  color: #fff7ef;
  background: linear-gradient(180deg, #d07b40, #7a3816);
}

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

.control {
  display: grid;
  gap: 0.4rem;
  min-width: 190px;
}

.control select {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 0.92rem 1rem;
  background: rgba(246, 251, 248, 0.12);
  color: #eff7f2;
  font: inherit;
  font-weight: 700;
  appearance: none;
}

.control option {
  color: var(--ink);
}

.control--buttons {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 0.92rem 1.12rem;
  background: rgba(246, 251, 248, 0.13);
  color: #f4fbf8;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

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

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

.button--primary {
  background: linear-gradient(180deg, #d07b40, #7a3816);
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.75fr);
  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 h2,
.panel h2,
.promotion-dialog__card h2 {
  font-size: clamp(1.9rem, 3vw, 2.9rem);
}

.board-frame {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent),
    linear-gradient(140deg, var(--board-border), var(--board-core));
}

.board-grid {
  width: min(100%, 720px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  aspect-ratio: 1;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.24);
}

.square {
  position: relative;
  border: 0;
  padding: 0;
  display: grid;
  place-items: center;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease;
}

.square:hover:not(:disabled) {
  transform: scale(0.985);
}

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

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

.square--selected::after,
.square--target::after,
.square--preview-from::after,
.square--preview-to::after {
  content: "";
  position: absolute;
  inset: 0.18rem;
  border-radius: 14px;
}

.square--selected::after {
  background: var(--square-selected);
}

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

.square--preview-from::after,
.square--preview-to::after {
  background: var(--square-preview);
}

.square__coord {
  position: absolute;
  left: 0.45rem;
  top: 0.38rem;
  color: rgba(17, 23, 26, 0.48);
}

.square--dark .square__coord {
  color: rgba(255, 248, 241, 0.62);
}

.piece {
  position: relative;
  z-index: 1;
  font-size: clamp(2rem, 4.6vw, 3.3rem);
  line-height: 1;
  text-shadow:
    0 4px 10px rgba(0, 0, 0, 0.18),
    0 0 12px rgba(255, 255, 255, 0.08);
}

.piece--white {
  color: var(--piece-white);
}

.piece--black {
  color: var(--piece-black);
}

.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.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat strong {
  display: block;
  margin-top: 0.3rem;
  color: #fff8f1;
  font-family: "Iowan Old Style", "Palatino Linotype", serif;
  font-size: 1.95rem;
}

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

.move-log li strong {
  color: #fff7ef;
}

.panel--rules ul {
  margin: 0.8rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.55rem;
}

.promotion-dialog {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 10, 0.54);
  padding: 1rem;
}

.promotion-dialog[hidden] {
  display: none;
}

.promotion-dialog__card {
  border-radius: 26px;
  padding: 1.4rem;
  width: min(480px, 100%);
}

.promotion-dialog__actions {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

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

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

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

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

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

  .hero {
    flex-direction: column;
  }

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

  .control {
    width: 100%;
  }

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

  .button {
    width: 100%;
  }

  .board-frame {
    padding: 0.65rem;
  }

  .piece {
    font-size: clamp(1.65rem, 7vw, 2.6rem);
  }

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