/* ——— Blackjack (js/casino/blackjack.js): the dealer above, your hands below, the moves under the felt. ——— */

.bj-stage {
    --bj-gold: #f3cf7a;
    --bj-felt: #0f3b2c;
    --bj-card-w: clamp(54px, 7.2vw, 76px);
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    padding: 14px 20px 0;
}

/* status: what is happening and what it means */

.bj-status {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 1px solid var(--cas-line);
    border-radius: 18px;
    background: rgba(7, 10, 16, 0.5);
    transition: border-color 0.3s, background 0.3s;
}

.bj-status.is-win {
    border-color: rgba(52, 211, 153, 0.35);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.12), rgba(7, 10, 16, 0.5));
}

.bj-status.is-loss {
    border-color: rgba(251, 113, 133, 0.25);
}

.bj-status__icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(160deg, #7c3aed, #4c1d95);
    box-shadow: 0 0 0 2px rgba(243, 207, 122, 0.55), 0 8px 18px -8px rgba(124, 58, 237, 0.9);
    color: #fff;
    font-size: 19px;
    font-weight: 800;
}

.bj-status__body {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.bj-status__label {
    color: var(--cas-muted-dark, #9aa6b8);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.bj-status__title {
    color: #fff;
    font-size: 17px;
    font-weight: 800;
}

.bj-status.is-win .bj-status__title { color: #6ee7b7; }
.bj-status.is-loss .bj-status__title { color: #fecdd3; }

.bj-status__meta {
    color: #c7d2e0;
    font-size: 13px;
}

/* the felt */

.bj-felt {
    position: relative;
    display: grid;
    grid-template-rows: auto auto 1fr;
    gap: 10px;
    min-height: 380px;
    padding: 16px 18px 20px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 22px;
    background:
        radial-gradient(110% 120% at 50% 0%, rgba(16, 185, 129, 0.18), transparent 60%),
        linear-gradient(180deg, #0f3b2c, #0a2a20);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), inset 0 0 0 6px rgba(0, 0, 0, 0.18), 0 18px 30px -22px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

.bj-shoe {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 46px;
    height: 62px;
}

.bj-shoe i {
    position: absolute;
    inset: 0;
    border-radius: 7px;
    background:
        radial-gradient(circle at 50% 50%, rgba(243, 207, 122, 0.4) 0 14%, transparent 15%),
        repeating-linear-gradient(45deg, #4c1d95 0 5px, #6d28d9 5px 10px);
    box-shadow: inset 0 0 0 2.5px #fff, 0 4px 10px -4px rgba(0, 0, 0, 0.7);
}

.bj-shoe i:nth-child(2) { transform: translate(-3px, 3px); }
.bj-shoe i:nth-child(3) { transform: translate(-6px, 6px); }

.bj-seat,
.bj-hand {
    display: grid;
    justify-items: center;
    gap: 8px;
}

.bj-seat__head,
.bj-hand__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 28px;
}

.bj-seat__name,
.bj-hand__name {
    color: #ecfdf5;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.bj-hand__stake {
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(5, 12, 9, 0.55);
    color: var(--bj-gold);
    font-family: var(--cas-mono);
    font-size: 12px;
    font-weight: 700;
}

.bj-hand__stake:empty { display: none; }

.bj-total {
    min-width: 38px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f8fafc;
    color: #0b1018;
    font-family: var(--cas-mono);
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    animation: bj-pop 0.3s var(--cas-spring);
}

.bj-total.is-21 {
    background: linear-gradient(180deg, #fde68a, #d6a647);
    color: #3a2400;
}

.bj-total.is-bust {
    background: #e11d48;
    color: #fff;
}

@keyframes bj-pop {
    from { opacity: 0; transform: scale(0.6); }
}

.bj-felt__rules {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px 0;
    color: rgba(243, 207, 122, 0.92);
    text-align: center;
}

.bj-felt__rules b {
    font-size: clamp(13px, 1.6vw, 16px);
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.bj-felt__rules span {
    color: rgba(236, 253, 245, 0.82);
    font-size: 12px;
    letter-spacing: 0.04em;
}

.bj-hands {
    display: flex;
    flex-wrap: wrap;
    align-content: start;
    align-items: start;
    justify-content: center;
    gap: 12px 18px;
}

.bj-hand {
    position: relative;
    padding: 8px 10px 10px;
    border-radius: 16px;
    transition: background 0.3s, box-shadow 0.3s, opacity 0.3s;
}

.bj-hand.is-active {
    background: rgba(243, 207, 122, 0.1);
    box-shadow: inset 0 0 0 1.5px rgba(243, 207, 122, 0.75), 0 0 22px rgba(243, 207, 122, 0.18);
}

.bj-hand.is-wait { opacity: 0.72; }
.bj-hand.is-win { background: rgba(16, 185, 129, 0.16); box-shadow: inset 0 0 0 1.5px rgba(52, 211, 153, 0.8); }
.bj-hand.is-push { background: rgba(148, 163, 184, 0.14); box-shadow: inset 0 0 0 1.5px rgba(203, 213, 225, 0.55); }
.bj-hand.is-lose { opacity: 0.86; }

.bj-hand__result {
    padding: 3px 12px;
    border-radius: 999px;
    background: rgba(5, 12, 9, 0.7);
    color: #f1f5f9;
    font-size: 13px;
    font-weight: 800;
    animation: bj-pop 0.35s var(--cas-spring);
}

.bj-hand.is-win .bj-hand__result { background: #059669; color: #fff; }
.bj-hand.is-lose .bj-hand__result { background: #9f1239; color: #fff; }

/* cards */

.bj-cards {
    display: flex;
    justify-content: center;
    min-height: calc(var(--bj-card-w) * 1.4);
}

.bj-card {
    position: relative;
    flex: none;
    width: var(--bj-card-w);
    aspect-ratio: 5 / 7;
    perspective: 700px;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.bj-card + .bj-card {
    margin-left: calc(var(--bj-card-w) * -0.38);
}

.bj-card.is-flying {
    transform: translate(var(--fx, 0), var(--fy, 0)) rotate(-10deg) scale(0.86);
    transition: none;
}

.bj-card__in {
    position: absolute;
    inset: 0;
    transform: rotateY(180deg);
    transform-style: preserve-3d;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.bj-card.is-open .bj-card__in {
    transform: rotateY(0deg);
}

.bj-card__face,
.bj-card__back {
    position: absolute;
    inset: 0;
    border-radius: 9px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.bj-card__back {
    transform: rotateY(180deg);
    background:
        radial-gradient(circle at 50% 50%, rgba(243, 207, 122, 0.4) 0 14%, transparent 15%),
        repeating-linear-gradient(45deg, #4c1d95 0 6px, #6d28d9 6px 12px);
    box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 4px rgba(0, 0, 0, 0.15), -4px 6px 14px -6px rgba(0, 0, 0, 0.75);
}

.bj-card__face {
    display: grid;
    grid-template-rows: auto 1fr;
    padding: 5px 6px;
    background: linear-gradient(180deg, #fff, #f1f5f9);
    box-shadow: inset 0 0 0 1px #cbd5e1, -4px 6px 14px -6px rgba(0, 0, 0, 0.75);
    color: #111827;
}

.bj-card__face.is-red { color: #b91c1c; }

.bj-card__rank {
    font-size: calc(var(--bj-card-w) * 0.28);
    font-weight: 800;
    line-height: 1;
}

.bj-card__suit {
    position: absolute;
    top: calc(5px + var(--bj-card-w) * 0.3);
    left: 6px;
    font-size: calc(var(--bj-card-w) * 0.2);
    line-height: 1;
}

.bj-card__pip {
    align-self: center;
    justify-self: center;
    font-size: calc(var(--bj-card-w) * 0.5);
    line-height: 1;
}

/* moves */

.bj-moves {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.bj-moves[hidden],
.bj-insure[hidden],
.bj-deal[hidden] { display: none; }

.bj-deal {
    width: 100%;
}

.bj-move {
    --c: #34d399;
    position: relative;
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 12px 8px 10px;
    border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
    border-radius: 14px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 22%, #101826), #0c131e);
    color: #fff;
    font: inherit;
    cursor: pointer;
    transition: transform 0.15s, filter 0.15s, opacity 0.2s;
}

.bj-move--stand { --c: #fb7185; }
.bj-move--double { --c: #f5b83d; }
.bj-move--split { --c: #a78bfa; }

.bj-move:hover:not(:disabled) { filter: brightness(1.15); transform: translateY(-1px); }
.bj-move:active:not(:disabled) { transform: translateY(1px); }

.bj-move:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.bj-move__name {
    font-size: 15px;
    font-weight: 800;
}

.bj-move__sub {
    color: #d8e1ec;
    font-size: 12px;
    font-weight: 600;
}

.bj-move kbd {
    position: absolute;
    top: 6px;
    right: 8px;
    color: rgba(255, 255, 255, 0.55);
    font-family: var(--cas-mono);
    font-size: 10px;
}

.bj-insure {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 16px;
    padding: 12px 14px;
    border: 1px solid rgba(243, 207, 122, 0.45);
    border-radius: 16px;
    background: rgba(243, 207, 122, 0.08);
    animation: bj-pop 0.3s var(--cas-spring);
}

.bj-insure p {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: #fde68a;
    font-size: 14px;
    font-weight: 700;
}

.bj-insure__btns {
    display: flex;
    gap: 8px;
}

.bj-keys {
    margin: 4px 0 0;
    color: #a3afc0;
    font-size: 12px;
}

.bj-rules-list {
    margin-top: 12px;
}

/* the fair panel: the first cards of the shoe */

.bj-verify {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bj-vcard {
    padding: 4px 7px;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    font-family: var(--cas-mono);
    font-size: 13px;
    font-weight: 700;
}

.bj-vcard.is-red { color: #b91c1c; }
.bj-vcard.is-deal { box-shadow: 0 0 0 2px #10b981; }

@media (max-width: 720px) {
    .bj-stage { padding: 10px 10px 0; gap: 10px; }
    .bj-status { padding: 10px 12px; gap: 10px; }
    .bj-status__icon { width: 40px; height: 40px; font-size: 16px; }
    .bj-status__title { font-size: 15px; }
    .bj-felt { min-height: 330px; padding: 12px 8px 14px; }
    .bj-shoe { top: 10px; right: 10px; transform: scale(0.8); transform-origin: top right; }
    .bj-moves { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .bj-move kbd,
    .bj-keys { display: none; }
    .bj-hands { gap: 8px; }
    .bj-hand { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
    .bj-card,
    .bj-card__in { transition: none; }
}

/* ——— side bets (owner 03.12, a demo): two fields under the bet, the results on the felt, the rules dialog ——— */

.bj-sidebets {
    display: grid;
    gap: 8px;
}

.bj-sidebets__rules {
    padding: 0;
    border: 0;
    background: none;
    color: #6ee7b7;
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.bj-sidebets .cas-field-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.bj-sidebet {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    min-width: 0;
    padding: 8px 10px 10px;
    border: 1px solid var(--cas-line-strong);
    border-radius: 14px;
    background: var(--cas-ink-950);
}

.bj-sidebet__head {
    display: grid;
    gap: 2px;
    cursor: text;
}

.bj-sidebet:focus-within {
    border-color: rgba(52, 211, 153, 0.6);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

.bj-sidebet__name {
    color: #f1f5f9;
    font-size: 13px;
    font-weight: 800;
}

.bj-sidebet__name em {
    color: var(--bj-gold, #f3cf7a);
    font-size: 11.5px;
    font-style: normal;
    font-weight: 700;
}

.bj-sidebet__sub {
    color: var(--cas-on-dark-3);
    font-size: 11px;
}

.bj-sidebet__input {
    unicode-bidi: plaintext;
    width: 100%;
    min-width: 0;
    margin-top: 4px;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: #fff;
    font-family: var(--cas-mono);
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.bj-sidebet__input::placeholder {
    color: #8b97a8;
}

.bj-sidebet__input:disabled {
    color: var(--cas-on-dark-2);
}

/* The slider: a big thumb for a thumb (owner 03.12), the filled part up to the amount (--fill, set by blackjack.js). */
.bj-sidebet__range {
    --fill: 0%;
    width: 100%;
    height: 30px;
    margin: 2px 0 0;
    background: transparent;
    cursor: pointer;
    touch-action: pan-y;
    -webkit-appearance: none;
    appearance: none;
}

.bj-sidebet__range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #10b981 var(--fill), rgba(255, 255, 255, 0.16) var(--fill));
}

.bj-sidebet__range::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #10b981 var(--fill), rgba(255, 255, 255, 0.16) var(--fill));
}

.bj-sidebet__range::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -9px;
    border: 3px solid #0b1220;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.7), 0 2px 6px rgba(0, 0, 0, 0.45);
    -webkit-appearance: none;
    appearance: none;
}

.bj-sidebet__range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 3px solid #0b1220;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.7), 0 2px 6px rgba(0, 0, 0, 0.45);
}

.bj-sidebet__range:focus-visible {
    outline: 2px solid rgba(52, 211, 153, 0.7);
    outline-offset: 2px;
    border-radius: 6px;
}

.bj-sidebet__range:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

/* RTL (fa): left to right like the main bet's slider right above it — small amounts on the left on both. */
[dir='rtl'] .bj-sidebet__range {
    direction: ltr;
}

/* «21+3 100 to 1» in an RTL page keeps its order (the English fallback would read «to 1 100 21+3»). */
[dir='rtl'] .bj-sidebet__name {
    unicode-bidi: plaintext;
    text-align: right;
}

/* The amount and «= bet» on one line, the slider and the quick amounts under them. */
.bj-sidebet__amount {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.bj-sidebet__amount .bj-sidebet__input {
    flex: 1;
    width: 0;
    margin-top: 0;
}

/* Quick amounts: the look of the bet box's ½ / 2× / Max. */
.bj-sidebet__quick {
    display: flex;
    gap: 4px;
}

.bj-sidebet__q {
    flex: 1 1 0;
    min-width: 0;
    height: 34px;
    padding: 0 6px;
    border: 1px solid var(--cas-line);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.04);
    color: #e2e8f0;
    font-family: var(--cas-mono);
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    unicode-bidi: plaintext;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.bj-sidebet__q--bet {
    flex: none;
    font-family: inherit;
    font-size: 12.5px;
}

.bj-sidebet__q:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.bj-sidebet__q.is-on {
    border-color: rgba(52, 211, 153, 0.7);
    background: rgba(16, 185, 129, 0.16);
    color: #fff;
}

.bj-sidebet__q:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.bj-sidebets__note {
    margin: 0;
    color: var(--cas-on-dark-2);
    font-size: 12px;
}

.bj-side {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.bj-side__badge {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(5, 12, 9, 0.72);
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 700;
    animation: bj-pop 0.35s var(--cas-spring);
}

.bj-side__badge small {
    color: #a7b4c6;
    font-size: 11px;
    font-weight: 700;
}

.bj-side__badge.is-win {
    background: linear-gradient(180deg, #f3cf7a, #d9a93f);
    color: #1c1405;
    box-shadow: 0 0 0 2px rgba(243, 207, 122, 0.35), 0 8px 18px -10px rgba(243, 207, 122, 0.9);
}

.bj-side__badge.is-win small {
    color: #3b2a06;
}

.bj-side-dlg {
    width: min(480px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 0;
    border: 0;
    border-radius: 20px;
    background: var(--cas-ink-900, #10151f);
    color: var(--cas-on-dark, #f1f5f9);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}

.bj-side-dlg::backdrop {
    background: rgba(7, 10, 16, 0.66);
}

.bj-side-dlg__box {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 20px 18px 18px;
}

.bj-side-dlg h2 {
    margin: 0 40px 0 0;
    font-size: 19px;
}

.bj-side-dlg__x {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #f1f5f9;
    font-size: 20px;
    cursor: pointer;
}

.bj-side-rules {
    display: grid;
    gap: 8px;
    font-size: 13.5px;
    line-height: 1.45;
}

.bj-side-rules p {
    margin: 0;
}

.bj-side-rules__note {
    color: var(--cas-on-dark-2, #cbd5e1);
    font-size: 12.5px;
}

[dir='rtl'] .bj-side-dlg__x {
    right: auto;
    left: 12px;
}

[dir='rtl'] .bj-side-dlg h2 {
    margin: 0 0 0 40px;
}

.bj-side-rules .num {
    white-space: nowrap;
}
