All files / web/src/components/nav ActivePlayersList.tsx

30.4% Statements 218/717
10.34% Branches 3/29
11.76% Functions 2/17
30.4% Lines 218/717

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 7181x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x           2x 2x 2x 2x 2x 2x           2x 2x 2x 2x 2x 2x                               2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x   2x 2x 2x 2x 2x 2x 2x 2x                       2x 2x 2x 2x 2x 2x                                               2x 2x 2x 2x                                     2x 2x 2x 2x                                                                           2x 2x 2x                                                                                                                                                                                     2x 2x 2x 2x 2x                                           2x 2x 2x 2x                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x  
import React from 'react'
import { PlayerTooltip } from './PlayerTooltip'
import type { PlayerBadge } from './types'
 
interface Player {
  id: string
  name: string
  emoji: string
  color?: string
  createdAt?: Date | number
  isLocal?: boolean
}
 
interface ActivePlayersListProps {
  activePlayers: Player[]
  shouldEmphasize: boolean
  onRemovePlayer: (playerId: string) => void
  onConfigurePlayer: (playerId: string) => void
  // Game state for turn indicator
  currentPlayerId?: string
  playerScores?: Record<string, number>
  playerStreaks?: Record<string, number>
  playerBadges?: Record<string, PlayerBadge>
  // Side assignments (for 2-player games)
  whitePlayerId?: string | null
  blackPlayerId?: string | null
  onAssignWhitePlayer?: (playerId: string | null) => void
  onAssignBlackPlayer?: (playerId: string | null) => void
  // Room/host context for assignment permissions
  isInRoom?: boolean
  isCurrentUserHost?: boolean
  // Game phase (for showing spectating vs assign)
  gamePhase?: 'setup' | 'playing' | 'results'
}
 
