/* ===================== Buffalo Cart Race ===================== */
.br-wrap {
    --br-accent: hsl(var(--base, 42 100% 52%));
    --br-card: rgba(255, 255, 255, 0.04);
    --br-line: rgba(255, 255, 255, 0.1);
    --br-text: #f3f3f3;
    --br-muted: rgba(255, 255, 255, 0.62);
    color: var(--br-text);
}
.br-wrap * { box-sizing: border-box; }

/* ---------- layout ---------- */
.br-grid { display: grid; gap: 16px; grid-template-columns: 1fr; grid-template-areas: "stage" "bet" "info"; }
.br-area-stage { grid-area: stage; }
.br-area-bet { grid-area: bet; }
.br-area-info { grid-area: info; }
@media (min-width: 768px) {
    .br-grid { grid-template-columns: minmax(300px, 400px) 1fr; grid-template-areas: "stage bet" "info info"; }
}
@media (min-width: 1200px) {
    .br-grid { grid-template-columns: minmax(330px, 420px) 1fr 370px; grid-template-areas: "stage info bet"; align-items: start; }
}

/* ---------- race stage (portrait drone footage) ---------- */
.brv-stage {
    position: relative; width: 100%; max-width: calc(80vh * 9 / 16); margin: 0 auto; aspect-ratio: 9 / 16;
    border-radius: 14px; overflow: hidden; background: #7a4a30 center/cover no-repeat;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .45); border: 1px solid var(--br-line);
}
.brv-stage canvas { pointer-events: none; }
.brv-hud { position: absolute; inset: 0; pointer-events: none; font-family: inherit; color: #fff; }
.brv-top { position: absolute; left: 8px; right: 52px; top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.brv-race { font-size: 12px; font-weight: 800; letter-spacing: 1px; background: rgba(0, 0, 0, .5); padding: 4px 9px; border-radius: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brv-pill { font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 20px; letter-spacing: 1px; white-space: nowrap; }
.brv-pill.live { background: #dc2626; animation: brBlink 1.2s infinite; }
.brv-pill.fin { background: #16a34a; }
.brv-pill.replay { background: #6366f1; }
.brv-pill.slow { background: #f59e0b; color: #111; }
.brv-progress { position: absolute; left: 8px; right: 8px; top: 40px; }
.brv-bar { height: 6px; border-radius: 6px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.brv-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #fbbf24, #ef4444); }
.brv-dist { font-size: 11px; font-weight: 700; margin-top: 3px; text-shadow: 0 1px 3px rgba(0, 0, 0, .9); }
.brv-lead { position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%); background: rgba(0, 0, 0, .58); padding: 5px 12px; border-radius: 20px; font-size: 12px; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.brv-tag { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 11px; font-weight: 700; background: rgba(0, 0, 0, .55); padding: 2px 8px 2px 5px; border-radius: 20px; display: flex; align-items: center; gap: 4px; will-change: transform; }
.brv-dot, .br3d-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .85); flex: none; vertical-align: middle; }
.brv-center {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; width: 86%;
    background: rgba(8, 10, 18, .7); padding: 14px 16px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .16); backdrop-filter: blur(3px);
}
.brv-center.mini { top: 70px; transform: translateX(-50%); padding: 8px 12px; }
.brv-center.win { border-color: #fbbf24; box-shadow: 0 0 30px rgba(251, 191, 36, .35); }
.brv-center .t1 { font-size: 12px; text-transform: uppercase; letter-spacing: 2px; opacity: .85; }
.brv-center .t2 { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.brv-center.win .t2 { color: #fde047; }
.brv-center .t3 { font-size: 12px; opacity: .85; margin-top: 2px; }
.brv-sound {
    position: absolute; right: 8px; top: 6px; z-index: 3; width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .4);
    background: rgba(0, 0, 0, .55); color: #fff; font-size: 18px; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.brv-sound.off { color: #f87171; }

/* ---------- panels ---------- */
.br-card { background: var(--br-card); border: 1px solid var(--br-line); border-radius: 14px; padding: 16px; }
.br-card + .br-card, .br-slots + .br-card { margin-top: 16px; }
.br-card h6 { color: var(--br-text); font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.br-card h6.br-gap { margin-top: 18px; }
.br-muted { color: var(--br-muted); }

.br-rule {
    display: flex; gap: 12px; align-items: flex-start; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
    background: linear-gradient(90deg, rgba(251, 191, 36, .16), rgba(239, 68, 68, .12)); border: 1px solid rgba(251, 191, 36, .45);
}
.br-rule i { font-size: 22px; color: #fbbf24; margin-top: 2px; }
.br-rule b { color: #fde047; }

.br-statusbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.br-statusbar .ttl { font-size: 18px; font-weight: 700; }
.br-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 30px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.br-pill.betting { background: rgba(34, 197, 94, .18); color: #4ade80; }
.br-pill.closed { background: rgba(251, 191, 36, .2); color: #fde047; }
.br-pill.waiting { background: rgba(239, 68, 68, .18); color: #f87171; }
.br-pill.racing { background: rgba(99, 102, 241, .25); color: #a5b4fc; }
.br-pill .blink { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: brBlink 1s infinite; }
@keyframes brBlink { 50% { opacity: .3; } }
.br-count { font-variant-numeric: tabular-nums; font-weight: 700; }

.br-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.br-slot { border: 1px solid var(--br-line); border-radius: 10px; padding: 8px 6px; text-align: center; background: rgba(255, 255, 255, .02); }
.br-slot.current { border-color: var(--br-accent); box-shadow: 0 0 0 1px var(--br-accent) inset; }
.br-slot .s1 { font-weight: 800; font-size: 16px; }
.br-slot .s2 { font-size: 11px; color: var(--br-muted); }
.br-slot .s3 { font-size: 12px; margin-top: 3px; }

.br-carts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 10px; padding-top: 4px; }
.br-cart {
    position: relative; cursor: pointer; border: 2px solid var(--br-line); border-radius: 12px; padding: 10px 12px; background: rgba(255, 255, 255, .03);
    transition: .15s; display: block; margin: 0; color: var(--br-text);
}
.br-cart:hover { border-color: rgba(255, 255, 255, .3); }
.br-cart input { position: absolute; opacity: 0; pointer-events: none; }
.br-cart.active { border-color: var(--cc); background: color-mix(in srgb, var(--cc) 16%, transparent); }
.br-cart .cn { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.br-cart .cl { font-size: 11px; color: var(--br-muted); font-weight: 500; }
.br-cart .cp { font-size: 12px; color: var(--br-muted); margin-top: 4px; }
.br-cart .cp b { color: var(--br-text); }
.br-cart .low { position: absolute; top: -9px; right: 8px; font-size: 10px; background: #fbbf24; color: #111; border-radius: 10px; padding: 1px 7px; font-weight: 800; }
.br-cart .mine { font-size: 11px; color: #fde047; margin-top: 2px; }
.br-cart.disabled { opacity: .55; cursor: not-allowed; }

.br-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.br-chip { border: 1px solid var(--br-line); background: rgba(255, 255, 255, .04); color: var(--br-text); border-radius: 20px; padding: 3px 12px; font-size: 12px; cursor: pointer; }
.br-chip:hover { border-color: var(--br-accent); }
.br-amount { display: flex; border: 1px solid var(--br-line); border-radius: 10px; overflow: hidden; background: rgba(0, 0, 0, .25); }
.br-amount span { padding: 10px 12px; color: var(--br-muted); border-right: 1px solid var(--br-line); }
.br-amount input { flex: 1; min-width: 0; background: transparent; border: 0; color: var(--br-text); padding: 10px 12px; font-size: 16px; outline: none; }
.br-payout { display: flex; justify-content: space-between; font-size: 13px; margin: 10px 0 12px; color: var(--br-muted); }
.br-payout b { color: #4ade80; }
.br-bal { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.br-bal .v { font-size: 20px; font-weight: 800; }

.br-list { list-style: none; margin: 0; padding: 0; }
.br-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px dashed var(--br-line); font-size: 13px; }
.br-list li:last-child { border-bottom: 0; }
.br-tagw { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.br-tagw.w { background: rgba(34, 197, 94, .2); color: #4ade80; }
.br-tagw.l { background: rgba(239, 68, 68, .2); color: #f87171; }
.br-tagw.p { background: rgba(255, 255, 255, .1); color: var(--br-muted); }
.br-btn-replay { background: rgba(255, 255, 255, .08); border: 1px solid var(--br-line); color: var(--br-text); border-radius: 8px; padding: 4px 10px; font-size: 12px; }
.br-btn-replay:hover { border-color: var(--br-accent); }
.br-empty { color: var(--br-muted); font-size: 13px; text-align: center; padding: 8px 0; }
.br-demo-badge { background: #6366f1; color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 700; }
#brBetBtn[disabled] { opacity: .5; cursor: not-allowed; }

@media (max-width: 575px) {
    .br-carts { gap: 14px 8px; }
    .br-cart { padding: 9px 9px; }
    .br-cart .cn { font-size: 15px; flex-wrap: wrap; gap: 4px 6px; }
    .brv-race { font-size: 10px; }
    .brv-tag { font-size: 10px; }
}
