/* ChessTraining website — design tokens, the app shell and every shared component. Dark first; a warm light theme too.
   Bootstrap stays underneath (forms, grid, dropdowns); its variables are pointed at these tokens. */

@font-face { font-family: 'Inter Variable'; font-style: normal; font-display: swap; font-weight: 100 900;
    src: url(/lib/inter/inter-latin-wght-normal.woff2) format('woff2-variations');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter Variable'; font-style: normal; font-display: swap; font-weight: 100 900;
    src: url(/lib/inter/inter-latin-ext-wght-normal.woff2) format('woff2-variations');
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root, [data-bs-theme="light"] {
    --ct-brand: #6aa13a;          /* the board's green, a little brighter */
    --ct-brand-2: #81b64c;
    --ct-brand-strong: #4e7a27;
    --ct-brand-ink: #fff;
    --ct-gold: #f2b632;
    --ct-coral: #ef6c57;
    --ct-sky: #4a90d9;
    --ct-bg: #f3f1ec;
    --ct-surface: #ffffff;
    --ct-surface-2: #f6f4ef;
    --ct-surface-3: #ece9e2;
    --ct-border: rgba(40, 35, 25, .09);
    --ct-text: #23211d;
    --ct-muted: #6f6a60;
    --ct-soft: #eaf3df;
    --ct-panel: var(--ct-surface);
    --ct-shadow-1: 0 1px 2px rgba(30, 25, 15, .06), 0 1px 1px rgba(30, 25, 15, .04);
    --ct-shadow-2: 0 2px 4px rgba(30, 25, 15, .05), 0 8px 24px rgba(30, 25, 15, .08);
    --ct-shadow-3: 0 12px 40px rgba(30, 25, 15, .18);
    --ct-radius: 16px;
    --ct-radius-sm: 10px;
    --ct-ring: 0 0 0 3px rgba(129, 182, 76, .45);
    --ct-side-w: 236px;
    --bs-body-font-family: 'Inter Variable', Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --bs-body-bg: var(--ct-bg);
    --bs-body-color: var(--ct-text);
    --bs-secondary-color: var(--ct-muted);
    --bs-tertiary-bg: var(--ct-surface-2);
    --bs-secondary-bg: var(--ct-surface-3);
    --bs-border-color: var(--ct-border);
    --bs-border-radius: 10px;
    --bs-border-radius-lg: 14px;
    --bs-link-color: #4e7a27;
    --bs-link-hover-color: #3a5c1d;
    --bs-link-color-rgb: 78, 122, 39;
    --bs-link-hover-color-rgb: 58, 92, 29;
    --bs-focus-ring-color: rgba(129, 182, 76, .45);
    color-scheme: light only;
}
[data-bs-theme="dark"] {
    --ct-bg: #1a1917;
    --ct-surface: #262522;
    --ct-surface-2: #2f2d2a;
    --ct-surface-3: #3a3834;
    --ct-border: rgba(255, 255, 255, .07);
    --ct-text: #ece9e4;
    --ct-muted: #a29d94;
    --ct-soft: #26331b;
    --ct-shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --ct-shadow-2: 0 2px 6px rgba(0, 0, 0, .25), 0 10px 30px rgba(0, 0, 0, .25);
    --ct-shadow-3: 0 16px 50px rgba(0, 0, 0, .55);
    --bs-body-bg: var(--ct-bg);
    --bs-body-color: var(--ct-text);
    --bs-emphasis-color: #fff;
    --bs-link-color: #9ccc65;
    --bs-link-hover-color: #b9df8a;
    --bs-link-color-rgb: 156, 204, 101;
    --bs-link-hover-color-rgb: 185, 223, 138;
    color-scheme: dark;
}

html { -webkit-text-size-adjust: 100%; }
body { background: var(--ct-bg); color: var(--ct-text); font-feature-settings: 'cv11', 'ss01'; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { font-weight: 800; letter-spacing: -.02em; }
::selection { background: rgba(129, 182, 76, .35); }
:focus-visible { outline: none; box-shadow: var(--ct-ring) !important; border-radius: 8px; }
a { text-underline-offset: 3px; }
.mi { font-size: 1.15em; vertical-align: -0.2em; }
.d-none-js { display: none; }
.text-brand { color: var(--ct-brand) !important; }
[data-bs-theme="dark"] .text-brand { color: var(--ct-brand-2) !important; }
.text-gold { color: var(--ct-gold) !important; }
.fw-800 { font-weight: 800; }

/* ── The app shell: a sidebar on wide screens, a tab bar on phones, a slim top bar ───────────────── */

.ct-shell { display: grid; grid-template-columns: var(--ct-side-w) minmax(0, 1fr); min-height: 100vh; }
.ct-shell.guest { grid-template-columns: minmax(0, 1fr); }
.ct-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--ct-surface); border-right: 1px solid var(--ct-border);
    display: flex; flex-direction: column; padding: 14px 12px; gap: 2px; z-index: 1020; }
.ct-brand { display: flex; align-items: center; gap: .6rem; padding: 6px 10px 14px; font-weight: 800; font-size: 1.15rem; color: var(--ct-text); text-decoration: none; letter-spacing: -.02em; }
.ct-brand img { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--ct-shadow-1); }
.ct-brand span b { color: var(--ct-brand); font-weight: 800; }
.ct-side-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .8rem; border-radius: 12px; color: var(--ct-text); text-decoration: none;
    font-weight: 600; font-size: .97rem; transition: background .15s, color .15s, transform .15s; position: relative; }
.ct-side-link .material-icons { font-size: 22px; color: var(--ct-muted); transition: color .15s, transform .2s; }
.ct-side-link:hover { background: var(--ct-surface-2); color: var(--ct-text); }
.ct-side-link:hover .material-icons { color: var(--ct-brand); transform: scale(1.08); }
.ct-side-link.active { background: var(--ct-soft); color: var(--ct-brand-strong); }
[data-bs-theme="dark"] .ct-side-link.active { color: #b9df8a; }
.ct-side-link.active .material-icons { color: var(--ct-brand); }
.ct-side-link.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ct-brand); }
.ct-side-link .ct-count { margin-left: auto; }
.ct-side-sep { height: 1px; background: var(--ct-border); margin: 10px 6px; }
.ct-side-cta { margin: 6px 4px 10px; }
.ct-side-foot { margin-top: auto; padding: 10px 6px 2px; font-size: .78rem; color: var(--ct-muted); display: flex; flex-direction: column; gap: 4px; }
.ct-side-foot a { color: var(--ct-muted); text-decoration: none; }
.ct-side-foot a:hover { color: var(--ct-text); }

.ct-main { min-width: 0; display: flex; flex-direction: column; }
.ct-topbar { position: sticky; top: 0; z-index: 1010; height: 60px; display: flex; align-items: center; gap: .5rem; padding: 0 clamp(12px, 3vw, 28px);
    background: color-mix(in srgb, var(--ct-bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--ct-border); }
.ct-topbar .ct-brand { display: none; padding: 0; }
.ct-shell.guest .ct-topbar .ct-brand { display: flex; }
.ct-topbar-title { font-weight: 700; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ct-muted); }
.ct-icon-btn { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--ct-text);
    display: inline-flex; align-items: center; justify-content: center; transition: background .15s, transform .1s; text-decoration: none; }
.ct-icon-btn:hover { background: var(--ct-surface-2); color: var(--ct-text); }
.ct-icon-btn:active { transform: scale(.94); }
.ct-icon-btn .material-icons { font-size: 23px; }
.ct-badge-dot { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--ct-coral); color: #fff;
    font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--ct-bg); }
