/**
 * panels.css - Side Area, Family Table & Player Cards
 *
 * Implements a vertically bounded side panel where the player list flexes
 * smoothly and handles arbitrary player counts without page overflow.
 */
.side {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 0.9vh, 10px);
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.panel {
  border: 1px solid #f8dfb124;
  background: #ffffff0b;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: clamp(12px, 1.6vh, 18px);
  padding: clamp(8px, 1.2vh, 13px);
  box-sizing: border-box;
}

.panel h2 {
  font-size: clamp(12px, 1.6vh, 14px);
  margin: 0 0 clamp(4px, 0.7vh, 8px);
  color: #f7e0bc;
}

/* Family Table dynamically sizes to fit players without a scrollbar when screen estate allows */
.side .panel:first-child {
  flex: 0 1 auto;
  max-height: min(65%, calc(100% - 220px));
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

#players {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.5vh, 5px);
  padding-right: 2px;
  scrollbar-width: thin;
}

#players::-webkit-scrollbar {
  width: 4px;
}

#players::-webkit-scrollbar-thumb {
  background: #ffffff22;
  border-radius: 4px;
}

#players::-webkit-scrollbar-thumb:hover {
  background: #ffffff44;
}

.player {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 9px);
  padding: clamp(4px, 0.7vh, 7px) clamp(6px, 1vw, 9px);
  border-radius: 10px;
  border: 1px solid transparent;
  background: #00000014;
  transition: background 0.15s, border-color 0.15s;
}

.player.active {
  background: #fff8d921;
  border-color: #f6d588;
  box-shadow: 0 0 0 1px #f6d58844;
}

.player.captureloss {
  animation: captureLoss 0.75s ease-in-out;
  border-color: #ffbf72;
}

@keyframes captureLoss {
  0%, 100% { background: transparent; }
  45% { background: #c050353d; box-shadow: 0 0 0 2px #ffb26b42; }
}

.avatar {
  width: clamp(26px, 3.8vh, 34px);
  height: clamp(26px, 3.8vh, 34px);
  flex: 0 0 clamp(26px, 3.8vh, 34px);
  border-radius: clamp(8px, 1.1vh, 11px);
  display: grid;
  place-items: center;
  color: #1d130f;
  font-size: clamp(13px, 2vh, 18px);
  font-weight: 800;
  border: 1.5px solid #fff5ce80;
  box-shadow: 0 2px 5px #0004;
}

.pname-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.pname {
  font-size: clamp(11.5px, 1.5vh, 13px);
  font-weight: 650;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Anti-Wobble Right-Aligned Score Badge */
.pscore-badge {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  background: #ffb70322;
  color: #ffda79;
  border: 1px solid #ffb7034d;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: clamp(8.5px, 1.1vh, 10px);
  font-weight: 750;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: 0 0 auto;
  margin-left: auto;
  min-width: clamp(52px, 6vw, 64px);
  text-align: right;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}

.pscore-val {
  font-variant-numeric: tabular-nums;
  text-align: right;
  display: inline-block;
}

.pscore-unit {
  font-size: 0.9em;
  opacity: 0.85;
}

/* Yellow Star for top 1st leading player */
.leader-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(11px, 1.4vh, 13px);
  line-height: 1;
  filter: drop-shadow(0 0 3px #f59e0b) drop-shadow(0 0 7px rgba(245, 158, 11, 0.7));
  margin-left: 2px;
  vertical-align: middle;
  cursor: default;
  animation: leaderStarPulse 2.4s ease-in-out infinite;
}

@keyframes leaderStarPulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 3px #f59e0b);
  }
  50% {
    transform: scale(1.18);
    filter: drop-shadow(0 0 6px #fbbf24) drop-shadow(0 0 10px rgba(251, 191, 36, 0.8));
  }
}

.player.is-leader {
  border-color: rgba(245, 158, 11, 0.45);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.15);
}

.pscore-track {
  width: 100%;
  height: 3px;
  background: #ffffff18;
  border-radius: 2px;
  margin: 3px 0 2px;
  overflow: hidden;
}

.pscore-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.35s ease;
}

.pmeta {
  font-size: clamp(9px, 1.15vh, 10.5px);
  color: #c8b49d;
  margin-top: 1px;
}

.piecestatus {
  display: grid;
  gap: 1px;
  margin-top: 2px;
  color: #e6d3ba;
  font-size: clamp(8px, 1.05vh, 9.5px);
  line-height: 1.25;
}

.piecestatus b {
  color: #ffe3a6;
  font-weight: 750;
}

.turn {
  color: #f2d18d;
  font-size: clamp(10px, 1.3vh, 11px);
  white-space: nowrap;
}

.divider {
  height: 1px;
  background: #ffffff1c;
  margin: clamp(4px, 0.7vh, 8px) 0;
  flex-shrink: 0;
}

.helper {
  font-size: clamp(9.5px, 1.2vh, 11px);
  color: #d2c1aa;
  line-height: 1.4;
}

.small {
  font-size: clamp(8.5px, 1.1vh, 10px);
  color: #c5b097;
}

/* Dayakattai Dice Panel expands to fill available side height */
.side .panel:last-child {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.side .panel:last-child h2 {
  text-align: center;
  margin-bottom: clamp(6px, 1vh, 12px);
}

/* High-Visibility Last Roll Outcome Card */
.lastroll-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: clamp(6px, 1vh, 12px);
  padding: clamp(6px, 1vh, 10px) clamp(10px, 1.4vw, 16px);
  border-radius: 12px;
  background: #00000028;
  border: 1px solid #ffffff1a;
  text-align: center;
  width: 100%;
  max-width: 290px;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.lastroll-header {
  font-size: clamp(10px, 1.3vh, 12px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #d2c1aa;
  margin-bottom: 2px;
}

.lastroll-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
}

.lastroll-number {
  font-size: clamp(30px, 4.4vh, 44px);
  font-weight: 950;
  line-height: 1;
  color: #ffdaa5;
  text-shadow: 0 0 16px #ffbd5988, 0 2px 6px #000000aa;
  letter-spacing: -0.5px;
}

.lastroll-name {
  font-size: clamp(14px, 1.9vh, 18px);
  font-weight: 800;
  color: #ffe6ba;
}

.lastroll-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: clamp(10px, 1.35vh, 12px);
  font-weight: 750;
  padding: 3px 10px;
  border-radius: 20px;
  background: #ffffff14;
  color: #f7e0bc;
  border: 1px solid #ffffff24;
}

.lastroll-status.bonus {
  background: #ff950028;
  color: #ffd880;
  border-color: #ffa72688;
  box-shadow: 0 0 10px #ff950044;
  animation: bonusBadgeGlow 1.6s infinite ease-in-out;
}

@keyframes bonusBadgeGlow {
  0%, 100% { box-shadow: 0 0 8px #ff950044; border-color: #ffa72666; }
  50% { box-shadow: 0 0 16px #ff950088; border-color: #ffbd59; }
}

.lastroll-helper-init {
  font-size: clamp(10px, 1.3vh, 11.5px);
  color: #d2c1aa;
  line-height: 1.4;
  text-align: center;
  padding: 4px 0;
}
