.jp-shell {
    --jp-ink: #241a33;
    --jp-plum: #3a2456;
    --jp-amber: #f2a03d;
    --jp-coral: #ef6f5a;
    --jp-mint: #6fd6c4;
    --jp-deep: #17102a;
    width: min(92vw, 780px);
    margin: 0 auto;
    color: var(--cg-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.jp-topbar,
.jp-hud,
.jp-row,
.jp-tiers {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.jp-topbar {
    justify-content: space-between;
    margin-bottom: 10px;
}

.jp-statline {
    display: flex;
    gap: 8px;
    min-width: 0;
}

.jp-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff, #f1ecf8);
    border: 1px solid var(--cg-line);
    box-shadow: 0 4px 10px rgba(36, 26, 51, 0.08);
    min-width: 64px;
}

.jp-stat span,
.jp-pill span {
    font-size: 0.66rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--cg-muted);
}

.jp-stat strong,
.jp-pill strong {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--jp-ink);
    font-variant-numeric: tabular-nums;
}

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

.jp-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid var(--cg-line);
    background: linear-gradient(180deg, #ffffff, #f2eef8);
    color: var(--jp-ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(36, 26, 51, 0.08);
    transition: transform 120ms ease, box-shadow 120ms ease, background 160ms ease;
}

.jp-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(36, 26, 51, 0.14);
}

.jp-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.jp-btn:focus-visible,
.jp-stage:focus-visible {
    outline: 3px solid var(--jp-amber);
    outline-offset: 3px;
}

.jp-icon {
    width: 44px;
    padding: 0;
    font-size: 1.05rem;
    line-height: 1;
}

.jp-muted {
    color: var(--cg-muted);
    background: linear-gradient(180deg, #f3f0f8, #e9e4f2);
}

.jp-stage {
    position: relative;
    width: min(92vw, 720px);
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    background: #150d24;
    border: 1px solid rgba(255, 222, 176, 0.22);
    box-shadow: var(--cg-shadow), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: default;
}

.jp-focus {
    border-color: rgba(242, 160, 61, 0.7);
}

.jp-bg,
.jp-fx {
    position: absolute;
    inset: 0;
    display: block;
}

.jp-fx {
    pointer-events: none;
}

.jp-pieces {
    position: absolute;
    inset: 0;
}

.jp-piece {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    cursor: grab;
    will-change: transform;
}

.jp-piece canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.jp-lift {
    cursor: grabbing;
    filter: drop-shadow(0 16px 20px rgba(10, 4, 20, 0.62));
}

.jp-hold {
    filter: drop-shadow(0 6px 10px rgba(10, 4, 20, 0.5)) brightness(1.07) saturate(1.05);
}

.jp-sel::after {
    content: "";
    position: absolute;
    inset: 2px;
    border-radius: 12px;
    box-shadow: 0 0 0 3px var(--jp-amber);
    pointer-events: none;
}

.jp-pulse {
    animation: jp-pulse 320ms ease-out;
}

@keyframes jp-pulse {
    0% { filter: brightness(1.7) saturate(0.5); }
    100% { filter: none; }
}

.jp-nope {
    animation: jp-shake 240ms ease-in-out;
}

@keyframes jp-shake {
    0%, 100% { margin-left: 0; }
    25% { margin-left: -5px; }
    60% { margin-left: 4px; }
}

.jp-finish {
    position: absolute;
    inset: auto 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 22px;
    text-align: center;
    background: linear-gradient(180deg, rgba(58, 36, 86, 0.92), rgba(12, 6, 22, 0.98));
    backdrop-filter: blur(5px);
    animation: jp-rise 280ms ease-out both;
}

.jp-finish-tag {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--jp-amber);
    font-weight: 700;
}

.jp-finish strong {
    font-size: 2.6rem;
    font-weight: 800;
    color: #fff6e6;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 6px 22px rgba(242, 160, 61, 0.4);
}

.jp-finish p {
    margin: 0;
    max-width: 34ch;
    color: rgba(255, 240, 222, 0.82);
    font-size: 0.9rem;
}

.jp-finish-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 6px;
}

.jp-primary {
    background: linear-gradient(180deg, var(--jp-amber), #d97b1d);
    border-color: rgba(255, 220, 170, 0.5);
    color: #2a1704;
}

.jp-primary:hover:not(:disabled) {
    background: linear-gradient(180deg, #ffb355, #e2861f);
}

@keyframes jp-rise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.jp-hud {
    margin: 10px auto 0;
    justify-content: center;
}

.jp-pill {
    display: flex;
    align-items: baseline;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 999px;
    background: linear-gradient(180deg, #2c1e44, #201531);
    border: 1px solid rgba(255, 222, 176, 0.2);
    min-width: 92px;
    justify-content: center;
}

.jp-pill span {
    color: rgba(255, 226, 186, 0.7);
}

.jp-pill strong {
    color: #fff3e0;
}

.jp-row {
    margin: 10px 0 0;
    justify-content: center;
}

.jp-tiers {
    margin: 8px 0 0;
    justify-content: center;
}

.jp-row .jp-btn,
.jp-tiers .jp-btn {
    flex: 1 1 0;
    min-width: 44px;
}

.jp-on {
    background: linear-gradient(180deg, #3a2456, #2a1a44);
    border-color: rgba(242, 160, 61, 0.6);
    color: #ffe9c8;
    box-shadow: 0 5px 14px rgba(58, 36, 86, 0.3);
}

.jp-hint {
    margin: 10px auto 0;
    max-width: 62ch;
    text-align: center;
    font-size: 0.82rem;
    color: var(--cg-muted);
}

.jp-live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.jp-hidden {
    display: none !important;
}

.jp-modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(16, 8, 28, 0.62);
}

.jp-modal-card {
    position: relative;
    max-width: 520px;
    width: 100%;
    max-height: 84vh;
    overflow: auto;
    padding: 26px 26px 22px;
    border-radius: 20px;
    background: linear-gradient(180deg, #2e1f47, #1d1330);
    border: 1px solid rgba(255, 222, 176, 0.28);
    box-shadow: var(--cg-shadow);
    color: rgba(255, 243, 226, 0.9);
}

.jp-modal-card h2 {
    margin: 0 0 10px;
    font-size: 1.3rem;
    color: #fff3e0;
}

.jp-modal-card p {
    margin: 0 0 10px;
    font-size: 0.92rem;
    line-height: 1.55;
}

.jp-modal-card p:last-child {
    margin-bottom: 0;
}

.jp-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255, 222, 176, 0.3);
    background: rgba(255, 255, 255, 0.08);
    color: #ffe9c8;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.jp-close:hover {
    background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 760px) {
    .jp-stage {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .jp-shell {
        width: 100%;
    }

    .jp-stat {
        min-width: 56px;
        padding: 5px 10px;
    }

    .jp-pill {
        min-width: 0;
        flex: 1 1 40%;
        padding: 7px 10px;
    }

    .jp-btn {
        padding: 0 12px;
    }
}

.jp-pop {
    animation: jp-pop 420ms ease-out;
}

@keyframes jp-pop {
    0% { filter: brightness(1.9) drop-shadow(0 0 14px rgba(255, 214, 120, 0.95)); }
    100% { filter: none; }
}

.jp-edge {
    filter: drop-shadow(0 0 5px rgba(255, 200, 90, 0.95));
}

.jp-icon[aria-pressed="true"] {
    border-color: var(--jp-amber);
    background: rgba(230, 167, 69, 0.22);
}

@media (max-width: 480px) {
    .jp-statline .jp-stat:first-child {
        display: none;
    }

    .jp-actions {
        gap: 4px;
    }
}
