/* 本将棋の見た目。色・形・ボタン・ダイアログ・7 つの場所の格子は共通の枠（/app/_shared/game-shell/v1/game-tokens.css・
   game-layout.css）が持つ。ここは色の値の上書き・本将棋だけの色（盤の利き・席の色）・盤と駒の中・ホームとギャラリーの中身だけ。 */
:root {
  --accent: #b5532a;
  --promoted: #c0261d;
  --target: rgba(40, 140, 80, 0.45);
  --last: rgba(255, 200, 60, 0.55);
  --picked: rgba(60, 120, 220, 0.45);
  --check: rgba(220, 40, 40, 0.55);
  --heat-0: rgba(40, 110, 220, 0.28);
  --heat-1: rgba(220, 60, 60, 0.28);
  --s0: #2b6cd6;
  --s1: #d23f3f;
}
.topbar {
  padding: 8px 0 0;
}
h1 {
  font-size: 1.6rem;
  margin: 8px 0 4px;
}
h2 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}
h3 {
  font-size: 0.95rem;
  margin: 12px 0 6px;
  color: var(--text-2);
}
.lede,
.hint {
  color: var(--text-2);
  font-size: 0.9rem;
  margin: 4px 0 12px;
}
.error {
  color: var(--promoted);
  font-weight: 700;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.85rem;
  color: var(--text-2);
}
.field input,
.field select {
  color: var(--text);
}
/* ===== 対局（場所の格子は枠。ここは中身だけ） ===== */
.stats-wrap {
  overflow-x: auto;
}
table.stats {
  border-collapse: collapse;
  font-size: 0.8rem;
  width: 100%;
}
table.stats th,
table.stats td {
  border-bottom: 1px solid var(--border);
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
}
table.stats tbody th {
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap; /* 行の名は短い語（12 字まで）。折り返さない */
}
.stats-wrap {
  overflow-x: auto;
}
.moves {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  font-size: 0.88rem;
}
.moves li {
  display: flex;
  gap: 6px;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: var(--radius-s);
}
.moves li.cur {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}
.moves .no {
  color: var(--text-2);
  min-width: 2.2em;
  text-align: right;
}
.moves .ms {
  margin-left: auto;
  color: var(--text-2);
  font-size: 0.75rem;
}

/* ===== 盤と駒（立体 / 平面）: 同じ部品（.ban・.piece = 側面 ＋ 上の面）で、違いは傾き・厚み・影だけ =====
   質感はピラミッド将棋（apps/pyramid-shogi: 五角形の駒・厚み・影）に合わせ、本将棋らしく榧の盤・黄楊の駒・墨の字・朱の成り駒・星・駒台 */
:root {
  --kaya: #e6be72;
  --kaya-2: #d9a95a;
  --kaya-grain: rgba(140, 90, 30, 0.13);
  --ban-line: #3b2a14;
  --ban-edge: #8a5a24;
  --ban-edge-2: #6b4318;
  --tsuge: #f8e3ad;
  --tsuge-2: #e9c67f;
  --tsuge-grain: rgba(150, 100, 40, 0.12);
  --koma-side-0: #b98444;
  --koma-side-1: #9b7a4c;
  --koma-ink: #17100a;
  --shu: #c0261d;
  --komadai: #e9c98e;
  --font-koma:
    'Yuji Boku', 'Yuji Syuku', 'Kaisei Decol', 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', 'Noto Serif JP',
    'Noto Serif CJK JP', serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --kaya: #c99d55;
    --kaya-2: #b88c46;
    --ban-line: #2a1d0c;
    --ban-edge: #6b4318;
    --ban-edge-2: #4a2c0e;
    --komadai: #b8935a;
  }
}
/* 盤の箱（枠の .gs-board = 正方形）の中: 筋の数字（上）・段の数字（右）も箱の内側（点検 E2）。
   盤の幅 = 箱の幅から段の数字の列を引いた物と、箱の高さに収まる幅（升は縦長 1 : 1.08）の小さい方 */
