/* ChessTraining board: themes, pieces, highlights, arrows, promotion, and the capture burst. */
.ct-board { --light: #eeeed2; --dark: #769656; --last: rgba(255, 235, 59, .45); --sel: rgba(20, 85, 30, .5); --dot: rgba(0, 0, 0, .18);
    --check: radial-gradient(circle, rgba(255, 0, 0, .9) 0%, rgba(231, 0, 0, .6) 30%, rgba(169, 0, 0, 0) 75%);
    position: relative; width: 100%; aspect-ratio: 1 / 1; user-select: none; touch-action: none; border-radius: 6px; overflow: hidden;
    box-shadow: 0 4px 18px rgba(0, 0, 0, .25);
    /* The board keeps its own colours: browsers with a forced dark mode (Samsung Internet) must not re-colour squares or pieces. */
    color-scheme: only light; }
.theme-brown .ct-board, .ct-board.theme-brown { --light: #f0d9b5; --dark: #b58863; }
.theme-blue .ct-board, .ct-board.theme-blue { --light: #dee3e6; --dark: #8ca2ad; }
.theme-grey .ct-board, .ct-board.theme-grey { --light: #e0e0e0; --dark: #9e9e9e; }
.theme-purple .ct-board, .ct-board.theme-purple { --light: #efe6f7; --dark: #8e6bb3; }
.theme-wood .ct-board, .ct-board.theme-wood { --light: #e8c99b; --dark: #a0703e; }
.ct-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.ct-sq { position: relative; }
.ct-sq.light { background: var(--light); }
.ct-sq.dark { background: var(--dark); }
.ct-sq.last::before, .ct-sq.premove::before, .ct-sq.selected::before { content: ""; position: absolute; inset: 0; background: var(--last); }
.ct-sq.selected::before { background: var(--sel); }
.ct-sq.premove::before { background: rgba(20, 30, 85, .45); }
.ct-sq.check::after { content: ""; position: absolute; inset: 0; background: var(--check); }
.ct-sq.dest::after { content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; border-radius: 50%; background: var(--dot); }
.ct-sq.dest-take::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 6px var(--dot); }
.ct-sq.hover { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .65); }
.ct-coord { position: absolute; font-size: clamp(8px, 1.5vw, 12px); font-weight: 700; pointer-events: none; line-height: 1; }
.ct-sq.light .ct-coord { color: var(--dark); }
.ct-sq.dark .ct-coord { color: var(--light); }
.ct-coord.file { right: 4%; bottom: 3%; }
.ct-coord.rank { left: 4%; top: 4%; }
.ct-pieces, .ct-fx { position: absolute; inset: 0; pointer-events: none; }
.ct-piece { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; background-size: cover; will-change: transform; z-index: 2; }
.ct-piece.ct-anim { transition: transform .22s cubic-bezier(.25, .8, .35, 1); }
.ct-piece.dragging { z-index: 10; transform-origin: center; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, .35)); cursor: grabbing; }
.ct-piece.ct-appear { animation: ct-appear .25s ease-out; }
@keyframes ct-appear { from { opacity: 0; } to { opacity: 1; } }
.ct-board:not(.ct-board-view) { cursor: pointer; }
.ct-shapes { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.ct-shapes .arrow { stroke-width: .16; stroke-linecap: round; opacity: .8; }
.ct-shapes .arrow.faint { opacity: .45; }
.ct-shapes .circle { fill: none; stroke-width: .07; opacity: .8; }
.ct-shapes .brush-green { stroke: #15781b; fill: #15781b; }
.ct-shapes .brush-red { stroke: #882020; fill: #882020; }
.ct-shapes .brush-blue { stroke: #003088; fill: #003088; }
.ct-shapes .brush-yellow { stroke: #e68f00; fill: #e68f00; }
.ct-shapes .brush-engine { stroke: #2b6cb0; fill: #2b6cb0; }
.ct-shapes .brush-chat { stroke: #c026d3; fill: #c026d3; }
.ct-shapes circle.brush-green, .ct-shapes circle.brush-red, .ct-shapes circle.brush-blue, .ct-shapes circle.brush-yellow, .ct-shapes circle.brush-chat { fill: none; }

/* Hints: a move or square from the chat, on top of everything (an earlier position covers the board for the moment). */
.ct-hint { position: absolute; inset: 0; z-index: 47; pointer-events: none; }
.ct-hint .ct-hint-shapes { z-index: 3; }
.ct-hint .ct-hint-shapes .arrow { opacity: .9; stroke-width: .18; }
.ct-hint .ct-hint-shapes .hint-sq { fill: rgba(192, 38, 211, .28); }
.ct-hint .ct-hint-shapes .hint-ring { stroke-width: .09; opacity: .95; filter: drop-shadow(0 0 .08px rgba(192, 38, 211, .9)); }
.ct-hint-tag { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); z-index: 4; padding: .15rem .6rem; border-radius: 999px;
    background: #c026d3; color: #fff; font-size: clamp(10px, 1.5vw, 12px); font-weight: 800; white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); }
.ct-board.hinting .ct-mate-banner, .ct-board.hinting .ct-promo { visibility: hidden; }
.ct-board.hinting { cursor: default; }

/* Promotion picker */
.ct-promo { position: absolute; width: 12.5%; z-index: 20; display: flex; flex-direction: column; background: rgba(255, 255, 255, .95);
    box-shadow: 0 6px 24px rgba(0, 0, 0, .35); border-radius: 6px; overflow: hidden; }
.ct-promo.top { top: 0; }
.ct-promo.bottom { bottom: 0; flex-direction: column-reverse; }
.ct-promo-piece { aspect-ratio: 1 / 1; border: 0; background-color: transparent; background-size: cover; cursor: pointer; }
.ct-promo-piece:hover { background-color: #e6f2d8; }
.ct-promo-cancel { border: 0; background: #eee; font-size: 18px; line-height: 1.2; cursor: pointer; }

/* The capture burst: the taken piece pops, a ring spreads, shards fly. */
.ct-burst { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; z-index: 4; }
.ct-burst-piece { position: absolute; inset: 0; background-size: cover; animation: ct-pop .45s ease-out forwards; }
@keyframes ct-pop { 0% { transform: scale(1); opacity: 1; } 40% { transform: scale(1.25) rotate(8deg); opacity: .9; } 100% { transform: scale(.2) rotate(-20deg); opacity: 0; } }
.ct-burst .ring { position: absolute; left: 10%; top: 10%; width: 80%; height: 80%; border-radius: 50%; border: 3px solid rgba(255, 196, 0, .9);
    animation: ct-ring .5s ease-out forwards; }
@keyframes ct-ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.9); opacity: 0; } }
.ct-burst .shard { position: absolute; left: 44%; top: 44%; width: 12%; height: 12%; border-radius: 2px;
    animation: ct-shard .6s cubic-bezier(.15, .7, .3, 1) forwards; }
.ct-burst .shard.light { background: #fff; box-shadow: 0 0 0 1px #333; }
.ct-burst .shard.dark { background: #222; box-shadow: 0 0 0 1px #ddd; }
@keyframes ct-shard { from { transform: translate(0, 0) rotate(0); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }

/* Move-rating marks on a square (the last move's class). */
.ct-sq[class*="mark-"]::after { content: ""; position: absolute; right: -2%; top: -2%; width: 34%; height: 34%; border-radius: 50%;
    background-size: 70%; background-position: center; background-repeat: no-repeat; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); z-index: 6; }
.ct-sq.mark-Brilliant::after { background-color: #1baca6; }
.ct-sq.mark-Great::after { background-color: #5c8bb0; }
.ct-sq.mark-Best::after { background-color: #81b64c; }
.ct-sq.mark-Excellent::after { background-color: #96bc4b; }
.ct-sq.mark-Good::after { background-color: #96af8b; }
.ct-sq.mark-Book::after { background-color: #a88865; }
.ct-sq.mark-Inaccuracy::after { background-color: #f7c631; }
.ct-sq.mark-Mistake::after { background-color: #e58f2a; }
.ct-sq.mark-Miss::after { background-color: #ee6b55; }
.ct-sq.mark-Blunder::after { background-color: #ca3431; }
.ct-sq.mark-Forced::after { background-color: #96af8b; }

/* Little boards (tournament pages, lists) */
.ct-mini .ct-board { box-shadow: none; border-radius: 3px; }
.ct-mini .ct-coord { display: none; }

/* ── Fun mode (kids) ── */
.fun-layer { position: absolute; inset: 0; pointer-events: none; z-index: 30; overflow: visible; }
.fun { position: absolute; transform: translate(-50%, -50%); font-weight: 900; white-space: nowrap; }
.fun.pow { font-size: clamp(18px, 4.5vw, 40px); color: #ffeb3b; -webkit-text-stroke: 2px #d32f2f; text-shadow: 3px 3px 0 #b71c1c;
    font-family: "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif; animation: fun-pow 1.1s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.fun.pow.big { font-size: clamp(26px, 6.5vw, 58px); }
@keyframes fun-pow { 0% { transform: translate(-50%, -50%) scale(.2) rotate(var(--rot)); opacity: 0; } 20% { transform: translate(-50%, -80%) scale(1.3) rotate(var(--rot)); opacity: 1; }
    70% { transform: translate(-50%, -95%) scale(1) rotate(var(--rot)); opacity: 1; } 100% { transform: translate(-50%, -130%) scale(.8) rotate(var(--rot)); opacity: 0; } }
.fun.star { font-size: clamp(14px, 2.6vw, 24px); animation: fun-star 1s ease-out forwards; }
@keyframes fun-star { from { transform: translate(-50%, -50%) scale(.4); opacity: 1; } to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(200deg); opacity: 0; } }
.fun.ko { font-size: clamp(11px, 1.8vw, 15px); color: #fff; background: rgba(0, 0, 0, .65); padding: 2px 8px; border-radius: 999px; animation: fun-ko 1.5s ease-out forwards; }
@keyframes fun-ko { 0% { transform: translate(-50%, 40%); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(-50%, -160%); opacity: 0; } }
.fun.crown { font-size: clamp(28px, 6vw, 54px); animation: fun-crown 1.4s ease-out forwards; }
@keyframes fun-crown { 0% { transform: translate(-50%, -50%) scale(.2); } 30% { transform: translate(-50%, -110%) scale(1.4) rotate(-10deg); } 100% { transform: translate(-50%, -160%) scale(1) rotate(10deg); opacity: 0; } }
.fun-banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-size: clamp(22px, 6vw, 56px); font-weight: 900;
    font-family: "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif; color: #fff; text-shadow: 0 4px 0 rgba(0, 0, 0, .35), 0 0 22px rgba(0, 0, 0, .35);
    white-space: nowrap; animation: fun-banner 1.4s cubic-bezier(.2, 1.5, .4, 1) forwards; }
.fun-banner.check { color: #ff5252; -webkit-text-stroke: 2px #fff; }
.fun-banner.mate { color: #ffd740; -webkit-text-stroke: 2px #e65100; font-size: clamp(26px, 7vw, 64px); }
.fun-banner.cheer { color: #b9f6ca; -webkit-text-stroke: 1.5px #1b5e20; font-size: clamp(18px, 4.5vw, 42px); top: 18%; }
.fun-banner.oops { color: #ffe0b2; -webkit-text-stroke: 1px #e65100; font-size: clamp(14px, 3vw, 28px); top: 18%; }
.fun-banner.castle, .fun-banner.promo { color: #e1f5fe; -webkit-text-stroke: 1.5px #01579b; }
@keyframes fun-banner { 0% { transform: translate(-50%, -50%) scale(.2); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
    75% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -70%) scale(.9); opacity: 0; } }
.fun-shake { animation: fun-shake .45s ease-in-out; }
@keyframes fun-shake { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-6px, 3px) rotate(-.6deg); } 40% { transform: translate(6px, -3px) rotate(.6deg); }
    60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, -1px); } }
.fun-confetti { position: fixed; top: -12px; width: 10px; height: 14px; border-radius: 2px; z-index: 3000; pointer-events: none;
    animation: fun-fall 2.2s cubic-bezier(.3, .6, .5, 1) forwards; }
@keyframes fun-fall { to { transform: translateY(var(--fall)) rotate(var(--spin)); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .fun, .fun-banner { animation-duration: .01s !important; } }

/* ── Lessons: the stage ── */
.ct-lesson-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.ct-stage { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.1rem; align-items: start; }
@media (max-width: 991.98px) { .ct-stage { grid-template-columns: minmax(0, 1fr); } }
.ct-stage-main { max-width: min(100%, calc(100vh - 300px)); width: 100%; margin: 0 auto; }
@media (max-width: 991.98px) { .ct-stage-main { max-width: 100%; } }
.ct-stage-side { display: flex; flex-direction: column; gap: .8rem; }
.ct-stage-side .ct-moves { max-height: 46vh; }
.ct-lesson-board { position: relative; border-radius: 10px; }
.ct-lesson-board .ct-board { box-shadow: 0 10px 34px rgba(0, 0, 0, .35); border-radius: 10px; }
/* A strong last-move mark so everyone sees what just moved. */
.ct-lesson-board .ct-sq.last::before { background: rgba(255, 213, 0, .55); box-shadow: inset 0 0 0 3px rgba(255, 170, 0, .85); }

/* The camera window: slides between corners (lesson-stage.js sets left/top). */
.ct-pip { position: absolute; left: 0; top: 0; width: 27%; max-width: 230px; aspect-ratio: 4 / 3; z-index: 40; border-radius: 14px; overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .5); border: 2px solid rgba(255, 255, 255, .9); cursor: grab; background: #000; touch-action: none;
    transition: left .55s cubic-bezier(.3, .9, .3, 1), top .55s cubic-bezier(.3, .9, .3, 1), opacity .3s, transform .2s; }
.ct-pip.no-anim, .ct-pip.dragging { transition: none; }
.ct-pip.dragging { cursor: grabbing; transform: scale(1.04); box-shadow: 0 16px 40px rgba(0, 0, 0, .55); }
.ct-pip video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ct-pip.mirror video { transform: scaleX(-1); }
.ct-pip-bar { position: absolute; right: 4px; top: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
.ct-pip:hover .ct-pip-bar, .ct-pip:focus-within .ct-pip-bar { opacity: 1; }
@media (hover: none) { .ct-pip-bar { opacity: 1; } }
.ct-pip-btn { border: 0; background: rgba(0, 0, 0, .55); color: #fff; border-radius: 50%; width: 26px; height: 26px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.ct-pip-btn .material-icons { font-size: 16px; }
.ct-pip-btn:hover { background: rgba(0, 0, 0, .8); }

/* Where the instructor points. */
.ct-pointer { position: absolute; left: 50%; top: 50%; width: 5.5%; aspect-ratio: 1; margin: -2.75% 0 0 -2.75%; border-radius: 50%; z-index: 35; pointer-events: none;
    background: radial-gradient(circle, rgba(255, 82, 82, .95) 0 28%, rgba(255, 82, 82, .45) 45%, rgba(255, 82, 82, 0) 72%);
    opacity: 0; transform: scale(.4); transition: left .12s linear, top .12s linear, opacity .35s, transform .35s; }
.ct-pointer.on { opacity: 1; transform: scale(1); animation: ct-pointer 1.4s ease-in-out infinite; }
@keyframes ct-pointer { 50% { filter: brightness(1.25); transform: scale(1.18); } }

/* Pinned question, the instructor's caption, the "earlier move" pill, the ended screen. */
.ct-pinned { display: flex; align-items: center; gap: .45rem; margin: 0 0 .6rem;
    background: rgba(255, 244, 204, .97); color: #4a3700; padding: .45rem .7rem .45rem .6rem; border-radius: 14px; font-weight: 600; font-size: .92rem;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .35); animation: ct-slide-in .35s cubic-bezier(.2, 1.2, .4, 1); }
.ct-pinned .material-icons { font-size: 18px; color: #d99a14; flex: none; }
.ct-pinned span:not(.material-icons) { overflow-wrap: anywhere; }
.ct-pinned-x { border: 0; background: transparent; color: #7a5a00; padding: 0; margin-left: .2rem; display: inline-flex; }
.ct-caption { position: absolute; left: 50%; bottom: 12px; transform: translate(-50%, 10px); z-index: 45; max-width: 86%; text-align: center;
    background: rgba(18, 18, 16, .86); color: #fff; padding: .5rem .85rem; border-radius: 12px; font-size: clamp(.85rem, 1.6vw, 1.05rem); font-weight: 600;
    opacity: 0; pointer-events: none; transition: opacity .35s, transform .35s; box-shadow: 0 8px 22px rgba(0, 0, 0, .4); }
.ct-caption.on { opacity: 1; transform: translate(-50%, 0); }
.ct-history-pill { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 46; display: flex; align-items: center; gap: .45rem;
    background: #2b6cb0; color: #fff; padding: .35rem .4rem .35rem .7rem; border-radius: 999px; font-weight: 700; font-size: .88rem; white-space: nowrap;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .35); animation: ct-slide-in .3s; }
.ct-history-pill .material-icons { font-size: 18px; }
.ct-history-pill button { border: 0; border-radius: 999px; background: #fff; color: #2b6cb0; font-weight: 800; padding: .2rem .7rem; }
.ct-ended { position: absolute; inset: 0; z-index: 44; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; text-align: center;
    background: rgba(20, 20, 18, .62); color: #fff; border-radius: 10px; backdrop-filter: blur(2px); pointer-events: none; }
.ct-ended img { width: 120px; height: 120px; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, .4)); }
.ct-ended strong { font-size: 1.3rem; }

/* Letters and numbers round the lesson board's edge (board-tools.js EdgeCoords): big and dark on the page. */
.ct-board-frame { position: relative; --cw: clamp(18px, 4.2vw, 28px); }
.ct-board-frame.coords-out { padding: 0 0 var(--cw) var(--cw); }
.ct-edge { position: absolute; display: none; pointer-events: none; user-select: none; color: var(--ct-text); font-weight: 800;
    font-size: clamp(12px, 1.9vw, 17px); line-height: 1; font-variant-numeric: tabular-nums; }
.ct-board-frame.coords-out .ct-edge { display: grid; }
.ct-edge.ranks { left: 0; top: 0; bottom: var(--cw); width: var(--cw); grid-template-rows: repeat(8, 1fr); }
.ct-edge.files { left: var(--cw); right: 0; bottom: 0; height: var(--cw); grid-template-columns: repeat(8, 1fr); }
.ct-edge span { display: flex; align-items: center; justify-content: center; }
body.ct-pip-doc .ct-edge, body.ct-bare .ct-edge { color: #f3f1ec; }

/* "Drawings stay — Caps Lock is on" (the instructor's stage). */
.ct-caps-note { position: absolute; left: 8px; top: 8px; z-index: 46; display: inline-flex; align-items: center; gap: .3rem; pointer-events: none;
    padding: .25rem .65rem .25rem .45rem; border-radius: 999px; background: rgba(18, 18, 16, .82); color: #fff; font-size: .8rem; font-weight: 700;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .35); animation: ct-slide-in .3s; }
.ct-caps-note .material-icons { font-size: 17px; color: var(--ct-gold); }

/* The toolbar and, beside it, the instructor's Stop / Start again (never fades). */
.ct-stage-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }
.ct-stage-row > .ct-stage-bar { margin: 0; }
.ct-stage-stop { display: flex; }
.ct-stop-btn { display: inline-flex; align-items: center; gap: .35rem; height: 46px; border-radius: 14px; font-weight: 800; padding: 0 1rem; box-shadow: var(--ct-shadow-2); }
.ct-stop-btn.btn-danger { --bs-btn-bg: #d93a2b; --bs-btn-border-color: transparent; --bs-btn-hover-bg: #bf2e21; --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: #a5271c; --bs-btn-active-border-color: transparent; }

/* Tips under the lesson board. */
.ct-help { max-width: 720px; margin-left: auto; margin-right: auto; }
.ct-help-list { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: .35rem; font-size: .92rem; }
.ct-help-key { display: inline-block; padding: 0 .4rem; border-radius: 6px; border: 1px solid var(--ct-border); background: var(--ct-surface-2);
    font-size: .8rem; font-weight: 700; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .08); }

/* The floating toolbar under the board: fades when nobody moves (lesson-stage.js autoHide). */
.ct-stage-bar { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; margin: .7rem auto 0; padding: 6px; width: fit-content; max-width: 100%;
    background: var(--ct-surface); border: 1px solid var(--ct-border); border-radius: 18px; box-shadow: var(--ct-shadow-2); }
.ct-autohide { transition: opacity .45s ease, transform .45s ease; }
.ct-lesson.idle .ct-autohide { opacity: 0; transform: translateY(6px); pointer-events: none; }
.ct-lesson.idle .ct-pip-bar { opacity: 0; }
.ct-bar-btn { position: relative; height: 42px; min-width: 42px; border: 0; border-radius: 13px; background: transparent; color: var(--ct-text); display: inline-flex;
    align-items: center; justify-content: center; gap: .35rem; padding: 0 .55rem; font-weight: 700; transition: background .15s, color .15s, transform .1s; }
.ct-bar-btn:hover { background: var(--ct-surface-2); }
.ct-bar-btn:active { transform: scale(.94); }
.ct-bar-btn .material-icons { font-size: 22px; }
.ct-bar-btn.on { background: #e5533d; color: #fff; }
.ct-bar-btn.on:hover { background: #cc4430; }
#btn-listen.on { background: var(--ct-brand); }
.ct-bar-btn.wide { padding: 0 .85rem; background: var(--ct-brand); color: #fff; }
.ct-bar-btn.wide:hover { background: #5d9732; }
.ct-bar-btn.attention { animation: ct-pulse 1.4s ease-in-out infinite; box-shadow: 0 0 0 3px rgba(129, 182, 76, .45); }
.ct-bar-btn .ct-badge-dot { top: 2px; right: 2px; }
.ct-bar-sep { width: 1px; height: 26px; background: var(--ct-border); margin: 0 4px; }

/* The chat drawer. */
.ct-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 1060; background: var(--ct-surface); border-left: 1px solid var(--ct-border);
    box-shadow: var(--ct-shadow-3); display: flex; flex-direction: column; transform: translateX(105%); transition: transform .35s cubic-bezier(.3, .9, .3, 1); visibility: hidden; }
.ct-drawer.open { transform: none; visibility: visible; }
.ct-drawer-head { display: flex; align-items: center; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--ct-border); }
.ct-drawer .ct-chat-lines { flex: 1; max-height: none; padding: .8rem; }
.ct-drawer form { border-top: 1px solid var(--ct-border); }
@media (max-width: 575.98px) { .ct-drawer { top: auto; height: 70vh; width: 100vw; border-radius: 22px 22px 0 0; transform: translateY(105%); border-left: 0; } .ct-drawer.open { transform: none; } }
.ct-lesson-chat { max-height: 260px; }
.ct-chat-pin { display: inline-block; margin-left: .4rem; border: 0; border-radius: 999px; background: var(--ct-surface-3); color: var(--ct-text); font-size: .72rem; font-weight: 700; padding: .05rem .5rem; }
.ct-chat-pin:hover { background: var(--ct-gold); color: #3d2700; }

/* Pop-outs: what stays behind, and the always-on-top window. */
.ct-popped { aspect-ratio: 1 / 1; width: 100%; border-radius: 10px; border: 2px dashed var(--ct-border); display: flex; align-items: center; justify-content: center; background: var(--ct-surface-2); }
.ct-popped > div { display: flex; flex-direction: column; align-items: center; gap: .5rem; color: var(--ct-muted); text-align: center; padding: 1rem; }
.ct-popped .material-icons { font-size: 40px; color: var(--ct-brand); }
body.ct-pip-doc { margin: 0; background: #161512; display: flex; align-items: center; justify-content: center; min-height: 100vh; overflow: hidden; }
body.ct-pip-doc > * { width: min(100vw - 8px, 100vh - 8px); margin: 0; }
body.ct-pip-doc > .ct-board-wrap { width: min(100vw - 8px, 100vh - 130px); max-width: none; }
body.ct-bare .ct-lesson .ct-stage { display: block; }
body.ct-bare .ct-stage-main { width: min(100vw - 16px, 100vh - 16px); max-width: none; }
body.ct-bare .ct-game { display: block; }
body.ct-bare .ct-game > .ct-side, body.ct-bare .ct-game > .ct-eval-bar { display: none !important; }
body.ct-bare .ct-game > .ct-board-wrap { width: min(100vw - 16px, 100vh - 140px); max-width: none; }

/* ── Checkmate: impossible to miss ── */
.ct-sq.mate::before { content: ""; position: absolute; inset: 0; z-index: 1;
    background: radial-gradient(circle, rgba(255, 30, 30, .95) 0%, rgba(210, 0, 0, .75) 45%, rgba(150, 0, 0, .45) 80%); animation: ct-mate-pulse 1.2s ease-in-out 3; }
.ct-sq.mate-winner::before { content: ""; position: absolute; inset: 0; z-index: 1; background: radial-gradient(circle, rgba(255, 215, 64, .9) 0%, rgba(242, 182, 50, .5) 55%, rgba(242, 182, 50, 0) 85%); }
@keyframes ct-mate-pulse { 50% { filter: brightness(1.35); } }
.ct-piece.ct-mated { filter: drop-shadow(0 0 6px rgba(255, 0, 0, .8)); transition: transform .6s cubic-bezier(.5, -0.4, .4, 1.4) .25s; z-index: 3; }
.ct-piece.ct-mate-winner { filter: drop-shadow(0 0 8px rgba(255, 200, 40, .95)); }
.ct-mate-banner { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 48; pointer-events: none; text-align: center; white-space: nowrap;
    display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .7em 1.6em; border-radius: 18px;
    background: linear-gradient(135deg, rgba(198, 25, 25, .96), rgba(120, 10, 10, .96)); color: #fff; box-shadow: 0 16px 50px rgba(0, 0, 0, .55), inset 0 0 0 2px rgba(255, 255, 255, .25);
    font-size: clamp(14px, 3.4vw, 22px); animation: ct-mate-in .55s cubic-bezier(.2, 1.4, .4, 1); transition: top .6s cubic-bezier(.3, .9, .3, 1), transform .6s cubic-bezier(.3, .9, .3, 1), font-size .6s, padding .6s, border-radius .6s; }
.ct-mate-banner strong { font-size: 2.1em; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; line-height: 1; }
.ct-mate-banner span { font-weight: 700; opacity: .92; }
.ct-mate-banner.settled { flex-direction: row; gap: .6em; padding: .25em .9em; font-size: clamp(10px, 1.6vw, 13px); }
.ct-mate-banner.settled.at-top { top: 0; transform: translate(-50%, 0); border-radius: 0 0 12px 12px; }
.ct-mate-banner.settled.at-bottom { top: 100%; transform: translate(-50%, -100%); border-radius: 12px 12px 0 0; }
.ct-mate-banner.settled strong { font-size: 1.15em; }
@keyframes ct-mate-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.4); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.ct-mini .ct-mate-banner { display: none; }
