:root {
  --bg: #101218;
  --panel: #171a22;
  --text: #f4f7ff;
  --muted: #bac2d3;
  --accent: #58a6ff;
  --danger: #d94a4a;
  --light: #f0d9b5;
  --dark: #b58863;
  --piece: #111318;
  --select: #ffe169;
  --border: #2a2f3b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.app {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 14px;
}
.app__header h1 { margin: 0; font-size: 1.4rem; }
.app__header p { margin: 6px 0 0; color: var(--muted); }

.metadata,
.result-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.metadata {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.result-status {
  margin: 0;
  min-height: 1.25rem;
  color: var(--muted);
}
.field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: .85rem;
  font-weight: 600;
}
.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #202533;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.board-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.board {
  width: min(100%, 560px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-rows: repeat(8, minmax(0, 1fr));
  border: 2px solid #000;
  background: var(--dark);
  overflow: hidden;
}
.square {
  border: none;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1 / 1;
  color: var(--piece);
  font-family: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols2", "Arial Unicode MS", sans-serif;
  font-size: clamp(1.6rem, 8.2vw, 3rem);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
}
.square--light { background: var(--light); }
.square--dark { background: var(--dark); }
.square--selected { outline: 4px solid var(--select); z-index: 1; position: relative; }
.square--legal { box-shadow: inset 0 0 0 4px rgba(88,166,255,.7); }
.status { margin: 10px 4px 2px; min-height: 1.25rem; color: var(--muted); }

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.btn {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #202533;
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}
.btn:active { transform: scale(0.98); }
.btn--danger { background: var(--danger); border-color: #ad3333; }

.moves {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}
.moves h2 { margin: 0 0 8px; font-size: 1.1rem; }
.move-list {
  margin: 0;
  padding-left: 1.4rem;
  line-height: 1.7;
  font-size: 1rem;
}

@media (min-width: 820px) {
  .app {
    grid-template-columns: minmax(300px, 560px) 1fr;
    align-items: start;
  }
  .app__header, .metadata, .result-panel, .controls { grid-column: 1 / -1; }
}
