/* Bar dice in the minigames sheet (minigames/dice): the bar mat, the dice
   (SVG from dice/draw.rs), Roll and Stand. The plates, status line and
   buttons wear pool.css's. Theme tokens only. */

.dice-felt { position: relative; flex: 1; min-height: 150px; display: grid; place-items: center; overflow: hidden; }
.dice-mat { --die: clamp(44px, 8vmin, 76px); width: min(100%, 760px); height: 100%; max-height: 430px; display: grid; grid-template-rows: auto 1fr auto; align-items: center; gap: 10px; padding: 18px 20px 12px; border: 1px solid var(--rule-2); border-radius: 10px; background: var(--well); outline: 1px dashed var(--rule-2); outline-offset: -8px; }

/* Ship, captain, crew: their slots, in order. */
.dice-crew { display: flex; justify-content: center; gap: clamp(12px, 3vw, 28px); }
.dice-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dice-slot > span { font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); }
.dice-slot.set > span { color: var(--ink); }
.dice-hole { width: calc(var(--die) + 10px); height: calc(var(--die) + 10px); display: grid; place-items: center; border-radius: 14px; border: 1px dashed var(--rule-2); background: var(--paper); }
.dice-slot.set .dice-hole { border-style: solid; border-color: var(--rule); }

/* A die: cream face, ink edge and pips. */
.die { width: var(--die); height: var(--die); flex: none; transform: translateY(var(--dy, 0px)) rotate(var(--rot, 0deg)); }
.die svg { display: block; width: 100%; height: 100%; overflow: visible; }
.die-face { fill: var(--panel); stroke: var(--ink); stroke-width: 2.5; }
.die-edge { fill: var(--ink); }
.pip { fill: var(--ink); }
.die.ghost { opacity: .16; }
.die.ghost .die-edge { display: none; }
.die.ghost .die-face { stroke-dasharray: 5 4; }
.die.cup { opacity: .4; }
.die.idle { opacity: .5; }
.dice-loose { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: clamp(10px, 2.4vw, 26px); min-height: calc(var(--die) + 24px); }

/* The cargo: tap to keep a die off the next roll. */
button.die { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 12px; transition: transform .12s ease-out; }
button.die:focus-visible { outline: 2px solid var(--sig); outline-offset: 3px; }
.die.cargo.kept { transform: translateY(calc(var(--dy, 0px) - 8px)) rotate(0deg); }
.die.cargo.kept .die-face { stroke: var(--sig); stroke-width: 4; }
.dice-keep { position: absolute; left: 50%; bottom: -20px; transform: translateX(-50%); font: 700 10px var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 1px 6px; border-radius: 999px; background: var(--sig); color: var(--on-sig); visibility: hidden; }
.die.kept .dice-keep { visibility: visible; }

.dice-cap { display: flex; justify-content: center; align-items: baseline; gap: 10px; min-height: 30px; }
.dice-who { font: 600 11px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--mute); max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dice-cap b { font: 800 24px var(--font); color: var(--ink); }
.dice-cap b.none { font-size: 18px; color: var(--err); }

/* The roll: shaken in the cup, thrown onto the mat, the crew clicking in. */
.die.shake { animation: dice-shake .11s linear infinite alternate; animation-delay: var(--dl, 0ms); }
@keyframes dice-shake {
  0% { transform: translate(-3px, 1px) rotate(-9deg); }
  50% { transform: translate(3px, -2px) rotate(8deg); }
  100% { transform: translate(-1px, 2px) rotate(-3deg); }
}
.die.tumble { animation: dice-tumble .68s cubic-bezier(.22, .8, .3, 1) both; animation-delay: var(--dl, 0ms); }
@keyframes dice-tumble {
  0% { opacity: 0; transform: translate(calc(var(--die) * -4), calc(var(--die) * -1.3)) rotate(-560deg) scale(.86); }
  12% { opacity: 1; }
  58% { transform: translate(calc(var(--die) * .22), calc(var(--dy, 0px) - 4px)) rotate(calc(var(--rot, 0deg) + 34deg)) scale(1); }
  80% { transform: translate(calc(var(--die) * -.06), var(--dy, 0px)) rotate(calc(var(--rot, 0deg) - 7deg)); }
  100% { transform: translate(0, var(--dy, 0px)) rotate(var(--rot, 0deg)); }
}
.die.fresh { animation: dice-in .24s ease-out both; }
@keyframes dice-in { from { transform: translateY(-16px) scale(1.14); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .die.shake, .die.tumble, .die.fresh { animation: none; } }

/* Roll and Stand, with the rolls used. */
.dice-ctl { flex: none; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; }
.dice-ctl[hidden] { display: none; }
.dice-ctl.idle { visibility: hidden; }
.dice-ctl .btn { display: inline-flex; align-items: center; gap: 6px; }
.dice-roll { min-width: 128px; justify-content: center; }
.dice-left { display: inline-flex; gap: 5px; margin-right: 6px; }
.dice-left i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink); }
.dice-left i.used { background: var(--ink); }

/* The picker: the game, its rules, the players. Mexico has nothing to set
   aside, Threes five places. */
.dice-pick { flex-direction: column; align-items: stretch; gap: 8px; }
.dice-pick .btn { align-self: flex-end; }
.dice-pick [data-mg="kind"] { max-width: none; }
.dice-rule { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ink-2); max-width: 72ch; }
.pool-acts > .dice-rule { align-self: center; text-align: center; }
.dice-mat.k-mexico { grid-template-rows: 1fr auto; }
.dice-mat.k-mexico .dice-crew { display: none; }
.dice-mat.k-threes .dice-crew { gap: clamp(6px, 1.6vw, 16px); }

/* Up to five plates in a row: names give way first. */
.dice-plates .pool-plate { flex-wrap: nowrap; }
.dice-plates .pool-plate b { flex: 0 1 auto; min-width: 0; }
.pool-plate.out { opacity: .5; }

@media (max-width: 640px) {
  .dice-mat { --die: 42px; padding: 12px 10px 8px; gap: 8px; }
  .dice-plates { flex-wrap: wrap; }
  .dice-plates .pool-plate { flex: 1 1 40%; }
}
