/* Gaming Bureau — cascade engine (cluster-pays tumble board).
   Every selector lives under .bx-eng--cascade. Only transform, opacity and
   clip-path move; the JS skips every movement when motion is off. */

.bx-eng--cascade {
    --bx-cs-gap: 6px;
    --bx-cs-pad: 14px;
    --bx-cs-plum: #2a1840;
    --bx-cs-amethyst: #b45cf0;
}

.bx-eng--cascade .bx-cs-board,
.bx-eng--cascade .bx-cs-board * {
    box-sizing: border-box;
}

.bx-eng--cascade .bx-cs-board {
    container-type: size;
    place-items: stretch;
    min-height: 340px;
    padding: 20px 20px 10px;
}

.bx-eng--cascade .bx-cs-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* ---------------------------------------------------------------- hud */

.bx-eng--cascade .bx-cs-hud {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: none;
    width: 176px;
}

.bx-eng--cascade .bx-cs-chip {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px 11px;
    border: 1px solid var(--bx-line);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(243, 236, 223, .08), rgba(243, 236, 223, .02)), rgba(18, 13, 28, .55);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 10px 22px -16px rgba(0, 0, 0, .9);
}

.bx-eng--cascade .bx-cs-chip[hidden] { display: none; }

.bx-eng--cascade .bx-cs-chip__k {
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .11em;
    text-transform: uppercase;
    color: var(--bx-muted);
}

.bx-eng--cascade .bx-cs-chip__v {
    display: block;
    font-size: 1.4rem;
    line-height: 1.15;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--bx-ink);
    transform-origin: left center;
}

.bx-eng--cascade .bx-cs-chip[data-key="mult"][data-live="false"] .bx-cs-chip__v { color: var(--bx-muted); }

.bx-eng--cascade .bx-cs-chip[data-key="mult"][data-live="true"] {
    border-color: rgba(245, 196, 81, .55);
    background: linear-gradient(180deg, rgba(245, 196, 81, .24), rgba(245, 196, 81, .05)), rgba(18, 13, 28, .55);
}

.bx-eng--cascade .bx-cs-chip[data-key="mult"][data-live="true"] .bx-cs-chip__v { color: var(--bx-gold); }

.bx-eng--cascade .bx-cs-chip[data-key="total"][data-tone="win"] .bx-cs-chip__v { color: var(--bx-gold); }

.bx-eng--cascade .bx-cs-chip[data-key="bonus"] {
    border-color: rgba(255, 107, 87, .55);
    background: linear-gradient(180deg, rgba(255, 107, 87, .22), rgba(255, 107, 87, .05)), rgba(18, 13, 28, .55);
}

.bx-eng--cascade .bx-cs-chip.is-bump .bx-cs-chip__v { animation: bx-cs-bump .26s ease-out; }

@keyframes bx-cs-bump {
    40% { transform: scale(1.14); }
}

.bx-eng--cascade .bx-cs-legend {
    display: grid;
    gap: 10px;
    margin: 6px 0 0;
    font-size: .8rem;
    line-height: 1.4;
    color: var(--bx-muted);
}

.bx-eng--cascade .bx-cs-legend__row {
    display: grid;
    grid-template-columns: 30px 1fr;
    align-items: center;
    gap: 8px;
}

.bx-eng--cascade .bx-cs-legend__dots {
    position: relative;
    width: 30px;
    height: 24px;
}

/* a small plus-shaped cluster of five tiles */
.bx-eng--cascade .bx-cs-legend__dots::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 9px;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: var(--bx-gold);
    box-shadow: -8px 0 var(--bx-gold), 8px 0 var(--bx-gold), 0 -8px var(--bx-gold), 0 8px var(--bx-gold);
}

.bx-eng--cascade .bx-cs-legend__sym {
    display: block;
    width: 30px;
    height: 30px;
}

/* ---------------------------------------------------------------- frame */

