/* =============================================================================
   EloCircuit — Brand Theme (v1.6)
   ============================================================================
   Aesthetic: dark navy/black background, electric neon green accent, white
   headings, muted gray body text. Tournament-platform feel — closer to a
   sportsbook / fintech app than the warm-paper chess club look of v1.5.

   This file preserves the same CSS variable names + component classes
   (.btn, .card, .topbar, .eyebrow, etc.) that v1.5 markup uses, so it's
   a true theme swap — pages need their <link> updated and minor copy
   tweaks, but no structural rewrites.

   Imports for typography:
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
   ============================================================================= */

:root {
    /* ---- Brand palette ---- */
    --bg-deep:      #0a0e14;   /* page background base */
    --bg:           #0d1117;   /* primary surface */
    --bg-raised:   #161b22;   /* cards */
    --bg-elevated: #1c232c;   /* hover, inputs */
    --bg-overlay:  rgba(13, 17, 23, 0.85);

    --line:        #21282f;   /* subtle borders */
    --line-strong: #2d3640;
    --line-glow:   #2a4d20;   /* green-tinted border on focus/active */

    --ink:         #f3f5f7;   /* primary text (near-white) */
    --ink-soft:    #c9d1d9;   /* secondary text */
    --ink-muted:   #8b949e;   /* tertiary / labels */
    --ink-dim:     #6e7681;   /* placeholder, disabled */

    --neon:        #b4f04c;   /* PRIMARY ACCENT — the EloCircuit green */
    --neon-bright: #c8ff5c;   /* hover */
    --neon-dim:    #7aa634;   /* pressed / muted */
    --neon-glow:   rgba(180, 240, 76, 0.35);
    --neon-soft:   rgba(180, 240, 76, 0.08);

    --gold:        #ffc94a;   /* tournament category: rapid */
    --purple:      #a78bff;   /* tournament category: classical */
    --red-soft:    #ff6b5e;   /* tournament category: daily fire */
    --blue-soft:   #4ea8de;

    --danger:      #ff5c5c;
    --warn:        #ffb84a;
    --success:     var(--neon);

    /* Aliases for v1.5-era component code (compat) */
    --paper:       var(--bg-raised);
    --paper-edge:  var(--bg-elevated);
    --walnut:      var(--ink);
    --brass:       var(--neon);
    --brass-bright: var(--neon-bright);
    --crimson:     var(--danger);
    --rule:        var(--line);

    --shadow-sm:   0 1px 2px rgba(0,0,0,0.4);
    --shadow-md:   0 4px 16px rgba(0,0,0,0.5);
    --shadow-lg:   0 18px 48px rgba(0,0,0,0.6);
    --shadow-glow: 0 0 24px var(--neon-glow);

    --serif:       "Inter", system-ui, -apple-system, sans-serif;
    --mono:        "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
    --sans:        "Inter", system-ui, -apple-system, sans-serif;

    --radius-sm:   6px;
    --radius:      10px;
    --radius-lg:   16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body { height: 100%; }

body {
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-soft);
    background: var(--bg-deep);
    /* Subtle vignette + tiny grid for depth */
    background-image:
        radial-gradient(ellipse 1100px 600px at 50% -100px,
                        rgba(180, 240, 76, 0.06), transparent 70%),
        linear-gradient(180deg, var(--bg-deep) 0%, #060a10 100%);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5 {
    font-family: var(--sans);
    color: var(--ink);
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.1;
}
h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); font-weight: 900; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.4rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p   { margin-bottom: 1rem; }
a   { color: var(--neon); text-decoration: none; transition: color .15s; }
a:hover { color: var(--neon-bright); }

strong { color: var(--ink); font-weight: 600; }

/* Eyebrow / kicker style. Used on every page just above the H1. */
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--neon);
    background: var(--neon-soft);
    border: 1px solid rgba(180, 240, 76, 0.25);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
}
.eyebrow::before {
    content: "⚡";
    color: var(--neon);
}
.eyebrow.plain {
    background: transparent;
    border: 0;
    padding: 0;
    color: var(--ink-muted);
}
.eyebrow.plain::before { content: "— "; color: var(--ink-muted); }

