:root {
  --cell: 32px;
  --board: #d8a85a;
  --board-dark: #c8964a;
  --line: #5a3d1a;
  --margin: #f3ead7;
  --bg: #20242b;
  --panel: #2b313b;
  --panel2: #232831;
  --text: #eef1f5;
  --muted: #9aa3b1;
  --black: #1c1f25;
  --white: #f7f7f4;
  --accent: #4da3ff;
  --capture: #ff5d5d;
  --good: #5fd07a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 12px 60px;
}
.wrap { display: flex; gap: 28px; align-items: flex-start; flex-wrap: wrap; justify-content: center; }

.about {
  width: 100%;
  max-width: 760px;
  margin: 48px auto 0;
  padding: 20px 24px;
  background: var(--panel2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}
.about h2 { font-size: 16px; margin: 0 0 10px; color: var(--text); letter-spacing: 0.5px; }
.about p { margin: 0 0 10px; }
.about p:last-child { margin-bottom: 0; }
.about strong { color: var(--text); font-weight: 600; }
.about a { color: var(--accent); text-decoration: none; }
.about a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: 1px; }
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* ---- Board ---- */
.board-area { position: relative; }
.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(20, var(--cell));
  grid-template-rows: repeat(20, var(--cell));
  background: var(--margin);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  user-select: none;
}
.cell { position: relative; width: var(--cell); height: var(--cell); display: flex; align-items: center; justify-content: center; }
.cell.onboard { background: var(--board); box-shadow: inset 0 0 0 0.5px rgba(90,61,26,.45); }
.cell.onboard.alt { background: var(--board-dark); }
.cell.margin { color: var(--muted); font-size: 11px; font-weight: 600; }
.cell.selectable { cursor: pointer; }
.cell.selectable:hover.onboard { filter: brightness(1.08); }

