/* v1.1.0 Phase 7 — approved board-master runtime integration. */
[data-board-master="true"]{
  background-color:transparent!important;
  background-image:var(--board-master-image)!important;
  background-repeat:no-repeat!important;
  background-position:center!important;
  background-size:100% 100%!important;
  border-color:transparent!important;
  box-shadow:none!important;
}


/* v1.7.8 Phase 12 — board-ready gate.
   Never paint a stale master or a legacy logical board while the current master
   is still loading. A neutral, non-animated skeleton remains until the asset
   resolves. On a genuine load error, data-board-master-loaded="false" becomes
   ready and the historical logical fallback may render. */
:is([data-board-master="true"],[data-game-zone="board"])[data-board-ready="false"]{
  background-color:#10151c!important;
  background-image:linear-gradient(135deg,rgba(255,255,255,.025),rgba(255,255,255,0) 42%),linear-gradient(90deg,rgba(209,173,104,.055),rgba(255,255,255,.018),rgba(209,173,104,.055))!important;
  border:1px solid rgba(209,173,104,.18)!important;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,.018)!important;
}
:is([data-board-master="true"],[data-game-zone="board"])[data-board-ready="false"]::before,
:is([data-board-master="true"],[data-game-zone="board"])[data-board-ready="false"]::after{content:none!important;display:none!important}
:is([data-board-master="true"],[data-game-zone="board"])[data-board-ready="false"]>*{visibility:hidden!important}
.carre-board[data-board-master="true"][data-board-master-loaded="pending"] .board-lines{opacity:0}

/* Alquerque-family overlays: the approved artwork carries the static network. */
.carre-board[data-board-master="true"]{overflow:visible;border:0!important}

/* v1.3.2 — Alquerque board-master anti-occlusion.
   Legacy material pseudo-layers from apps/alquerque/public/app.css are painted
   above the element background inside the isolated stacking context. When a
   real board master is active they must not exist, otherwise the approved WebP
   is loaded successfully but remains visually hidden. */
.carre-board[data-board-master="true"]::before,
.carre-board[data-board-master="true"]::after{
  content:none!important;
  display:none!important;
  background:none!important;
  box-shadow:none!important;
}

/* If the approved master genuinely fails to load, keep a neutral surface and
   expose the logical SVG network fallback without resurrecting the opaque
   legacy material layers. */
.carre-board[data-board-master="true"][data-board-master-loaded="false"]{
  background-color:#15120d!important;
  background-image:none!important;
  border:1px solid rgba(209,173,104,.34)!important;
}
.carre-board[data-board-master="true"] .board-lines{opacity:.72;pointer-events:none;transition:opacity .12s ease}
.carre-board[data-board-master="true"][data-board-master-loaded="true"] .board-lines{opacity:0}
.carre-board[data-board-master="true"][data-board-master-loaded="false"] .board-lines{opacity:.84}
.carre-board[data-board-master="true"] .node{left:var(--board-anchor-x,var(--master-x,50%));top:var(--board-anchor-y,var(--master-y,50%));z-index:3}
.carre-board[data-board-master="true"] .node[data-player=""]{background:transparent;border-color:transparent;box-shadow:none}
.carre-board[data-board-master="true"] .node[data-player=""][data-legal="true"]{border-color:var(--ag-focus);background:rgba(8,12,16,.16)}
.carre-board[data-board-master="true"] .node[data-player=""][data-hint="true"]{border-color:rgba(229,196,119,.8);background:rgba(229,196,119,.08)}

/* Nim boards are trays/fields; heaps and objects stay live above the master. */
.nim-rows[data-board-master="true"]{position:relative;padding:var(--board-master-pad-y) var(--board-master-inset-x)!important;border:0!important;border-radius:0!important;box-sizing:border-box;background-size:contain!important}
.nim-rows[data-board-master="true"] .nim-row{z-index:2;background:transparent;border-color:transparent;box-shadow:none}
.nim-rows[data-board-master="true"] .nim-row::after{opacity:.2}
.nim-rows[data-board-master="true"] .nim-row[data-selected="true"]{background:rgba(9,13,17,.12);border-color:rgba(233,201,122,.56)}

