:root {
  --light: #efdcbd;
  --dark: #a3714b;
  --accent: #d9a44a;
  --text: #ece5d8;
  --muted: #9d9484;
  --card: rgba(255, 255, 255, 0.045);
  --edge: rgba(255, 255, 255, 0.08);
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1100px 700px at 50% -10%, #2c251d, #171310 70%);
  color: var(--text);
  font: 15px/1.45 system-ui, sans-serif;
  display: flex;
  justify-content: center;
}
main {
  display: flex;
  gap: 28px;
  padding: 28px 20px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
#game { display: flex; flex-direction: column; }

/* ---- plaques ---- */
.plaque {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  margin: 10px 6px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid transparent;
  min-height: 46px;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.plaque .name {
  font-family: Charter, Georgia, serif;
  font-size: 19px;
  letter-spacing: 0.04em;
}
.plaque .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4c463c;
  flex: none;
  transition: background 0.25s;
}
.plaque.active { border-color: rgba(217, 164, 74, 0.55); box-shadow: 0 0 18px rgba(217, 164, 74, 0.12); }
.plaque.active .dot { background: var(--accent); animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse {
  50% { box-shadow: 0 0 0 5px rgba(217, 164, 74, 0.18); }
}
.plaque .captured { display: flex; margin-left: auto; height: 22px; }
.plaque .captured img { height: 22px; width: 22px; margin-left: -7px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5)); }
.plaque .mat { color: var(--accent); font-size: 13px; min-width: 24px; text-align: right; }

/* ---- board and frame ---- */
#frame {
  position: relative;
  padding: 22px;
  border-radius: 14px;
  background: linear-gradient(140deg, #463526, #2b1f17 65%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
#board {
  position: relative;
  width: min(88vw, 580px);
  aspect-ratio: 1;
  border-radius: 3px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), inset 0 0 26px rgba(0, 0, 0, 0.14);
}
#squares { position: absolute; inset: 0; display: grid; grid-template: repeat(8, 1fr) / repeat(8, 1fr); }
.sq { position: relative; cursor: pointer; }
.sq.light { background: linear-gradient(160deg, #f3e2c5, #e9d5b1); }
.sq.dark { background: linear-gradient(160deg, #ab7850, #9c6a44); }
.sq.last::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(217, 164, 74, 0.36);
}
.sq.selected::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(217, 164, 74, 0.32);
  box-shadow: inset 0 0 0 3px rgba(217, 164, 74, 0.85);
}
.sq.check::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(196, 52, 38, 0.65) 15%, rgba(196, 52, 38, 0.12) 75%);
}
.sq.target::after {
  content: '';
  position: absolute;
  inset: 36.5%;
  border-radius: 50%;
  background: rgba(46, 30, 16, 0.32);
}
.sq.capture::after {
  content: '';
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: 4px solid rgba(46, 30, 16, 0.35);
}

#pieces { position: absolute; inset: 0; pointer-events: none; }
.piece {
  position: absolute;
  width: 12.5%;
  height: 12.5%;
  transition: transform 0.18s ease;
  will-change: transform;
}
.piece.moving { z-index: 2; }
.piece img {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.35));
  transition: opacity 0.2s, scale 0.2s;
}
.piece.spawn img { opacity: 0; scale: 0.5; }
.piece.gone img { opacity: 0; scale: 0.6; }

/* frame coordinates */
#ranks, #files { position: absolute; display: flex; pointer-events: none; }
#ranks { top: 22px; bottom: 22px; left: 0; width: 22px; flex-direction: column; }
#files { left: 22px; right: 22px; bottom: 0; height: 22px; }
#ranks span, #files span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #c5a880;
  opacity: 0.75;
}

/* ---- sidebar ---- */
aside {
  width: 240px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-self: center;
}
.card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 12px;
}
#status { padding: 16px 18px; }
#status-main { font-family: Charter, Georgia, serif; font-size: 21px; }
#status-sub { color: var(--muted); font-size: 13px; min-height: 1.2em; margin-top: 2px; }
#status.over #status-main { color: var(--accent); }

#moves {
  margin: 0;
  padding: 10px 14px;
  list-style: none;
  min-height: 140px;
  max-height: 380px;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
#moves li {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  padding: 2px 0;
}
#moves li .num { color: var(--muted); }
#moves li span.latest { color: var(--accent); }

.actions { display: flex; gap: 10px; }
button { font: inherit; }
.actions button {
  flex: 1;
  padding: 9px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--edge);
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.actions button:hover { border-color: var(--accent); color: var(--accent); }

/* ---- promotion ---- */
#promo {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
}
#promo[hidden] { display: none; }
.sheet {
  display: flex;
  gap: 10px;
  padding: 18px;
  border-radius: 14px;
  background: #2e261e;
  border: 1px solid var(--edge);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
.sheet button {
  width: 72px;
  height: 72px;
  padding: 8px;
  background: var(--light);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: scale 0.12s;
}
.sheet button:hover { scale: 1.07; }
.sheet button img { width: 100%; height: 100%; }

@media (max-width: 900px) {
  main { flex-direction: column; }
  aside { width: min(88vw, 580px); }
}