/* ---- Layout ---- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 4rem;
    position: relative;
    z-index: 2;
}
.container--narrow { max-width: 560px; }
.container--medium { max-width: 880px; }

/* ---- Topbar ---- */
.topbar {
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar .brand {
    font-family: var(--sans);
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--ink);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}
/* Shield mark — uses clip-path in modern browsers; we ALSO accept an
   inline <svg> sibling (brand-svg) so renderers without clip-path
   support (and our pre-render preview tooling) still show a shield. */
.topbar .brand::before {
    content: "";
    width: 28px;
    height: 32px;
    background-color: var(--neon);
    clip-path: polygon(50% 0, 100% 18%, 100% 60%, 50% 100%, 0 60%, 0 18%);
    display: inline-block;
    box-shadow: 0 0 12px var(--neon-glow);
}
/* If the page provides an inline brand-svg, suppress the CSS-only mark. */
.topbar .brand.has-svg::before { display: none; }
.topbar .brand .brand-svg {
    width: 28px; height: 32px;
    filter: drop-shadow(0 0 8px var(--neon-glow));
}
.topbar .brand .brand-sub {
    font-family: var(--mono);
    font-size: 0.62rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    color: var(--ink-muted);
    text-transform: uppercase;
    margin-top: 2px;
}
.topbar .brand-stack {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.topbar nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.topbar nav a {
    /* Defensive: gap above handles modern browsers. The margin-right
       gives a fallback gap in renderers without flex-gap support
       (older Safari, image-export tools). The last child trims it. */
    margin-right: 1.5rem;
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-soft);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.4rem 0;
    position: relative;
}
.topbar nav a:last-child { margin-right: 0; }
.topbar nav a.active,
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.active::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -4px;
    height: 2px;
    background: var(--neon);
}
.topbar .actions { display: flex; align-items: center; gap: 0.75rem; }

.coins-pill {
    font-family: var(--mono);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--neon);
    background: var(--neon-soft);
    border: 1px solid rgba(180, 240, 76, 0.25);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
}
.coins-pill::before { content: "◈ "; opacity: 0.7; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--sans);
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.85rem 1.6rem;
    border: 1px solid var(--line-strong);
    background: var(--bg-elevated);
    color: var(--ink);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}
.btn:hover {
    background: var(--bg-raised);
    border-color: var(--line-glow);
    color: var(--ink);
}
.btn:disabled,
.btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Primary CTA — neon */
.btn--brass, .btn--primary {
    background: var(--neon);
    color: #0a0e14;
    border-color: var(--neon);
    box-shadow: 0 0 0 transparent;
}
.btn--brass:hover, .btn--primary:hover {
    background: var(--neon-bright);
    border-color: var(--neon-bright);
    color: #0a0e14;
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}
.btn--brass:active, .btn--primary:active { transform: translateY(0); }

/* Ghost / outline */
.btn--ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--line-strong);
}
.btn--ghost:hover {
    background: var(--bg-raised);
    border-color: var(--ink-muted);
}

.btn--small { padding: 0.5rem 1rem; font-size: 0.75rem; }
.btn--block { width: 100%; }
.btn--danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn--danger:hover { background: rgba(255, 92, 92, 0.1); }

/* ---- Cards ---- */
.card {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--line-strong); }
.card--padded { padding: 2rem; }
.card--accent { border-color: var(--line-glow); box-shadow: var(--shadow-glow); }

/* ---- Forms ---- */
.field { margin-bottom: 1rem; }
.field label {
    display: block;
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
    margin-bottom: 0.5rem;
}
.field input,
.field select,
.field textarea {
    width: 100%;
    font-family: var(--sans);
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    transition: border-color 0.15s, background 0.15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--neon);
    background: var(--bg-raised);
    box-shadow: 0 0 0 3px var(--neon-soft);
}
.field input::placeholder { color: var(--ink-dim); }

/* ---- Alerts ---- */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.88rem;
    border: 1px solid;
}
.alert--success { background: var(--neon-soft); border-color: rgba(180, 240, 76, 0.3); color: var(--ink); }
.alert--danger,
.alert--error  { background: rgba(255, 92, 92, 0.08); border-color: rgba(255, 92, 92, 0.3); color: var(--ink); }
.alert--warn   { background: rgba(255, 184, 74, 0.08); border-color: rgba(255, 184, 74, 0.3); color: var(--ink); }
.alert--info   { background: rgba(78, 168, 222, 0.08); border-color: rgba(78, 168, 222, 0.3); color: var(--ink); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    font-family: var(--mono);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink-muted);
    background: var(--bg-elevated);
}
.badge--live { color: var(--neon); border-color: rgba(180, 240, 76, 0.3); background: var(--neon-soft); }
.badge--live::before { content: "● "; }
.badge--soon { color: var(--ink-muted); }
.badge--beta { color: var(--gold); border-color: rgba(255, 201, 74, 0.3); background: rgba(255, 201, 74, 0.08); }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 0.88rem;
}
th {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
    background: var(--bg-deep);
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-elevated); }