export function ActivePlayersList({
  activePlayers,
  shouldEmphasize,
  onRemovePlayer,
  onConfigurePlayer,
  currentPlayerId,
  playerScores = {},
  playerStreaks = {},
  playerBadges = {},
  whitePlayerId,
  blackPlayerId,
  onAssignWhitePlayer,
  onAssignBlackPlayer,
  isInRoom = false,
  isCurrentUserHost = false,
  gamePhase,
}: ActivePlayersListProps) {
  const [hoveredPlayerId, setHoveredPlayerId] = React.useState<string | null>(null)
  const [hoveredBadge, setHoveredBadge] = React.useState<string | null>(null)
  const [clickCooldown, setClickCooldown] = React.useState<string | null>(null)
 
  // Determine if user can assign players
  // Can assign if: not in room (local play) OR in room and is host
  const canAssignPlayers = !isInRoom || isCurrentUserHost
 
  // Handler to assign to white
  const handleAssignWhite = React.useCallback(
    (playerId: string, e: React.MouseEvent) => {
      e.stopPropagation()
      if (!onAssignWhitePlayer) return
      onAssignWhitePlayer(playerId)
      setClickCooldown(playerId)
    },
    [onAssignWhitePlayer]
  )
 
  // Handler to assign to black
  const handleAssignBlack = React.useCallback(
    (playerId: string, e: React.MouseEvent) => {
      e.stopPropagation()
      if (!onAssignBlackPlayer) return
      onAssignBlackPlayer(playerId)
      setClickCooldown(playerId)
    },
    [onAssignBlackPlayer]
  )
 
  // Handler to swap sides
  const handleSwap = React.useCallback(
    (playerId: string, e: React.MouseEvent) => {
      e.stopPropagation()
      if (!onAssignWhitePlayer || !onAssignBlackPlayer) return

      if (whitePlayerId === playerId) {
        // Currently white, swap with black player
        const currentBlack = blackPlayerId ?? null
        onAssignWhitePlayer(currentBlack)
        onAssignBlackPlayer(playerId)
      } else if (blackPlayerId === playerId) {
        // Currently black, swap with white player
        const currentWhite = whitePlayerId ?? null
        onAssignBlackPlayer(currentWhite)
        onAssignWhitePlayer(playerId)
      }
    },
    [whitePlayerId, blackPlayerId, onAssignWhitePlayer, onAssignBlackPlayer]
  )
 
  // Helper to get celebration level based on consecutive matches
  const getCelebrationLevel = (consecutiveMatches: number) => {
    if (consecutiveMatches >= 5) return 'legendary'
    if (consecutiveMatches >= 3) return 'epic'
    if (consecutiveMatches >= 2) return 'great'
    return 'normal'
  }
 
  return (
    <>
      {activePlayers.map((player) => {
        const isCurrentPlayer = currentPlayerId ? player.id === currentPlayerId : false
        const hasGameState = currentPlayerId !== undefined
        const score = playerScores[player.id] || 0
        const streak = playerStreaks[player.id] || 0
        const celebrationLevel = getCelebrationLevel(streak)
        const badge = playerBadges[player.id]
 
        return (
          <PlayerTooltip
            key={player.id}
            playerName={player.name}
            playerColor={player.color}
            isLocal={player.isLocal !== false}
            createdAt={player.createdAt}
          >
            <div
              style={{
                display: 'flex',
                flexDirection: 'column',
                alignItems: 'center',
                gap: '4px',
              }}
            >
              <div
                style={{
                  position: 'relative',
                  fontSize: isCurrentPlayer && hasGameState ? '70px' : '56px',
                  lineHeight: 1,
                  transition: 'all 0.4s cubic-bezier(0.4, 0, 0.2, 1)',
                  filter: 'drop-shadow(0 6px 12px rgba(0,0,0,0.3))',
                  cursor: shouldEmphasize ? 'pointer' : 'default',
                  display: 'flex',
                  alignItems: 'center',
                  justifyContent: 'center',
                  opacity: hasGameState ? (isCurrentPlayer ? 1 : 0.65) : 1,
                  transform: isCurrentPlayer && hasGameState ? 'scale(1.1)' : 'scale(1)',
                  animation:
                    isCurrentPlayer && hasGameState
                      ? 'avatarFloat 3s ease-in-out infinite'
                      : 'none',
                }}
                onClick={() => shouldEmphasize && onConfigurePlayer(player.id)}
                onMouseEnter={() => shouldEmphasize && setHoveredPlayerId(player.id)}
                onMouseLeave={() => shouldEmphasize && setHoveredPlayerId(null)}
              >
                {/* Border ring for current player */}
                {isCurrentPlayer && hasGameState && (
                  <div
                    style={{
                      position: 'absolute',
                      inset: '-8px',
                      borderRadius: '50%',
                      border: `4px solid ${player.color || '#3b82f6'}`,
                      boxShadow: `0 0 0 2px white, 0 0 20px ${player.color || '#3b82f6'}80`,
                      animation: 'borderPulse 2s ease-in-out infinite',
                      zIndex: -1,
                    }}
                  />
                )}
 
                {player.emoji}
 
                {/* Score badge - bottom right */}
                {hasGameState && score > 0 && (
                  <div
                    style={{
                      position: 'absolute',
                      bottom: '-6px',
                      right: '-6px',
                      width: '24px',
                      height: '24px',
                      borderRadius: '50%',
                      border: '3px solid white',
                      background: player.color || '#3b82f6',
                      color: 'white',
                      fontSize: '11px',
                      fontWeight: 'bold',
                      display: 'flex',
                      alignItems: 'center',
                      justifyContent: 'center',
                      boxShadow: '0 4px 10px rgba(0,0,0,0.4)',
                      zIndex: 2,
                      lineHeight: 1,
                    }}
                  >
                    {score}
                  </div>
                )}
 
                {/* Streak badge - top right */}
                {hasGameState && streak >= 2 && (
                  <div
                    style={{
                      position: 'absolute',
                      top: '-8px',
                      right: '-8px',
                      fontSize: '20px',
                      filter:
                        celebrationLevel === 'legendary'
                          ? 'drop-shadow(0 0 8px #a855f7)'
                          : celebrationLevel === 'epic'
                            ? 'drop-shadow(0 0 8px #f97316)'
                            : 'drop-shadow(0 0 8px #22c55e)',
                      animation: isCurrentPlayer ? 'streakPulse 1s ease-in-out infinite' : 'none',
                      zIndex: 2,
                    }}
                  >
                    🔥
                  </div>
                )}
 
                {/* Show playerBadge only if assignment UI is not present */}
                {badge && !onAssignWhitePlayer && !onAssignBlackPlayer && (
                  <div
                    style={{
                      display: 'inline-flex',
                      alignItems: 'center',
                      gap: '6px',
                      padding: '4px 10px',
                      borderRadius: '999px',
                      background: badge.background ?? 'rgba(148, 163, 184, 0.25)',
                      color: badge.color ?? '#0f172a',
                      fontSize: '11px',
                      fontWeight: 700,
                      letterSpacing: '0.04em',
                      textTransform: 'uppercase',
                      boxShadow: badge.shadowColor
                        ? `0 4px 12px ${badge.shadowColor}`
                        : '0 4px 12px rgba(15, 23, 42, 0.25)',
                      border: badge.borderColor
                        ? `2px solid ${badge.borderColor}`
                        : '2px solid rgba(255,255,255,0.4)',
                      backdropFilter: 'blur(4px)',
                      marginTop: '6px',
                      whiteSpace: 'nowrap',
                    }}
                  >
                    {badge.icon && (
                      <span
                        aria-hidden
                        style={{
                          fontSize: '14px',
                          filter: 'drop-shadow(0 2px 4px rgba(15,23,42,0.35))',
                        }}
                      >
                        {badge.icon}
                      </span>
                    )}
                    <span>{badge.label}</span>
                  </div>
                )}
 
                {shouldEmphasize && hoveredPlayerId === player.id && (
                  <>
                    {/* Configure button - bottom left */}
                    <button
                      type="button"
                      onClick={(e) => {
                        e.stopPropagation()
                        onConfigurePlayer(player.id)
                      }}
                      style={{
                        position: 'absolute',
                        bottom: '-6px',
                        left: '-6px',
                        width: '24px',
                        height: '24px',
                        borderRadius: '50%',
                        border: '3px solid white',
                        background: 'linear-gradient(135deg, #6b7280, #4b5563)',
                        color: 'white',
                        fontSize: '12px',
                        display: 'flex',
                        alignItems: 'center',
                        justifyContent: 'center',
                        cursor: 'pointer',
                        boxShadow: '0 4px 12px rgba(0,0,0,0.4)',
                        transition: 'all 0.2s ease',
                        padding: 0,
                        lineHeight: 1,
                      }}
                      onMouseEnter={(e) => {
                        e.currentTarget.style.background =
                          'linear-gradient(135deg, #3b82f6, #2563eb)'
                        e.currentTarget.style.transform = 'scale(1.2)'
                        e.currentTarget.style.boxShadow = '0 6px 16px rgba(59, 130, 246, 0.5)'
                      }}
                      onMouseLeave={(e) => {
                        e.currentTarget.style.background =
                          'linear-gradient(135deg, #6b7280, #4b5563)'
                        e.currentTarget.style.transform = 'scale(1)'
                        e.currentTarget.style.boxShadow = '0 4px 12px rgba(0,0,0,0.4)'
                      }}
                      aria-label={`Configure ${player.name}`}
                    >
                      âš™
                    </button>

                    {/* Remove button - top right */}
                    <button
                      type="button"
                      onClick={(e) => {
                        e.stopPropagation()
                        onRemovePlayer(player.id)
                      }}
                      style={{
                        position: 'absolute',
                        top: '-6px',
                        right: '-6px',
                        width: '26px',
                        height: '26px',
                        borderRadius: '50%',
                        border: '3px solid white',
                        background: 'linear-gradient(135deg, #ef4444, #dc2626)',
                        color: 'white',
                        fontSize: '14px',
                        fontWeight: 'bold',
                        display: 'flex',
                        alignItems: 'center',
                        justifyContent: 'center',
                        cursor: 'pointer',
                        boxShadow: '0 4px 12px rgba(0,0,0,0.4)',
                        transition: 'all 0.2s ease',
                        padding: 0,
                        lineHeight: 1,
                      }}
                      onMouseEnter={(e) => {
                        e.currentTarget.style.background =
                          'linear-gradient(135deg, #dc2626, #b91c1c)'
                        e.currentTarget.style.transform = 'scale(1.15)'
                        e.currentTarget.style.boxShadow = '0 6px 16px rgba(239, 68, 68, 0.5)'
                      }}
                      onMouseLeave={(e) => {
                        e.currentTarget.style.background =
                          'linear-gradient(135deg, #ef4444, #dc2626)'
                        e.currentTarget.style.transform = 'scale(1)'
                        e.currentTarget.style.boxShadow = '0 4px 12px rgba(0,0,0,0.4)'
                      }}
                      aria-label={`Remove ${player.name}`}
                    >
                      ×
                    </button>
                  </>
                )}
              </div>
 
              {/* Turn label */}
              {isCurrentPlayer && hasGameState && (
                <div
                  style={{
                    fontSize: '12px',
                    fontWeight: 900,
                    color: player.color || '#3b82f6',
                    textTransform: 'uppercase',
                    letterSpacing: '0.5px',
                    textShadow: `
                      -1px -1px 0 white,
                      1px -1px 0 white,
                      -1px 1px 0 white,
                      1px 1px 0 white,
                      0 2px 4px rgba(0,0,0,0.3)
                    `,
                    marginTop: '-2px',
                    position: 'relative',
                    zIndex: 10,
                  }}
                >
                  Your turn
                </div>
              )}
 
              {/* Side assignment badge (white/black for 2-player games) */}
              {onAssignWhitePlayer && onAssignBlackPlayer && (
                <div
                  style={{
                    marginTop: '8px',
                    width: '88px', // Fixed width to prevent layout shift
                    transition: 'none', // Prevent any inherited transitions
                  }}
                  onMouseEnter={() => canAssignPlayers && setHoveredBadge(player.id)}
                  onMouseLeave={() => {
                    setHoveredBadge(null)
                    setClickCooldown(null)
                  }}
                >
                  {/* Unassigned player - show split button on hover */}
                  {whitePlayerId !== player.id && blackPlayerId !== player.id && (
                    <>
                      {canAssignPlayers ? (
                        // Host/local play: show interactive assignment buttons
                        <>
                          {hoveredBadge === player.id && clickCooldown !== player.id ? (
                            // Hover state: split button
                            <div style={{ display: 'flex', width: '100%' }}>
                              <div
                                onClick={(e) => handleAssignWhite(player.id, e)}
                                style={{
                                  flex: 1,
                                  padding: '4px 0',
                                  borderRadius: '12px 0 0 12px',
                                  fontSize: '10px',
                                  fontWeight: 800,
                                  letterSpacing: '0.5px',
                                  textTransform: 'uppercase',
                                  cursor: 'pointer',
                                  background: 'linear-gradient(135deg, #f0f0f0, #ffffff)',
                                  color: '#1a202c',
                                  border: '2px solid #cbd5e0',
                                  borderRight: 'none',
                                  boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
                                  textAlign: 'center',
                                }}
                              >
                                W
                              </div>
                              <div
                                onClick={(e) => handleAssignBlack(player.id, e)}
                                style={{
                                  flex: 1,
                                  padding: '4px 0',
                                  borderRadius: '0 12px 12px 0',
                                  fontSize: '10px',
                                  fontWeight: 800,
                                  letterSpacing: '0.5px',
                                  textTransform: 'uppercase',
                                  cursor: 'pointer',
                                  background: 'linear-gradient(135deg, #2d3748, #1a202c)',
                                  color: '#ffffff',
                                  border: '2px solid #4a5568',
                                  borderLeft: 'none',
                                  boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
                                  textAlign: 'center',
                                }}
                              >
                                B
                              </div>
                            </div>
                          ) : (
                            // Normal state: ASSIGN or SPECTATING button
                            <div
                              style={{
                                width: '100%',
                                padding: '4px 0',
                                borderRadius: '12px',
                                fontSize: '10px',
                                fontWeight: 800,
                                letterSpacing: '0.5px',
                                textTransform: 'uppercase',
                                cursor: 'pointer',
                                background: 'linear-gradient(135deg, #e5e7eb, #d1d5db)',
                                color: '#6b7280',
                                border: '2px solid #9ca3af',
                                boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
                                textAlign: 'center',
                                transition: 'none',
                              }}
                            >
                              {gamePhase === 'playing' ? 'SPECTATING' : 'ASSIGN'}
                            </div>
                          )}
                        </>
                      ) : // Guest in room: show SPECTATING during gameplay, nothing during setup
                      gamePhase === 'playing' ? (
                        <div
                          style={{
                            width: '100%',
                            padding: '4px 0',
                            borderRadius: '12px',
                            fontSize: '10px',
                            fontWeight: 800,
                            letterSpacing: '0.5px',
                            textTransform: 'uppercase',
                            background: 'transparent',
                            color: '#9ca3af',
                            border: '2px solid transparent',
                            textAlign: 'center',
                            opacity: 0.5,
                          }}
                        >
                          SPECTATING
                        </div>
                      ) : (
                        // During setup/results: show nothing
                        <div style={{ width: '100%', height: '28px' }} />
                      )}
                    </>
                  )}

                  {/* White player - show SWAP to black on hover */}
                  {whitePlayerId === player.id && (
                    <>
                      {canAssignPlayers ? (
                        // Host/local play: show interactive swap
                        <>
                          {hoveredBadge === player.id && clickCooldown !== player.id ? (
                            // Hover state: SWAP with black styling
                            <div
                              onClick={(e) => handleSwap(player.id, e)}
                              style={{
                                width: '100%',
                                padding: '4px 0',
                                borderRadius: '12px',
                                fontSize: '10px',
                                fontWeight: 800,
                                letterSpacing: '0.5px',
                                textTransform: 'uppercase',
                                cursor: 'pointer',
                                transition: 'all 0.2s ease',
                                background: 'linear-gradient(135deg, #2d3748, #1a202c)',
                                color: '#ffffff',
                                border: '2px solid #4a5568',
                                boxShadow: '0 4px 12px rgba(0,0,0,0.25)',
                                textAlign: 'center',
                              }}
                            >
                              SWAP
                            </div>
                          ) : (
                            // Normal state: WHITE
                            <div
                              style={{
                                width: '100%',
                                padding: '4px 0',
                                borderRadius: '12px',
                                fontSize: '10px',
                                fontWeight: 800,
                                letterSpacing: '0.5px',
                                textTransform: 'uppercase',
                                cursor: 'pointer',
                                transition: 'all 0.2s ease',
                                background: 'linear-gradient(135deg, #f0f0f0, #ffffff)',
                                color: '#1a202c',
                                border: '2px solid #cbd5e0',
                                boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
                                textAlign: 'center',
                              }}
                            >
                              WHITE
                            </div>
                          )}
                        </>
                      ) : (
                        // Guest in room: show static WHITE label
                        <div
                          style={{
                            width: '100%',
                            padding: '4px 0',
                            borderRadius: '12px',
                            fontSize: '10px',
                            fontWeight: 800,
                            letterSpacing: '0.5px',
                            textTransform: 'uppercase',
                            cursor: 'default',
                            background: 'linear-gradient(135deg, #f0f0f0, #ffffff)',
                            color: '#1a202c',
                            border: '2px solid #cbd5e0',
                            boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
                            textAlign: 'center',
                            opacity: 0.8,
                          }}
                        >
                          WHITE
                        </div>
                      )}
                    </>
                  )}

                  {/* Black player - show SWAP to white on hover */}
                  {blackPlayerId === player.id && (
                    <>
                      {canAssignPlayers ? (
                        // Host/local play: show interactive swap
                        <>
                          {hoveredBadge === player.id && clickCooldown !== player.id ? (
                            // Hover state: SWAP with white styling
                            <div
                              onClick={(e) => handleSwap(player.id, e)}
                              style={{
                                width: '100%',
                                padding: '4px 0',
                                borderRadius: '12px',
                                fontSize: '10px',
                                fontWeight: 800,
                                letterSpacing: '0.5px',
                                textTransform: 'uppercase',
                                cursor: 'pointer',
                                transition: 'all 0.2s ease',
                                background: 'linear-gradient(135deg, #f0f0f0, #ffffff)',
                                color: '#1a202c',
                                border: '2px solid #cbd5e0',
                                boxShadow: '0 4px 12px rgba(0,0,0,0.25)',
                                textAlign: 'center',
                              }}
                            >
                              SWAP
                            </div>
                          ) : (
                            // Normal state: BLACK
                            <div
                              style={{
                                width: '100%',
                                padding: '4px 0',
                                borderRadius: '12px',
                                fontSize: '10px',
                                fontWeight: 800,
                                letterSpacing: '0.5px',
                                textTransform: 'uppercase',
                                cursor: 'pointer',
                                transition: 'all 0.2s ease',
                                background: 'linear-gradient(135deg, #2d3748, #1a202c)',
                                color: '#ffffff',
                                border: '2px solid #4a5568',
                                boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
                                textAlign: 'center',
                              }}
                            >
                              BLACK
                            </div>
                          )}
                        </>
                      ) : (
                        // Guest in room: show static BLACK label
                        <div
                          style={{
                            width: '100%',
                            padding: '4px 0',
                            borderRadius: '12px',
                            fontSize: '10px',
                            fontWeight: 800,
                            letterSpacing: '0.5px',
                            textTransform: 'uppercase',
                            cursor: 'default',
                            background: 'linear-gradient(135deg, #2d3748, #1a202c)',
                            color: '#ffffff',
                            border: '2px solid #4a5568',
                            boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
                            textAlign: 'center',
                            opacity: 0.8,
                          }}
                        >
                          BLACK
                        </div>
                      )}
                    </>
                  )}
                </div>
              )}
            </div>
          </PlayerTooltip>
        )
      })}
 
      {/* Animation styles */}
      <style
        dangerouslySetInnerHTML={{
          __html: `
            @keyframes avatarFloat {
              0%, 100% {
                transform: scale(1.1) translateY(0px);
              }
              50% {
                transform: scale(1.1) translateY(-6px);
              }
            }
 
            @keyframes borderPulse {
              0%, 100% {
                opacity: 1;
                box-shadow: 0 0 0 2px white, 0 0 20px currentColor;
              }
              50% {
                opacity: 0.8;
                box-shadow: 0 0 0 2px white, 0 0 30px currentColor;
              }
            }
 
            @keyframes streakPulse {
              0%, 100% {
                transform: scale(1);
                opacity: 1;
              }
              50% {
                transform: scale(1.2);
                opacity: 0.8;
              }
            }
 
            @keyframes turnBadgePulse {
              0%, 100% {
                transform: scale(1);
                box-shadow: 0 4px 12px currentColor;
              }
              50% {
                transform: scale(1.15);
                box-shadow: 0 6px 20px currentColor;
              }
            }
          `,
        }}
      />
    </>
  )
}