/* OBELIXPRO Font */
@font-face {
  font-family: 'OBELIXPRO';
  src: url('fonts/ObelixPro-cyr.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OBELIXPRO';
  src: url('fonts/ObelixProB-cyr.ttf') format('truetype');
  font-weight: bold;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'OBELIXPRO';
  src: url('fonts/ObelixProIt-cyr.ttf') format('truetype');
  font-weight: normal;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'OBELIXPRO';
  src: url('fonts/ObelixProBIt-cyr.ttf') format('truetype');
  font-weight: bold;
  font-style: italic;
  font-display: swap;
}

/* ==================
   AUTH & USER SYSTEM STYLES
   ================== */

/* Auth Screen */
* {
  font-family: 'OBELIXPRO', 'Comic Sans MS', cursive, sans-serif !important;
}

.auth-container {
  font-family: 'OBELIXPRO', 'Comic Sans MS', cursive, sans-serif;
  background: white;
  border-radius: 24px;
  padding: 3rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e5e7eb;
}

.auth-tab {
  flex: 1;
  padding: 1rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: #6b7280;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group input {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  transition: border-color 0.3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
}

.auth-error {
  color: #ef4444;
  font-size: 0.9rem;
  margin-top: 1rem;
  text-align: center;
}

.guest-option {
  text-align: center;
  margin-top: 1.5rem;
}

.text-button {
  background: none;
  border: none;
  color: #667eea;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: underline;
}

.text-button:hover {
  color: #764ba2;
}

/* User Header in Main Menu */
.user-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1.5rem 1.5rem 1.5rem;
  background: linear-gradient(to bottom, #08112a 0%, #0d1a3d 100%);
  border-radius: 0 0 16px 16px;
  margin-bottom: 2rem;
  box-shadow: 0 4px 15px rgba(13, 26, 61, 0.4);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.user-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: white;
  margin: 0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.user-stats-mini {
  display: flex;
  gap: 1rem;
}

.stat-mini {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.95rem;
  color: white;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.stat-icon {
  font-size: 1rem;
}

.user-actions {
  display: flex;
  gap: 0.5rem;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  font-size: 1.25rem;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  border: 2px solid white;
}

/* Profile, Friends, and Match History Screens - remove padding and center when active */
#profile-screen.active,
#friends-screen.active,
#match-history-screen.active {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Profile Screen */
.profile-container {
  background: linear-gradient(135deg, #08112a 0%, #060d25 40%, #04081a 80%, #020510 100%);
  border-radius: 24px;
  padding: 3rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 700px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow:
    0 0 20px rgba(59, 130, 246, 0.4),
    0 0 40px rgba(37, 99, 235, 0.3),
    0 0 60px rgba(29, 78, 216, 0.2);
}

.profile-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.15) 0%, transparent 20%),
    radial-gradient(circle at 80% 70%, rgba(37, 99, 235, 0.15) 0%, transparent 20%);
  pointer-events: none;
  z-index: 1;
}

.profile-container > * {
  position: relative;
  z-index: 2;
}

.close-button {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: #f3f4f6;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10;
}

.close-button:hover {
  background: #e5e7eb;
  transform: rotate(90deg);
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #e5e7eb;
}

.profile-avatar-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.profile-avatar-current {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.profile-info {
  flex: 1;
}

.profile-username {
  font-size: 2rem;
  color: #1f2937;
  margin-bottom: 0.5rem;
}

.profile-email {
  font-size: 1rem;
  color: #6b7280;
}

.secondary-button.small {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.profile-stat-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 1.5rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  transition: all 0.2s ease;
}

.profile-stat-card:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.98);
}

.profile-stat-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.profile-stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #60a5fa;
  margin-bottom: 0.25rem;
}

.profile-stat-label {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.profile-detailed-stats {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.5rem;
  border-radius: 12px;
}

.profile-detailed-stats h3 {
  font-size: 1.2rem;
  color: #f3f4f6;
  margin-bottom: 1rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-row .stat-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 1rem;
}

.stat-row .stat-value {
  color: #f3f4f6;
  font-weight: 600;
  font-size: 1rem;
}

/* Avatar Selector Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 3000;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: linear-gradient(135deg, #08112a 0%, #060d25 40%, #04081a 80%, #020510 100%);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 24px;
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4), 0 0 40px rgba(37, 99, 235, 0.3);
}

.modal-content h3 {
  font-size: 1.5rem;
  color: #f3f4f6;
  margin-bottom: 1.5rem;
  text-align: center;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.avatar-option {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.avatar-option:active {
  transform: scale(0.95);
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.2);
  box-shadow: 0 0 12px rgba(96, 165, 250, 0.4);
}

/* Friends Screen - Mobile First Design */
.friends-mobile-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #08112a 0%, #060d25 40%, #04081a 80%, #020510 100%);
  position: relative;
  overflow: hidden;
}

