.cp-shell {
    --cp-lite: #f0d9b5;
    --cp-dark: #a97a52;
    --cp-edge: #4b3524;
    --cp-mark: #d9b25a;
    display: block;
}

.cp-wrap {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-family: Inter, Arial, sans-serif;
    color: var(--cg-ink);
}

.cp-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.cp-ident {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
}

.cp-badge {
    display: inline-block;
    padding: 7px 12px;
    border-radius: 999px;
    background: var(--cg-ink);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.02em;
}

.cp-streakchip {
    display: inline-block;
    padding: 7px 12px;
    border: 1px solid var(--cg-line);
    border-radius: 999px;
    background: var(--cg-panel);
    color: var(--cg-muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cp-streakchip strong {
    color: var(--cg-green);
    font-size: 0.9rem;
}

.cp-actions {
    display: flex;
    gap: 8px;
}

.cp-btn {
    appearance: none;
    min-height: 44px;
    border: 1px solid var(--cg-line);
    background: var(--cg-panel);
    color: var(--cg-ink);
    border-radius: 9px;
    padding: 10px 15px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease, border-color 0.12s ease;
}

.cp-btn:hover:not(:disabled) {
    border-color: var(--cg-teal);
    transform: translateY(-1px);
}

.cp-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.cp-btn.cp-on {
    background: var(--cg-ink);
    color: #fff;
    border-color: var(--cg-ink);
}

.cp-primary {
    background: var(--cg-green);
    border-color: var(--cg-green);
    color: #fff;
}

.cp-primary:hover {
    color: #fff;
    border-color: var(--cg-ink);
}

.cp-icon {
    width: 44px;
    padding: 10px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

.cp-icon svg {
    width: 21px;
    height: 21px;
}

.cp-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 1.5em;
}

.cp-title {
    font-size: 1.1rem;
    font-weight: 900;
}

.cp-sub {
    color: var(--cg-muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.cp-stage {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 18px;
    gap: 3px;
}

.cp-ranks,
.cp-files {
    display: flex;
    color: var(--cg-muted);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.03em;
}

.cp-ranks {
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
}

.cp-files {
    align-items: center;
    justify-content: space-around;
}

.cp-ranks span,
.cp-files span {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cp-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1;
    border: 5px solid var(--cp-edge);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--cg-shadow);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    outline-offset: 3px;
}

.cp-board.cp-dragging {
    cursor: grabbing;
}

.cp-sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.cp-light {
    background: var(--cp-lite);
}

.cp-dark {
    background: var(--cp-dark);
}

.cp-last::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--cp-mark);
    opacity: 0.42;
}

.cp-sel::before {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 4px var(--cg-amber);
}

.cp-check::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(189, 60, 55, 0.92), rgba(189, 60, 55, 0) 72%);
}

.cp-hint::before {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 0 4px var(--cg-blue);
    animation: cp-pulse 1s ease-in-out infinite;
}

.cp-hint2::after {
    content: '';
    position: absolute;
    width: 46%;
    height: 46%;
    border-radius: 50%;
    border: 4px solid var(--cg-blue);
    box-sizing: border-box;
}

@keyframes cp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.cp-target::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: rgba(30, 37, 40, 0.42);
}

.cp-target.cp-cap::after {
    width: 84%;
    height: 84%;
    background: none;
    border: 6px solid rgba(189, 60, 55, 0.72);
    box-sizing: border-box;
}

.cp-cursor {
    outline: 3px solid var(--cg-teal);
    outline-offset: -3px;
    z-index: 3;
}

.cp-p {
    position: relative;
    z-index: 2;
    line-height: 1;
    font-size: clamp(30px, 9.2vw, 72px);
    pointer-events: none;
}

.cp-w {
    color: #fff;
    text-shadow: 0 0 2px #241a12, 1.4px 1.4px 0 #241a12, -1.4px -1.4px 0 #241a12, 1.4px -1.4px 0 #241a12, -1.4px 1.4px 0 #241a12, 0 3px 4px rgba(0, 0, 0, 0.35);
}

