#game-root {
    --ks-line: #c3cdc8;
    --ks-cage: #56646a;
    color: var(--cg-ink);
    font-family: Inter, Arial, sans-serif;
}

.ks-game {
    max-width: 980px;
    margin: 0 auto;
    padding: 2px 0 26px;
}

.ks-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.ks-stats,
.ks-tools,
.ks-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ks-stats > div,
.ks-status > div {
    flex: 1 1 0;
    min-width: 70px;
    padding: 7px 10px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
}

.ks-stats span,
.ks-status span {
    display: block;
    color: var(--cg-muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.ks-stats strong,
.ks-status strong {
    display: block;
    margin-top: 1px;
    font-size: 18px;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
}

.ks-btn,
.ks-icon,
.ks-key,
.ks-cell {
    font: inherit;
    color: var(--cg-ink);
    cursor: pointer;
}

.ks-btn,
.ks-icon {
    min-height: 44px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: var(--cg-panel);
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.ks-icon {
    width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-weight: 900;
}

.ks-btn {
    padding: 0 12px;
    font-weight: 800;
}

.ks-btn:disabled,
.ks-key:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.ks-btn:not(:disabled):hover,
.ks-icon:hover,
.ks-key:not(:disabled):hover {
    transform: translateY(-1px);
    border-color: rgba(49, 95, 157, 0.5);
}

.ks-btn:focus-visible,
.ks-icon:focus-visible,
.ks-key:focus-visible,
.ks-cell:focus-visible {
    outline: 3px solid rgba(49, 95, 157, 0.34);
    outline-offset: 2px;
}

.ks-btn.ks-on {
    border-color: var(--cg-green);
    background: rgba(29, 127, 98, 0.1);
    box-shadow: inset 0 0 0 2px rgba(29, 127, 98, 0.16);
}

.ks-svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ks-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 264px;
    gap: 16px;
    align-items: start;
}

.ks-board-shell {
    min-width: 0;
}

.ks-board-wrap {
    position: relative;
    width: 100%;
    max-width: 700px;
    aspect-ratio: 1;
    margin: 0 auto;
    border-radius: 10px;
    box-shadow: var(--cg-shadow);
}

.ks-board {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    border: 3px solid var(--cg-ink);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.ks-cell {
    position: relative;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-right: 1px solid var(--ks-line);
    border-bottom: 1px solid var(--ks-line);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fdfefb;
    transition: background 0.1s ease;
}

.ks-cell.ks-c0 { background: #fdfdf7; }
.ks-cell.ks-c1 { background: #f2f8fb; }
.ks-cell.ks-c2 { background: #f7f4fb; }
.ks-cell.ks-c3 { background: #f4faf3; }

.ks-cell.ks-given {
    background: #e7eee6;
    font-weight: 900;
}

.ks-cell.ks-peer { background: #e0edf1; }
.ks-cell.ks-incage { background: #dff0e6; }
.ks-cell.ks-match { background: #cfe8d8; }

.ks-cell.ks-sel {
    background: #fff2d9;
    box-shadow: inset 0 0 0 3px rgba(196, 122, 23, 0.55);
    z-index: 3;
}

.ks-cell.ks-bad {
    background: #fbe1df;
}

.ks-cell.ks-bt { border-top: 2px solid var(--cg-ink); }
.ks-cell.ks-bl { border-left: 2px solid var(--cg-ink); }
.ks-cell.ks-br { border-right: 0; }
.ks-cell.ks-bb { border-bottom: 0; }

.ks-cg {
    position: absolute;
    inset: 7%;
    pointer-events: none;
    z-index: 2;
}

.ks-cg.ks-et { border-top: 2px dashed var(--ks-cage); }
.ks-cg.ks-eb { border-bottom: 2px dashed var(--ks-cage); }
.ks-cg.ks-el { border-left: 2px dashed var(--ks-cage); }
.ks-cg.ks-er { border-right: 2px dashed var(--ks-cage); }

.ks-sum {
    position: absolute;
    top: 6%;
    left: 10%;
    z-index: 4;
    padding: 0 1px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.88);
    color: #33474f;
    font-size: clamp(9.5px, 2.3vw, 13px);
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.ks-sum.ks-sum-ok {
    background: rgba(29, 127, 98, 0.16);
    color: #12613f;
}

.ks-sum.ks-sum-bad {
    background: rgba(189, 60, 55, 0.16);
    color: var(--cg-red);
}

.ks-val {
    font-size: clamp(20px, 5.6vw, 34px);
    line-height: 1;
    transform: translateY(6%);
}

.ks-cell.ks-user .ks-val { color: var(--cg-blue); font-weight: 800; }
.ks-cell.ks-bad .ks-val { color: var(--cg-red); }

.ks-notes {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 33%;
    bottom: 10%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    align-items: center;
    justify-items: center;
    color: #5d6b6c;
    font-size: clamp(8px, 2vw, 12px);
    font-weight: 800;
    line-height: 1;
}

.ks-side {
    display: grid;
    gap: 10px;
    align-content: start;
}

.ks-pad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.ks-key {
    min-height: 56px;
    border: 1px solid var(--cg-line);
    border-radius: 8px;
    background: var(--cg-panel);
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.ks-key strong {
    display: block;
    font-size: 24px;
    line-height: 1.1;
}

.ks-key span {
    display: block;
    color: var(--cg-muted);
    font-size: 11px;
    font-weight: 800;
}

.ks-acts,
.ks-tabs,
.ks-modes {
    display: grid;
    gap: 8px;
}

.ks-acts,
.ks-modes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ks-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ks-wide {
    padding: 0 6px;
}

.ks-cover {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: grid;
    place-items: center;
    padding: 14px;
    border-radius: 10px;
    background: rgba(246, 247, 242, 0.88);
    backdrop-filter: blur(4px);
}

.ks-cover[hidden],
.ks-modal[hidden] {
    display: none;
}

.ks-cover-card {
    width: min(280px, 94%);
    display: grid;
    gap: 9px;
    justify-items: stretch;
    padding: 18px;
    border: 1px solid var(--cg-line);
    border-radius: 10px;
    background: var(--cg-panel);
    box-shadow: var(--cg-shadow);
    text-align: center;
}

.ks-cover-card strong { font-size: 24px; }

.ks-cover-card span {
    color: var(--cg-muted);
    font-weight: 700;
}

.ks-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(30, 37, 40, 0.4);
}

.ks-modal-card {
    width: min(440px, 100%);
    padding: 18px;
    border: 1px solid var(--cg-line);
    border-radius: 10px;
    background: var(--cg-panel);
    box-shadow: var(--cg-shadow);
}

.ks-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.ks-modal-head strong { font-size: 20px; }

.ks-modal-card p {
    margin: 10px 0 0;
    color: var(--cg-muted);
    line-height: 1.45;
}

@media (max-width: 900px) {
    .ks-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .ks-side {
        max-width: 700px;
        width: 100%;
        margin: 0 auto;
    }

    .ks-pad {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    .ks-acts,
    .ks-modes {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 520px) {
    .ks-bar {
        gap: 8px;
    }

    .ks-stats > div,
    .ks-status > div {
        min-width: 0;
        padding: 6px 7px;
    }

    .ks-stats strong,
    .ks-status strong {
        font-size: 15px;
    }

    .ks-stats span,
    .ks-status span {
        font-size: 10px;
    }

    .ks-board {
        border-width: 2px;
    }

    .ks-cg {
        inset: 8%;
        border-width: 0;
    }

    .ks-cg.ks-et,
    .ks-cg.ks-eb,
    .ks-cg.ks-el,
    .ks-cg.ks-er {
        border-width: 1.5px;
    }

    .ks-key {
        min-height: 50px;
    }

    .ks-key strong { font-size: 20px; }

    .ks-btn {
        padding: 0 4px;
        font-size: 14px;
    }
}
