:root {
  --bg: #ffffff;
  --panel: #f6f7f9;
  --text: #1d1f23;
  --muted: #646a73;
  --line: #dde0e5;
  --cell: #c8ccd3;
  --cell-hover: #b9bec7;
  --cell-open: #f2f3f5;
  /* 未開封のマスの縁(上と左は光、下と右は影。盛り上がって見せる) */
  --bevel-hi: rgba(255, 255, 255, 0.75);
  --bevel-lo: rgba(0, 0, 0, 0.16);
  --mine: #c2412d;
  --p0: #2f6fd6;
  --p1: #23955a;
  --p2: #c98a00;
  --lie: #d33a2c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17181b;
    --panel: #212226;
    --text: #ecedf0;
    --muted: #9ea3ab;
    --line: #36373c;
    --cell: #4d515b;
    --cell-hover: #5c606b;
    --cell-open: #1c1d20;
    --bevel-hi: rgba(255, 255, 255, 0.16);
    --bevel-lo: rgba(0, 0, 0, 0.38);
    --mine: #ef6a54;
    --p0: #6aa1ff;
    --p1: #4fce88;
    --p2: #f2b632;
    --lie: #ff6b5c;
  }
}

/* 右上のボタンでダークを選んだとき(端末の設定より優先) */
:root[data-theme="dark"] {
  --bg: #17181b;
  --panel: #212226;
  --text: #ecedf0;
  --muted: #9ea3ab;
  --line: #36373c;
  --cell: #4d515b;
  --cell-hover: #5c606b;
  --cell-open: #1c1d20;
  --bevel-hi: rgba(255, 255, 255, 0.16);
  --bevel-lo: rgba(0, 0, 0, 0.38);
  --mine: #ef6a54;
  --p0: #6aa1ff;
  --p1: #4fce88;
  --p2: #f2b632;
  --lie: #ff6b5c;
}


* { box-sizing: border-box; }
/* スマホでダブルタップしても拡大しない(二本指で広げる拡大はできる) */
html { touch-action: manipulation; }
/* スクロールバーが出たり消えたりしても、中身が左右にずれないよう、その場所をいつも空けておく */
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
main { max-width: 980px; margin: 0 auto; padding: 20px 16px 16px; }
.top, .rules, .size-row, .people, .stats, .tools, .message { max-width: 600px; margin-left: auto; margin-right: auto; }