.friends-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
  flex-shrink: 0;
}

.friends-mobile-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f3f4f6;
  margin: 0;
}

.friends-close-btn {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #f3f4f6;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.friends-close-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}

.friends-mobile-tabs {
  display: flex;
  gap: 0;
  background: rgba(15, 23, 42, 0.4);
  padding: 0.5rem;
  flex-shrink: 0;
}

.friends-mobile-tab {
  flex: 1;
  padding: 0.75rem 0.5rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
}

.friends-mobile-tab.active {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.friends-mobile-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.friends-content {
  display: none;
  height: 100%;
}

.friends-content.active {
  display: flex;
  flex-direction: column;
}

.tab-badge {
  background: #ef4444;
  color: white;
  border-radius: 10px;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  min-width: 1.25rem;
  text-align: center;
}

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

.friend-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.friend-card:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.98);
}

.friend-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.friend-info {
  flex: 1;
  min-width: 0; /* Allow text truncation */
  overflow: hidden;
}

.friend-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f3f4f6;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-shadow: 0.5px 0.5px 1px rgba(0, 0, 0, 0.1);
}

.friend-level {
  font-size: 0.9rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.friend-status {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.friend-status.online {
  color: #10b981;
  font-weight: 600;
}

.friend-status.offline {
  color: #9ca3af;
}

.friend-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 70px;
}

.primary-button.small,
.secondary-button.small {
  padding: 0.5rem 0.875rem;
  font-size: 0.813rem;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border-radius: 8px;
}

.primary-button.small {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.secondary-button.small {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.empty-message {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  padding: 3rem 1.5rem;
  font-size: 0.95rem;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-friend-form {
  padding: 1.5rem;
}

.add-friend-form input {
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  margin-bottom: 1rem;
  transition: border-color 0.3s ease;
  background: rgba(255, 255, 255, 0.08);
  color: #f3f4f6;
}

.add-friend-form input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.add-friend-form input:focus {
  outline: none;
  border-color: #60a5fa;
  background: rgba(255, 255, 255, 0.12);
}

.add-friend-error {
  color: #f87171;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  text-align: center;
  padding: 0.75rem;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
}

.add-friend-success {
  color: #34d399;
  font-size: 0.875rem;
  margin-top: 0.5rem;
  text-align: center;
  padding: 0.75rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 8px;
}

/* User Search */
.user-search-section {
  position: relative;
  margin-bottom: 1rem;
}

.user-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  max-height: 300px;
  overflow-y: auto;
  backdrop-filter: blur(10px);
  z-index: 10;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 10;
  margin-top: 0.5rem;
}

.user-search-result {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background-color 0.2s ease;
  cursor: pointer;
}

.user-search-result:last-child {
  border-bottom: none;
}

.user-search-result:active {
  background-color: rgba(255, 255, 255, 0.08);
}

.user-search-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.user-search-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.user-search-name {
  font-weight: 600;
  font-size: 1rem;
  color: #f3f4f6;
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-search-meta {
  display: flex;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.875rem;
  color: #6b7280;
}

.user-search-status {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.user-search-level {
  color: #9ca3af;
}

.user-search-action {
  flex-shrink: 0;
}

.user-status-tag {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
}

.user-status-tag.friend {
  background-color: #d1fae5;
  color: #065f46;
}

.user-status-tag.pending {
  background-color: #fef3c7;
  color: #92400e;
}

.search-no-results {
  padding: 2rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.95rem;
}

/* Game Invitation Modal */
.modal-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.modal-buttons button {
  flex: 1;
}

#invitation-message {
  font-size: 1.1rem;
  color: #374151;
  text-align: center;
  padding: 1rem 0;
}

/* Sign-In Benefits Modal */
.benefits-modal {
  max-width: 550px;
}

.benefits-intro {
  font-size: 1rem;
  color: #6b7280;
  text-align: center;
  margin-bottom: 2rem;
}

.benefits-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.benefit-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.benefit-item:hover {
  background: #f3f4f6;
  transform: translateX(5px);
}

.benefit-icon {
  font-size: 2rem;
  flex-shrink: 0;
  line-height: 1;
}

.benefit-text {
  flex: 1;
}

.benefit-text strong {
  display: block;
  font-size: 1.1rem;
  color: #1f2937;
  margin-bottom: 0.25rem;
}

.benefit-text p {
  margin: 0;
  font-size: 0.95rem;
  color: #6b7280;
}

.play-now-button {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Mobile Responsive for User System */
@media (max-width: 768px) {
  .auth-container, .profile-container, .friends-container {
    padding: clamp(0.5rem, 1.5vh, 1rem);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .user-header {
    padding: 0 clamp(0.3rem, 1vh, 0.5rem) clamp(0.3rem, 1vh, 0.5rem) clamp(0.3rem, 1vh, 0.5rem);
    margin-bottom: clamp(0.3rem, 1vh, 0.5rem);
    gap: clamp(0.3rem, 1vh, 0.5rem);
    flex-shrink: 0;
    width: 100%;
    border-radius: 0 0 16px 16px;
    margin-left: 0;
    margin-right: 0;
  }

  .user-info {
    gap: clamp(0.3rem, 1vh, 0.5rem);
  }

  .user-avatar {
    width: clamp(30px, 6vh, 40px);
    height: clamp(30px, 6vh, 40px);
    font-size: clamp(1rem, 3vh, 1.3rem);
    flex-shrink: 0;
  }

  .user-name {
    font-size: clamp(0.8rem, 2.2vh, 1rem);
  }

  .user-stats-mini {
    gap: clamp(0.4rem, 1.5vh, 0.6rem);
  }

  .stat-mini {
    font-size: clamp(0.65rem, 1.8vh, 0.8rem);
  }

  .stat-icon {
    font-size: clamp(0.75rem, 2vh, 0.9rem);
  }

  .user-actions {
    gap: clamp(0.2rem, 0.8vh, 0.4rem);
  }

  .icon-button {
    width: clamp(28px, 5vh, 36px);
    height: clamp(28px, 5vh, 36px);
    font-size: clamp(0.9rem, 2.5vh, 1.1rem);
    flex-shrink: 0;
  }

  .close-button {
    top: clamp(0.5rem, 1.5vh, 1rem);
    right: clamp(0.5rem, 1.5vh, 1rem);
    width: clamp(32px, 5vh, 40px);
    height: clamp(32px, 5vh, 40px);
    font-size: clamp(1.2rem, 3vh, 1.5rem);
  }

  .profile-header {
    flex-direction: column;
    text-align: center;
    gap: clamp(0.5rem, 2vh, 1rem);
    margin-bottom: clamp(0.5rem, 2vh, 1rem);
    padding-bottom: clamp(0.5rem, 2vh, 1rem);
    flex-shrink: 0;
  }

  .profile-avatar-current {
    width: clamp(60px, 10vh, 80px);
    height: clamp(60px, 10vh, 80px);
    font-size: clamp(2rem, 5vh, 3rem);
  }

  .profile-username {
    font-size: clamp(1.3rem, 3.5vh, 1.8rem);
    margin-bottom: clamp(0.2rem, 0.8vh, 0.4rem);
  }

  .profile-email {
    font-size: clamp(0.8rem, 2vh, 1rem);
  }

  .secondary-button.small {
    padding: clamp(0.4rem, 1.2vh, 0.6rem) clamp(0.7rem, 2vh, 1rem);
    font-size: clamp(0.8rem, 2vh, 0.9rem);
  }

  .profile-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: clamp(0.4rem, 1.2vh, 0.6rem);
    margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
    flex-shrink: 0;
  }

  .profile-stat-card {
    padding: clamp(0.6rem, 1.8vh, 1rem);
  }

  .profile-stat-icon {
    font-size: clamp(1.2rem, 3vh, 1.6rem);
    margin-bottom: clamp(0.2rem, 0.8vh, 0.4rem);
  }

  .profile-stat-value {
    font-size: clamp(1.2rem, 3.2vh, 1.6rem);
    margin-bottom: clamp(0.1rem, 0.5vh, 0.25rem);
  }

  .profile-stat-label {
    font-size: clamp(0.7rem, 1.8vh, 0.85rem);
  }

  .profile-detailed-stats {
    padding: clamp(0.75rem, 2vh, 1.2rem);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .profile-detailed-stats h3 {
    font-size: clamp(1rem, 2.5vh, 1.2rem);
    margin-bottom: clamp(0.5rem, 1.5vh, 0.8rem);
  }

  .stat-row {
    padding: clamp(0.4rem, 1.2vh, 0.6rem) 0;
  }

  .stat-row .stat-label,
  .stat-row .stat-value {
    font-size: clamp(0.85rem, 2.2vh, 1rem);
  }

  .friends-tabs {
    flex-wrap: wrap;
  }

  .friends-tab {
    flex: 1 1 auto;
    min-width: 100px;
  }

  .friends-list {
    max-height: calc(100vh - 20rem);
    max-height: calc(100dvh - 20rem);
  }

  .friend-card {
    flex-direction: row;
    text-align: left;
  }

  .friend-actions {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .friend-actions button {
    width: auto;
    flex: 1;
    min-width: 80px;
  }
}

/* Match History Screen - Mobile First Design */
.match-history-mobile-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #08112a 0%, #060d25 40%, #04081a 80%, #020510 100%);
  position: relative;
  overflow: hidden;
}

.match-history-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
  flex-shrink: 0;
}

.match-history-mobile-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f3f4f6;
  margin: 0;
}

.match-history-close-btn {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #f3f4f6;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.match-history-close-btn:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.95);
}

.match-history-mobile-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.match-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.match-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  min-height: fit-content;
}

.match-card:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.98);
}

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem;
  min-height: 100px;
}

