/*==================================================
    Big Gamba
==================================================*/

:root {
    --bg: #08130e;
    --felt: #0d3324;
    --felt-2: #11402e;
    --panel: #10201a;
    --panel-2: #172c23;
    --line: rgba(255, 255, 255, 0.09);
    --text: #f2f7f3;
    --muted: #9db5a8;
    --gold: #fbbf24;
    --gold-2: #b45309;
    --win: #22c55e;
    --lose: #ef4444;
    --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
    --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 50% -10%, rgba(251, 191, 36, 0.12), transparent 60%),
        radial-gradient(700px 500px at 0% 100%, rgba(34, 197, 94, 0.08), transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
}

button,
input {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel-2);
    padding: 8px 16px;
    font-weight: 800;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

button:hover:not(:disabled) {
    border-color: rgba(251, 191, 36, 0.6);
}

button:active:not(:disabled) {
    transform: translateY(1px);
}

button:disabled {
    cursor: default;
    opacity: 0.45;
}

button.active {
    border-color: var(--gold);
    background: rgba(251, 191, 36, 0.16);
    color: #fde68a;
}

button.primary,
button.gold {
    border-color: var(--gold);
    background: linear-gradient(180deg, #fcd34d, #d97706);
    color: #3b1d03;
}

button.primary.cash {
    border-color: var(--win);
    background: linear-gradient(180deg, #4ade80, #15803d);
    color: #052e16;
}

/* Header */
.bg-top {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 1320px;
    margin: 0 auto;
    padding: 8px 16px;
}

.bg-home {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--muted);
    text-decoration: none;
    font-weight: 800;
}

.bg-home:hover {
    color: var(--text);
    border-color: var(--gold);
}

.bg-logo {
    margin: 0;
    font-family: var(--font-display);
    font-size: 26px;
    letter-spacing: 0.5px;
    color: #fde68a;
    text-shadow: 0 3px 0 var(--gold-2), 0 0 24px rgba(251, 191, 36, 0.35);
}

.bg-logo span {
    color: var(--gold);
}

.bg-wallet {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-left: auto;
}

.bg-wallet span {
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    font-weight: 800;
    font-size: 14px;
    white-space: nowrap;
}

.bg-goal {
    margin: 0 max(16px, calc((100% - 1288px) / 2)) 10px;
    padding: 6px 14px;
    border: 1px dashed rgba(251, 191, 36, 0.35);
    border-radius: 12px;
    background: rgba(251, 191, 36, 0.06);
    color: #fde68a;
    font-size: 14px;
}

.bg-bank {
    display: grid;
    justify-items: end;
    line-height: 1.15;
}

.bg-bank small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.bg-bank strong {
    font-family: var(--font-display);
    font-size: 28px;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
}

.bg-bank strong.broke {
    color: var(--lose);
}

/* Layout */
.bg-layout {
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr) 340px;
    gap: 14px;
    align-items: start;
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 16px 24px;
}

.bg-games {
    display: grid;
    gap: 6px;
}

.bg-games button {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 14px;
    padding: 7px 12px;
    text-align: left;
    background: var(--panel);
}

.bg-games button.locked {
    opacity: 0.6;
}

.bg-games button.locked.ready {
    position: relative;
    opacity: 1;
    border-color: rgba(251, 191, 36, 0.5);
}

/* The glow fades in and out on its own layer, so it never repaints the button. */
.bg-games button.locked.ready::after {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.18);
    pointer-events: none;
    opacity: 0;
    will-change: opacity;
    animation: pulse 1.6s ease-in-out infinite;
}

.tab-icon {
    font-size: 24px;
}

.tab-text {
    display: grid;
    min-width: 0;
}

.tab-text small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* Table */
.bg-table {
    position: relative;
    display: grid;
    gap: 10px;
    padding: 12px 16px;
    border: 1px solid rgba(251, 191, 36, 0.25);
    border-radius: 22px;
    background:
        radial-gradient(circle at 50% 30%, var(--felt-2), var(--felt) 70%);
    box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.18), 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* Name and blurb share a line. */
.bg-table-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 12px;
}

.bg-table-head h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 22px;
}

.bg-table-head p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

.bg-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 200px;
    overflow: hidden;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.22);
}

.bg-params {
    display: flex;
    justify-content: center;
}

.bg-pays {
    margin: 0;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

.bg-pays b {
    color: var(--text);
}

.bg-choice {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.bg-param-stack {
    display: grid;
    justify-items: center;
    gap: 10px;
    width: 100%;
}

.bg-choice-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px 10px;
    color: var(--muted);
    font-weight: 700;
}

.bg-choice-row .bg-choice {
    gap: 4px;
}

.bg-choice-row button {
    padding: 6px 12px;
    font-size: 14px;
}

.bg-slider {
    display: grid;
    gap: 6px;
    width: min(420px, 100%);
    color: var(--muted);
    font-weight: 700;
    text-align: center;
}

.bg-slider b {
    color: var(--text);
}

.bg-slider input[type="range"] {
    width: 100%;
    accent-color: var(--gold);
}

/* Bet and play buttons, one row when there's room */
.bg-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px 16px;
}

.bg-bet {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bg-bet label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.bg-bet-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.bg-bet-dollar {
    margin-right: -30px;
    z-index: 1;
    color: var(--muted);
    font-weight: 800;
    padding-left: 14px;
}

.bg-bet-row input {
    width: 130px;
    padding: 8px 12px 8px 28px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.3);
    font-weight: 800;
}

.bg-bet-row input:focus {
    outline: none;
    border-color: var(--gold);
}

.bg-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.bg-actions .primary {
    min-width: 150px;
    padding: 9px 24px;
    font-family: var(--font-display);
    font-size: 20px;
}