.bx-eng--cascade .bx-cs-frame {
    position: relative;
    flex: none;
    width: min(calc(100cqw - 200px), calc((100cqh - 2 * var(--bx-cs-pad) - 6px) * 1.2 + 2 * var(--bx-cs-pad) + 6px), 660px);
    padding: var(--bx-cs-pad);
    border: 3px solid transparent;
    border-radius: 28px;
    background:
        linear-gradient(160deg, #3a2257, #1c1030 55%, #241338) padding-box,
        conic-gradient(from 210deg, #f5c451, #ff8a6b, var(--bx-cs-amethyst), #5d7cff, var(--bx-jade), #f5c451) border-box;
    box-shadow:
        0 34px 60px -28px rgba(0, 0, 0, .95),
        0 0 46px -14px rgba(180, 92, 240, .55),
        inset 0 1px 0 rgba(255, 255, 255, .22),
        inset 0 -2px 0 rgba(0, 0, 0, .35);
}

/* inner bevel line */
.bx-eng--cascade .bx-cs-frame::before {
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid rgba(245, 196, 81, .32);
    border-radius: 22px;
    pointer-events: none;
}

/* bonus glow, faded in and out */
.bx-eng--cascade .bx-cs-frame::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 28px;
    box-shadow: 0 0 0 2px rgba(255, 138, 107, .9), 0 0 40px rgba(255, 107, 87, .5), inset 0 0 26px rgba(255, 107, 87, .28);
    opacity: 0;
    transition: opacity .3s ease-out;
    pointer-events: none;
}

.bx-eng--cascade .bx-cs-frame[data-mode="bonus"]::after { opacity: 1; }

.bx-eng--cascade .bx-cs-gem {
    position: absolute;
    z-index: 2;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    transform: rotate(45deg);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(255, 255, 255, .35);
}

.bx-eng--cascade .bx-cs-gem--tl { top: -9px; left: -9px; background: radial-gradient(circle at 35% 30%, #fff 0 8%, #8ff7d6 22%, #13a37a 80%); }
.bx-eng--cascade .bx-cs-gem--tr { top: -9px; right: -9px; background: radial-gradient(circle at 35% 30%, #fff 0 8%, #ffb3a4 22%, #d23a26 80%); }
.bx-eng--cascade .bx-cs-gem--bl { bottom: -9px; left: -9px; background: radial-gradient(circle at 35% 30%, #fff 0 8%, #e1b5ff 22%, #7a2fc0 80%); }
.bx-eng--cascade .bx-cs-gem--br { bottom: -9px; right: -9px; background: radial-gradient(circle at 35% 30%, #fff 0 8%, #ffe7a3 22%, #c48a12 80%); }

.bx-eng--cascade .bx-cs-ribbon {
    position: absolute;
    z-index: 5;
    top: 0;
    left: 50%;
    padding: 5px 16px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #2a0d08;
    background: linear-gradient(180deg, #ffb09e, var(--bx-coral));
    box-shadow: 0 8px 18px -8px rgba(255, 107, 87, .8), inset 0 1px 0 rgba(255, 255, 255, .55);
    transform: translate(-50%, -62%);
}

.bx-eng--cascade .bx-cs-ribbon[hidden] { display: none; }

.bx-eng--cascade .bx-cs-flash {
    position: absolute;
    inset: 0;
    z-index: 4;
    border-radius: 26px;
    background: radial-gradient(closest-side, rgba(245, 196, 81, .32), rgba(245, 196, 81, 0));
    opacity: 0;
    pointer-events: none;
}

.bx-eng--cascade .bx-cs-flash.is-on { animation: bx-cs-flash .9s ease-out; }

@keyframes bx-cs-flash {
    25% { opacity: 1; }
}

/* ---------------------------------------------------------------- well and grid */

.bx-eng--cascade .bx-cs-well {
    position: relative;
    aspect-ratio: var(--bx-cs-cols) / var(--bx-cs-rows);
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(120% 80% at 50% -10%, rgba(180, 92, 240, .28), rgba(180, 92, 240, 0) 60%),
        radial-gradient(90% 70% at 50% 110%, rgba(63, 224, 176, .12), rgba(63, 224, 176, 0) 70%),
        linear-gradient(180deg, #24133a, #140b22);
    box-shadow: inset 0 3px 14px rgba(0, 0, 0, .7), inset 0 0 0 1px rgba(255, 255, 255, .06);
}

/* glass sheen over the symbols */
.bx-eng--cascade .bx-cs-well::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 3;
    background: linear-gradient(172deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .03) 28%, rgba(255, 255, 255, 0) 42%);
    pointer-events: none;
}

.bx-eng--cascade .bx-cs-slots,
.bx-eng--cascade .bx-cs-grid {
    position: absolute;
    inset: var(--bx-cs-gap);
    display: grid;
    grid-template-columns: repeat(var(--bx-cs-cols), minmax(0, 1fr));
    grid-template-rows: repeat(var(--bx-cs-rows), minmax(0, 1fr));
    gap: var(--bx-cs-gap);
}

.bx-eng--cascade .bx-cs-slots i {
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .015));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07), inset 0 -10px 18px rgba(0, 0, 0, .22);
}

.bx-eng--cascade .bx-cs-grid { z-index: 2; }

.bx-eng--cascade .bx-cs-cell {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    padding: 7%;
}

.bx-eng--cascade .bx-cs-cell .bx-sym {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .5));
    transition: transform .2s ease-out;
}

.bx-eng--cascade .bx-cs-cell .bx-sym--text {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    background: rgba(243, 236, 223, .08);
    color: var(--bx-ink);
    filter: none;
}

/* glow behind a paying symbol */
.bx-eng--cascade .bx-cs-cell::before {
    content: '';
    position: absolute;
    inset: 4%;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(255, 226, 140, .7), rgba(245, 196, 81, 0));
    opacity: 0;
    transition: opacity .18s ease-out, transform .2s ease-out;
}

/* cluster outline: each cell draws only the edges that face outside its cluster */
.bx-eng--cascade .bx-cs-cell::after {
    content: '';
    position: absolute;
    inset: calc(var(--bx-cs-gap) / -2);
    z-index: 2;
    border: 0 solid var(--bx-gold);
    background: linear-gradient(180deg, rgba(255, 226, 150, .14), rgba(245, 196, 81, .06));
    opacity: 0;
    transition: opacity .18s ease-out;
    pointer-events: none;
}

.bx-eng--cascade .bx-cs-cell.is-win::before { opacity: .75; }
.bx-eng--cascade .bx-cs-cell.is-win::after { opacity: 1; }
.bx-eng--cascade .bx-cs-cell.is-win .bx-sym {
    transform: scale(1.08);
    filter: drop-shadow(0 0 9px rgba(255, 214, 120, .7)) drop-shadow(0 4px 5px rgba(0, 0, 0, .45));
}

.bx-eng--cascade .bx-cs-cell[data-edge*="t"]::after { border-top-width: 2px; }
.bx-eng--cascade .bx-cs-cell[data-edge*="r"]::after { border-right-width: 2px; }
.bx-eng--cascade .bx-cs-cell[data-edge*="b"]::after { border-bottom-width: 2px; }
.bx-eng--cascade .bx-cs-cell[data-edge*="l"]::after { border-left-width: 2px; }
.bx-eng--cascade .bx-cs-cell[data-edge*="t"][data-edge*="l"]::after { border-top-left-radius: 12px; }
.bx-eng--cascade .bx-cs-cell[data-edge*="t"][data-edge*="r"]::after { border-top-right-radius: 12px; }
.bx-eng--cascade .bx-cs-cell[data-edge*="b"][data-edge*="l"]::after { border-bottom-left-radius: 12px; }
.bx-eng--cascade .bx-cs-cell[data-edge*="b"][data-edge*="r"]::after { border-bottom-right-radius: 12px; }

.bx-eng--cascade .bx-cs-cell.is-pop {
    opacity: 0;
    transform: scale(1.22);
    transition: opacity .2s ease-out, transform .2s ease-out;
}

.bx-eng--cascade .bx-cs-cell.is-pop::before { transform: scale(1.6); }

.bx-eng--cascade .bx-cs-cell.is-out {
    opacity: 0;
    transform: translateY(40%);
    transition: opacity .17s ease-out, transform .17s ease-out;
}

/* bonus symbols that start or add bonus drops */
.bx-eng--cascade .bx-cs-cell.is-call::after {
    opacity: 1;
    inset: 0;
    border-width: 2px;
    border-color: var(--bx-jade);
    border-radius: 12px;
    background: rgba(63, 224, 176, .16);
}

.bx-eng--cascade .bx-cs-cell.is-call::before {
    opacity: .7;
    background: radial-gradient(closest-side, rgba(143, 247, 214, .75), rgba(63, 224, 176, 0));
}

.bx-eng--cascade .bx-cs-cell.is-call .bx-sym { animation: bx-cs-call .7s ease-out; }

@keyframes bx-cs-call {
    40% { transform: scale(1.16); }
}

/* ---------------------------------------------------------------- amount tags */

.bx-eng--cascade .bx-cs-tags {
    position: absolute;
    inset: var(--bx-cs-gap);
    z-index: 4;
    pointer-events: none;
}

.bx-eng--cascade .bx-cs-tag {
    position: absolute;
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 4px 11px 5px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: #241304;
    background: linear-gradient(180deg, #fff0bf, var(--bx-gold));
    box-shadow: 0 8px 18px -6px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255, 255, 255, .7);
    transform: translate(-50%, -50%);
    animation: bx-cs-tag .24s ease-out both;
}

.bx-eng--cascade .bx-cs-tag small {
    font-size: .72em;
    color: #7a3d00;
}

.bx-eng--cascade .bx-cs-tag.is-gone {
    opacity: 0;
    transition: opacity .18s ease-out;
}

@keyframes bx-cs-tag {
    from { opacity: 0; transform: translate(-50%, -20%) scale(.92); }
}

/* ---------------------------------------------------------------- narrow stages */

@container (max-width: 640px) {
    .bx-eng--cascade .bx-cs-stage {
        flex-direction: column;
        justify-content: flex-start;
        gap: 12px;
    }

    .bx-eng--cascade .bx-cs-hud {
        flex-direction: row;
        width: 100%;
        gap: 6px;
    }

    .bx-eng--cascade .bx-cs-chip {
        flex: 1 1 0;
        min-width: 0;
        align-items: center;
        padding: 6px 4px 7px;
        border-radius: 12px;
    }

    .bx-eng--cascade .bx-cs-chip__k {
        font-size: .56rem;
        letter-spacing: .06em;
        white-space: nowrap;
    }

    .bx-eng--cascade .bx-cs-chip__v {
        font-size: 1.02rem;
        transform-origin: center;
    }

    .bx-eng--cascade .bx-cs-legend { display: none; }

    .bx-eng--cascade .bx-cs-frame {
        --bx-cs-pad: 9px;
        width: min(100cqw, calc((100cqh - 66px - 2 * var(--bx-cs-pad) - 6px) * 1.2 + 2 * var(--bx-cs-pad) + 6px));
        border-radius: 22px;
    }

    .bx-eng--cascade .bx-cs-frame::before { inset: 4px; border-radius: 18px; }
    .bx-eng--cascade .bx-cs-frame::after { border-radius: 22px; }
    .bx-eng--cascade .bx-cs-well { border-radius: 14px; }
    .bx-eng--cascade .bx-cs-slots i { border-radius: 9px; }
    .bx-eng--cascade .bx-cs-tag { font-size: .82rem; padding: 3px 8px 4px; }
}

@media (max-width: 560px) {
    .bx-eng--cascade { --bx-cs-gap: 4px; }
    .bx-eng--cascade .bx-cs-board { padding: 16px 10px 6px; min-height: 320px; }
}

@media (prefers-reduced-motion: reduce) {
    .bx-eng--cascade .bx-cs-tag,
    .bx-eng--cascade .bx-cs-flash.is-on,
    .bx-eng--cascade .bx-cs-chip.is-bump .bx-cs-chip__v,
    .bx-eng--cascade .bx-cs-cell.is-call .bx-sym { animation: none; }
}
