/* ベーススタイル */
:root {
  --grid-gap: 12px;
  --circle-size: 44px;
  --color-group-1: #ff6b6b;
  --bg: #f7f9fc;
  --panel: #ffffff;
  --text: #1f2933;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans JP", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px 48px;
  gap: 16px;
}

.controls {
  width: fit-content;
  max-width: 100%;
  display: flex;
  padding: 10px 12px;
  background: var(--panel);
  border-radius: 12px;
  box-shadow: var(--shadow);
  align-self: center;
  justify-content: center;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.control-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.input-row {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.input-pair {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  justify-content: center;
}

label {
  display: flex;
  gap: 8px;
  align-items: center;
}

input[type="number"] {
  width: 86px;
  font-size: 18px;
  padding: 6px 8px;
  border: 2px solid #d0d7e2;
  border-radius: 10px;
  text-align: center;
  background: #fdfdff;
}

input[type="number"]:focus {
  outline: 2px solid #94b7ff;
}

.cross {
  font-size: 28px;
  font-weight: bold;
}

.buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}

.toggle-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* シンプルなトグル */
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

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

button {
  font-size: 18px;
  padding: 10px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #6aa7ff, #4e86ff);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.05s ease, box-shadow 0.1s ease;
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.board-wrapper {
  position: relative;
  width: min(960px, 100%);
  background: var(--panel);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 320px;
}

.grid-shell {
  display: grid;
  grid-template-columns: auto max-content;
  grid-template-rows: auto 1fr;
  column-gap: calc(var(--grid-gap) / 2);
  row-gap: calc(var(--grid-gap) / 2);
  justify-content: center;
  justify-items: center;
  align-items: start;
}

.corner {
  width: 32px;
  height: 32px;
}

.col-labels {
  display: grid;
  gap: var(--grid-gap);
  justify-content: center;
  align-items: center;
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

.row-labels {
  display: grid;
  gap: var(--grid-gap);
  align-content: center;
  justify-content: end;
  grid-column: 1 / 2;
  grid-row: 2 / 3;
}

.label-cell {
  width: var(--circle-size);
  height: var(--circle-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #4a5563;
  background: #eef2f7;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.grid-holder {
  position: relative;
  grid-column: 2 / 3;
  grid-row: 2 / 3;
}

#grid {
  display: grid;
  gap: var(--grid-gap);
  justify-content: center;
}

.circle {
  width: var(--circle-size);
  height: var(--circle-size);
  border-radius: 50%;
  background: #fff;
  border: 2px solid #e1e7f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #5b6470;
  user-select: none;
  touch-action: none; /* pointer イベントでドラッグ選択を扱う */
}

.circle[data-group="1"] {
  background: var(--color-group-1);
  color: #fff;
  border-color: var(--color-group-1);
}

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.overlay-group {
  position: absolute;
  border: 2px solid #333;
  border-radius: 10px;
  box-sizing: border-box;
  pointer-events: none;
}

.overlay-box {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.85);
  color: #2b2b2b; /* 濃いめの灰色 */
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  text-shadow:
    -1px -1px 0 rgba(255, 255, 255, 0.9),
    1px -1px 0 rgba(255, 255, 255, 0.9),
    -1px 1px 0 rgba(255, 255, 255, 0.9),
    1px 1px 0 rgba(255, 255, 255, 0.9); /* 白の縁取り */
}

.palette {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.palette-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #e4e7ed;
  cursor: pointer;
  outline: none;
  padding: 0;
  box-shadow: var(--shadow);
  transition: transform 0.05s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}

.color-swatch.selected {
  border-color: #2b2f38;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
}

.color-swatch:active {
  transform: translateY(1px);
}

.cat-button {
  padding: 10px 14px;
  font-size: 32px;
  line-height: 1;
  min-width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  box-shadow: none;
  border: none;
  border-radius: 12px;
}

@media (max-width: 640px) {
  :root {
    --circle-size: 36px;
    --grid-gap: 10px;
  }

  button {
    font-size: 16px;
  }

  .overlay-box {
    font-size: 18px;
  }
}