.bg-message {
    min-height: 1.4em;
    margin: -2px 0 -4px;
    text-align: center;
    font-weight: 800;
}

.bg-message.bad {
    color: #fca5a5;
}

.bg-message.good {
    color: #86efac;
}

/* A fixed grid of same-size slots, so nothing shifts as results come in. */
.bg-history {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 5px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bg-history li {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    height: 24px;
    padding: 0 4px;
    overflow: hidden;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    background: rgba(239, 68, 68, 0.18);
    color: #fca5a5;
}

.bg-history li span {
    flex: none;
    font-size: 11px;
}

.bg-history li b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bg-history li.empty {
    background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 640px) {
    .bg-history {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .bg-history li:nth-child(n + 9) {
        display: none;
    }
}

.bg-history li.win {
    background: rgba(34, 197, 94, 0.18);
    color: #86efac;
}

.bg-history li.push {
    background: rgba(255, 255, 255, 0.08);
    color: var(--muted);
}

/* Floating amounts and the big-win banner */
.bg-float {
    position: absolute;
    top: 45%;
    z-index: 5;
    pointer-events: none;
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    transform: translateX(-50%);
    animation: float-up 1s ease-out forwards;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
    will-change: opacity, translate;
}

.bg-float.win {
    color: #4ade80;
}

.bg-float.lose {
    color: #f87171;
}

.bg-float.beg {
    color: #fde68a;
    font-size: 20px;
}

@keyframes float-up {
    from { opacity: 1; translate: 0 0; }
    to { opacity: 0; translate: 0 -70px; }
}

@keyframes pulse {
    50% { opacity: 1; }
}

.bg-banner {
    position: fixed;
    top: 30%;
    left: 50%;
    z-index: 50;
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 18px 34px;
    border: 3px solid var(--gold);
    border-radius: 24px;
    background: radial-gradient(circle, #3b2405, #120a02);
    box-shadow: 0 0 60px rgba(251, 191, 36, 0.55);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.bg-banner[hidden] {
    display: none;
}

.bg-banner.show {
    animation: banner var(--banner-ms, 2200ms) ease-out forwards;
}

.bg-banner b {
    font-family: var(--font-display);
    font-size: clamp(34px, 8vw, 64px);
    color: var(--gold);
    text-shadow: 0 4px 0 var(--gold-2);
    white-space: nowrap;
}

.bg-banner span {
    font-weight: 800;
    font-size: 20px;
    color: #fde68a;
}

@keyframes banner {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(2deg); }
    25% { transform: translate(-50%, -50%) scale(1) rotate(0); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* Banner tiers. Past Legendary ("grand") the whole screen flares. */
.bg-banner.tier-mega {
    border-color: #4ade80;
    background: radial-gradient(circle, #0f3d25, #04140b);
    box-shadow: 0 0 60px rgba(74, 222, 128, 0.45), inset 0 0 0 3px rgba(251, 191, 36, 0.45);
}

.bg-banner.tier-ultra {
    border-width: 4px;
    box-shadow: 0 0 80px rgba(251, 191, 36, 0.7), 0 0 0 7px rgba(251, 191, 36, 0.22);
}

.bg-banner.tier-legendary,
.bg-banner.grand {
    border-width: 4px;
    background: radial-gradient(circle, #4a3006, #0b2016);
    box-shadow: 0 0 90px rgba(251, 191, 36, 0.8), 0 0 40px rgba(34, 197, 94, 0.5);
}

.bg-banner.tier-legendary b,
.bg-banner.grand b {
    background-image: linear-gradient(180deg, #fff3c4, var(--gold) 55%, #d97706);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 4px 0 #78350f);
}

.bg-banner.grand {
    padding: 22px 42px;
}

.bg-banner.grand b {
    font-size: clamp(36px, 9vw, 84px);
}

@media (max-width: 640px) {
    .bg-banner.grand {
        width: calc(100vw - 56px);
        padding: 14px 12px;
    }

    .bg-banner.grand b {
        font-size: 34px;
        line-height: 1.05;
        text-align: center;
        white-space: normal;
    }
}

.bg-banner.tier-mythic {
    border-color: #4ade80;
    background: radial-gradient(circle, #0b3b22, #03110a);
    box-shadow: 0 0 110px rgba(74, 222, 128, 0.7), 0 0 0 8px rgba(251, 191, 36, 0.3);
}

.bg-banner.tier-mythic b {
    background-image: linear-gradient(180deg, #fef3c7, #fbbf24 45%, #4ade80);
    filter: drop-shadow(0 4px 0 #064e3b);
}

.bg-banner.tier-cosmic {
    border-color: #6ee7b7;
    background:
        radial-gradient(2px 2px at 20% 30%, #fff, transparent),
        radial-gradient(2px 2px at 75% 20%, #fde68a, transparent),
        radial-gradient(1.5px 1.5px at 60% 75%, #fff, transparent),
        radial-gradient(1.5px 1.5px at 35% 80%, #a7f3d0, transparent),
        radial-gradient(circle, #053b33, #010d0b);
    box-shadow: 0 0 130px rgba(110, 231, 183, 0.65), 0 0 50px rgba(251, 191, 36, 0.6), 0 0 0 8px rgba(110, 231, 183, 0.25);
}

.bg-banner.tier-cosmic b {
    background-image: linear-gradient(180deg, #ecfdf5, #a7f3d0 40%, #fbbf24);
    filter: drop-shadow(0 0 14px rgba(110, 231, 183, 0.8)) drop-shadow(0 4px 0 #064e3b);
}

.bg-banner.tier-divine {
    border-color: #fff7d6;
    background: radial-gradient(circle, #6b4f12, #1a1205);
    box-shadow: 0 0 160px rgba(255, 247, 214, 0.85), 0 0 60px rgba(251, 191, 36, 0.9), 0 0 0 10px rgba(255, 247, 214, 0.3);
}

.bg-banner.tier-divine b {
    background-image: linear-gradient(180deg, #ffffff, #fef3c7 40%, #f59e0b);
    filter: drop-shadow(0 0 18px rgba(255, 247, 214, 0.9)) drop-shadow(0 4px 0 #92400e);
}

.bg-banner.tier-transcendent {
    border-color: var(--gold);
    background: radial-gradient(circle, #14532d, #2a1a03 70%, #050302);
    box-shadow: 0 0 180px rgba(251, 191, 36, 0.9), 0 0 90px rgba(74, 222, 128, 0.8), 0 0 0 12px rgba(255, 247, 214, 0.35);
}

.bg-banner.tier-transcendent b {
    background-image: linear-gradient(90deg, #fbbf24, #4ade80, #fff7d6, #fbbf24, #4ade80, #fbbf24);
    background-size: 300% 100%;
    filter: drop-shadow(0 0 22px rgba(251, 191, 36, 0.9)) drop-shadow(0 4px 0 #064e3b);
    animation: shimmer 1.4s linear infinite;
}

.bg-banner.tier-transcendent.show {
    animation: banner var(--banner-ms) ease-out forwards, throb 0.5s ease-in-out 0.4s 6;
}

@keyframes shimmer {
    to { background-position: 300% 0; }
}

@keyframes throb {
    50% { scale: 1.06; }
}

.bg-flare {
    --flare-a: rgba(34, 197, 94, 0.35);
    --flare-b: rgba(251, 191, 36, 0.35);
    position: fixed;
    inset: 0;
    z-index: 45;
    overflow: hidden;
    pointer-events: none;
    background: radial-gradient(circle at 50% 30%, var(--flare-a), transparent 70%);
    animation: flare-wash var(--banner-ms) ease-out forwards;
}

.bg-flare.tier-cosmic {
    --flare-a: rgba(4, 47, 46, 0.85);
    --flare-b: rgba(110, 231, 183, 0.3);
}

.bg-flare.tier-divine {
    --flare-a: rgba(254, 243, 199, 0.6);
    --flare-b: rgba(255, 255, 255, 0.45);
}

.bg-flare.tier-transcendent {
    --flare-a: rgba(251, 191, 36, 0.5);
    --flare-b: rgba(74, 222, 128, 0.45);
}

.bg-flare-rays,
.bg-flare.tier-transcendent::after {
    position: absolute;
    top: 30%;
    left: 50%;
    width: 220vmax;
    height: 220vmax;
    margin: -110vmax 0 0 -110vmax;
    background: repeating-conic-gradient(var(--flare-b) 0deg 5deg, transparent 5deg 15deg);
    -webkit-mask-image: radial-gradient(circle, #000, transparent 42%);
    mask-image: radial-gradient(circle, #000, transparent 42%);
    animation: flare-spin var(--banner-ms) linear forwards;
}

.bg-flare.tier-transcendent::after {
    content: "";
    background: repeating-conic-gradient(rgba(255, 247, 214, 0.35) 0deg 3deg, transparent 3deg 20deg);
    animation-direction: reverse;
}

/* The divine and transcendent flares open with a flash. */
.bg-flare.tier-divine::before,
.bg-flare.tier-transcendent::before {
    content: "";
    position: absolute;
    inset: 0;
    background: #fff7d6;
    opacity: 0;
    animation: flash 0.6s ease-out;
}

.bg-flare i {
    position: absolute;
    top: 30%;
    left: 50%;
    font-size: calc(26px * var(--s));
    font-style: normal;
    opacity: 0;
    animation: flare-burst calc(var(--banner-ms) * 0.8) cubic-bezier(0.15, 0.8, 0.3, 1) var(--d) forwards;
}

@keyframes flare-wash {
    0% { opacity: 0; }
    8%, 75% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes flare-spin {
    from { transform: rotate(0); }
    to { transform: rotate(50deg); }
}

@keyframes flare-burst {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.2); }
    10%, 70% { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1) rotate(160deg); }
}

@keyframes flash {
    from { opacity: 0.7; }
    to { opacity: 0; }
}

/* Coin */
.coin-wrap {
    perspective: 800px;
}

.coin {
    position: relative;
    width: 130px;
    height: 130px;
    transform-style: preserve-3d;
}

.coin-face {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    border-radius: 50%;
    border: 6px solid #b45309;
    background: radial-gradient(circle at 35% 30%, #fef3c7, #fbbf24 45%, #d97706);
    box-shadow: inset 0 0 0 5px rgba(120, 53, 15, 0.35);
    font-size: 52px;
    backface-visibility: hidden;
}

.coin-face small {
    font-size: 13px;
    font-weight: 800;
    color: #78350f;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.coin-face.tails {
    transform: rotateY(180deg);
    border-color: #64748b;
    background: radial-gradient(circle at 35% 30%, #f8fafc, #cbd5e1 45%, #94a3b8);
}

.coin-face.tails small {
    color: #334155;
}

.bg-stage:has(.coin-trail) {
    align-content: center;
    gap: 12px;
}

.coin-trail {
    display: flex;
    gap: 6px;
    min-height: 32px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.coin-trail li {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 2px solid var(--line);
    border-radius: 50%;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
}

.coin-trail li.hit {
    border-color: var(--win);
    background: rgba(34, 197, 94, 0.2);
}

.coin-trail li.miss {
    border-color: var(--lose);
    background: rgba(239, 68, 68, 0.25);
}

/* Dice */
.dice-combo {
    color: var(--muted);
    font-weight: 800;
    letter-spacing: 1px;
}

.dice-combo.hot b {
    color: var(--gold);
}
.bg-stage:has(.dice-roll) {
    align-content: center;
    gap: 14px;
    padding: 20px 26px;
}

.dice-roll {
    font-family: var(--font-display);
    font-size: 64px;
    font-variant-numeric: tabular-nums;
}

.dice-roll.win {
    color: var(--win);
}

.dice-roll.lose {
    color: var(--lose);
}

.dice-track {
    position: relative;
    width: min(520px, 100%);
    height: 16px;
    border-radius: 999px;
    background: rgba(239, 68, 68, 0.5);
}

.dice-zone {
    height: 100%;
    overflow: hidden;
    border-radius: 999px 0 0 999px;
    background: var(--win);
    transition: width 0.15s;
}

.dice-sweet {
    height: 100%;
    background: var(--gold);
    transition: width 0.15s;
}

.dice-marker {
    position: absolute;
    top: -8px;
    width: 6px;
    height: 32px;
    border-radius: 3px;
    background: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
    transform: translateX(-50%);
}

.dice-scale {
    display: flex;
    justify-content: space-between;
    width: min(520px, 100%);
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

/* Slots */
.slot-machine {
    --cell: 58px;
    position: relative;
    display: flex;
    gap: 10px;
    padding: 12px;
    border: 4px solid var(--gold);
    border-radius: 18px;
    background: linear-gradient(180deg, #7f1d1d, #450a0a);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.slot-machine.r4 {
    --reel: 72px;
}

.slot-machine.r5 {
    --reel: 62px;
    gap: 6px;
}

.slot-reel {
    width: var(--reel, 82px);
    transition: box-shadow 0.2s;
    height: calc(var(--cell) * 3);
    overflow: hidden;
    border-radius: 10px;
    background: linear-gradient(180deg, #d4d4d8, #fafafa 30%, #fafafa 70%, #d4d4d8);
}

.slot-reel.lit {
    box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(251, 191, 36, 0.8);
}

.slot-note {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.slot-cell {
    display: grid;
    place-items: center;
    height: var(--cell);
    font-size: 36px;
}

.slot-line {
    position: absolute;
    left: 6px;
    right: 6px;
    top: 50%;
    height: 3px;
    background: rgba(239, 68, 68, 0.8);
    pointer-events: none;
}

.slot-pays,
.wheel-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
}

.slot-pays li,
.wheel-legend li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.slot-pays b {
    color: var(--gold);
}

.wheel-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.wheel-legend small {
    color: var(--muted);
}

/* Wheel */
.wheel-wrap {
    position: relative;
    width: min(250px, 80vw);
    padding: 8px 0;
}

.wheel {
    display: block;
    width: 100%;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.5));
}

.wheel text {
    fill: #fff;
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
}

#wheelSpin {
    transform-box: view-box;
    transform-origin: 50% 50%;
}

.wheel-pointer {
    position: absolute;
    top: 2px;
    left: 50%;
    z-index: 2;
    width: 0;
    height: 0;
    border-left: 14px solid transparent;
    border-right: 14px solid transparent;
    border-top: 26px solid #fff;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
    transform: translateX(-50%);
}

.wheel-result {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
    font-family: var(--font-display);
    font-size: 40px;
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.9);
}

.wheel-result.win {
    color: #4ade80;
}

.wheel-result.lose {
    color: #f87171;
}

/* Crash */
.crash-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.crash-mult {
    position: relative;
    font-family: var(--font-display);
    font-size: 64px;
    font-variant-numeric: tabular-nums;
    color: var(--gold);
    text-shadow: 0 4px 14px rgba(0, 0, 0, 0.7);
}

.crash-mult.win {
    color: var(--win);
}

.crash-mult.lose {
    color: var(--lose);
}

.crash-note {
    position: absolute;
    bottom: 12px;
    color: var(--muted);
    font-weight: 700;
}

.crash-target {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.crash-target input {
    width: 90px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.3);
    text-align: center;
    font-weight: 800;
}

.crash-target button {
    width: 36px;
    padding: 6px 0;
}

/* Side panels */
.bg-side {
    display: grid;
    gap: 16px;
}

.bg-panel {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
}

.bg-panel h2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-size: 20px;
}

.bg-panel p {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 14px;
}

.bg-panel p b {
    color: var(--text);
}

.bg-shop {
    display: grid;
    gap: 8px;
}

.bg-buy {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border-radius: 14px;
    padding: 9px 12px;
    text-align: left;
}

.bg-buy:disabled {
    opacity: 0.55;
}

.buy-icon {
    font-size: 22px;
}

.buy-text {
    display: grid;
}

.buy-text b small {
    color: var(--muted);
    font-size: 12px;
}

.buy-text > small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.buy-cost {
    color: var(--gold);
    font-weight: 800;
    white-space: nowrap;
}

.bg-layer-button {
    width: 100%;
    margin-bottom: 12px;
}

.bg-amount {
    font-size: 16px;
    color: var(--gold);
}

.bg-panel h3 {
    margin: 16px 0 8px;
    font-family: var(--font-display);
    font-size: 16px;
    color: var(--muted);
}

.bg-stats {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    margin: 0 0 12px;
    font-size: 14px;
}

.bg-stats dt {
    color: var(--muted);
}

.bg-stats dd {
    margin: 0;
    font-weight: 800;
    text-align: right;
}

.bg-wipe {
    padding: 4px 12px;
    font-size: 12px;
    color: #fca5a5;
    background: transparent;
}

/* Side tabs */
.bg-side-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bg-side-tabs button {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    font-size: 13px;
}

/* Table upgrades */
.bg-table-ups {
    display: grid;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

.bg-mastery {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.bg-mastery b {
    color: var(--text);
}

.bg-shop-row {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.bg-shop-row .bg-buy {
    gap: 8px;
    padding: 6px 10px;
}

.bg-shop-row .buy-icon {
    font-size: 18px;
}

.bg-shop-row .buy-text b {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
}

.bg-shop-row .buy-text > small {
    font-size: 11px;
    line-height: 1.25;
}

.bg-shop-row .buy-cost {
    font-size: 14px;
}

.bg-pays b.up {
    color: #86efac;
}

.bg-pays b.down {
    color: #fca5a5;
}

.bg-sliders {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 20px;
    width: min(520px, 100%);
}

/* Milestones, trophies, automation */
.bg-milestones {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 13px;
    color: var(--muted);
}

.bg-milestones li {
    display: grid;
    gap: 1px;
    padding: 7px 10px;
    border: 1px dashed var(--line);
    border-radius: 10px;
}

.bg-milestones li b {
    color: var(--text);
}

.bg-milestones li.done {
    border-style: solid;
    border-color: rgba(34, 197, 94, 0.35);
    color: #bbf7d0;
}

.bg-trophies {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bg-trophies li {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    opacity: 0.55;
    font-size: 12px;
}

.bg-trophies li span {
    grid-row: span 2;
    font-size: 20px;
}

.bg-trophies li small {
    color: var(--muted);
}

.bg-trophies li.done {
    opacity: 1;
    border-color: rgba(251, 191, 36, 0.4);
}

.bg-toggles {
    display: grid;
    gap: 10px;
    margin-bottom: 10px;
    font-weight: 700;
    font-size: 14px;
}

/* The checkbox stays beside its text, which wraps on its own. */
.bg-toggles label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.bg-toggles label > span {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.bg-toggles label small {
    color: var(--muted);
    font-weight: 700;
}

.bg-toggles label.locked {
    color: var(--muted);
    opacity: 0.5;
}

.bg-toggles label.sub {
    padding-left: 26px;
    font-size: 13px;
}

.bg-toggles input[type="checkbox"] {
    flex: none;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--gold);
}

.bg-toggles input[type="text"] {
    width: 80px;
    padding: 3px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.3);
    font-weight: 800;
}

/* Toasts */
.bg-toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    display: grid;
    gap: 8px;
    width: min(320px, calc(100vw - 32px));
    pointer-events: none;
}

.bg-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid rgba(251, 191, 36, 0.5);
    border-radius: 14px;
    background: #14261d;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: toast-in 0.3s ease-out;
    transition: opacity 0.5s, transform 0.5s;
}

.bg-toast.out {
    opacity: 0;
    transform: translateX(30px);
}

.bg-toast > span {
    font-size: 26px;
}

.bg-toast div {
    display: grid;
}

.bg-toast small {
    color: var(--muted);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(16px); }
}

/* Plinko */
.plinko-wrap {
    display: grid;
    gap: 4px;
    width: min(400px, 100%);
    padding: 6px 0;
}

.plinko-canvas {
    width: 100%;
    height: auto;
}

.plinko-slots {
    display: grid;
    grid-template-columns: repeat(13, 1fr);
    gap: 2px;
    padding: 0 calc(100% / 14 / 2);
}

.plinko-slot {
    padding: 4px 0;
    border-radius: 5px;
    background: color-mix(in srgb, #ef4444 calc(var(--heat) * 100%), #1e3a8a);
    font-size: clamp(8px, 1.6vw, 11px);
    font-weight: 800;
    text-align: center;
    transition: transform 0.2s;
}

.plinko-slot.hit {
    outline: 2px solid #fff;
    transform: translateY(4px);
}

/* Mines */
.mines-grid {
    display: grid;
    grid-template-columns: repeat(var(--grid, 5), 1fr);
    gap: 5px;
    width: min(calc(44px * var(--grid, 5)), 80vw);
    padding: 8px 0;
}

.mine-tile {
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    border-radius: 10px;
    background: linear-gradient(180deg, #334155, #1e293b);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35);
    font-size: clamp(16px, 3.4vw, 22px);
}

.mine-tile.safe {
    background: linear-gradient(180deg, #166534, #14532d);
    animation: pop 0.2s ease-out;
}

.mine-tile.defused {
    background: linear-gradient(180deg, #1d4ed8, #1e3a8a);
}

.mine-tile.mine {
    background: linear-gradient(180deg, #b91c1c, #7f1d1d);
    animation: pop 0.25s ease-out;
}

.mine-tile.faded {
    opacity: 0.4;
}

@keyframes pop {
    from { transform: scale(0.6); }
}

/* Narrow screens */
@media (max-width: 1100px) {
    .bg-layout {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

    .bg-games {
        grid-column: 1 / -1;
        display: flex;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .bg-games button {
        flex: 0 0 auto;
    }
}

@media (max-width: 780px) {
    .bg-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .bg-side-tabs button span {
        display: none;
    }

    .bg-top {
        flex-wrap: wrap;
        gap: 10px;
    }

    .bg-logo {
        font-size: 24px;
    }

    .bg-bank strong {
        font-size: 24px;
    }

    .bg-table {
        padding: 12px;
    }

    .bg-stage {
        min-height: 220px;
    }

    .slot-machine {
        --cell: 56px;
    }

    .slot-reel {
        width: var(--reel, 66px);
    }

    .slot-machine.r4 {
        --reel: 58px;
    }

    .slot-machine.r5 {
        --cell: 48px;
        --reel: 50px;
    }

    .slot-machine.r5 .slot-cell {
        font-size: 28px;
    }

    .slot-cell {
        font-size: 34px;
    }

    .dice-roll,
    .crash-mult {
        font-size: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-games button.locked.ready::after {
        animation: none;
        opacity: 1;
    }

    .bg-flare i,
    .bg-flare-rays,
    .bg-flare::before,
    .bg-flare::after {
        display: none;
    }

    .bg-banner.tier-transcendent b {
        animation: none;
    }
}

/* Account */

.bg-account {
    flex: none;
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    padding: 8px 14px;
}

.bg-account.signed-in {
    border-color: rgba(34, 197, 94, 0.45);
}

.bg-account.error,
.bg-account.conflict {
    border-color: rgba(239, 68, 68, 0.6);
}

.bg-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
}

.bg-modal-back {
    position: absolute;
    inset: 0;
    background: rgba(2, 8, 5, 0.72);
}

.bg-modal-card {
    position: relative;
    width: min(420px, 100%);
    padding: 22px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.bg-modal-card h2 {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-size: 24px;
}

.bg-modal-card p {
    margin: 0 0 14px;
    color: var(--muted);
    line-height: 1.45;
}

.bg-modal-card label {
    display: grid;
    gap: 5px;
    margin-bottom: 12px;
    font-weight: 800;
    font-size: 14px;
}

.bg-modal-card input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
}

.bg-modal-card input:focus {
    outline: 2px solid rgba(251, 191, 36, 0.6);
    outline-offset: 1px;
}

.bg-modal-error {
    min-height: 1.2em;
    color: #fca5a5 !important;
    font-weight: 700;
}

.bg-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.bg-modal-fine {
    margin: 14px 0 0 !important;
    font-size: 12px;
}

.bg-pick {
    display: grid;
    gap: 3px;
    width: 100%;
    margin-bottom: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    text-align: left;
}

.bg-pick small {
    color: var(--muted);
    font-weight: 700;
}

@media (max-width: 640px) {
    .bg-account {
        max-width: 150px;
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* Short windows: squeeze the table a little more. */
@media (max-height: 820px) and (min-width: 781px) {
    .bg-stage {
        min-height: 170px;
    }

    .bg-goal {
        margin-bottom: 8px;
    }

    .crash-mult {
        font-size: 52px;
    }
}

/* Laptop-height windows: smaller games so the upgrades still show. */
@media (max-height: 720px) and (min-width: 781px) {
    .bg-top {
        padding: 4px 16px;
    }

    .bg-goal {
        margin-bottom: 6px;
        padding: 4px 14px;
    }

    .bg-table {
        gap: 7px;
        padding: 10px 14px;
    }

    .bg-table-head p {
        display: none;
    }

    .bg-stage {
        min-height: 130px;
    }

    .coin {
        width: 96px;
        height: 96px;
    }

    .slot-machine {
        --cell: 46px;
    }

    .slot-cell {
        font-size: 28px;
    }

    .wheel-wrap {
        width: 180px;
        padding: 4px 0;
    }

    .plinko-wrap {
        width: min(280px, 100%);
    }

    .mines-grid {
        width: calc(32px * var(--grid, 5));
        gap: 4px;
        padding: 4px 0;
    }

    .crash-mult {
        font-size: 44px;
    }

    .bg-message {
        min-height: 0;
    }

    .bg-games button {
        padding: 5px 12px;
    }

    .bg-panel .bg-buy {
        padding: 6px 12px;
    }

    .bg-side-tabs button {
        padding: 4px 10px;
    }
}

/* Picked during a round; takes over when it ends. */
button.queued {
    border-style: dashed;
    border-color: var(--gold);
}

/*==================================================
    Layer systems: side bets, charms, the floor, fate
==================================================*/

.bg-fine {
    color: var(--muted);
    font-size: 12px;
}

.bg-panel p.bg-fine {
    font-size: 12px;
}

/* This run, under the goal. */
.bg-run {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: -4px max(16px, calc((100% - 1288px) / 2)) 10px;
    font-size: 13px;
    font-weight: 700;
}

.bg-run[hidden] {
    display: none;
}

.bg-run > span,
.bg-run > button {
    padding: 3px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
}

.bg-run .run-fate {
    border-color: rgba(168, 85, 247, 0.45);
    color: #e9d5ff;
}

.bg-run .run-side {
    border-color: rgba(34, 197, 94, 0.45);
    color: #bbf7d0;
}

.bg-run .run-piggy {
    font-size: 13px;
    border-color: rgba(244, 114, 182, 0.5);
}

/* Reset buttons: the reset, and a flip of it. */
.bg-layer-buttons {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

.bg-layer-buttons .bg-layer-button {
    margin-bottom: 0;
}

.bg-flip {
    padding: 5px 12px;
    font-size: 13px;
}

/* Side bets */
.bg-sides {
    display: grid;
    gap: 8px;
}

.side-bet {
    display: grid;
    gap: 4px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-2);
    font-size: 13px;
}

.side-bet b small {
    color: var(--gold);
    font-size: 12px;
}

.side-bet > span {
    color: var(--muted);
}

.side-bet.live {
    border-color: rgba(34, 197, 94, 0.5);
}

.side-bet.live > small {
    color: #bbf7d0;
    font-weight: 800;
}

.side-stakes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.side-stakes button {
    padding: 4px 12px;
    font-size: 13px;
}

/* Scratch cards */
.bg-scratch {
    display: grid;
    grid-template-columns: repeat(3, 56px);
    justify-content: center;
    gap: 6px;
}

.bg-scratch:empty {
    display: none;
}

.scratch-cell {
    display: grid;
    place-items: center;
    height: 56px;
    border-radius: 10px;
    background: #1f2a25;
    font-size: 28px;
    animation: scratch-off 0.35s var(--d) both;
}

.bg-scratch.done .scratch-cell.win {
    background: rgba(251, 191, 36, 0.25);
    outline: 2px solid var(--gold);
}

@keyframes scratch-off {
    from { color: transparent; background: linear-gradient(135deg, #a8a29e, #57534e); transform: scale(0.9); }
}

.bg-panel .bg-scratch-prize {
    margin: 8px 0 0;
    color: var(--gold);
    font-weight: 800;
    text-align: center;
}

.bg-panel .bg-scratch-prize:empty {
    display: none;
}

/* Charms */
.bg-charms {
    display: grid;
    gap: 6px;
}

.charm {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-left-width: 4px;
    border-radius: 12px;
    background: var(--panel-2);
    font-size: 13px;
}

.charm > span {
    grid-row: span 2;
    font-size: 24px;
}

.charm > b small {
    color: var(--muted);
    font-size: 11px;
}

.charm > small {
    grid-column: 2;
    color: var(--muted);
}

.charm > button {
    grid-column: 3;
    grid-row: 1 / span 2;
    padding: 4px 12px;
    font-size: 12px;
}

.charm.r0 { border-left-color: #94a3b8; }
.charm.r1 { border-left-color: #38bdf8; }
.charm.r2 { border-left-color: #c084fc; }

.charm.on {
    background: color-mix(in srgb, var(--gold) 10%, var(--panel-2));
    border-color: rgba(251, 191, 36, 0.45);
}

.charm.locked {
    opacity: 0.5;
}

/* The floor */
.bg-floor {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
}

.floor-table {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 4px 10px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
}

.floor-table select {
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

.floor-edge {
    display: grid;
    font-size: 12px;
    color: var(--muted);
}

.floor-edge b {
    color: var(--text);
}

.floor-edge input {
    width: 100%;
    accent-color: var(--gold);
}

.floor-table > small {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 12px;
}

.bg-build {
    width: 100%;
    margin-bottom: 8px;
    font-size: 14px;
}

.bg-ticker {
    display: grid;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 12px;
    color: var(--muted);
}

.bg-ticker b {
    color: #fca5a5;
}

.bg-panel b.down {
    color: #fca5a5;
}

/* Fate */
.bg-hand {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    margin-bottom: 8px;
}

.fate-card {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 10px 8px;
    border: 1px solid rgba(168, 85, 247, 0.5);
    border-radius: 12px;
    background: linear-gradient(180deg, #2e1065, #1e1b4b);
    font-size: 13px;
    text-align: center;
}

.fate-card > span {
    font-size: 28px;
}

.fate-card > small {
    color: #ddd6fe;
    font-size: 11px;
}

.bg-deck {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bg-deck button {
    padding: 4px 10px;
    font-size: 12px;
    opacity: 0.55;
}

.bg-deck button.active {
    opacity: 1;
}

/* Double or nothing */
.bg-message.double button {
    padding: 5px 14px;
    font-size: 14px;
}

.mine-tile.spotted {
    background: linear-gradient(180deg, #0e7490, #164e63);
}

/* A whale at the door. */
.bg-whale {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 61;
    display: grid;
    gap: 6px;
    width: min(340px, calc(100vw - 32px));
    padding: 12px 14px;
    border: 1px solid rgba(56, 189, 248, 0.6);
    border-radius: 16px;
    background: #0c2233;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    font-size: 13px;
    animation: toast-in 0.3s ease-out;
}

.bg-whale[hidden] {
    display: none;
}

.bg-whale > b {
    font-family: var(--font-display);
    font-size: 16px;
}

.bg-whale > span {
    color: var(--muted);
}

.bg-whale b.up {
    color: #86efac;
}

.bg-whale b.down {
    color: #fca5a5;
}

.bg-whale > div {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bg-whale button {
    padding: 6px 12px;
    font-size: 13px;
}

.bg-whale small {
    margin-left: auto;
    color: var(--muted);
    font-weight: 800;
}

/*==================================================
    The Stable, the Back Room, the Descent
==================================================*/

.bg-panel h3 small {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 700;
}

/* What a layer has won so far. */
.bg-owned {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bg-owned li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    padding: 5px 8px;
    border-radius: 10px;
    background: var(--panel-2);
    font-size: 13px;
}

.bg-owned li > span {
    grid-row: span 2;
    font-size: 20px;
    text-align: center;
}

.bg-owned li small {
    color: var(--muted);
    font-size: 12px;
}

.bg-owned li b small {
    color: var(--gold);
}

.bg-owned li.none {
    opacity: 0.5;
}

.bg-panel p.bg-say {
    margin: 8px 0 0;
    font-size: 13px;
    font-weight: 700;
}

.bg-panel p.bg-say:empty {
    display: none;
}

.bg-panel p.bg-say.good {
    color: #86efac;
}

.bg-panel p.bg-say.bad {
    color: #fca5a5;
}

/* The Stable */
.bg-rider {
    display: grid;
    gap: 6px;
}

.bg-rider label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    color: var(--muted);
}

.bg-panel select {
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

.bg-rider select {
    flex: 1;
}

.bg-tactics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bg-tactics button {
    padding: 4px 10px;
    font-size: 12px;
}

.bg-races,
.bg-horses,
.bg-rivals {
    display: grid;
    gap: 6px;
}

.bg-horses {
    margin-bottom: 8px;
}

.race-row,
.horse,
.rival {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 2px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-2);
    font-size: 13px;
}

.race-row > span {
    grid-row: span 3;
    font-size: 22px;
    text-align: center;
}

.horse > span,
.rival > span {
    grid-row: span 2;
    font-size: 22px;
    text-align: center;
}

.race-row b small,
.horse b small,
.rival b small {
    color: var(--muted);
    font-size: 11px;
}

.race-row > small,
.horse > small,
.rival > small {
    grid-column: 2;
    color: var(--muted);
    font-size: 12px;
}

.race-row > button,
.race-row > .race-done {
    grid-column: 3;
    grid-row: 1 / span 3;
    padding: 4px 10px;
    font-size: 12px;
}

.race-row .race-done {
    color: var(--muted);
    font-weight: 800;
    text-align: right;
}

.race-row.done {
    opacity: 0.6;
}

.horse > div {
    grid-column: 3;
    grid-row: 1 / span 2;
    display: grid;
    gap: 4px;
}

.horse button {
    padding: 3px 10px;
    font-size: 12px;
}

.horse > small b {
    color: var(--text);
}

.horse.on {
    border-color: rgba(251, 191, 36, 0.5);
    background: color-mix(in srgb, var(--gold) 8%, var(--panel-2));
}

.horse.hurt > small {
    color: #fca5a5;
}

.bg-breed {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 6px;
}

.bg-breed[hidden] {
    display: none;
}

.bg-breed > span {
    color: var(--muted);
    font-weight: 800;
}

.bg-breed button {
    grid-column: 1 / -1;
    font-size: 13px;
}

/* A race being run: lanes, right to left to the post. */
.bg-track {
    display: grid;
    gap: 2px;
    margin-top: 8px;
    padding: 6px 8px 6px 14px;
    border-radius: 12px;
    background:
        linear-gradient(90deg, #fff 0 3px, transparent 3px) 8px 0 / 100% 100% no-repeat,
        repeating-linear-gradient(180deg, #3f2a14 0 24px, #4a3218 24px 26px);
}

.bg-track[hidden] {
    display: none;
}

.lane {
    position: relative;
    height: 24px;
}

.lane small {
    position: absolute;
    right: 4px;
    top: 4px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
    font-weight: 800;
}

.lane.you small {
    color: var(--gold);
}

.runner {
    position: absolute;
    top: 0;
    left: calc(100% - 26px);
    font-size: 20px;
    line-height: 24px;
    animation: gallop var(--t) cubic-bezier(0.35, 0.1, 0.4, 1) forwards;
}

.lane.you .runner {
    filter: drop-shadow(0 0 4px var(--gold));
}

@keyframes gallop {
    to { left: 0; }
}

/* The Back Room */
.bg-duel {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 14px;
    background: radial-gradient(circle at 50% 0%, #1d4d36, #0d2a1e);
}

.bg-duel[hidden] {
    display: none;
}

.duel-side {
    display: grid;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
}

.duel-side b {
    color: var(--text);
}

.cards {
    display: flex;
    gap: 6px;
}

.card {
    display: grid;
    place-items: center;
    width: 44px;
    height: 60px;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 17px;
    font-weight: 900;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    animation: deal 0.25s ease-out both;
}

.card.red {
    color: #dc2626;
}

.card.back {
    background: repeating-linear-gradient(45deg, #7f1d1d 0 6px, #991b1b 6px 12px);
    outline: 2px solid #f8fafc;
    outline-offset: -4px;
}

@keyframes deal {
    from { transform: translateY(-8px) rotate(-4deg); opacity: 0; }
}

.duel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.duel-actions button {
    display: grid;
    padding: 5px 14px;
    font-size: 14px;
    line-height: 1.15;
}

.duel-actions button small {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.8;
}

.bg-panel p.duel-say {
    margin: 0;
    font-size: 13px;
    font-weight: 800;
}

.bg-panel p.duel-say.good {
    color: #86efac;
}

.bg-panel p.duel-say.bad {
    color: #fca5a5;
}

.rival > .holdout,
.rival > .side-stakes {
    grid-column: 2 / -1;
}

.holdout {
    height: 6px;
    margin: 3px 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.holdout i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    transition: width 0.4s;
}

.rival .side-stakes button {
    padding: 3px 10px;
    font-size: 12px;
}

.rival.done {
    opacity: 0.6;
}

/* The Descent */
.bg-depth {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 10px;
}

.bg-depth .circle {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 50%;
    background: #1c1210;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.bg-depth .circle.seen {
    border-color: rgba(239, 68, 68, 0.6);
    background: #3b1410;
}

.bg-depth .circle.here {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.7);
}

.bg-dive {
    display: grid;
    gap: 8px;
}

.dive-head {
    font-family: var(--font-display);
    font-size: 16px;
}

.dive-head small {
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 12px;
}

.doors {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.door {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 2px;
    padding: 10px 6px;
    border-color: rgba(239, 68, 68, 0.4);
    border-radius: 14px;
    background: linear-gradient(180deg, #3b1410, #1c0d0b);
    text-align: center;
}

.door > span {
    font-size: 26px;
}

.door b {
    font-size: 13px;
}

.door small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.door small:nth-of-type(1) {
    color: #fdba74;
}

.bg-keeper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 800;
}

.bg-keeper[hidden] {
    display: none;
}

.bg-keeper select {
    flex: 1;
}

.bg-run .run-races {
    font-size: 13px;
    border-color: rgba(251, 191, 36, 0.5);
}

@media (max-width: 640px) {
    .doors {
        grid-template-columns: 1fr;
    }

    .door {
        grid-template-columns: 32px minmax(0, 1fr);
        justify-items: start;
        text-align: left;
    }

    .door > span {
        grid-row: span 3;
    }
}

@media (prefers-reduced-motion: reduce) {
    .runner {
        animation-duration: 0.01s;
    }

    .card {
        animation: none;
    }
}
