/* ==========================================================================
   ELITECHESS - DEDICATED 1V1 MULTIPLAYER GAMEPLAY INTERFACE
   - Scope: Isolated to 1v1 PvP Live Multiplayer (#pvp-gameplay-container)
   - Mobile (<= 1023px): Dedicated ergonomic vertical stack with bottom toolbar
   - Desktop (>= 1024px): 2-Stage Master Arena matching reference UI (Left/Center Board Stage + Right Panel)
   - Luxury Dark Palette: Deep Obsidian / Royal Violet (#16151F, #1D1B27)
   ========================================================================== */

#pvp-gameplay-container {
  display: none !important;
}

.pvp-avatar-box {
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: #2D2A3B;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pvp-avatar-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* 1. Global Viewport Lock when 1v1 Multiplayer is Active */
body.pvp-gameplay-active {
  overflow: hidden !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  background: #16151F !important;
  color: #FFFFFF !important;
  touch-action: manipulation;
  margin: 0 !important;
  padding: 0 !important;
  user-select: none;
  -webkit-user-select: none;
}

body.pvp-gameplay-active .topbar,
body.pvp-gameplay-active .app-topbar,
body.pvp-gameplay-active .mobile-bottom-nav,
body.pvp-gameplay-active #app-mobile-nav,
body.pvp-gameplay-active .footer-container,
body.pvp-gameplay-active .site-footer,
body.pvp-gameplay-active .floating-theme-switch,
body.pvp-gameplay-active .scroll-to-top-btn,
body.pvp-gameplay-active #play-matchmaking-lobby,
body.pvp-gameplay-active #play-arena-game-container,
body.pvp-gameplay-active #play-tournament-waiting-room,
body.pvp-gameplay-active #bot-gameplay-container {
  display: none !important;
}

/* Base content reset */
body.pvp-gameplay-active .main-viewport,
body.pvp-gameplay-active .app-main-content,
body.pvp-gameplay-active #app-container,
body.pvp-gameplay-active #view-play,
body.pvp-gameplay-active.play-view-active.match-active #view-play,
body.pvp-gameplay-active.play-view-active.match-active .main-viewport,
body.pvp-gameplay-active.play-view-active.match-active .app-main-content,
body.pvp-gameplay-active .app-content-wrapper,
body.pvp-gameplay-active .app-main-layout {
  padding: 0 !important;
  margin: 0 !important;
  left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
  overflow: hidden !important;
  transform: none !important;
  animation: none !important;
  box-sizing: border-box !important;
  background: #16151F !important;
}

/* ==========================================================================
   2. MOBILE LAYOUT (<= 1023px) - Ergonomic Stacked Mobile Interface
   ========================================================================== */
