/* The dice of Backgammon, Ludo and Snakes and Ladders (and of the shop): a solid die that shared/dice.js (buildDie) makes
   out of 26 flat pieces, lit one by one, with its shadow on the table. A die's look sets data-kind, data-pips and its
   colours (--a, --b: the faces; --e1, --e2: the edges; --pip, --one; --t1…--t4: pattern tints); this sheet paints them. */
.die[data-look][data-kind] { background: none; }
.die .toss, .die .cube { position: absolute; inset: 0; display: block; transform-style: preserve-3d; }
.die .cube { transform: translateZ(calc(var(--die) / -2)); }

/* The pieces: each is the die's size, laid in place by its own transform, and shows only its outer side. */
.die .piece { position: absolute; left: 0; top: 0; width: var(--die); height: var(--die); transform-origin: 0 0; backface-visibility: hidden; }
/* The light (shared/dice.js light): --shade darkens a piece turned away from it, --shine is the polish catching it. */
.die .piece::after { content: ""; position: absolute; inset: 0; --glint: color-mix(in srgb, var(--e1) 35%, white); background: linear-gradient(color-mix(in srgb, var(--glint) calc(var(--shine, 0) * 100%), transparent), color-mix(in srgb, var(--glint) calc(var(--shine, 0) * 100%), transparent)), rgb(0 0 0 / var(--shade, 0)); }
.die .corner { clip-path: polygon(0 0, 100% 0, 0 100%); }
.die .face { background: radial-gradient(circle at 30% 24%, rgb(255 255 255 / .34), rgb(255 255 255 / 0) 52%), linear-gradient(145deg, var(--a), var(--b)); }
/* An edge is rounded in look: the colour of the faces where it meets them, and its crest catching the light. */
.die .bevel { background: linear-gradient(var(--e2), var(--e1) 46%, var(--e1) 54%, var(--e2)); }
.die .corner { background: linear-gradient(135deg, var(--e1), var(--e2)); }
.die .face svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

