/* ピラミッド将棋 — スタイル。砂漠の色（砂・黄土・テラコッタ・夕空）。light / dark 両対応、390px で横にはみ出さない */
:root {
  --bg: #f6ead2; /* 昼の砂 */
  --bg-2: #f1d9b5;
  --sky: #f7c58f; /* 夕空の上 */
  --surface: #fff8ec;
  --border: #dcc3a0;
  --text: #3a2614;
  --text-2: #7a5a3c;
  --accent: #b5532c; /* テラコッタ */
  --accent-2: #c98a2b; /* 黄土 */
  --accent-soft: rgba(181, 83, 44, 0.12);
  --on-accent: #fff;
  --danger: #b3261e;
  --warn: #8a5a00;
  --board-line: #9b7442;
  --sand-1: #f3dcae; /* 盤の地（層ごとに少しずつ濃く） */
  --sand-2: #ecd09a;
  --sand-3: #e4c386;
  --sand-4: #dbb574;
  --sand-5: #d2a862;
  --zone-b: rgba(70, 110, 170, 0.16); /* 先手の敵陣（後手の陣）= 夕空の青 */
  --zone-w: rgba(196, 92, 50, 0.16); /* 後手の敵陣（先手の陣）= テラコッタ */
  --piece: #fbe9c4;
  --piece-edge: #b28a4f;
  --piece-text: #2a1a0c;
  --promoted: #c8261d;
  --sel: rgba(201, 138, 43, 0.5);
  --mv: rgba(46, 104, 170, 0.7);
  --cp: rgba(200, 38, 29, 0.85);
  --jump: rgba(0, 135, 95, 0.85);
  --last: rgba(242, 178, 30, 0.45);
  --arrow: #1e9a4e;
  --check: #c8261d;
  --try: #c27b00;
  --atk-from: rgba(200, 30, 60, 0.35);
  --atk-line: rgba(200, 30, 60, 0.9);
  --atk-fill: rgba(240, 70, 80, 0.34);
  --p0: #b5532c; /* ▲先手 */
  --p1: #2f5f9e; /* △後手 */
  --shadow: 0 8px 22px rgba(90, 55, 20, 0.14);
  --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: #1d1420; /* 夕暮れの後の空 */
    --bg-2: #2a1a1c;
    --sky: #4a2a2a;
    --surface: #2b2024;
    --border: #4d3a36;
    --text: #f4e6d2;
    --text-2: #c9ad8e;
    --accent: #e0814f;
    --accent-2: #e2a74a;
    --accent-soft: rgba(224, 129, 79, 0.18);
    --on-accent: #1c120c;
    --danger: #ff7a68;
    --warn: #f0b93a;
    --board-line: #7a5a32;
    --sand-1: #b8935a;
    --sand-2: #ad8850;
    --sand-3: #a17d47;
    --sand-4: #95723f;
    --sand-5: #8a6838;
    --zone-b: rgba(120, 160, 230, 0.2);
    --zone-w: rgba(240, 120, 80, 0.2);
    --piece: #f6e1b6;
    --piece-edge: #8d6b35;
    --sel: rgba(226, 167, 74, 0.55);
    --mv: rgba(110, 170, 255, 0.85);
    --cp: rgba(255, 90, 80, 0.9);
    --jump: rgba(70, 220, 160, 0.9);
    --last: rgba(255, 200, 60, 0.38);
    --arrow: #3ddc7a;
    --try: #ffcc4d;
    --p0: #f08a54;
    --p1: #79a6ec;
    --shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
html {
  overflow-x: hidden;
}
body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, var(--sky) 0, var(--bg) 220px, var(--bg-2) 100%);
  background-attachment: fixed;
  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;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
  touch-action: manipulation;
  transition:
    background 0.15s,
    border-color 0.15s;
}
button:hover:not(:disabled) {
  border-color: var(--accent);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
button.danger {
  color: var(--danger);
}
button.big {
  width: 100%;
  padding: 14px;
  font-size: 1.1rem;
  margin-top: 18px;
}
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  min-height: 40px;
  min-width: 0;
  max-width: 100%;
}

/* ===== ホーム ===== */
.screen {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}
.home,
.gallery {
  max-width: 640px;
}
.home-head {
  text-align: center;
  padding: 8px 0 4px;
}
.topbar {
  display: flex;
  justify-content: flex-start;
  margin-bottom: 6px;
}
.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;
}
.home-head h1 {
  margin: 0;
  font-size: clamp(1.7rem, 7vw, 2.4rem);
  letter-spacing: 0.06em;
  color: var(--accent);
}
.subtitle {
  margin: 0;
  font-weight: 700;
  color: var(--accent-2);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
}
.lede {
  color: var(--text-2);
  margin: 6px 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: 14px 0 6px;
  font-weight: 600;
}
.panel h2:first-child {
  margin-top: 0;
}
.hint {
  font-size: 0.8rem;
  color: var(--text-2);
  margin: 8px 0 0;
}
.hint.warn {
  color: var(--warn);
}
.seg {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 6px;
}
.seg button {
  padding: 8px 6px;
  font-size: 0.92rem;
  white-space: normal;
  line-height: 1.3;
  min-width: 0;
  transition: none;
}
.seg button[aria-checked='true'] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}
.style-pick {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 560px) {
  .style-pick {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
/* 強さ: 1手読み・2手読み・3手読み・深読みの 4 つを 1 行に（390px でも折り返さない） */
.depth-pick {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.home-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
/* 2 列に入りきらない最後の 1 つ（駒の動き）は横いっぱい */
.home-buttons > :last-child:nth-child(odd) {
  grid-column: 1 / -1;
}
.rules summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 32px;
}
.rules-body {
  font-size: 0.88rem;
  color: var(--text-2);
  padding-left: 1.2em;
  margin: 8px 0 0;
}
.rules-body li {
  margin: 2px 0;
}

/* ===== ギャラリー ===== */
.sub-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sub-head h1 {
  margin: 0;
  font-size: 1.4rem;
  color: var(--accent);
}
.back-btn {
  flex: 0 0 auto;
}
.panel-title {
  font-size: 1rem !important;
  color: var(--text) !important;
}
.gallery-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.gallery-open {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
}
.gallery-item-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}
.gallery-item-meta {
  font-size: 0.8rem;
  color: var(--text-2);
  font-weight: 400;
  overflow-wrap: anywhere;
}
.field {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-2);
}