.cp-b {
    color: #241a12;
    text-shadow: 0 0 2px rgba(255, 255, 255, 0.5), 0 2px 3px rgba(0, 0, 0, 0.4);
}

.cp-ghost {
    position: fixed;
    z-index: 500;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
}

.cp-shake {
    animation: cp-shake 0.34s ease;
}

@keyframes cp-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    45% { transform: translateX(6px); }
    70% { transform: translateX(-4px); }
}

.cp-feedback {
    min-height: 2.6em;
    padding: 8px 12px;
    border: 1px solid var(--cg-line);
    border-radius: 9px;
    background: var(--cg-panel);
    color: var(--cg-muted);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.35;
    display: flex;
    align-items: center;
}

.cp-fb-good {
    border-color: #8ec3ad;
    background: #e6f5ee;
    color: #16624a;
}

.cp-fb-bad {
    border-color: #e0a9a6;
    background: #fbeceb;
    color: #96302b;
}

.cp-fb-hint {
    border-color: #a9c0e0;
    background: #ecf1fb;
    color: #2b4f86;
}

.cp-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.cp-modes {
    display: flex;
    gap: 8px;
}

.cp-result {
    padding: 14px;
    border: 1px solid #bfd5ce;
    border-radius: 11px;
    background: linear-gradient(135deg, #edf8f3, #f8fbfa 60%, #eef4fa);
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.cp-result[hidden] {
    display: none;
}

.cp-result-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.cp-result-head strong {
    font-size: 1.05rem;
}

.cp-result-head span {
    color: var(--cg-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.cp-result-line {
    padding: 9px 11px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 0.92rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.cp-result-actions {
    display: flex;
    gap: 8px;
}

.cp-stats {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.cp-stat {
    flex: 1 1 0;
    min-width: 74px;
    padding: 8px 10px;
    border: 1px solid var(--cg-line);
    border-radius: 9px;
    background: var(--cg-panel);
    text-align: center;
}

.cp-stat span {
    display: block;
    color: var(--cg-muted);
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cp-stat strong {
    display: block;
    font-size: 1.12rem;
}

.cp-promo,
.cp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 26, 24, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    z-index: 200;
}

.cp-promo[hidden],
.cp-overlay[hidden] {
    display: none;
}

.cp-promo {
    gap: 10px;
}

.cp-promo-btn {
    width: 74px;
    height: 74px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--cp-edge);
    border-radius: 10px;
    background: var(--cp-lite);
    font-size: 44px;
    line-height: 1;
    cursor: pointer;
}

.cp-promo-btn:hover {
    background: var(--cp-mark);
}

.cp-dialog {
    position: relative;
    background: var(--cg-panel);
    color: var(--cg-ink);
    border-radius: 12px;
    padding: 22px 24px;
    max-width: 470px;
    width: 100%;
    box-shadow: var(--cg-shadow);
}

.cp-dialog h2 {
    margin: 0 0 10px;
    font-size: 1.2rem;
}

.cp-dialog ul {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.92rem;
    line-height: 1.45;
}

.cp-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
    border: 1px solid var(--cg-line);
    border-radius: 9px;
    background: var(--cg-panel);
    color: var(--cg-ink);
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
}

.cp-close:hover {
    border-color: var(--cg-red);
    color: var(--cg-red);
}

@media (max-width: 640px) {
    .cp-wrap {
        gap: 8px;
    }

    .cp-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .cp-badge,
    .cp-streakchip {
        padding: 6px 9px;
        font-size: 0.7rem;
        white-space: nowrap;
    }

    .cp-actions {
        gap: 6px;
    }

    .cp-title {
        font-size: 1rem;
    }

    .cp-sub {
        font-size: 0.8rem;
    }

    .cp-stage {
        grid-template-columns: 14px minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) 14px;
    }

    .cp-board {
        border-width: 4px;
    }

    .cp-feedback {
        font-size: 0.84rem;
        min-height: 3.2em;
    }

    .cp-stat {
        min-width: 62px;
        padding: 7px 6px;
    }

    .cp-stat strong {
        font-size: 1rem;
    }

    .cp-controls {
        gap: 8px;
    }

    .cp-next {
        flex: 1;
    }
}
