/* Local board games share the GameRoom palette and controls. */
.bg-shell { max-width: 1120px; margin: 0 auto; padding: 18px; }
.bg-header, .bg-toolbar, .bg-players { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bg-header h2 { margin: 0; font-size: 1.35rem; }
.bg-kicker { margin: 0 0 4px; color: var(--accent); font-size: .72rem; letter-spacing: .18em; text-transform: uppercase; }
.bg-toolbar { justify-content: flex-start; margin: 20px 0; padding: 14px; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; }
.bg-toolbar label { display: grid; gap: 4px; color: var(--muted); font-size: .8rem; }
.bg-toolbar select { color: var(--text); background: var(--bg3); border: 1px solid var(--border); border-radius: 6px; padding: 8px; font: inherit; }
.bg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 24px; align-items: start; }
.bg-table { min-width: 0; background: radial-gradient(ellipse at center, #203346, var(--bg2) 75%); border: 1px solid var(--border); border-radius: 16px; padding: 18px; overflow: hidden; }
.bg-players { position: relative; z-index: 1; }
.bg-player { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: .85rem; background: var(--bg); }
.bg-player.bg-turn { border-color: var(--accent); box-shadow: 0 0 15px #00b3ff20; }
.bg-disc { width: 13px; height: 13px; border-radius: 50%; background: #f1e5ce; box-shadow: 0 2px 0 #9d8a69; }
.bg-player:last-child .bg-disc { background: #324357; box-shadow: 0 2px 0 #111a24; }
.bg-stage { --tilt: 32deg; --spin: 0deg; --counter: 0deg; perspective: 1100px; padding: 35px 12px 48px; }
.bg-stage.bg-flat { --tilt: 0deg; }
.bg-stage.bg-flipped { --spin: 180deg; --counter: -180deg; }
.bg-platform { position: relative; width: min(88%, 560px); margin: 0 auto; aspect-ratio: 1; transform: rotateX(var(--tilt)) rotateZ(var(--spin)); transform-style: preserve-3d; transition: transform .65s ease; border: 12px solid #79583e; border-radius: 5px; box-shadow: 0 7px 0 #573c2b, 0 14px 0 #392a22, 0 24px 28px #0008; }
.bg-board { display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; height: 100%; }
.bg-cell { position: relative; min-width: 0; padding: 0; border: 0; border-radius: 0; background: #d2bd97; color: #54432e; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.bg-cell.bg-dark { background: #614c3b; color: #e7d5b8; }
.bg-cell.bg-last { box-shadow: inset 0 0 0 3px #e4bc6277; }
.bg-cell.bg-selected { background: #177c9b; box-shadow: inset 0 0 0 3px #7ce1ff; }
.bg-cell.bg-target::after { content: ''; position: absolute; width: 25%; height: 25%; background: #7ee6d0; border: 2px solid #c2fff1; border-radius: 50%; left: 37.5%; top: 37.5%; box-shadow: 0 0 12px #00ffb888; }
.bg-cell.bg-check { background: #ab443b; }
.bg-cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; z-index: 1; }
.bg-coordinate { position: absolute; bottom: 2px; left: 3px; font-size: clamp(7px, 1vw, 10px); opacity: .8; transform: rotate(var(--counter)); }
.bg-pieces { position: absolute; inset: 0; pointer-events: none; transform-style: preserve-3d; }
.bg-piece { position: absolute; left: calc(var(--x) * 12.5%); top: calc(var(--y) * 12.5%); width: 12.5%; height: 12.5%; display: grid; place-items: center; transform: translateZ(8px); transform-style: preserve-3d; }
.bg-piece-body { display: grid; place-items: center; width: 74%; height: 74%; border-radius: 50%; color: #77572e; background: radial-gradient(circle at 36% 25%, #fff4da, #cfb789); border: 3px double #b59b6d; box-shadow: 0 2px 0 #b59b6d, 0 4px 0 #9e8358, 0 6px 0 #876c45, 2px 9px 6px #0008; transform: rotateZ(var(--counter)); font-size: clamp(13px, 3vw, 30px); }
.bg-b .bg-piece-body { color: #b9d0e5; background: radial-gradient(circle at 36% 25%, #526781, #1b2636); border-color: #73869d; box-shadow: 0 2px 0 #273b51, 0 4px 0 #17293b, 0 6px 0 #101a26, 2px 9px 6px #0008; }
.bg-d .bg-piece-body { transform: translateZ(6px) rotateZ(var(--counter)); outline: 2px solid #d5ae58; outline-offset: 2px; }
.bg-chess .bg-piece-body { width: 95%; height: 100%; border: 0; border-radius: 0; background: none; box-shadow: none; color: #f3e5c7; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(24px, 6vw, 57px); line-height: 1; text-shadow: 1px 1px #9b8055, 2px 2px #9b8055, 3px 3px #705737, 4px 7px 4px #0009; transform: rotateZ(var(--counter)) rotateX(calc(0deg - var(--tilt))); transform-origin: center 80%; }
.bg-chess .bg-b .bg-piece-body { color: #34465b; text-shadow: -1px -1px #b1c1d3, 1px 1px #142435, 2px 2px #142435, 3px 3px #101b27, 4px 7px 4px #0009; }
.bg-caption { text-align: center; margin: 0; color: var(--muted); font-size: .8rem; }
.bg-sidebar { display: grid; gap: 16px; }
.bg-panel { padding: 16px; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; }
.bg-panel h3 { margin: 0 0 10px; font-size: 1rem; }
#bg-status { color: var(--text); font-size: 1.1rem; margin: 0 0 8px; }
#bg-hint { color: var(--muted); font-size: .85rem; margin: 0; }
.bg-log { padding-left: 28px; max-height: 220px; overflow-y: auto; margin-bottom: 0; font-family: ui-monospace, monospace; font-size: .85rem; }
.bg-log:empty::after { content: 'La partita inizia dal Bianco.'; color: var(--muted); }
.bg-help { color: var(--muted); font-size: .83rem; }
.bg-help summary { color: var(--text); cursor: pointer; }
.bg-promotion { border: 1px solid var(--accent); padding: 12px; border-radius: 8px; margin-top: 12px; }
.bg-promotion p { margin: 0 0 8px; }
.bg-promotion .btn { margin: 3px; }
@media (max-width: 780px) { .bg-layout { grid-template-columns: 1fr; } .bg-sidebar { grid-template-columns: 1fr 1fr; } .bg-table { padding: 12px; } .bg-stage { padding: 20px 2px 35px; } .bg-log { max-height: 120px; } }
@media (max-width: 420px) { .bg-shell { padding: 10px; } .bg-sidebar { grid-template-columns: 1fr; } .bg-toolbar { gap: 8px; padding: 10px; } .bg-toolbar .btn { padding: 7px 9px; font-size: .8rem; } .bg-platform { border-width: 8px; } }
@media (prefers-reduced-motion: reduce) { .bg-platform { transition: none; } }

.bg-chess .bg-piece-body svg { display: block; width: 100%; height: 100%; fill: currentColor; stroke: #ad9062; stroke-width: 1; stroke-linejoin: round; filter: drop-shadow(1px 2px 0 #806341) drop-shadow(2px 4px 2px #0009); }
.bg-chess .bg-b .bg-piece-body svg { stroke: #8a9eb5; filter: drop-shadow(1px 2px 0 #142435) drop-shadow(2px 4px 2px #0009); }

.bg-chess .bg-piece-body .bg-knight-eye { fill: var(--bg2); stroke: none; }

/* Whole-square highlights belong to the board plane and are occluded by pieces. */
.bg-shell .bg-board .bg-cell.bg-selected { background: #bd861b; box-shadow: inset 0 0 0 4px #fff1a3, inset 0 0 24px #ffe668aa; }
.bg-shell .bg-board .bg-cell.bg-target { background: #237f70; box-shadow: inset 0 0 0 4px #72ffcf, inset 0 0 24px #65ffd677; }
.bg-shell .bg-board .bg-cell.bg-target::after { content: ''; position: absolute; inset: 2px; width: auto; height: auto; border: 2px solid #c2ffeb; border-radius: 1px; background: linear-gradient(135deg, #afffe644, #23bda844); box-shadow: 0 0 8px #65ffd6cc; pointer-events: none; }
.bg-shell .bg-board .bg-cell:focus-visible { outline: 4px solid #fff; outline-offset: -5px; }
@media (hover: hover) { .bg-shell .bg-board .bg-cell:hover { box-shadow: inset 0 0 0 3px #ffffffaa; } }
.bg-stage { position: relative; }

/* Match preparation uses the same three-card shell as Battaglia navale. */
#view-board-games.setup-shell { scroll-margin-top:80px; width:min(1200px,100%); max-width:1200px; box-sizing:border-box; }
#bg-setup label { display:block; margin-bottom:6px; color:var(--muted); font-size:.85rem; }
#bg-setup select,#bg-setup input { color:var(--text); background:var(--bg3); border:1px solid var(--border); border-radius:7px; padding:10px; font:inherit; }
.bg-resume-box { display:grid; gap:12px; border-top:1px solid #34495f; padding-top:14px; margin-top:8px; }
#bg-match-summary { margin:0; margin-right:auto; overflow-wrap:anywhere; }
#bg-play .bg-toolbar { margin-top:0; }
#bg-second-player input { margin-top:0; }
#bg-white-name,#bg-black-name { max-width:150px; overflow-wrap:anywhere; }
#bg-resume-summary { overflow-wrap:anywhere; }

.bg-online-games { margin-top:24px; }
#bg-online-games { display:grid; gap:10px; }
#bg-online-games button { white-space:normal; overflow-wrap:anywhere; text-align:left; }
#bg-online-lobby input { min-width:0; }
#bg-join-form { display:grid; gap:10px; }
#bg-room-players { padding-left:20px; overflow-wrap:anywhere; }

@media (max-width:540px) { #bg-play .setup-footer { flex-wrap:wrap; } #bg-play .setup-footer .btn { flex:1 1 calc(50% - 12px); } }

/* The same Crea/Unisciti tabs, card grid and radio rows as naval battle. */
#bg-setup .home-panel { margin:0; background:none; border:0; overflow:visible; }
#bg-setup .tabs { margin:0 0 18px; border:1px solid #34495f; border-radius:12px; overflow:hidden; }
#bg-setup .tab-pane { padding:0; }
#bg-setup .rules-opt { display:flex; margin:8px 0 0; color:var(--text); }
#bg-setup .rules-opt input { padding:0; }
#bg-find-form { display:grid; gap:12px; }
#bg-online-games button.my-game { width:100%; box-sizing:border-box; font:inherit; }
#bg-online-games .my-game-info { min-width:0; }

#bg-captured { display:grid; gap:16px; max-height:310px; overflow-y:auto; }
.bg-captured-label { margin:0 0 8px; font-size:.82rem; color:var(--muted); }
.bg-trophies { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
.bg-trophy { display:grid; place-items:center; min-width:0; padding:4px; border:1px solid var(--border); border-radius:8px; background:var(--bg3); }
.bg-trophy .bc-avatar { height:76px; }
.bg-trophy-name { font-size:.68rem; text-transform:capitalize; }
.bg-captured-disc { width:34px; height:34px; display:grid; place-items:center; margin:8px; border:3px double #b59b6d; border-radius:50%; background:radial-gradient(circle at 35% 25%,#fff4da,#cfb789); color:#77572e; box-shadow:0 3px #9e8358; }
.bg-captured-b { border-color:#73869d; background:radial-gradient(circle at 35% 25%,#526781,#1b2636); color:#d5ae58; box-shadow:0 3px #101a26; }
#bg-result { width:min(440px,calc(100% - 24px)); max-height:90dvh; overflow:auto; box-sizing:border-box; }
#bg-show-result { margin-top:12px; }
