:root {
  --ink: #1b1c1f;
  --muted: #5c6570;
  --line: #d9dee5;
  --bg: #f6f7f9;
  --panel: #ffffff;
  /* 盤は藍。緑にすると本家の意匠に寄るので使わない */
  --board: #23405f;
  --board-line: #35577c;
  --cell: #2c4d70;
  --disc-black: #16181d;
  --disc-white: #f5f4f0;
  --good: #d24a3d;
  --bad: #3a6ed0;
  --accent: #d24a3d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 16px 64px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7;
}

.site-head {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 0 20px;
  text-align: center;
}

.site-head h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  letter-spacing: 0.01em;
}

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

main { max-width: 560px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.lead { margin: 0 0 12px; font-size: 1rem; }

.intro {
  margin: 0 0 20px;
  padding-left: 1.1em;
  font-size: 0.9rem;
  color: var(--muted);
}

.intro li { margin-bottom: 6px; }

.chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: #fff;
  white-space: nowrap;
}

.chip--good { background: var(--good); }
.chip--bad { background: var(--bad); }

.btn-main {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-main:hover { filter: brightness(1.06); }

.btn-sub {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-sub:hover { background: #f0f2f5; }

.sub { margin: 10px 0 0; font-size: 0.82rem; color: var(--muted); }

/* --- スコア・状況 --- */

.scoreline {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 10px;
  font-size: 0.95rem;
}

.score { display: inline-flex; align-items: center; gap: 6px; }
.score b { font-size: 1.15rem; }

.disc {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}

.disc--black { background: var(--disc-black); }
.disc--white { background: var(--disc-white); border: 1px solid #b9bcc2; }

.status {
  margin: 0 0 12px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
}

.status--thinking { color: var(--muted); }

.alert {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
}

.alert--warn { background: #fdf3e3; border: 1px solid #efd9ac; color: #7a5518; }

/* --- 盤 --- */

.board-wrap { display: flex; justify-content: center; }

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  /* 行を指定しないと行高さが中身なりになり、石が縦長の楕円になる */
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  padding: 6px;
  background: var(--board-line);
  border-radius: 8px;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cell);
  border: none;
  border-radius: 3px;
  padding: 0;
  cursor: default;
  font: inherit;
  color: #fff;
}

.cell--playable { cursor: pointer; }
.cell--playable:hover { outline: 2px solid rgba(255, 255, 255, 0.55); outline-offset: -2px; }

.cell__disc {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  transition: transform 0.12s ease;
}

.cell__disc--black { background: var(--disc-black); box-shadow: inset 0 -2px 4px rgba(255,255,255,0.12); }
.cell__disc--white { background: var(--disc-white); box-shadow: inset 0 -2px 4px rgba(0,0,0,0.16); }

/* 評価値のオーバーレイ。色だけでなく数値も必ず出す（色覚多様性への配慮） */
.cell__score {
  font-size: clamp(0.62rem, 2.6vw, 0.86rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 2px 5px;
  border-radius: 4px;
  color: #fff;
  pointer-events: none;
}

.cell--best { outline: 3px solid #ffd45e; outline-offset: -3px; }

.cell--last::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px dashed rgba(255, 212, 94, 0.75);
  border-radius: 3px;
  pointer-events: none;
}

/* --- 読み中 --- */

.thinking { margin-top: 14px; }

.thinking__label {
  margin: 0 0 6px;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

.bar {
  height: 6px;
  background: #e7eaef;
  border-radius: 999px;
  overflow: hidden;
}

.bar__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.18s ease;
}

/* --- 説明 --- */

.explain { margin-top: 14px; min-height: 3.4em; }

.explain__head {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 0.94rem;
}

.explain__list { margin: 0; padding-left: 1.1em; font-size: 0.88rem; color: var(--muted); }
.explain__list li { margin-bottom: 2px; }
.explain__list li.good::marker { color: var(--good); }
.explain__list li.bad::marker { color: var(--bad); }

/* --- 終局 --- */

.result {
  margin-top: 16px;
  padding: 14px;
  border-radius: 10px;
  background: #f2f5fa;
  border: 1px solid var(--line);
  text-align: center;
}

.result__head { margin: 0; font-size: 1.1rem; font-weight: 700; }

/* --- 操作 --- */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 0.88rem; cursor: pointer; }

.site-foot {
  max-width: 560px;
  margin: 28px auto 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.site-foot p { margin: 0 0 8px; }

@media (max-width: 400px) {
  .panel { padding: 14px; }
  .scoreline { gap: 14px; font-size: 0.88rem; }
}