.board {
  container-type: size;
  user-select: none;
  -webkit-user-select: none;
}
.board-wrap {
  --ban-w: min(100cqw - 16px, (100cqh - 16px - 18px) / 1.08 + 18px);
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: var(--ban-w) 16px;
  grid-template-rows: 16px auto;
  grid-template-areas:
    'files .'
    'ban ranks';
  justify-content: center;
  align-content: center;
  transform-origin: 50% 100%;
  transition: transform 0.25s ease;
}
.files {
  grid-area: files;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  align-items: end;
  padding: 0 9px;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--text-2);
  text-align: center;
}
.ranks {
  grid-area: ranks;
  display: grid;
  grid-template-rows: repeat(9, 1fr);
  padding: 9px 0;
  font-size: 0.7rem;
  color: var(--text-2);
  align-items: center;
  text-align: center;
}
/* 盤（榧の木目 ＋ 縁） */
.ban {
  grid-area: ban;
  position: relative;
  min-width: 0;
  padding: 7px;
  border-radius: var(--radius-s);
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 240, 200, 0.35), transparent 60%),
    repeating-linear-gradient(
      92deg,
      var(--kaya-grain) 0 1px,
      transparent 1px 7px,
      var(--kaya-grain) 7px 8px,
      transparent 8px 15px
    ),
    linear-gradient(180deg, var(--kaya), var(--kaya-2));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 2px 6px rgba(60, 35, 10, 0.25);
}
.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 2px solid var(--ban-line);
}
.stars {
  position: absolute;
  inset: 9px; /* .ban の padding ＋ .grid の枠 */
  pointer-events: none;
  z-index: 2;
}
.star {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--ban-line);
}
.star-0 {
  left: 33.333%;
  top: 33.333%;
}
.star-1 {
  left: 66.667%;
  top: 33.333%;
}
.star-2 {
  left: 33.333%;
  top: 66.667%;
}
.star-3 {
  left: 66.667%;
  top: 66.667%;
}
.cell {
  position: relative;
  aspect-ratio: 1 / 1.08;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--ban-line);
  border-bottom: 1px solid var(--ban-line);
  border-radius: 0;
  background: transparent;
  overflow: visible;
  container-type: size;
}
.cell:nth-child(9n) {
  border-right: 0;
}
.cell:nth-child(n + 73) {
  border-bottom: 0;
}
.cell::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.cell.heat-0::before {
  background: var(--heat-0);
}
.cell.heat-1::before {
  background: var(--heat-1);
}
.cell.last::before {
  background: var(--last);
}
.cell.picked::before {
  background: var(--picked);
  box-shadow: inset 0 0 0 2px var(--s0);
}
.cell.check::before {
  background: var(--check);
}
.cell.hanging::before {
  box-shadow: inset 0 0 0 2px var(--promoted);
}
.cell.target::after {
  content: '';
  position: absolute;
  left: 34%;
  top: 34%;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: var(--target);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
  z-index: 3;
  pointer-events: none;
}
.cell.target:has(.piece)::after {
  left: 6%;
  top: 6%;
  width: 88%;
  height: 88%;
  border-radius: var(--radius-s);
  background: transparent;
  box-shadow: inset 0 0 0 3px var(--target);
}
/* 駒（五角形 = 上の面と側面を同じ形で切り、立体では側面を少し下へずらして厚みにする） */
.piece {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 4%;
  bottom: 8%;
  z-index: 1;
  pointer-events: none;
  container-type: size;
  filter: drop-shadow(0 1px 1px rgba(40, 20, 0, 0.3));
}
.piece.k-P {
  left: 13%;
  right: 13%;
  top: 9%;
}
.piece.k-L,
.piece.k-N {
  left: 11%;
  right: 11%;
  top: 7%;
}
.piece.k-K {
  left: 5%;
  right: 5%;
  top: 2%;
}
.koma-top,
.koma-side {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 85% 15%, 100% 100%, 0% 100%, 15% 15%);
}
.koma-side {
  display: none;
  background: linear-gradient(180deg, var(--koma-side-0), color-mix(in srgb, var(--koma-side-0) 70%, #3a2008));
}
.piece.s1 .koma-side {
  background: linear-gradient(180deg, var(--koma-side-1), color-mix(in srgb, var(--koma-side-1) 70%, #2a2030));
}
.koma-top {
  display: grid;
  place-items: center;
  padding-top: 14%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 35%),
    repeating-linear-gradient(
      97deg,
      var(--tsuge-grain) 0 1px,
      transparent 1px 4px,
      var(--tsuge-grain) 4px 5px,
      transparent 5px 9px
    ),
    linear-gradient(180deg, var(--tsuge), var(--tsuge-2));
  box-shadow:
    inset 0 -2px 0 rgba(120, 70, 20, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.piece.away .koma-top,
.piece.away .koma-side {
  rotate: 180deg;
}
.glyph {
  font-family: var(--font-koma);
  font-weight: 900;
  font-size: min(60cqh, 92cqw);
  line-height: 1;
  color: var(--koma-ink);
  text-shadow: 0 0 0.5px var(--koma-ink);
}
.piece.promoted .glyph {
  color: var(--shu);
  text-shadow: 0 0 0.5px var(--shu);
}
/* 駒台（枠の決まった升 .gs-hand-grid。駒の絵は盤と同じ部品） */
.gs-hand-grid {
  background:
    repeating-linear-gradient(92deg, var(--kaya-grain) 0 1px, transparent 1px 9px),
    linear-gradient(180deg, var(--komadai), color-mix(in srgb, var(--komadai) 85%, #6b4318));
  box-shadow: 0 1px 3px rgba(60, 35, 10, 0.25);
}
.gs-hand-piece {
  container-type: size;
}
.gs-hand-piece .piece {
  left: 50%;
  right: auto;
  top: 3px;
  bottom: 3px;
  width: min(calc(100% - 6px), 36px);
  translate: -50% 0;
}
.heat {
  position: absolute;
  z-index: 4;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  text-shadow:
    0 0 2px #fff,
    0 0 2px #fff;
}
.heat.h0 {
  right: 2px;
  bottom: 2px;
  color: var(--s0);
}
.heat.h1 {
  left: 2px;
  top: 2px;
  color: var(--s1);
}
/* 立体: 盤を少し傾け（箱の中だけ。点検 E3）、縁に厚み・影、駒に側面と影（駒台・成りの問いの駒も） */
.board[data-style='3d'] .board-wrap {
  /* 傾きは箱の中だけ。上が遠くへ縮んで空く分を小さくするため 12 度 */
  transform: perspective(1100px) rotateX(12deg);
}
.board[data-style='3d'] .ban {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.3),
    0 4px 0 var(--ban-edge),
    0 8px 0 var(--ban-edge-2),
    0 12px 14px rgba(40, 20, 0, 0.3);
}
[data-look='3d'] .koma-side,
.gs-promote .koma-side {
  display: block;
  translate: 0 9%;
}
[data-look='3d'] .koma-top,
.gs-promote .koma-top {
  translate: 0 -2%;
}
[data-look='3d'] .piece {
  filter: drop-shadow(0 3px 2px rgba(40, 20, 0, 0.4));
}
/* 成りの問いの駒の絵（成る = 成った駒・成らない = 元の駒） */
.gs-promote-btn .piece {
  position: relative;
  inset: auto;
  display: block;
  width: 40px;
  height: 46px;
}
/* 問いは盤の幅の内に収める（スマホでは 5 升ほどの幅。左右の端の筋を隠さない） */
.gs-promote .gs-dialog-box {
  padding: 6px 8px 10px;
}
.gs-promote-btn {
  min-width: 76px;
  padding: 6px 8px;
}
@media (max-width: 480px) {
  .gs-promote .gs-dialog-box {
    padding: 4px 6px 8px;
  }
  .gs-promote .gs-dialog-head {
    gap: 2px;
  }
  .gs-promote .gs-dialog-title {
    padding-left: 0;
    font-size: 0.9rem;
  }
  .gs-promote .gs-close {
    width: 32px;
    height: 32px;
    min-height: 32px;
    margin: -2px -4px 0 0;
  }
  .gs-promote .gs-dialog-buttons {
    gap: 4px;
  }
  .gs-promote-btn {
    min-width: 60px;
    padding: 4px;
    font-size: 0.85rem;
  }
  .gs-promote-btn .piece {
    width: 34px;
    height: 40px;
  }
}

/* ===== 対局の画面の中身（横の欄・ダイアログ） ===== */
.gs-side .moves {
  flex: 1;
  min-height: 0;
  max-height: none;
}
@media (max-width: 1099px) {
  .gs-side .moves {
    max-height: 320px;
  }
}
.view-panel {
  display: grid;
  gap: 12px;
}
.view-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.view-label {
  min-width: 4.5em;
  color: var(--text-2);
}
.stats-panel table.stats tbody th .gs-help-link {
  font-weight: 600;
  color: var(--text-2);
}
.stats-panel .search-stats summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  color: var(--text-2);
  cursor: pointer;
}
/* 駒の動き（5×5 の升・真ん中が駒） */
.guide-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.guide-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(5, 24px);
  grid-auto-rows: 26px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--kaya) 35%, var(--surface));
}
.guide-cell {
  position: relative;
  display: grid;
  place-items: center;
  border-right: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}
.guide-cell.step::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}
.guide-name {
  font-size: 0.85rem;
}

/* ===== AI の設定（探索部・評価部・強さ・棋風のチップ。フレネミー将棋の組み合わせのチップの形） ===== */
table.searchers {
  margin-top: 8px;
}
table.searchers tbody th,
table.searchers thead th:first-child {
  white-space: nowrap;
}
/* 棋風の発動（対局後） */
.persona-stats h3 {
  margin-top: 12px;
}
.persona-line {
  margin: 4px 0;
  font-size: 0.85rem;
}
.persona-per {
  margin: 0 0 4px;
  padding-left: 1.2em;
  font-size: 0.78rem;
  color: var(--text-2);
}
.persona-moves {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.persona-move {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  font-size: 0.8rem;
  min-height: 32px;
  padding: 2px 8px;
}
.persona-move .no {
  color: var(--text-2);
}
.persona-move small {
  color: var(--accent);
}
/* ===== ホーム（1 列・箱なし。区画は見出し ＋ 細い区切り線。design ui-shell §2.1） ===== */
.home h1 {
  margin: 12px 0 0;
}
.home .lede {
  margin: 0 0 4px;
}
.home-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0;
}
.home .big {
  display: block;
  width: 100%;
  margin: 12px 0 0;
  font-size: 1.1rem;
}
.home #engine-status {
  margin: 8px 0 0;
}
/* 棋譜の区画 */
.records-head {
  display: flex;
  align-items: center;
  margin: 16px 0 4px;
}
.records {
  margin: 0;
  padding: 0;
  list-style: none;
}
.record {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.record-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 12px;
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 400;
  text-align: left;
}
.record-row .rec-date {
  grid-row: span 2;
  color: var(--text-2);
  font-size: 0.8rem;
}
.record-row .rec-players {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.record-row .rec-result {
  color: var(--text-2);
  font-size: 0.8rem;
}
.link-btn {
  min-height: 32px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 400;
  text-decoration: underline;
}
.home-foot {
  margin: 32px 0 0;
  font-size: 0.85rem;
}
.home.over {
  outline: 2px dashed var(--accent);
  outline-offset: 4px;
}
.more-settings {
  display: grid;
  gap: 12px;
}
/* ===== ギャラリー・統計（1 列・箱なし。戻り口は見出しの左。design ui-shell §2.4） ===== */
.sub-title {
  display: flex;
  align-items: center;
  margin: 4px 0 0;
  font-size: 1.4rem;
}
.gallery-row {
  grid-template-columns: minmax(0, 1fr);
}
.gal-title {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.gallery-filters {
  display: grid;
  gap: 12px;
}
.stats-picks {
  align-items: flex-end;
}
.field > span {
  display: inline-flex;
  align-items: center;
}
.sub-page .stats-wrap {
  margin-top: 12px;
}
