:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --ink: #1d1a17;
  --muted: #6a5f56;
  --accent: #0f766e;
  --accent-2: #c33a20;
  --card: #ffffff;
  --line: rgba(29, 26, 23, 0.12);
  --shadow: 0 18px 40px rgba(29, 26, 23, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Pretendard", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, #fff8f2 0%, transparent 55%),
    radial-gradient(circle at 85% 20%, rgba(15, 118, 110, 0.18) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg), #efe9e2 100%);
  min-height: 100vh;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: rgba(243, 241, 236, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.28em;
  font-size: 13px;
  color: var(--accent);
}

.status {
  font-weight: 600;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 0.6fr);
  gap: 20px;
  padding: 20px 24px 28px;
  flex: 1;
}

.board-wrap {
  display: grid;
  gap: 12px;
}

.board {
  width: 100%;
  max-width: 760px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  background: #fff;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  font-size: clamp(26px, 4vw, 44px);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.square.light {
  background: #f7f2ea;
}

.square.dark {
  background: #d9cfc4;
}

.square.selected {
  outline: 3px solid rgba(15, 118, 110, 0.7);
  outline-offset: -3px;
}

.square.check {
  box-shadow: inset 0 0 0 4px rgba(195, 58, 32, 0.55);
}

.square.disabled {
  cursor: not-allowed;
}

.dot,
.capture-dot {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  opacity: 0.85;
}

.dot {
  background: rgba(15, 118, 110, 0.45);
}

.capture-dot {
  background: rgba(195, 58, 32, 0.7);
}

.legend {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.side {
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.panel-title {
  font-weight: 700;
  font-size: 14px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.25);
}

.btn.ghost {
  background: rgba(29, 26, 23, 0.08);
  color: var(--ink);
  box-shadow: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(29, 26, 23, 0.2);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}

.toggle input {
  width: 18px;
  height: 18px;
}

.move-log {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--ink);
  max-height: 220px;
  overflow: auto;
}

.help {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 8px;
  font-size: 12px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(29, 26, 23, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 24px;
  display: grid;
  gap: 10px;
  max-width: 320px;
  text-align: center;
}

.overlay-title {
  font-weight: 700;
  font-size: 18px;
}

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

  .board {
    max-width: 100%;
  }

  .move-log {
    max-height: 200px;
  }
}

@media (max-width: 560px) {
  .layout {
    padding: 16px;
  }

  .topbar {
    padding: 14px 16px;
  }
}
