.prg-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.prison-popup .prg-tabs [data-pr-game] {
  min-inline-size: 0;
  padding: 5px 7px;
  border: 1px solid var(--room-rule);
  background: var(--room-panel);
  color: var(--room-ink);
  font-size: .85rem;
  white-space: normal;
  overflow-wrap: anywhere;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}
.prison-popup .prg-tabs [aria-pressed="true"] {
  border-color: var(--room-gold);
  background: color-mix(in srgb, var(--room-gold) 14%, var(--room-panel));
  color: var(--room-gold);
}
.prison-popup .prg-tabs [data-pr-game]:active:not(:disabled) { transform: scale(.97); }
.prison-popup .prg-choices:has(> :nth-child(3)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.prison-popup .prg-choices .cp-choice > span {
  text-align: center;
  overflow-wrap: anywhere;
  font-size: .82rem;
  line-height: 1.2;
}
@media (max-width: 530px) {
  .prg-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.prison-popup .prg-table {
  --prg-felt-ink: #fbecd5;
  --prg-felt-muted: #d5c8b8;
  --prg-gilt: #ffd58d;
  min-inline-size: 0;
}
.prison-popup .prg-table[data-pr-game-stage="sutda"] {
  background: radial-gradient(ellipse at 50% 42%, #4a302a, #281d1c 82%);
  border-color: #6e4a3d;
  box-shadow: inset 0 0 16px #190f0b6e;
}
.prison-popup .prg-table[data-pr-game-stage="sicbo"] {
  background: radial-gradient(ellipse at 50% 42%, #305548, #192e2a 82%);
  border-color: #47665a;
  box-shadow: inset 0 0 16px #071f1d83;
}
.prison-popup .prg-table[data-pr-game-stage="ladder"] {
  background: #182229;
  border: 12px solid #5d4731;
  border-image: url('/img/city/prison-games/ladder-board.webp') 48 fill stretch;
  padding-block: 4px;
  clip-path: inset(0 round 12px);
}
.prison-popup .prg-table [data-pr-game-detail] { color: var(--prg-felt-muted); }
.prg-feedback { display: grid; gap: 4px; min-width: 0; }
.prg-table[data-pr-game-stage="sutda"] [data-pr-game-detail] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.prison-popup .prg-table .prg-result { font-weight: 700; }
.prison-popup .prg-table .prg-result[data-outcome="win"] { color: var(--prg-gilt); }
.prison-popup .prg-table .prg-result[data-outcome="loss"] { color: #ffcfbc; }
.prison-popup .prg-table .prg-result[data-outcome="push"] { color: #e0edf0; }
.prison-popup .prg-table [data-pr-game-detail][hidden],
.prison-popup .prg-table :is([data-pr-game-detail], .prg-result):empty { display: none; }

.prg-board {
  display: grid;
  align-items: center;
  inline-size: min(100%, 360px);
  min-block-size: clamp(138px, 27vw, 163px);
  color: var(--prg-felt-ink);
  font-variant-numeric: tabular-nums;
}
.prg-board[hidden] { display: none; }

.prg-sutda {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  position: relative;
}
.prg-sutda::before {
  content: '';
  position: absolute;
  inset-block: 9% 10%;
  inset-inline-start: 50%;
  border-inline-start: 1px solid #ad7d5c54;
}
.prg-hand {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  min-inline-size: 0;
  text-align: center;
}
.prg-hand-label { color: var(--prg-felt-muted); font-size: .8rem; }
.prg-hand-rank { color: var(--prg-felt-ink); font-size: .87rem; line-height: 1.22; }
.prg-board[data-prg-result="won"] .prg-hand:first-child .prg-hand-rank { color: var(--prg-gilt); }
.prg-board[data-prg-revealing] .prg-hand-rank { visibility: hidden; }
.prg-hand-cards {
  inline-size: 100%;
  display: flex;
  justify-content: center;
  gap: clamp(5px, 2vw, 10px);
}
.prg-card {
  position: relative;
  inline-size: min(42%, clamp(37px, 12vw, 59px));
  aspect-ratio: 2 / 3;
  perspective: 320px;
}
.prg-card-turn, .prg-card-face, .prg-card-back {
  position: absolute;
  inset: 0;
  border-radius: 5px;
}
.prg-card-turn { transform-style: preserve-3d; }
.prg-card[data-covered] .prg-card-turn { transform: rotateY(-180deg); }
.prg-card-face, .prg-card-back {
  backface-visibility: hidden;
  border: 1px solid;
  box-shadow: 0 3px 5px #180d0880;
}
.prg-card-face {
  display: grid;
  place-items: center;
  color: #611d1d;
  border-color: #ac6c41;
  background: #edc894 url('/img/city/prison-games/sutda-face.webp') center / cover no-repeat;
}
.prg-card-number {
  z-index: 1;
  font-family: var(--game, system-ui, sans-serif);
  font-size: clamp(1.2rem, 5.8vw, 1.85rem);
  line-height: 1;
}
.prg-card-stamp {
  display: grid;
  place-items: center;
  position: absolute;
  inset-inline-end: 3px;
  inset-block-end: 3px;
  inline-size: clamp(15px, 4vw, 21px);
  aspect-ratio: 1;
  border: 1px solid #ffe7b6;
  border-radius: 50%;
  background: #a22a27;
  color: #fff1cb;
  font-size: clamp(9px, 3vw, 13px);
  font-weight: 800;
  line-height: 1;
}
.prg-card-back {
  transform: rotateY(180deg);
  border-color: #8c4b27;
  background: #6b231f url('/img/city/prison-games/sutda-back.webp') center / cover no-repeat;
}

.prg-sicbo { display: grid; justify-items: center; gap: clamp(10px, 2vw, 16px); }
.prg-dice {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 3.4vw, 23px);
  inline-size: 100%;
  perspective: 400px;
}
.prg-die {
  position: relative;
  inline-size: min(25%, clamp(40px, 14vw, 60px));
  aspect-ratio: 1;
  border: 1px solid #cba36e;
  border-radius: 15%;
  background: #e5c696 url('/img/city/prison-games/sicbo-die.webp') center / cover no-repeat;
  box-shadow: 0 3px 0 #936844, 0 6px 10px #101a1591;
}
.prg-die[data-face="0"] { opacity: .67; }
.prg-die[data-face="0"]::before {
  content: '';
  position: absolute;
  inset: 30%;
  rotate: 45deg;
  border: 1px solid #986947;
  border-radius: 20%;
}
.prg-die-pips {
  position: absolute;
  inset: 12%;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  place-items: center;
}
.prg-die-pip {
  inline-size: 58%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #4f2529;
  box-shadow: inset 0 1px 2px #260f15;
}
.prg-die[data-face="1"] .prg-die-pips:not(.prg-die-tumble) .prg-die-pip {
  inline-size: 78%;
  background: #a02e2a;
}
.prg-dice-score { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 9px; }
.prg-dice-label { color: var(--prg-felt-muted); font-size: .8rem; }
.prg-dice-total { color: var(--prg-felt-ink); font-size: 1.15rem; line-height: 1; }
.prg-dice-triple {
  padding: 2px 7px;
  border: 1px solid #ad7b47;
  border-radius: 4px;
  background: #563b2a;
  color: var(--prg-gilt);
  font-weight: 800;
  font-size: .76rem;
}
.prg-board[data-prg-revealing] :is(.prg-dice-total, .prg-dice-triple) { visibility: hidden; }
.prg-board:not([data-prg-revealing]) .prg-sicbo:has(.prg-dice-triple) .prg-die {
  box-shadow: 0 3px 0 #936844, 0 0 0 2px #d69c58, 0 0 13px #ffc57864;
}

.prg-ladder {
  --prg-rail: #8a9ca4;
  --prg-route: #ffcf84;
  inline-size: min(100%, 316px);
  justify-self: center;
}
.prg-ladder-entries, .prg-ladder-exits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
  text-align: center;
  font-size: .77rem;
}
.prg-ladder-entry {
  position: relative;
  min-inline-size: 0;
  padding: 0 4px 7px;
  color: var(--prg-felt-muted);
  overflow-wrap: anywhere;
}
.prg-ladder-entry::after {
  content: '';
  position: absolute;
  inset-inline-start: 50%;
  inset-block-end: -4px;
  z-index: 1;
  translate: -50% 0;
  inline-size: 8px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--prg-rail);
}
.prg-ladder-entry[data-chosen] { color: var(--prg-gilt); font-weight: 800; }
.prg-ladder-entry[data-chosen]::after { background: var(--prg-route); outline: 2px solid #8d6843; }
.prg-ladder-chart { position: relative; block-size: clamp(73px, 16vw, 99px); }
.prg-rail, .prg-rung { position: absolute; border-radius: 2px; background: var(--prg-rail); }
.prg-rail { inline-size: 2px; translate: -50% 0; }
.prg-rung { inline-size: calc(100% / 3); block-size: 2px; translate: 0 -50%; }
.prg-board[data-prg-result="ready"] .prg-rail {
  background: repeating-linear-gradient(var(--prg-rail) 0 4px, transparent 4px 8px);
}
.prg-ladder-path { border-radius: 0; background: var(--prg-route); box-shadow: 0 0 6px #ffbf7185; }
.prg-rail.prg-ladder-path { inline-size: 3px; }
.prg-rung.prg-ladder-path { block-size: 3px; }
.prg-ladder-exit {
  position: relative;
  margin-block-start: 0;
  padding: 2px 8px;
  min-inline-size: 42px;
  border: 1px solid #617683;
  border-radius: 5px;
  background: #293945;
  color: var(--prg-felt-ink);
}
.prg-ladder-exit[data-winning] { border-color: #9d815d; color: var(--prg-gilt); }
.prg-board:not([data-prg-revealing]) .prg-ladder-exit[data-arrived] {
  box-shadow: 0 0 0 2px #da9a79;
  background: #663f35;
  font-weight: 800;
}
.prg-board:not([data-prg-revealing]) .prg-ladder-exit[data-arrived][data-winning] {
  box-shadow: 0 0 0 2px #997043;
  background: var(--prg-gilt);
  color: #312010;
}

@media (prefers-reduced-motion: reduce) {
  .prison-popup .prg-tabs [data-pr-game] { transition: none; }
  .prison-popup .prg-tabs [data-pr-game]:active { transform: none; }
}