/* ===== 対局画面 ===== */
.game-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: wrap;
}
.turn {
  font-weight: 700;
}
.mark-b {
  color: var(--p0);
  font-weight: 700;
}
.mark-w {
  color: var(--p1);
  font-weight: 700;
}
.check {
  background: var(--check);
  color: #fff;
  font-weight: 700;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
}
.thinking {
  color: var(--accent);
  font-size: 0.85rem;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink {
  50% {
    opacity: 0.35;
  }
}
@media (prefers-reduced-motion: reduce) {
  .thinking {
    animation: none;
  }
}
.view-pick {
  grid-template-columns: repeat(2, minmax(0, 96px));
}

.game-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .game-body {
    grid-template-columns: minmax(0, 1fr);
  }
}
.play-area {
  min-width: 0;
}

/* 持ち駒 */
.hand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 52px;
  padding: 4px 8px;
  margin: 6px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.hand-label {
  font-size: 0.8rem;
  color: var(--text-2);
  margin-right: 4px;
  white-space: nowrap;
}
.hand-empty {
  font-size: 0.8rem;
  color: var(--text-2);
}
.hand-piece {
  position: relative;
  padding: 2px 10px 2px 8px;
  min-width: 44px;
  font-family: var(--font-piece);
  font-size: 1.15rem;
  line-height: 1.5;
}
.hand-piece.chess {
  font-family: var(--font);
  font-weight: 800;
}
.hand-piece .cnt {
  font-family: var(--font);
  font-size: 0.75rem;
  margin-left: 2px;
  color: var(--text-2);
}
.hand-piece.sel {
  border-color: var(--accent);
  background: var(--sel);
}
.hand-piece:disabled {
  opacity: 1;
  cursor: default;
}

