/* フレネミー将棋 — スタイル（light / dark 両対応） */
:root {
  --bg: #f4efe6;
  --bg-2: #ebe3d4;
  --surface: #fffaf1;
  --border: #d9cdb7;
  --text: #2b2418;
  --text-2: #6d6250;
  --accent: #b5562b;
  --accent-soft: rgba(181, 86, 43, 0.12);
  --danger: #c0392b;
  --board: #e9c37a;
  --board-line: #8a6a33;
  --coord: #6d6250;
  --piece: #f8e7bf;
  --piece-edge: #b08a4a;
  --piece-text: #1f1a12;
  --promoted: #c8261d;
  --fox-tile: #dfe6ee;
  --fox-edge: #8193a8;
  --eval-b: rgba(181, 86, 43, 0.38);
  --eval-w: rgba(52, 104, 170, 0.32);
  --xai-b: #c2410c; /* 棋譜 URL の AI 比較（B33、B36 で最大 2 本）: ▲先手グラフ / △後手グラフ */
  --xai-w: #1d4ed8;
  --cand-char: #6b7280; /* 次の一手の「🎭 ○○が選ぶ手」の枠 */
  --cand-1: #1559c7;
  --cand-2: #3f7fd6;
  --cand-fox: #d96a0b;
  --cand-text: #fff;
  --sel: rgba(40, 120, 220, 0.38);
  --dest: rgba(40, 120, 220, 0.55);
  --last: rgba(255, 196, 0, 0.42);
  --flash: #ff6a3d;
  --check: #d6261d;
  --try: #1d8a4a;
  --actual: #12935a;
  --shadow: 0 8px 24px rgba(60, 40, 10, 0.12);
  --radius: 14px;
  --font: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', system-ui, sans-serif;
  --font-piece: 'Hiragino Mincho ProN', 'Yu Mincho', 'Noto Serif JP', serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --bg-2: #181b26;
    --surface: #1d2130;
    --border: #2f3548;
    --text: #e8e6e1;
    --text-2: #a5a9b8;
    --accent: #f08a54;
    --accent-soft: rgba(240, 138, 84, 0.16);
    --danger: #ff6b5e;
    --board: #b98d4c;
    --board-line: #5a4220;
    --coord: #a5a9b8;
    --piece: #f3dfb2;
    --piece-edge: #8d6b35;
    --fox-tile: #c9d3df;
    --fox-edge: #6c7d93;
    --eval-b: rgba(240, 138, 84, 0.42);
    --eval-w: rgba(110, 160, 235, 0.36);
    --xai-b: #fb923c;
    --xai-w: #60a5fa;
    --cand-char: #a8b0bf;
    --cand-1: #1446a8;
    --cand-2: #2f63b5;
    --cand-fox: #c45a00;
    --sel: rgba(80, 160, 255, 0.45);
    --dest: rgba(90, 170, 255, 0.7);
    --last: rgba(255, 200, 40, 0.38);
    --try: #2fae66;
    --actual: #3fd08a;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), var(--bg-2));
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.6;
}
[hidden] { display: none !important; }