/* ---- Footer ---- */
footer {
    background: var(--bg-deep);
    border-top: 1px solid var(--line);
    padding: 2.5rem 1.5rem;
    text-align: center;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--ink-muted);
    letter-spacing: 0.06em;
}
footer a { color: var(--ink-soft); margin: 0 0.6rem; }

/* ---- Homepage / hero ---- */
.hero {
    padding: 4rem 0 3rem;
    position: relative;
    overflow: hidden;
}
.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 3rem;
    align-items: center;
}
@media (max-width: 980px) {
    .hero-grid { grid-template-columns: 1fr; }
}
.hero h1 .accent { color: var(--neon); display: block; }
.hero .lede { font-size: 1.05rem; color: var(--ink-soft); margin-top: 1.5rem; max-width: 480px; }
.hero .cta-row { margin-top: 2rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.hero .pillars {
    margin-top: 3rem;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem;
    max-width: 760px;
}
@media (max-width: 640px) {
    .hero .pillars { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}
.pillar { display: flex; flex-direction: column; gap: 0.3rem; }
.pillar-icon {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--neon);
    margin-bottom: 0.4rem;
}
.pillar-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink);
}
.pillar-body { font-size: 0.82rem; color: var(--ink-muted); line-height: 1.45; }

/* Tournament cards (homepage) */
.t-card {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: border-color 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.t-card:hover { border-color: var(--line-glow); transform: translateY(-3px); }
.t-card .header { display: flex; align-items: center; gap: 0.75rem; }
.t-card .icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.t-card .icon.blitz     { background: rgba(180, 240, 76, 0.15); color: var(--neon); }
.t-card .icon.rapid     { background: rgba(255, 201, 74, 0.15); color: var(--gold); }
.t-card .icon.classical { background: rgba(167, 139, 255, 0.15); color: var(--purple); }
.t-card .icon.daily     { background: rgba(255, 107, 94, 0.15); color: var(--red-soft); }
.t-card .cat {
    font-family: var(--mono);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.t-card .name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
}
.t-card .row {
    display: flex;
    justify-content: space-between;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--ink-muted);
}
.t-card .row .value {
    color: var(--ink);
    font-size: 0.95rem;
    font-weight: 600;
}
.t-card .row .value.prize { color: var(--neon); }

/* "Live tournament" sidebar card */
.live-card {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.live-card .head {
    display: flex; justify-content: space-between; align-items: center;
}
.live-card .head .label {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-muted);
}
.live-card .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--neon);
    box-shadow: 0 0 8px var(--neon-glow);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.live-card .name { font-size: 1.1rem; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 0.5rem; }
.live-card .prize { font-size: 2rem; font-weight: 900; color: var(--neon); line-height: 1; }
.live-card .stat-row { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 0.78rem; color: var(--ink-muted); padding: 0.25rem 0; border-bottom: 1px solid var(--line); }
.live-card .stat-row:last-of-type { border-bottom: 0; }
.live-card .stat-row .v { color: var(--ink); font-weight: 600; }

/* Section header with right link */
.section-head {
    display: flex; justify-content: space-between; align-items: end;
    margin: 3rem 0 1.25rem;
}
.section-head h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; }
.section-head .more { font-family: var(--mono); font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.08em; }
.section-head .more::after { content: " →"; color: var(--neon); }

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.25rem;
}
@media (max-width: 980px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* Why-play strip */
.value-prop {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.value-prop .icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--neon-soft);
    color: var(--neon);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}
.value-prop .icon.sec { background: rgba(167, 139, 255, 0.15); color: var(--purple); }
.value-prop .icon.fair { background: rgba(78, 168, 222, 0.15); color: var(--blue-soft); }
.value-prop .icon.built { background: rgba(255, 201, 74, 0.15); color: var(--gold); }
.value-prop .title { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink); }
.value-prop p { color: var(--ink-muted); font-size: 0.88rem; line-height: 1.5; margin: 0; }