.match-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.match-mode {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: #f3f4f6;
}

.match-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  flex-wrap: wrap;
}

.match-date,
.match-topic {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.match-result {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  text-align: center;
  min-width: 100px;
}

.match-result.win {
  background: #d1fae5;
  color: #065f46;
}

.match-result.loss {
  background: #fee2e2;
  color: #991b1b;
}

.match-result.abandoned {
  background: #fef3c7;
  color: #92400e;
}

.match-result.in_progress {
  background: #dbeafe;
  color: #1e40af;
}

.match-stats {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.7);
  flex-wrap: wrap;
}

.match-stat {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.match-stat strong {
  color: #667eea;
}

.match-expand-icon {
  font-size: 1.25rem;
  transition: transform 0.3s ease;
  color: rgba(255, 255, 255, 0.5);
}

.match-card.expanded .match-expand-icon {
  transform: rotate(180deg);
}

.match-details {
  display: none;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.2);
}

.match-card.expanded .match-details {
  display: block;
}

.match-players-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f3f4f6;
  margin-bottom: 1rem;
}

.match-players-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.player-in-match {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.player-in-match:active {
  background: rgba(255, 255, 255, 0.08);
  transform: scale(0.98);
}

.player-placement {
  font-weight: 700;
  font-size: 1.1rem;
  color: #9ca3af;
  width: 30px;
  text-align: center;
}

.player-placement.first {
  color: #f59e0b;
}

.player-placement.second {
  color: #9ca3af;
}

.player-placement.third {
  color: #cd7f32;
}

.player-match-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.player-match-info {
  flex: 1;
  min-width: 0; /* Allow text truncation */
  overflow: hidden;
}

.player-match-name {
  font-weight: 600;
  color: #f3f4f6;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-match-level {
  font-size: 0.75rem;
  color: #667eea;
  font-weight: 500;
  margin-top: 2px;
}

.player-match-score {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.player-match-bot {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}

.add-friend-btn {
  padding: 0.5rem 1rem;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.add-friend-btn:hover {
  background: #5a67d8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Desktop: Better spacing for match history */
@media (min-width: 769px) {
  .match-history-container {
    max-height: 90vh;
    max-height: 90dvh;
  }

  .match-history-list {
    max-height: calc(90vh - 12rem);
    max-height: calc(90dvh - 12rem);
    min-height: 400px;
  }

  .match-card {
    font-size: 1rem;
  }

  .match-info {
    gap: 0.75rem;
  }

  .match-mode {
    font-size: 1.15rem;
  }

  .match-meta, .match-stats {
    font-size: 1rem;
  }

  .match-details {
    font-size: 1rem;
  }

  .player-match-info {
    font-size: 1rem;
  }
}

/* Mobile Responsive for Match History */
@media (max-width: 768px) {
  .match-history-container {
    padding: 1.5rem 1rem;
    max-height: calc(100vh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
  }

  .match-history-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
  }

  .match-history-list {
    max-height: calc(100vh - 10rem);
    max-height: calc(100dvh - 10rem);
  }

  .match-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
  }

  .match-mode {
    font-size: 1rem;
  }

  .match-meta {
    font-size: 0.85rem;
    gap: 0.75rem;
  }

  .match-stats {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .match-result {
    align-self: flex-start;
    min-width: 90px;
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
  }

  .match-details {
    padding: 1rem;
  }

  .player-in-match {
    padding: 0.6rem;
    gap: 0.75rem;
  }

  .player-match-avatar {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .player-match-name {
    font-size: 0.95rem;
  }

  .add-friend-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }
}

/* Guest Sign-In Button */
.guest-signin-button {
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.guest-signin-button:hover {
  border-color: #667eea;
  background: #f9fafb;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(102, 126, 234, 0.2);
}

.guest-signin-button svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}

/* ==================
   GLOBAL CHAT PROFILE FEATURE
   ================== */

/* Clickable avatars in global chat */
.global-chat-avatar.clickable {
  cursor: pointer;
  transition: all 0.3s ease;
}

.global-chat-avatar.clickable:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  filter: brightness(1.1);
}

/* User Profile Modal from Chat */
.user-profile-modal {
  max-width: 500px;
}

.user-profile-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid #e5e7eb;
}

.user-profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

#chat-user-username {
  font-size: 1.8rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  text-align: center;
}

.user-profile-level {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.level-badge {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.user-profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.user-profile-stat {
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  padding: 1.5rem;
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s ease;
}

.user-profile-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-profile-stat .stat-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: block;
}

.user-profile-stat .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 0.25rem;
  display: block;
}

.user-profile-stat .stat-label {
  font-size: 0.85rem;
  color: #6b7280;
  display: block;
}

.user-profile-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.friend-status-message {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  padding: 0.75rem;
  border-radius: 8px;
  min-height: 1.5rem;
}

/* Mobile Responsive for Chat User Profile */
@media (max-width: 768px) {
  .user-profile-modal {
    max-width: 90vw;
    padding: 1.5rem;
  }

  .user-profile-avatar {
    width: 80px;
    height: 80px;
    font-size: 2.5rem;
  }

  #chat-user-username {
    font-size: 1.5rem;
  }

  .level-badge {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
  }

  .user-profile-stats-grid {
    gap: 0.75rem;
  }

  .user-profile-stat {
    padding: 1rem;
  }

  .user-profile-stat .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.35rem;
  }

  .user-profile-stat .stat-value {
    font-size: 1.5rem;
  }

  .user-profile-stat .stat-label {
    font-size: 0.75rem;
  }

  .friend-status-message {
    font-size: 0.9rem;
    padding: 0.6rem;
  }
}