/* Traditional grid / track boards: artwork supplies material, cells keep interactions only. */
.mancala-board[data-board-master="true"],
.tafl-board[data-board-master="true"],
.ur-board[data-board-master="true"],
.senet-board[data-board-master="true"],
.fanorona-board[data-board-master="true"]{
  box-sizing:border-box;
  aspect-ratio:var(--ag-board-aspect,var(--board-master-aspect))!important;
  padding:var(--board-master-pad-y) var(--board-master-inset-x)!important;
  background-size:100% 100%!important;
}
.mancala-board[data-board-master="true"] .mancala-pit,
.mancala-board[data-board-master="true"] .mancala-store,
.tafl-board[data-board-master="true"] .tafl-cell,
.ur-board[data-board-master="true"] .ur-cell,
.senet-board[data-board-master="true"] .senet-cell,
.fanorona-board[data-board-master="true"] .fan-cell{
  background:transparent!important;
  border-color:transparent!important;
  box-shadow:none;
}

/* Keep semantic/special states readable without repainting the underlying approved board. */
.tafl-board[data-board-master="true"] .tafl-cell.throne,
.tafl-board[data-board-master="true"] .tafl-cell.escape,
.ur-board[data-board-master="true"] .ur-cell.rosette,
.senet-board[data-board-master="true"] .senet-cell.special{background:transparent!important}

.mancala-board[data-board-master="true"] .mancala-pit::before,
.mancala-board[data-board-master="true"] .mancala-store::before,
.tafl-board[data-board-master="true"] .tafl-cell::before,
.ur-board[data-board-master="true"] .ur-cell::before,
.senet-board[data-board-master="true"] .senet-cell::before,
.fanorona-board[data-board-master="true"] .fan-cell::before{opacity:.08}

.mancala-board[data-board-master="true"] .mancala-pit.legal,
.tafl-board[data-board-master="true"] .tafl-cell.legal,
.ur-board[data-board-master="true"] .ur-cell.legal-destination,
.senet-board[data-board-master="true"] .senet-cell.destination,
.fanorona-board[data-board-master="true"] .fan-cell.legal{background:rgba(233,201,122,.06)!important}