/* Stats strip */
.stats-strip {
    background: var(--bg);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin-top: 3rem;
}
.stats-strip .row {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    align-items: center;
}
@media (max-width: 720px) { .stats-strip .row { grid-template-columns: repeat(2, 1fr); } }
.stat .num { font-size: 1.8rem; font-weight: 900; color: var(--neon); line-height: 1; }
.stat .label { font-family: var(--mono); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-muted); margin-top: 0.4rem; }
.stat .icon { color: var(--neon); margin-right: 0.4rem; }

/* ---- Auth pages ---- */
.auth-shell {
    min-height: calc(100vh - 80px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
}
.auth-card {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 460px;
}

/* ---- Chess board (player side) ---- */
.board-shell {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
}

/* Chess.com / lichess-style board palette tuned to dark theme.
   board.js applies these via CSS vars or classes. */
:root {
    --board-light: #ebecd0;
    --board-dark:  #739552;
    --board-from:  rgba(180, 240, 76, 0.55);
    --board-to:    rgba(180, 240, 76, 0.35);
    --board-check: rgba(255, 92, 92, 0.6);
}

/* ---- Utilities ---- */
.muted { color: var(--ink-muted); }
.dim   { color: var(--ink-dim); }
.accent { color: var(--neon); }
.center { text-align: center; }
.mono { font-family: var(--mono); }
.upper { text-transform: uppercase; letter-spacing: 0.08em; }

.hide-mobile { }
@media (max-width: 760px) { .hide-mobile { display: none !important; } }

/* Focus-visible across the app */
:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }

/* =============================================================================
   Chess board + play page layout (v1.6.1 hotfix)
   ============================================================================
   These styles were inadvertently dropped during the v1.5 → v1.6 rebrand.
   board.js (the inline renderer) emits .cb-board / .cb-sq / .cb-piece /
   .cb-coords, and the play / replay / botplay pages use .play-grid +
   .side-panel for the two-column layout. Restored here.
   ============================================================================= */

.play-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 2.5rem;
    align-items: start;
    margin-top: 1.25rem;
}
@media (max-width: 880px) {
    .play-grid { grid-template-columns: 1fr; }
}

.side-panel {
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.status-line {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--neon);
    margin-bottom: 0.85rem;
}

.move-list {
    font-family: var(--mono);
    font-size: 0.85rem;
    line-height: 1.8;
    max-height: 280px;
    overflow-y: auto;
    padding: 0.75rem 0.9rem;
    background: var(--bg-deep);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    word-spacing: 0.3em;
}

.cb-board {
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    border: 6px solid var(--bg-elevated);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    user-select: none;
    overflow: hidden;
}

.cb-sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}
.cb-sq.light { background: var(--board-light); }
.cb-sq.dark  { background: var(--board-dark); }

.cb-sq.selected::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 4px var(--neon);
    pointer-events: none;
}

.cb-sq.legal::before {
    content: "";
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.32);
    pointer-events: none;
}
.cb-sq.legal.has-piece::before {
    width: 86%;
    height: 86%;
    background: transparent;
    border: 5px solid rgba(180, 0, 0, 0.55);
    border-radius: 50%;
}

.cb-sq.last-move        { background: var(--board-from) !important; }
.cb-sq.dark.last-move   { background: var(--board-to)   !important; }

.cb-piece {
    width: 88%;
    height: 88%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(28px, 7vw, 52px);
    line-height: 1;
    cursor: grab;
    pointer-events: auto;
    color: #1a1a1a;
    text-shadow:
         1px  1px 0 #fff,
        -1px  1px 0 #fff,
         1px -1px 0 #fff,
        -1px -1px 0 #fff;
}
.cb-piece:active { cursor: grabbing; }
.cb-piece.dragging { opacity: 0.4; }

.cb-coords {
    font-family: var(--mono);
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.5);
    position: absolute;
    pointer-events: none;
}
.cb-coord-file { right: 4px;  bottom: 2px; }
.cb-coord-rank { left:  4px;  top:    2px; }
.cb-sq.dark .cb-coords { color: rgba(255, 255, 255, 0.6); }
