/* ============================================================
   将棋囲いプラグイン v8.0 — Premium CSS
   ・将棋盤の正確な再現（木目・枠・マス目）
   ・SVG五角形駒（ホンモノの形）
   ・PC / タブレット横 / タブレット縦 / スマホ / 小型スマホ 5段階対応
   ============================================================ */

/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  /* セルサイズ */
  --cell:       58px;
  /* 将棋盤ボーダー */
  --bord:       5px;
  /* 駒SVGサイズ (セル内に収まる最大値) */
  --piece-w:    46px;
  --piece-h:    52px;
  /* 駒台 */
  --mochi-size: 40px;
  /* フォント */
  --label-sz:   13px;
  /* サイドバー幅 */
  --sb-w:       300px;
  /* 盤面色 */
  --board-bg:     #e2b35a;
  --board-line:   #8b5a10;
  --board-border: #2c1600;
  /* 共通 */
  --radius: 8px;
}

/* タブレット横 〜 1100px */
@media (max-width: 1100px) {
  :root { --cell:52px; --piece-w:41px; --piece-h:46px; --mochi-size:36px; --sb-w:270px; }
}
/* タブレット縦 〜 860px */
@media (max-width: 860px) {
  :root { --cell:48px; --piece-w:38px; --piece-h:43px; --mochi-size:34px; --sb-w:100%; }
}
/* スマホ 〜 540px */
@media (max-width: 540px) {
  :root { --cell:38px; --piece-w:30px; --piece-h:34px; --mochi-size:28px; --label-sz:11px; --bord:4px; }
}
/* 小型スマホ 〜 390px */
@media (max-width: 390px) {
  :root { --cell:33px; --piece-w:26px; --piece-h:30px; --mochi-size:25px; --label-sz:10px; --bord:3px; }
}

/* ============================================================
   管理画面 レイアウト
   ============================================================ */