.ct-badge-dot:empty, .ct-badge-dot[data-n="0"] { display: none; }
.ct-me-btn { display: inline-flex; align-items: center; gap: .5rem; padding: 4px 10px 4px 4px; border-radius: 999px; border: 0; background: transparent; color: var(--ct-text); font-weight: 600; }
.ct-me-btn:hover { background: var(--ct-surface-2); }
.ct-content { width: 100%; max-width: 1320px; margin: 0 auto; padding: clamp(14px, 2.4vw, 28px) clamp(12px, 3vw, 28px) 28px; flex: 1; }
.ct-footer { max-width: 1320px; width: 100%; margin: 0 auto; padding: 0 clamp(12px, 3vw, 28px) 28px; color: var(--ct-muted); font-size: .85rem; display: flex; flex-wrap: wrap; gap: 1rem; }
.ct-footer a { color: var(--ct-muted); }

.ct-tabbar { display: none; }
@media (max-width: 991.98px) {
    .ct-shell { grid-template-columns: minmax(0, 1fr); }
    .ct-sidebar { display: none; }
    .ct-topbar .ct-brand { display: flex; }
    .ct-topbar-title { display: none; }
    .ct-tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
        background: color-mix(in srgb, var(--ct-surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        border-top: 1px solid var(--ct-border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
    .ct-tab { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: .7rem; font-weight: 600; color: var(--ct-muted); text-decoration: none;
        border: 0; background: transparent; padding: 4px 0; border-radius: 12px; position: relative; }
    .ct-tab .material-icons { font-size: 24px; transition: transform .2s; }
    .ct-tab.active { color: var(--ct-brand); }
    .ct-tab.active .material-icons { transform: translateY(-1px) scale(1.08); }
    .ct-tab .ct-badge-dot { top: 0; right: calc(50% - 22px); }
    body.has-tabbar .ct-content { padding-bottom: 92px; }
    body.has-tabbar .ct-footer { padding-bottom: 96px; }
    #ct-toasts { bottom: 84px !important; }
}
.ct-more .offcanvas-body { display: flex; flex-direction: column; gap: 2px; }

/* ── Buttons ──────────────────────────────────────────────────────────────────────────────────── */

.btn { font-weight: 600; border-radius: 11px; transition: transform .08s ease, box-shadow .15s, background-color .15s, border-color .15s, color .15s; }
.btn:active { transform: translateY(1px) scale(.985); }
.btn-sm { border-radius: 9px; }
.btn-lg { border-radius: 14px; }
.btn-brand { --bs-btn-bg: var(--ct-brand); --bs-btn-border-color: transparent; --bs-btn-color: #fff;
    --bs-btn-hover-bg: #5d9732; --bs-btn-hover-border-color: transparent; --bs-btn-hover-color: #fff;
    --bs-btn-active-bg: var(--ct-brand-strong); --bs-btn-active-color: #fff; --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-bg: var(--ct-brand); --bs-btn-disabled-border-color: transparent; --bs-btn-disabled-color: #fff;
    background-image: linear-gradient(180deg, rgba(255, 255, 255, .14), rgba(255, 255, 255, 0)); box-shadow: 0 3px 0 var(--ct-brand-strong), 0 6px 14px rgba(78, 122, 39, .25); }
.btn-brand:hover { box-shadow: 0 3px 0 #3a5c1d, 0 8px 20px rgba(78, 122, 39, .32); }
.btn-brand:active { box-shadow: 0 1px 0 var(--ct-brand-strong); transform: translateY(2px); }
.btn-play { font-size: 1.12rem; font-weight: 800; padding: .85rem 1.3rem; border-radius: 14px; letter-spacing: -.01em; }
.btn-outline-secondary { --bs-btn-color: var(--ct-text); --bs-btn-bg: var(--ct-surface-2); --bs-btn-border-color: var(--ct-border);
    --bs-btn-hover-bg: var(--ct-surface-3); --bs-btn-hover-border-color: var(--ct-border); --bs-btn-hover-color: var(--ct-text);
    --bs-btn-active-bg: var(--ct-surface-3); --bs-btn-active-color: var(--ct-text); --bs-btn-active-border-color: var(--ct-brand-2);
    --bs-btn-disabled-color: var(--ct-muted); --bs-btn-disabled-bg: var(--ct-surface-2); --bs-btn-disabled-border-color: var(--ct-border); }
.btn-check:checked + .btn-outline-secondary, .btn-outline-secondary.active { background: var(--ct-soft); border-color: var(--ct-brand-2); color: var(--ct-text); box-shadow: inset 0 0 0 1px var(--ct-brand-2); }
.btn-outline-danger { --bs-btn-bg: transparent; }
.btn-light { --bs-btn-bg: #fff; --bs-btn-color: #2a3a1b; box-shadow: 0 3px 0 rgba(0, 0, 0, .18); }
.btn .material-icons.mi { margin-right: .15rem; }

/* ── Cards, lists, tables, forms ─────────────────────────────────────────────────────────────── */

.card { --bs-card-bg: var(--ct-surface); --bs-card-border-color: var(--ct-border); border: 1px solid var(--ct-border); border-radius: var(--ct-radius);
    box-shadow: var(--ct-shadow-1); background: var(--ct-surface); }
.card-header { background: transparent; font-weight: 700; border-bottom: 1px solid var(--ct-border); padding: .85rem 1rem; display: flex; align-items: center; gap: .5rem; }
.card-header:first-child { border-radius: var(--ct-radius) var(--ct-radius) 0 0; }
.card-header .material-icons { color: var(--ct-brand); font-size: 20px; }
.card.lift { transition: transform .18s ease, box-shadow .18s ease; }
.card.lift:hover { transform: translateY(-3px); box-shadow: var(--ct-shadow-2); }
.list-group { --bs-list-group-bg: transparent; --bs-list-group-border-color: var(--ct-border); --bs-list-group-action-hover-bg: var(--ct-surface-2);
    --bs-list-group-action-active-bg: var(--ct-surface-3); }
.list-group-item { padding: .75rem 1rem; }
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--ct-surface-2); --bs-table-border-color: var(--ct-border); }
.table > :not(caption) > * > * { vertical-align: middle; padding: .7rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ct-muted); font-weight: 700; }
tr[data-href] { cursor: pointer; }
.form-control, .form-select { border-radius: 11px; background-color: var(--ct-surface-2); border-color: var(--ct-border); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus { border-color: var(--ct-brand-2); box-shadow: var(--ct-ring); background-color: var(--ct-surface); }
.form-control-sm, .form-select-sm { border-radius: 9px; padding: .35rem .6rem; }
.form-check-input:checked { background-color: var(--ct-brand); border-color: var(--ct-brand); }
.form-check-input:focus { box-shadow: var(--ct-ring); border-color: var(--ct-brand-2); }
.form-switch .form-check-input { width: 2.4em; height: 1.3em; }
.form-label { font-weight: 600; }
.nav-pills { gap: .35rem; }
.nav-pills .nav-link { border-radius: 12px; color: var(--ct-text); font-weight: 600; background: var(--ct-surface-2); }
.nav-pills .nav-link.active { background: var(--ct-brand); color: #fff; box-shadow: 0 2px 0 var(--ct-brand-strong); }
.nav-tabs { border-bottom-color: var(--ct-border); }
.nav-tabs .nav-link { border: 0; border-bottom: 3px solid transparent; color: var(--ct-muted); font-weight: 600; }
.nav-tabs .nav-link.active { background: transparent; color: var(--ct-text); border-bottom-color: var(--ct-brand); }
.dropdown-menu { --bs-dropdown-bg: var(--ct-surface); --bs-dropdown-border-color: var(--ct-border); --bs-dropdown-link-hover-bg: var(--ct-surface-2);
    --bs-dropdown-link-active-bg: var(--ct-brand); border-radius: 14px; box-shadow: var(--ct-shadow-3); padding: 6px; }
.dropdown-item { border-radius: 9px; padding: .5rem .75rem; font-weight: 500; display: flex; align-items: center; gap: .55rem; }
.dropdown-item .material-icons { font-size: 19px; color: var(--ct-muted); }
.offcanvas { --bs-offcanvas-bg: var(--ct-surface); }
.alert { border-radius: 14px; border: 0; box-shadow: var(--ct-shadow-1); }
.alert-success { background: #e3f3d6; color: #2c5214; }
.alert-danger { background: #fde4df; color: #8a2213; }
[data-bs-theme="dark"] .alert-success { background: #253a17; color: #cfeab4; }
[data-bs-theme="dark"] .alert-danger { background: #43201a; color: #ffc9bd; }
.badge { border-radius: 999px; font-weight: 700; }
details > summary { cursor: pointer; font-weight: 600; }
hr { border-color: var(--ct-border); opacity: 1; }

/* ── Page headers, heroes, illustrated empty states ────────────────────────────────────────── */

.ct-page-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.ct-page-head h1 { margin: 0; font-size: clamp(1.5rem, 2.6vw, 2rem); }
.ct-page-head .lead { margin: .2rem 0 0; color: var(--ct-muted); font-size: 1rem; }
.ct-page-head .ct-head-icon { width: 54px; height: 54px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--ct-brand-2), var(--ct-brand-strong)); color: #fff; box-shadow: 0 6px 16px rgba(78, 122, 39, .3); flex: none; }
.ct-page-head .ct-head-icon .material-icons { font-size: 30px; }
.ct-head-icon { width: 54px; height: 54px; border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--ct-brand-2), var(--ct-brand-strong)); color: #fff; flex: none; }
.ct-head-icon.ct-head-sm { width: 42px; height: 42px; border-radius: 13px; }
.ct-head-icon.gold, .ct-page-head .ct-head-icon.gold { background: linear-gradient(135deg, #f7cd5c, #d99a14); box-shadow: 0 6px 16px rgba(217, 154, 20, .3); }
.ct-head-icon.sky, .ct-page-head .ct-head-icon.sky { background: linear-gradient(135deg, #6fb0f0, #2b6cb0); box-shadow: 0 6px 16px rgba(43, 108, 176, .3); }
.ct-head-icon.coral, .ct-page-head .ct-head-icon.coral { background: linear-gradient(135deg, #ff9a85, #d4513b); box-shadow: 0 6px 16px rgba(212, 81, 59, .3); }
.ct-head-icon.violet, .ct-page-head .ct-head-icon.violet { background: linear-gradient(135deg, #b39ddb, #6a4bb0); box-shadow: 0 6px 16px rgba(106, 75, 176, .3); }
.ct-page-head .ct-head-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.ct-hero { position: relative; overflow: hidden; color: #fff; border-radius: 26px; isolation: isolate;
    background: radial-gradient(120% 140% at 0% 0%, #94c95e 0%, #5d9732 38%, #3a5c1d 100%); box-shadow: var(--ct-shadow-2); }
.ct-hero::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .12;
    background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%), linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%);
    background-size: 64px 64px; background-position: 0 0, 32px 32px; mask-image: linear-gradient(100deg, transparent 30%, #000 100%); -webkit-mask-image: linear-gradient(100deg, transparent 30%, #000 100%); }
.ct-hero .lead { opacity: .94; }
.ct-hero h1 { font-weight: 900; letter-spacing: -.035em; }
.ct-hero-art { width: min(300px, 70%); filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .3)); animation: ct-bob 5s ease-in-out infinite; }
@keyframes ct-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }
.ct-feature { display: flex; gap: .85rem; align-items: flex-start; padding: .9rem 1rem; border-radius: 16px; background: var(--ct-surface); color: var(--ct-text); box-shadow: var(--ct-shadow-1); }
.ct-feature .ic { width: 42px; height: 42px; flex: none; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.ct-feature .ic.g { background: linear-gradient(135deg, #94c95e, #4e7a27); } .ct-feature .ic.y { background: linear-gradient(135deg, #f7cd5c, #d99a14); }
.ct-feature .ic.b { background: linear-gradient(135deg, #6fb0f0, #2b6cb0); } .ct-feature .ic.r { background: linear-gradient(135deg, #ff9a85, #d4513b); }
.ct-feature .ic.v { background: linear-gradient(135deg, #b39ddb, #6a4bb0); } .ct-feature .ic.t { background: linear-gradient(135deg, #6fd3cc, #1b8a84); }

.ct-empty { padding: 2.2rem 1rem; text-align: center; color: var(--ct-muted); display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.ct-empty img { width: 120px; height: 120px; margin-bottom: .4rem; animation: ct-bob 6s ease-in-out infinite; }
.ct-empty.sm { padding: 1.2rem .8rem; }
.ct-empty.sm img { width: 76px; height: 76px; }
.ct-empty h2, .ct-empty .h5 { color: var(--ct-text); margin: 0; }
.ct-empty p { margin: 0 0 .6rem; max-width: 36rem; }
.ct-empty .material-icons { font-size: 48px; color: var(--ct-brand-2); }
.ct-big-icon { font-size: 56px; }
.ct-link-box { word-break: break-all; font-family: var(--bs-font-monospace); background: var(--ct-surface-2); border: 1px dashed var(--ct-border); padding: .65rem .8rem; border-radius: 12px; font-size: .9rem; }

/* ── Avatars: initials in a colour from the name, or a computer opponent's face ───────────────── */

.ct-av { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none;
    font-weight: 800; font-size: .85rem; color: #fff; text-transform: uppercase; letter-spacing: -.02em; position: relative; user-select: none;
    background: linear-gradient(135deg, var(--a1, #94c95e), var(--a2, #4e7a27)); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .12); }
.ct-av img { width: 100%; height: 100%; border-radius: 30%; display: block; }
.ct-av.bot { background: none; box-shadow: none; border-radius: 30%; }
.ct-av.sm { width: 28px; height: 28px; font-size: .7rem; }
.ct-av.lg { width: 56px; height: 56px; font-size: 1.25rem; }
.ct-av.xl { width: 88px; height: 88px; font-size: 2rem; box-shadow: 0 6px 18px rgba(0, 0, 0, .18), inset 0 -3px 0 rgba(0, 0, 0, .12); }
.ct-av .ct-online { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; box-shadow: 0 0 0 2px var(--ct-surface); z-index: 1; }
/* A profile photo laid over the initials (which show through if it fails). */
.ct-av > img.ct-av-pic { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--ct-surface-3); }
.av-0 { --a1: #94c95e; --a2: #4e7a27; } .av-1 { --a1: #6fb0f0; --a2: #2b6cb0; } .av-2 { --a1: #ff9a85; --a2: #d4513b; }
.av-3 { --a1: #f7cd5c; --a2: #d99a14; } .av-4 { --a1: #b39ddb; --a2: #6a4bb0; } .av-5 { --a1: #6fd3cc; --a2: #1b8a84; }
.av-6 { --a1: #f48fb1; --a2: #c2185b; } .av-7 { --a1: #ffb74d; --a2: #e65100; } .av-8 { --a1: #90a4ae; --a2: #455a64; }
.av-9 { --a1: #aed581; --a2: #689f38; }
.ct-online { width: 9px; height: 9px; border-radius: 50%; background: #9e9a92; display: inline-block; flex: none; }
.ct-online.on { background: #4caf50; box-shadow: 0 0 0 0 rgba(76, 175, 80, .6); animation: ct-online 2.4s infinite; }
.ct-online.bot { background: var(--ct-sky); }
@keyframes ct-online { 0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, .5); } 70% { box-shadow: 0 0 0 6px rgba(76, 175, 80, 0); } 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); } }

/* ── Ratings, chips and counts ─────────────────────────────────────────────────────────────── */

.ct-ratings { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: .55rem; }
.ct-rating { background: var(--ct-surface-2); border-radius: 14px; padding: .6rem .75rem; display: flex; align-items: center; gap: .55rem; border: 1px solid var(--ct-border); }
.ct-rating .ic { width: 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.ct-rating .ic .material-icons { font-size: 19px; }
.ct-rating .label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ct-muted); font-weight: 700; }
.ct-rating .value { font-size: 1.25rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.sp-bullet { background: linear-gradient(135deg, #ffd54f, #f2a20c); } .sp-blitz { background: linear-gradient(135deg, #ff9a85, #e5533d); }
.sp-rapid { background: linear-gradient(135deg, #94c95e, #4e7a27); } .sp-classical { background: linear-gradient(135deg, #6fd3cc, #1b8a84); }
.sp-daily { background: linear-gradient(135deg, #6fb0f0, #2b6cb0); } .sp-puzzles { background: linear-gradient(135deg, #b39ddb, #6a4bb0); }
.sp-unlimited, .sp-correspondence { background: linear-gradient(135deg, #90a4ae, #455a64); }
.ct-turn-badge { background: var(--ct-brand); color: #fff; border-radius: 999px; padding: .15rem .6rem; font-size: .78rem; font-weight: 800; white-space: nowrap;
    box-shadow: 0 2px 8px rgba(106, 161, 58, .35); }
.ct-turn-badge.pulse { animation: ct-pulse 1.8s ease-in-out infinite; }
@keyframes ct-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.ct-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; background: var(--ct-surface-2); border: 1px solid var(--ct-border);
    font-size: .8rem; font-weight: 600; color: var(--ct-muted); white-space: nowrap; }
.ct-chip .material-icons { font-size: 15px; }
.ct-chip.live { background: #fde4df; color: #c0392b; border-color: transparent; }
.ct-chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: ct-blink 1.2s infinite; }
[data-bs-theme="dark"] .ct-chip.live { background: #4a1f18; color: #ff8a75; }
@keyframes ct-blink { 50% { opacity: .25; } }
.ct-count { background: var(--ct-coral); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: .05rem .45rem; min-width: 1.4rem; text-align: center; }
.ct-count:empty { display: none; }
.ct-form { font-family: var(--bs-font-monospace); letter-spacing: 1px; }
.ct-leader-1 { font-weight: 800; }
.ct-rating-line { fill: none; stroke: var(--ct-brand-2); stroke-width: 2; vector-effect: non-scaling-stroke; }
.ct-medal { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; align-items: center; justify-content: center; font-size: .78rem; font-weight: 800; background: var(--ct-surface-3); }
.ct-medal.m1 { background: linear-gradient(135deg, #ffe082, #f2b632); color: #5a3d00; }
.ct-medal.m2 { background: linear-gradient(135deg, #eceff1, #b0bec5); color: #37474f; }
.ct-medal.m3 { background: linear-gradient(135deg, #ffcc80, #c77d3a); color: #4a2a0b; }

/* ── Profile ── */
.ct-profile-card { background: linear-gradient(135deg, var(--ct-soft), var(--ct-surface) 60%); }
.ct-score-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.ct-score { border-radius: 14px; padding: .6rem; text-align: center; background: var(--ct-surface-2); }
.ct-score b { display: block; font-size: 1.6rem; font-weight: 900; line-height: 1.1; }
.ct-score span { font-size: .75rem; color: var(--ct-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.ct-score.win b { color: #43a047; } .ct-score.loss b { color: #e5533d; } .ct-score.draw b { color: var(--ct-muted); }

/* ── Home ───────────────────────────────────────────────────────────────────────────────────── */

.ct-greet { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.1rem; }
.ct-greet img { width: 64px; height: 64px; }
.ct-greet h1 { margin: 0; font-size: clamp(1.35rem, 2.4vw, 1.8rem); }
.ct-greet p { margin: 0; color: var(--ct-muted); }
.ct-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
@media (max-width: 767.98px) { .ct-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ct-tile { position: relative; overflow: hidden; display: flex; flex-direction: column; gap: .15rem; padding: 1rem 1rem .9rem; border-radius: 18px; text-decoration: none;
    color: #fff; min-height: 116px; box-shadow: var(--ct-shadow-1); transition: transform .18s cubic-bezier(.2, .8, .3, 1.3), box-shadow .18s; isolation: isolate; border: 0; text-align: left; }
.ct-tile::after { content: ""; position: absolute; right: -18px; bottom: -22px; width: 96px; height: 96px; border-radius: 50%; background: rgba(255, 255, 255, .14); z-index: -1; }
.ct-tile:hover { transform: translateY(-4px) scale(1.015); box-shadow: var(--ct-shadow-2); color: #fff; }
.ct-tile:active { transform: translateY(0) scale(.98); }
.ct-tile .material-icons { font-size: 30px; margin-bottom: auto; }
.ct-tile strong { font-size: 1.08rem; font-weight: 800; letter-spacing: -.01em; }
.ct-tile small { opacity: .9; font-weight: 500; }
.ct-tile.bullet { background: linear-gradient(140deg, #ffd54f, #f29a0c); color: #3d2700; } .ct-tile.bullet:hover { color: #3d2700; }
.ct-tile.blitz { background: linear-gradient(140deg, #ff9a85, #df4a33); }
.ct-tile.rapid { background: linear-gradient(140deg, #94c95e, #4e7a27); }
.ct-tile.daily { background: linear-gradient(140deg, #6fb0f0, #2b6cb0); }
.ct-tile.friend { background: linear-gradient(140deg, #b39ddb, #6a4bb0); }
.ct-tile.bot { background: linear-gradient(140deg, #6fd3cc, #1b8a84); }
.ct-tile.puzzle { background: linear-gradient(140deg, #f48fb1, #c2185b); }
.ct-tile.lesson { background: linear-gradient(140deg, #ffb74d, #e65100); }
.ct-bot-strip { display: flex; gap: .6rem; overflow-x: auto; padding: .25rem .1rem .6rem; scroll-snap-type: x mandatory; scrollbar-width: thin; scrollbar-color: var(--ct-surface-3) transparent; }
.ct-bot-chip { scroll-snap-align: start; flex: none; width: 96px; display: flex; flex-direction: column; align-items: center; gap: .3rem; text-decoration: none; color: var(--ct-text);
    padding: .6rem .3rem; border-radius: 16px; transition: background .15s, transform .15s; }
.ct-bot-chip:hover { background: var(--ct-surface-2); transform: translateY(-2px); color: var(--ct-text); }
.ct-bot-chip img { width: 62px; height: 62px; border-radius: 30%; box-shadow: var(--ct-shadow-1); }
.ct-bot-chip strong { font-size: .8rem; text-align: center; line-height: 1.15; }
.ct-bot-chip small { font-size: .72rem; color: var(--ct-muted); font-weight: 600; }
.ct-turn-boards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.ct-turn-board { text-decoration: none; color: var(--ct-text); border-radius: 14px; padding: .5rem; background: var(--ct-surface-2); border: 1px solid var(--ct-border);
    transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; gap: .35rem; }
.ct-turn-board:hover { transform: translateY(-3px); box-shadow: var(--ct-shadow-2); color: var(--ct-text); }
.ct-turn-board.mine { border-color: var(--ct-brand-2); box-shadow: 0 0 0 2px rgba(129, 182, 76, .35); }
.ct-turn-board .who { display: flex; align-items: center; gap: .4rem; font-weight: 700; font-size: .85rem; min-width: 0; }
.ct-turn-board .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-turn-board .meta { display: flex; justify-content: space-between; align-items: center; font-size: .75rem; color: var(--ct-muted); gap: .3rem; }
.ct-puzzle-card { display: flex; gap: 1rem; align-items: center; text-decoration: none; color: var(--ct-text); }
.ct-puzzle-card .ct-mini { width: 110px; flex: none; }
.ct-game-row td { white-space: nowrap; }

/* ── The game page ─────────────────────────────────────────────────────────────────────────── */

.ct-game { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }
.ct-game.with-eval { grid-template-columns: 22px minmax(0, 1fr) 360px; }
.ct-game.with-eval > .ct-board-wrap { grid-column: 2; }
.ct-game.with-eval > .ct-side { grid-column: 3; }
.ct-game.with-eval:has(> .ct-eval-bar.d-none) { grid-template-columns: minmax(0, 1fr) 360px; }
.ct-game.with-eval:has(> .ct-eval-bar.d-none) > .ct-board-wrap { grid-column: 1; }
.ct-game.with-eval:has(> .ct-eval-bar.d-none) > .ct-side { grid-column: 2; }
@media (max-width: 991.98px) { .ct-game, .ct-game.with-eval, .ct-game.with-eval:has(> .ct-eval-bar.d-none) { grid-template-columns: minmax(0, 1fr); }
    .ct-game > .ct-board-wrap, .ct-game > .ct-side, .ct-game.with-eval > .ct-board-wrap, .ct-game.with-eval > .ct-side { grid-column: 1 !important; } .ct-eval-bar { display: none !important; } }
.ct-board-wrap { max-width: min(100%, calc(100vh - 250px)); width: 100%; margin: 0 auto; }
@media (max-width: 991.98px) { .ct-board-wrap { max-width: 100%; } }
.ct-player { display: flex; align-items: center; gap: .6rem; padding: .45rem .55rem; min-height: 56px; margin: .35rem 0; border-radius: 14px; background: var(--ct-surface);
    border: 1px solid var(--ct-border); box-shadow: var(--ct-shadow-1); transition: box-shadow .25s, border-color .25s; }
.ct-player.to-move { border-color: rgba(129, 182, 76, .6); box-shadow: 0 0 0 3px rgba(129, 182, 76, .18); }
.ct-player .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.ct-player .who-top { display: flex; align-items: center; gap: .35rem; min-width: 0; }
.ct-player a { font-weight: 800; color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-player a:hover { text-decoration: underline; }
.ct-player .rating { color: var(--ct-muted); font-weight: 600; font-size: .85rem; }
.ct-player .material { font-size: .95rem; color: var(--ct-muted); letter-spacing: -2px; white-space: nowrap; overflow: hidden; min-height: 1.1em; }
.ct-player .material b { letter-spacing: 0; font-weight: 700; margin-left: 4px; color: var(--ct-text); font-size: .8rem; }
.ct-clock { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 1.55rem; font-weight: 800; padding: .25rem .8rem; border-radius: 11px;
    background: var(--ct-surface-3); color: var(--ct-muted); min-width: 6.6rem; text-align: right; letter-spacing: -.01em; transition: background .2s, color .2s, box-shadow .2s; display: inline-flex; align-items: center; justify-content: flex-end; gap: .3rem; }
.ct-clock.running { background: #fff; color: #111; box-shadow: 0 0 0 2px var(--ct-brand-2), 0 4px 16px rgba(129, 182, 76, .35); }
.ct-clock.running::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ct-brand); animation: ct-blink 1s infinite; }
[data-bs-theme="dark"] .ct-clock.running { background: #f1efe9; }
.ct-clock.low { color: #c0392b; }
.ct-clock.low.running { background: #ffe1dc; color: #b00020; box-shadow: 0 0 0 2px #e53935, 0 4px 18px rgba(229, 57, 53, .45); animation: ct-low 1s ease-in-out infinite; }
.ct-clock.low.running::before { background: #e53935; }
@keyframes ct-low { 50% { box-shadow: 0 0 0 4px rgba(229, 57, 53, .55), 0 4px 22px rgba(229, 57, 53, .6); } }
.ct-clock.none { display: none; }
.ct-clock.daily { font-size: .95rem; min-width: 0; }
.ct-side { display: flex; flex-direction: column; gap: .8rem; }
.ct-side > .card { padding: .85rem !important; }
/* Phones and tablets: whose move it is and the game's buttons sit straight under the board, above the move list. */
@media (max-width: 991.98px) {
    .ct-side > #status { order: -3; }
    .ct-side > .ct-offer, .ct-side > #draw-sent, .ct-side > .ct-main-controls { order: -2; }
}
.ct-game-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; color: var(--ct-muted); }
.ct-status { font-weight: 700; padding: .7rem .85rem; border-radius: 12px; background: var(--ct-surface-2); display: flex; align-items: center; gap: .5rem; }
.ct-status::before { font-family: 'Material Icons'; font-feature-settings: 'liga'; line-height: 1; font-size: 20px; content: "hourglass_top"; color: var(--ct-muted); font-weight: normal; }
.ct-status.mine { background: linear-gradient(135deg, var(--ct-brand-2), var(--ct-brand)); color: #fff; box-shadow: 0 4px 14px rgba(106, 161, 58, .35); }
.ct-status.mine::before { content: "touch_app"; color: #fff; }
.ct-status.over { background: var(--ct-surface-3); }
.ct-status.over::before { content: "flag"; }
.ct-moves { max-height: 340px; overflow: auto; font-size: .93rem; scrollbar-width: thin; padding-right: 2px; }
.ct-move-row { display: grid; grid-template-columns: 2.6rem 1fr 1fr; gap: 3px; padding: 2px 0; border-radius: 8px; }
.ct-move-row:nth-child(odd) { background: var(--ct-surface-2); }
.ct-move-no { color: var(--ct-muted); padding: .25rem .4rem; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ct-move { border: 0; background: transparent; text-align: left; padding: .25rem .5rem; color: inherit; border-radius: 8px; font-weight: 700; transition: background .12s; }
.ct-move:hover { background: var(--ct-soft); }
.ct-move.current { background: var(--ct-brand); color: #fff; box-shadow: 0 2px 6px rgba(106, 161, 58, .4); }
.ct-move-result { text-align: center; padding: .5rem; font-weight: 800; }
.ct-class { display: inline-block; min-width: 1.4em; margin-left: .3em; padding: 0 .3em; border-radius: 6px; font-size: .74rem; color: #fff; text-align: center; font-weight: 800; }
.c-Brilliant { --c: #1baca6; } .c-Great { --c: #5c8bb0; } .c-Best { --c: #81b64c; } .c-Excellent { --c: #96bc4b; } .c-Good { --c: #96af8b; }
.c-Book { --c: #a88865; } .c-Inaccuracy { --c: #f7c631; } .c-Mistake { --c: #e58f2a; } .c-Miss { --c: #ee6b55; } .c-Blunder { --c: #ca3431; } .c-Forced { --c: #96af8b; }
.ct-class[class*="c-"] { background: var(--c); }
.btn-link[class*="c-"] { color: var(--c); font-weight: 700; }
.ct-review-head { display: flex; align-items: center; gap: .4rem; padding: .6rem .7rem; border-radius: 12px; background: var(--ct-soft); }
.ct-eval { font-variant-numeric: tabular-nums; font-weight: 800; }
.ct-controls { display: flex; flex-wrap: wrap; gap: .45rem; }
.ct-nav-btns { display: flex; gap: .3rem; }
.ct-nav-btns .btn { flex: 1; }
.ct-toolbar { display: flex; gap: .3rem; flex-wrap: wrap; }
.ct-toolbar .btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; }
.ct-tool { width: 40px; height: 40px; padding: 0; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.ct-tool .material-icons { font-size: 21px; margin: 0 !important; }
.ct-eval-bar { position: relative; width: 22px; align-self: stretch; background: #403d39; border-radius: 8px; overflow: hidden; min-height: 300px; margin: 70px 0; }
.ct-eval-bar .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #f1f1f1; transition: height .4s ease; }
.ct-eval-bar.flipped .fill { bottom: auto; top: 0; background: #f1f1f1; }
.ct-eval-bar .txt { position: absolute; left: 0; right: 0; bottom: 4px; font-size: 10px; font-weight: 800; text-align: center; color: #333; }
.ct-offer { display: flex; align-items: center; gap: .5rem; padding: .65rem .75rem; border-radius: 14px; background: #fff4cc; color: #5a4300; flex-wrap: wrap;
    box-shadow: var(--ct-shadow-1); animation: ct-slide-in .3s cubic-bezier(.2, .9, .3, 1.2); }
[data-bs-theme="dark"] .ct-offer { background: #3a3220; color: #f3e1a6; }
@keyframes ct-slide-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.ct-chat-lines { max-height: 200px; overflow: auto; font-size: .9rem; display: flex; flex-direction: column; gap: 4px; }
.ct-chat-line { padding: .3rem .55rem; border-radius: 10px; background: var(--ct-surface-2); align-self: flex-start; max-width: 100%; overflow-wrap: anywhere; }
.ct-chat-line.system { color: var(--ct-muted); font-style: italic; background: transparent; padding: 0 .2rem; }
.ct-chat-line.instructor { background: var(--ct-soft); }

/* ── Chat (js/chat.js): bubbles in runs, notes, chips, the composer and the emoji picker ───────────────── */

.ct-chat-wrap { position: relative; display: flex; flex-direction: column; min-height: 0; }
.ct-chat-log { gap: 6px; padding: 2px 2px 4px; scrollbar-width: thin; }
#chat .ct-chat-log { max-height: 280px; min-height: 90px; }
.ct-drawer .ct-chat-wrap { flex: 1; }
.ct-drawer .ct-chat-wrap > .ct-chat-lines { flex: 1; min-height: 0; }
.ct-msg-empty { color: var(--ct-muted); font-size: .85rem; text-align: center; padding: 1rem .5rem; }
.ct-msg-note { align-self: center; max-width: 92%; text-align: center; color: var(--ct-muted); font-size: .78rem; font-weight: 600; padding: .15rem .6rem;
    border-radius: 999px; background: var(--ct-surface-2); overflow-wrap: anywhere; }
.ct-msg-run { display: flex; align-items: flex-end; gap: .45rem; max-width: 100%; }
.ct-msg-run > .ct-av { align-self: flex-start; margin-top: 1.1rem; }
.ct-msg-run.mine { flex-direction: row-reverse; }
.ct-msg-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: calc(100% - 40px); align-items: flex-start; }
.ct-msg-run.mine .ct-msg-body { align-items: flex-end; }
.ct-msg-head { display: flex; align-items: baseline; gap: .4rem; font-size: .74rem; padding: 0 .35rem; min-width: 0; }
.ct-msg-name { font-weight: 800; color: var(--ct-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-msg-time { color: var(--ct-muted); font-variant-numeric: tabular-nums; }
.ct-msg-badge { background: var(--ct-brand); color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; }
.ct-msg { padding: .38rem .65rem; border-radius: 14px 14px 14px 5px; background: var(--ct-surface-2); color: var(--ct-text); max-width: 100%;
    overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.4; border: 1px solid var(--ct-border); }
.ct-msg + .ct-msg { border-top-left-radius: 5px; }
.ct-msg-run.mine .ct-msg { background: var(--ct-brand); color: #fff; border-color: transparent; border-radius: 14px 14px 5px 14px; }
.ct-msg-run.mine .ct-msg + .ct-msg { border-top-right-radius: 5px; }
.ct-msg-run.instructor:not(.mine) .ct-msg { background: var(--ct-soft); border-color: rgba(129, 182, 76, .35); }
.ct-msg .ct-chat-pin { margin-left: .35rem; vertical-align: 1px; }
.ct-chat-newer { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); z-index: 2; display: inline-flex; align-items: center; gap: .25rem;
    border: 0; border-radius: 999px; padding: .25rem .75rem .25rem .55rem; background: var(--ct-brand); color: #fff; font-size: .78rem; font-weight: 800;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .25); animation: ct-slide-in .25s; }
.ct-chat-newer .material-icons { font-size: 16px; }

/* Move and square chips: buttons in a message (and their look in captions). */
.ct-cchip { display: inline-flex; align-items: center; gap: .1rem; margin: 0 .05rem; padding: 0 .4rem; border-radius: 7px; vertical-align: baseline;
    border: 1px solid rgba(192, 38, 211, .35); background: rgba(192, 38, 211, .1); color: inherit; font: inherit; font-weight: 800; line-height: 1.35;
    white-space: nowrap; cursor: pointer; transition: background .12s, box-shadow .12s; }
.ct-cchip.square { font-family: var(--bs-font-monospace); font-size: .92em; }
.ct-cchip.square::before { content: ""; width: .5em; height: .5em; margin-right: .15em; border-radius: 2px; background: currentColor; opacity: .55; }
span.ct-cchip { cursor: default; }
button.ct-cchip:hover, button.ct-cchip.on { background: rgba(192, 38, 211, .22); box-shadow: 0 0 0 2px rgba(192, 38, 211, .45); }
.ct-msg-run.mine .ct-cchip { border-color: rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .18); }
.ct-msg-run.mine button.ct-cchip:hover, .ct-msg-run.mine button.ct-cchip.on { background: rgba(255, 255, 255, .32); box-shadow: 0 0 0 2px rgba(255, 255, 255, .6); }
.ct-caption .ct-cchip { border-color: rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .14); }
.ct-pinned .ct-cchip { border-color: rgba(122, 90, 0, .4); background: rgba(255, 255, 255, .5); }

/* The composer. */
.ct-composer { position: relative; }
.ct-composer-row { display: flex; align-items: center; gap: .3rem; }
.ct-composer-row > .form-control { flex: 1; min-width: 0; }
.ct-composer-btn { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--ct-border); background: var(--ct-surface-2); color: var(--ct-text);
    font-size: 1.05rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; padding: 0; transition: background .12s; }
.ct-composer-btn:hover, .ct-composer-btn[aria-expanded="true"] { background: var(--ct-surface-3); }
.ct-composer-foot { display: flex; align-items: flex-start; gap: .5rem; margin-top: .3rem; font-size: .72rem; color: var(--ct-muted); line-height: 1.3; }
.ct-composer-hint { flex: 1; min-width: 0; }
.ct-composer-count { flex: none; font-variant-numeric: tabular-nums; font-weight: 600; }
.ct-composer-count.near { color: #d4513b; }
.ct-drawer .ct-composer-foot { padding: 0 .1rem; }

/* The emoji picker: quick phrases, groups as tabs, a grid of emoji. */
.ct-emoji-pop { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 1070; width: min(330px, 100%); max-height: min(360px, 60vh); overflow: auto;
    background: var(--ct-surface); border: 1px solid var(--ct-border); border-radius: 16px; box-shadow: var(--ct-shadow-3); padding: .5rem; animation: ct-slide-in .2s; }
.ct-emoji-pop[hidden] { display: none; }
.ct-emoji-phrases { display: flex; flex-wrap: wrap; gap: .3rem; padding-bottom: .45rem; margin-bottom: .4rem; border-bottom: 1px solid var(--ct-border); }
.ct-phrase { border: 1px solid var(--ct-border); background: var(--ct-surface-2); color: var(--ct-text); border-radius: 999px; padding: .15rem .55rem; font-size: .78rem; font-weight: 600; }
.ct-phrase:hover { background: var(--ct-soft); }
.ct-emoji-tabs { display: flex; gap: .2rem; margin-bottom: .3rem; }
.ct-emoji-tab { flex: 1; border: 0; border-radius: 10px; background: transparent; font-size: 1.1rem; padding: .25rem 0; line-height: 1.2; }
.ct-emoji-tab[hidden] { display: none; }
.ct-emoji-tab:hover { background: var(--ct-surface-2); }
.ct-emoji-tab.on { background: var(--ct-soft); box-shadow: inset 0 -2px 0 var(--ct-brand); }
.ct-emoji-title { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--ct-muted); padding: .1rem .2rem .25rem; }
.ct-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.ct-emoji { border: 0; background: transparent; border-radius: 8px; font-size: 1.3rem; line-height: 1; aspect-ratio: 1; padding: 0; display: flex; align-items: center; justify-content: center; }
.ct-emoji:hover, .ct-emoji:focus-visible { background: var(--ct-surface-3); }
@media (hover: none) { .ct-emoji { font-size: 1.45rem; } .ct-composer-btn { width: 38px; height: 38px; } }

/* Settings: your photo. */
.ct-photo-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.ct-photo-now { flex: none; }
.ct-photo-preview { display: inline-block; width: 88px; height: 88px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 3px var(--ct-brand-2), 0 6px 18px rgba(0, 0, 0, .18); }
.ct-photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ct-end { position: fixed; inset: 0; background: rgba(10, 10, 8, .5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 1050; padding: 16px; animation: ct-fade .25s; }
.ct-end .card { width: min(380px, 100%); text-align: center; border-radius: 24px; overflow: hidden; box-shadow: var(--ct-shadow-3); animation: ct-pop-in .45s cubic-bezier(.2, 1.3, .4, 1); }
.ct-end .ct-end-art { margin: -1.5rem -1.5rem 1rem; padding: 1.2rem 1rem .4rem; background: radial-gradient(120% 120% at 50% 0%, #a8d07a, #4e7a27); }
.ct-end .ct-end-art.lost { background: radial-gradient(120% 120% at 50% 0%, #b0bec5, #546e7a); }
.ct-end .ct-end-art.draw { background: radial-gradient(120% 120% at 50% 0%, #ffe082, #c99a1f); }
.ct-end .ct-end-art img { width: 120px; height: 120px; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .25)); }
@keyframes ct-pop-in { from { opacity: 0; transform: scale(.85) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ct-fade { from { opacity: 0; } to { opacity: 1; } }
.ct-line { display: flex; gap: .6rem; padding: .3rem .4rem; border-radius: 8px; cursor: pointer; font-size: .9rem; }
.ct-line:hover { background: var(--ct-soft); }
.ct-line .ct-eval { min-width: 3.6rem; }
.ct-pv { color: var(--ct-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-acc { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.ct-acc-w, .ct-acc-b { font-size: 1.6rem; font-weight: 900; text-align: center; padding: .25rem; border-radius: 12px; }
.ct-acc-w { background: #f4f4f4; color: #222; }
.ct-acc-b { background: #333; color: #eee; }
.ct-acc-label { color: var(--ct-muted); font-size: .78rem; text-transform: uppercase; font-weight: 700; }
.ct-counts td { padding: .15rem .3rem; }
#eval-graph { width: 100%; height: 90px; display: block; background: #403d39; border-radius: 10px; cursor: pointer; }
#eval-graph .graph-white { fill: #f1f1f1; }
#eval-graph .graph-mid { stroke: #999; stroke-width: 1; stroke-dasharray: 4 3; }
#eval-graph .graph-dot { stroke: #fff; stroke-width: 1.5; fill: var(--c); }
.ct-coach-lines { max-height: 320px; overflow: auto; font-size: .92rem; }
.ct-coach-q { background: var(--ct-soft); border-radius: 14px 14px 4px 14px; padding: .45rem .7rem; margin: .4rem 0 .4rem 2rem; }
.ct-coach-a { padding: .2rem .2rem; }
.ct-coach-a p { margin-bottom: .4rem; }

/* ── Bots, time controls ───────────────────────────────────────────────────────────────────── */

.ct-bot { cursor: pointer; border: 2px solid var(--ct-border); transition: border-color .15s, transform .15s, box-shadow .15s; }
.ct-bot:hover { transform: translateY(-2px); box-shadow: var(--ct-shadow-2); }
.ct-bot.active { border-color: var(--ct-brand-2); box-shadow: 0 0 0 3px rgba(129, 182, 76, .25); background: var(--ct-soft); }
.ct-bot img { width: 58px; height: 58px; border-radius: 30%; flex: none; box-shadow: var(--ct-shadow-1); transition: transform .25s cubic-bezier(.2, 1.4, .4, 1); }
.ct-bot.active img, .ct-bot:hover img { transform: rotate(-4deg) scale(1.06); }
.ct-bot .material-icons { font-size: 34px; color: var(--ct-brand); }
.ct-tc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: .4rem; }
.ct-tc-grid .btn { padding: .55rem .3rem; }
.ct-tc-grid .btn.active { background: var(--ct-brand); color: #fff; border-color: var(--ct-brand); box-shadow: 0 2px 0 var(--ct-brand-strong); }
.ct-tc-group { display: flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ct-muted); margin: .8rem 0 .35rem; }
.ct-tc-group .material-icons { font-size: 17px; }

/* ── Puzzles ───────────────────────────────────────────────────────────────────────────────── */

.ct-puzzle-msg { font-weight: 700; padding: .7rem .85rem; border-radius: 12px; background: var(--ct-surface-2); }
.ct-puzzle-msg.ok { background: #dff3cf; color: #245b0e; animation: ct-pop-in .35s; }
.ct-puzzle-msg.bad { background: #fde0dc; color: #8a1c13; animation: fun-shake .4s; }
[data-bs-theme="dark"] .ct-puzzle-msg.ok { background: #243a15; color: #cfeab4; }
[data-bs-theme="dark"] .ct-puzzle-msg.bad { background: #43201a; color: #ffc9bd; }

/* ── Learn to Play ─────────────────────────────────────────────────────────────────────────── */

.ct-learn-say { display: flex; gap: .75rem; align-items: flex-start; }
.ct-learn-say img { width: 56px; height: 56px; flex: none; }
.ct-learn-say p { margin: 0; font-size: 1.05rem; line-height: 1.5; }
.ct-learn-stars { color: #e0a400; white-space: nowrap; letter-spacing: .05em; }
.ct-learn-finish-art { width: 96px; height: 96px; }
.ct-learn-noboard { display: none; }
.ct-learn-bar { display: block; width: 100%; height: .55rem; border: 0; border-radius: 99px; overflow: hidden; background: var(--ct-surface-2); accent-color: #4e7a27; }
.ct-learn-bar::-webkit-progress-bar { background: var(--ct-surface-2); }
.ct-learn-bar::-webkit-progress-value { background: #5f9a2f; }
.ct-learn-bar::-moz-progress-bar { background: #5f9a2f; }
/* The guiding hand: a see-through hand and a ghost of the piece, sized and placed like a piece (translate in % of a square). */
.ct-learn-guide { position: absolute; inset: 0; pointer-events: none; z-index: 30; visibility: hidden; }
.ct-learn-guide.on { visibility: visible; }
.ct-learn-ghost, .ct-learn-hand { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; opacity: 0; will-change: transform, opacity; }
.ct-learn-ghost { background-size: cover; }
.ct-learn-hand svg { position: absolute; left: 16%; top: 48%; width: 90%; height: 90%; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35)); }
.ct-sq.mark-learn { box-shadow: inset 0 0 0 100px rgba(66, 133, 244, .42); }
.ct-sq.mark-found { box-shadow: inset 0 0 0 100px rgba(76, 175, 80, .62); }
.ct-sq.ct-sq.mark-learn::after, .ct-sq.ct-sq.mark-found::after { content: none; }
.ct-sq.ct-sq.mark-star::after { content: "\2605"; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0; background: none; box-shadow: none; display: flex; align-items: center; justify-content: center; font-size: 3.4em; line-height: 1; color: #f2b632; text-shadow: 0 1px 2px rgba(0, 0, 0, .55); pointer-events: none; }
/* Squares, moves and files named in Knightly's words: the words and the board share a colour (LessonRefs in Core). */
.ct-learn-practice-link { z-index: 2; }
.ct-ref { border-radius: .3em; padding: 0 .28em; color: #fff; font-weight: 600; white-space: nowrap; }
.ct-sq.ct-sq.mark-ref:not(.mark-star)::after { content: none; }
.ct-ref-0 { background: #2563eb; }
.ct-sq.mark-ref-0 { box-shadow: inset 0 0 0 .32em #2563eb, inset 0 0 0 100px rgba(37, 99, 235, .38); }
.ct-sq.mark-ref-0-l { box-shadow: inset 0 0 0 100px rgba(37, 99, 235, .2); }
.ct-ref-1 { background: #ea580c; }
.ct-sq.mark-ref-1 { box-shadow: inset 0 0 0 .32em #ea580c, inset 0 0 0 100px rgba(234, 88, 12, .38); }
.ct-sq.mark-ref-1-l { box-shadow: inset 0 0 0 100px rgba(234, 88, 12, .2); }
.ct-ref-2 { background: #9333ea; }
.ct-sq.mark-ref-2 { box-shadow: inset 0 0 0 .32em #9333ea, inset 0 0 0 100px rgba(147, 51, 234, .38); }
.ct-sq.mark-ref-2-l { box-shadow: inset 0 0 0 100px rgba(147, 51, 234, .2); }
.ct-ref-3 { background: #db2777; }
.ct-sq.mark-ref-3 { box-shadow: inset 0 0 0 .32em #db2777, inset 0 0 0 100px rgba(219, 39, 119, .38); }
.ct-sq.mark-ref-3-l { box-shadow: inset 0 0 0 100px rgba(219, 39, 119, .2); }
.ct-ref-4 { background: #0f766e; }
.ct-sq.mark-ref-4 { box-shadow: inset 0 0 0 .32em #0f766e, inset 0 0 0 100px rgba(13, 148, 136, .38); }
.ct-sq.mark-ref-4-l { box-shadow: inset 0 0 0 100px rgba(13, 148, 136, .2); }
.ct-ref-5 { background: #b45309; }
.ct-sq.mark-ref-5 { box-shadow: inset 0 0 0 .32em #b45309, inset 0 0 0 100px rgba(180, 83, 9, .38); }
.ct-sq.mark-ref-5-l { box-shadow: inset 0 0 0 100px rgba(180, 83, 9, .2); }

/* ── Tournament page ───────────────────────────────────────────────────────────────────────── */

.ct-tgames { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .8rem; }
.ct-tgame { padding: .55rem; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.ct-tgame:hover { transform: translateY(-3px); box-shadow: var(--ct-shadow-2); }
.ct-tgame.live { box-shadow: 0 0 0 2px var(--ct-brand-2); }
.ct-tgame-player { font-size: .8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: .15rem 0; }
.ct-tgame-status { font-size: .75rem; color: var(--ct-muted); }

/* ── Toasts ────────────────────────────────────────────────────────────────────────────────── */

#ct-toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 2000; max-width: min(380px, calc(100vw - 32px)); }
.ct-toast { display: flex; align-items: center; gap: .65rem; background: #23211d; color: #fff; padding: .7rem .8rem .7rem .7rem; border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35); text-decoration: none; transition: opacity .35s, transform .35s; animation: ct-toast-in .35s cubic-bezier(.2, 1.2, .4, 1); }
.ct-toast:hover { color: #fff; }
.ct-toast .ic { width: 32px; height: 32px; border-radius: 10px; flex: none; display: inline-flex; align-items: center; justify-content: center; background: var(--ct-brand); }
.ct-toast .ic .material-icons { font-size: 19px; }
.ct-toast.warn .ic { background: #e5533d; }
.ct-toast.turn .ic { background: var(--ct-gold); color: #3d2700; }
.ct-toast .txt { flex: 1; font-weight: 500; font-size: .92rem; line-height: 1.3; }
.ct-toast .act { flex: none; border: 0; border-radius: 9px; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 700; font-size: .8rem; padding: .3rem .55rem; }
.ct-toast .act:hover { background: rgba(255, 255, 255, .24); }
.ct-toast.gone { opacity: 0; transform: translateX(16px); }
@keyframes ct-toast-in { from { opacity: 0; transform: translateY(12px) scale(.96); } to { opacity: 1; transform: none; } }

/* ── Skeletons (while a list loads) ──────────────────────────────────────────────────────────── */

.ct-skel { border-radius: 10px; background: linear-gradient(90deg, var(--ct-surface-2) 0%, var(--ct-surface-3) 40%, var(--ct-surface-2) 80%); background-size: 300% 100%; animation: ct-shimmer 1.4s infinite linear; min-height: 1rem; }
@keyframes ct-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ── Settings: board themes and a live preview ─────────────────────────────────────────────────── */

.ct-theme-swatch { width: 44px; height: 44px; border-radius: 10px; display: inline-block; box-shadow: var(--ct-shadow-1);
    background-image: linear-gradient(45deg, var(--dark) 25%, transparent 25%, transparent 75%, var(--dark) 75%), linear-gradient(45deg, var(--dark) 25%, var(--light) 25%, var(--light) 75%, var(--dark) 75%);
    background-size: 22px 22px; background-position: 0 0, 11px 11px; }
.ct-theme-swatch.green { --light: #eeeed2; --dark: #769656; } .ct-theme-swatch.brown { --light: #f0d9b5; --dark: #b58863; }
.ct-theme-swatch.blue { --light: #dee3e6; --dark: #8ca2ad; } .ct-theme-swatch.grey { --light: #e0e0e0; --dark: #9e9e9e; }
.ct-theme-swatch.purple { --light: #efe6f7; --dark: #8e6bb3; } .ct-theme-swatch.wood { --light: #e8c99b; --dark: #a0703e; }
.btn-check:checked + .btn .ct-theme-swatch { box-shadow: 0 0 0 3px var(--ct-brand-2); }
.ct-preview { position: sticky; top: 76px; }
.ct-preview-box { max-width: 320px; margin: 0 auto; }
.ct-preview-board { position: relative; }
.ct-swatch-btn { display: inline-flex; flex-direction: column; align-items: center; gap: .3rem; padding: .45rem .55rem; font-size: .78rem; text-transform: capitalize; }

/* ── Lost connection: the board dims and says so; nothing can be moved until the server answers again. ── */

.ct-board-box { position: relative; }
.ct-conn { position: absolute; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.ct-conn.lost { background: rgba(20, 20, 20, .55); pointer-events: auto; border-radius: 8px; backdrop-filter: grayscale(.7); }
.ct-conn .ct-conn-lost, .ct-conn .ct-conn-back { display: none; max-width: 80%; text-align: center; color: #fff; background: #262421; padding: 1rem 1.2rem; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.ct-conn.lost .ct-conn-lost { display: block; animation: ct-pop-in .3s; }
.ct-conn.back { align-items: flex-start; padding-top: 12px; }
.ct-conn.back .ct-conn-back { display: block; background: #2e7d32; padding: .5rem .9rem; animation: ct-pop-in .3s; }
.ct-conn-lost strong { display: block; font-size: 1.1rem; margin: .4rem 0; }
.ct-spinner { display: inline-block; width: 28px; height: 28px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: ct-spin .9s linear infinite; }
@keyframes ct-spin { to { transform: rotate(360deg); } }

/* ── Sign-in pages ─────────────────────────────────────────────────────────────────────────── */

.ct-auth { max-width: 440px; margin: 2vh auto 0; }
.ct-auth .card { padding: 1.6rem !important; border-radius: 22px; box-shadow: var(--ct-shadow-2); }
.ct-auth .ct-auth-art { display: block; width: 92px; height: 92px; margin: -0.4rem auto .6rem; }

/* ── Pop-out windows (?view=board / ?view=video) ─────────────────────────────────────────────────── */

body.ct-bare { background: #161512; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 8px; }
body.ct-bare .ct-bare-board { width: min(100vw - 16px, 100vh - 16px); }
body.ct-bare .ct-bare-video { position: fixed; inset: 0; background: #000; }
body.ct-bare .ct-bare-video video { width: 100%; height: 100%; object-fit: contain; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.ct-auth.ct-auth-wide { max-width: 760px; }
.ct-auth h1 { text-align: center; }
.ct-auth h1 + p { text-align: center; }
.ct-side-mark { width: 10px; height: 10px; border-radius: 3px; flex: none; border: 1px solid rgba(0, 0, 0, .35); }
.ct-side-mark.w { background: #f4f4f4; } .ct-side-mark.b { background: #2a2a2a; border-color: rgba(255, 255, 255, .25); }
.min-w-0 { min-width: 0; }