button {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  touch-action: manipulation;
  transition: background 0.15s, border-color 0.15s, transform 0.06s;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.danger.primary, .dialog button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ghost { background: transparent; }
button.link { background: none; border: none; color: var(--text-2); text-decoration: underline; padding: 4px; }
button.big { width: 100%; padding: 14px; font-size: 1.1rem; margin-top: 18px; }

/* ===== メニュー ===== */
.screen { max-width: 980px; margin: 0 auto; padding: 12px 16px 32px; }
.menu { max-width: 560px; }
.menu-head { text-align: center; padding: 8px 0 4px; }
.back-link { display: inline-block; color: var(--text-2); font-size: 0.8rem; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.menu-topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.menu-open-btn { font-size: 0.85rem; padding: 6px 10px; white-space: nowrap; flex: none; }
.menu-head h1 { margin: 0; font-size: clamp(1.6rem, 6vw, 2.2rem); letter-spacing: 0.04em; }
.fox-mark { display: inline-block; transform: translateY(-2px); }
.lede { color: var(--text-2); margin: 4px 0 12px; font-size: 0.92rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin-top: 14px;
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 0.85rem; color: var(--text-2); margin: 12px 0 6px; font-weight: 600; }
.panel h2:first-child { margin-top: 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 6px; min-height: 52px; line-height: 1.25;
}
.seg button small { font-size: 0.7rem; color: var(--text-2); font-weight: 400; }
.seg button[aria-checked='true'] { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
/* 狐の動きは 4 択（なし / 玉 / ナイト / クィーン）: 375px でも折り返さないよう余白を詰める */
.seg[data-name='foxMove'] button { padding: 10px 2px; white-space: nowrap; }
/* 狐の休み: 狐なし（foxMove none）のときは無効（選択値は残す） */
.fox-rest-panel h2:first-child { margin-top: 12px; }
.fox-rest-panel.off h2 { color: var(--text-2); opacity: 0.7; }
.fox-rest-note { font-weight: 400; font-size: 0.75rem; margin-left: 6px; padding: 1px 6px; border: 1px solid var(--border); border-radius: 999px; }
.fox-rest-panel.off .seg button[aria-checked='true'] { box-shadow: none; }
.rules summary { cursor: pointer; font-weight: 700; }
.rules-body { font-size: 0.9rem; }
.rules-body h3 { font-size: 0.95rem; margin: 12px 0 4px; }
.rules-body ul { padding-left: 1.2em; margin: 4px 0; }
.rules-body li { margin: 2px 0; }
.muted { color: var(--text-2); }

/* 原案クレジット */
.credit {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 6px;
  text-align: center;
}
.credit-title { margin: 0; font-weight: 700; color: var(--accent); font-size: 0.95rem; }
.credit-text { margin: 4px 0 10px; font-size: 0.86rem; line-height: 1.6; }
.credit-link {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
}
.credit-link:hover { filter: brightness(1.08); }
.credit-link:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  .credit-link { color: #1d1208; }
}
/* 原案動画（16:9） */
.credit-video {
  width: 100%; aspect-ratio: 16 / 9;
  margin: 0 0 10px;
  border-radius: 10px; overflow: hidden;
  background: #000;
}
.credit-video iframe { display: block; width: 100%; height: 100%; border: 0; }
.menu-foot { margin-top: 18px; text-align: center; font-size: 0.78rem; color: var(--text-2); }
.menu-foot a { color: var(--accent); }

/* ===== 対局画面 ===== */
.game { padding-top: 8px; }
/* 1 行目: メニュー | 手番などの状態。2 行目: 対局条件のラベル（小さく 1 行、はみ出しは省略）。
   375px 幅でもボタン・手番表示は折り返さない */
.game-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px 8px;
  margin-bottom: 8px;
}
.game-head button { padding: 6px 10px; font-size: 0.85rem; white-space: nowrap; }
.status {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
  font-weight: 700; min-width: 0;
}
.status > * { white-space: nowrap; }
.turn {
  padding: 3px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 0.9rem;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.check {
  padding: 3px 10px; border-radius: 999px; background: var(--check); color: #fff; font-size: 0.85rem;
  animation: pulse 1s ease-in-out infinite;
}
/* 特殊トライ待ち（玉が相手陣 1 段目。10-try-rule-design.md） */
.try-ind {
  padding: 3px 10px; border-radius: 999px; background: var(--try); color: #fff; font-size: 0.85rem;
  white-space: nowrap;
}
.ply-limit-ind {
  padding: 3px 9px; border-radius: 999px; border: 1px solid var(--accent); color: var(--text); background: var(--accent-soft);
  font-size: 0.75rem; font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; flex: none;
}
.ply-limit-ind.urgent { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) {
  .ply-limit-ind.urgent { color: var(--bg); }
}
.thinking { font-size: 0.85rem; color: var(--text-2); animation: blink 1.2s ease-in-out infinite; }
/* 見出しの行: 対局条件 ＋ 500 手ルールの残り手数（I18b）。バッジの有無で高さが変わらないよう最小高さを確保 */
.mode-row { grid-column: 1 / -1; display: flex; justify-content: center; align-items: center; gap: 6px; min-width: 0; min-height: 27px; }
.mode-row:has(.mode-label:empty):has(.ply-limit-ind[hidden]) { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mode-label {
  min-width: 0; flex: 0 1 auto;
  font-size: 0.75rem; color: var(--text-2); text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mode-label:empty { display: none; }
@keyframes pulse { 50% { transform: scale(1.08); } }
@keyframes blink { 50% { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) {
  .thinking { animation: none; }
}
/* 残り秒（I02b）: スマホ幅では小さく（見出しを 1 段に収めて盤が上下しない） */
.think-sec { font-variant-numeric: tabular-nums; }
@media (max-width: 430px) {
  .think-sec { font-size: 0.8em; }
  /* 時間制の段階だけ「考え中…」の語を省く（絵文字＋残り秒）。時間制でなければ語を残す */
  .think-sec ~ .think-word, .think-word:has(~ .think-sec) { display: none; }
}

.game-body { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 860px) {
  .game-body { grid-template-columns: minmax(0, 1fr) 240px; align-items: start; }
}
.play-area { width: 100%; max-width: min(600px, calc((100dvh - 220px) * 1.05)); min-width: min(100%, 300px); margin: 0 auto; }

/* 持ち駒 */
.hand {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  min-height: 46px; padding: 4px 8px; margin: 4px 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.hand.to-move { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.hand-label { font-size: 0.78rem; color: var(--text-2); margin-right: 4px; white-space: nowrap; }
.hand-empty { font-size: 0.78rem; color: var(--text-2); opacity: 0.7; }
.hand-item {
  position: relative; width: 38px; height: 40px; padding: 0; border: none; background: none;
  display: grid; place-items: center; border-radius: 8px;
}
.hand-item .piece { width: 32px; height: 36px; font-size: 20px; }
.hand-item.sel { background: var(--sel); }
.hand-item .count {
  position: absolute; right: -2px; bottom: -2px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 8px; background: var(--text); color: var(--bg); font-size: 11px; line-height: 16px; text-align: center;
}

/* 盤 */
.board-frame {
  display: grid;
  grid-template-columns: 1fr 18px;
  grid-template-rows: 16px auto;
  gap: 2px;
}
.files { grid-column: 1; grid-row: 1; display: grid; grid-template-columns: repeat(var(--n, 9), 1fr); }
.ranks { grid-column: 2; grid-row: 2; display: grid; grid-template-rows: repeat(var(--n, 9), 1fr); }
.files span, .ranks span { display: grid; place-items: center; font-size: 11px; color: var(--coord); font-variant-numeric: tabular-nums; }
.board {
  grid-column: 1; grid-row: 2;
  display: grid;
  grid-template-columns: repeat(var(--n, 9), 1fr);
  grid-template-rows: repeat(var(--n, 9), 1fr);
  aspect-ratio: 1 / 1;
  background: var(--board);
  border: 2px solid var(--board-line);
  border-radius: 4px;
  box-shadow: var(--shadow);
  container-type: inline-size;
  touch-action: manipulation;
  user-select: none;
}
.cell {
  position: relative;
  border-right: 1px solid var(--board-line);
  border-bottom: 1px solid var(--board-line);
  display: grid; place-items: center;
  cursor: pointer;
  min-width: 0; min-height: 0;
}
.cell.col-last { border-right: none; }
.cell.row-last { border-bottom: none; }
.cell.last { background: var(--last); }
.cell.sel { background: var(--sel); }
.cell.dest::after {
  content: ''; position: absolute; width: 30%; height: 30%; border-radius: 50%;
  background: var(--dest); pointer-events: none; z-index: 2;
}
.cell.dest.capture::after {
  width: 86%; height: 86%; background: transparent; border: 3px solid var(--dest);
}
.cell.defected-flash::before {
  content: ''; position: absolute; inset: 0; background: var(--flash); opacity: 0;
  animation: flash 1.4s ease-out; pointer-events: none;
}
.cell.defected-mark { box-shadow: inset 0 0 0 2px var(--flash); }
.cell.try-wait { box-shadow: inset 0 0 0 3px var(--try); }
@keyframes flash { 0% { opacity: 0.85; } 100% { opacity: 0; } }

/* 駒（将棋駒の五角形） */
.piece {
  --ps: calc(100cqw / var(--n, 9));
  width: 86%; height: 92%;
  display: grid; place-items: center;
  clip-path: polygon(50% 0%, 84% 14%, 100% 100%, 0% 100%, 16% 14%);
  background: linear-gradient(180deg, var(--piece), color-mix(in srgb, var(--piece) 82%, var(--piece-edge)));
  color: var(--piece-text);
  font-family: var(--font-piece);
  font-weight: 700;
  font-size: calc(var(--ps) * 0.5);
  line-height: 1;
  padding-top: 12%;
  filter: drop-shadow(0 1px 0 var(--piece-edge));
  pointer-events: none;
}
.piece.down { rotate: 180deg; }
.piece.promoted { color: var(--promoted); }
.piece.k2 { font-size: calc(var(--ps) * 0.36); letter-spacing: -0.05em; }
.piece.defect-anim { animation: defect 0.9s ease-out; }
@keyframes defect {
  0% { transform: rotateY(0deg) scale(1); }
  40% { transform: rotateY(90deg) scale(1.15); }
  100% { transform: rotateY(0deg) scale(1); }
}
.hand-item .piece { font-size: 20px; padding-top: 4px; }

/* 狐（.fox = 位置とバッジの枠。向きは .fox-tile だけを回す） */
.fox {
  position: relative;
  width: 84%; height: 84%;
  pointer-events: none;
}
.fox-tile {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 28%;
  background: var(--fox-tile);
  border: 2px solid var(--fox-edge);
  font-size: calc(100cqw / var(--n, 9) * 0.5);
  line-height: 1;
  transition: rotate 0.45s ease-in-out;
}
/* 向きの目印（上辺の小さな山）。駒の五角形と同じく尖った側が「向いている方」 */
.fox-tile::before {
  content: ''; position: absolute; top: -2px; left: 50%;
  width: 26%; height: 10%;
  translate: -50% -100%;
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
  background: var(--fox-edge);
}
.fox-tile.down { rotate: 180deg; }
/* 盤中央の狐 = 相手キャラの顔（A07） */
.fox-tile.has-face { overflow: hidden; }
/* image-rendering はドット絵の拡大を保つ意図（SVG は crispEdges でにじまない） */
.fox-face { width: 86%; height: 86%; image-rendering: pixelated; object-fit: contain; }
/* 本将棋（9×9）はマスが小さいので札いっぱいに、天狐・神狐（明るい毛）は札を濃く */
.play-area[data-variant='standard'] .fox-face { width: 100%; height: 100%; }
.fox-tile.has-face.bright { background: color-mix(in srgb, var(--fox-edge) 55%, var(--fox-tile)); }
/* 休み中の顔はくすませすぎない（休みはバッジで伝える） */
.fox.resting .fox-tile.has-face { filter: grayscale(0.4); opacity: 0.9; }
.fox-face.char-emoji { width: auto; height: auto; }
.fox-tile.no-anim { transition: none; }
.fox.resting .fox-tile { filter: grayscale(0.7); opacity: 0.8; }
.fox.movable .fox-tile { box-shadow: 0 0 0 2px var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .fox-tile { transition: none; }
}
/* 狐の動きの記号（♛ / ♞）。左下に置き、札と一緒に回さない（休みバッジは右上） */
.fox-kind {
  position: absolute; bottom: -8%; left: -10%;
  font-size: max(9px, calc(100cqw / var(--n, 9) * 0.22));
  line-height: 1;
  padding: 1px 2px; border-radius: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--fox-edge);
  font-variant-emoji: text;
  font-family: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'DejaVu Sans', sans-serif;
}
.fox-badge {
  position: absolute; top: -6%; right: -10%;
  font-size: max(9px, calc(100cqw / var(--n, 9) * 0.2));
  font-family: var(--font);
  font-weight: 700;
  padding: 1px 3px; border-radius: 6px;
  background: var(--text); color: var(--bg);
  line-height: 1.2;
}

.controls { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.controls button { flex: 1 1 0; max-width: 140px; }

/* 棋譜 */
.kif-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow);
}
.kif-panel h2 { margin: 0 0 6px; font-size: 0.9rem; color: var(--text-2); }
.kif-list {
  list-style: none; margin: 0; padding: 0; position: relative;
  max-height: 240px; overflow-y: auto; font-size: 0.88rem; font-variant-numeric: tabular-nums;
}
@media (min-width: 860px) { .kif-list { max-height: 70vh; } }
.kif-list li { padding: 2px 4px; border-bottom: 1px dashed var(--border); display: flex; gap: 6px; flex-wrap: wrap; }
.kif-list li.latest { background: var(--accent-soft); }
.kif-list .no { color: var(--text-2); min-width: 2.2em; text-align: right; }
.kif-list .note { color: var(--accent); font-size: 0.8rem; }
.kif-empty { color: var(--text-2); font-size: 0.85rem; }

/* ダイアログ */
.dialog {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 240px;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.dialog-title { margin: 0 0 14px; font-weight: 700; text-align: center; }
.dialog-buttons { display: flex; gap: 10px; justify-content: center; }
.dialog-buttons button { min-width: 96px; }

.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  animation: fadein 0.3s ease-out;
}
.overlay-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 22px 24px 14px; text-align: center; min-width: min(320px, 100%); box-shadow: var(--shadow);
}
.result-title { font-size: 1.6rem; font-weight: 900; margin: 0; }
.result-reason { color: var(--text-2); margin: 4px 0 16px; white-space: pre-line; }
@keyframes fadein { from { opacity: 0; } }

/* トースト */
.toasts {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: 6px; align-items: center;
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  background: var(--text); color: var(--bg);
  padding: 8px 14px; border-radius: 999px; font-weight: 700; font-size: 0.9rem;
  box-shadow: var(--shadow); text-align: center;
  animation: toast-in 0.25s ease-out;
}
.toast.defect { background: var(--flash); color: #fff; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transition: opacity 0.4s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.noscript { text-align: center; padding: 24px; }

@media (max-width: 420px) {
  .screen { padding-left: 10px; padding-right: 10px; }
  .board-frame { grid-template-columns: 1fr 14px; grid-template-rows: 14px auto; }
  .files span, .ranks span { font-size: 10px; }
  .hand-item { width: 34px; height: 38px; }
  .hand-item .piece { width: 29px; height: 33px; font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition: none !important; }
}
.play-area[data-variant='mini'] { max-width: min(460px, calc((100dvh - 220px) * 1.05)); }

/* ===== 通信対戦 ===== */
.online-options .big { margin-top: 14px; }
.online-hint { color: var(--text-2); font-size: 0.8rem; margin: 6px 0 4px; }
.conn {
  font-size: 0.72rem; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-2); white-space: nowrap;
}
.conn[data-mode='sse'] { color: #1f8a4c; border-color: #1f8a4c; }
.conn[data-mode='polling'] { color: #b07a10; border-color: #b07a10; }
.conn[data-mode='offline'], .conn[data-mode='idle'] { color: var(--danger); border-color: var(--danger); }
.conn-btn { font-size: 0.75rem; padding: 2px 10px; border-color: var(--accent); color: var(--accent); }
.room-status.stalled::before { animation: none; background: var(--text-2); }
.room-card { max-width: 360px; width: calc(100% - 32px); }
.room-title { font-size: 1.15rem; font-weight: 700; margin: 0 0 8px; }
.room-sub { margin: 0 0 6px; font-size: 0.95rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
#room-overlay[data-kind='queued'] .room-title { color: #b07a10; }
#room-cancel-btn { margin-top: 14px; min-width: 9em; }
.room-status { color: var(--text-2); margin: 12px 0 4px; font-size: 0.85rem; min-height: 1.3em; }
.room-status::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 6px; animation: room-pulse 1.2s ease-in-out infinite; }
@keyframes room-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .room-status::before { animation: none; } }

/* ===== 終局後の振り返り ===== */
#result-overlay .dialog-buttons { flex-wrap: wrap; }
#result-overlay .dialog-buttons button { min-width: 84px; }
/* 振り返りバー（B34）: 盤のすぐ下に 局面の移動（⏮ ◀ ▶ ⏭）→ 解析・次の一手。盤反転などの操作列より上 */
.review-bar { margin-top: 8px; display: grid; gap: 6px; }
/* I27a: 振り返りの盤反転（盤のすぐ上・右寄せ） */
.review-top { display: flex; justify-content: flex-end; margin-bottom: 4px; }
.review-top button { font-size: 0.85rem; padding: 4px 12px; min-height: 36px; }
/* R2 枝分かれ検討: 盤の上の帯（左）＋盤反転（右）。狭い画面では帯が 1 行を取り、盤反転は下の行の右 */
.review-top.has-branch { justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.branch-band {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px 8px; flex: 1 1 auto; min-width: 0;
  padding: 3px 4px 3px 10px; border: 1px solid #2f855a; border-left-width: 4px; border-radius: 8px;
  background: rgba(47, 133, 90, 0.1); font-size: 0.85rem;
}
.branch-label { font-weight: 700; color: #276749; white-space: nowrap; }
.branch-eval, .branch-end { font-size: 0.8rem; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.branch-end { color: var(--text); font-weight: 700; }
.review-top .branch-exit { margin-left: auto; padding: 4px 10px; font-size: 0.82rem; white-space: nowrap; }
.kif-list li.kif-branch-head { color: #276749; font-size: 0.8rem; font-weight: 700; justify-content: center; border-bottom-style: solid; }
.kif-list li.kif-branch { background: rgba(47, 133, 90, 0.08); padding-left: 14px; }
.kif-list li.kif-branch-end { color: var(--text-2); cursor: default; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .branch-label, :root:not([data-theme='light']) .kif-list li.kif-branch-head { color: #68d391; }
}
.review-pos { margin: 0; text-align: center; font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.review-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.review-nav button {
  min-height: 46px; padding: 6px 4px; font-size: 1.05rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; white-space: nowrap;
  touch-action: manipulation;
}
.review-nav .nav-lab { font-size: 0.82rem; font-weight: 600; }
/* I22: 解析・共有はグラフの下（次の一手は「評価値 / 次の一手」の切り替えのカード） */
.review-tools { margin-top: 8px; }
.review-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.review-actions > button { min-height: 40px; padding: 6px 10px; font-size: 0.85rem; white-space: nowrap; }
.review-analyze { border-color: var(--accent); color: var(--accent); font-weight: 700; }
/* I34: 振り返りの [再挑戦]・[次の対局]（統計の上）。狭い画面でも横に 2 つ、高さ 44px 以上 */
.review-again { display: flex; gap: 8px; margin: 12px 0 4px; }
.review-again > button { flex: 1 1 0; min-width: 0; min-height: 48px; padding: 8px 10px; font-size: 0.95rem; font-weight: 700; }
.review-analyze.busy { font-variant-numeric: tabular-nums; opacity: 0.85; }
.cand-ai { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; color: var(--text-2); min-width: 0; }
.cand-ai select {
  min-width: 0; max-width: 14em; min-height: 36px; font: inherit; font-size: 0.82rem; color: var(--text);
  padding: 3px 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
@media (max-width: 420px) {
  .review-nav .nav-lab { font-size: 0.74rem; }
}
.kif-list.reviewable li { cursor: pointer; }
.kif-list.reviewable li:hover { background: var(--accent-soft); }
.kif-list li.current { outline: 2px solid var(--accent); outline-offset: -2px; }
.eval-panel {
  margin-top: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow);
}
.eval-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.eval-head h2 { margin: 0; font-size: 0.9rem; color: var(--text-2); }
.eval-status { font-size: 0.8rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.eval-graph { display: block; width: 100%; height: auto; margin-top: 6px; cursor: pointer; touch-action: manipulation; }
.eval-graph .area-b { fill: var(--eval-b); }
.eval-graph .area-w { fill: var(--eval-w); }
.eval-graph .line { fill: none; stroke: var(--text); stroke-width: 1.5; stroke-linejoin: round; }
.eval-graph .zero { stroke: var(--text-2); stroke-width: 1; }
.eval-graph .frame { fill: none; stroke: var(--border); }
.eval-graph .cursor { stroke: var(--accent); stroke-width: 2; }
.eval-graph .dot { fill: var(--accent); }
.eval-graph text { fill: var(--text-2); font-size: 10px; font-family: var(--font); }
.eval-graph .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }
.eval-graph .tick { font-size: 9px; font-variant-numeric: tabular-nums; }
.eval-graph .mate-mark rect { fill: var(--surface); stroke: var(--accent); stroke-width: 1; }
.eval-graph .mate-mark text { fill: var(--accent); font-size: 10px; font-weight: 700; }
.eval-cur { margin: 4px 0 0; font-size: 0.85rem; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 1.3em; }
.eval-note { margin: 4px 0 0; font-size: 0.75rem; color: var(--text-2); }

/* ===== プレイヤー名（通信対戦） ===== */
.name-input {
  display: block; width: 100%;
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px;
}
.name-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.online-options h2 label { cursor: pointer; }
/* 持ち駒欄の名前（長い名前は省略記号） */
.hand-name {
  display: inline-block; max-width: 8.5em; vertical-align: bottom;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); font-weight: 700;
}
.hand-name.hand-name-wide { max-width: 11em; }
.hand-name { text-wrap: balance; }
/* I30 レビュー: 組み合わせの長い名前は切らずに 2 行まで折り返す（ラベルの nowrap を名前だけ外す） */
.hand-label:has(.hand-name-wide) { white-space: normal; }
.hand-name.hand-name-wide {
  max-width: min(16em, 100%); white-space: normal; overflow-wrap: anywhere; line-height: 1.25;
  display: -webkit-inline-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
.result-players {
  margin: -10px 0 14px; font-size: 0.9rem; color: var(--text-2);
  overflow-wrap: anywhere;
}
.room-name { margin: 0 0 4px; font-size: 0.85rem; color: var(--text-2); overflow-wrap: anywhere; }

/* ===== 振り返り常設ボタン・次の一手 ===== */
.controls .review-open { border-color: var(--accent); color: var(--accent); }
.cand-btn { font-size: 0.85rem; }
.cand-btn[aria-pressed='true'] { border-color: var(--accent); background: var(--accent-soft); }
.board { position: relative; }
.cand-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 3; overflow: visible;
}
.cand .arrow { fill: var(--cand-2); stroke: #fff; stroke-width: 0.02; opacity: 0.62; }
.cand.rank1 .arrow { fill: var(--cand-1); opacity: 0.88; }
.cand.cand-fox .arrow { fill: var(--cand-fox); }
.cand .badge { fill: var(--cand-2); stroke: #fff; stroke-width: 0.03; }
.cand.rank1 .badge { fill: var(--cand-1); }
.cand.cand-fox .badge { fill: var(--cand-fox); }
.cand .badge-text { fill: var(--cand-text); font-size: 0.24px; font-weight: 800; font-family: var(--font); }
.cand .drop-box {
  fill: color-mix(in srgb, var(--cand-2) 22%, transparent);
  stroke: var(--cand-2); stroke-width: 0.05; stroke-dasharray: 0.12 0.07;
}
.cand.rank1 .drop-box { fill: color-mix(in srgb, var(--cand-1) 26%, transparent); stroke: var(--cand-1); stroke-width: 0.07; }
.cand .drop-text { fill: var(--cand-1); font-size: 0.3px; font-weight: 800; font-family: var(--font-piece); paint-order: stroke; stroke: #fff; stroke-width: 0.06px; }
.cand.dim { opacity: 0.22; }
.cand.hl .arrow { opacity: 0.95; }
/* 振り返り: 実際に指した手（緑・破線の輪郭。候補の矢印と区別） */
.actual .arrow { fill: color-mix(in srgb, var(--actual) 30%, transparent); stroke: var(--actual); stroke-width: 0.05; stroke-dasharray: 0.12 0.07; stroke-linejoin: round; }
.actual .drop-box { fill: color-mix(in srgb, var(--actual) 22%, transparent); stroke: var(--actual); stroke-width: 0.06; stroke-dasharray: 0.12 0.07; }
.actual.faint { opacity: 0.85; }
.actual .halo { fill: none; stroke: rgba(255, 255, 255, 0.9); stroke-width: 0.11; stroke-linejoin: round; }
.cand-actual { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; padding: 4px 8px; border-radius: 8px; border-left: 4px solid var(--actual); background: color-mix(in srgb, var(--actual) 10%, transparent); font-size: 0.85rem; }
.cand-actual-label { color: var(--actual); font-weight: 700; font-size: 0.78rem; }
.cand-actual-note { color: var(--text-2); font-size: 0.78rem; margin-left: auto; }
.cand-row.is-actual { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--actual) 60%, transparent); }
.cand-actual-badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--actual); color: #fff; font-size: 0.7rem; font-weight: 800; vertical-align: 1px; }
.cand-panel {
  margin-top: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; box-shadow: var(--shadow);
}
.eval-status.busy { animation: blink 1.2s ease-in-out infinite; color: var(--accent); font-weight: 700; }
.cand-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.cand-row {
  width: 100%; display: grid; grid-template-columns: 2em minmax(0, 1fr) auto; align-items: baseline;
  column-gap: 6px; text-align: left; padding: 6px 10px; font-variant-numeric: tabular-nums;
  border-left: 4px solid var(--cand-2);
}
.cand-row.rank1 { border-left-color: var(--cand-1); }
.cand-row.cand-fox { border-left-color: var(--cand-fox); } /* 狐の候補（盤の狐の .fox とは別の名前。R1 の不具合の修正） */
.cand-row.hl { background: var(--accent-soft); border-color: var(--accent); border-left-color: var(--accent); }
.cand-no { color: var(--text-2); }
.cand-kif { overflow-wrap: anywhere; }
.cand-score { font-weight: 800; text-align: right; }
.cand-side { grid-column: 2 / -1; font-size: 0.72rem; color: var(--text-2); font-weight: 400; text-align: right; }
/* 読み筋（R1）・候補のカード・「評価値 / 次の一手」の切り替え・凡例・注釈の折りたたみは features/review/review.css */
/* 終局後は「📈 振り返る」が入る。375px 幅でも 1 行に収める */
.controls button { white-space: nowrap; }
@media (max-width: 420px) {
  .controls { gap: 6px; }
  .controls button { padding: 8px 6px; font-size: 0.92rem; }
}

/* ===== 振り返りの共有 URL ===== */
.share-btn { font-size: 0.85rem; }
.share-dialog { width: min(440px, calc(100vw - 32px)); }
.share-note { margin: -6px 0 10px; font-size: 0.85rem; color: var(--text-2); }
.share-url {
  display: block; width: 100%; resize: none;
  font: 0.8rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  word-break: break-all;
}
.share-meta { margin: 4px 0 12px; font-size: 0.75rem; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.share-dialog .dialog-buttons { flex-wrap: wrap; }

/* ===== v8: 戦績・称号ボタン・通信対戦メニュー・部屋一覧・ナビゲーション ===== */
.menu-links { display: flex; gap: 10px; margin: 0 0 12px; }
.menu-links button { flex: 1; padding: 10px 8px; font-weight: 700; border-radius: var(--radius); }
.online-actions { display: grid; gap: 8px; margin-top: 14px; }
.online-actions .big { margin-top: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.online-actions .big small { font-size: 0.72rem; font-weight: 400; opacity: 0.85; }
.online-actions button:not(.primary) { border-color: var(--accent); color: var(--accent); }

.lobby { max-width: 560px; }
.lobby-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 8px 0 4px; }
.lobby-head h1 { margin: 0; font-size: 1.25rem; text-align: center; }
.lobby-meta { margin: 4px 0 10px; font-size: 0.82rem; color: var(--text-2); text-align: center; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.lobby-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.lobby-room {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 12px; display: grid; gap: 6px;
}
.lobby-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.rule-badge {
  font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-2); white-space: nowrap;
}
.rule-badge.std { border-color: var(--accent); color: var(--accent); }
.rule-badge.mini { border-color: var(--text-2); color: var(--text); }
.rule-badge.try { border-color: var(--try); color: var(--try); }
.lobby-host { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.lobby-name { font-weight: 700; font-size: 1rem; max-width: 12em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-rec, .lobby-rate { font-size: 0.85rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.lobby-rate { font-weight: 700; }
.lobby-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lobby-wait { font-size: 0.8rem; color: var(--text-2); font-variant-numeric: tabular-nums; }
.lobby-enter { min-width: 6.5em; }
.lobby-empty { text-align: center; color: var(--text-2); padding: 18px 0 6px; }
.lobby-empty p { margin: 0 0 10px; }

/* 持ち駒欄の通算成績・レート（通信対戦） */
.hand-stats {
  display: block; font-size: 0.68rem; line-height: 1.25; color: var(--text-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
#room-menu-btn { display: block; margin: 6px auto 0; font-size: 0.8rem; }
.result-extra:empty { display: none; }
.result-extra { margin: -6px 0 12px; }

.nav-sheet { width: min(360px, calc(100% - 32px)); }
.nav-list { display: grid; gap: 8px; }
.nav-list button { text-align: left; padding: 12px 14px; font-weight: 700; font-size: 1rem; }
.nav-list .nav-close { text-align: center; font-weight: 400; color: var(--text-2); }
.nav-note { margin: -6px 0 12px; font-size: 0.8rem; color: var(--accent); text-align: center; }
.leave-text { margin: 0 0 16px; font-size: 0.9rem; line-height: 1.55; color: var(--text); max-width: 32em; }
.rules-dialog { width: min(560px, calc(100% - 24px)); }
.rules-dialog-body { max-height: min(65vh, 560px); overflow-y: auto; margin-bottom: 12px; font-size: 0.9rem; }
.rules-dialog-body .rules-body { padding: 0; }
@media (max-width: 420px) {
  .nav-sheet[open] { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 18px 18px 0 0; }
}
.result-rating { margin: -8px 0 14px; display: grid; gap: 2px; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.result-rating span { overflow-wrap: anywhere; }

/* ---- 棋譜 URL の AI 比較（B33） ---- */
.eval-graph .line.s-b { stroke: var(--xai-b); stroke-width: 2; }
.eval-graph .line.s-w { stroke: var(--xai-w); stroke-width: 2; }
.eval-graph .dot.s-b { fill: var(--xai-b); }
.eval-graph .dot.s-w { fill: var(--xai-w); }
.xai { margin-top: 6px; }
.xai-players { margin: 0 0 6px; font-size: 0.8rem; color: var(--text-2); overflow-wrap: anywhere; }
.xai-slots { display: grid; gap: 4px; }
.xai-row { display: grid; grid-template-columns: 14px 6.2em minmax(0, 1fr) auto; align-items: center; gap: 6px; font-size: 0.82rem; }
.xai-row select { min-width: 0; width: 100%; font: inherit; padding: 3px 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.xai-sw { width: 14px; height: 0; border-top: 3px solid var(--xai-b); }
.xai-sw.s-w { border-top-color: var(--xai-w); }
.xai-lab { white-space: nowrap; font-weight: 600; }
.xai-custom { margin-top: 6px; font-size: 0.82rem; }
.xai-custom summary { cursor: pointer; color: var(--text-2); }
.xai-custom input[type='file'] { display: block; margin: 6px 0; max-width: 100%; font-size: 0.8rem; }
.xai-json { display: block; box-sizing: border-box; width: 100%; font: 0.78rem ui-monospace, SFMono-Regular, Menlo, monospace; padding: 4px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.xai-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.xai-msg { margin: 4px 0 0; font-size: 0.8rem; color: var(--accent); min-height: 1em; }
.xai-msg:empty { display: none; }
.cand-char { margin: 6px 0 0; padding: 4px 8px; border-radius: 8px; border-left: 4px solid var(--cand-char); background: color-mix(in srgb, var(--cand-char) 10%, transparent); font-size: 0.82rem; overflow-wrap: anywhere; }

/* 感情の吹き出し（I19e・18 §8.5）: 盤中央の狐の上に短いセリフ。4 秒ほどで薄くなる */
.emo-bubble {
  position: absolute; z-index: 6; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  padding: 4px 9px; border-radius: 12px; white-space: nowrap;
  background: var(--surface, #fff); color: var(--text); border: 2px solid var(--accent);
  font-size: 0.85rem; font-weight: 700; line-height: 1.3; box-shadow: var(--shadow);
  pointer-events: none; animation: emo-pop 4.5s ease forwards;
}
.emo-bubble::after {
  content: ''; position: absolute; left: 50%; top: 100%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--accent);
}
.emo-bubble.below { bottom: auto; top: calc(100% + 6px); }
.emo-bubble.below::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--accent); }
.emo-bubble.left { left: 0; transform: none; }
.emo-bubble.left::after { left: 14px; }
.emo-bubble.right { left: auto; right: 0; transform: none; }
.emo-bubble.right::after { left: auto; right: 8px; transform: none; }
.emo-bubble-free { top: 8px; bottom: auto; }
.emo-bubble-free::after { display: none; }
@keyframes emo-pop { 0% { opacity: 0; } 6% { opacity: 1; } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .emo-bubble { animation: none; } }

/* 解析 AI のスロット A・B（I20e） */
.xai-pick { flex: 1; min-height: 40px; text-align: left; padding: 4px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xai-x { min-width: 40px; min-height: 40px; font-size: 1.1rem; }
.xai-add-b { flex: 1; min-height: 40px; border-style: dashed; }
.eval-view { display: flex; gap: 4px; margin: 6px 0 2px; }
.eval-view button { flex: 1; min-height: 36px; padding: 4px 2px; font-size: 0.85rem; }
.eval-view button[aria-pressed='true'] { background: var(--accent); color: var(--gal-on-accent, #fff); border-color: var(--accent); }
.xai-sheet-box { max-width: 520px; }
.xai-sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; max-height: 40vh; overflow-y: auto; padding: 2px; }
.xai-sheet-opt, .xai-sheet-stage { min-height: 40px; text-align: left; padding: 4px 8px; font-size: 0.85rem; }
.xai-sheet-opt[aria-checked='true'], .xai-sheet-stage[aria-checked='true'] { background: var(--accent); color: var(--gal-on-accent, #fff); border-color: var(--accent); }
.xai-sheet-stages { display: flex; flex-wrap: wrap; gap: 6px; }
.xai-sheet-h3 { font-size: 0.9rem; margin: 10px 0 4px; }
.xai-head { margin: 4px 0 2px; font-size: 0.85rem; font-weight: 700; }
.xai-sw.s-main { border-top-color: var(--text); }

/* 評価値グラフのイベント（I21） */
.eval-graph .ev { font-size: 12px; pointer-events: auto; cursor: pointer; paint-order: stroke; stroke: var(--surface, var(--bg)); stroke-width: 3px; stroke-linejoin: round; }
.eval-graph .ev-blunder { fill: #dc2626; font-weight: 700; }
.eval-graph .ev-good { fill: #15803d; font-weight: 700; }
.eval-graph .ev-check { fill: var(--text); }
.eval-event-cur { font-size: 0.8rem; margin: 2px 0; min-height: 1.2em; }
.eval-events { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.ev-chip { min-height: 32px; padding: 2px 8px; border-radius: 999px; font-size: 0.78rem; }
.ev-chip[aria-pressed='false'] { opacity: 0.45; text-decoration: line-through; }
.ev-chip.ev-blunder { color: #dc2626; }
.ev-chip.ev-good { color: #15803d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .eval-graph .ev-blunder, :root:not([data-theme='light']) .ev-chip.ev-blunder { fill: #f87171; color: #f87171; } :root:not([data-theme='light']) .eval-graph .ev-good, :root:not([data-theme='light']) .ev-chip.ev-good { fill: #4ade80; color: #4ade80; } }
.eval-graph .diff { fill: var(--text-2); }
.eval-graph .ev-dubious { fill: #d97706; font-weight: 700; }
.ev-chip.ev-dubious { color: #b45309; }
.ev-diff-legend { font-size: 0.75rem; color: var(--text-2); align-self: center; }
.eval-graph .ev-hoard, .eval-graph .ev-avoid { font-size: 10px; font-weight: 700; fill: #7c3aed; }
.eval-graph .ev-avoid { fill: #be185d; }
.ev-chip.ev-hoard { color: #6d28d9; }
.ev-chip.ev-avoid { color: #be185d; }
/* 寝返り（I21 追加）: 駒の字＋⚔ の縦 2 段。得をした側の色（▲ 先手 = グラフの先手の色、△ 後手 = 後手の色） */
.eval-graph .ev-defect { font-size: 10px; font-weight: 700; }
.eval-graph .ev-defect .ev-sw { font-size: 12.5px; font-weight: 900; }
.eval-graph .ev-defect-b { fill: #b5562b; }
.eval-graph .ev-defect-w { fill: #3468aa; }
.ev-chip.ev-defect { color: #8a4b2a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .eval-graph .ev-defect-b { fill: #f08a54; } :root:not([data-theme='light']) .eval-graph .ev-defect-w { fill: #6ea0eb; } :root:not([data-theme='light']) .ev-chip.ev-defect { color: #f0a074; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .eval-graph .ev-hoard { fill: #c4b5fd; } :root:not([data-theme='light']) .ev-chip.ev-hoard { color: #c4b5fd; } :root:not([data-theme='light']) .eval-graph .ev-avoid { fill: #f9a8d4; } :root:not([data-theme='light']) .ev-chip.ev-avoid { color: #f9a8d4; } :root:not([data-theme='light']) .ev-chip.ev-dubious { color: #fbbf24; } }
.eval-event-nav { display: flex; gap: 6px; margin: 4px 0 0; }
.eval-event-nav button { flex: 1; min-height: 36px; font-size: 0.82rem; }

/* I22: スマホ幅で 盤 → 移動ボタン → グラフ がなるべく 1 画面に収まるよう、振り返りまわりの余白を詰める */
@media (max-width: 480px) {
  .review-bar { margin-top: 4px; gap: 4px; }
  .review-pos { font-size: 0.82rem; }
  .review-nav button { min-height: 42px; }
  #eval-panel { margin-top: 6px; padding: 6px 8px; }
  #eval-panel .eval-head h2 { font-size: 0.8rem; }
  /* 読み上げ欄は 1 行に（長い A／B の名前は … で省略。グラフを押し下げないように） */
  #eval-panel .eval-cur { margin: 2px 0 0; font-size: 0.8rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #eval-panel .eval-graph { margin-top: 2px; }
}

/* I23: この対局の数字（KPI）。▲先手・△後手の 2 列の小さな表 */
.kpi-box { margin: 0 0 10px; }
.kpi-box > summary { cursor: pointer; font-weight: 700; font-size: 0.88rem; min-height: 32px; line-height: 32px; }
.kpi-table { width: 100%; max-width: 440px; border-collapse: collapse; font-size: 0.82rem; font-variant-numeric: tabular-nums; margin-top: 4px; }
.kpi-table th, .kpi-table td { padding: 3px 6px; border-bottom: 1px solid var(--border); text-align: right; }
.kpi-table th[scope='row'] { text-align: left; font-weight: 600; color: var(--text-2); }
.kpi-table thead th { font-size: 0.78rem; color: var(--text-2); }
.kpi-table .kpi-hi { font-weight: 800; color: #6d28d9; }
.kpi-table .kpi-hi-avoid { font-weight: 800; color: #be185d; }
.kpi-table .kpi-wait { color: var(--text-2); font-weight: 400; }
.kpi-table .kpi-note { display: block; font-size: 0.7rem; font-weight: 400; }
/* I29: 形勢の面積 */
.kpi-area-h { margin: 10px 0 0; font-weight: 700; font-size: 0.86rem; }
.kpi-note-p { margin: 2px 0 0; font-size: 0.74rem; color: var(--text-2); }
.kpi-table.kpi-area th[scope='row'] { font-weight: 400; color: var(--text); }
.kpi-table .kpi-nowrap { white-space: nowrap; }
/* I27a: 厨・嫌のセルは句ごとに改行しない行、説明は小見出しに 1 回 */
.kpi-table .kpi-part { display: block; white-space: nowrap; }
.kpi-table .kpi-part + .kpi-part { font-size: 0.72rem; font-weight: 400; color: var(--text-2); }
.kpi-table tr.kpi-sub th { text-align: left; font-size: 0.74rem; font-weight: 600; color: var(--text); background: var(--bg-2); padding-top: 6px; }
.kpi-table .kpi-item { text-align: left; font-weight: 400; }
.kpi-table .kpi-bad { font-weight: 800; color: #c81e1e; }
.kpi-table .kpi-good { font-weight: 800; color: #15803d; }
.kpi-game { margin: 4px 0 0; font-size: 0.8rem; color: var(--text-2); line-height: 1.45; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .kpi-table .kpi-hi { color: #c4b5fd; }
  :root:not([data-theme='light']) .kpi-table .kpi-hi-avoid { color: #f9a8d4; }
  :root:not([data-theme='light']) .kpi-table .kpi-bad { color: #f87171; }
  :root:not([data-theme='light']) .kpi-table .kpi-good { color: #4ade80; }
}

/* I25: 罠モードのアイコン（絵文字。凡例は既定の色） */
.eval-graph .ev-trap { font-size: 11px; }

/* 確認用の全解放（?unlockall=1）の印（ui/unlock-all-banner.js）。ページのいちばん上 */
.unlock-all-banner {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px;
  margin: 0; padding: 6px 16px; border-bottom: 2px dashed var(--fox-edge);
  background: var(--surface); color: var(--text); font-size: 0.85rem; font-weight: 700; text-align: center;
}
.unlock-all-off { color: var(--accent); font-weight: 700; }
.unlock-all-note { margin: 0; padding: 6px 10px; border: 2px dashed var(--fox-edge); border-radius: 8px; font-size: 0.85rem; font-weight: 700; }
