/* AI lab — chess and adversarial search (/lab#chess). Board, original piece set, 3D view, the AI's mind panel. */

.lab-panel.lab-chess {
    grid-template-columns: minmax(0, 1fr) 340px;
}

.chess-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.chess-live {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.chess-stage {
    gap: 10px;
}

/* ---------- player cards ---------- */
.chess-player {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 6px 12px;
    border: 1px solid #22314b;
    border-radius: 12px;
    background: linear-gradient(135deg, #152238 0%, #101a2b 100%);
    color: #f7f1e4;
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.chess-player.is-turn {
    border-color: rgba(212, 188, 122, 0.7);
    box-shadow: 0 0 0 3px rgba(212, 188, 122, 0.14), 0 8px 22px rgba(11, 19, 34, 0.25);
}

.chess-player-ico {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(212, 188, 122, 0.55);
    border-radius: 50%;
    color: #d4bc7a;
}

.chess-player-ico svg { width: 18px; height: 18px; }

.chess-player-dot {
    flex: none;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.5px solid #d4bc7a;
}
.chess-player-dot.is-w { background: #fbf6e9; }
.chess-player-dot.is-b { background: #22355a; }

.chess-player-name {
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chess-think {
    display: none;
    gap: 4px;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(212, 188, 122, 0.14);
    color: #e2c27a;
    font-size: 12px;
    white-space: nowrap;
}
.chess-think i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    animation: chess-dot 1s ease-in-out infinite;
}
.chess-think i:nth-child(2) { animation-delay: 0.15s; }
.chess-think i:nth-child(3) { animation-delay: 0.3s; }
.chess-player.is-thinking .chess-think { display: inline-flex; }
@keyframes chess-dot { 0%, 100% { opacity: 0.25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.chess-taken {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0;
    margin-inline-start: auto;
    direction: ltr;
}
.cp-mini { display: inline-block; width: 19px; height: 19px; margin-inline-end: -5px; }
.cp-mini svg { width: 100%; height: 100%; }
.chess-adv { margin-inline-start: 9px; color: #e2c27a; font-size: 12.5px; }

/* ---------- arena: evaluation bar + board ---------- */
.chess-arena {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
}

.chess-evalbar {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: linear-gradient(180deg, #22355a, #0d1629);
    box-shadow: inset 0 0 0 1px rgba(212, 188, 122, 0.35);
}
.chess-evalbar i {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 50%;
    background: linear-gradient(180deg, #fffdf7, #e6d8b6);
    transition: height 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chess-evalbar::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    top: 50%;
    height: 1px;
    background: rgba(176, 141, 62, 0.8);
}
.chess-evalbar b {
    position: absolute;
    left: 50%;
    bottom: 6px;
    z-index: 1;
    color: #152238;
    font-size: 10px;
    font-weight: 800;
    writing-mode: vertical-rl;
    transform: translateX(-50%) rotate(180deg);
    direction: ltr;
}
.chess-evalbar b.is-low { bottom: auto; top: 6px; color: #f3e6c2; }

.chess-board-wrap {
    position: relative;
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
}

.chess-table {
    position: relative;
    padding: 16px;
    border-radius: 16px;
    background: var(--ch-frame);
    box-shadow: 0 18px 40px rgba(11, 19, 34, 0.32), inset 0 0 0 1px var(--ch-frame-line), inset 0 0 0 6px var(--ch-frame-in), inset 0 0 0 7px var(--ch-frame-line);
    transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-style: preserve-3d;
}

.chess-board {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 3px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    outline: none;
    transform-style: preserve-3d;
    box-shadow: 0 0 0 1px var(--ch-frame-line);
}
.chess-board:focus-visible { box-shadow: 0 0 0 3px #8ab4f8; }
.chess-board.is-locked { cursor: default; }

.chess-squares,
.chess-pieces,
.chess-arrows {
    position: absolute;
    inset: 0;
}
.chess-arrows { width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.chess-pieces { pointer-events: none; transform-style: preserve-3d; }

.sq {
    position: absolute;
    width: 12.5%;
    height: 12.5%;
    background: var(--ch-light);
}
.sq.is-dark { background: var(--ch-dark); }
.sq.is-dark::after,
.sq.is-light::after { content: none; }
.chess-squares::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: var(--ch-texture, none);
    pointer-events: none;
}

.sq-file,
.sq-rank {
    position: absolute;
    z-index: 2;
    font: 700 11px/1 "Vazirmatn", Tahoma, sans-serif;
    opacity: 0.85;
    pointer-events: none;
}
.sq-file { right: 4px; bottom: 3px; }
.sq-rank { left: 4px; top: 4px; }
.sq.is-light .sq-file, .sq.is-light .sq-rank { color: var(--ch-dark-text, var(--ch-dark)); }
.sq.is-dark .sq-file, .sq.is-dark .sq-rank { color: var(--ch-light); }

.sq.is-last { box-shadow: inset 0 0 0 999px var(--ch-last); }
.sq.is-sel { box-shadow: inset 0 0 0 999px var(--ch-sel); }
.sq.is-check { background-image: radial-gradient(circle, rgba(255, 70, 70, 0.95) 0%, rgba(230, 40, 40, 0.55) 40%, transparent 72%); }
.sq.is-hover { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.75); }
.sq.is-cursor { box-shadow: inset 0 0 0 3px #8ab4f8; }
.sq.is-target::before {
    content: "";
    position: absolute;
    z-index: 2;
    left: 36%;
    top: 36%;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: var(--ch-dot);
}
.sq.is-take::before {
    content: "";
    position: absolute;
    z-index: 2;
    inset: 4%;
    border-radius: 50%;
    border: 5px solid var(--ch-dot);
}

/* ---------- pieces (an original set; the king wears an eight-pointed shamseh) ---------- */
.cp {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
    width: 12.5%;
    height: 12.5%;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
    will-change: transform;
}
.cp.no-anim { transition: none; }
.cp.is-drag { z-index: 6; }
.cp.is-drag svg { filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.4)); }
.cp.is-gone { opacity: 0; }
.cp svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.3));
    transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.cp .b { stroke-width: 2.8; stroke-linejoin: round; }
.cp .l { fill: none; stroke-width: 2.2; stroke-linecap: round; opacity: 0.75; }
.cp.is-w .b { fill: url(#cpW); stroke: #1e2b42; }
.cp.is-w .l { stroke: #8a6c28; }
.cp.is-w .e { fill: #1e2b42; }
.cp.is-b .b { fill: url(#cpB); stroke: #d9b960; }
.cp.is-b .l { stroke: #d9b960; }
.cp.is-b .e { fill: #f2dc9a; }

/* ---------- arrows: the AI's current best move (gold), its expected continuation, a hint (teal) ---------- */
.chess-arrows line { stroke-width: 16; stroke-linecap: round; }
.chess-arrows .ar-gold { stroke: #e2b84a; opacity: 0.85; filter: drop-shadow(0 0 6px rgba(226, 184, 74, 0.7)); }
.chess-arrows .ar-teal { stroke: #26a69a; opacity: 0.85; filter: drop-shadow(0 0 6px rgba(38, 166, 154, 0.6)); }
.chess-arrows .ar-soft { stroke: #8ab4f8; opacity: 0.4; stroke-width: 11; }
.chess-arrows .ar-scan { stroke: #8ab4f8; opacity: 0.55; stroke-width: 9; stroke-dasharray: 18 14; animation: chess-scan 0.8s linear infinite; }
@keyframes chess-scan { to { stroke-dashoffset: -64; } }

/* ---------- themes ---------- */
.chess-board-wrap,
.chess-board-wrap[data-theme="firoozeh"] {
    --ch-frame: linear-gradient(145deg, #1b2c49 0%, #101a2b 100%);
    --ch-frame-line: rgba(212, 188, 122, 0.55);
    --ch-frame-in: #142139;
    --ch-light: #f3ead5;
    --ch-dark: #2e6e66;
    --ch-dark-text: #2e6e66;
    --ch-texture: url("../Images/ornament/girih.svg") 0 0 / 25% 25% repeat;
    --ch-last: rgba(226, 184, 74, 0.38);
    --ch-sel: rgba(226, 184, 74, 0.55);
    --ch-dot: rgba(16, 26, 43, 0.35);
}
.chess-board-wrap[data-theme="firoozeh"] .chess-squares::before { opacity: 0.12; mix-blend-mode: multiply; }

.chess-board-wrap[data-theme="night"] {
    --ch-frame: radial-gradient(circle at 30% 0%, #1b2a4a 0%, #070c18 70%);
    --ch-frame-line: rgba(138, 180, 248, 0.45);
    --ch-frame-in: #0a1222;
    --ch-light: #2a3b5e;
    --ch-dark: #141f37;
    --ch-dark-text: #8ab4f8;
    --ch-texture: linear-gradient(rgba(138, 180, 248, 0.08) 1px, transparent 1px) 0 0 / 12.5% 12.5%, linear-gradient(90deg, rgba(138, 180, 248, 0.08) 1px, transparent 1px) 0 0 / 12.5% 12.5%;
    --ch-last: rgba(138, 180, 248, 0.28);
    --ch-sel: rgba(138, 180, 248, 0.45);
    --ch-dot: rgba(138, 180, 248, 0.55);
}
.chess-board-wrap[data-theme="night"] .cp.is-b .b { fill: url(#cpN); stroke: #f0d58a; }
.chess-board-wrap[data-theme="night"] .sq.is-dark .sq-file,
.chess-board-wrap[data-theme="night"] .sq.is-dark .sq-rank { color: #8ab4f8; }

.chess-board-wrap[data-theme="wood"] {
    --ch-frame: linear-gradient(145deg, #6b4423 0%, #3e2612 100%);
    --ch-frame-line: rgba(240, 217, 181, 0.45);
    --ch-frame-in: #4d301a;
    --ch-light: #efd9b4;
    --ch-dark: #b3825a;
    --ch-dark-text: #8a5d39;
    --ch-texture: repeating-linear-gradient(100deg, rgba(90, 50, 20, 0.05) 0 2px, transparent 2px 7px);
    --ch-last: rgba(205, 210, 106, 0.55);
    --ch-sel: rgba(20, 85, 30, 0.45);
    --ch-dot: rgba(20, 30, 20, 0.3);
}

/* ---------- 3D: the table tilts, the pieces stand up ---------- */
.chess-board-wrap.is-3d { perspective: 1100px; perspective-origin: 50% 0%; }
.chess-board-wrap.is-3d .chess-table { transform: translateY(-6%) rotateX(34deg) scale(0.92); transform-origin: 50% 70%; }
.chess-board-wrap.is-3d .cp { transform-style: preserve-3d; }
.chess-board-wrap.is-3d .cp svg { transform: rotateX(-34deg) translateY(-14%) scale(1.22); transform-origin: 50% 90%; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, 0.35)); }
.chess-board-wrap.is-3d .cp::before {
    content: "";
    position: absolute;
    left: 16%;
    right: 16%;
    bottom: 6%;
    height: 22%;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(0, 0, 0, 0.45), transparent);
}
.chess-board-wrap.is-3d .sq-file,
.chess-board-wrap.is-3d .sq-rank { opacity: 0.6; }

/* ---------- promotion and game-over overlays ---------- */
.chess-promo,
.chess-over {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(7, 12, 24, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.chess-promo[hidden],
.chess-over[hidden] { display: none; }

.chess-promo-box,
.chess-over-box {
    padding: 16px 20px;
    border: 1px solid rgba(212, 188, 122, 0.6);
    border-radius: 14px;
    background: linear-gradient(145deg, #1b2c49, #101a2b);
    color: #f7f1e4;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    animation: chess-pop 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes chess-pop { from { opacity: 0; transform: scale(0.92) translateY(8px); } to { opacity: 1; transform: none; } }
.chess-promo-box p { margin: 0 0 10px; font-weight: 700; }
.chess-promo-box div { display: flex; gap: 8px; }
.chess-promo-box .cp {
    position: static;
    width: 64px;
    height: 64px;
    padding: 4px;
    border: 1px solid rgba(212, 188, 122, 0.4);
    border-radius: 10px;
    background: #f3ead5;
    cursor: pointer;
    transform: none;
}
.chess-promo-box .cp:hover,
.chess-promo-box .cp:focus-visible { outline: 3px solid #e2c27a; }
.chess-over-box b { display: block; margin-bottom: 4px; color: #e2c27a; font-size: 24px; }
.chess-over-box span { display: block; margin-bottom: 14px; color: rgba(247, 241, 228, 0.8); font-size: 14px; }
.chess-over-box div { display: flex; gap: 8px; justify-content: center; }

/* ---------- toolbar under the board ---------- */
.chess-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.chess-toolbar .lab-btn { display: inline-flex; align-items: center; gap: 6px; }
.chess-toolbar .lab-btn svg { width: 16px; height: 16px; }
.lab-btn:disabled { opacity: 0.45; cursor: default; }
.lab-chess.is-reviewing .chess-review-note { display: block; }
.chess-review-note {
    display: none;
    margin: 0;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(138, 180, 248, 0.14);
    color: #3a5c8f;
    font-size: 13px;
    text-align: center;
}

.lab-chess .lab-console { margin-top: 0; min-height: 150px; }
.lab-chess .lab-console-body { max-height: 220px; }

/* ---------- side panel ---------- */
.chess-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.chess-subtabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 12px;
    background: var(--ac-paper-2, #ebe6db);
}
.chess-subtab {
    padding: 8px 6px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ac-navy, #152238);
    font: 700 13px/1.4 inherit;
    font-family: inherit;
    cursor: pointer;
}
.chess-subtab.is-active { background: var(--ac-navy, #152238); color: #e2c27a; box-shadow: 0 4px 12px rgba(21, 34, 56, 0.25); }
.chess-pane { display: grid; gap: 12px; align-content: start; }
.chess-pane[hidden] { display: none; }

.chess-label {
    margin: 0 0 6px;
    color: var(--ac-muted, #5c6470);
    font-size: 12.5px;
    font-weight: 700;
}

.chess-seg {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.chess-seg button {
    padding: 8px 4px;
    border: 1px solid var(--ac-line, #ddd6c8);
    border-radius: 9px;
    background: #fff;
    color: var(--ac-navy, #152238);
    font: 600 12.5px/1.45 inherit;
    font-family: inherit;
    cursor: pointer;
}
.chess-seg button.is-on { border-color: var(--ac-navy, #152238); background: var(--ac-navy, #152238); color: #e2c27a; }
.chess-color-row .chess-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chess-color-row .chess-seg i { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid #b08d3e; }
.chess-color-row .chess-seg i.is-w { background: #fbf6e9; }
.chess-color-row .chess-seg i.is-b { background: #22355a; }
.chess-color-row .chess-seg i.is-r { background: linear-gradient(90deg, #fbf6e9 50%, #22355a 50%); }

.chess-level {
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #152238, #1e3354);
    color: #f7f1e4;
}
.chess-level label > span { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.chess-level output { color: #e2c27a; }
.chess-level input[type="range"] { width: 100%; margin: 8px 0 4px; accent-color: #d4bc7a; }
.chess-level-desc { margin: 0; color: rgba(247, 241, 228, 0.7); font-size: 12px; line-height: 1.7; }

.chess-moves-box {
    max-height: 210px;
    overflow: auto;
    border: 1px solid #22314b;
    border-radius: 10px;
    background: #0b1322;
    direction: ltr;
}
.chess-moves { margin: 0; padding: 4px 0; list-style: none; }
.chess-moves li {
    display: grid;
    grid-template-columns: 38px 1fr 1fr;
    align-items: center;
    padding: 0 6px;
}
.chess-moves li:nth-child(odd) { background: rgba(255, 255, 255, 0.03); }
.chess-moves .mv-no { color: #75849e; font-size: 12px; text-align: center; }
.chess-moves .mv {
    margin: 1px;
    padding: 3px 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #dfe7f5;
    font: 600 13.5px/1.6 "Vazirmatn", Tahoma, sans-serif;
    text-align: left;
    cursor: pointer;
}
.chess-moves .mv:hover { background: rgba(138, 180, 248, 0.15); }
.chess-moves .mv.is-current { background: #e2c27a; color: #152238; }
.chess-moves .mv-empty { display: block; padding: 10px 12px; color: #75849e; font-size: 13px; text-align: center; }
.chess-fig { font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif; font-size: 1.1em; margin-right: 1px; }

.chess-nav { display: grid; grid-template-columns: repeat(4, 1fr) 1.4fr; gap: 6px; }
.chess-nav .lab-btn { padding: 6px; }

.chess-graph {
    display: block;
    width: 100%;
    height: 70px;
    border-radius: 10px;
    background: #0b1322;
}

.chess-pv {
    margin: 0;
    padding: 8px 10px;
    border-radius: 10px;
    background: #0b1322;
    color: #e6cf8c;
    font: 600 13.5px/1.9 "Vazirmatn", Tahoma, sans-serif;
    direction: ltr;
    text-align: left;
    word-spacing: 4px;
}

.chess-cands { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.chess-cands li {
    display: grid;
    grid-template-columns: 62px 1fr 64px;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--ac-line, #ddd6c8);
    direction: ltr;
    font-size: 13px;
}
.chess-cands li.is-best { border-color: #e2b84a; box-shadow: 0 0 0 2px rgba(226, 184, 74, 0.2); }
.chess-cands li.is-bound { opacity: 0.72; }
.chess-cands li.is-empty { display: block; text-align: center; color: var(--ac-muted, #5c6470); }
.cand-move { font-weight: 700; }
.cand-bar { height: 6px; border-radius: 3px; background: #ece5d4; overflow: hidden; }
.cand-bar i { display: block; height: 100%; background: linear-gradient(90deg, #2e6e66, #e2b84a); }
.cand-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: #152238; }
.chess-hint-text { margin: 0; color: var(--ac-muted, #5c6470); font-size: 12px; line-height: 1.8; }

.lab-chess .lab-stats dd { font-size: 18px; }

.chess-switches { display: grid; gap: 8px; }
.chess-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--ac-line, #ddd6c8);
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
}
.chess-switch small { display: block; color: var(--ac-muted, #5c6470); font-size: 11.5px; line-height: 1.6; }
.chess-switch input[type="checkbox"] { width: 18px; height: 18px; accent-color: #152238; flex: none; }
.chess-switch select { padding: 4px 8px; border: 1px solid var(--ac-line, #ddd6c8); border-radius: 8px; background: #fff; font: inherit; }
.chess-switch:has(input:disabled) { opacity: 0.5; cursor: default; }

.lab-chess .lab-algos { grid-template-columns: 1fr; }
.lab-chess .lab-sliders { margin: 0; }

/* ---------- the lesson under the game: tree and comparison ---------- */
.chess-lesson {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 18px;
    padding-top: 6px;
    border-top: 1px solid var(--ac-line, #ddd6c8);
}
.chess-card {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--ac-line, #ddd6c8);
    border-radius: 12px;
    background: #fffdf8;
}
.chess-card h3 { margin: 0 0 6px; color: var(--ac-navy, #152238); font-size: 16px; }
.chess-card > p { margin: 0 0 10px; color: var(--ac-muted, #5c6470); font-size: 13px; line-height: 1.9; }
.chess-card-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.chess-card-actions label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.chess-busy { margin: 0; color: var(--ac-muted, #5c6470); font-size: 13px; }

.chess-tree-sum { margin: 0 0 8px; font-size: 13px; line-height: 1.9; }
.chess-tree-list { max-height: 360px; overflow: auto; margin: 0; padding: 0 2px 0 0; list-style: none; display: grid; gap: 6px; }
.tn {
    padding: 7px 10px;
    border: 1px solid var(--ac-line, #ddd6c8);
    border-inline-start: 4px solid #2e6e66;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.tn:hover, .tn:focus-visible, .tn.is-shown { border-color: #26a69a; outline: none; }
.tn.is-cut { border-inline-start-color: #c9b9a0; background: #faf8f3; }
.tn.is-best { border-inline-start-color: #e2b84a; background: #fffaf0; }
.tn-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; direction: ltr; justify-content: flex-start; }
.tn-max { font-weight: 800; color: #152238; }
.tn-arrow { color: #75849e; font-size: 11.5px; }
.tn-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.tn-crown { padding: 1px 8px; border-radius: 999px; background: #e2b84a; color: #152238; font-size: 11px; font-weight: 800; }
.tn-kids { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; direction: ltr; }
.tn-leaf { padding: 1px 7px; border-radius: 6px; background: #eef3f1; font-size: 12px; }
.tn-leaf em { font-style: normal; color: #5c6470; }
.tn-leaf.is-min { background: #2e6e66; color: #fff; }
.tn-leaf.is-min em { color: #d5ece8; }
.tn-more { padding: 1px 7px; border-radius: 6px; background: #f1ede4; font-size: 12px; color: #5c6470; }
.tn-cut { padding: 1px 7px; border-radius: 6px; background: #fbeee0; color: #a0521d; font-size: 12px; font-weight: 600; }

.chess-compare { width: 100%; border-collapse: collapse; font-size: 13px; }
.chess-compare[hidden] { display: none; }
.chess-compare th, .chess-compare td { padding: 6px 8px; border-bottom: 1px solid var(--ac-line, #ddd6c8); text-align: start; }
.chess-compare thead th { color: var(--ac-muted, #5c6470); font-size: 12px; }
.chess-compare td { font-variant-numeric: tabular-nums; }
.chess-compare small { color: #a0521d; }
.chess-compare-sum { margin: 10px 0 0; font-size: 13px; line-height: 1.9; color: #1d4f49; font-weight: 600; }

.lab-chess .lab-note { grid-column: 1 / -1; }
.lab-chess .lab-note h3 { margin: 14px 0 4px; color: var(--ac-navy, #152238); font-size: 15px; }

@media (max-width: 980px) {
    .lab-panel.lab-chess { grid-template-columns: 1fr; }
    .chess-lesson { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .chess-table { padding: 8px; border-radius: 10px; }
    .chess-arena { grid-template-columns: 14px minmax(0, 1fr); gap: 6px; }
    .chess-evalbar b { display: none; }
    .sq-file, .sq-rank { font-size: 9px; }
    .chess-player { padding: 5px 10px; min-height: 40px; }
    .chess-toolbar .lab-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
    .cp, .cp svg, .chess-table, .chess-evalbar i { transition: none; }
    .chess-arrows .ar-scan, .chess-think i { animation: none; }
}

.chess-eval-seg { grid-template-columns: 1fr 1fr; }
.chess-eval-seg .chess-switch { padding: 8px; }
.chess-toolbar .lab-btn[hidden] { display: none; }
.chess-nav { direction: ltr; }