.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: 0.02em; }
/* 幅が足りないとき(スマホでシードと推理の点を出すとき)は、地雷の数と時間を 2 行目の右に回す */
.stats { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px 12px; margin-bottom: 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats > span { white-space: nowrap; }
.stats-right { display: flex; gap: 12px; margin-left: auto; }
/* ヒントが地雷の数も使うときは、地雷の数を黄色にする */
#minesBox { border-radius: 6px; padding: 0 6px; box-shadow: 0 0 0 2px transparent; }
#minesBox.count-hint { background: color-mix(in srgb, #f2c230 40%, transparent); box-shadow: 0 0 0 2px #e0a800; }
/* 開いたマスに自分で付ける印(メモ) */
.cell.open.memo { box-shadow: inset 0 0 0 3px var(--text); }
.stats b { color: var(--text); }
.rules { color: var(--muted); font-size: 0.9rem; margin-top: 4px; margin-bottom: 6px; }

.people { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
/* 3 人の質問は 1 人 1 行 */
.person {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c);
  border-radius: 8px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.person.liar { outline: 2px solid var(--lie); }
.person .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.person .tag { font-size: 0.75rem; color: var(--lie); font-weight: 700; flex: none; }
.person .q { font-size: 0.9rem; color: var(--text); line-height: 1.4; flex: 1; }

/* 横スクロールバーは出さない(8×8 でもスマホの幅に収まる。端数の誤差で一瞬出ることがあったため) */
.board-wrap { overflow-x: clip; container-type: inline-size; }
/* 盤面と座標(上に列の文字、左に行の番号)。盤面は、ほかの欄と同じ幅(最大 600px)いっぱいに広げる */
.board-frame {
  --gap: 3px;
  --label: 18px;
  /* 1px は端数の誤差のための余白。
     高さでも抑える: 盤面(座標の行も)と下の道具ボタン(約 80px)が、画面の高さに収まる大きさまで
     (スマホを横向きにしたとき、スクロールしなくても盤面が全部見えるように。縦向きや PC では幅のほうで決まる) */
  --size: max(24px, min(calc((100cqw - var(--label) - var(--w, 8) * var(--gap) - 1px) / var(--w, 8)), calc((100svh - var(--label) - var(--w, 8) * var(--gap) - 88px) / var(--w, 8))));
  display: grid;
  grid-template-columns: var(--label) auto;
  grid-template-rows: var(--label) auto;
  gap: var(--gap);
  width: max-content;
  margin: 0 auto;
}
.col-labels, .row-labels { display: grid; gap: var(--gap); font-size: 0.75rem; font-weight: 700; color: var(--muted); user-select: none; -webkit-user-select: none; }
.col-labels { grid-column: 2; grid-row: 1; grid-template-columns: repeat(var(--w, 8), var(--size)); }
.row-labels { grid-column: 1; grid-row: 2; grid-template-rows: repeat(var(--w, 8), var(--size)); }
.col-labels span, .row-labels span { display: grid; place-items: center; }
.board-frame > .board { grid-column: 2; grid-row: 2; }
.board {
  display: grid;
  --gap: 3px;
  grid-template-columns: repeat(var(--w, 9), var(--size));
  gap: var(--gap);
  width: max-content;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* iPhone で長押ししたときのメニューを出さない(長押しは旗) */
  touch-action: manipulation;
}
.cell {
  width: var(--size);
  height: var(--size);
  border: none;
  border-radius: 4px;
  background: var(--cell);
  --bw: 2px;
  box-shadow: inset var(--bw) var(--bw) 0 var(--bevel-hi), inset calc(var(--bw) * -1) calc(var(--bw) * -1) 0 var(--bevel-lo);
  padding: 0;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  position: relative;
}
.cell:hover:not(.open) { background: var(--cell-hover); }
/* スマホで指が触れている間(開いていないマスは乗せたときと同じ色、開いたマスは少し濃く) */
.cell.pressing:not(.open):not(.hit) { background: var(--cell-hover); }
.cell.open.pressing { background: color-mix(in srgb, var(--text) 10%, var(--cell-open)); }
/* ゲームが終わったあとは押せないので、指の形にも、乗せたときの色の変化にもしない */
.board.over .cell { cursor: default; }
/* 旗のマスは、道具を選んでいないときは押しても変わらないので、指の形にも、乗せたときの色の変化にもしない */
.cell.flagged { cursor: default; }
body:not(.tool-on) .cell.flagged:hover:not(.open) { background: var(--cell); }
body.tool-on .board:not(.over) .cell.flagged { cursor: pointer; }
.board.over .cell:hover:not(.open) { background: var(--cell); }
.cell:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }
.cell.open { background: var(--cell-open); cursor: default; box-shadow: inset 0 0 0 1px var(--line); }
/* 押した瞬間の灰色の影(スマホのブラウザが付けるもの)は出さない。開いているマスは押しても何も起きないので、枠も出さない */
.cell { -webkit-tap-highlight-color: transparent; }
.cell.open:focus-visible { outline: none; }
.cell.mine { background: #c8ccd3; box-shadow: none; }
.cell.hit { background: var(--mine); box-shadow: none; }
/* 説明の小さな盤面では、縁を細くする */
.board.mini .cell { --bw: 1px; }
.icon { width: 1em; height: 1em; vertical-align: -0.12em; margin-right: 4px; }
.cell .icon { width: 62%; height: 62%; margin: 0; color: var(--text); }
.cell.mine .icon { color: #111; }

/* 開いたマスの印: 聞いたマスは「はい」の人の色の丸、嘘と分かったマスは赤い角 */
.yes-dots { display: flex; gap: calc(var(--size) * 0.06); }
.yes-dot { width: calc(var(--size) * 0.2); height: calc(var(--size) * 0.2); border-radius: 50%; background: var(--c); }
.cell.lied::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 calc(var(--size) * 0.32) calc(var(--size) * 0.32) 0;
  border-color: transparent var(--lie) transparent transparent;
  border-top-right-radius: 4px;
}



.message { min-height: 1.6em; font-weight: 600; margin: 12px 0; }
.message.bad { color: var(--lie); }

/* 旗・？の道具(スマホでも印を置けるように) */
.tools:not([hidden]) { display: flex; }
.tools { justify-content: center; gap: 10px; margin-top: 16px; }
.tools button {
  width: 52px;
  height: 52px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font: inherit;
}
.tools button .icon { width: 26px; height: 26px; margin: 0; }
.tools button[aria-pressed="true"] { border: 2px solid var(--text); background: var(--cell); }
.qmark { font-weight: 800; font-size: 1.4rem; line-height: 1; }
.cell .qmark { font-size: calc(var(--size) * 0.5); }
.message { text-align: center; }

/* ゲームが終わったあとの「もう一度遊ぶ」 */
.replay-wrap { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
#replay {
  font: inherit;
  font-weight: 700;
  border: none;
  background: var(--text);
  color: var(--bg);
  border-radius: 10px;
  padding: 12px 28px;
  cursor: pointer;
}
#replay[hidden], #share[hidden] { display: none; }
/* ヒントなしでクリアしたときの「Xで共有」 */
#share {
  font: inherit;
  font-weight: 700;
  border: 1px solid var(--text);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
}
/* ボタンが 1 つも出ていないときは場所を取らない */
.replay-wrap:not(:has(button:not([hidden]))) { display: none; }

/* 答えを待っているマス */
.cell.asking { animation: asking 0.7s ease-in-out infinite alternate; }
@keyframes asking { to { opacity: 0.45; } }
/* 通信エラーのときだけ出す。空なら場所を取らない */
.message:empty { display: none; }

/* 盤面を作っている間 */
.board-area { position: relative; max-width: 600px; margin-left: auto; margin-right: auto; }
.board-area.loading { min-height: 200px; }
.board-area.loading .board { opacity: 0.3; pointer-events: none; }
.board-area.busy .board { pointer-events: none; }
.loading-note {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--text);
  animation: asking 0.7s ease-in-out infinite alternate;
}
.loading-note[hidden] { display: none; }
#replay:disabled { opacity: 0.5; cursor: default; }