/* ===== 平面 ===== */
.plane-host {
  width: 100%;
}
.plane {
  position: relative;
}
.plane-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px 10px 0 0;
}
.plane-tab {
  padding: 6px 2px;
  font-size: 0.9rem;
  min-height: 44px;
}
.plane-tab {
  position: relative;
}
/* 見えていない層の動きに気づけるよう、タブに印（● 直前の手・○ 行き先・■ 利き・! 王手。色だけでなく形でも区別） */
.plane-tab .tab-marks {
  position: absolute;
  top: 2px;
  right: 4px;
  display: flex;
  gap: 1px;
  font-size: 0.62rem;
  line-height: 1;
  font-weight: 800;
}
.tab-mark-last {
  color: var(--accent-2);
}
.tab-mark-target {
  color: var(--mv);
}
.tab-mark-attack {
  color: var(--atk-line);
}
.tab-mark-check {
  color: var(--check);
}
.plane-tab.active .tab-marks span {
  color: var(--on-accent);
}
.plane-tab.flash {
  animation: tab-flash 0.5s ease-in-out 3;
}
@keyframes tab-flash {
  50% {
    background: var(--last);
    border-color: var(--accent-2);
  }
}
.plane-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.plane-scroll {
  position: relative; /* section の offsetTop の基準 */
  height: clamp(320px, 62vh, 760px);
  overflow-y: auto;
  overflow-x: hidden;
  container-type: inline-size;
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--sky) 45%, transparent),
    transparent 40%
  );
  padding: 6px 4px 10px;
}
.plane-sec {
  padding: 8px 0 14px;
  --cell: min(46px, calc((100cqw - 34px) / 9.2));
}
.plane-sec + .plane-sec {
  border-top: 1px dashed var(--border);
}
.plane-sec-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: calc(var(--cell) * 0.8);
}
.plane-layer {
  display: grid;
  justify-items: center;
  min-width: 0;
}
.plane-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 2px;
  text-align: center;
}
.plane-grid {
  display: grid;
}
.plane-row-cells {
  display: flex;
  align-items: center;
}
.plane-ylabel {
  width: 24px;
  flex: 0 0 24px;
  font-size: 0.62rem;
  color: var(--text-2);
  text-align: right;
  padding-right: 3px;
}
.plane-xlabel {
  width: var(--cell);
  flex: 0 0 var(--cell);
  font-size: 0.62rem;
  color: var(--text-2);
  text-align: center;
}
.plane-layer.z1 .cell {
  background-color: var(--sand-1);
}
.plane-layer.z2 .cell {
  background-color: var(--sand-2);
}
.plane-layer.z3 .cell {
  background-color: var(--sand-3);
}
.plane-layer.z4 .cell {
  background-color: var(--sand-4);
}
.plane-layer.z5 .cell {
  background-color: var(--sand-5);
}
.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  min-height: 0;
  flex: 0 0 var(--cell);
  border: 1px solid color-mix(in srgb, var(--board-line) 60%, transparent);
  border-radius: 0;
  padding: 0;
  container-type: size;
  cursor: pointer;
}
.cell:hover:not(:disabled) {
  border-color: var(--board-line);
}
.cell.zone-b {
  background-image: linear-gradient(var(--zone-b), var(--zone-b));
}
.cell.zone-w {
  background-image: linear-gradient(var(--zone-w), var(--zone-w));
}
.cell.zone-both {
  background-image: linear-gradient(135deg, var(--zone-w) 50%, var(--zone-b) 50%);
}
.cell.last::before,
.cell.sel::before,
.cell.inspect::before,
.cell.check-king::before {
  content: '';
  position: absolute;
  inset: 0;
}
.cell.last::before {
  background: var(--last);
}
.cell.inspect::before {
  background: var(--atk-from);
}
.cell.sel::before {
  background: var(--sel);
}
.cell.check-king::before {
  background: color-mix(in srgb, var(--check) 45%, transparent);
}
.cell.attack::after {
  content: '';
  position: absolute;
  inset: 3px;
  z-index: 2;
  pointer-events: none;
  border-radius: 3px;
  background: var(--atk-fill); /* 利きは塗りだけ（赤い枠は「取れるマス」専用） */
}
.cell.target::after {
  content: '';
  position: absolute;
  left: 34%;
  top: 34%;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--mv);
  pointer-events: none;
  z-index: 2;
}
.cell.target.capture::after {
  left: 6%;
  top: 6%;
  width: 88%;
  height: 88%;
  background: transparent;
  border: 3px solid var(--cp);
}
.cell.target.jump::after {
  left: 31%;
  top: 31%;
  width: 38%;
  height: 38%;
  border-radius: 2px;
  background: var(--jump);
  transform: rotate(45deg);
}
.cell.target.capture.jump::after {
  left: 17%;
  top: 17%;
  width: 66%;
  height: 66%;
  background: transparent;
  border: 3px solid var(--cp);
  box-shadow: 0 0 0 2px var(--jump);
}
.cell.attack.jump::after {
  inset: auto;
  left: 17%;
  top: 17%;
  width: 66%;
  height: 66%;
  transform: rotate(45deg);
  border: 2px dashed var(--atk-line);
}
.cell.tone-b.inspect::before {
  background: rgba(230, 120, 30, 0.4);
}
.cell.tone-b.attack::after {
  border-color: rgba(214, 100, 0, 0.95);
  background: rgba(255, 150, 40, 0.34);
}
.cell.tone-w.inspect::before {
  background: rgba(40, 110, 230, 0.35);
}
.cell.tone-w.attack::after {
  border-color: rgba(30, 95, 220, 0.95);
  background: rgba(40, 140, 255, 0.3);
}
.cell.arrow-from,
.cell.arrow-to {
  box-shadow: inset 0 0 0 3px var(--arrow);
}
.cell.arrow-from {
  box-shadow: inset 0 0 0 2px var(--arrow);
}
.cell.try-cell {
  box-shadow: inset 0 0 0 3px var(--try);
}
.cell .try-star {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 0;
  pointer-events: none;
  font-size: 70cqh;
  line-height: 1;
  color: color-mix(in srgb, var(--try) 55%, transparent);
}
.piece {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 6%;
  bottom: 6%;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
  clip-path: polygon(50% 0%, 84% 14%, 100% 100%, 0% 100%, 16% 14%);
  /* 色は plane-view.js が立体と同じ値（pyramid-model.js の pieceStyle）を --pc-fill / --pc-edge / --pc-text に入れる。
     チェスも将棋も、light / dark も同じ色。成駒の赤い字・脱落した人の灰色もそこで決まる */
  background: linear-gradient(
    180deg,
    var(--pc-fill, var(--piece)),
    color-mix(in srgb, var(--pc-fill, var(--piece)) 80%, var(--pc-edge, var(--piece-edge)))
  );
  color: var(--pc-text, var(--piece-text));
  font-family: var(--font-piece);
  font-weight: 700;
  line-height: 1;
  font-size: 52cqh;
  padding-top: 12%;
}
/* チェスの駒: 立体（ui/pyramid-piece.js の discGeo）と同じ「丸 + 前（持ち主の前 = 上）の尖り」のスライム形に英字。
   色は将棋の駒と全く同じ（持ち主の淡い地に濃い字）。形（スライム / 五角形）と字体だけで区別する。
   形は丸 R=0.29・尖り 0.4 を幅 0.58 × 高さ 0.69 の箱に入れた多角形（--slime-shape。駒の説明の札も同じ形） */
:root {
  --slime-shape: polygon(50% 0%, 26% 21.1%, 16.3% 26.9%, 8.5% 34.6%, 3% 43.5%, 0.3% 53.3%, 0.4% 63.4%, 3.4% 73.2%, 9% 82.1%, 17% 89.6%, 26.9% 95.2%, 38.1% 98.8%, 50% 100%, 61.9% 98.8%, 73.1% 95.2%, 83% 89.6%, 91% 82.1%, 96.6% 73.2%, 99.6% 63.4%, 99.7% 53.3%, 97% 43.5%, 91.5% 34.6%, 83.7% 26.9%, 74% 21.1%);
}
.piece.chess {
  clip-path: var(--slime-shape);
  left: 15%;
  right: 15%;
  top: 9%;
  bottom: 9%;
  /* 字は丸の中心（箱の上から 58%）に置く。padding の % は幅基準なので、ほぼ正方形のマスで中心が約 8% 下がる値 */
  padding-top: 13%;
  font-family: var(--font);
  font-weight: 800;
  font-size: 44cqh;
}
.piece.down {
  rotate: 180deg;
}
.plane-legend {
  font-size: 0.75rem;
  color: var(--text-2);
  margin: 4px 0 0;
}
.plane-legend summary {
  cursor: pointer;
  text-align: center;
  min-height: 24px;
}
.plane-legend p {
  margin: 4px 0 0;
  text-align: center;
}

