/* ---------- Backgammon ---------- */
.bgm { gap: .35rem; }

/* player bars */
.bg-bar { flex: none; display: flex; align-items: center; gap: .5rem; padding: .3rem .6rem; border-radius: 14px;
  background: var(--panel); border: 2px solid var(--line); transition: border-color .25s, box-shadow .25s, opacity .3s; min-height: 2.7rem; }
.bg-bar.turn { border-color: #f59e0b; animation: bgbreathe 2s ease-in-out infinite; }
.bg-bar.won { border-color: var(--accent); box-shadow: 0 0 22px var(--accent); }
.bg-bar.lost, .bg-bar.offline { opacity: .6; }
@keyframes bgbreathe { 50% { box-shadow: 0 0 16px #f59e0b88; } }
.bg-av { width: 1.7rem; height: 1.7rem; border-radius: 50%; flex: none; }
.bg-av.w { background: radial-gradient(circle at 35% 30%, #fff, #efe3c8 60%, #c9b48a); box-shadow: inset 0 0 0 2px #b9a173; }
.bg-av.b { background: radial-gradient(circle at 35% 30%, #c0475a, #7d1d2e 60%, #4a0f1b); box-shadow: inset 0 0 0 2px #3a0a14; }
.bg-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.bg-who b { font-family: var(--fun); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-who small { color: var(--muted); font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-score { margin-left: auto; font-family: var(--fun); line-height: 1; white-space: nowrap; }
.bg-score b { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.bg-score small { color: var(--muted); font-size: .8rem; }

/* board */
.bg-wrap { flex: 1; min-height: 0; display: grid; place-items: center; }
.bg-board { width: 100%; height: 100%; max-height: 100%; display: block; touch-action: manipulation;
  filter: drop-shadow(0 12px 22px #000a); }
.bg-frame { fill: #5b3417; stroke: #8a5a2b; stroke-width: .12; }
.bg-felt { fill: #1f4d3a; }
.bg-barstrip { fill: #4a2a12; }
.bg-tray { fill: #2d1a0b; stroke: #7a4d24; stroke-width: .04; transition: fill .2s; }
.bg-tray.target { fill: #4a3410; stroke: #ffc145; stroke-width: .08; animation: traypulse 1s ease-in-out infinite; }
@keyframes traypulse { 50% { fill: #6b4c14; } }
.tri.t1 { fill: #e9d3a6; }
.tri.t2 { fill: #a8432f; }
.tri.recent { filter: brightness(1.25); }
.pnum { font: 600 .28px var(--fun); fill: #e9d3a6aa; text-anchor: middle; pointer-events: none; }

/* checkers */
.ck { stroke-width: .05; transition: filter .2s; }
.ck.w { fill: #f6ecd6; stroke: #9e8457; }
.ck.b { fill: #8e2236; stroke: #3d0914; }
.ck.src { stroke: #ffc145; stroke-width: .1; animation: ckglow 1.3s ease-in-out infinite; }
.ck.sel { stroke: #ffde7a; stroke-width: .14; filter: drop-shadow(0 0 .25px #ffc145) brightness(1.15); }
@keyframes ckglow { 50% { stroke-width: .16; filter: drop-shadow(0 0 .2px #ffc145); } }
.ck.ghost { opacity: .45; stroke: #ffc145; stroke-width: .07; stroke-dasharray: .18 .12; animation: ghost 1s ease-in-out infinite; pointer-events: none; }
.ck.ghost.hitme { stroke: #ff5a4a; opacity: .6; }
@keyframes ghost { 50% { opacity: .75; } }
.ck.slide, .slab.slide { animation: ckslide .34s cubic-bezier(.25, .9, .3, 1.05); }
.ck.hitslide { animation: ckslide .5s .12s cubic-bezier(.3, .7, .3, 1) both; }
@keyframes ckslide { from { transform: translate(calc(var(--dx) * 1px), calc(var(--dy) * 1px)); } }
.slab.w { fill: #f6ecd6; stroke: #9e8457; stroke-width: .03; }
.slab.b { fill: #8e2236; stroke: #3d0914; stroke-width: .03; }
.cnt { font: 700 .4px var(--fun); text-anchor: middle; pointer-events: none; }
.cnt.w { fill: #5b3417; } .cnt.b { fill: #f6ecd6; }

/* cube */
.cube rect { fill: #fffaf0; stroke: #5b3417; stroke-width: .06; }
.cube text { font: 700 .5px var(--fun); fill: #2a1600; text-anchor: middle; }
.cube.offer rect { fill: #ffd36b; animation: cubeoffer .6s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: center; }
@keyframes cubeoffer { to { transform: scale(1.18) rotate(8deg); } }
.cube.dead rect { fill: #cbbfa4; }

/* dice drawn on the board */
.bdie rect { stroke-width: .05; }
.bdie.w rect { fill: #fffdf6; stroke: #b29a70; }
.bdie.w circle { fill: #2b1d10; }
.bdie.b rect { fill: #7d1d2e; stroke: #3a0a14; }
.bdie.b circle { fill: #fdf3dc; }
.bdie > * { transform-box: view-box; }
.bdie.tumble rect, .bdie.tumble circle { animation: bdtumble .24s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes bdtumble { 50% { transform: rotate(180deg) scale(.85); } 100% { transform: rotate(360deg); } }
.bdie.land rect { animation: bdland .4s cubic-bezier(.3, 1.8, .5, 1); transform-box: fill-box; transform-origin: center; }
@keyframes bdland { from { transform: scale(1.35) rotate(-14deg); } }
.bdie.spent { opacity: .32; }
.bdie.stuck { opacity: .5; }
.dleft { font: .32px system-ui, sans-serif; fill: #ffc145; text-anchor: middle; letter-spacing: .05px; }

/* tap zones */
.zone { fill: transparent; }
.bg-board.live .zone { cursor: pointer; }

/* buttons */
.bg-actions .mid { display: flex; gap: .5rem; justify-content: center; flex: 1; min-width: 0; }
.bg-actions .mid button { flex: 1; max-width: 11rem; font-size: 1.05rem; }
.bg-actions .mid button:disabled { opacity: .35; }
.bg-rollbtn { animation: bgready 1.2s ease-in-out infinite; }
@keyframes bgready { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg) translateY(-2px); } }
.bg-pulse { animation: bgpulse 1s ease-in-out infinite; }
@keyframes bgpulse { 50% { box-shadow: 0 3px 0 #b9801a, 0 0 18px #ffc145aa; } }
.bg-dbl { border-color: var(--accent) !important; color: var(--accent); font-family: var(--fun); }
.bg-resign { color: var(--muted); flex: none; }
.bg-resign.armed { color: var(--bad); border-color: var(--bad); }
.bgm .bg-actions { justify-content: space-between; gap: .4rem; }
.statusbar.nudge { animation: bgnudge .4s; }
@keyframes bgnudge { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

@media (prefers-reduced-motion: reduce) {
  .ck.slide, .slab.slide, .ck.hitslide, .bdie.tumble rect, .bdie.tumble circle, .bg-rollbtn, .ck.src, .ck.ghost { animation: none; }
}
