#game-root {
    --kk-line: #b9c6c2;
    --kk-dark: #2b3439;
    --kk-dark2: #384349;
    color: var(--cg-ink);
    font-family: Inter, Arial, sans-serif;
}

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

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

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

.kk-stats > div,
.kk-status > div,
.kk-run {
    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.82);
}

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

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

.kk-runs {
    display: flex;
    gap: 8px;
}

.kk-run-a {
    border-left: 4px solid var(--cg-blue);
}

.kk-run-d {
    border-left: 4px solid var(--cg-teal);
}

.kk-good { color: var(--cg-green); }
.kk-warn { color: var(--cg-red); }

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

.kk-btn,
.kk-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;
}

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

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

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

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

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

.kk-btn.kk-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);
}

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

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

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

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

.kk-board {
    width: 100%;
    height: 100%;
    display: grid;
    gap: 1px;
    padding: 2px;
    border: 2px solid var(--kk-dark);
    border-radius: 10px;
    background: var(--kk-dark);
    overflow: hidden;
}

.kk-cell {
    position: relative;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fdfefb;
    overflow: hidden;
    transition: background 0.1s ease;
}

.kk-blk {
    background: linear-gradient(160deg, var(--kk-dark2), var(--kk-dark));
}

.kk-slash {
    position: absolute;
    left: -20%;
    right: -20%;
    top: 50%;
    height: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.42);
    transform: rotate(45deg);
}

.kk-sum {
    position: absolute;
    color: #f4f8f6;
    font-size: clamp(9px, 2.1vw, 15px);
    font-weight: 900;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.kk-sum-a {
    top: 8%;
    right: 8%;
}

.kk-sum-d {
    bottom: 8%;
    left: 8%;
}

.kk-sum-ok { color: #7fe0b4; }
.kk-sum-bad { color: #ff9c94; }

.kk-sum-on {
    text-shadow: 0 0 0 #fff;
    background: rgba(255, 217, 122, 0.9);
    color: #2b3439;
    border-radius: 3px;
    padding: 0 2px;
}

.kk-open {
    background: #fdfdf7;
}

.kk-open.kk-inrun { background: #dceef9; }
.kk-open.kk-incol { background: #e0f2e6; }

.kk-open.kk-sel {
    background: #ffe6a8;
    box-shadow: inset 0 0 0 3px rgba(196, 122, 23, 0.6);
    z-index: 2;
}

.kk-open.kk-bad {
    background: #fbe1df;
}

.kk-val {
    font-size: clamp(16px, 4.4vw, 32px);
    font-weight: 700;
    line-height: 1;
    color: var(--cg-blue);
}

.kk-open.kk-bad .kk-val { color: var(--cg-red); }

.kk-notes {
    position: absolute;
    inset: 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(7px, 1.7vw, 12px);
    font-weight: 800;
    line-height: 1;
}

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

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

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

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

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

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

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

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

.kk-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);
}

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

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

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

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

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

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

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

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

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

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

    .kk-side {
        max-width: 660px;
        width: 100%;
        margin: 0 auto;
    }

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

    .kk-key {
        min-height: 48px;
    }

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

@media (max-width: 520px) {
    .kk-stats > div,
    .kk-status > div,
    .kk-run {
        min-width: 0;
        padding: 6px 7px;
    }

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

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

    .kk-board {
        border-width: 2px;
        gap: 1px;
    }

    .kk-key {
        min-height: 46px;
    }

    .kk-key strong { font-size: 19px; }

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