/* ===== ピラミッド（B04 の ui/pyramid-view.js が中身を作る） ===== */
.pyramid-host {
  position: relative;
  width: 100%;
  height: clamp(320px, 66vh, 680px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: radial-gradient(ellipse at 50% 20%, #f8c98e, #d98c5a 60%, #6a3b3b);
  touch-action: none;
}
@media (prefers-color-scheme: dark) {
  .pyramid-host {
    background: radial-gradient(ellipse at 50% 20%, #5b3a4a, #2a1b2a 60%, #120c16);
  }
}
.pyramid-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.pyramid-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff4e0;
  padding: 16px;
  text-align: center;
  font-size: 0.9rem;
}

/* 観戦のつまみ */
.watch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.watch-label {
  font-size: 0.8rem;
  color: var(--text-2);
}
.watch-speed {
  grid-template-columns: repeat(3, minmax(0, 64px));
  gap: 4px;
}

.hint-line {
  min-height: 1.4em;
  font-size: 0.82rem;
  color: var(--text-2);
  margin: 6px 0;
  text-align: center;
}
.controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* サイド */
.side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.side-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.side-panel h2 {
  font-size: 0.85rem;
  color: var(--text-2);
  margin: 0 0 6px;
}
.players {
  font-size: 0.88rem;
  display: grid;
  gap: 2px;
  overflow-wrap: anywhere;
}
.rule-note {
  font-size: 0.75rem;
  color: var(--text-2);
}
.kifu-list {
  position: relative;
  margin: 0;
  padding-left: 2.6em;
  max-height: 320px;
  overflow-y: auto;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}
.kifu-list li.latest {
  font-weight: 700;
  color: var(--accent);
}
.kifu-empty,
.kifu-ending {
  list-style: none;
  margin-left: -2.6em;
  color: var(--text-2);
}
.kifu-ending {
  margin-top: 4px;
  font-weight: 700;
}
.kifu-list.reviewing li {
  padding: 0;
}
.kifu-btn {
  display: block;
  width: 100%;
  min-height: 32px;
  text-align: left;
  padding: 1px 6px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-weight: 500;
  font-size: inherit;
}
.kifu-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}
.kifu-list li.current .kifu-btn {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

/* ダイアログ */
.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  max-width: min(92vw, 380px);
}
.dialog::backdrop {
  background: rgba(30, 15, 5, 0.45);
}
.dialog-title {
  font-weight: 700;
  margin: 0 0 12px;
  text-align: center;
}
.dialog-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.pawn-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
/* 指す手の問い（成り・昇格先・指す前の確かめ）: 後ろの盤の仮の局面が見えるよう、暗くしすぎない */
.move-dialog::backdrop {
  background: rgba(30, 15, 5, 0.15);
}
.move-sub {
  margin-top: 8px;
}
.move-sub button {
  font-size: 0.9rem;
}
.result-dialog {
  text-align: center;
  width: min(92vw, 380px);
  padding: 22px 24px;
}
.result-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  color: var(--accent);
}
.result-reason {
  color: var(--text-2);
  margin: 4px 0 16px;
}

/* 駒の動き */
.guide-dialog {
  max-width: min(94vw, 680px);
  width: 100%;
  padding: 0;
}
.guide-form {
  display: flex;
  flex-direction: column;
  max-height: 86vh;
}
.guide-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.guide-head .dialog-title {
  margin: 0;
}
.guide-body {
  overflow-y: auto;
  padding: 8px 16px 16px;
  font-size: 0.88rem;
}
.guide-lede {
  color: var(--text-2);
}
.guide-common,
.guide-notes {
  padding-left: 1.2em;
  color: var(--text-2);
}
.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  table-layout: fixed;
}
.guide-table caption {
  text-align: left;
  font-weight: 700;
  color: var(--accent);
  padding: 4px 0;
}
.guide-table th,
.guide-table td {
  border-top: 1px solid var(--border);
  padding: 6px 4px;
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}
.guide-table thead th {
  font-size: 0.75rem;
  color: var(--text-2);
}
.guide-table thead th:first-child {
  width: 24%;
}
.guide-table thead th.guide-count {
  width: 6em;
}
.guide-piece {
  font-weight: 600;
}
.guide-glyph {
  display: inline-grid;
  place-items: center;
  width: 1.8em;
  height: 1.8em;
  margin-right: 6px;
  border-radius: 4px;
  background: var(--piece);
  color: var(--piece-text);
  font-family: var(--font-piece);
  font-weight: 700;
  vertical-align: middle;
}
.guide-glyph.chess {
  border-radius: 0;
  clip-path: var(--slime-shape);
  width: 1.6em;
  height: 1.9em;
  padding-top: 0.3em;
  box-sizing: border-box;
  font-family: var(--font);
}
.guide-name {
  font-size: 0.82rem;
}
.guide-move,
.guide-vec {
  margin: 0;
}
.guide-vec {
  font-size: 0.78rem;
  color: var(--text-2);
}