.shogi-admin-wrap {
  max-width: 1180px;
  margin: 0 auto;
}
.shogi-admin-header {
  padding-bottom: 16px;
  border-bottom: 2px solid #d4b87a;
  margin-bottom: 24px;
}
.shogi-admin-header h1 { font-size: 22px; font-weight: 800; color: #1c0e00; margin: 0 0 6px; }
.shogi-admin-header p  { color: #666; font-size: 13px; margin: 0; }

.shogi-admin-app {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}
.shogi-board-col { flex-shrink: 0; }

/* ============================================================
   プレイヤーバー
   ============================================================ */
.player-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 14px;
}
.sente-bar {
  background: linear-gradient(90deg,#1e0e00,#3c1e00);
  border: 2px solid #5a3010;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.gote-bar {
  background: linear-gradient(90deg,#100018,#2a0038);
  border: 2px solid #4a1060;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.player-name  { font-weight: 800; font-size: 15px; letter-spacing: .04em; }
.sente-name   { color: #ffd060; }
.gote-name    { color: #e8a8ff; }

.turn-badge {
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,.2);
  color: #fff;
  animation: turn-blink 1.2s ease-in-out infinite;
}
@keyframes turn-blink { 0%,100%{opacity:1} 50%{opacity:.5} }

.check-badge {
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  background: #d02838;
  color: #fff;
  animation: check-flash .5s step-start infinite;
}
@keyframes check-flash { 0%,100%{opacity:1} 50%{opacity:0} }

/* ============================================================
   駒台 (Mochigoma)
   ============================================================ */
.mochigoma {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  min-height: calc(var(--mochi-size) + 20px);
  border-radius: var(--radius);
  margin-bottom: 6px;
  align-items: center;
}
.sente-mochi {
  background: linear-gradient(135deg,#201000,#3c2000);
  border: 2px solid #6a3c0a;
}
.gote-mochi {
  background: linear-gradient(135deg,#0e0018,#280034);
  border: 2px solid #5a1878;
}

.mochi-empty {
  font-size: 12px;
  color: rgba(255,255,255,.35);
  font-style: italic;
}
.mochi-piece {
  position: relative;
  cursor: pointer;
  background: none;
  border: 2px solid transparent;
  padding: 2px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s, border-color .15s;
  line-height: 0;
}
.mochi-piece svg { width: var(--mochi-size) !important; height: calc(var(--mochi-size) * 54/48) !important; display: block; }
.mochi-piece:hover      { transform: translateY(-2px); border-color: rgba(255,255,255,.4); }
.mochi-piece.mochi-selected {
  border-color: #ffd040;
  border-radius: 6px;
  box-shadow: 0 0 0 1px #ffd040, 0 0 8px rgba(255,208,64,.5);
  animation: mochi-glow .8s ease-in-out infinite;
}
@keyframes mochi-glow { 0%,100%{box-shadow:0 0 0 1px #ffd040,0 0 8px rgba(255,208,64,.5)} 50%{box-shadow:0 0 0 1px #ffb020,0 0 14px rgba(255,176,32,.7)} }

.mochi-count {
  position: absolute;
  bottom: 0; right: 0;
  background: #e04020;
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 800;
  width: 15px; height: 15px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
  z-index: 2;
  pointer-events: none;
}

/* ============================================================
   将棋盤ラッパー
   ============================================================ */
.shogi-board-wrap {
  display: inline-flex;
  flex-direction: column;
  user-select: none;
}

/* 列ラベル: 9〜1 (左→右)
   ボーダー幅分だけ左にオフセットして盤の列と揃える */
.shogi-col-labels {
  display: flex;
  /* ボーダー分だけ右シフト（行ラベル分は不要、列ラベルは盤の真上） */
  padding-left: var(--bord);
  margin-bottom: 4px;
  box-sizing: border-box;
}
.shogi-col-labels span {
  width: var(--cell);
  text-align: center;
  font-size: var(--label-sz);
  font-weight: 700;
  color: #4a2c08;
  font-family: 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  line-height: 1;
}

.shogi-board-and-rows {
  display: flex;
  align-items: stretch;
}

/* ============================================================
   将棋盤 — 正確な木目グリッド
   ============================================================ */
.shogi-board {
  display: grid;
  grid-template-columns: repeat(9, var(--cell));
  grid-template-rows:    repeat(9, var(--cell));

  /* 榧(かや)材の木目色 */
  background-color: var(--board-bg);
  /* 木目テクスチャ（軽量CSS） */
  background-image:
    repeating-linear-gradient(
      6deg,
      transparent 0px, transparent 22px,
      rgba(140,80,0,.05) 22px, rgba(140,80,0,.05) 23px
    ),
    repeating-linear-gradient(
      174deg,
      transparent 0px, transparent 34px,
      rgba(100,50,0,.04) 34px, rgba(100,50,0,.04) 35px
    );

  /* 厚みのある枠 */
  border: var(--bord) solid var(--board-border);
  border-radius: 2px;

  box-shadow:
    /* 外枠の厚み感 */
    0 0 0 1px #8a5010,
    /* 浮き上がり */
    0 8px 32px rgba(0,0,0,.45),
    0 2px 8px  rgba(0,0,0,.3),
    /* 内側ハイライト */
    inset 0 1px 0 rgba(255,220,120,.35);
}

/* ---- マス目 ---- */
.shogi-cell {
  width: var(--cell);
  height: var(--cell);
  border: 1px solid var(--board-line);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  transition: background-color .1s;
}
.shogi-cell:hover {
  background: rgba(255,220,100,.25);
}

/* 選択中 */
.shogi-cell.cell-selected {
  background: rgba(255,200,30,.55) !important;
  box-shadow: inset 0 0 0 2px #c08800, inset 0 0 12px rgba(255,200,0,.5);
  z-index: 1;
}

/* 移動可能マス (空き) */
.shogi-cell.cell-valid {
  background: rgba(40,180,80,.12);
}
/* 緑の丸 */
.shogi-cell.cell-valid::after {
  content: '';
  position: absolute;
  width: 38%;
  height: 38%;
  border-radius: 50%;
  background: rgba(30,160,70,.75);
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 6px rgba(30,160,70,.5);
  animation: dot-pulse .9s ease-in-out infinite;
}
@keyframes dot-pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.6;transform:scale(.85)} }

/* 取れるマス */
.shogi-cell.cell-capture {
  background: rgba(210,30,30,.18) !important;
}
.shogi-cell.cell-capture::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px solid rgba(200,20,20,.7);
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
  animation: cap-pulse .7s ease-in-out infinite;
}
@keyframes cap-pulse { 0%,100%{border-color:rgba(200,20,20,.7)} 50%{border-color:rgba(240,60,60,1)} }

/* マス内側コンテナ */
.shogi-cell-inner {
  width: var(--piece-w);
  height: var(--piece-h);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.shogi-cell-inner svg {
  width: var(--piece-w) !important;
  height: var(--piece-h) !important;
  display: block;
  transition: filter .15s, transform .15s;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,.35));
}

/* セル選択・ホバー時に駒を浮かせる */
.shogi-cell.cell-selected .shogi-cell-inner svg {
  filter: drop-shadow(0 4px 10px rgba(200,160,0,.8)) drop-shadow(0 2px 4px rgba(0,0,0,.4));
  transform: translateY(-2px) scale(1.05);
}
.shogi-cell:hover .shogi-cell-inner svg {
  filter: drop-shadow(0 3px 7px rgba(0,0,0,.45));
  transform: translateY(-1px) scale(1.02);
}

/* ============================================================
   SVG 駒のスタイル
   ============================================================ */
/* 本体ポリゴン: 先手・後手共通 (グラデーションはSVG内で定義) */
.sp-svg { display: block; overflow: visible; }

/* ============================================================
   行ラベル
   ============================================================ */
.shogi-row-labels {
  display: flex;
  flex-direction: column;
  margin-left: 6px;
}
.shogi-row-labels span {
  height: var(--cell);
  display: flex;
  align-items: center;
  font-size: var(--label-sz);
  font-weight: 700;
  color: #4a2c08;
  font-family: 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  line-height: 1;
}

/* ============================================================
   成りモーダル
   ============================================================ */
.shogi-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.shogi-modal-box {
  background: linear-gradient(150deg,#fefae8,#f5e8bc);
  border: 3px solid #7a5010;
  border-radius: 16px;
  padding: 28px 32px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.5);
  animation: slideUp .22s cubic-bezier(.2,.8,.3,1.1);
  min-width: 260px;
}
@keyframes slideUp { from{transform:scale(.88) translateY(20px);opacity:0} to{transform:scale(1) translateY(0);opacity:1} }

.shogi-modal-title {
  font-size: 18px;
  font-weight: 800;
  color: #1e0e00;
  margin: 0 0 20px;
  font-family: 'Hiragino Mincho ProN','Yu Mincho',serif;
}
.shogi-modal-choices { display: flex; gap: 20px; justify-content: center; }
.promo-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border: 2px solid #c8a040;
  border-radius: 12px;
  cursor: pointer;
  background: linear-gradient(145deg,#fefcf0,#f5e8c0);
  font-size: 14px;
  font-weight: 700;
  color: #2a1400;
  font-family: inherit;
  transition: all .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.promo-choice:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.22); background: linear-gradient(145deg,#fffcf0,#faecb0); border-color: #a07828; }

/* モーダル内の駒プレビュー */
#promo-yes-kanji, #promo-no-kanji,
.promo-yes-kanji, .promo-no-kanji {
  width: 44px; height: calc(44px * 54/48);
  display: flex; align-items: center; justify-content: center;
}
#promo-yes-kanji svg, #promo-no-kanji svg,
.promo-yes-kanji svg, .promo-no-kanji svg {
  width: 44px !important; height: calc(44px * 54/48) !important;
}

/* ============================================================
   管理画面 サイドバー
   ============================================================ */
.shogi-sidebar {
  flex: 1;
  max-width: var(--sb-w);
  min-width: 220px;
}

/* モード切替 */
.shogi-mode-tabs {
  display: flex;
  border: 2px solid #3c2005;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.shogi-mode-btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: #f5edd8;
  color: #4a2c08;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
  letter-spacing: .02em;
}
.shogi-mode-btn + .shogi-mode-btn { border-left: 1px solid #c4963c; }
.shogi-mode-btn.active {
  background: linear-gradient(135deg,#3c2005,#1e0e00);
  color: #ffd060;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.3);
}
.shogi-mode-btn:not(.active):hover { background: #ede4cc; }

/* サイドブロック */
.sidebar-block {
  background: #fff;
  border: 1px solid #e8d8bc;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
}
.sidebar-block h3 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 800;
  color: #1e0e00;
  padding-bottom: 8px;
  border-bottom: 2px solid #c89830;
  letter-spacing: .04em;
  text-transform: none;
}

/* 先手/後手トグル */
.owner-toggle { display: flex; gap: 6px; margin-bottom: 14px; }
.owner-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 6px;
  border: 2px solid #ddd;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: #555;
  transition: all .15s;
}
.owner-label input { display: none; }
.sente-label:has(input:checked) { background: linear-gradient(135deg,#2c1400,#5a2800); color: #ffd060; border-color: #5a2800; }
.gote-label:has( input:checked) { background: linear-gradient(135deg,#1a0028,#3c0058); color: #e8a8ff; border-color: #3c0058; }
.owner-label:not(:has(input:checked)):hover { background: #f5edd8; border-color: #c09040; }

/* パレット */
.palette-section { margin-bottom: 10px; }
.palette-sec-label { font-size: 10px; font-weight: 700; color: #999; margin: 0 0 5px; letter-spacing: .08em; text-transform: uppercase; }
.palette-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 4px; }
.palette-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 2px;
  background: #faf5ee;
  border: 2px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-family: inherit;
  transition: all .13s;
}
.palette-piece-wrap { width: 36px; height: calc(36px * 54/48); display: flex; align-items: center; justify-content: center; }
.palette-piece-wrap svg { width: 36px !important; height: calc(36px * 54/48) !important; }
.palette-label { font-size: 9px; color: #888; text-align: center; line-height: 1.3; font-family: 'Hiragino Sans', sans-serif; }
.palette-btn:hover { background: #f0e8d8; border-color: #c09040; transform: translateY(-1px); }
.palette-btn.selected { background: #fde898; border-color: #b87820; box-shadow: 0 0 0 2px rgba(184,120,32,.3); }

/* ボタン */
.sc-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  transition: all .14s;
  line-height: 1.4;
  white-space: nowrap;
}
.sc-btn-primary { background: linear-gradient(135deg,#3c2005,#6a3808); color: #ffd060; border-color: #6a3808; box-shadow: 0 2px 8px rgba(0,0,0,.22); }
.sc-btn-primary:hover { background: linear-gradient(135deg,#5a3010,#8a5018); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.28); }
.sc-btn-ghost { background: #f5edd8; color: #4a2c08; border-color: #c89830; }
.sc-btn-ghost:hover { background: #ede4c8; transform: translateY(-1px); }
.sc-btn-danger { background: #fff0f0; color: #b01828; border-color: #d89090; }
.sc-btn-danger:hover { background: #ffe0e0; }
.sc-btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.save-form { display: flex; flex-direction: column; gap: 8px; }
.sc-input {
  width: 100% !important;
  padding: 8px 12px !important;
  border: 2px solid #d0b880 !important;
  border-radius: 6px !important;
  font-size: 14px !important;
  box-sizing: border-box;
  transition: border-color .15s !important;
}
.sc-input:focus { border-color: #a07830 !important; outline: none !important; box-shadow: 0 0 0 3px rgba(160,120,48,.2) !important; }

/* ヘルプ */
.help-text { font-size: 12px; color: #888; line-height: 1.7; margin: 8px 0 0; }
.help-list { list-style: none; padding: 0; margin: 0; font-size: 12px; color: #555; display: flex; flex-direction: column; gap: 8px; }
.help-list li { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.green { background: rgba(30,160,70,.85); }
.dot.red   { background: rgba(200,30,30,.85); }

/* ============================================================
   囲い一覧
   ============================================================ */
.castles-list { display: flex; flex-direction: column; gap: 10px; }
.castle-item {
  padding: 12px 14px;
  border: 1px solid #e8d8bc;
  border-radius: 8px;
  background: linear-gradient(145deg,#fefbf4,#f8edd8);
  transition: box-shadow .15s, transform .15s;
}
.castle-item:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); transform: translateY(-1px); }
.castle-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.castle-name { font-size: 14px; font-weight: 800; color: #1e0e00; }
.castle-meta { font-size: 11px; color: #aaa; }
.castle-sc {
  display: block;
  background: #f0ead8;
  border: 1px solid #d8c8a0;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  color: #555;
  margin-bottom: 8px;
  word-break: break-all;
  cursor: pointer;
  transition: background .14s;
}
.castle-sc:hover { background: #e8dcc0; color: #3a2000; }
.castle-btns { display: flex; gap: 6px; }

/* ============================================================
   トースト
   ============================================================ */
.shogi-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  z-index: 999999;
  transform: translateY(60px);
  opacity: 0;
  transition: transform .28s cubic-bezier(.2,.8,.3,1.1), opacity .28s;
  max-width: 300px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  pointer-events: none;
}
.shogi-toast-show { transform: translateY(0); opacity: 1; }
.shogi-toast-success { background: linear-gradient(135deg,#1a5828,#228040); }
.shogi-toast-error   { background: linear-gradient(135deg,#7a1020,#b01830); }
.shogi-toast-info    { background: linear-gradient(135deg,#183870,#2050a0); }
.shogi-toast-check   { background: linear-gradient(135deg,#7a3800,#b85800); }
.shogi-toast-win     { background: linear-gradient(135deg,#380070,#6010b0); }

/* ============================================================
   フロントエンド (ショートコード)
   ============================================================ */
.shogi-shortcode-wrap { margin: 24px 0; display: inline-block; max-width: 100%; }
.shogi-sc-title { font-size: 18px; font-weight: 800; color: #1e0e00; margin: 0 0 12px; font-family: 'Hiragino Mincho ProN','Yu Mincho',serif; }
.shogi-shortcode-root { display: inline-block; max-width: 100%; overflow-x: auto; }
.sc-reset-btn { margin-top: 12px; display: inline-flex; }
.shogi-error { color: #b01828; font-weight: 700; }

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 860px) {
  .shogi-admin-app { flex-direction: column; align-items: stretch; }
  .shogi-sidebar { max-width: 100%; min-width: 0; }
  .shogi-board-col { overflow-x: auto; padding-bottom: 4px; }
}

@media (max-width: 540px) {
  .shogi-admin-header h1 { font-size: 18px; }
  .sidebar-block { padding: 12px; }
  .palette-grid { grid-template-columns: repeat(4,1fr); gap: 3px; }
  .shogi-modal-box { padding: 18px 16px; min-width: 230px; }
  .shogi-modal-choices { gap: 12px; }
  .promo-choice { padding: 10px 14px; }
  .shogi-toast { right: 12px; bottom: 12px; font-size: 12px; padding: 9px 14px; }
  .mochigoma { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 390px) {
  .shogi-mode-btn { font-size: 12px; padding: 8px 6px; }
  .sc-btn { font-size: 12px; padding: 6px 10px; }
  .palette-btn { padding: 4px 1px; }
}

/* ============================================================
   印刷
   ============================================================ */
@media print {
  .shogi-sidebar, .shogi-mode-tabs, .shogi-toast, .shogi-modal-overlay { display: none !important; }
  .shogi-board { box-shadow: none; border: 2px solid #000; }
}

/* ============================================================
   言語切替ボタン / Language Toggle Button
   ============================================================ */
.shogi-admin-header-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.shogi-lang-btn {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 14px;
  letter-spacing: .06em;
  border-radius: 20px;
  min-width: 44px;
  text-align: center;
}
.shogi-lang-btn:hover {
  background: #ede4cc !important;
  transform: translateY(-1px);
}

/* フロントエンドのボタン行 */
.sc-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.sc-lang-btn-front {
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 20px;
  font-weight: 800;
  letter-spacing: .06em;
}

/* ============================================================
   詰将棋 管理画面: ステップバー
   ============================================================ */
.tsume-step-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8f4eb;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
}
.tsume-step {
  color: #999;
  padding: 4px 10px;
  border-radius: 20px;
}
.tsume-step.tsume-step-active {
  color: #fff;
  background: #8b5e2f;
}
.tsume-step-arrow {
  color: #bbb;
  font-size: 12px;
}

/* ============================================================
   詰将棋 管理画面: 持ち駒エディター
   ============================================================ */
.hand-editor-section {
  margin-bottom: 12px;
}
.hand-editor-title {
  font-size: 12px;
  font-weight: 700;
  color: #5a3e1b;
  margin-bottom: 6px;
  padding-left: 2px;
}
.hand-editor-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.hand-editor-item {
  display: flex;
  align-items: center;
  gap: 3px;
  background: #fdf8ef;
  border: 1px solid #e0c890;
  border-radius: 6px;
  padding: 3px 4px;
  font-size: 12px;
}
.hand-piece-name {
  font-family: 'Yu Mincho', 'Hiragino Mincho ProN', serif;
  font-weight: 700;
  font-size: 13px;
  color: #3a2a10;
  min-width: 14px;
  text-align: center;
}
.hand-count-btn {
  background: #e8d8b0;
  border: 1px solid #c8a860;
  border-radius: 3px;
  color: #5a3e1b;
  font-size: 11px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.hand-count-btn:hover {
  background: #d4b878;
}
.hand-count-btn:disabled {
  background: #d8cbb8;
  border-color: #b8a888;
  color: #a09070;
  cursor: not-allowed;
  opacity: 0.55;
}
.hand-fill-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  font-size: 12px;
  padding: 6px 10px;
  text-align: center;
}
.hand-count-num {
  font-size: 12px;
  font-weight: 700;
  color: #3a2a10;
  min-width: 14px;
  text-align: center;
}

/* ============================================================
   詰将棋 管理画面: 解答入力棋譜
   ============================================================ */
.tsume-kifu-record {
  background: #f8f4eb;
  border: 1px solid #e0c890;
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 60px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 13px;
}
.kifu-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border-bottom: 1px solid #f0e4c0;
}
.kifu-row:last-child { border-bottom: none; }
.kifu-num {
  color: #999;
  font-size: 11px;
  min-width: 20px;
  text-align: right;
}
.kifu-move {
  font-weight: 600;
  font-size: 13px;
}
.kifu-sente { color: #1a4a8a; }
.kifu-gote  { color: #8a1a1a; }
.kifu-auto  { opacity: 0.65; font-style: italic; }
.kifu-empty { color: #aaa; font-size: 12px; }
.tsume-moves-badge {
  background: #6a3b1a;
  color: #fff;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 12px;
  font-weight: 700;
}

/* ============================================================
   詰将棋 フロントエンド
   ============================================================ */
.shogi-tsume-wrap .shogi-sc-title {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tsume-move-badge {
  font-size: 11px;
  font-weight: 700;
  background: #8b5e2f;
  color: #fff;
  padding: 2px 10px;
  border-radius: 12px;
}

/* 結果表示 */
.tsume-result {
  min-height: 32px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  padding: 6px 0;
  transition: all 0.2s;
  border-radius: 6px;
  margin: 6px 0;
}
.tsume-correct {
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  color: #1b5e20;
  border: 2px solid #4caf50;
  animation: tsume-pop 0.4s ease;
}
.tsume-wrong {
  background: linear-gradient(135deg, #fce4ec, #f8bbd9);
  color: #880e4f;
  border: 2px solid #e91e63;
  animation: tsume-shake 0.3s ease;
}
@keyframes tsume-pop {
  0%   { transform: scale(0.95); opacity: 0; }
  60%  { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes tsume-shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-6px); }
  75%     { transform: translateX(6px); }
}

/* 棋譜（フロントエンド）*/
.tsume-kifu-title {
  font-size: 12px;
  font-weight: 700;
  color: #8b5e2f;
  margin: 8px 0 4px;
  letter-spacing: 0.05em;
}
.tsume-kifu-front {
  background: #f8f4eb;
  border: 1px solid #e0c890;
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 40px;
  max-height: 150px;
  overflow-y: auto;
  font-size: 13px;
  margin-bottom: 6px;
}

/* ヒントボタン */
.tsume-hint-btn {
  background: linear-gradient(135deg, #fff8e1, #fff3cd) !important;
  border-color: #f59f00 !important;
  color: #856404 !important;
  font-weight: 700;
}
.tsume-hint-btn:hover {
  background: linear-gradient(135deg, #fff3cd, #ffe066) !important;
  transform: translateY(-1px);
}
.tsume-hint-text {
  font-size: 12px;
  color: #856404;
  font-weight: 600;
  min-height: 18px;
  text-align: center;
  padding: 2px 0;
}

/* ヒントマス */
.cell-hint-from {
  background: rgba(255, 210, 50, 0.55) !important;
  box-shadow: inset 0 0 0 2px #f59f00;
  animation: hint-pulse 0.8s ease infinite alternate;
}
.cell-hint-to {
  background: rgba(255, 150, 0, 0.4) !important;
  box-shadow: inset 0 0 0 2px #e67e00;
  animation: hint-pulse 0.8s ease infinite alternate;
}
@keyframes hint-pulse {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

/* フリーモード: ターン表示なし */
.shogi-free-badge {
  font-size: 11px;
  background: #6b4a9a;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}

/* 詰将棋完成時: 保存ボタンパルス (v8.0) */
@keyframes tsume-save-pulse {
  0%,100% { transform: scale(1);    box-shadow: 0 0 0 3px rgba(255,200,32,0.5); }
  50%      { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(255,200,32,0.2); }
}

/* ============================================================
   Formation Tutorial v8.3 — 初期配置 → 囲い完成 ステップ表示
   ============================================================ */

/* ── モードタブバー ────────────────────────────────────────── */
.sc-mode-bar {
  display: flex;
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
  border: 2px solid #7a4e10;
  border-bottom: 3px solid #2c1600;
  margin-bottom: 0;
  box-shadow: 0 2px 0 #140800;
}
.sc-mode-tab {
  flex: 1;
  padding: 11px 6px;
  background: #efe0c0;
  border: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  color: #6a4010;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.02em;
  border-right: 1px solid #c8a060;
}
.sc-mode-tab:last-child { border-right: none; }
.sc-mode-tab-active {
  background: linear-gradient(160deg, #2c1600 0%, #4a2800 100%);
  color: #ffd060;
  cursor: default;
}
.sc-mode-tab:not(.sc-mode-tab-active):hover {
  background: #e2d0a8;
  color: #4a2c08;
}
.sc-tab-icon { font-size: 15px; line-height: 1; }

/* ── チュートリアルパネル ──────────────────────────────────── */
.sc-tutorial-controls {
  margin-top: 10px;
  padding: 12px 14px 14px;
  background: linear-gradient(160deg, #1a0e00 0%, #342000 100%);
  border: 1.5px solid #6a3c0a;
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* プログレスバー */
.sc-progress-wrap {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}
.sc-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #c89818 0%, #ffd060 50%, #ff9820 100%);
  background-size: 200% 100%;
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(.25,.8,.25,1);
  width: 0%;
  animation: sc-prog-shimmer 2.5s linear infinite;
}
.sc-progress-bar.sc-progress-complete {
  animation: none;
  background: linear-gradient(90deg, #4ec820, #80f040);
}
@keyframes sc-prog-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ステップ行 */
.sc-step-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
  min-height: 22px;
}
.sc-step-counter {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255,208,96,0.6);
  letter-spacing: 0.05em;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* 移動記述 (▲金 6九→7八) */
.sc-move-desc {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.38);
  font-style: italic;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  transition: color 0.22s, font-weight 0.22s;
}
.sc-move-desc.sc-move-prompt {
  color: rgba(255,208,96,0.5);
  font-style: normal;
}
.sc-move-desc.sc-move-added {
  color: #7ee850;
  font-style: normal;
  font-weight: 700;
  font-family: 'Hiragino Mincho ProN','Yu Mincho','Noto Serif JP',serif;
  letter-spacing: 0.06em;
}
.sc-move-desc.sc-move-complete {
  color: #ffd060;
  font-style: normal;
  font-weight: 800;
}

/* ナビゲーション行 */
.sc-nav-row {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.sc-nav-btn {
  flex: 1;
  text-align: center;
  padding: 8px 3px;
  font-size: 12px;
  min-width: 0;
}
.sc-nav-sm {
  flex: 0 0 32px;
  padding: 8px 0;
  font-size: 14px;
  text-align: center;
}
.sc-nav-play {
  flex: 0 0 72px;
  font-size: 12px;
  padding: 8px 4px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sc-nav-play.sc-btn-playing {
  background: rgba(255,100,50,0.18) !important;
  border-color: rgba(255,100,50,0.6) !important;
  color: #ff8060 !important;
}
.sc-nav-btn:disabled,
.sc-nav-sm:disabled,
.sc-nav-play:disabled {
  opacity: 0.22;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* キーボードヒント */
.sc-kbd-hint {
  font-size: 10.5px;
  color: rgba(255,255,255,0.22);
  text-align: center;
  letter-spacing: 0.01em;
  line-height: 1.6;
}
.sc-kbd-hint kbd {
  display: inline-block;
  padding: 0 4px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 3px;
  font-size: 9.5px;
  font-family: inherit;
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.35);
  margin: 0 1px;
}

/* ── チュートリアルのヒントマス (from/to) ──────────────────── */
/* from: 駒が移動してきた元のマス → 今は空のマス → 薄い枠で示す */
.sc-tutorial-active.shogi-board .cell-hint-from,
.shogi-board .sc-tutorial-active .cell-hint-from {
  background: rgba(160, 120, 20, 0.22) !important;
  box-shadow: inset 0 0 0 1.5px rgba(200, 160, 40, 0.45);
  animation: sc-hint-from-pulse 1.4s ease infinite alternate;
}
/* to: 駒が到着したマス → 明るく目立たせる */
.sc-tutorial-active.shogi-board .cell-hint-to,
.shogi-board .sc-tutorial-active .cell-hint-to {
  background: rgba(50, 180, 60, 0.22) !important;
  box-shadow: inset 0 0 0 2px rgba(60, 210, 70, 0.75),
              inset 0 0 12px rgba(50, 200, 60, 0.15);
  animation: sc-hint-to-pulse 0.9s ease infinite alternate;
}
/* boardEl に直接クラスが付く場合のフォールバック */
.sc-tutorial-active .cell-hint-from {
  background: rgba(160, 120, 20, 0.22) !important;
  box-shadow: inset 0 0 0 1.5px rgba(200, 160, 40, 0.45);
  animation: sc-hint-from-pulse 1.4s ease infinite alternate;
}
.sc-tutorial-active .cell-hint-to {
  background: rgba(50, 180, 60, 0.22) !important;
  box-shadow: inset 0 0 0 2px rgba(60, 210, 70, 0.75);
  animation: sc-hint-to-pulse 0.9s ease infinite alternate;
}
@keyframes sc-hint-from-pulse {
  from { opacity: 0.55; } to { opacity: 0.9; }
}
@keyframes sc-hint-to-pulse {
  from { opacity: 0.75; } to { opacity: 1; }
}

/* ── 駒ポップインアニメーション ────────────────────────────── */
@keyframes sc-pop {
  0%   { transform: scale(0.25) rotate(-8deg); opacity: 0; }
  55%  { transform: scale(1.18) rotate(2deg);  opacity: 1; }
  80%  { transform: scale(0.94) rotate(0deg);              }
  100% { transform: scale(1)    rotate(0deg);              }
}
.shogi-cell.sc-piece-pop .shogi-cell-inner {
  animation: sc-pop 0.38s cubic-bezier(.34,1.56,.64,1) both;
}

/* ── フリープレイコントロール ───────────────────────────────── */
.sc-free-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.sc-free-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
  font-style: italic;
  margin: 0;
  padding: 7px 11px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.06);
  line-height: 1.5;
}

/* ── レスポンシブ ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .sc-mode-tab { font-size: 12px; padding: 10px 5px; gap: 5px; }
  .sc-tutorial-controls { padding: 10px 10px 12px; }
  .sc-nav-btn { font-size: 12px; padding: 7px 2px; }
  .sc-nav-sm  { flex: 0 0 30px; font-size: 13px; }
  .sc-nav-play { flex: 0 0 64px; }
}
@media (max-width: 600px) {
  .sc-mode-tab { font-size: 12px; padding: 9px 3px; }
  .sc-tab-icon { font-size: 14px; }
  .sc-move-desc { font-size: 12px; }
  .sc-kbd-hint  { display: none; }
  .sc-nav-play  { flex: 0 0 54px; font-size: 11px; }
}
@media (max-width: 400px) {
  .sc-mode-tab { font-size: 11px; padding: 8px 2px; }
  .sc-tab-icon { display: none; }
  .sc-nav-sm   { flex: 0 0 26px; font-size: 12px; }
  .sc-nav-play { flex: 0 0 46px; font-size: 10px; }
}

/* ============================================================
   管理画面 手順入力モード（v8.4）
   ============================================================ */

/* 棋譜記録エリア（管理画面用・tsume-kifu-record スタイルを継承） */
#admin-kifu-record {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
#admin-kifu-record::-webkit-scrollbar { width: 4px; }
#admin-kifu-record::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 2px; }

/* 1手戻すボタン — disabled 時 */
#btn-undo-record:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 手数バッジ（囲い一覧） */
.castle-meta {
  font-size: 11px;
  color: #aaa;
  background: rgba(255,255,255,.07);
  border-radius: 10px;
  padding: 2px 8px;
  font-weight: 600;
}
