:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --ink: #1d2733;
    --muted: #6a7a8c;
    --line: #d5dfea;
    --brand: #0f4c81;
    --brand-soft: #e6eef7;
    --accent: #1a9e8f;
    --warn: #c2410c;
    --err: #d64545;
    --ok: #2f9e44;
    --card: #f4f8fc;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(20, 40, 70, .08), 0 6px 18px rgba(20, 40, 70, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--brand); }

.wrap {
    max-width: 1480px;
    margin: 0 auto;
    padding: 16px 18px 40px;
}

/* ---------- шапка ---------- */
.top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    padding: 6px 0 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: auto;
}

.brand .mark {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 17px;
    letter-spacing: .5px;
}

.brand h1 {
    margin: 0;
    font-size: 19px;
    line-height: 1.2;
}

.brand p {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.lang button,
.mode button,
.btn {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    border-radius: 8px;
    padding: 8px 13px;
    transition: background .15s, border-color .15s, color .15s;
}

.btn:hover,
.lang button:hover,
.mode button:hover { border-color: var(--brand); }

.btn.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.btn.primary:hover { background: #0c3d68; }

.mode, .lang {
    display: inline-flex;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 9px;
    overflow: hidden;
}

.mode button, .lang button {
    border: 0;
    border-radius: 0;
    padding: 8px 14px;
}

.mode button + button, .lang button + button { border-left: 1px solid var(--line); }

.mode button.on, .lang button.on {
    background: var(--brand);
    color: #fff;
}

.bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.bar .spacer { flex: 1; }

.score {
    font-size: 13.5px;
    color: var(--muted);
    white-space: nowrap;
}

.score b { color: var(--ink); }

/* ---------- ссылка на парную игру ---------- */
.crosslink {
    margin: 0 0 12px;
    padding: 9px 14px;
    border: 1px solid #cfe3d6;
    border-radius: var(--radius);
    background: #f2f9f5;
    font-size: 13px;
}

.crosslink a { font-weight: 600; }

/* ---------- сообщение ---------- */
.msg {
    min-height: 20px;
    margin: 0 0 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: var(--brand-soft);
    border: 1px solid #cfe0f0;
    color: #1b3c5c;
    font-size: 14px;
}

.msg.ok { background: #e7f6ea; border-color: #bfe3c6; color: #1f6b2c; }
.msg.err { background: #fdeaea; border-color: #f3c4c4; color: #9c2b2b; }

/* ---------- поле игры ---------- */
.board {
    display: grid;
    grid-template-columns: 300px repeat(5, minmax(200px, 1fr));
    gap: 12px;
    align-items: start;
}

.col {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 180px;
}

.col.pool {
    position: sticky;
    top: 10px;
    max-height: calc(100vh - 24px);
}

.col > header {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--brand);
    color: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
}

.col.pool > header { background: #37475a; }

.col > header .num {
    font-size: 11px;
    opacity: .75;
    letter-spacing: .8px;
    text-transform: uppercase;
}

.col > header .name {
    display: block;
    font-weight: 600;
    font-size: 15px;
    margin-top: 1px;
}

.col > header .sub {
    display: block;
    font-size: 11.5px;
    opacity: .8;
    margin-top: 2px;
}

.drop {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    min-height: 90px;
}

.col.pool .drop { padding-bottom: 14px; }

.drop.hot {
    background: #eaf4ff;
    outline: 2px dashed var(--brand);
    outline-offset: -4px;
}

.drop .empty {
    color: #a9b7c6;
    font-size: 12.5px;
    text-align: center;
    padding: 18px 6px;
    border: 1px dashed var(--line);
    border-radius: 8px;
}

/* ---------- карточка ---------- */
.card {
    background: var(--card);
    border: 1px solid #cdd9e6;
    border-left: 3px solid var(--brand);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 13px;
    line-height: 1.38;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.card:hover { background: #fff; }

.card.dragging { opacity: .35; }

.card.ghost {
    position: fixed;
    z-index: 60;
    pointer-events: none;
    box-shadow: 0 12px 28px rgba(15, 40, 70, .28);
    background: #fff;
    transform: rotate(-1deg);
    cursor: grabbing;
    opacity: .97;
}

.card.right { border-color: #bfe3c6; border-left-color: var(--ok); background: #f1fbf3; }
.card.wrong { border-color: #f3c4c4; border-left-color: var(--err); background: #fdf1f1; }
.card.flash-ok { animation: flashOk .5s ease; }
.card.flash-err { animation: flashErr .5s ease; }

@keyframes flashOk {
    0% { background: #c9f0d3; }
    100% { background: var(--card); }
}

@keyframes flashErr {
    0%, 40% { background: #fbd2d2; transform: translateX(0); }
    10% { transform: translateX(-4px); }
    25% { transform: translateX(4px); }
    100% { background: var(--card); transform: translateX(0); }
}

.card .note {
    display: block;
    margin-top: 6px;
    padding-top: 5px;
    border-top: 1px dotted #c9a3a3;
    font-size: 12px;
    font-weight: 600;
    color: #9c2b2b;
}

.card .seq {
    display: inline-block;
    min-width: 20px;
    margin-right: 6px;
    font-weight: 700;
    color: var(--brand);
}

.card .move {
    display: inline-block;
    margin-right: 6px;
    padding: 1px 6px;
    border-radius: 20px;
    background: #fde8d6;
    color: var(--warn);
    font-size: 11.5px;
    font-weight: 700;
}

.placeholder {
    height: 34px;
    border: 2px dashed var(--brand);
    border-radius: 8px;
    background: #eaf4ff;
}

/* ---------- правила ---------- */
details.rules {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px 16px;
    margin-bottom: 12px;
}

details.rules summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--brand);
}

details.rules ol { margin: 10px 0 0; padding-left: 20px; }
details.rules li { margin-bottom: 5px; }

footer {
    margin-top: 26px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 12.5px;
    color: var(--muted);
}

footer a { color: var(--muted); }

/* ---------- подсказка к карточке ---------- */
#cardTip {
    position: fixed;
    z-index: 80;
    max-width: 330px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(20, 40, 70, .18);
    font-size: 12.5px;
    line-height: 1.45;
    pointer-events: none;
}

#cardTip b {
    display: block;
    color: var(--brand);
    font-size: 13px;
    margin-bottom: 5px;
}

#cardTip p { margin: 0 0 6px; }

#cardTip .tools {
    display: block;
    padding-top: 5px;
    border-top: 1px dotted var(--line);
    color: var(--muted);
}

/* ---------- адаптив ---------- */
@media (max-width: 1180px) {
    .board {
        grid-template-columns: repeat(3, minmax(220px, 1fr));
    }
    .col.pool {
        grid-column: 1 / -1;
        position: static;
        max-height: 340px;
    }
}

@media (max-width: 720px) {
    .wrap { padding: 12px 12px 32px; }
    .board { grid-template-columns: 1fr; }
    .col.pool { max-height: 300px; }
    .brand h1 { font-size: 17px; }
    .bar { position: sticky; top: 0; z-index: 20; }
}
