/* ============================================
   CallBrazi — XO (Tic-Tac-Toe) Game Styles
   ============================================ */

/* ── Game Overlay ── */
.xo-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
}

.xo-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Panel ── */
.xo-panel {
  width: 370px;
  max-width: 95vw;
  background: rgba(15, 20, 45, 0.97);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: 16px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(108, 99, 255, 0.15);
  overflow: hidden;
  animation: xoSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes xoSlideIn {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ── */
.xo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: rgba(108, 99, 255, 0.1);
  border-bottom: 1px solid rgba(108, 99, 255, 0.2);
}

.xo-title {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #6c63ff, #00d4aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0;
}

.xo-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.xo-close-btn:hover {
  color: #ff4757;
}

/* ── Screens (shared) ── */
.xo-screen {
  padding: 24px 20px;
  text-align: center;
}

/* ── Invite Screen ── */
.xo-invite-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  letter-spacing: 4px;
}

.xo-invite-text {
  color: #8b92c5;
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.xo-invite-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── Buttons ── */
.xo-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
}

.xo-btn-primary {
  background: linear-gradient(135deg, #6c63ff, #3b82f6);
  color: white;
}
.xo-btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(108, 99, 255, 0.4);
}

.xo-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #8b92c5;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.xo-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #f0f2ff;
}

.xo-btn-danger {
  background: rgba(255, 71, 87, 0.2);
  color: #ff4757;
  border: 1px solid rgba(255, 71, 87, 0.3);
}
.xo-btn-danger:hover {
  background: rgba(255, 71, 87, 0.3);
}

/* ── Waiting Spinner ── */
.xo-waiting-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(108, 99, 255, 0.2);
  border-top-color: #6c63ff;
  border-radius: 50%;
  animation: xoSpin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes xoSpin {
  to { transform: rotate(360deg); }
}

/* ── Scoreboard ── */
.xo-scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}

.xo-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  transition: all 0.3s ease;
  min-width: 90px;
}

.xo-player.xo-active-player {
  background: rgba(108, 99, 255, 0.15);
  box-shadow: 0 0 15px rgba(108, 99, 255, 0.2);
}

.xo-player-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: #8b92c5;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.xo-player-symbol {
  font-size: 1.2rem;
  font-weight: 800;
}

.xo-symbol-x {
  color: #00d4aa;
}
.xo-symbol-o {
  color: #ff6b81;
}

.xo-player-timer {
  font-size: 0.7rem;
  font-weight: 600;
  color: #5a6199;
  font-variant-numeric: tabular-nums;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
}

.xo-timer-danger {
  color: #ff4757 !important;
  background: rgba(255, 71, 87, 0.15) !important;
  animation: xoPulse 0.6s ease-in-out infinite;
}

@keyframes xoPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.xo-score {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 800;
  color: #f0f2ff;
}
.xo-score-separator {
  color: #5a6199;
  font-size: 1rem;
}

/* ── Turn Indicator ── */
.xo-turn-indicator {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 14px;
  transition: all 0.3s ease;
}

.xo-my-turn {
  background: rgba(0, 212, 170, 0.15);
  color: #00d4aa;
}

.xo-partner-turn {
  background: rgba(255, 107, 129, 0.15);
  color: #ff6b81;
}

/* ── Game Board ── */
.xo-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  background: rgba(90, 97, 153, 0.2);
  border-radius: 12px;
  margin-bottom: 10px;
  position: relative;
}

.xo-line-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#xo-win-line {
  stroke: #ffffff;
  stroke-width: 8px;
  stroke-linecap: round;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.8)) drop-shadow(0 0 15px rgba(255, 255, 255, 0.6));
  stroke-dasharray: 400;
  stroke-dashoffset: 400;
  transition: stroke-dashoffset 0.6s ease-out;
}

#xo-win-line.draw {
  stroke-dashoffset: 0;
}

.xo-board-disabled {
  pointer-events: none;
}

.xo-cell {
  aspect-ratio: 1;
  background: rgba(15, 20, 45, 0.8);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.xo-cell:hover:not(.xo-x):not(.xo-o) {
  background: rgba(108, 99, 255, 0.15);
  transform: scale(1.03);
}

.xo-cell.xo-x,
.xo-cell.xo-o {
  cursor: default;
}

.xo-cell.xo-winning {
  animation: xoWinGlow 0.6s ease-in-out infinite alternate;
}

@keyframes xoWinGlow {
  from { box-shadow: 0 0 5px rgba(108, 99, 255, 0.3); }
  to { box-shadow: 0 0 20px rgba(108, 99, 255, 0.6), inset 0 0 10px rgba(108, 99, 255, 0.15); }
}

/* ── Marks (SVG) ── */
.xo-mark {
  width: 55%;
  height: 55%;
}

.xo-mark-x {
  color: #00d4aa;
  animation: xoMarkIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.xo-mark-o {
  color: #ff6b81;
  animation: xoMarkIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes xoMarkIn {
  from { opacity: 0; transform: scale(0.5) rotate(-15deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ── Result Overlay ── */
.xo-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 39, 0.92);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  gap: 16px;
  animation: xoResultIn 0.4s ease;
  z-index: 20; /* تم رفعه ليكون فوق الخط المضيء */
}

@keyframes xoResultIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.xo-result-text {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #6c63ff, #00d4aa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#xo-play-again {
  display: none; /* إخفاء الزر لأن الإعادة أصبحت تلقائية */
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .xo-panel {
    width: 320px;
  }

  .xo-cell {
    min-height: 70px;
  }

  .xo-player {
    min-width: 70px;
    padding: 6px 8px;
  }
}