/* 盤面の大きさの切り替え */
.size-row { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.sizes { display: flex; gap: 6px; flex-wrap: wrap; }
.sizes button {
  font: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 10px;
  cursor: pointer;
}
.sizes button[aria-pressed="true"] { color: var(--text); border-color: var(--text); font-weight: 700; }

/* ヒント: 考えるとよいマスは黄色(枠が点滅)、安全なマスは緑の点線 */
.cell.clue {
  background: color-mix(in srgb, #f2c230 40%, var(--cell-open));
  box-shadow: inset 0 0 0 3px #e0a800;
  animation: clue 0.8s ease-in-out infinite alternate;
}
/* 答えだけで矛盾している手がかり(そのマスで誰かが嘘をついている)は紫 */
.cell.clue-conflict {
  background: color-mix(in srgb, #8b3fd9 30%, var(--cell-open));
  box-shadow: inset 0 0 0 3px #8b3fd9;
  animation: clue-conflict 0.8s ease-in-out infinite alternate;
}
@keyframes clue-conflict { to { box-shadow: inset 0 0 0 3px color-mix(in srgb, #8b3fd9 30%, transparent); } }
@keyframes clue { to { box-shadow: inset 0 0 0 3px color-mix(in srgb, #e0a800 30%, transparent); } }
/* 安全なマス: 緑の点線。iPhone の Safari では点線の枠(outline・border)の一辺が欠けることがあるので、
   4 辺を背景の縞(点線の形)で描く。--hw: 線の太さ、--hd: 点の長さ、--hg: 点の間 */
.cell.hint-target::after {
  content: "";
  position: absolute;
  inset: 1px;
  pointer-events: none;
  --hw: 3px;
  --hd: 7px;
  --hg: 4px;
  --h-x: repeating-linear-gradient(90deg, var(--p1) 0 var(--hd), transparent var(--hd) calc(var(--hd) + var(--hg)));
  --h-y: repeating-linear-gradient(180deg, var(--p1) 0 var(--hd), transparent var(--hd) calc(var(--hd) + var(--hg)));
  background:
    var(--h-x) left top / 100% var(--hw) no-repeat,
    var(--h-x) left bottom / 100% var(--hw) no-repeat,
    var(--h-y) left top / var(--hw) 100% no-repeat,
    var(--h-y) right top / var(--hw) 100% no-repeat;
}

/* ヒントを計算している間の電球 */
.tools button.waiting { animation: asking 0.5s ease-in-out infinite alternate; }
/* しばらくマスを開けていないとき、ヒントのボタンをゆっくり光らせる */
.tools button.nudge { animation: nudge 1.4s ease-in-out infinite alternate; }
@keyframes nudge {
  from { box-shadow: 0 0 0 0 rgba(242, 194, 48, 0); }
  to { box-shadow: 0 0 0 6px rgba(242, 194, 48, 0.55); background: color-mix(in srgb, #f2c230 30%, var(--panel)); }
}
@media (prefers-reduced-motion: reduce) {
  .tools button.nudge { animation: none; box-shadow: 0 0 0 4px rgba(242, 194, 48, 0.55); }
}

/* 負けたときの解説 */
#explainBtn {
  font: inherit;
  font-weight: 700;
  border: 1px solid var(--text);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 12px 20px;
  cursor: pointer;
}
#explainBtn[hidden] { display: none; }
.explain {
  max-width: 600px;
  margin: 16px auto 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-margin-top: 12px;
}
.explain[hidden] { display: none; }
.explain figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.explain figcaption { margin-top: 10px; font-size: 0.9rem; line-height: 1.6; display: flex; flex-direction: column; gap: 4px; }
.mini-wrap { container-type: inline-size; max-width: 280px; margin: 0 auto; }
.board.mini { --gap: 2px; }
/* 座標つき: 左に行の番号、上に列の文字 */
.board.mini.labeled {
  --label: 16px;
  --size: calc((100cqw - var(--label) - var(--w) * var(--gap)) / var(--w));
  grid-template-columns: var(--label) repeat(var(--w), var(--size));
}
.coord { display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
/* 切り出した図の盤面の端: 端に接するマスの縁に重ねて太い線(明るい画面は黒、暗い画面は白っぽい文字の色) */
.board.mini .cell.edge-l::before, .board.mini .cell.edge-r::before, .board.mini .cell.edge-t::before, .board.mini .cell.edge-b::before {
  content: ""; position: absolute; top: -1px; bottom: -1px; left: -1px; right: -1px;
  border: 0 solid var(--text); pointer-events: none;
}
.board.mini .cell.edge-l::before { border-left-width: 3px; }
.board.mini .cell.edge-r::before { border-right-width: 3px; }
.board.mini .cell.edge-t::before { border-top-width: 3px; }
.board.mini .cell.edge-b::before { border-bottom-width: 3px; }
.board.mini .cell { cursor: default; animation: none; border-radius: 3px; }
.board.mini .cell.hint-target::after { --hw: 2px; --hd: 4px; --hg: 3px; }
.board.mini .cell.clue { box-shadow: inset 0 0 0 2px #e0a800; }
.board.mini .cell.clue-conflict { box-shadow: inset 0 0 0 2px #8b3fd9; }
.cell.picked { box-shadow: inset 0 0 0 3px var(--lie); }
/* 場合分けの表 */
.cases { width: 100%; border-collapse: collapse; font-size: 0.85rem; line-height: 1.5; }
.cases caption { text-align: left; font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.cases th, .cases td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; text-align: left; }
.explain .note { color: var(--muted); font-size: 0.8rem; }
/* 解説の図の黄色のマス(押せる)と、選んでいるマス */
.board.mini button.cell { cursor: pointer; font: inherit; }
.cases ul { margin: 0; padding-left: 1.1em; }
.cases li + li { margin-top: 4px; }
.cases .then { color: var(--muted); }
/* 「→ …」はひとまとまり: 行の途中で入りきらなければ、矢印の前で改行する */
.then.arrow { display: inline-block; }
.cases b.t { color: var(--p1); }
/* 矢印から後ろはひとまとまり: 行の途中で入りきらなければ、矢印の前で改行する */
.concl { display: inline-block; white-space: nowrap; }
.cases details { margin-top: 4px; }
.cases summary { cursor: pointer; color: var(--muted); }
/* 説明文の中の小さな見本 */
.key { display: inline-block; width: 0.95em; height: 0.95em; border-radius: 3px; vertical-align: -0.12em; margin: 0 2px; background: var(--cell); }
.key-picked { box-shadow: inset 0 0 0 2px var(--lie); }
.key-safe { --kc: var(--p1); --kb: var(--cell); }
/* 文中の点線の印(緑の点線・黒い点線・赤い点線): 盤面のマスの点線をそのまま縮めた太さと間隔にする
   (outline の点線は小さい印には太く粗すぎる)。4 辺を背景の縞で描く。--kc: 線の色、--kb: マスの色 */
.key-safe, .key-elim, .key-assumed {
  --kw: 1px;
  --kd: 2.5px;
  --kg: 1.5px;
  --k-x: repeating-linear-gradient(90deg, var(--kc) 0 var(--kd), transparent var(--kd) calc(var(--kd) + var(--kg)));
  --k-y: repeating-linear-gradient(180deg, var(--kc) 0 var(--kd), transparent var(--kd) calc(var(--kd) + var(--kg)));
  background:
    var(--k-x) left 1px top 1px / calc(100% - 2px) var(--kw) no-repeat,
    var(--k-x) left 1px bottom 1px / calc(100% - 2px) var(--kw) no-repeat,
    var(--k-y) left 1px top 1px / var(--kw) calc(100% - 2px) no-repeat,
    var(--k-y) right 1px top 1px / var(--kw) calc(100% - 2px) no-repeat,
    var(--kb);
}
.key-conflict { background: color-mix(in srgb, #8b3fd9 30%, var(--cell-open)); box-shadow: inset 0 0 0 2px #8b3fd9; }
.key-clue { background: color-mix(in srgb, #f2c230 40%, var(--cell-open)); box-shadow: inset 0 0 0 2px #e0a800; }
.key-dot { border-radius: 50%; background: var(--c); width: 0.7em; height: 0.7em; vertical-align: 0; }
.key-dot.hollow { background: var(--bg); box-shadow: inset 0 0 0 2px var(--c); }
/* 理由の表は、PC でもスマホでも、嘘つきごとに見出しと「使う答え」を縦に並べる */
.cases thead { display: none; }
.cases, .cases tbody, .cases tr, .cases th, .cases td { display: block; width: auto; }
.cases tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.cases th, .cases td { border: none; }
.cases tbody th { background: var(--panel); }
.cases td::before { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.cases td:nth-of-type(1)::before { content: "使う証言"; }
.cases td.by-count::before { content: "地雷の数で考える"; }
.cases td.by-lie::before { content: "嘘の回数で考える"; }
.cases td + td { border-top: 1px dashed var(--line); }
/* 答えの並びのすぐ下の結論(1 行) */
.cases .cases-concl { margin: 6px 0 0; }
.cases caption { display: block; }

/* 解説 ①: 嘘つきではない人の理由 */
.explain .elim { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 0.9rem; line-height: 1.6; }
.explain .elim h3 { margin: 0 0 6px; font-size: 0.95rem; }
.explain .elim p { margin: 0 0 6px; }
.chain { margin: 0; padding-left: 1.4em; }
.chain li + li { margin-top: 4px; }
.chain .then { color: var(--muted); }
.chain b.t { color: var(--p1); }
.chain li.assume { list-style: none; margin-left: -1.4em; font-weight: 700; }
.chain-assume { margin: 0 0 4px; font-weight: 700; }
.chain li.pair .pair-line { display: block; }
.chain li.pair .pair-line + .pair-line { margin-top: 2px; }
.chain li.pair .pair-result { font-weight: 700; }
/* 手順の図: 決まった段の番号(地雷は角に小さく、安全は真ん中に) */
.board.mini .cell .step-no { position: absolute; top: 1px; left: 3px; font-size: 0.6rem; font-weight: 700; color: #111; line-height: 1; }
/* 開いたマス(嘘のマス)の段の番号は、文字の色(暗い画面でも見える) */
.board.mini .cell.open:not(.mine) .step-no { color: var(--text); }
.board.mini .cell.step-safe .step-num { font-size: 0.85rem; font-weight: 700; color: var(--p1); }
.board.mini .cell.contra-cell::after { content: ""; position: absolute; inset: 2px; border: 2px solid var(--lie); border-radius: 3px; pointer-events: none; }
/* 「嘘つきではない」の理由に使うマス: 黒い点線。iPhone の Safari では内側に描く outline の一辺が欠けるので、重ねた枠で描く */
.board.mini .cell.elim-cell::after { content: ""; position: absolute; inset: 2px; border: 2px dashed var(--text); border-radius: 3px; pointer-events: none; }
.key-elim { --kc: var(--text); --kb: var(--cell-open); }
.explain .elim details { margin-top: 4px; }
.explain .elim summary { cursor: pointer; color: var(--muted); }
.explain .flags .flag-list { list-style: none; padding-left: 0; }
.explain .flag-mini { width: 1em; height: 1em; vertical-align: -0.15em; margin-right: 4px; }
.board.mini .cell .icon.flag { width: 60%; height: 60%; margin: 0; }
.key-flag { width: 1.1em; height: 1.1em; vertical-align: -0.2em; margin: 0 1px; }
.explain .flag-mini { width: 1.2em; height: 1.2em; }
/* 地雷の総数で決まる場合の図 */
.explain .count-fig { margin: 8px 0 0; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.explain .count-fig figcaption { font-size: 0.8rem; }
.board.mini .cell.assumed::after { content: ""; position: absolute; inset: 2px; border: 2px dashed var(--lie); border-radius: 3px; pointer-events: none; }
.board.mini .cell .icon.bomb { width: 60%; height: 60%; margin: 0; }
.key-assumed { --kc: var(--lie); --kb: var(--cell); }
.cases .uses-fold, .explain .elim .uses-fold { margin-top: 6px; }
.cases .uses-fold summary, .explain .elim .uses-fold summary { cursor: pointer; color: var(--muted); font-size: 0.8rem; }
.explain .count-fig { margin-top: 0; }
/* 解説の図の安全なマス(押せる)と、表で理由を見ているマス */
.board.mini button.cell.hint-target { font: inherit; }
.board.mini .cell.hint-target.target-selected { background: color-mix(in srgb, var(--p1) 30%, var(--cell)); }
.explain-loading { margin: 0; text-align: center; font-weight: 700; color: var(--muted); animation: asking 0.7s ease-in-out infinite alternate; }
#explainBtn:disabled { opacity: 1; color: var(--text); cursor: default; }

/* 右上のライト/ダーク切り替え */
.theme-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.theme-btn .icon { width: 20px; height: 20px; margin: 0; }
.top { align-items: center; }
.key-lie { background: linear-gradient(225deg, var(--lie) 0 35%, var(--cell-open) 35%); box-shadow: inset 0 0 0 1px var(--line); }
/* 解説の節と表は、見出しを押すと折りたためる */
.explain details > summary { cursor: pointer; }
.explain details.elim > summary h3 { display: inline; }
.explain details.elim[open] > summary { margin-bottom: 6px; }
.cases-wrap > summary { font-weight: 700; font-size: 0.95rem; margin-bottom: 6px; }
.explain details.elim > summary { color: var(--text); }
/* シード(この盤面の URL をコピー) */
.seed-btn { margin-right: auto; font: inherit; font-size: 0.8rem; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; cursor: pointer; }
.seed-btn b { color: var(--text); font-weight: 700; letter-spacing: 0.04em; }
.seed-btn.copied b { color: var(--p1); }
.seed-btn[hidden] { display: none; }
.score-box { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.seed-btn { white-space: nowrap; }
.score-box b { color: var(--text); font-weight: 700; }
.score-box[hidden] { display: none; }
/* レベルの横の、同じ大きさ・難しさで新しい盤面にするボタン */
.regen-btn {
  width: 30px;
  height: 30px;
  margin-left: -6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.regen-btn .icon { width: 16px; height: 16px; margin: 0; }
/* 解説: 色の丸と名前・「合わない ✗」などを改行で分けない */
.nw { white-space: nowrap; }

/* 右上: デイリーへの行き来とライト/ダーク */
.top-right { display: flex; align-items: center; gap: 8px; }
.mode-link {
  height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}
.mode-link.done::after { content: " ✓"; color: var(--p1); }
/* デイリーの日付と盤面 */
.daily-head { max-width: 600px; margin: 0 auto 10px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.daily-head[hidden] { display: none; }
.daily-head b { font-size: 1.05rem; }
/* デイリーの成績 */
.daily-result { max-width: 600px; margin: 16px auto 0; text-align: center; font-size: 1.05rem; line-height: 1.7; }
.daily-result[hidden] { display: none; }
.daily-result .rank { font-size: 1.5rem; font-weight: 800; }
.daily-result .streak { display: block; font-weight: 700; }
.daily-result .sub { display: block; color: var(--muted); font-size: 0.9rem; }
.mode-link[hidden] { display: none; }
.home-link { color: inherit; text-decoration: none; }
/* 題名の下(ルールの行を証言の上に移したので、ここで間を空ける) */
.top { margin-bottom: 14px; }
/* スマホの幅: 題名と「デイリーチャレンジ」のボタンが 1 行に収まるように少し小さく */
@media (max-width: 420px) {
  h1 { font-size: 1.35rem; }
  .mode-link { padding: 0 8px; font-size: 0.8rem; }
  .top-right { gap: 6px; }
  /* シード・ヒントの回数・地雷の数・時間を 1 行に収める */
  .stats { gap: 4px 8px; font-size: 0.9rem; }
  .stats-right { gap: 8px; }
  #minesBox { padding: 0 4px; }
}

/* JavaScript が動かないときだけ出る、ルールの要約 */
.noscript-about { max-width: 640px; margin: 24px auto; padding: 0 16px; line-height: 1.7; }

/* 統計の画面 */
.stats-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  padding: 16px;
  box-sizing: border-box;
}
.stats-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stats-dialog h2 { margin: 0; font-size: 1.2rem; }
.stats-dialog h3 { margin: 18px 0 6px; font-size: 1rem; }
#statsBands { margin: 10px 0 8px; }
.stats-table-wrap { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.stats-table th:first-child, .stats-table td:first-child { text-align: left; }
.stats-table thead th { font-size: 0.75rem; line-height: 1.25; color: var(--muted); font-weight: 700; vertical-align: bottom; }
.stats-table td.none { color: var(--muted); }
.stats-list th { font-weight: 600; }
.stats-table .icon { width: 0.95em; height: 0.95em; margin-right: 2px; vertical-align: -0.1em; }
/* 画面には出さず、読み上げだけに入れる文字 */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* 狭い画面: 題名の右のボタン(デイリー・統計・ライト/ダーク)が1行に収まるように詰める */
@media (max-width: 420px) {
  .top { gap: 6px; }
  .top-right { gap: 6px; }
  .mode-link { padding: 0 8px; }
}
.stats-dialog:focus { outline: none; }
/* 大きさ・範囲ごとの表: 単位は付けず、数字を真ん中にそろえる */
#statsTable th, #statsTable td { text-align: center; }
#statsTable th:first-child, #statsTable td:first-child { text-align: left; }
/* レベルの数字の欄(書き換えると、いちばん近いレベルの盤面にする) */
.level-input {
  width: 3.4em;
  height: 26px;
  margin-left: 2px;
  padding: 0 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  text-align: center;
  -moz-appearance: textfield;
}
.level-input::-webkit-inner-spin-button, .level-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.level-input[hidden], #scoreText[hidden] { display: none; }
/* デイリーチャレンジのボタン: 題名の右に入りきらない狭い画面では「デイリー」 */
.mode-short { display: none; }
@media (max-width: 370px) {
  .mode-long { display: none; }
  .mode-short { display: inline; }
}
/* 小さいスマホ: 統計の表が入りきるように、画面の余白と表の間を少し詰める */
@media (max-width: 370px) {
  .stats-dialog { padding: 12px; }
  .stats-table th, .stats-table td { padding: 7px 3px; }
}