/* ===== 振り返り ===== */
.review-nav {
  margin: 6px 0 0;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.rv-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 52px)) minmax(0, 1fr) repeat(2, minmax(0, 52px));
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.rv-steps button {
  padding: 6px 0;
  font-size: 1.05rem;
  min-width: 0;
}
.rv-ply {
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rv-auto-row {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
#rv-auto {
  flex: 0 0 auto;
  min-width: 118px;
}
#rv-auto[aria-pressed='true'] {
  border-color: var(--accent);
  color: var(--accent);
}
.rv-speed {
  grid-template-columns: repeat(3, minmax(0, 60px));
  gap: 4px;
}
.rv-move {
  margin: 6px 0 0;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
  min-height: 1.4em;
  overflow-wrap: anywhere;
}
.review-panel {
  display: grid;
  gap: 8px;
}
.review-panel h2,
.review-panel h3 {
  margin: 0;
}
.rv-eval {
  display: grid;
  gap: 4px;
}
.rv-eval-text {
  font-weight: 800;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.rv-eval-text.side-b {
  color: var(--p0);
}
.rv-eval-text.side-w {
  color: var(--p1);
}
.rv-eval-progress {
  margin: 0;
  font-size: 0.78rem;
  color: var(--accent);
}
.eval-bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--p1);
  border: 1px solid var(--border);
}
.eval-bar-b {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--p0);
  transition: width 0.2s;
}
.eval-bar::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--surface);
}
.eval-bar-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
}
.eval-graph {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  background: var(--bg);
  border-radius: 8px;
}
.eval-graph text {
  font-size: 11px;
  fill: var(--text-2);
}
.eval-graph .eg-frame {
  fill: none;
  stroke: var(--border);
}
.eval-graph .eg-grid {
  stroke: var(--border);
  stroke-dasharray: 2 3;
}
.eval-graph .eg-zero {
  stroke: var(--text-2);
  stroke-width: 0.8;
}
.eval-graph .eg-area-b {
  fill: color-mix(in srgb, var(--p0) 30%, transparent);
}
.eval-graph .eg-area-w {
  fill: color-mix(in srgb, var(--p1) 30%, transparent);
}
.eval-graph .eg-line {
  fill: none;
  stroke: var(--text);
  stroke-width: 1.4;
  stroke-linejoin: round;
}
.eval-graph .eg-line4 {
  fill: none;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
.eval-graph .eg-line4.eg-p-A {
  stroke: var(--pA);
}
.eval-graph .eg-line4.eg-p-B {
  stroke: var(--pB);
}
.eval-graph .eg-line4.eg-p-C {
  stroke: var(--pC);
}
.eval-graph .eg-line4.eg-p-D {
  stroke: var(--pD);
}
.eval-graph .eg-dot4 {
  stroke: var(--surface);
  stroke-width: 1;
}
.eval-graph .eg-dot4.eg-p-A {
  fill: var(--pA);
}
.eval-graph .eg-dot4.eg-p-B {
  fill: var(--pB);
}
.eval-graph .eg-dot4.eg-p-C {
  fill: var(--pC);
}
.eval-graph .eg-dot4.eg-p-D {
  fill: var(--pD);
}
.rv-eval4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  font-variant-numeric: tabular-nums;
}
.rv-eval4-cell {
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rv-eval4-cell.out {
  font-weight: 400;
  color: var(--text-2);
}
.eval-graph .eg-cursor {
  stroke: var(--accent);
  stroke-width: 1.6;
}
.eval-graph .eg-dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 1;
}
.rv-hint {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: grid;
  gap: 6px;
}
.rv-hint-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rv-hint-head h3 {
  font-size: 0.85rem;
  color: var(--text-2);
}
.rv-hint-head button {
  padding: 4px 12px;
  font-size: 0.85rem;
}
.rv-ai-label {
  font-size: 0.8rem;
  color: var(--text-2);
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}
.rv-ai-label select {
  flex: 1 1 auto;
}
.rv-hint-body p {
  margin: 0 0 4px;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.rv-hint-note {
  color: var(--text-2);
  font-size: 0.8rem !important;
}
.rv-hint-note.thinking {
  color: var(--accent);
}
.rv-sec-head {
  font-size: 0.78rem !important;
  font-weight: 700;
  color: var(--text-2);
}
.rv-best-move {
  color: var(--mv);
}
.rv-cmp {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.rv-cmp.best {
  background: color-mix(in srgb, var(--arrow) 22%, transparent);
  color: var(--arrow);
}
.rv-cmp.different {
  background: var(--border);
  color: var(--text-2);
}

/* ===== 390px 前後（スマホ）: 盤・持ち駒・案内の文・ボタンが最初の画面に入るように ===== */
.hand.compact {
  min-height: 0;
  padding: 2px 8px;
  margin: 4px 0;
}
.hand.compact .hand-piece {
  min-width: 32px;
  min-height: 30px;
  padding: 0 6px;
  font-size: 0.95rem;
}
.hand.empty {
  min-height: 0;
  padding-top: 3px;
  padding-bottom: 3px;
}
@media (max-width: 560px) {
  /* 見出し（約 50px）・持ち駒 2 つ・タブ・案内の文・ボタンの分を引いた高さ。端まで来たらページがスクロールする */
  .plane-scroll {
    height: max(260px, calc(100dvh - 310px));
  }
  .game-head {
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 4px;
  }
  .view-pick {
    flex: none;
    grid-template-columns: repeat(2, auto);
    gap: 4px;
  }
  .view-pick button {
    min-height: 36px;
    padding: 4px 8px;
    font-size: 0.8rem;
    white-space: nowrap;
  }
  .screen.game {
    padding-top: 8px;
  }
  .pyramid-host {
    height: max(300px, calc(100dvh - 290px));
  }
  .plane-ylabel {
    width: 14px;
    flex: 0 0 14px;
    font-size: 0.55rem;
    padding-right: 1px;
  }
  .plane-sec {
    --cell: min(46px, calc((100cqw - 18px) / 9.1));
  }
  .hint-line {
    margin: 4px 0;
  }
  .controls {
    margin-top: 2px;
  }
  /* 成り・昇格のダイアログは下寄せ（盤の上半分 = 行き先のあたりを隠さない） */
  .promo-dialog {
    margin-top: auto;
    margin-bottom: 16px;
  }
}

/* 振り返りの「？」 */
.rv-help {
  font-size: 0.78rem;
  color: var(--text-2);
  margin: 4px 0 8px;
}
.rv-help summary {
  cursor: pointer;
  min-height: 28px;
}
.rv-help p {
  margin: 4px 0;
}
.kifu-list li.kifu-start {
  list-style: none;
  margin-left: -2.6em;
}

/* 駒の動きの図（上の層・同じ層・下の層） */
.guide-legend {
  font-size: 0.8rem;
  color: var(--text-2);
  margin: 0 0 8px;
}
.guide-diagram {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0;
}
.guide-layer {
  display: grid;
  justify-items: center;
  gap: 2px;
}
.guide-layer-name {
  font-size: 0.68rem;
  color: var(--text-2);
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(var(--n), 16px);
  grid-auto-rows: 16px;
  gap: 1px;
  background: var(--board-line);
  border: 1px solid var(--board-line);
}
.guide-cell {
  display: grid;
  place-items: center;
  background: var(--sand-1);
  font-size: 0.62rem;
  line-height: 1;
  color: var(--text);
}
.guide-cell.self {
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-piece);
  font-weight: 700;
}
.guide-cell.step,
.guide-cell.ray {
  color: var(--mv);
}
.guide-cell.cap {
  color: var(--cp);
  font-weight: 800;
}
.guide-more {
  font-size: 0.75rem;
  color: var(--text-2);
}
.guide-more summary {
  cursor: pointer;
}
.guide-table td.guide-count,
.guide-table th.guide-count {
  font-size: 0.8rem;
  text-align: center;
}
@media (max-width: 560px) {
  .guide-grid {
    grid-template-columns: repeat(var(--n), 12px);
    grid-auto-rows: 12px;
  }
  .guide-cell {
    font-size: 0.5rem;
  }
  .guide-diagram {
    gap: 5px;
  }
}
@media (max-width: 560px) {
  /* 駒の列は字と名前を縦に並べて細くし、図の入る「動き」の列を広くする */
  .guide-table thead th:first-child {
    width: 3.6em;
  }
  .guide-table thead th.guide-count {
    width: 4.2em;
  }
  .guide-piece > span {
    display: block;
  }
}

/* ===== 4 人モード ===== */
:root {
  --pA: var(--p0); /* A = 先手と同じテラコッタ */
  --pB: #2f7d4f; /* B = オアシスの緑 */
  --pC: var(--p1); /* C = 後手と同じ夕空の青 */
  --pD: #9c2f6f; /* D = 砂漠の花の紫紅 */
}
@media (prefers-color-scheme: dark) {
  :root {
    --pB: #6fcf97;
    --pD: #f08ac4;
  }
}
.mark-A {
  color: var(--pA);
  font-weight: 700;
}
.mark-B {
  color: var(--pB);
  font-weight: 700;
}
.mark-C {
  color: var(--pC);
  font-weight: 700;
}
.mark-D {
  color: var(--pD);
  font-weight: 700;
}
/* 駒の向き（持ち主の前が上）: 4 人では横向きもある */
.piece.rot-90 {
  rotate: 90deg;
}
.piece.rot-270 {
  rotate: 270deg;
}
/* 脱落した人の駒（利かない・誰でも取れる）は灰色（色は pieceStyle）。詰まされた玉（裏王）は字の無い駒（色・形・向きは持ち主のまま。立体と同じ） */
.piece.dead {
  opacity: 0.75;
}
.cell.tone-A.inspect::before,
.cell.tone-C.inspect::before,
.cell.tone-B.inspect::before,
.cell.tone-D.inspect::before {
  background: color-mix(in srgb, var(--tone) 38%, transparent);
}
.cell.tone-A.attack::after,
.cell.tone-B.attack::after,
.cell.tone-C.attack::after,
.cell.tone-D.attack::after {
  border-color: var(--tone);
  background: color-mix(in srgb, var(--tone) 30%, transparent);
}
.cell.tone-A {
  --tone: #e07a1e;
}
.cell.tone-B {
  --tone: #2fa86a;
}
.cell.tone-C {
  --tone: #2e7cf0;
}
.cell.tone-D {
  --tone: #c0398a;
}

/* 4 人の持ち駒: 上に 3 人を小さく横並び。高さは 1 行（30px）に固定し、入りきらない分は「＋n」（触ると重ねて開く）。
   行の高さを grid の行で固定しているので、開いても盤は動かない */
.hands-others {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: 30px;
  gap: 4px;
  margin: 4px 0;
  position: relative;
}
.hands-others .hand {
  margin: 0;
  min-width: 0;
  gap: 3px;
  height: 30px;
  min-height: 0;
  padding: 0 6px;
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: pointer;
}
.hands-others .hand.open {
  height: auto;
  min-height: 30px;
  flex-wrap: wrap;
  overflow: visible;
  white-space: normal;
  align-self: start;
  padding: 2px 6px;
  position: relative;
  z-index: 5;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.25);
}
.hands-others .hand-piece {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 24px;
  height: 24px;
  padding: 0 3px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.hands-others .hand-piece .cnt {
  font-size: 0.68rem;
  margin-left: 1px;
}
.hands-others .hand-more {
  flex: none;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-2);
}
.hands-others .hand-empty {
  font-size: 0.7rem;
}
.hands-others .hand-label {
  margin-right: 2px;
}
.hand.turn {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.hand.dead {
  opacity: 0.7;
}
.hand.dead .hand-label .mark {
  text-decoration: line-through;
}
.turn-note {
  margin: 2px 0;
  padding: 3px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  text-wrap: pretty;
  min-height: 1.6em;
  box-sizing: content-box;
}
.turn-note.empty {
  visibility: hidden;
}
.check:empty {
  display: none;
}

/* ホームの 4 人の席 */
.seats4 {
  display: grid;
  gap: 6px;
}
.seat-row {
  display: grid;
  grid-template-columns: 3.7em 92px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 44px;
}
.seat-name {
  white-space: nowrap;
  font-size: 0.85rem;
}
.seat-kind {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}
.seat-kind button {
  min-width: 0;
  padding: 6px 4px;
}
.seat-ai {
  min-width: 0;
  width: 100%;
  min-height: 40px;
  font: inherit;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 6px;
}

/* 対局者の一覧（4 人）・視点 */
.player-row.dead {
  color: var(--text-2);
}
.player-row.dead > span:first-child {
  text-decoration: line-through;
}
.player-row.turn {
  font-weight: 700;
}
.player-status {
  margin-left: 6px;
  font-size: 0.78rem;
  color: var(--text-2);
}
.seat-view {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.seat-view-label {
  font-size: 0.8rem;
  color: var(--text-2);
}
.seat-view-pick {
  grid-template-columns: repeat(4, 44px);
  gap: 4px;
}
.seat-view-pick button {
  min-width: 0;
  padding: 4px;
}

/* 終局の順位 */
.result-lines {
  margin: 4px 0 10px;
  padding-left: 1.2em;
  font-size: 0.9rem;
  list-style: none;
  padding-left: 0;
}
.gallery-tag {
  display: inline-block;
  padding: 0 6px;
  font-size: 0.72rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  vertical-align: 1px;
}

/* ===== 平面: 直前の手の緑の矢印・動く駒（ui/plane-anim.js）。スクロールの中身に重ねる板 ===== */
.plane-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 3;
}
.plane-arrow {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
}
.plane-arrow .pa-line {
  stroke: var(--arrow);
  stroke-linecap: round;
  opacity: 0.85;
}
.plane-arrow .pa-head {
  fill: var(--arrow);
}
.plane-arrow .pa-dot {
  fill: var(--arrow);
  opacity: 0.85;
}
.plane-arrow .pa-ring {
  fill: none;
  stroke: var(--arrow);
  opacity: 0.85;
}
.float-cell {
  position: absolute;
  left: 0;
  top: 0;
  container-type: size;
  pointer-events: none;
  z-index: 4;
  --lift: 0;
  will-change: transform;
  /* 駒は clip-path で切ってあるので、影は外の箱に付ける */
  filter: drop-shadow(0 calc(3px + 5px * var(--lift)) 4px rgba(0, 0, 0, 0.35));
}
.float-cell .piece {
  scale: calc(1 + 0.18 * var(--lift));
}

/* ===== カメラ: 固定 / 追う ===== */
.cam-pick-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cam-label {
  font-size: 0.8rem;
  color: var(--text-2);
  white-space: nowrap;
}
.cam-pick {
  grid-template-columns: repeat(2, minmax(0, 56px));
  gap: 4px;
}
.cam-pick button {
  min-height: 36px;
  padding: 4px 6px;
  font-size: 0.82rem;
}
#cam-play {
  margin-top: 8px;
}