/* Oware has no stores; Kalah and Congkak artwork include store cavities. */
.mancala-board[data-board-master="true"] .mancala-store{color:var(--ag-text);text-shadow:0 2px 5px #000}
.mancala-board[data-board-master="true"] .mancala-pit{isolation:isolate}

/* The Ur master already contains its non-rectangular physical shape. */
.ur-board[data-board-master="true"] .ur-cell.off{visibility:hidden}

/* Mobile rotation rules continue to target the same live board wrappers. */
@media(max-width:520px){
  .nim-rows[data-board-master="true"]{padding:calc(var(--board-master-pad-y) * .7) calc(var(--board-master-inset-x) * .7)!important}
  .mancala-board[data-board-master="true"],.tafl-board[data-board-master="true"],.ur-board[data-board-master="true"],.senet-board[data-board-master="true"],.fanorona-board[data-board-master="true"]{background-size:100% 100%!important}
}
@media(prefers-reduced-motion:reduce){[data-board-master="true"]{transition:none!important}}

/* Fanorona masters are node networks: live hit targets sit on intersections, not in cell centres. */
.fanorona-board[data-board-master="true"][data-master-layout="nodes"]{display:block!important;position:relative!important;padding:0!important}
.fanorona-board[data-board-master="true"][data-master-layout="nodes"] .fan-cell{position:absolute!important;transform:translate(-50%,-50%);display:grid;place-items:center;border:0!important;background:transparent!important;overflow:visible}
.fanorona-board[data-board-master="true"][data-master-layout="nodes"] .fan-cell::before{display:none}

/* Oware master has exactly six pits per row and no side stores. */
.mancala-board[data-board-master-variant="oware"]{grid-template-columns:repeat(6,1fr)!important;grid-template-rows:repeat(2,1fr)!important}

/* v1.2.0 Phase 2 — generic calibrated anchors and QA-only geometry overlay. */
.board-calibrated-anchor{
  position:absolute!important;
  left:var(--board-anchor-x)!important;
  top:var(--board-anchor-y)!important;
  transform:translate(-50%,-50%) scale(var(--board-anchor-scale,1));
  transform-origin:center;
}
.board-calibration-debug{
  position:absolute;
  inset:0;
  z-index:90;
  pointer-events:none;
  overflow:visible;
}
.board-calibration-debug-marker{
  position:absolute;
  width:12px;
  height:12px;
  border:1px solid currentColor;
  border-radius:50%;
  transform:translate(-50%,-50%);
  color:#ffd76b;
  background:rgba(8,12,16,.52);
  box-shadow:0 0 0 1px rgba(8,12,16,.88),0 0 10px rgba(255,215,107,.45);
}


/* v1.2.0 Phase 4 — Alquerque/Morris piece calibration.
   The button is the pointer target; .node-piece is the visible object. Anchor
   position never changes on hover/selection, so interaction cannot de-centre a piece. */
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node{
  width:clamp(var(--board-hit-target-min,32px),var(--board-hit-target-pct,8%),var(--board-hit-target-max,56px));
  aspect-ratio:1;
  border:0!important;
  background:transparent!important;
  box-shadow:none!important;
  filter:none;
  transform:translate(-50%,-50%)!important;
  overflow:visible;
}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node::after{display:none!important}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node-piece{
  --board-piece-state-scale:1;
  position:absolute;
  left:calc(50% + var(--board-piece-offset-x,0%));
  top:calc(50% + var(--board-piece-offset-y,0%));
  width:var(--board-piece-ratio,88%);
  aspect-ratio:1;
  border-radius:50%;
  pointer-events:none;
  opacity:0;
  transform:translate(-50%,-50%) scale(var(--board-piece-depth-scale,1)) scale(var(--board-piece-state-scale));
  transform-origin:center;
  transition:transform .13s ease,filter .13s ease,box-shadow .13s ease,border-color .13s ease;
}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-player="player-1"] .node-piece{
  opacity:1;border:1.5px solid rgba(124,180,209,.56);background:radial-gradient(circle at 32% 27%,#7895a8,#425e78 42%,#233849 82%);
  box-shadow:inset 0 2px 5px rgba(255,255,255,.08),inset 0 -5px 9px rgba(0,0,0,.42),0 5px 9px rgba(0,0,0,.36);
}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-player="player-2"] .node-piece{
  opacity:1;border:1.5px solid rgba(214,130,103,.56);background:radial-gradient(circle at 32% 27%,#b77b69,#874d3f 42%,#4b2821 82%);
  box-shadow:inset 0 2px 5px rgba(255,255,255,.08),inset 0 -5px 9px rgba(0,0,0,.44),0 5px 9px rgba(0,0,0,.36);
}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-selected="true"] .node-piece{
  --board-piece-state-scale:1.08;
  box-shadow:0 0 0 3px rgba(233,201,122,.84),0 0 22px rgba(233,201,122,.22),inset 0 -5px 9px rgba(0,0,0,.3);
}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-legal="true"][data-player=""]::before,
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-hint="true"][data-player=""]::before{
  content:"";position:absolute;left:50%;top:50%;width:42%;aspect-ratio:1;border-radius:50%;transform:translate(-50%,-50%);
  border:2px solid rgba(239,210,139,.72);background:rgba(8,12,16,.12);box-shadow:0 0 12px rgba(239,210,139,.16);pointer-events:none;
}
@media(hover:hover){
  .carre-board[data-board-master="true"][data-piece-calibrated="true"] .node:not(:disabled):hover .node-piece{--board-piece-state-scale:1.045;filter:brightness(1.11) var(--ag-piece-cast-shadow)}
  .carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-selected="true"]:not(:disabled):hover .node-piece{--board-piece-state-scale:1.08}
}
@media(prefers-reduced-motion:reduce){.carre-board[data-piece-calibrated="true"] .node-piece{transition:none!important}}


/* v1.2.0 Phase 12B — validated line-game object artwork.
   The node remains the hit target; the image layer is decorative and never
   changes the calibrated anchor or Phase 4 depth scaling. */
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-player="player-1"] .node-piece[data-object-id="line.p1"],
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-player="player-2"] .node-piece[data-object-id="line.p2"]{
  border:0;
  background-color:transparent;
  background-position:center;
  background-repeat:no-repeat;
  background-size:contain;
  box-shadow:none;
  filter:var(--ag-piece-cast-shadow);
}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-player="player-1"] .node-piece[data-object-id="line.p1"]{background-image:var(--ag-object-line-p1)}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-player="player-2"] .node-piece[data-object-id="line.p2"]{background-image:var(--ag-object-line-p2)}
.carre-board[data-board-master="true"][data-piece-calibrated="true"] .node[data-selected="true"] .node-piece[data-object-id]{
  box-shadow:0 0 0 3px rgba(233,201,122,.84),0 0 22px rgba(233,201,122,.22);
}
