:root {
  --bg: #f9fbff;
  --card: #ffffff;
  --primary: #ff7e5f;
  --primary-dark: #e85d3f;
  --text: #2f2f2f;
  --muted: #666;
  --board-light: #ffe7d1;
  --board-dark: #ffb26b;
  --highlight: #00c2ff;
  --capture: #ff3b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Comic Sans MS', 'Baloo 2', 'Nunito', system-ui, sans-serif;
  background: radial-gradient(circle at top right, #e0f7ff, var(--bg));
  color: var(--text);
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem;
}

.hero {
  text-align: center;
}

.hero h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  color: #2f66ff;
}

.hero p {
  margin-top: 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgb(0 0 0 / 8%);
  padding: 1rem;
}

.controls {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  margin-bottom: 1rem;
}

.control-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

select,
button {
  width: 100%;
  border-radius: 12px;
  border: 2px solid #eee;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  font-family: inherit;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

button {
  cursor: pointer;
  background: linear-gradient(130deg, var(--primary), #ffb347);
  border: 0;
  color: #fff;
  font-weight: 700;
  transition: transform 0.15s ease, filter 0.15s ease;
}

button:hover {
  filter: brightness(1.05);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

.game-area {
  display: grid;
  grid-template-columns: minmax(280px, 620px) minmax(260px, 1fr);
  gap: 1rem;
}

.board-wrapper {
  display: grid;
  place-items: center;
}

.board {
  width: min(88vw, 620px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  border-radius: 16px;
  overflow: hidden;
  border: 6px solid #e4d4a8;
}

.square {
  display: grid;
  place-items: center;
  position: relative;
  font-size: clamp(1.3rem, 5vw, 3rem);
  user-select: none;
}

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

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

.square.selected {
  outline: 4px solid var(--highlight);
  outline-offset: -4px;
}

.square .dot,
.square .capture-dot {
  position: absolute;
  border-radius: 50%;
}

.square .dot {
  width: 24%;
  height: 24%;
  background: rgb(0 0 0 / 22%);
}

.square .capture-dot {
  width: 70%;
  height: 70%;
  border: 5px solid rgb(255 0 80 / 45%);
}

.coord {
  position: absolute;
  font-size: 0.74rem;
  font-weight: 700;
  color: rgb(0 0 0 / 44%);
}

.coord.file {
  right: 6px;
  bottom: 4px;
}

.coord.rank {
  left: 4px;
  top: 3px;
}

.sidebar h2,
.sidebar h3 {
  margin-top: 0;
}

.move-history {
  max-height: 260px;
  overflow: auto;
  padding-left: 1.1rem;
}

#promotionDialog {
  border: none;
  border-radius: 18px;
  padding: 0;
}

.promotion-form {
  padding: 1rem;
  min-width: 280px;
}

.promotion-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.promotion-options button {
  width: 100%;
}

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

  .sidebar {
    order: 2;
  }
}


.ai-config {
  margin-bottom: 1rem;
}

.ai-config h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}

input {
  width: 100%;
  border-radius: 12px;
  border: 2px solid #eee;
  padding: 0.55rem 0.7rem;
  font-size: 1rem;
  font-family: inherit;
}

.help-text {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}


.hero-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
}

.lang-switch {
  display: inline-flex;
  gap: 0.35rem;
}

.lang-btn {
  width: 48px;
  min-width: 48px;
  padding: 0.35rem;
  font-size: 1.25rem;
  line-height: 1;
  border-radius: 10px;
  border: 2px solid #ffe3b4;
}

.lang-btn.active {
  outline: 3px solid #2f66ff;
  outline-offset: 1px;
}