@media (max-width: 959px) {
  body.pvp-gameplay-active .app-sidebar {
    display: none !important;
  }

  body.pvp-gameplay-active #pvp-gameplay-container {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    background: #14131A !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    justify-content: space-between !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 100 !important;
  }

  /* Hide Desktop-only panels on mobile */
  .pvp-desktop-panel {
    display: none !important;
  }

  /* Top Mobile Header */
  .pvp-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 12px !important;
    box-sizing: border-box !important;
    background: rgba(22, 21, 31, 0.95) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    flex-shrink: 0 !important;
    z-index: 20 !important;
  }

  .pvp-header-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #CBD5E1;
    cursor: pointer;
    padding: 0;
  }

  .pvp-header-btn:hover {
    color: #FFFFFF;
    background: rgba(255, 255, 255, 0.08);
  }

  .pvp-header-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    font-weight: 800;
    color: #FFFFFF;
  }

  .brand-crown {
    color: #D4AF37;
  }

  /* Horizontal Move History Strip on Mobile */
  .pvp-history-strip {
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    height: 32px !important;
    min-height: 32px !important;
    background: #1D1B27 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    padding: 0 10px !important;
    box-sizing: border-box !important;
    overflow-x: auto !important;
    flex-shrink: 0 !important;
    gap: 6px !important;
  }

  .pvp-moves-list {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    white-space: nowrap;
    overflow-x: auto;
  }

  .pvp-moves-empty {
    font-size: 0.78rem;
    color: #64748B;
  }

  .pvp-move-turn-group {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.8rem;
  }

  .pvp-move-turn-num {
    color: #64748B;
    font-weight: 700;
  }

  .pvp-move-btn {
    background: transparent;
    border: none;
    color: #E2E8F0;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 4px;
    cursor: pointer;
  }

  .pvp-move-btn.active {
    background: #3B82F6;
    color: #FFFFFF;
    font-weight: 800;
  }

  .pvp-board-stage {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 2px 0 !important;
    box-sizing: border-box !important;
    gap: 4px !important;
    overflow: hidden !important;
  }

  .pvp-board-side-tools {
    display: none !important;
  }

  .pvp-board-wrapper {
    width: 100% !important;
    max-width: min(100vw, calc(100dvh - 216px)) !important;
    max-height: min(100vw, calc(100dvh - 216px)) !important;
    aspect-ratio: 1 / 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    margin: 0 auto !important;
  }

  .pvp-board-frame {
    width: 100% !important;
    height: 100% !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: #1E1B29 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
  }

  /* Mobile Player Cards */
  .pvp-player-card {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    max-width: min(calc(100vw - 8px), calc(100dvh - 230px)) !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 4px !important;
    background: transparent !important;
    border: none !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
  }

  .pvp-spectator-pill {
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    color: #94A3B8;
    font-size: 0.72rem;
    font-weight: 700;
    margin-right: 4px;
    flex-shrink: 0;
  }

  #pvp-player-spectator-pill {
    display: none !important;
  }

  .pvp-player-info-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }

  .pvp-avatar-box {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    background: #2D2A3B;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .pvp-avatar-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .pvp-player-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .pvp-player-row-top {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.84rem;
    font-weight: 700;
  }

  .pvp-player-name {
    color: #FFFFFF;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 120px;
  }

  .pvp-player-class-badge {
    background: #3B82F6;
    color: #FFF;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 3px;
  }

  .pvp-player-rating {
    color: #94A3B8;
    font-size: 0.78rem;
  }

  .pvp-clock {
    background: #CBD5E1 !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 4px 10px !important;
    min-width: 78px !important;
    text-align: center !important;
    font-family: 'JetBrains Mono', monospace !important;
    font-variant-numeric: tabular-nums !important;
    font-size: 1.05rem !important;
    font-weight: 900 !important;
    color: #0E0D14 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
  }

  .pvp-clock.active {
    background: #FFFFFF !important;
    color: #0E0D14 !important;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.5) !important;
  }

  .pvp-clock.low-time {
    border-color: #E11D48;
    color: #E11D48;
    animation: pvpPulseTime 1s infinite alternate;
  }

  /* Mobile Bottom Controls Bar */
  .pvp-controls-bar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-around !important;
    width: 100% !important;
    height: calc(54px + env(safe-area-inset-bottom, 0px)) !important;
    min-height: 54px !important;
    background: #14131A !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    z-index: 350 !important;
    touch-action: manipulation !important;
  }

  .pvp-control-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #94A3B8;
    font-size: 0.68rem;
    font-weight: 600;
    gap: 3px;
    cursor: pointer;
    flex: 1;
    height: 100%;
    position: relative;
    touch-action: manipulation;
    transition: color 0.2s ease, background 0.2s ease;
  }

  .pvp-control-btn:hover {
    color: #FFFFFF;
  }

  /* Animated Chat to Cross Icon Morph on Mobile Bar */
  .pvp-chat-icon-morph {
    position: relative;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .pvp-chat-icon-morph .icon-chat-bubble,
  .pvp-chat-icon-morph .icon-chat-cross {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 20px;
    height: 20px;
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s ease, color 0.22s ease;
  }

  .pvp-chat-icon-morph .icon-chat-bubble {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }

  .pvp-chat-icon-morph .icon-chat-cross {
    opacity: 0;
    transform: rotate(90deg) scale(0.3);
    pointer-events: none;
  }

  /* Active Open State: morphs chat icon into red cross */
  #pvp-btn-chat.is-open .pvp-chat-icon-morph .icon-chat-bubble,
  #pvp-btn-chat.chat-open .pvp-chat-icon-morph .icon-chat-bubble {
    opacity: 0;
    transform: rotate(-90deg) scale(0.3);
    pointer-events: none;
  }

  #pvp-btn-chat.is-open .pvp-chat-icon-morph .icon-chat-cross,
  #pvp-btn-chat.chat-open .pvp-chat-icon-morph .icon-chat-cross {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    color: #F43F5E;
  }

  #pvp-btn-chat.is-open,
  #pvp-btn-chat.chat-open {
    color: #F43F5E !important;
  }

  #pvp-btn-chat.is-open .pvp-chat-btn-label,
  #pvp-btn-chat.chat-open .pvp-chat-btn-label {
    color: #F43F5E !important;
    font-weight: 700 !important;
  }

  .pvp-chat-badge {
    position: absolute;
    top: 4px;
    right: calc(50% - 20px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #10B981;
    color: #052E16;
    border-radius: 999px;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.45);
  }

  /* Slide-Up Mobile Chat Drawer */
  .pvp-chat-drawer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(54px + env(safe-area-inset-bottom, 0px)) !important;
    background: #16151F;
    z-index: 300;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.65);
  }

  .pvp-chat-drawer.open {
    transform: translateY(0);
  }

  .pvp-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1D1B27;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .pvp-chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #FFF;
  }

  .pvp-chat-close-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #94A3B8;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    touch-action: manipulation;
    flex-shrink: 0;
  }

  .pvp-chat-close-btn:hover {
    background: rgba(244, 63, 94, 0.18);
    border-color: rgba(244, 63, 94, 0.4);
    color: #F43F5E;
    transform: scale(1.08) rotate(90deg);
  }

  .pvp-chat-close-btn:active {
    transform: scale(0.92);
  }

  .pvp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .pvp-chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.35;
  }

  .pvp-chat-msg.self {
    align-self: flex-end;
    background: #059669;
    color: #FFF;
  }

  .pvp-chat-msg.opponent {
    align-self: flex-start;
    background: #262334;
    color: #E2E8F0;
  }

  .pvp-chat-input-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #14121E;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .pvp-chat-emoji-btn {
    width: 36px;
    height: 38px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: #221F2F;
    color: #E2E8F0;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .pvp-chat-emoji-btn.active,
  .pvp-chat-emoji-btn:hover {
    background: rgba(16, 185, 129, 0.16);
    border-color: rgba(16, 185, 129, 0.45);
  }

  .pvp-chat-input {
    flex: 1;
    height: 38px;
    background: #221F2F;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 0 12px;
    color: #FFF;
    font-size: 0.85rem;
  }

  .pvp-chat-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    border: none;
    background: #10B981;
    color: #FFF;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* ==========================================================================
   3. DESKTOP LAYOUT (>= 1024px) - Master Professional Chess Arena
   - Matches Target Reference Design
   ========================================================================== */
