.elg-scramble {
    --elg-sc-ink: #172033;
    --elg-sc-muted: #64748b;
    --elg-sc-indigo: #4f46e5;
    --elg-sc-blue: #0ea5e9;
    --elg-sc-green: #22c55e;
    --elg-sc-orange: #f97316;
    --elg-sc-pink: #ec4899;
    max-width: 920px;
    margin: 24px auto;
    padding: 20px;
    position: relative;
    overflow: hidden;
    border: 1px solid #dbeafe;
    border-radius: 16px;
    background:
        radial-gradient(circle at 12% 10%, rgba(14, 165, 233, .18), transparent 30%),
        radial-gradient(circle at 88% 8%, rgba(249, 115, 22, .16), transparent 26%),
        linear-gradient(145deg, #f8fafc 0%, #eef2ff 56%, #ecfeff 100%);
    color: var(--elg-sc-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    box-shadow: 0 18px 45px rgba(30, 41, 59, .12);
    box-sizing: border-box;
}

.elg-scramble *,
.elg-scramble *::before,
.elg-scramble *::after {
    box-sizing: border-box;
}

.elg-scramble [hidden] {
    display: none !important;
}

.elg-sc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.elg-sc-title-wrap {
    min-width: 0;
}

.elg-sc-kicker {
    display: block;
    margin-bottom: 3px;
    color: var(--elg-sc-blue);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.elg-sc-title {
    margin: 0;
    color: #312e81;
    font-size: 1.28rem;
    font-weight: 900;
    line-height: 1.2;
}

.elg-sc-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    color: #334155;
    font-size: .92rem;
    font-weight: 800;
}

.elg-sc-stats span {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    background: rgba(255, 255, 255, .82);
}

.elg-sc-stats b {
    color: #4338ca;
}

.elg-sc-icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    background: #ffffff;
    color: #4338ca;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .1s ease;
}

.elg-sc-icon-btn:hover,
.elg-sc-icon-btn:focus-visible {
    background: #eef2ff;
    outline: none;
}

.elg-sc-icon-btn:active {
    transform: scale(.96);
}

.elg-sc-icon-btn svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}
.elg-sc-icon-btn svg path,
.elg-sc-icon-btn svg line,
.elg-sc-icon-btn svg circle {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.elg-sc-progress {
    height: 10px;
    margin-bottom: 16px;
    overflow: hidden;
    border-radius: 999px;
    background: #dbeafe;
}

.elg-sc-progress span {
    width: 0;
    height: 100%;
    display: block;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--elg-sc-green), var(--elg-sc-blue), var(--elg-sc-indigo));
    transition: width .35s ease;
}

.elg-sc-setup {
    padding: 22px;
    border: 1px solid rgba(199, 210, 254, .9);
    border-radius: 14px;
    background: rgba(255, 255, 255, .9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), 0 12px 26px rgba(79, 70, 229, .08);
}

.elg-sc-setup-label {
    display: block;
    margin-bottom: 8px;
    color: #312e81;
    font-size: 1rem;
    font-weight: 900;
}

.elg-sc-setup-input {
    width: 100%;
    min-height: 190px;
    padding: 12px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    color: #172033;
    font: inherit;
    font-size: .96rem;
    font-weight: 700;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.elg-sc-setup-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .17);
}

.elg-sc-setup-input::placeholder {
    color: #94a3b8;
}

.elg-sc-setup-help {
    margin-top: 8px;
    color: #64748b;
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.45;
}

.elg-sc-setup-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 14px;
}

.elg-sc-setup-message {
    min-height: 24px;
    margin-top: 10px;
    color: #dc2626;
    font-size: .94rem;
    font-weight: 800;
    text-align: center;
}

.elg-sc-card {
    padding: 22px;
    border: 1px solid rgba(199, 210, 254, .9);
    border-radius: 14px;
    background: rgba(255, 255, 255, .88);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75), 0 12px 26px rgba(79, 70, 229, .08);
}

.elg-sc-round {
    width: fit-content;
    margin: 0 auto 10px;
    padding: 7px 13px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: .86rem;
    font-weight: 900;
}

.elg-sc-hint {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: #475569;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
}

.elg-sc-hint strong {
    color: var(--elg-sc-orange);
}

.elg-sc-letters {
    min-height: 74px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 14px auto 20px;
    padding: 14px;
    border: 2px dashed #bfdbfe;
    border-radius: 16px;
    background: rgba(239, 246, 255, .72);
    touch-action: none;
}

