/*! supertwentyplus licence: (c) 2026 Supertwentyplus Pte. Ltd. All rights reserved. Proprietary, not open source.
   Use only as provided on supertwentyplus.com (free or by subscription, under its Terms). Copying, reuse or hosting elsewhere,
   in whole or in part, needs a written licence: supertwentyplus@gmail.com. See LICENSE.txt at the site root. */
/* Backgammon */
.bg-app { gap: 8px; padding: 10px; }
.bg-top { display: flex; flex-direction: column; gap: 6px; }
.bg-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; background: linear-gradient(100deg, #5E1416 0%, #A3262A 45%, #6B3A1E 100%); color: #fff; box-shadow: inset 0 0 0 2px rgba(201,165,75,.55), 0 3px 0 rgba(43,20,7,.25); }
.bg-title { flex: 1; margin: 0; display: flex; align-items: center; gap: 8px; font: 700 30px/1 var(--font-hand, var(--font-display)); color: #FBEFD0; text-shadow: 2px 2px 0 rgba(43,20,7,.45); letter-spacing: .01em; }
.bg-tdie { font-size: 22px; color: #F3D98A; display: inline-block; animation: bg-wobble 4s ease-in-out infinite; }
.bg-tdie + .bg-tdie, .bg-title .bg-tdie:last-child { animation-delay: -2s; }
@keyframes bg-wobble { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
.bg-score { padding: 4px 10px; border-radius: 999px; background: rgba(255,250,235,.94); color: #3B1A0B; font: 700 13px/1 var(--font-mono); white-space: nowrap; }
.bg-new { min-height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: #F3D98A; color: #3B1A0B; font: 700 13px/1 var(--font-body); cursor: pointer; box-shadow: 0 2px 0 rgba(43,20,7,.4); white-space: nowrap; }
.bg-new:hover { background: #F7E3A6; }
.bg-new:active { transform: translateY(2px); box-shadow: none; }
.bg-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; }
.bg-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.bg-chip { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font: 600 12px/1 var(--font-body); cursor: pointer; }
.bg-chip:hover { border-color: var(--ink); }
.bg-chip[data-mode][aria-pressed="true"] { background: #A3262A; border-color: #A3262A; color: #fff; }

.bg-stage { display: flex; justify-content: center; }
/* Two layers: the wooden board (drawn once) and the checkers, dice and highlights on top */
.bg-board-wrap { position: relative; width: 100%; max-width: 940px; aspect-ratio: 1040 / 680; border-radius: 10px; box-shadow: 0 6px 18px rgba(43,20,7,.35); }
.bg-board-bg, .bg-board { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.bg-board-bg { border-radius: 10px; }
.bg-board { touch-action: none; user-select: none; -webkit-user-select: none; }
.bg-num { font: 700 13px/1 var(--font-mono, monospace); fill: #F3E2B3; text-anchor: middle; dominant-baseline: middle; opacity: .85; }
.bg-tray-label { font: 700 11px/1 var(--font-mono, monospace); fill: #C9A54B; text-anchor: middle; letter-spacing: .1em; opacity: .7; }
.bg-count { font: 700 22px/1 var(--font-mono, monospace); text-anchor: middle; }
.bg-ck { cursor: pointer; }
.bg-ck circle:first-child { filter: drop-shadow(0 2px 1.5px rgba(0,0,0,.45)); }
.is-flying circle:first-child, .is-dragging circle:first-child { filter: drop-shadow(0 8px 6px rgba(0,0,0,.45)); }
.is-dragging { pointer-events: none; }
.bg-can { fill: none; stroke: #F3D98A; stroke-width: 3; stroke-dasharray: 6 5; opacity: .9; pointer-events: none; }
.bg-sel { fill: none; stroke: #FFE27A; stroke-width: 5; pointer-events: none; filter: drop-shadow(0 0 6px #FFE27A); }
.bg-tgt-zone { fill: rgba(255,226,122,.18); stroke: #FFE27A; stroke-width: 2; pointer-events: none; }
.bg-tgt { fill: rgba(255,226,122,.35); stroke: #FFE27A; stroke-width: 3; stroke-dasharray: 7 5; pointer-events: none; }
.bg-die.is-used { opacity: .35; }
.bg-die rect { filter: drop-shadow(0 3px 2px rgba(0,0,0,.45)); }
.bg-die.is-rolling { transform-box: fill-box; }

.bg-controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.bg-pip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px; background: #F6EEDC; color: #3B1A0B; font-size: 12px; font-weight: 600; white-space: nowrap; }
.bg-pip b { font-family: var(--font-mono); }
.bg-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #7A6440; }
.bg-dot.is-a { background: radial-gradient(circle at 35% 30%, #FFFEF7, #CDB98A); }
.bg-dot.is-b { background: radial-gradient(circle at 35% 30%, #5A5550, #0B0908); border-color: #000; }
.bg-msg { margin: 0; text-align: center; font-size: 14px; color: var(--ink); min-height: 20px; }
.bg-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 40px; }
.bg-btn { min-height: 40px; padding: 0 18px; border-radius: 999px; font-size: 14px; }
#bg-roll, #bg-done { background: linear-gradient(180deg, #C2372F, #8E1A1C); border-color: #6E1214; color: #FFF6E2; box-shadow: 0 3px 0 #4A0C0E; }
#bg-roll:hover, #bg-done:hover { background: linear-gradient(180deg, #D2443A, #A0201F); }
#bg-roll:active, #bg-done:active { transform: translateY(2px); box-shadow: 0 1px 0 #4A0C0E; }
.bg-hint { margin: 0; text-align: center; font-size: 12px; }
.bg-link { padding: 0; border: 0; background: none; color: var(--ink-2); font: inherit; text-decoration: underline; cursor: pointer; }
.is-over .bg-board-wrap { animation: bg-cheer .8s ease-in-out 2; }
@keyframes bg-cheer { 50% { transform: scale(1.012); } }
:root[data-theme="dark"] .bg-pip { background: #2A2118; color: #F6EEDC; }

@media (max-width: 560px) {
  .bg-bar { flex-wrap: wrap; gap: 6px; padding: 6px 8px; }
  .bg-title { font-size: 24px; flex: 1 1 auto; }
  .bg-score { font-size: 12px; padding: 4px 8px; }
  .bg-new { min-height: 28px; padding: 0 10px; font-size: 12px; }
  .bg-tdie { display: none; }
  .bg-chip span { display: none; }
  .bg-chip[data-mode] span { display: inline; }
  .bg-controls { grid-template-columns: 1fr 1fr; }
  .bg-msg { grid-column: 1 / -1; order: 3; }
  .bg-pip { justify-self: start; }
  .bg-pip:last-child { justify-self: end; }
  .bg-app { padding: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .bg-tdie, .bg-can, .is-over .bg-board-wrap { animation: none; }
}
/* Full screen: the board takes all the height left over */
.bg-app:fullscreen { background: var(--surface, #fff); padding: 10px 12px; display: flex; flex-direction: column; height: 100vh; overflow: auto; gap: 6px; }
.bg-app:fullscreen > * { flex-shrink: 0; }
.bg-app:fullscreen .bg-stage { flex: 1 1 0; min-height: 0; flex-shrink: 1; align-items: center; }
.bg-app:fullscreen .bg-board-wrap { width: auto; height: 100%; max-width: 100%; max-height: 100%; }
/* v2100: room kept for the score bar while the game draws (no layout shift) */
.bg-bar{min-height:42px}
@media (max-width:479px){.bg-bar{min-height:70px}}
