/* Game Overlay & UI Styling */

.game-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 600px;
  height: 85%;
  max-height: 800px;
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, width 0.3s ease, height 0.3s ease;
  direction: rtl;
}

.game-overlay.d-none {
  display: none !important;
}

/* Header Styling */
.game-overlay-header {
  background-color: #1f2937;
  color: #ffffff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #374151;
  user-select: none;
}

#game-overlay-title {
  font-family: 'Tajawal', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.game-overlay-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#game-viewers-count {
  font-size: 0.85rem;
  background-color: rgba(255, 255, 255, 0.15);
  padding: 4px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-overlay-actions button {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background-color 0.2s;
}

.game-overlay-actions button:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
}

/* Game Stage Styling */
.game-stage {
  flex-grow: 1;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #f3f4f6;
  display: flex;
  flex-direction: column;
}

/* Voice Controls */
.game-voice-controls {
  display: none !important;
  background-color: #111827;
  color: #ffffff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #1f2937;
}

.game-voice-controls button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background-color: #374151;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.game-voice-controls button:hover {
  background-color: #4b5563;
}

.game-voice-controls button.muted {
  background-color: #ef4444;
}

.game-voice-controls button.muted:hover {
  background-color: #dc2626;
}

#game-voice-status {
  font-size: 0.85rem;
  color: #9ca3af;
}

/* Minimized Indicator */
.game-minimized-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: #8b5cf6;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
  z-index: 1040;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-family: 'Tajawal', sans-serif;
  font-weight: 700;
  transition: transform 0.2s, background-color 0.2s;
  animation: pulse-ring 2s infinite;
}

.game-minimized-indicator:hover {
  background-color: #7c3aed;
  transform: scale(1.05);
}

.game-minimized-indicator.d-none {
  display: none !important;
}

/* Square Board Aspect Ratio Constraints */
.ludo-game-container,
.carrom-container {
  height: 100% !important;
  display: flex;
  flex-direction: column;
}

/* Square aspects for Board Containers */
.ludo-board-wrapper,
.carrom-board-wrapper {
  aspect-ratio: 1/1 !important;
  width: 95% !important;
  max-width: 500px !important;
  margin: auto !important;
}

/* Responsiveness & Mobile Adaptations */
@media (max-width: 768px) {
  .game-overlay {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .ludo-board-wrapper,
  .carrom-board-wrapper {
    max-width: 92vw !important;
  }
}

/* ... existing styles ... */
@keyframes pulse-ring {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
  }
}

.ludo-arena {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.ludo-players-top, .ludo-players-bottom {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.ludo-player-card {
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 12px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    width: clamp(150px, 40vw, 200px);
    transition: all 0.2s;
    font-size: 0.85rem;
    position: relative;
    overflow: hidden;
}

.ludo-player-card.is-active {
    border-color: #3b82f6;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.3);
}

.ludo-player-card.color-red { border-left: 5px solid #ef4444; }
.ludo-player-card.color-blue { border-left: 5px solid #3b82f6; }
.ludo-player-card.color-green { border-left: 5px solid #22c55e; }
.ludo-player-card.color-yellow { border-left: 5px solid #eab308; }

.ludo-player-avatar-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.ludo-player-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fff;
}

.ludo-turn-progress {
    position: absolute;
    top: -2px;
    left: -2px;
    width: 52px;
    height: 52px;
    transform: rotate(-90deg);
}

.ludo-turn-progress circle {
    fill: none;
    stroke-width: 4px;
    stroke-dasharray: 126; /* 2 * PI * r (approx 20) */
    stroke-dashoffset: 126;
    transition: stroke-dashoffset 0.25s linear;
}

.ludo-player-mic-state {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #fff;
    border-radius: 50%;
    padding: 3px;
    font-size: 10px;
    border: 1px solid #ddd;
}

.ludo-player-details {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ludo-player-name {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ludo-voice-meter {
    display: none;
    gap: 2px;
    align-items: center;
}

.ludo-player-card.is-speaking .ludo-voice-meter {
    display: flex;
}

.ludo-voice-meter span {
    width: 3px;
    height: 10px;
    background: #22c55e;
    animation: meter-bounce 0.5s infinite alternate;
}

@keyframes meter-bounce {
    from { height: 5px; }
    to { height: 15px; }
}

.ludo-player-speaker-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #6b7280;
}
