:root {
    --green-900: #102318;
    --green-800: #173325;
    --green-700: #234a35;
    --green-600: #2f6b4a;
    --gold: #c6a035;
    --gold-soft: #ead58a;
    --cream: #f4efe4;
    --paper: #fffdf8;
    --ink: #1b221d;
    --muted: #5d6a61;
    --line: #e4dccb;
    --board-light: #ecdab9;
    --board-dark: #c5a076;
    --last: rgba(198, 160, 53, 0.48);
    --legal: rgba(47, 107, 74, 0.28);
    --ok: #2f7a4a;
    --bad: #b23b32;
    --shadow: 0 16px 40px rgba(16, 35, 24, 0.12);
    --radius: 16px;
    --max: 1140px;
    --header-h: 72px;
}

* { box-sizing: border-box; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}
body {
    margin: 0;
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--cream);
    line-height: 1.5;
    overflow-x: hidden;
}

img { max-width: 100%; display: block; }
a { color: var(--green-600); }
h1, h2, h3, h4 {
    font-family: Fraunces, Georgia, serif;
    line-height: 1.2;
    margin: 0 0 0.5em;
}

.demo-banner {
    background: #2a2110;
    color: #f3e6c0;
    font-size: 13px;
    text-align: center;
    padding: 8px 16px;
}
.demo-banner a { color: var(--gold-soft); }

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--green-900);
    color: #fff;
    min-height: var(--header-h);
}
.header-inner {
    position: relative;
    max-width: var(--max);
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    min-width: 0;
}
.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
}
.brand-award {
    width: 52px;
    height: 52px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    padding: 2px;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-sub { font-size: 11px; color: var(--gold-soft); }

.nav {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.nav a {
    color: #dce8e0;
    text-decoration: none;
    padding: 8px 10px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
}
.nav a:hover, .nav a.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}
.nav a.active { color: var(--gold-soft); }

.nav-toggle {
    display: none;
    margin-left: auto;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    border-radius: 8px;
    padding: 8px 12px;
    font: inherit;
}

.wrap {
    max-width: var(--max);
    margin: 0 auto;
    padding: 32px 20px 64px;
}

.hero {
    background: var(--green-800);
    color: #fff;
    padding: 48px 20px 56px;
}
.hero-inner {
    max-width: var(--max);
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.35fr 0.75fr;
    gap: 36px;
    align-items: center;
}
.kicker {
    display: inline-block;
    background: var(--gold);
    color: var(--green-900);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 14px;
}
.hero h1 {
    font-size: clamp(2rem, 4vw, 3.2rem);
    margin-bottom: 12px;
}
.hero p { font-size: 1.15rem; max-width: 38em; color: #eef4ef; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.hero-award {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 22px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 14px;
    padding: 10px 14px 10px 10px;
    max-width: 28rem;
}
.hero-award img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 4px;
    flex-shrink: 0;
}
.hero-award strong {
    display: block;
    font-family: Fraunces, Georgia, serif;
    font-size: 1.15rem;
}
.hero-award span { color: #e8efe9; font-size: 0.95rem; }
.stat-award {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}
.stat-award img {
    width: 96px;
    height: 96px;
    object-fit: contain;
}

.photos { margin-top: 28px; }
.photo-full, .photo-half { margin: 0 0 28px; }
.photo-full img,
.photo-half img {
    width: 100%;
    display: block;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.photo-full img {
    aspect-ratio: 2.2 / 1;
    object-fit: cover;
    object-position: center 82%;
}
.photo-half {
    max-width: 640px;
}
.photo-half img {
    height: auto;
}
.photos figcaption {
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.95rem;
}

.session-card {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.session-card h2 { font-size: 1.15rem; }
.session-card dl { margin: 0; }
.session-card dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold-soft); margin-top: 10px; }
.session-card dd { margin: 2px 0 0; font-weight: 600; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    border: 0;
    cursor: pointer;
    font: inherit;
}
.btn-gold { background: var(--gold); color: var(--green-900); }
.btn-gold:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.45); }
.btn-green { background: var(--green-700); color: #fff; }
.btn-line { background: #fff; color: var(--green-800); border: 1px solid var(--line); }

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: -28px;
    position: relative;
    z-index: 2;
}
.stat {
    background: var(--paper);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 1.4rem; font-family: Fraunces, serif; color: var(--green-700); }

.grid-3, .grid-2, .cards {
    display: grid;
    gap: 18px;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset;
}
.card h3 { font-size: 1.15rem; }
.muted { color: var(--muted); }
.section-title { margin: 40px 0 16px; font-size: 1.8rem; }

.about-award {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 12px 0 0;
}
.about-award img {
    width: 88px;
    height: 88px;
    object-fit: contain;
    flex-shrink: 0;
}
.coach {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100%;
}
.coach .role {
    color: var(--green-600);
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.page-hero {
    background: var(--green-800);
    color: #fff;
    padding: 48px 20px 36px;
}
.page-hero-inner { max-width: var(--max); margin: 0 auto; }
.page-hero p { max-width: 42em; color: #d7e4db; }

.news-item { display: grid; gap: 6px; }
.news-item time { color: var(--muted); font-size: 13px; font-weight: 600; }

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}
.gallery img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 12px;
}

form.stack { display: grid; gap: 12px; max-width: 520px; }
label { font-weight: 600; font-size: 14px; }
input, textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 16px;
    background: #fff;
}
textarea { min-height: 120px; resize: vertical; }
.form-ok {
    display: none;
    background: #e7f5ec;
    color: var(--ok);
    padding: 12px 14px;
    border-radius: 10px;
    font-weight: 600;
}