/* Pips: engraved ones have a lighter lip under the hole and a faint sheen inside it; metal ones are gold; glowing ones shine. */
.die .pip { fill: var(--pip); }
.die .one { fill: var(--one, var(--pip)); }
.die .lip { fill: color-mix(in srgb, var(--a) 45%, white); opacity: .8; }
.die .hollow { fill: rgb(255 255 255 / .09); }
.die[data-pips=metal] :is(.pip, .one) { fill: url(#gk-die-gold); }
.die[data-pips=metal] .lip { fill: rgb(0 0 0 / .35); }
.die[data-pips=glow] .face svg { filter: drop-shadow(0 0 calc(var(--die) * .05) var(--glow)); }

/* Glass: see-through faces and thin, bright edges; the far side's pips only faintly show through. */
.die[data-kind=glass] .piece { backface-visibility: visible; }
.die[data-kind=glass] .face { background: radial-gradient(circle at 30% 24%, rgb(255 255 255 / .3), rgb(255 255 255 / 0) 46%), linear-gradient(155deg, color-mix(in srgb, var(--a) 72%, transparent), color-mix(in srgb, var(--b) 60%, transparent)); }
.die[data-kind=glass] :is(.bevel, .corner) { background: color-mix(in srgb, var(--e1) 70%, transparent); }
.die[data-kind=glass] .face svg { opacity: calc(.14 + .86 * var(--front, 1)); }
/* Pearl: a soft rainbow sheen over pearly white, well rounded. */
.die[data-kind=pearl] .face { background: radial-gradient(circle at 28% 20%, rgb(255 255 255 / .95), rgb(255 255 255 / 0) 40%), radial-gradient(circle at 76% 80%, color-mix(in srgb, var(--t1) 80%, transparent), transparent 52%), conic-gradient(from 200deg at 62% 60%, var(--a), var(--t1), var(--t2), var(--t3), var(--t4), var(--a)); }
/* Walnut: grain on the faces and running along the edges; pips printed on the wood. */
.die[data-kind=wood] .face { background: radial-gradient(circle at 30% 24%, rgb(255 236 200 / .26), transparent 55%), repeating-linear-gradient(97deg, var(--t1) 0 2.5%, var(--t2) 2.5% 6%, var(--t3) 6% 8%, var(--t4) 8% 12%); }
.die[data-kind=wood] .bevel { background: repeating-linear-gradient(90deg, var(--t2) 0 4%, var(--t4) 4% 9%, var(--t3) 9% 11%); }
.die[data-kind=wood] .pip { opacity: .88; }
/* Marble: swirled stone. */
.die[data-kind=marble] .face { background: radial-gradient(circle at 26% 20%, rgb(255 255 255 / .4), transparent 34%), radial-gradient(ellipse at 72% 78%, var(--b), transparent 60%), conic-gradient(from 30deg at 45% 55%, var(--a), var(--t2), var(--t1), var(--t2), var(--t3), var(--b), var(--a)); }
/* Neon: dark glass with lit edges. */
.die[data-kind=neon] .face { background: radial-gradient(circle at 30% 24%, var(--a), var(--b) 72%); }

/* The shadow on the table (shared/dice.js cast): --lift is how high the die is, --yaw how it is turned. */
.die .shade { position: absolute; inset: 0; pointer-events: none; --lift: 0; --yaw: 0rad; }
.die .shade::before, .die .shade::after { content: ""; position: absolute; border-radius: 24%; rotate: var(--yaw); }
/* Where it touches: tight and dark, gone once it is off the table. */
.die .shade::before { inset: 9%; background: rgb(0 0 0 / .62); filter: blur(calc(var(--die) * .025)); opacity: calc(1 - var(--lift) * 1.7); }
/* Cast away from the light: soft, and longer, larger and fainter the higher the die is. */
.die .shade::after { inset: 5%; background: rgb(0 0 0 / .4); filter: blur(calc(var(--die) * (.05 + .06 * var(--lift)))); translate: calc(var(--die) * (.08 + .3 * var(--lift))) calc(var(--die) * (.11 + .42 * var(--lift))); scale: calc(1 + .22 * var(--lift)); opacity: calc(.95 - .16 * var(--lift)); }
/* The result glow: once the dice have stopped, a warm light under them. */
.die.lit:not(.used) .shade::before { inset: -10%; background: radial-gradient(closest-side, rgb(255 214 106 / .8), rgb(255 184 74 / .35) 55%, transparent); filter: blur(calc(var(--die) * .06)); opacity: 1; transition: opacity .3s; }

/* A throw's effects (shared/dice.js): dust where a die first lands, a small shake of the board, and the cup. */
.gk-dust { position: absolute; z-index: 1; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; pointer-events: none; --dust: rgb(255 246 221);
  background: radial-gradient(circle, transparent 38%, color-mix(in srgb, var(--dust) 50%, transparent) 50%, transparent 64%), radial-gradient(circle at 20% 30%, var(--dust) 0 2px, transparent 3px), radial-gradient(circle at 78% 26%, var(--dust) 0 2px, transparent 3px), radial-gradient(circle at 70% 80%, var(--dust) 0 2px, transparent 3px), radial-gradient(circle at 26% 74%, var(--dust) 0 1.5px, transparent 3px);
  animation: gk-dust .55s ease-out forwards; }
@keyframes gk-dust { from { opacity: .85; scale: .35; } to { opacity: 0; scale: 1.35; } }
.gk-thud { animation: gk-thud .2s ease-out; }
@keyframes gk-thud { 25% { translate: 0 3px; } 55% { translate: 0 -1px; } }
.gk-cup { position: fixed; z-index: calc(var(--gk-z-bar) - 2); width: var(--cup); height: calc(var(--cup) * 1.2); margin: calc(var(--cup) * -.6) 0 0 calc(var(--cup) * -.5); pointer-events: none; transform-origin: 50% 80%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 92 110'%3E%3Cdefs%3E%3ClinearGradient id='l' x1='0' x2='1'%3E%3Cstop offset='0' stop-color='%23401f0d'/%3E%3Cstop offset='.45' stop-color='%23874a22'/%3E%3Cstop offset='1' stop-color='%232e1608'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath d='M14 14h64l-8 88H22z' fill='url(%23l)'/%3E%3Cpath d='M22 102h48' stroke='%23d9a934' stroke-width='5' stroke-linecap='round'/%3E%3Cellipse cx='46' cy='14' rx='34' ry='9' fill='%231a0b03' stroke='%23d9a934' stroke-width='4'/%3E%3Cpath d='M30 40h32M28 64h36' stroke='%23d9a93466' stroke-width='2'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 10px 12px rgb(0 0 0 / .55)); animation: gk-cup-shake .72s ease-in-out; }
.gk-cup.pour { animation: none; rotate: var(--tip); opacity: 0; transition: rotate .22s ease-in, opacity .3s .3s; }
@keyframes gk-cup-shake { 0%, 100% { rotate: 0deg; translate: 0 0; } 15% { rotate: -14deg; translate: -4px -6px; } 30% { rotate: 12deg; translate: 3px 2px; } 45% { rotate: -12deg; translate: -3px -5px; } 60% { rotate: 13deg; translate: 3px 3px; } 75% { rotate: -10deg; translate: -2px -4px; } 90% { rotate: 6deg; } }

/* The row of a turn's dice beside the big die (Ludo, Snakes and Ladders; shared/dice.js diceRow): kept until they are
   played (a six is rolled again first). The player chooses which die to play: in Ludo by tapping a token, then (when two
   numbers could move it) a die, or a die first; in Snakes and Ladders by tapping the die to walk. Dice waiting to be
   chosen (.pick) bob and glow. A used die fades with a tick; three sixes are struck through, the turn lost. The dice of
   the turn just ended stay, dimmed. */
.dice-row { display: flex; gap: 2px; min-height: 44px; margin-bottom: 2px; }
.mini-die { position: relative; width: 44px; height: 44px; padding: 5px; border: 0; border-radius: var(--gk-r-sm); background: none; cursor: pointer; }
.mini-die svg { display: block; width: 100%; height: 100%; filter: drop-shadow(var(--gk-shadow-1)); }
.mini-die .body { fill: var(--gk-white); stroke: var(--player-color, var(--gk-gold)); stroke-width: 3; }
.mini-die .pip { fill: var(--gk-night); }
.mini-die:disabled { cursor: default; opacity: 1; }
.mini-die.chosen { box-shadow: 0 0 0 3px var(--gk-gold); }
.dice-row.pick .mini-die:not(:disabled) { box-shadow: 0 0 0 3px var(--gk-gold); animation: mini-die-pick .5s ease-in-out infinite alternate; }
@keyframes mini-die-pick { to { translate: 0 -5px; } }
.mini-die.used svg { opacity: .38; }
.mini-die.used::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--gk-good); font: var(--gk-bold) var(--gk-text-lg) var(--gk-font); }
.mini-die.lost::after { content: ""; position: absolute; left: 6px; right: 6px; top: 50%; height: 4px; margin-top: -2px; border-radius: 2px; background: var(--gk-bad); rotate: -35deg; }
.dice-row.old .mini-die svg { opacity: .55; }
html.gk-empty .dice-row { visibility: hidden; }
