/* =============================================================
   GAME: Pig
   ============================================================= */
.board-pig {
  --pg-glow: #ff9bd2;
  --pg-rgb: 255, 155, 210;
  width: min(calc(100vw - 44px), 520px);
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
}

/* ----- player cards with a race track to 100 ----- */
.pg-players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pg-card {
  --pc: var(--p1);
  min-width: 0; padding: 10px 12px 12px; border-radius: 14px; background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .2s, transform .2s;
}
.pg-card.p2 { --pc: var(--p2); }
.pg-card.cur { box-shadow: inset 0 0 0 2px var(--pc), 0 0 18px color-mix(in srgb, var(--pc) 35%, transparent); }
.pg-cardtop { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pg-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; font-size: .92rem; color: var(--muted); }
.pg-card.cur .pg-name { color: var(--ink); }
.pg-score { font: 900 1.8rem/1 var(--font-body); color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 0 12px color-mix(in srgb, var(--pc) 60%, transparent); }
.pg-track { position: relative; height: 12px; margin: 14px 14px 6px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .5); }
.pg-fill, .pg-ghost { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 6px; transition: width .6s ease; }
.pg-fill { background: linear-gradient(90deg, color-mix(in srgb, var(--pc) 55%, #000), var(--pc)); box-shadow: 0 0 10px color-mix(in srgb, var(--pc) 60%, transparent); }
.pg-ghost { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--pc) 45%, transparent) 0 5px, transparent 5px 9px); }
.pg-flag {
  position: absolute; right: -6px; top: -9px; width: 12px; height: 30px; border-radius: 2px;
  background: linear-gradient(#fff 0 0) left / 2px 100% no-repeat, conic-gradient(#fff 25%, #222 0 50%, #fff 0 75%, #222 0) 2px 0 / 10px 10px no-repeat;
}
.pg-pig { position: absolute; top: 50%; left: 0; width: 30px; height: 30px; transform: translate(-50%, -54%); transition: left .6s cubic-bezier(.3, 1.4, .5, 1); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.pg-pig svg { display: block; width: 100%; height: 100%; }
.pg-card.cur .pg-pig { animation: pg-bob 1.4s ease-in-out infinite; }
@keyframes pg-bob { 50% { transform: translate(-50%, -66%); } }

/* ----- felt, dice, turn total ----- */
.pg-felt {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 12px 14px; border-radius: 18px;
  background: radial-gradient(ellipse at 50% 30%, #1d4a5c 0%, #10283a 50%, #0b0f24 100%);
  box-shadow: 0 0 0 2px var(--pg-glow), 0 0 28px rgba(var(--pg-rgb), .3), inset 0 0 50px rgba(0, 0, 0, .45);
}
.pg-turn { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pg-turnlbl { font: 800 .74rem var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.pg-turnval { font: 900 2.9rem/1 var(--font-body); color: #fff; text-shadow: 0 0 18px rgba(var(--pg-rgb), .8); font-variant-numeric: tabular-nums; }
.pg-turnval.pop { animation: pg-pop .35s ease-out; }
@keyframes pg-pop { 0% { transform: scale(1.35); color: var(--pg-glow); } 100% { transform: scale(1); } }
.pg-turnval.lost { color: #ff6b8a; text-decoration: line-through; text-shadow: 0 0 14px rgba(255, 80, 120, .7); }

.pg-dicewrap { position: relative; width: 100%; display: flex; justify-content: center; }
.pg-dice { --die: min(30vw, 118px); display: flex; justify-content: center; gap: 22px; padding: 10px 0 4px; }
.pg-dice.two { --die: min(27vw, 100px); }
.pg-die[hidden] { display: none; }
.pg-face {
  --c: calc(var(--die) * .7);
  position: relative; width: var(--die); height: var(--die); display: grid; place-items: center; perspective: calc(var(--die) * 5);
}
.pg-face::before {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 0; height: 22%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, .7), transparent);
}
.pg-cube {
  position: relative; width: var(--c); height: var(--c); transform-style: preserve-3d;
  transition: transform .74s cubic-bezier(.2, .75, .3, 1.06), opacity .2s;
  transition-delay: calc(var(--k, 0) * 40ms);
}
.pg-die.instant .pg-cube { transition: opacity .2s; }
.pg-side {
  position: absolute; inset: 0; padding: 15%; border-radius: 20%; backface-visibility: hidden;
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); place-items: center;
  background: radial-gradient(circle at 30% 25%, #fff, #fbeef6 55%, #e3c3d6);
  box-shadow: inset 0 0 0 1px rgba(90, 20, 60, .18), inset -3px -4px 7px rgba(120, 40, 90, .25), inset 3px 3px 5px #fff;
}
.pg-side.f1 { transform: translateZ(calc(var(--c) / 2)); }
.pg-side.f6 { transform: rotateY(180deg) translateZ(calc(var(--c) / 2)); }
.pg-side.f3 { transform: rotateY(90deg) translateZ(calc(var(--c) / 2)); }
.pg-side.f4 { transform: rotateY(-90deg) translateZ(calc(var(--c) / 2)); }
.pg-side.f2 { transform: rotateX(90deg) translateZ(calc(var(--c) / 2)); }
.pg-side.f5 { transform: rotateX(-90deg) translateZ(calc(var(--c) / 2)); }
.pg-side i { width: 72%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #4a2a5a, #170a22 70%); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .6), 0 1px 0 rgba(255, 255, 255, .8); }
.pg-side.f1 i { width: 95%; background: radial-gradient(circle at 40% 35%, #ff9bd2, #d6247a 70%); }
.pg-die.blank .pg-cube { opacity: .45; }
.pg-die.bust .pg-side { background: radial-gradient(circle at 30% 25%, #fff0f3, #ffb8c6 60%, #e5728c); }
.pg-die.bust .pg-face { animation: pg-shake .45s ease-in-out; }
@keyframes pg-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px) rotate(-3deg); } 75% { transform: translateX(6px) rotate(3deg); } }
.pg-die.rolling .pg-face { animation: pg-toss .74s ease-out both; animation-delay: calc(var(--k, 0) * 40ms); }
@keyframes pg-toss {
  0% { transform: translateY(0); }
  30% { transform: translateY(-26px); }
  65% { transform: translateY(2px); }
  80% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.pg-stamp {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-8deg) scale(.6); opacity: 0; pointer-events: none;
  font: 900 clamp(1.3rem, 6.5vw, 2.1rem)/1 var(--font-head); letter-spacing: .05em; text-transform: uppercase; white-space: nowrap;
  padding: 6px 16px; border-radius: 10px; border: 3px solid currentColor; background: rgba(10, 6, 20, .8);
}
.pg-stamp.bad { color: #ff5c7f; text-shadow: 0 0 14px rgba(255, 70, 110, .8); }
.pg-stamp.show { animation: pg-stamp 1.5s ease-out both; }
@keyframes pg-stamp {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(1.8); }
  15% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
  80% { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(-8deg) scale(.95); }
}
@media (prefers-reduced-motion: reduce) {
  .pg-stamp.show { opacity: 1; transform: translate(-50%, -50%) rotate(-8deg); }
}

.pg-trail { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; min-height: 26px; max-width: 100%; }
.pg-chip { padding: 2px 9px; border-radius: 999px; font-weight: 800; font-size: .85rem; color: #ffe1f1; background: rgba(var(--pg-rgb), .16); box-shadow: inset 0 0 0 1px rgba(var(--pg-rgb), .45); }
.pg-chip.bad { color: #fff; background: #d6345c; box-shadow: none; }
.pg-note { margin: 0; min-height: 2.6em; text-align: center; color: var(--muted); font-weight: 600; font-size: .95rem; line-height: 1.3; }
.pg-actions { display: flex; gap: 12px; width: 100%; justify-content: center; }
.pg-actions .btn { flex: 1 1 0; max-width: 220px; min-height: 62px; font-size: 1.3rem; border-radius: 16px; font-weight: 800; }
.pg-hold { background: linear-gradient(135deg, #1fb89a, #3df5c8); color: #04241e; box-shadow: 0 6px 20px rgba(61, 245, 200, .3); }
.pg-skip[hidden] { display: none; }

@media (max-width: 480px) {
  .pg-card { padding: 8px 10px 10px; }
  .pg-score { font-size: 1.4rem; }
  .pg-turnval { font-size: 2.2rem; }
  .pg-actions .btn { min-height: 56px; font-size: 1.15rem; }
}
