.bw-game {
    display: grid;
    gap: 0.875rem;
    width: 100%;
    color: #f8f5f7;
}

.bw-scoreboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.bw-score-item {
    display: flex;
    min-width: 0;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.3rem;
    padding: 0.56rem 0.7rem;
    border: 1px solid #454055;
    border-radius: 0.65rem;
    background: #232035;
}

.bw-score-item span,
.bw-score-item small {
    color: #d1c7d7;
    font-size: 0.83rem;
}

.bw-score-item strong {
    color: #fcf4f2;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bw-score-total {
    border-color: #ab665f;
    background: #422a3a;
}

.bw-score-total strong {
    color: #ffb2a5;
}

.bw-game[data-celebration] {
    --bw-reward: #ffd391;
    --bw-glow: #f8a95460;
}

.bw-game[data-celebration="spare"] {
    --bw-reward: #ffb3d0;
    --bw-glow: #ef75ac60;
}

.bw-game[data-celebration] .bw-score-total {
    border-color: var(--bw-reward);
    box-shadow: 0 0 1.05rem var(--bw-glow);
}

.bw-game[data-celebration] .bw-score-total strong {
    color: var(--bw-reward);
}

.bw-lane {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    aspect-ratio: 2.12;
    min-height: 9.25rem;
    border: 1px solid #54445e;
    border-radius: 0.9rem;
    background: #12131f;
    box-shadow: inset 0 0 2.2rem #080712b0;
}

.bw-lane[data-active="true"] {
    cursor: crosshair;
    touch-action: manipulation;
}

.bw-lane > div {
    position: absolute;
    pointer-events: none;
}