/* ==================== */
/* Topic Selection Mobile Container */
/* ==================== */

.topic-mobile-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #08112a 0%, #060d25 40%, #04081a 80%, #020510 100%);
  position: relative;
  overflow: hidden;
}

.topic-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
  flex-shrink: 0;
}

.topic-mobile-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f3f4f6;
  margin: 0;
}

.topic-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.topic-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.topic-mobile-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

.topic-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  cursor: pointer;
}

.topic-card:hover {
  background: rgba(96, 165, 250, 0.1);
  border-color: rgba(96, 165, 250, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.2);
}

.topic-card:active {
  transform: translateY(0);
}

.topic-icon {
  font-size: 2rem;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topic-info {
  flex: 1;
}

.topic-name {
  font-size: 1.125rem;
  font-weight: 600;
  color: #f3f4f6;
  margin: 0 0 0.25rem 0;
}

.topic-description {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

.topic-arrow {
  font-size: 1.25rem;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

.empty-message {
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  padding: 2rem 1rem;
  font-size: 0.9375rem;
}

/* ==================== */
/* Queue/Matchmaking Mobile Container */
/* ==================== */

.queue-mobile-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #08112a 0%, #060d25 40%, #04081a 80%, #020510 100%);
  position: relative;
  overflow: hidden;
}

.queue-mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(59, 130, 246, 0.2);
  flex-shrink: 0;
}

.queue-mobile-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f3f4f6;
  margin: 0;
}

.queue-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.queue-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.queue-mobile-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.queue-animation {
  margin-bottom: 2rem;
}

.spinner {
  width: 80px;
  height: 80px;
  border: 6px solid rgba(96, 165, 250, 0.2);
  border-top: 6px solid #60a5fa;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.queue-timer {
  font-size: 3rem;
  font-weight: 700;
  color: #60a5fa;
  margin-bottom: 2rem;
  text-align: center;
}

.queue-info-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 400px;
  margin-bottom: 2rem;
}

.queue-info-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.queue-info-label {
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.queue-info-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #f3f4f6;
  text-align: center;
}

.queue-actions {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.queue-actions .primary-button {
  width: 100%;
  padding: 1rem 2rem;
  font-size: 1.125rem;
}
