.jg-page {
    --jg-bg-1: #0e1518;
    --jg-bg-2: #1a2730;
    --jg-bg-3: #243341;
    --jg-card: rgba(18, 28, 36, 0.9);
    --jg-border: rgba(255, 255, 255, 0.08);
    --jg-text-soft: #c7d6de;
    --jg-accent: #f27955;
    --jg-accent-2: #27c0b5;
    --jg-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
    position: relative;
    width: 100%;
    max-width: 78rem;
    padding: 0.2rem 0 2rem;
}

.jg-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 10% 10%, rgba(39, 192, 181, 0.16), transparent 35%),
        radial-gradient(circle at 92% 8%, rgba(242, 121, 85, 0.22), transparent 42%),
        linear-gradient(165deg, var(--jg-bg-1), var(--jg-bg-2) 56%, var(--jg-bg-3));
    border: 1px solid var(--jg-border);
    border-radius: 1.25rem;
    z-index: 0;
}

.jg-page>* {
    position: relative;
    z-index: 1;
}

.jg-hero {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    padding: 1.25rem;
    border-bottom: 1px solid var(--jg-border);
}

.jg-eyebrow {
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--jg-accent-2);
    margin: 0 0 0.45rem;
}

.jg-title {
    font-size: clamp(1.45rem, 2.3vw, 2.2rem);
    line-height: 1.15;
    margin: 0;
}

.jg-subtitle {
    margin: 0.7rem 0 0;
    max-width: 48rem;
    color: var(--jg-text-soft);
    font-size: 0.95rem;
}

.jg-link {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--jg-border);
    border-radius: 999px;
    height: 2.25rem;
    padding: 0 0.85rem;
    font-size: 0.82rem;
    color: #f8fafb;
    transition: all 180ms ease;
    background: rgba(255, 255, 255, 0.04);
}

.jg-link:hover,
.jg-link:focus-visible {
    border-color: rgba(39, 192, 181, 0.5);
    background: rgba(39, 192, 181, 0.15);
}

.jg-layout {
    display: grid;
    grid-template-columns: minmax(16.5rem, 21rem) 1fr;
    gap: 1rem;
    padding: 1rem;
}

.jg-panel,
.jg-board-wrap,
.jg-help {
    border-radius: 1rem;
    border: 1px solid var(--jg-border);
    background: var(--jg-card);
    box-shadow: var(--jg-shadow);
}

.jg-panel {
    padding: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.95rem;
}

.jg-control-block {
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 0.8rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.14);
}

.jg-block-title {
    margin: 0 0 0.6rem;
    font-size: 0.86rem;
    letter-spacing: 0.02em;
    color: #f2f6f8;
}

.jg-image-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.48rem;
}

.jg-image-option {
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.65rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    transition: all 160ms ease;
}

.jg-image-option img {
    width: 100%;
    height: 4.2rem;
    object-fit: cover;
}

.jg-image-option p {
    margin: 0;
    font-size: 0.74rem;
    padding: 0.35rem 0.42rem 0.45rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jg-image-option[aria-selected='true'] {
    border-color: var(--jg-accent-2);
    transform: translateY(-1px);
    box-shadow: 0 0 0 2px rgba(39, 192, 181, 0.22);
}

.jg-difficulty-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.42rem;
}

.jg-difficulty-option {
    cursor: pointer;
    min-width: 4.5rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    padding: 0.36rem 0.7rem;
    font-size: 0.78rem;
    color: #f5fafb;
    background: rgba(255, 255, 255, 0.04);
    transition: all 150ms ease;
}

.jg-difficulty-option[aria-checked='true'] {
    border-color: rgba(242, 121, 85, 0.86);
    background: rgba(242, 121, 85, 0.16);
}

.jg-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.jg-btn {
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.62rem;
    padding: 0.48rem 0.62rem;
    font-size: 0.8rem;
    color: #f7fbfd;
    background: rgba(255, 255, 255, 0.05);
    transition: all 150ms ease;
}

.jg-btn:hover,
.jg-btn:focus-visible {
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.11);
}

.jg-btn-primary {
    border-color: rgba(242, 121, 85, 0.6);
    background: rgba(242, 121, 85, 0.25);
}

