/* Редактор доски /chess-board-editor и задачи «Собери все награды» (docs/board_editor.md). */

.be-page { max-width: 1240px; margin: 1rem auto 2rem; padding: 0 12px; color: var(--text-1, #212529); }
.be-crumbs { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 .5rem; padding: 0; list-style: none; font-size: .9rem; font-weight: 600; }
.be-crumbs li + li::before { content: '/'; margin-right: .25rem; color: var(--text-2, #6c757d); }
.be-crumbs a { color: inherit; }
.be-page h1 { font-family: inherit; font-size: 1.8rem; font-weight: 800; margin: 0 0 .25rem; }
.be-lead { color: var(--text-2, #6c757d); margin-bottom: 1rem; max-width: 820px; }
.be-h2 { font-size: 1.25rem; font-weight: 800; margin: 1.5rem 0 .75rem; }
.be-banner { margin-bottom: .75rem; }

/* ---------- раскладка: палитра | доска | инструменты ---------- */
.be-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr) 240px; gap: 18px; align-items: start; }
.be-panel { background: var(--surface-1, #fff); border: 1px solid var(--border, #dee2e6); border-radius: 14px; padding: 12px; }
html[data-theme="dark"] .be-panel { background: var(--surface-2, #1e293b); }
.be-center { min-width: 0; }
.be-side .btn-block + .btn-block { margin-top: 6px; }
.be-side .btn, .be-solve-side .btn { white-space: normal; }
@media (max-width: 1199px) {
  .be-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .be-center { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 640px) {
  .be-layout { grid-template-columns: minmax(0, 1fr); }
  .be-page h1 { font-size: 1.45rem; }
}

.be-heading { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: .9rem; margin: 10px 0 6px; }
.be-heading:first-child { margin-top: 0; }
.be-hint { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(13, 110, 253, .12); color: #0d6efd; font-size: .75rem; cursor: help; }
.be-hint-text { font-size: .8rem; color: var(--text-2, #6c757d); margin: 6px 0 10px; }
.be-tools { display: flex; gap: 6px; }
.be-tools .btn { flex: 1 1 0; }
.be-mode { display: flex; width: 100%; }
.be-mode .btn { flex: 1 1 0; }

/* ---------- палитра ---------- */
.be-pal-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin-bottom: 4px; }
.be-pal-item {
  position: relative; display: grid; place-items: center; aspect-ratio: 1 / 1; padding: 2px; min-width: 0;
  border: 2px solid transparent; border-radius: 8px; background: rgba(0, 0, 0, .04); cursor: pointer;
}
html[data-theme="dark"] .be-pal-item { background: rgba(255, 255, 255, .08); }
.be-pal-item img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.be-pal-item:hover { border-color: rgba(13, 110, 253, .45); }
.be-pal-item.active { border-color: #0d6efd; background: rgba(13, 110, 253, .14); box-shadow: 0 0 0 2px rgba(13, 110, 253, .25); }
.be-pal-guard::after {
  content: ''; position: absolute; top: 1px; right: 1px; width: 40%; height: 40%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e5383b' d='M12 2 4 5v6c0 5 3.4 9.5 8 11 4.6-1.5 8-6 8-11V5z'/%3E%3Cpath fill='%23fff' d='M11 7h2v8h-2zM8 10h8v2H8z'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- доска ---------- */
.be-board-wrap { position: relative; width: 100%; max-width: 640px; margin: 0 auto; padding-right: 14px; }
.be-board, .be-board.cg-board-wrap { position: relative; width: 100%; height: auto; }
.be-board::before { content: ''; display: block; padding-top: 100%; }
.be-board .cg-board { background-image: url('/cg/assets/images/board/brown.svg'); background-size: cover; }
.be-stamping .cg-board { cursor: copy; }
.be-board piece.tree, .be-board piece.rock, .be-board piece.bricks, .be-board piece.dragon, .be-board piece.spikes,
.be-board piece.candy, .be-board piece.star, .be-board piece.icecream, .be-board piece.gem {
  background-size: 82%; background-position: center; background-repeat: no-repeat;
}
.be-board piece.tree { background-image: url('/img/board_editor/tree.svg'); }
.be-board piece.rock { background-image: url('/img/board_editor/rock.svg'); }
.be-board piece.bricks { background-image: url('/img/board_editor/bricks.svg'); }
.be-board piece.dragon { background-image: url('/img/board_editor/dragon.svg'); }
.be-board piece.spikes { background-image: url('/img/board_editor/spikes.svg'); }
.be-board piece.candy { background-image: url('/img/board_editor/candy.svg'); }
.be-board piece.star { background-image: url('/img/board_editor/star.svg'); }
.be-board piece.icecream { background-image: url('/img/board_editor/icecream.svg'); }
.be-board piece.gem { background-image: url('/img/board_editor/gem.svg'); }
/* часовой: чёрная фигура с красным щитом */
.be-board piece[class*="guard-"] {
  background-repeat: no-repeat, no-repeat; background-size: 38%, cover; background-position: 96% 4%, center;
  filter: drop-shadow(0 0 3px rgba(229, 56, 59, .85));
}
.be-board piece.guard-pawn { background-image: var(--be-shield), url('/cg/assets/images/pieces/cburnett/bP.svg'); }
.be-board piece.guard-knight { background-image: var(--be-shield), url('/cg/assets/images/pieces/cburnett/bN.svg'); }
.be-board piece.guard-bishop { background-image: var(--be-shield), url('/cg/assets/images/pieces/cburnett/bB.svg'); }
.be-board piece.guard-rook { background-image: var(--be-shield), url('/cg/assets/images/pieces/cburnett/bR.svg'); }
.be-board piece.guard-queen { background-image: var(--be-shield), url('/cg/assets/images/pieces/cburnett/bQ.svg'); }
.be-board piece.guard-king { background-image: var(--be-shield), url('/cg/assets/images/pieces/cburnett/bK.svg'); }
.be-board {
  --be-shield: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23e5383b' d='M12 2 4 5v6c0 5 3.4 9.5 8 11 4.6-1.5 8-6 8-11V5z'/%3E%3Cpath fill='%23fff' d='M11 7h2v8h-2zM8 10h8v2H8z'/%3E%3C/svg%3E");
}

.be-status { display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 32px; margin-top: 6px; font-weight: 700; }
.be-msg-ok { color: #2f9e44; }
.be-msg-warn { color: #e8590c; }
.be-msg-error { color: #e5383b; }
.be-count { display: inline-flex; align-items: center; gap: 4px; }
.be-count img { width: 22px; height: 22px; }
.be-fen { display: flex; align-items: center; gap: 6px; max-width: 640px; margin: 4px auto 0; }
.be-fen label { margin: 0; font-weight: 700; font-size: .85rem; }
.be-fen input { font-family: monospace; font-size: .8rem; }
.be-save { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border, #dee2e6); }
.be-save .form-control { margin-bottom: 6px; }

/* ---------- сохранённые позиции ---------- */
.be-saved-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.be-saved-card { border: 1px solid var(--border, #dee2e6); border-radius: 12px; padding: 8px; background: var(--surface-1, #fff); }
html[data-theme="dark"] .be-saved-card { background: var(--surface-2, #1e293b); }
.be-saved-open { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.be-saved-title { font-weight: 700; font-size: .85rem; margin: 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.be-saved-actions { display: flex; gap: 6px; }
.be-saved-actions .btn { flex: 1 1 0; }
.be-pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 12px; }
.be-mini { display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; aspect-ratio: 1 / 1; border-radius: 4px; overflow: hidden; }
.be-mini-sq { position: relative; display: block; }
.be-mini-sq::before { content: ''; display: block; padding-top: 100%; }
.be-mini-sq img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.be-light { background: #f0d9b5; }
.be-dark { background: #b58863; }
.be-mini-guard { filter: drop-shadow(0 0 2px rgba(229, 56, 59, .95)); }

/* ---------- окно «Добавить в курс» ---------- */
.be-dlg-backdrop { position: fixed; inset: 0; z-index: 1050; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px 12px; background: rgba(15, 23, 42, .55); overflow-y: auto; }
.be-dlg { width: 100%; max-width: 540px; border-radius: 14px; background: var(--surface-1, #fff); color: var(--text-1, #212529); box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
html[data-theme="dark"] .be-dlg { background: var(--surface-2, #1e293b); }
.be-dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 6px; }
.be-dlg-head h3 { font-size: 1.15rem; font-weight: 800; margin: 0; }
.be-dlg-head .close { color: inherit; }
.be-dlg-body { padding: 6px 16px 16px; }
.be-dlg-kind { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border, #dee2e6); }
html[data-theme="dark"] .be-select, html[data-theme="dark"] .be-dlg .form-control { background: #0f172a; color: #e2e8f0; border-color: #334155; }
html[data-theme="dark"] .be-select option { background: #0f172a; color: #e2e8f0; }
html[data-theme="dark"] .be-select option:disabled { color: #64748b; }
.be-select option:disabled { color: #8a8f98; }

/* ---------- SEO-текст ---------- */
.be-seo { margin-top: 2rem; max-width: 900px; color: var(--text-1, #212529); }
.be-seo ul { padding-left: 1.2rem; }
.be-seo li { margin-bottom: .35rem; }

/* ---------- решатель ---------- */
.be-solve { max-width: 960px; margin: 0 auto; }
.be-solve-task { font-size: 1.15rem; font-weight: 800; text-align: center; margin: 4px 0 10px; }
.be-solve-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; align-items: flex-start; }
.be-solve-board { flex: 1 1 420px; max-width: 600px; margin: 0; }
.be-solve-side { flex: 0 1 260px; min-width: 220px; }
.be-solve-count { display: flex; align-items: center; gap: 8px; font-size: 1.2rem; font-weight: 800; }
.be-solve-count img { width: 34px; height: 34px; }
.be-solve-mistakes { color: #e8590c; font-weight: 700; margin-top: 4px; }
.be-solve-actions { margin-top: 12px; }
.be-solve-actions .btn-block + .btn-block, .be-solve-actions .btn-block + div { margin-top: 8px; }
.be-star { width: 30px; margin-right: 4px; }
.be-kp-overlay { position: fixed; inset: 0; z-index: 1060; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(20, 30, 50, .55); }
.be-kp-box { width: 100%; max-width: 420px; padding: 24px 20px 20px; border-radius: 24px; background: #fff; color: #2b2b3a; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); animation: bePop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes bePop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.be-kp-title { font-size: 1.6rem; font-weight: 900; color: #ff6a2b; margin-bottom: 6px; }
.be-kp-sub { font-weight: 700; margin-bottom: 14px; }
.be-kp-next { display: block; padding: .8rem 1rem; border-radius: 999px; background: #ff8a2b; color: #fff !important; font-weight: 900; font-size: 1.2rem; text-decoration: none !important; box-shadow: 0 5px 0 #d9681a; }
.be-kp-again { margin-top: 12px; border: 0; background: none; color: #2b6fd6; font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .be-kp-box { animation: none; } }