.bw-wall {
    inset: 0 0 52%;
    background:
        radial-gradient(ellipse at 50% 0, #ffb28025 0%, transparent 60%),
        repeating-linear-gradient(90deg, transparent 0 12%, #0e101a 12% 12.5%),
        linear-gradient(180deg, #202235 0%, #3a2638 55%, #201726 100%);
}

.bw-wall::before {
    content: '';
    position: absolute;
    inset: 29% 6% 45%;
    border-top: 0.09rem solid #ffad92;
    border-bottom: 0.0625rem solid #c47df5;
    border-radius: 0.875rem;
    opacity: 0.68;
    box-shadow: 0 0 1rem #ff887c50, inset 0 0 1rem #ff887c28;
}

.bw-horizon {
    inset: 17% 3% 0;
    z-index: 1;
    background: linear-gradient(180deg, #171622 8%, #58344d 26%, #211926 32%, #16131c 100%);
    clip-path: polygon(0 7%, 37% 11%, 39% 0, 61% 0, 63% 11%, 100% 7%, 100% 41%, 0 41%);
}

.bw-horizon::before {
    content: '';
    position: absolute;
    inset: 3% 38% 67%;
    background:
        linear-gradient(90deg, transparent 0%, #b6727f25 50%, transparent 100%),
        linear-gradient(180deg, #13131d, #251d2b);
    border-top: 0.1rem solid #ff9881;
    box-shadow: inset 0 0.25rem 1rem #ff736624;
}

.bw-floor {
    inset: 35% -8% 0;
    background:
        radial-gradient(ellipse at 50% 12%, #b585a66b, transparent 59%),
        repeating-linear-gradient(0deg, #5d3d4d 0 1px, transparent 1px 11%),
        linear-gradient(90deg, #171320 0%, #433044 21%, #201823 50%, #433044 79%, #171320 100%);
}

.bw-floor::before,
.bw-floor::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(90deg, transparent 0 4%, #633b4250 4% 4.5%),
        linear-gradient(180deg, #95616a 0%, #78506a 42%, #50394c 100%);
    clip-path: polygon(15% 0, 33% 0, 20% 100%, 0 100%);
}

.bw-floor::after {
    transform: scaleX(-1);
}

.bw-wood {
    inset: 32% 0 0;
    z-index: 2;
    clip-path: polygon(38% 0, 62% 0, 89% 100%, 11% 100%);
    background:
        radial-gradient(ellipse at 50% 7%, #fff3bc96 0%, #ffdaa518 24%, transparent 50%),
        repeating-conic-gradient(from -90deg at 50% -48%, #823e2550 0deg 0.52deg, transparent 0.6deg 4.5deg),
        repeating-linear-gradient(0deg, transparent 0 19%, #7241322c 19% 19.8%),
        linear-gradient(180deg, #ba8169 0%, #d5a078 26%, #a97058 67%, #6a4143 100%);
}

.bw-wood::after {
    content: '';
    position: absolute;
    inset: 72% 0 0;
    border-top: 0.1rem solid #3b202ce0;
    background: linear-gradient(#d7906d30, #00000035);
}

.bw-guide {
    inset: 39% 0 16%;
    z-index: 3;
    background: repeating-linear-gradient(180deg, #fff1c6d9 0 4px, transparent 4px 10px);
    clip-path: polygon(
        calc(50% + var(--bw-aim-x, 0%)) 0%,
        calc(50% + var(--bw-aim-x, 0%) + 2px) 0%,
        calc(50% + 2px) 100%,
        50% 100%
    );
    mask-image: linear-gradient(transparent, #000 24%, #000 84%, transparent);
}

.bw-lane[data-active="false"] .bw-guide {
    opacity: 0.22;
}

.bw-pins {
    inset: 0;
    z-index: 4;
}

.bw-pin {
    position: absolute;
    left: var(--bw-pin-x);
    top: var(--bw-pin-y);
    z-index: var(--bw-pin-layer);
    width: clamp(0.46rem, 2.4%, 0.87rem);
    height: 13%;
    color: #fff8df;
    filter: drop-shadow(0 0.12rem 0.1rem #301a2c75);
    transform: translate(-50%, -91%) scale(var(--bw-pin-scale));
    transform-origin: 50% 90%;
}

.bw-pin::before {
    position: absolute;
    inset: 0 18% 38%;
    content: '';
    border-radius: 55% 55% 35% 35%;
    background: linear-gradient(180deg, transparent 0 48%, #ce443a 49% 62%, transparent 63% 70%, #ce443a 71% 83%, transparent 84%),
        linear-gradient(90deg, #cdbcba, currentColor 55%, #d7bdb5);
}

.bw-pin::after {
    position: absolute;
    inset: 43% 0 0;
    content: '';
    border-radius: 55% 55% 39% 39%;
    background: linear-gradient(90deg, #b49ca2, currentColor 58%, #c8a9a5);
}

.bw-pin-down {
    opacity: 0;
    transform: translate(-50%, -68%) rotate(76deg) scale(var(--bw-pin-scale));
    transition: transform 0.23s ease-out, opacity 0.16s ease-in;
    transition-delay: var(--bw-fall-delay, 0ms);
}

.bw-ball {
    left: 50%;
    top: 85%;
    z-index: 5;
    width: clamp(1.35rem, 7.6%, 3.05rem);
    aspect-ratio: 1;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background:
        radial-gradient(circle at 43% 25%, #351c3a 0 4%, transparent 5%),
        radial-gradient(circle at 57% 29%, #3a2041 0 4%, transparent 5%),
        radial-gradient(circle at 49% 40%, #2c1636 0 5%, transparent 6%),
        radial-gradient(circle at 35% 29%, #ffd6c2 0%, #ea7a81 23%, #923859 58%, #3b203c 86%, #231831 100%);
    box-shadow: 0.18rem 0.42rem 0.65rem #191322ad;
}

.bw-celebration {
    inset: 0;
    z-index: 6;
    display: grid;
    place-items: center;
    background: radial-gradient(ellipse at center, #1a102aaf, transparent 74%);
}

.bw-celebration[hidden] {
    display: none;
}

.bw-celebration strong {
    z-index: 1;
    padding: 0.26em 0.65em 0.33em;
    border: 1px solid var(--bw-reward);
    border-radius: 0.6rem;
    background: linear-gradient(145deg, #2b1a36f0, #1c1029f3);
    color: var(--bw-reward);
    font-size: clamp(1.65rem, 5.8vw, 3rem);
    line-height: 1.15;
    letter-spacing: 0.06em;
    box-shadow: 0 0 2.35rem var(--bw-glow), inset 0 0 1rem var(--bw-glow);
    animation: bw-celebrate 0.44s cubic-bezier(.19, .79, .39, 1.16) both;
}

.bw-burst {
    position: absolute;
    width: 79%;
    height: 78%;
    background:
        radial-gradient(circle at 11% 58%, #ffc476 0 0.18rem, transparent 0.22rem),
        radial-gradient(circle at 19% 24%, #fb99ac 0 0.14rem, transparent 0.18rem),
        radial-gradient(circle at 32% 83%, #fff0c5 0 0.18rem, transparent 0.22rem),
        radial-gradient(circle at 32% 13%, #cbadfd 0 0.19rem, transparent 0.23rem),
        radial-gradient(circle at 59% 14%, #fff0c5 0 0.15rem, transparent 0.19rem),
        radial-gradient(circle at 69% 87%, #fb99ac 0 0.16rem, transparent 0.2rem),
        radial-gradient(circle at 79% 34%, #ffc476 0 0.18rem, transparent 0.22rem),
        radial-gradient(circle at 89% 64%, #cbadfd 0 0.18rem, transparent 0.22rem);
    animation: bw-burst 0.78s ease-out both;
}

.bw-burst::after {
    position: absolute;
    inset: 9% 25%;
    border: 0.095rem solid var(--bw-reward);
    border-radius: 50%;
    content: '';
}

@keyframes bw-celebrate {
    from { opacity: 0; transform: scale(0.6) rotate(-6deg); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes bw-burst {
    0% { opacity: 0; transform: scale(0.28) rotate(-13deg); }
    28% { opacity: 0.95; }
    100% { opacity: 0; transform: scale(1.38) rotate(9deg); }
}

.bw-feedback-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.bw-feedback {
    min-height: 1.35em;
    margin: 0;
    color: #ddd1df;
    font-size: 0.9rem;
    line-height: 1.55;
}

.bw-sound {
    flex: 0 0 auto;
    min-height: 2.3rem;
    padding: 0.25rem 0.55rem;
    border: 1px solid #685271;
    border-radius: 0.5rem;
    background: #272036;
    color: #f4dee9;
    font: inherit;
    font-size: 0.85rem;
}

.bw-sound:hover {
    background: #372947;
}

.bw-sound[aria-pressed="true"] {
    border-color: #ffc091;
    background: #4d293c;
    color: #ffd1ae;
}

.bw-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    align-items: end;
    gap: 0.75rem;
}

.bw-control {
    display: grid;
    min-width: 0;
    gap: 0.28rem;
    align-content: center;
    padding: 0.47rem 0.66rem 0.24rem;
    border-radius: 0.62rem;
    border: 1px solid #4b4057;
    background: #241f35;
}

.bw-control span {
    display: flex;
    justify-content: space-between;
    gap: 0.2rem;
    font-size: 0.9rem;
}

.bw-control output {
    color: #ffb2a5;
    font-size: 0.85rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bw-control input[type="range"] {
    width: 100%;
    min-height: 1.57rem;
    margin: 0;
    accent-color: #ff837d;
    cursor: pointer;
}

.bw-control input[type="range"]:disabled {
    cursor: default;
}

.bw-throw {
    align-self: stretch;
    min-width: 5.25rem;
    min-height: 2.8rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid #ffb2a5;
    border-radius: 0.62rem;
    background: #ff837d;
    color: #22122a;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    white-space: nowrap;
}

.bw-throw:hover:not([aria-disabled="true"]) {
    background: #ffabe1;
}

.bw-throw[aria-disabled="true"] {
    cursor: wait;
    opacity: 0.68;
}

.bw-throw:focus-visible,
.bw-sound:focus-visible,
.bw-control input:focus-visible {
    outline: 0.15rem solid #fff8e2;
    outline-offset: 0.14rem;
}

@media (max-width: 480px) {
    .bw-scoreboard {
        gap: 0.35rem;
    }

    .bw-score-item {
        display: grid;
        gap: 0.12rem;
        padding: 0.35rem 0.48rem;
    }

    .bw-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .bw-throw {
        grid-column: 1 / -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bw-pin-down {
        transition: none;
    }

    .bw-celebration strong {
        animation: none;
    }

    .bw-burst {
        display: none;
        animation: none;
    }
}