.jg-btn-primary:hover,
.jg-btn-primary:focus-visible {
    border-color: rgba(242, 121, 85, 0.95);
    background: rgba(242, 121, 85, 0.36);
}

.jg-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.7rem;
    font-size: 0.8rem;
    color: var(--jg-text-soft);
}

.jg-toggle input {
    accent-color: var(--jg-accent);
}

.jg-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.44rem;
}

.jg-stat {
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-radius: 0.65rem;
    background: rgba(0, 0, 0, 0.15);
    padding: 0.52rem 0.62rem;
}

.jg-stat-label {
    display: block;
    font-size: 0.68rem;
    color: #95a8b2;
    text-transform: uppercase;
    letter-spacing: 0.09em;
}

.jg-stat strong {
    display: block;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.jg-board-wrap {
    padding: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.jg-board-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.jg-image-name {
    margin: 0;
    color: #f9fcff;
    font-size: 0.9rem;
    font-weight: 600;
}

.jg-difficulty-name {
    margin: 0.12rem 0 0;
    color: #9eb0bb;
    font-size: 0.76rem;
}

.jg-board-shell {
    position: relative;
    width: min(100%, 42rem);
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    border-radius: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(145deg, rgba(1, 12, 18, 0.75), rgba(20, 37, 49, 0.75));
    overflow: hidden;
}

.jg-board {
    --jg-size: 4;
    display: grid;
    width: 100%;
    height: 100%;
    grid-template-columns: repeat(var(--jg-size), 1fr);
    grid-template-rows: repeat(var(--jg-size), 1fr);
    gap: 2px;
    padding: 2px;
    background: rgba(255, 255, 255, 0.06);
}

.jg-piece {
    border: 0;
    cursor: grab;
    background-repeat: no-repeat;
    background-color: #141d22;
    transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
    outline: none;
}

.jg-piece:active {
    cursor: grabbing;
}

.jg-piece:hover,
.jg-piece:focus-visible {
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.jg-piece.is-selected {
    box-shadow: inset 0 0 0 2px var(--jg-accent-2), 0 0 0 1px rgba(0, 0, 0, 0.6);
    transform: scale(0.98);
}

.jg-piece.is-correct {
    filter: saturate(1.05) contrast(1.04);
}

.jg-piece-label {
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.2rem;
    margin: 0.25rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.56);
    color: #fff;
    font-size: 0.67rem;
    font-weight: 600;
}

.jg-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
    background: rgba(7, 13, 18, 0.66);
}

.jg-overlay.hidden {
    display: none;
}

.jg-overlay-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.jg-overlay-text {
    margin: 0.45rem 0 0.95rem;
    color: #d2e0e7;
    font-size: 0.88rem;
}

.jg-status-text {
    margin: 0;
    text-align: center;
    color: #c2d1d9;
    font-size: 0.83rem;
    min-height: 1.2rem;
}

.jg-help {
    margin: 0 1rem 1rem;
    padding: 0.95rem;
}

.jg-help ul {
    margin: 0.45rem 0 0;
    padding: 0 0 0 1rem;
    color: #ccd8df;
    font-size: 0.86rem;
    display: grid;
    gap: 0.35rem;
}

.jg-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(4, 10, 14, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.jg-preview-modal.hidden {
    display: none;
}

.jg-preview-modal img {
    width: min(92vw, 46rem);
    max-height: 85vh;
    object-fit: contain;
    border-radius: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.17);
}

.jg-preview-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
}

@media (max-width: 63.98rem) {
    .jg-layout {
        grid-template-columns: 1fr;
    }

    .jg-panel {
        order: 2;
    }

    .jg-board-wrap {
        order: 1;
    }
}

@media (max-width: 47.98rem) {
    .jg-page {
        border-radius: 1rem;
    }

    .jg-page::before {
        border-radius: 1rem;
    }

    .jg-hero {
        flex-direction: column;
        padding: 1rem;
    }

    .jg-layout {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .jg-panel,
    .jg-board-wrap,
    .jg-help {
        border-radius: 0.8rem;
    }

    .jg-actions {
        grid-template-columns: 1fr;
    }

    .jg-image-list {
        grid-template-columns: 1fr 1fr;
    }

    .jg-image-option img {
        height: 4.9rem;
    }

    .jg-help {
        margin: 0 0.75rem 0.8rem;
    }
}