/* ===== 決着・脱落・王手の文字（ui/finish-fx.js。393 の .finish-text を参考に） ===== */
.fx-text,
.fx-check {
  position: fixed;
  z-index: 40;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15em;
  max-width: calc(100vw - 16px);
  text-align: center;
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Noto Sans CJK JP', sans-serif;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: 0.04em;
}
.fx-text .fx-main,
.fx-check .fx-main {
  white-space: nowrap;
  -webkit-text-stroke: 0.04em rgba(70, 36, 0, 0.6);
  paint-order: stroke fill;
}
.fx-text .fx-sub {
  font-size: 1.05rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(30, 18, 8, 0.55);
  color: #fff3d6;
}
.fx-text.tone-win .fx-main,
.fx-text.tone-neutral .fx-main {
  color: #fff3a6;
  text-shadow:
    0 0 0.12em rgba(255, 220, 110, 0.95),
    0 0 0.45em rgba(255, 170, 40, 0.75),
    0 0 1em rgba(255, 120, 30, 0.45),
    0 0.06em 0 #9a5a12;
}
.fx-text.tone-lose .fx-main {
  color: #b8c0de;
  -webkit-text-stroke-color: rgba(20, 26, 50, 0.6);
  text-shadow:
    0 0 0.3em rgba(120, 140, 210, 0.55),
    0 0.05em 0 #2e3456;
}
.fx-text.size-mid .fx-main {
  color: #ffe9c9;
  text-shadow:
    0 0 0.25em rgba(220, 90, 40, 0.8),
    0 0.05em 0 #6a2a10;
}
.fx-text.size-mid.tone-lose .fx-main {
  color: #b8c0de;
  text-shadow:
    0 0 0.3em rgba(120, 140, 210, 0.55),
    0 0.05em 0 #2e3456;
}
.fx-check .fx-main {
  color: #fff;
  -webkit-text-stroke: 0.05em rgba(120, 0, 0, 0.75);
  text-shadow:
    0 0 0.2em rgba(230, 40, 40, 0.9),
    0 0.06em 0 #7a0f0f;
}
.fx-text.pop {
  animation: fx-pop 650ms cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
.fx-text.tone-lose.pop {
  animation: fx-sink 900ms ease-out both;
}
.fx-check {
  animation: fx-check var(--fx-check-ms, 800ms) ease-out both;
}
@keyframes fx-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}
@keyframes fx-sink {
  from {
    opacity: 0;
    transform: translate(-50%, -80%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}
@keyframes fx-check {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.6);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}
@media (prefers-reduced-motion: reduce) {
  .fx-text.pop,
  .fx-text.tone-lose.pop {
    animation: none;
  }
  .fx-check {
    animation: none;
  }
}
.rv-fx {
  display: block;
  margin: 6px auto 0;
  font-size: 0.85rem;
}

/* ===== 利きのガイド（features/attack-guide-model.js。★ 空きマスの利き・⚠ 危ない行き先） ===== */
:root {
  --guide-cell: #7a4fd0; /* ★ 見ているマスの輪（ほかの目印に無い紫） */
  --danger-mark: #d62020;
  --danger-mark-text: #fff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --guide-cell: #b89cff;
    --danger-mark: #ff5a4a;
    --danger-mark-text: #1c0a08;
  }
}
:root[data-theme='dark'] {
  --guide-cell: #b89cff;
  --danger-mark: #ff5a4a;
  --danger-mark-text: #1c0a08;
}
.guide-fx {
  display: flex;
  margin-top: 8px;
}
/* 利いている駒: 持ち主の色の丸い輪（赤枠 = 取る・◇ = 跳ぶ とは形で分ける） */
.cell .guide-ring {
  position: absolute;
  inset: 4%;
  z-index: 3;
  border-radius: 50%;
  border: 2.5px solid var(--tone, var(--danger-mark));
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--surface) 70%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--surface) 60%, transparent);
  pointer-events: none;
}
.cell .guide-ring.hover {
  border-style: solid;
  border-width: 3px;
}
/* ★ 見ているマス: 紫の点線の輪 + 持ち主ごとの数（色付き） */
.cell.guide-cell {
  box-shadow: inset 0 0 0 2px var(--guide-cell);
}
.cell .guide-count {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6%;
  font-size: 42cqh;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 0 2px var(--surface), 0 0 2px var(--surface);
}
.cell .guide-count.many {
  font-size: 32cqh;
}
.cell .guide-count .none {
  color: var(--text-2);
}
.cell .guide-count span {
  color: var(--tone, var(--text));
}
/* ⚠ 危ない行き先: 右上の角に小さな赤い三角（行き先の点・赤枠・◇ とは重ならない） */
.cell .danger-mark {
  position: absolute;
  right: 0;
  top: 0;
  width: 44%;
  height: 44%;
  z-index: 4;
  pointer-events: none;
  background: var(--danger-mark);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}