.elg-sc-tile {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(160deg, #60a5fa, #4f46e5);
    color: #ffffff;
    font: inherit;
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1;
    text-transform: uppercase;
    cursor: grab;
    user-select: none;
    box-shadow: 0 10px 20px rgba(79, 70, 229, .22), inset 0 1px 0 rgba(255, 255, 255, .28);
    transition: transform .16s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
    -webkit-tap-highlight-color: transparent;
}

.elg-sc-tile:nth-child(3n + 1) {
    background: linear-gradient(160deg, #38bdf8, #2563eb);
}

.elg-sc-tile:nth-child(3n + 2) {
    background: linear-gradient(160deg, #fb7185, #ec4899);
}

.elg-sc-tile:nth-child(3n + 3) {
    background: linear-gradient(160deg, #fbbf24, #f97316);
}

.elg-sc-tile:hover,
.elg-sc-tile:focus-visible {
    transform: translateY(-2px);
    outline: none;
}

.elg-sc-tile:active {
    cursor: grabbing;
}

.elg-sc-tile.is-dragging {
    opacity: .35;
    transform: scale(.92);
}

.elg-sc-tile.is-selected {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, .2), 0 14px 24px rgba(79, 70, 229, .26);
    transform: translateY(-3px);
}

.elg-sc-tile.is-correct {
    background: linear-gradient(160deg, #4ade80, #16a34a);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .18), 0 10px 22px rgba(22, 163, 74, .24);
    animation: elg-sc-pop .32s ease both;
}

.elg-sc-tile.is-revealed {
    background: linear-gradient(160deg, #fde68a, #f97316);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .2), 0 10px 22px rgba(249, 115, 22, .22);
}

.elg-sc-tile.is-locked {
    cursor: default;
}

.elg-sc-input-label {
    display: block;
    margin: 0 0 6px;
    color: #334155;
    font-size: .9rem;
    font-weight: 800;
}

.elg-sc-input {
    width: 100%;
    min-height: 48px;
    padding: 11px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: #ffffff;
    color: #172033;
    font: inherit;
    font-size: 1rem;
    font-weight: 700;
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.elg-sc-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .17);
}

.elg-sc-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.elg-sc-btn {
    min-height: 44px;
    padding: 11px 18px;
    border: 0;
    border-radius: 12px;
    background: #e2e8f0;
    color: #334155;
    font: inherit;
    font-size: .95rem;
    font-weight: 800;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .1s ease, opacity .2s ease;
}

.elg-sc-btn:hover:not(:disabled),
.elg-sc-btn:focus-visible:not(:disabled) {
    background: #cbd5e1;
    outline: none;
}

.elg-sc-btn:active:not(:disabled) {
    transform: scale(.96);
}

.elg-sc-btn:disabled {
    cursor: default;
    opacity: .5;
}

.elg-sc-btn-primary {
    background: #4f46e5;
    color: #ffffff;
}

.elg-sc-btn-primary:hover:not(:disabled),
.elg-sc-btn-primary:focus-visible:not(:disabled) {
    background: #4338ca;
}

.elg-sc-btn-next {
    background: #22c55e;
    color: #ffffff;
}

.elg-sc-btn-next:hover:not(:disabled),
.elg-sc-btn-next:focus-visible:not(:disabled) {
    background: #16a34a;
}

.elg-sc-message {
    min-height: 30px;
    margin-top: 14px;
    color: #475569;
    font-size: 1rem;
    font-weight: 800;
    text-align: center;
}

.elg-sc-message.success {
    color: #15803d;
}

.elg-sc-message.error {
    color: #dc2626;
}

.elg-scramble.is-celebrating .elg-sc-card {
    animation: elg-sc-celebrate .48s ease both;
}

.elg-scramble.is-celebrating::before,
.elg-scramble.is-celebrating::after {
    content: "";
    position: absolute;
    inset: 18px;
    pointer-events: none;
    background:
        radial-gradient(circle, #22c55e 0 3px, transparent 4px) 8% 18% / 80px 80px,
        radial-gradient(circle, #f97316 0 3px, transparent 4px) 72% 12% / 92px 92px,
        radial-gradient(circle, #0ea5e9 0 3px, transparent 4px) 28% 82% / 86px 86px,
        radial-gradient(circle, #ec4899 0 3px, transparent 4px) 88% 72% / 74px 74px;
    animation: elg-sc-sparkle .8s ease both;
}

.elg-scramble:fullscreen,
.elg-scramble.is-fullscreen {
    width: 100vw;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    padding: 24px;
    border: 0;
    border-radius: 0;
    overflow: auto;
}

.elg-scramble:fullscreen .elg-sc-card,
.elg-scramble.is-fullscreen .elg-sc-card {
    max-width: 980px;
    margin: 0 auto;
}

@media (max-width: 700px) {
    .elg-scramble {
        margin: 16px auto;
        padding: 14px;
    }

    .elg-sc-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .elg-sc-stats {
        width: 100%;
        justify-content: space-between;
    }

    .elg-sc-card {
        padding: 16px;
    }

    .elg-sc-setup {
        padding: 16px;
    }

    .elg-sc-tile {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        font-size: 1.2rem;
    }

    .elg-sc-actions {
        align-items: stretch;
    }

    .elg-sc-btn {
        flex: 1 1 calc(50% - 10px);
    }
}

@media (max-width: 430px) {
    .elg-sc-stats span {
        flex: 1 1 auto;
        justify-content: center;
    }

    .elg-sc-icon-btn {
        flex: 0 0 40px;
        width: 40px;
        height: 40px;
    }

    .elg-sc-letters {
        gap: 8px;
        padding: 10px;
    }

    .elg-sc-tile {
        width: 44px;
        height: 44px;
        font-size: 1.12rem;
    }

    .elg-sc-btn {
        flex-basis: 100%;
    }

    .elg-sc-setup-input {
        min-height: 220px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .elg-scramble *,
    .elg-scramble *::before,
    .elg-scramble *::after {
        animation: none !important;
        transition: none !important;
    }
}

@keyframes elg-sc-pop {
    0% {
        transform: scale(.86);
    }

    70% {
        transform: scale(1.08);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes elg-sc-celebrate {
    0%,
    100% {
        transform: translateY(0);
    }

    45% {
        transform: translateY(-4px);
    }
}

@keyframes elg-sc-sparkle {
    0% {
        opacity: 0;
        transform: translateY(12px);
    }

    35% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(-12px);
    }
}
