:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #141414;
    --muted: #6f6f6f;
    --line: #e7e7e7;
    --accent: #1f5fd1;
    --accent-soft: #e9f0fd;
    --red: #c8322b;
    --card-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e0e0f;
        --surface: #161618;
        --text: #f1f1f1;
        --muted: #8d8d8d;
        --line: #2a2a2d;
        --accent: #7aa7ff;
        --accent-soft: #18233a;
        --red: #ff6b63;
        --card-bg: #1c1c1f;
    }
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 24px;
}

body {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.65;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

.top {
    padding: 72px 0 48px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
}

h1 {
    font-size: clamp(44px, 9vw, 72px);
    font-weight: 700;
    letter-spacing: -0.04em;
    line-height: 1.05;
    margin: 6px 0 16px;
}

.lead {
    max-width: 620px;
    font-size: 18px;
    color: var(--muted);
}

.facts {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 32px;
    max-width: 620px;
}

.facts li {
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    font-weight: 600;
}

.facts span {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--muted);
}

.layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 56px;
    padding-top: 48px;
    padding-bottom: 64px;
}

.toc {
    position: sticky;
    top: 24px;
    align-self: start;
}

.toc-title {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    margin-bottom: 10px;
}

.toc ol {
    list-style: none;
}

.toc a {
    display: block;
    padding: 5px 0;
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.toc a:hover {
    color: var(--text);
}

.content {
    min-width: 0;
    max-width: 660px;
}

section + section {
    margin-top: 56px;
}

h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 14px;
}

h2 span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--text);
    color: var(--bg);
    font-size: 13px;
    font-weight: 600;
}

.anchor {
    margin-left: 8px;
    color: var(--muted);
    font-weight: 400;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
}

h2:hover .anchor,
h3:hover .anchor,
.anchor:focus-visible,
.anchor.copied {
    opacity: 1;
}

.anchor:hover {
    color: var(--accent);
}

.anchor.copied {
    color: var(--accent);
}

@media (hover: none) {
    .anchor {
        opacity: 0.35;
    }
}

h3 {
    scroll-margin-top: 24px;
    font-size: 16px;
    font-weight: 600;
    margin: 28px 0 10px;
}

p + p {
    margin-top: 12px;
}

b {
    font-weight: 600;
}

.note {
    margin-top: 16px;
    padding: 12px 16px;
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    border-radius: 0 10px 10px 0;
}

.caption {
    font-size: 14px;
    color: var(--muted);
    margin-top: 10px;
}

.table {
    margin: 16px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
}

.row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 16px;
}

.row + .row {
    border-top: 1px solid var(--line);
}

.row span:last-child {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.row.head {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.row.head span:last-child {
    font-weight: 400;
}

.row.total {
    background: var(--bg);
}

.cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.card {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    height: 60px;
    padding: 0 6px;
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.red,
.card.red {
    color: var(--red);
}

.card.trump {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: transparent;
}

.steps,
.rules {
    padding-left: 22px;
}

.steps li,
.rules li {
    padding-left: 4px;
}

.steps li + li,
.rules li + li {
    margin-top: 8px;
}

.example {
    margin-top: 20px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.example-title {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
    margin-bottom: 6px;
}

.game {
    margin-top: 16px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.game-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
}

.game-trump {
    font-weight: 600;
}

.game-trump span {
    display: inline-block;
    min-width: 28px;
    padding: 2px 8px;
    margin-left: 4px;
    text-align: center;
    border-radius: 6px;
    background: var(--accent-soft);
    font-size: 16px;
}

.game-stats {
    color: var(--muted);
}

.game-table {
    display: grid;
    grid-template-columns: 1fr 88px 1fr;
    grid-template-areas:
        ". partner ."
        "left . right"
        ". you .";
    justify-items: center;
    align-items: center;
    gap: 14px 12px;
    margin: 20px 0 8px;
}

.seat {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 88px;
}

.seat-partner { grid-area: partner; }
.seat-left { grid-area: left; justify-self: end; }
.seat-right { grid-area: right; justify-self: start; }
.seat-you { grid-area: you; }

.seat-name {
    font-size: 12px;
    color: var(--muted);
}

.seat.lead .seat-name {
    color: var(--accent);
    font-weight: 600;
}

.seat.lead::after {
    content: "зайшов";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 2px;
    font-size: 11px;
    color: var(--accent);
    white-space: nowrap;
}

.slot {
    width: 56px;
    height: 80px;
    border: 1px dashed var(--line);
    border-radius: 8px;
}

.pcard {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 80px;
    background: var(--card-bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    line-height: 1.1;
    animation: deal 0.25s ease both;
}

.pcard .rank {
    font-size: 18px;
}

.pcard .suit {
    font-size: 22px;
}

.pcard.red {
    color: var(--red);
}

.pcard.is-trump::after {
    content: "";
    position: absolute;
    top: 5px;
    right: 5px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}

.pcard.winner {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@keyframes deal {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

.game-message {
    min-height: 48px;
    margin: 12px 0;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--bg);
    font-size: 15px;
    text-align: center;
}

.game-message.ok {
    background: var(--accent-soft);
}

.game-message.bad {
    background: color-mix(in srgb, var(--red) 14%, transparent);
}

.game-hand {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

button.pcard {
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.2s ease, box-shadow 0.15s ease;
}

button.pcard:hover:not(:disabled) {
    transform: translateY(-6px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

button.pcard:disabled {
    cursor: default;
}

.game-hand.hint button.pcard.legal,
.game-hand.reveal button.pcard.legal {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.game-hand.hint button.pcard:not(.legal),
.game-hand.reveal button.pcard:not(.legal) {
    opacity: 0.45;
}

.game-hand button.pcard.chosen {
    opacity: 0.25;
}

.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.game-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
}

.game-hint input {
    accent-color: var(--accent);
}

.game-next {
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 9px 16px;
    border: 0;
    border-radius: 10px;
    background: var(--text);
    color: var(--bg);
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.game-next:hover {
    opacity: 0.85;
}

.bottom {
    padding: 28px 0 40px;
    border-top: 1px solid var(--line);
    font-size: 14px;
    color: var(--muted);
}

@media (max-width: 760px) {
    .top {
        padding: 48px 0 36px;
    }

    .facts {
        grid-template-columns: repeat(2, 1fr);
    }

    .layout {
        grid-template-columns: 1fr;
        gap: 32px;
        padding-top: 32px;
    }

    .toc {
        position: static;
        padding: 16px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
    }

    .toc ol {
        columns: 2;
        column-gap: 16px;
    }

    .game {
        padding: 16px 12px;
    }

    .slot,
    .pcard {
        width: 48px;
        height: 68px;
    }

    .pcard .rank {
        font-size: 16px;
    }

    .pcard .suit {
        font-size: 19px;
    }

    .game-hand {
        gap: 6px;
    }

    .card {
        min-width: 38px;
        height: 52px;
        font-size: 15px;
    }
}