.cell .danger-mark::after {
  content: '!';
  position: absolute;
  right: 8%;
  top: -4%;
  font-size: 30cqh;
  font-weight: 900;
  line-height: 1;
  color: var(--danger-mark-text);
}
.tone-ring-b {
  --tone: #e07a1e;
}
.tone-ring-w {
  --tone: #2e7cf0;
}
.tone-ring-A {
  --tone: #e07a1e;
}
.tone-ring-B {
  --tone: #2fa86a;
}
.tone-ring-C {
  --tone: #2e7cf0;
}
.tone-ring-D {
  --tone: #c0398a;
}
.plane-tab .tab-mark-guide {
  color: var(--guide-cell);
}
/* 長押し・右クリックの ★（駒のあるマス）: 数は下の帯にして駒の字を隠さない。長押しで文字選択・iOS のメニューを出さない */
.plane .cell {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.cell .guide-count.on-piece {
  inset: auto 0 0 0;
  height: 40%;
  font-size: 34cqh;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
}

/* 平面: 方位磁石（4&5層の行の空き。押すと盤を 90° 回す）。字は回さず、針が北を指す。下に「自分目線に戻る」 */
.plane-orient {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 4px;
}
.plane-own {
  min-height: 32px;
  padding: 2px 6px;
  font-size: 0.66rem;
  white-space: nowrap;
}
.plane-own[hidden] {
  display: none;
}
.plane-compass {
  display: grid;
  justify-items: center;
  gap: 0;
  width: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.66rem;
  line-height: 1.2;
  cursor: pointer;
}
.plane-compass svg {
  width: clamp(48px, calc(var(--cell) * 1.7), 66px);
  height: auto;
  display: block;
}
.plane-compass .cmp-ring {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}
.plane-compass .cmp-n {
  fill: var(--danger-mark);
}
.plane-compass .cmp-s {
  fill: var(--text-2);
  opacity: 0.55;
}
.plane-compass .cmp-hub {
  fill: var(--surface);
  stroke: var(--text-2);
  stroke-width: 1;
}
.plane-compass .cmp-t {
  fill: var(--text);
  font-size: 11px;
  font-weight: 700;
}
.plane-compass .cmp-t.cmp-tn {
  fill: var(--danger-mark);
}
.plane-compass-note {
  font-weight: 700;
}