.site-footer {
    background: var(--green-900);
    color: #c9d6ce;
    padding: 28px 20px;
    font-size: 14px;
}
.footer-inner {
    max-width: var(--max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.footer-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}
.footer-brand img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 4px;
}
.site-footer a { color: var(--gold-soft); }

/* cm-chessboard: контейнер обязан иметь реальную ширину до конструктора */
.board-host {
    width: 100%;
    max-width: 520px;
    aspect-ratio: 1;
    position: relative;
}
.board-host .cm-chessboard {
    width: 100%;
    height: 100%;
    touch-action: manipulation;
}

.viewer {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(280px, 420px);
    gap: 24px;
    align-items: start;
}
.viewer-board { max-width: 520px; }
.players {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-weight: 700;
}
.players span { color: var(--muted); font-weight: 600; }

.nav-btns {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}
.nav-btns button {
    flex: 1;
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.nav-btns button:disabled { opacity: 0.4; cursor: default; }
.nav-btns button:not(:disabled):hover { border-color: var(--green-600); }

.moves {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 2px 8px;
    max-height: 280px;
    overflow: auto;
    background: #f8f5ee;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px;
    font-variant-numeric: tabular-nums;
}
.moves .n { color: var(--muted); text-align: right; }
.moves button {
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    padding: 2px 6px;
    border-radius: 6px;
    cursor: pointer;
}
.moves button.on { background: var(--green-700); color: #fff; }

.comment {
    margin-top: 12px;
    background: #fff;
    border-left: 4px solid var(--gold);
    padding: 12px 14px;
    border-radius: 0 10px 10px 0;
    min-height: 3.2em;
}

.shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 22px;
    align-items: start;
}
.side-list {
    display: grid;
    gap: 10px;
    max-height: calc(100vh - 140px);
    overflow: auto;
    padding-right: 4px;
}
.side-item {
    text-align: left;
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    font: inherit;
}
.side-item:hover, .side-item.on {
    border-color: var(--green-600);
    box-shadow: 0 0 0 2px rgba(47, 107, 74, 0.15);
}
.side-item b { display: block; }
.side-item small { color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.chip.on { background: var(--green-700); color: #fff; border-color: var(--green-700); }

.lesson-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}
.lesson-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    font: inherit;
    padding: 0;
}
.lesson-card .mini { pointer-events: none; max-width: none; }
.lesson-card .meta { padding: 12px; }
.lesson-card .meta b { display: block; margin-top: 4px; font-size: 1.02rem; }
.lesson-card .tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--green-600);
}
.lesson-card.on { outline: 2px solid var(--green-600); }
.lesson-card .board-host { max-width: none; }

.puzzle-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin-top: 10px;
    font-weight: 700;
}
.puzzle-bar.ok { color: var(--ok); }
.puzzle-bar.bad { color: var(--bad); }

.hint { font-weight: 400; color: var(--muted); }

.map-embed {
    border: 0;
    width: 100%;
    min-height: 280px;
    border-radius: var(--radius);
}

.quote {
    font-family: Fraunces, serif;
    font-size: 1.05rem;
    font-style: italic;
    color: var(--green-800);
}

.learn-stage { position: sticky; top: 88px; }
.learn-shell .lesson-grid { grid-template-columns: 1fr; }

@media (max-width: 1100px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        flex-shrink: 0;
    }
    .nav {
        display: none;
        position: absolute;
        left: 0;
        right: 0;
        top: 100%;
        background: var(--green-800);
        flex-direction: column;
        gap: 2px;
        padding: 8px 10px 14px;
        margin: 0;
        z-index: 50;
        box-shadow: 0 16px 28px rgba(0, 0, 0, 0.28);
    }
    .nav.open { display: flex; }
    .nav a {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 10px 14px;
        border-radius: 8px;
    }
}

@media (max-width: 900px) {
    .hero-inner, .viewer, .shell, .stats, .grid-3, .grid-2 {
        grid-template-columns: 1fr;
    }
    .hero {
        padding: 28px 16px 36px;
    }
    .hero h1 { font-size: 1.7rem; }
    .hero p { font-size: 1rem; }
    .wrap { padding: 20px 16px 48px; }
    .stats { margin-top: -18px; }
    .section-title { font-size: 1.4rem; margin: 28px 0 12px; }
    .page-hero { padding: 28px 16px 24px; }
    .side-list { max-height: none; }
    .learn-stage { position: static; }
    .learn-shell { display: flex; flex-direction: column; }
    .learn-shell .lesson-grid {
        max-height: 38vh;
        overflow: auto;
        grid-template-columns: 1fr;
    }
    .lesson-card .board-host,
    .lesson-card .mini { display: none; }
    .board-host { max-width: 100%; }
    .viewer-board { max-width: 100%; }
    .photo-full img {
        aspect-ratio: 4 / 3;
        object-position: center 78%;
    }
    .photo-half { max-width: none; }
    .hero-actions .btn { flex: 1 1 160px; }
    .brand-sub { display: none; }
    .gallery { grid-template-columns: repeat(2, 1fr); }
    .gallery img { height: 140px; }
}

@media (max-width: 520px) {
    .brand-award { display: none; }
    .brand-logo { width: 40px; height: 40px; }
    .brand-name { font-size: 13px; }
    .hero-award img { width: 64px; height: 64px; }
    .stat-award img { width: 72px; height: 72px; }
    .demo-banner { font-size: 12px; padding: 7px 10px; }
    .footer-brand { align-items: flex-start; }
}