@media (min-width: 960px) {
  /* Slim Rail Sidebar (72px) */
  body.pvp-gameplay-active .app-sidebar {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: #12101A !important;
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
    z-index: 500 !important;
    flex-direction: column !important;
    padding: 16px 0 !important;
    box-sizing: border-box !important;
    align-items: center !important;
    justify-content: flex-start !important;
  }

  body.pvp-gameplay-active .app-sidebar .sidebar-brand {
    padding: 0 0 16px 0 !important;
    justify-content: center !important;
    width: 100% !important;
  }

  body.pvp-gameplay-active .app-sidebar .sidebar-brand-title {
    display: none !important;
  }

  body.pvp-gameplay-active .app-sidebar .sidebar-nav {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    align-items: center !important;
    width: 100% !important;
  }

  body.pvp-gameplay-active .app-sidebar .sidebar-btn {
    width: 48px !important;
    height: 48px !important;
    padding: 0 !important;
    justify-content: center !important;
    border-radius: 12px !important;
  }

  body.pvp-gameplay-active .app-sidebar .sidebar-btn span:not(.sidebar-icon) {
    display: none !important;
  }

  /* Offset main area for slim sidebar without compounding margin */
  body.pvp-gameplay-active .app-main-content,
  body.pvp-gameplay-active .main-viewport,
  body.pvp-gameplay-active #app-container,
  body.pvp-gameplay-active #view-play {
    position: fixed !important;
    top: 0 !important;
    left: 72px !important;
    right: 0 !important;
    bottom: 0 !important;
    width: calc(100vw - 72px) !important;
    max-width: calc(100vw - 72px) !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #16151F !important;
    overflow: hidden !important;
  }

  /* Master Gameplay Arena Container: EXACT 50/50 pixel-perfect centering */
  body.pvp-gameplay-active #pvp-gameplay-container {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: clamp(28px, 4vw, 56px) !important;
    width: 100% !important;
    max-width: 1240px !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 auto !important;
    padding: 16px 24px !important;
    box-sizing: border-box !important;
    background: transparent !important;
  }

  /* Hide mobile-specific elements on desktop */
  .pvp-header,
  .pvp-history-strip,
  .pvp-controls-bar,
  .pvp-chat-drawer {
    display: none !important;
  }

  /* Center Board Stage (Left Column) */
  .pvp-board-stage {
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 12px !important;
    width: min(72vh, 640px) !important;
    max-width: 640px !important;
    flex-shrink: 0 !important;
    position: relative !important;
  }

  .pvp-board-wrapper {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    width: 100% !important;
  }

  /* Floating Side Tools (+, -, ⌖) */
  .pvp-board-side-tools {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    position: absolute !important;
    left: -48px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: rgba(22, 20, 32, 0.88) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 20px !important;
    padding: 6px 4px !important;
    z-index: 25 !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4) !important;
  }

  .pvp-side-tool-btn {
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    color: #94A3B8 !important;
    font-size: 1.1rem !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    transition: all 0.15s ease !important;
  }

  .pvp-side-tool-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #FFFFFF !important;
  }

  /* Perfectly Square 1:1 Chessboard with 16px Rounded Outer Corners */
  .pvp-board-frame {
    width: min(72vh, 640px) !important;
    height: min(72vh, 640px) !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    background: #1E1B29 !important;
    box-shadow: 0 16px 44px rgba(0, 0, 0, 0.6) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    touch-action: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
  }

  /* Desktop Player Cards (Clean, Unboxed, Spacious) */
  .pvp-player-card {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    padding: 4px 6px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .pvp-player-info-left {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    min-width: 0 !important;
  }

  .pvp-avatar-box {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    background: #2A2738 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    border: 2px solid rgba(255, 255, 255, 0.12) !important;
  }

  .pvp-avatar-box img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  .pvp-player-meta {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    gap: 2px !important;
  }

  .pvp-player-row-top {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    font-size: 1rem !important;
    font-weight: 800 !important;
  }

  .pvp-player-name {
    color: #FFFFFF !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 200px !important;
    font-size: 1.05rem !important;
  }

  .pvp-player-class-badge {
    background: #3B82F6 !important;
    color: #FFF !important;
    font-size: 0.72rem !important;
    font-weight: 800 !important;
    padding: 2px 7px !important;
    border-radius: 5px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
  }

  .pvp-player-rating {
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 0.88rem !important;
    font-weight: 600 !important;
  }

  .pvp-player-card-right {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
  }

  .pvp-spectator-pill {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    font-size: 0.8rem !important;
    color: #94A3B8 !important;
    background: rgba(255, 255, 255, 0.05) !important;
    padding: 4px 8px !important;
    border-radius: 6px !important;
  }

  /* Clocks */
  .pvp-clock {
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 10px !important;
    padding: 7px 18px !important;
    min-width: 96px !important;
    text-align: center !important;
    font-family: 'SF Mono', 'Roboto Mono', 'JetBrains Mono', monospace !important;
    font-variant-numeric: tabular-nums !important;
    font-size: 1.25rem !important;
    font-weight: 800 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    letter-spacing: 0.5px !important;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease !important;
  }

  /* ACTIVE TURN CLOCK: HIGH-CONTRAST PURE WHITE PILL WITH BOLD BLACK TEXT */
  .pvp-clock.active,
  body.pvp-turn-your-turn .pvp-current-player-card .pvp-clock,
  body.pvp-turn-opp-turn .pvp-opponent-card .pvp-clock {
    background: #FFFFFF !important;
    color: #0E0D14 !important;
    border-color: #FFFFFF !important;
    font-weight: 900 !important;
    box-shadow: 0 0 14px rgba(255, 255, 255, 0.35) !important;
  }

  .pvp-clock.low-time {
    border-color: #E11D48 !important;
    color: #E11D48 !important;
    animation: pvpPulseTime 1s infinite alternate !important;
  }

  /* Right Desktop Panel (Transparent Wrapper Hosting 2 Floating Rounded Cards) */
  .pvp-desktop-panel {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    width: clamp(340px, 26vw, 390px) !important;
    height: min(84vh, 740px) !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    flex-shrink: 0 !important;
  }

  /* Card 1: Match Meta, Controls & Move History Table */
  .pvp-match-meta-card {
    background: #1B1926 !important;
    border-radius: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45) !important;
    padding: 16px 18px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    flex: 1 1 56% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  .pvp-match-meta-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
  }

  .pvp-match-meta-info {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
  }

  .pvp-match-meta-title {
    font-size: 0.95rem !important;
    font-weight: 800 !important;
    color: #FFFFFF !important;
  }

  .pvp-match-meta-sub {
    font-size: 0.76rem !important;
    color: #94A3B8 !important;
  }

  .pvp-meta-crest {
    width: 38px !important;
    height: 38px !important;
    background: rgba(16, 185, 129, 0.15) !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .pvp-match-meta-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .pvp-pill-btn {
    height: 38px !important;
    border-radius: 10px !important;
    font-size: 0.85rem !important;
    font-weight: 800 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: rgba(255, 255, 255, 0.08) !important;
    color: #FFFFFF !important;
  }

  .pvp-pill-btn:hover {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #FFF !important;
  }

  .pvp-pill-btn.danger {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.25) !important;
    color: #F87171 !important;
  }

  .pvp-pill-btn.danger:hover {
    background: #E11D48 !important;
    color: #FFF !important;
  }

  /* Move Navigation Toolbar */
  .pvp-nav-toolbar {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 6px 12px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border-radius: 10px !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    flex-shrink: 0 !important;
  }

  .pvp-nav-btn {
    width: 34px !important;
    height: 32px !important;
    border-radius: 8px !important;
    border: none !important;
    background: transparent !important;
    color: #94A3B8 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.12s ease !important;
  }

  .pvp-nav-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #FFFFFF !important;
  }

  .pvp-nav-btn:disabled {
    opacity: 0.35 !important;
    cursor: not-allowed !important;
  }

  /* 3-Column Move History Notation Table */
  .pvp-notation-container {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    background: transparent !important;
    border: none !important;
  }

  .pvp-notation-header {
    display: grid !important;
    grid-template-columns: 1fr 48px 1fr !important;
    padding: 6px 10px !important;
    font-size: 0.75rem !important;
    font-weight: 800 !important;
    color: #64748B !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    text-align: center !important;
    flex-shrink: 0 !important;
  }

  .pvp-desktop-notation-table {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 4px 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
  }

  .pvp-empty-notation {
    text-align: center !important;
    color: #64748B !important;
    font-size: 0.8rem !important;
    padding: 20px 0 !important;
  }

  .pvp-notation-row {
    display: grid !important;
    grid-template-columns: 1fr 48px 1fr !important;
    align-items: center !important;
    padding: 3px 0 !important;
    border-radius: 6px !important;
    text-align: center !important;
  }

  .pvp-notation-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.02) !important;
  }

  .pvp-notation-cell.move-num {
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    color: #64748B !important;
    font-family: 'SF Mono', monospace !important;
  }

  .pvp-ply-btn {
    border: none !important;
    background: transparent !important;
    color: #CBD5E1 !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    font-family: 'SF Mono', monospace !important;
    padding: 3px 8px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    transition: all 0.1s ease !important;
  }

  .pvp-ply-btn:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #FFF !important;
  }

  .pvp-ply-btn.active {
    background: rgba(255, 255, 255, 0.14) !important;
    color: #FFFFFF !important;
    font-weight: 800 !important;
  }

  /* Card 2: In-Game Chat Box */
  .pvp-desktop-chat-container {
    position: relative !important;
    background: #1B1926 !important;
    border-radius: 16px !important;
    border: 1px solid rgba(255, 255, 255, 0.07) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45) !important;
    padding: 14px 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    flex: 1 1 44% !important;
    min-height: 0 !important;
    overflow: visible !important;
  }

  .pvp-desktop-chat-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding-bottom: 8px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    flex-shrink: 0 !important;
  }

  .pvp-chat-card-title {
    font-size: 0.95rem !important;
    font-weight: 800 !important;
    color: #FFFFFF !important;
  }

  .pvp-chat-header-icons {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    color: #94A3B8 !important;
  }

  .pvp-desktop-chat-messages {
    flex: 1 1 auto !important;
    overflow-y: auto !important;
    padding: 6px 2px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
  }

  .pvp-chat-placeholder {
    color: #64748B !important;
    font-size: 0.78rem !important;
    text-align: center !important;
    padding: 20px 0 !important;
  }

  /* Speech Bubbles */
  .pvp-desktop-chat-msg {
    max-width: 82% !important;
    padding: 8px 12px !important;
    border-radius: 12px !important;
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
    word-break: break-word !important;
  }

  .pvp-desktop-chat-msg.self {
    align-self: flex-end !important;
    background: #143528 !important;
    color: #E2E8F0 !important;
    border-bottom-right-radius: 3px !important;
  }

  .pvp-desktop-chat-msg.opponent {
    align-self: flex-start !important;
    background: #252233 !important;
    color: #E2E8F0 !important;
    border-bottom-left-radius: 3px !important;
  }

  .pvp-desktop-chat-input-bar {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px !important;
    padding: 4px 6px 4px 12px !important;
    flex-shrink: 0 !important;
  }

  .pvp-desktop-chat-input-bar input {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    color: #FFFFFF !important;
    font-size: 0.85rem !important;
    outline: none !important;
    padding: 6px 0 !important;
  }

  .pvp-desktop-chat-emoji-btn,
  .pvp-desktop-send-btn {
    background: transparent !important;
    border: none !important;
    color: #94A3B8 !important;
    cursor: pointer !important;
    padding: 6px !important;
    border-radius: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.15s ease !important;
  }

  .pvp-desktop-send-btn {
    color: #10B981 !important;
  }

  .pvp-desktop-send-btn:hover {
    color: #34D399 !important;
  }

  .pvp-desktop-chat-emoji-btn:hover,
  .pvp-desktop-chat-emoji-btn.active {
    color: #FFFFFF !important;
    background: rgba(16, 185, 129, 0.16) !important;
  }

  .pvp-desktop-chat-sender {
    font-weight: 800;
    color: #34D399;
    margin-right: 4px;
  }

  .pvp-desktop-chat-msg.opponent .pvp-desktop-chat-sender {
    color: #FBBF24;
  }

  .pvp-pill-btn:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
  }
}
/* ==========================================================================
   4. MODALS & DIALOGS (Universal across Desktop & Mobile)
   ========================================================================== */