.stone { width: 74%; height: 74%; border-radius: 50%; pointer-events: none; z-index: 2; }
.stone.B { background: radial-gradient(circle at 35% 30%, #4a4f59, var(--black) 70%); box-shadow: 0 1px 2px rgba(0,0,0,.5); }
.stone.W { background: radial-gradient(circle at 35% 30%, #ffffff, #d7d7cf 75%); box-shadow: 0 1px 2px rgba(0,0,0,.4); }

.cell.footprint::after {
  content: ""; position: absolute; inset: 1px; border: 2px solid var(--accent);
  border-radius: 4px; z-index: 1; pointer-events: none; opacity: .55;
}
.cell.center-mark::before {
  content: ""; position: absolute; inset: 3px; background: rgba(77,163,255,.18);
  border-radius: 4px; z-index: 0;
}
.cell.hint::after {
  content: ""; position: absolute; inset: 1px; border: 2px dashed var(--good);
  border-radius: 4px; z-index: 1; pointer-events: none;
}

.dot { position: absolute; width: 30%; height: 30%; border-radius: 50%; background: rgba(77,163,255,.85); z-index: 3; pointer-events: none; }
.dot.capture { width: 78%; height: 78%; background: transparent; border: 3px solid var(--capture); box-shadow: 0 0 6px rgba(255,93,93,.6); }
.dot.goal { background: var(--good); box-shadow: 0 0 8px var(--good); }
.cell.legal { cursor: pointer; }

.thinking {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(20,24,32,.35); border-radius: 6px; z-index: 10; font-weight: 600; letter-spacing: 1px;
}
.thinking.show { display: flex; }
.thinking span { background: rgba(0,0,0,.6); padding: 8px 18px; border-radius: 20px; }

/* ---- Side panel ---- */
.panel { background: var(--panel); border-radius: 10px; padding: 18px 20px; width: 300px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.turn { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 600; margin-bottom: 14px; }
.turn .chip { width: 22px; height: 22px; border-radius: 50%; border: 1px solid #000; }
.chip.B { background: radial-gradient(circle at 35% 30%, #4a4f59, #1c1f25 70%); }
.chip.W { background: radial-gradient(circle at 35% 30%, #fff, #d7d7cf 75%); }

.stat { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); margin: 4px 0; }
.stat b { color: var(--text); }

.banner { margin: 14px 0; padding: 12px; border-radius: 8px; background: #173a17; color: #b6f5b6; font-weight: 600; text-align: center; display: none; }
.banner.show { display: block; }

.controls { background: var(--panel2); border-radius: 8px; padding: 12px; margin: 14px 0; }
.controls .row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.controls label { color: var(--muted); width: 64px; flex: none; }
.controls select { flex: 1; background: #3a4250; color: var(--text); border: none; padding: 6px; border-radius: 6px; font-size: 13px; }

.btns { display: flex; gap: 8px; margin-top: 12px; }
button { flex: 1; background: #3a4250; color: var(--text); border: none; padding: 10px; border-radius: 7px; font-size: 14px; cursor: pointer; transition: background .15s; }
button:hover { background: #49546a; }
button.primary { background: var(--accent); color: #06243f; font-weight: 600; }
button.primary:hover { background: #6fb6ff; }
button:disabled { opacity: .4; cursor: default; }

details { margin-top: 16px; font-size: 13px; color: var(--muted); line-height: 1.55; }
details summary { cursor: pointer; color: var(--text); font-weight: 600; margin-bottom: 6px; }
details ul { padding-left: 18px; margin: 6px 0; }
.legend { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 12px; }
.legend .sw { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.legend .sw.move { background: rgba(77,163,255,.85); transform: scale(.55); }
.legend .sw.cap { border: 3px solid var(--capture); }

/* ---- Tutorial ---- (表示/非表示は .hidden で制御) */
.tutorial .tstep { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.tutorial h2 { font-size: 18px; margin: 0 0 10px; }
.tutorial .ttext { font-size: 14px; line-height: 1.6; }
.tutorial .ttext b { color: var(--text); }
.tutorial .tgoal { margin: 12px 0; padding: 10px; border-radius: 8px; background: var(--panel2); font-size: 13px; }
.tutorial .tgoal.done { background: #173a17; color: var(--good); }
.tutorial .progress { display: flex; gap: 5px; margin: 12px 0; }
.tutorial .progress i { height: 5px; flex: 1; border-radius: 3px; background: #3a4250; }
.tutorial .progress i.on { background: var(--accent); }
.hidden { display: none !important; }
.picker-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; letter-spacing: 0.5px; }
#modePicker { border: 1px solid var(--accent); }

/* ---- コーチマーク(吹き出し) ---- */
.coach {
  position: fixed; z-index: 1000; max-width: 230px;
  background: var(--accent); color: #06243f;
  font-size: 13px; font-weight: 600; line-height: 1.5;
  padding: 10px 13px; border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.45);
  display: none; pointer-events: none;
  animation: coachbob 1.4s ease-in-out infinite;
}
.coach.show { display: block; }
@keyframes coachbob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.coach .coach-arrow { position: absolute; width: 0; height: 0; }
.coach.top .coach-arrow { bottom: -8px; border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 8px solid var(--accent); }
.coach.bottom .coach-arrow { top: -8px; border-left: 8px solid transparent; border-right: 8px solid transparent; border-bottom: 8px solid var(--accent); }
.coach.no-arrow .coach-arrow { display: none; }

.cell.coach-target::after {
  content: ""; position: absolute; inset: -1px; border-radius: 50%;
  border: 3px solid var(--good); z-index: 4; pointer-events: none;
  animation: coachpulse 1.1s infinite;
}
@keyframes coachpulse {
  0% { box-shadow: 0 0 0 0 rgba(95,208,122,.6); }
  70% { box-shadow: 0 0 0 9px rgba(95,208,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(95,208,122,0); }
}

/* 3×3の枠(駒の範囲を示す)。グリッドに干渉しないよう絶対配置のオーバーレイ。 */
.frame3 {
  position: absolute;
  border: 3px solid var(--accent);
  border-radius: 6px;
  pointer-events: none;
  z-index: 6;
  box-shadow: 0 0 0 2px rgba(77,163,255,.25), 0 0 10px rgba(77,163,255,.4);
}
.frame3.bad {
  border-color: var(--capture);
  box-shadow: 0 0 0 2px rgba(255,93,93,.25), 0 0 10px rgba(255,93,93,.45);
}
.frame3.c2 {
  border-color: #f0a832;
  box-shadow: 0 0 0 2px rgba(240,168,50,.25), 0 0 10px rgba(240,168,50,.45);
}
.frame3.c3 {
  border-color: #b07bff;
  box-shadow: 0 0 0 2px rgba(176,123,255,.25), 0 0 10px rgba(176,123,255,.45);
}
.frame3.c4 {
  border-color: #57c98a;
  box-shadow: 0 0 0 2px rgba(87,201,138,.25), 0 0 10px rgba(87,201,138,.45);
}
/* 選択クイズで見つけた駒のチェックマーク */
.cell .check {
  position: absolute;
  z-index: 5;
  color: var(--good);
  font-weight: 900;
  font-size: 18px;
  text-shadow: 0 0 4px rgba(0,0,0,.7);
  pointer-events: none;
}
