/* EL3AB Ludo Game Styles */

/* ============================================
   GAME LAYOUT
   ============================================ */

.ludo-layout {
  display: flex;
  flex-direction: column;
  gap: 0;
  max-width: 100%;
  direction: ltr;
}

.ludo-board-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* Player info cards */
.ludo-players-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  justify-content: space-between;
}

.ludo-player-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex: 1;
  min-width: 0;
  transition: all 0.3s var(--ease);
  direction: rtl;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.ludo-player-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(231,168,50,0.5), 0 2px 8px rgba(0,0,0,0.2);
}

.ludo-player-card.finished {
  opacity: 0.5;
}

.ludo-player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ludo-player-dot--p1 { background: var(--ludo-p1); }
.ludo-player-dot--p2 { background: var(--ludo-p2); }
.ludo-player-dot--p3 { background: var(--ludo-p3); }
.ludo-player-dot--p4 { background: var(--ludo-p4); }

.ludo-player-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ludo-player-status {
  font-size: 10px;
  color: var(--text-3);
  margin-right: auto;
}

/* ============================================
   BOARD
   ============================================ */

.ludo-board-wrapper {
  position: relative;
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
}

.ludo-board {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  background: var(--ludo-board-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  border: 3px solid rgba(0,0,0,0.2);
  direction: ltr;
}

/* Path cells */
.ludo-cell {
  position: relative;
  background: #faf8f4;
  border: 0.5px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Safe position star */
.ludo-cell--safe::after {
  content: '\2605';
  font-size: 1em;
  color: #d4a017;
  opacity: 1;
  text-shadow: 0 0 4px rgba(212,160,23,0.5);
}

/* Start cells (colored) */
.ludo-cell--start-p1 { background: linear-gradient(135deg, var(--ludo-p1), #c0392b); }
.ludo-cell--start-p2 { background: linear-gradient(135deg, var(--ludo-p2), #1e8449); }
.ludo-cell--start-p3 { background: linear-gradient(135deg, var(--ludo-p3), #d4ac0d); }
.ludo-cell--start-p4 { background: linear-gradient(135deg, var(--ludo-p4), #2471a3); }

/* Home entrance strips */
.ludo-cell--home-p1 { background: linear-gradient(to top, var(--ludo-home-p1), rgba(231,76,60,0.2)); border-color: var(--ludo-p1); }
.ludo-cell--home-p2 { background: linear-gradient(to right, var(--ludo-home-p2), rgba(46,204,113,0.2)); border-color: var(--ludo-p2); }
.ludo-cell--home-p3 { background: linear-gradient(to bottom, var(--ludo-home-p3), rgba(241,196,15,0.2)); border-color: var(--ludo-p3); }
.ludo-cell--home-p4 { background: linear-gradient(to left, var(--ludo-home-p4), rgba(52,152,219,0.2)); border-color: var(--ludo-p4); }

/* Corner bases */
.ludo-base {
  position: relative;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ludo-base--p1 { grid-area: 10/1 / 16/7; background: radial-gradient(circle at 30% 70%, #e74c3c 0%, #c0392b 100%); }
.ludo-base--p2 { grid-area: 1/1 / 7/7; background: radial-gradient(circle at 30% 30%, #2ecc71 0%, #1e8449 100%); }
.ludo-base--p3 { grid-area: 1/10 / 7/16; background: radial-gradient(circle at 70% 30%, #f1c40f 0%, #d4ac0d 100%); }
.ludo-base--p4 { grid-area: 10/10 / 16/16; background: radial-gradient(circle at 70% 70%, #3498db 0%, #2471a3 100%); }

/* Inner base circle (where pieces sit initially) */
.ludo-base-inner {
  width: 72%;
  height: 72%;
  background: #fffef8;
  border-radius: 50%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12%;
  padding: 16%;
  box-shadow: inset 0 3px 8px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.15);
}

.ludo-base-slot {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
}

/* Center home (3x3) */
.ludo-center {
  grid-area: 7/7 / 10/10;
  position: relative;
  overflow: hidden;
}

.ludo-center-triangle {
  position: absolute;
  width: 0;
  height: 0;
}

.ludo-center-triangle--p1 {
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-bottom: 100px solid var(--ludo-p1);
}

.ludo-center-triangle--p2 {
  left: 0; top: 50%;
  transform: translateY(-50%);
  border-top: 100px solid transparent;
  border-bottom: 100px solid transparent;
  border-left: 100px solid var(--ludo-p2);
}

.ludo-center-triangle--p3 {
  top: 0; left: 50%;
  transform: translateX(-50%);
  border-left: 100px solid transparent;
  border-right: 100px solid transparent;
  border-top: 100px solid var(--ludo-p3);
}

.ludo-center-triangle--p4 {
  right: 0; top: 50%;
  transform: translateY(-50%);
  border-top: 100px solid transparent;
  border-bottom: 100px solid transparent;
  border-right: 100px solid var(--ludo-p4);
}

/* ============================================
   PIECES
   ============================================ */

.ludo-pieces {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.ludo-piece {
  position: absolute;
  width: 5.8%;
  height: 5.8%;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  transform: translate(-50%, -50%);
  transition: top 0.25s var(--ease), left 0.25s var(--ease);
  z-index: 2;
  pointer-events: auto;
  cursor: default;
  box-shadow: 0 3px 6px rgba(0,0,0,0.5), inset 0 3px 5px rgba(255,255,255,0.4), inset 0 -3px 4px rgba(0,0,0,0.3);
}

.ludo-piece--p1 { background: radial-gradient(circle at 35% 35%, #ff6b6b, var(--ludo-p1) 60%, #a83232); }
.ludo-piece--p2 { background: radial-gradient(circle at 35% 35%, #6bff6b, var(--ludo-p2) 60%, #1a7a1a); }
.ludo-piece--p3 { background: radial-gradient(circle at 35% 35%, #fff06b, var(--ludo-p3) 60%, #b89b0a); }
.ludo-piece--p4 { background: radial-gradient(circle at 35% 35%, #6bb5ff, var(--ludo-p4) 60%, #1a5a8a); }

.ludo-piece--highlight {
  cursor: pointer;
  animation: ludo-pulse 0.8s ease-in-out infinite;
  z-index: 3;
  filter: brightness(1.2);
}

.ludo-piece--highlight.ludo-piece--p1 { box-shadow: 0 0 10px var(--ludo-p1), 0 0 20px var(--ludo-p1); }
.ludo-piece--highlight.ludo-piece--p2 { box-shadow: 0 0 10px var(--ludo-p2), 0 0 20px var(--ludo-p2); }
.ludo-piece--highlight.ludo-piece--p3 { box-shadow: 0 0 10px var(--ludo-p3), 0 0 20px var(--ludo-p3); }
.ludo-piece--highlight.ludo-piece--p4 { box-shadow: 0 0 10px var(--ludo-p4), 0 0 20px var(--ludo-p4); }

@keyframes ludo-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.35); }
}

.ludo-piece--home {
  opacity: 0;
  pointer-events: none;
}

/* Stacking offset for pieces on same cell */
.ludo-piece[data-stack="1"] { margin-left: 2.2%; margin-top: -1.5%; }
.ludo-piece[data-stack="2"] { margin-left: -2.2%; margin-top: 1.5%; }
.ludo-piece[data-stack="3"] { margin-left: 2.2%; margin-top: 1.5%; }

/* ============================================
   DICE
   ============================================ */

.ludo-dice-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.ludo-dice {
  width: 72px;
  height: 72px;
  background: #f8f4ec;
  border: 3px solid #c8b88a;
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px;
  gap: 4px;
  place-items: center;
  transition: transform 0.1s;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 1px 3px rgba(255,255,255,0.6), 0 0 0 1px rgba(200,184,138,0.3);
}

.ludo-dice--rolling {
  animation: ludo-dice-roll-3d 0.5s ease;
  perspective: 300px;
}

@keyframes ludo-dice-roll-3d {
  0% { transform: rotateX(0deg) rotateY(0deg) scale(1); }
  25% { transform: rotateX(180deg) rotateY(90deg) scale(0.85); }
  50% { transform: rotateX(360deg) rotateY(180deg) scale(1.1); }
  75% { transform: rotateX(540deg) rotateY(270deg) scale(0.9); }
  100% { transform: rotateX(720deg) rotateY(360deg) scale(1); }
}

.ludo-dice-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a1a1a;
  display: none;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.4);
}

.ludo-dice-dot--visible {
  display: block;
}

.ludo-roll-btn {
  padding: 12px 36px;
  background: var(--gold);
  color: var(--text-inverse);
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 3px 10px rgba(231,168,50,0.4);
  font-family: var(--font-ar);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
}

.ludo-roll-btn:hover { background: var(--gold-dark); }
.ludo-roll-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============================================
   SIDE PANEL
   ============================================ */

.ludo-side-panel {
  display: none;
  flex-direction: column;
  width: 260px;
  min-width: 240px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.ludo-turn-indicator {
  padding: 12px 16px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  direction: rtl;
}

.ludo-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-2);
  max-height: 200px;
  direction: rtl;
}

.ludo-log-entry {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}

.ludo-log-entry:last-child { border-bottom: none; }

.ludo-controls {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  direction: rtl;
}

/* ============================================
   CHAT
   ============================================ */

.ludo-chat {
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: 200px;
}

.ludo-chat-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: rtl;
}

.ludo-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 140px;
}

.ludo-chat-msg {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--bg-3);
  direction: rtl;
}

.ludo-chat-msg--system {
  color: var(--text-3);
  font-style: italic;
  background: none;
  text-align: center;
}

.ludo-chat-sender {
  font-weight: 600;
  margin-left: 4px;
}

.ludo-chat-input-row {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-top: 1px solid var(--border);
  direction: rtl;
}

.ludo-chat-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-1);
  font-size: 12px;
  font-family: var(--font-ar);
}

.ludo-chat-send {
  padding: 6px 12px;
  background: var(--cyan);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.ludo-quick-msgs {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
  overflow-x: auto;
  direction: rtl;
}

.ludo-quick-msg {
  padding: 4px 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 11px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.15s;
}

.ludo-quick-msg:hover { background: var(--bg-2); color: var(--text-1); }

/* ============================================
   GAME RESULT OVERLAY
   ============================================ */

.ludo-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--overlay-result);
  z-index: 10;
  border-radius: var(--radius-md);
  gap: 12px;
  direction: rtl;
}

.ludo-result-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
}

.ludo-result-subtitle {
  font-size: 14px;
  color: var(--text-2);
}

.ludo-result-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* ============================================
   MOBILE PANEL
   ============================================ */

.ludo-mobile-panel {
  display: none;
  flex-direction: column;
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Mobile chat toggle */
.ludo-chat-toggle {
  position: fixed;
  bottom: calc(var(--nav-bottom-h) + 12px);
  left: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--cyan);
  color: var(--text-inverse);
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  z-index: 20;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (min-width: 768px) {
  .ludo-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
    justify-content: center;
    padding: 8px 0;
  }

  .ludo-board-column {
    flex: 0 0 auto;
    width: min(480px, calc(100vh - 180px));
  }

  .ludo-side-panel {
    display: flex;
    flex: 0 1 280px;
    max-height: min(480px, calc(100vh - 180px));
  }

  .ludo-mobile-panel { display: none; }
}

@media (max-width: 767px) {
  .ludo-layout {
    flex-direction: column;
    align-items: center;
    padding: 0 4px;
    padding-bottom: 24px;
  }

  .ludo-board-column { width: 100%; }
  .ludo-board-wrapper { max-width: 100%; margin: 0 auto; }
  .ludo-side-panel { display: none; }

  .ludo-mobile-panel {
    display: flex;
    margin-top: 12px;
    margin-bottom: 24px;
    padding: 16px;
  }

  .ludo-chat-toggle { display: flex; }

  .ludo-players-row { max-width: 100%; margin-bottom: 6px; }
}

/* Piece land bounce */
.ludo-piece--landed {
  animation: piece-land 0.4s var(--ease, cubic-bezier(0.4, 0, 0.2, 1)) both;
}

@keyframes piece-land {
  0% { transform: translate(-50%, -50%) scale(1, 1); }
  30% { transform: translate(-50%, -50%) scale(1.3, 0.7); }
  60% { transform: translate(-50%, -50%) scale(0.9, 1.1); }
  100% { transform: translate(-50%, -50%) scale(1, 1); }
}

/* Capture explosion particles */
.ludo-capture-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  animation: capture-burst 0.6s ease-out forwards;
}

@keyframes capture-burst {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--px, 0), var(--py, 0)) scale(0);
    opacity: 0;
  }
}