.pvp-modal-backdrop {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: rgba(0, 0, 0, 0.78) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  z-index: 999999 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.pvp-modal-backdrop.active,
.pvp-modal-backdrop.show {
  display: flex !important;
}

.pvp-modal-box {
  background: #1E1B29;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  padding: 20px;
  box-sizing: border-box;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: pvpModalPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pvpModalPop {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

.pvp-modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFFFFF;
  margin: 0;
  text-align: center;
}

.pvp-modal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pvp-modal-btn.primary {
  background: #10B981;
  color: #FFFFFF;
}

.pvp-modal-btn.primary:hover {
  background: #059669;
}

.pvp-modal-btn.danger {
  background: #DC2626;
  color: #FFFFFF;
}

.pvp-modal-btn.danger:hover {
  background: #EF4444;
}

.pvp-modal-btn.secondary {
  background: #2D2A3B;
  color: #E2E8F0;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pvp-modal-btn.secondary:hover {
  background: #3B384D;
  color: #FFFFFF;
}

@keyframes pvpPulseTime {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

/* History Review Banner & Status */
.pvp-review-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(27, 25, 38, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(245, 158, 11, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55), 0 0 14px rgba(245, 158, 11, 0.15);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 0.82rem;
  color: #F8FAFC;
  pointer-events: auto;
  white-space: nowrap;
  animation: pvpBannerPop 0.2s cubic-bezier(0.2, 0, 0, 1);
}

@keyframes pvpBannerPop {
  from {
    opacity: 0;
    transform: translate(-50%, -8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.pvp-review-info {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #F59E0B;
  font-weight: 600;
  font-family: inherit;
}

.pvp-review-live-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #F59E0B;
  color: #0F172A;
  border: none;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pvp-review-live-btn:hover {
  background: #FBBF24;
  transform: translateY(-1px);
}

.pvp-board-wrapper,
.bot-board-wrapper {
  position: relative !important;
}

/* Shared In-Game Chat Emoji Picker Popover & Delivery Feedback */
.pvp-emoji-popover {
  position: absolute;
  bottom: 58px;
  right: 12px;
  width: 248px;
  max-width: calc(100% - 24px);
  background: #1E1C2A;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.65);
  z-index: 420;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pvp-emoji-popover[hidden] {
  display: none !important;
}

.pvp-mobile-emoji-popover {
  left: 12px;
  right: auto;
  bottom: 64px;
}

.pvp-emoji-popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94A3B8;
  padding: 0 2px;
}

.pvp-emoji-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.pvp-emoji-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.pvp-emoji-choice:hover,
.pvp-emoji-choice:focus-visible {
  transform: scale(1.12);
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.45);
  outline: none;
}

.pvp-chat-msg-sender {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.85;
  margin-bottom: 2px;
}

.pvp-chat-msg-status {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  margin-top: 3px;
  color: #F87171;
}
