:root {
  --bg: #f4efe2;
  --ink: #202531;
  --panel: #fffaf0;
  --line: #d2c3a5;
  --light: #f0d9b5;
  --dark: #b58863;
  --hl: #38bdf8;
  --cap: #ef4444;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #fff8e8, #f4efe2 48%, #ece4d2);
  color: var(--ink);
}

.shell {
  width: min(1060px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.top h1 { margin: 0; font-size: 1.45rem; }
.top p { margin: 4px 0 0; color: #5b6675; }

#restartBtn {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.hud {
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 560px) 1fr;
  gap: 14px;
}

.board {
  width: min(560px, calc(100vw - 28px));
  aspect-ratio: 1;
  border: 2px solid #93714f;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
}

.square {
  display: grid;
  place-items: center;
  font-size: clamp(20px, 2.8vw, 34px);
  font-weight: 800;
  user-select: none;
  cursor: pointer;
}

.square.light { background: var(--light); }
.square.dark { background: var(--dark); color: #f8fafc; }
.square.selected { outline: 3px solid #0ea5e9; outline-offset: -3px; }
.square.target::after,
.square.capture::after {
  content: "";
  width: 15px;
  height: 15px;
  border-radius: 999px;
  position: absolute;
}
.square.target { position: relative; }
.square.target::after { background: rgba(2, 132, 199, 0.55); }
.square.capture { position: relative; }
.square.capture::after { background: rgba(239, 68, 68, 0.75); }

.white-piece { color: #1f2937; text-shadow: 0 1px 0 rgba(255,255,255,0.45); }
.black-piece { color: #111827; }

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 12px;
}

.panel h2,
.panel h3 { margin: 0 0 8px; }
.panel p { margin: 0 0 8px; color: #465264; }
.small { font-size: 0.9rem; }

#moves {
  margin: 0;
  max-height: 370px;
  overflow: auto;
  padding-left: 20px;
}

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

  .board {
    margin: 0 auto;
  }
}
