/* ===================================
   ChessDare – Profile Page Styles
   =================================== */

.profile-section {
  padding: calc(64px + var(--space-3xl)) 0 var(--space-3xl);
  min-height: 100vh;
}

/* ── Not Found ── */
.profile-not-found {
  text-align: center;
  padding: var(--space-3xl) 0;
  animation: fadeInUp 0.5s ease;
}

.not-found-icon {
  font-size: 4rem;
  margin-bottom: var(--space-md);
  opacity: 0.8;
}

.profile-not-found h1 {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

.profile-not-found p {
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-xl);
}

/* ── Profile Header Card ── */
.profile-card {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  box-shadow: var(--shadow-lg);
  animation: fadeInUp 0.5s ease;
  position: relative;
  overflow: hidden;
}

/* Subtle glow behind card */
.profile-card::before {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.15) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid rgba(160, 160, 184, 0.1);
  position: relative;
  z-index: 1;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 24px rgba(124, 58, 237, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.2);
  border: 3px solid var(--bg-card);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-letter-lg {
  color: white;
  font-size: var(--font-size-4xl);
  font-weight: 700;
}

.profile-info {
  flex: 1;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: 4px;
}

.profile-username {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin: 0;
}

.profile-rank-badge {
  font-size: var(--font-size-sm);
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rank-first {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.rank-second {
  background: rgba(156, 163, 175, 0.1);
  color: #d1d5db;
  border: 1px solid rgba(156, 163, 175, 0.3);
}

.rank-third {
  background: rgba(180, 83, 9, 0.1);
  color: #d97706;
  border: 1px solid rgba(180, 83, 9, 0.3);
}

.rank-default {
  background: rgba(160, 160, 184, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(160, 160, 184, 0.2);
}

.profile-own-badge {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-mid);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: var(--radius-full);
}

/* ── Partner Badge ── */
.profile-partner-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 12px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(234, 179, 8, 0.15));
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-full);
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.3);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
}

/* Override global a:hover / a:visited (accent link colors) — keep partner pill amber */
.profile-partner-badge:visited {
  color: #fbbf24;
}

.profile-partner-badge:hover {
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.55);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(234, 179, 8, 0.22));
}

.profile-partner-badge:active {
  color: #fde68a;
}

.profile-partner-badge:focus {
  outline: none;
}

.profile-partner-badge:focus-visible {
  color: #fcd34d;
  outline: 2px solid rgba(245, 158, 11, 0.65);
  outline-offset: 2px;
}

/* ── Partner Badge Picker ── */
.partner-badge-picker {
  margin-top: var(--space-sm);
}

.partner-choose-badge-btn {
  font-family: inherit;
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 4px 2px;
  margin: 0;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

.partner-choose-badge-btn:hover {
  color: var(--text-secondary);
  text-decoration: underline;
  text-decoration-color: rgba(160, 160, 184, 0.4);
  text-underline-offset: 3px;
}

.partner-choose-badge-btn:focus {
  outline: none;
}

.partner-choose-badge-btn:focus-visible {
  outline: 2px solid rgba(124, 58, 237, 0.45);
  outline-offset: 2px;
  border-radius: 2px;
}

.partner-badge-picker-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.partner-badge-current {
  font-size: 1.5rem;
  line-height: 1;
  padding: 4px 8px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-md);
}

.partner-remove-badge {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* ── Partner emoji modal (full picker) ── */
body.partner-emoji-modal-open {
  overflow: hidden;
}

.partner-emoji-modal[hidden] {
  display: none !important;
}

.partner-emoji-modal {
  position: fixed;
  inset: 0;
  /* Above navbar (200) and same stacking family as other profile overlays */
  z-index: calc(var(--z-modal) + 20);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  /* No paint here — avoids a full-screen solid slab; dimming lives on the backdrop */
  background: transparent;
}

.partner-emoji-modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(6, 6, 12, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.partner-emoji-modal-dialog {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  max-height: min(90vh, 560px);
  display: flex;
  flex-direction: column;
  background-color: #12121a;
  border: 1px solid rgba(80, 80, 110, 0.55);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  isolation: isolate;
}

.partner-emoji-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background-color: #12121a;
}

.partner-emoji-modal-title {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
}

.partner-emoji-modal-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.partner-emoji-modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.partner-emoji-modal-body {
  flex: 1;
  min-height: 0;
  padding: var(--space-sm);
  overflow: auto;
  background-color: #12121a;
}

.partner-emoji-modal-picker-shell {
  background-color: #12121a;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.partner-emoji-modal-body emoji-picker {
  display: block;
  width: 100%;
  height: min(420px, 70vh);
  background-color: #12121a;
  --background: #12121a;
  --border-color: #3d3d52;
  --border-radius: 0;
  --button-hover-background: #2c2c3d;
  --button-active-background: #38384a;
  --input-border-color: #5c5c72;
  --input-font-color: #ececf1;
  --input-placeholder-color: #9898a8;
  --input-font-size: 0.95rem;
  --category-font-color: #e4e4ea;
}

.profile-email {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  margin-bottom: var(--space-sm);
  margin-top: 0;
}

.profile-joined {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin-top: var(--space-sm);
}

/* ── Stats Grid ── */
.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-md);
  position: relative;
  z-index: 1;
}

.profile-stat-card {
  background: rgba(160, 160, 184, 0.04);
  border: 1px solid rgba(160, 160, 184, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  text-align: center;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 84px;
}

.profile-stat-card:hover {
  background: rgba(160, 160, 184, 0.08);
  transform: translateY(-2px);
}

.stat-elo {
  background: rgba(124, 58, 237, 0.06);
  border-color: rgba(124, 58, 237, 0.2);
}

.stat-elo:hover {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.3);
}

.profile-stat-value {
  display: block;
  font-size: var(--font-size-2xl);
  font-weight: 800;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.profile-stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.gradient-text {
  background: var(--gradient-accent-h);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-win {
  color: var(--color-success);
}

.stat-draw {
  color: var(--color-draw);
}

.stat-loss {
  color: var(--color-error);
}

/* ── Winrate Bar ── */
.winrate-section {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px dashed rgba(160, 160, 184, 0.1);
  position: relative;
  z-index: 1;
}

.winrate-bar {
  display: flex;
  height: 22px;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-sm);
  opacity: 0.95;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.winrate-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  transition: width 0.3s ease;
}

.winrate-win {
  background-color: #32a253;
}

.winrate-draw-bar {
  background-color: #9d9d9d;
}

.winrate-loss {
  background-color: #c93557;
}

.winrate-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-win {
  background: var(--color-success);
}

.legend-draw {
  background: var(--color-draw);
}

.legend-loss {
  background: var(--color-error);
}

/* ── Head-to-Head ── */
.h2h-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px dashed rgba(160, 160, 184, 0.1);
  position: relative;
  z-index: 1;
}

.h2h-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.h2h-header svg {
  color: var(--accent-mid);
  flex-shrink: 0;
}

.h2h-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.h2h-total {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(160, 160, 184, 0.08);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.h2h-scores {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
  margin-bottom: var(--space-md);
}

.h2h-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 60px;
}

.h2h-value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.h2h-wins .h2h-value {
  color: var(--color-success);
}

.h2h-draws-score .h2h-value {
  color: var(--text-muted);
}

.h2h-losses .h2h-value {
  color: var(--color-error);
}

.h2h-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.h2h-bar {
  display: flex;
  height: 6px;
  border-radius: var(--radius-full);
  overflow: hidden;
  gap: 2px;
}

.h2h-bar-fill {
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
  min-width: 3px;
}

.h2h-bar-you {
  background: var(--color-success);
}

.h2h-bar-them {
  background: var(--color-error);
}

/* ── History Section ── */
.history-section {
  margin-top: var(--space-4xl);
  animation: fadeInUp 0.5s ease 0.1s both;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  margin-top: var(--space-lg);
}

.history-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0;
}

.history-title svg {
  color: var(--accent-mid);
}

.history-count {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-weight: 500;
  background: rgba(160, 160, 184, 0.1);
  padding: 4px 12px;
  border-radius: var(--radius-full);
}

.history-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th {
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(124, 58, 237, 0.04);
  border-bottom: 1px solid var(--border-color);
}

.history-row {
  border-bottom: 1px solid rgba(160, 160, 184, 0.06);
  transition: background var(--transition-fast);
  animation: slideIn 0.3s ease var(--delay) both;
}

.history-row:hover {
  background: rgba(124, 58, 237, 0.03);
}

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

.history-table td {
  padding: var(--space-sm) var(--space-md);
  vertical-align: middle;
  white-space: nowrap;
}

.truncate-text {
  display: inline-block;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.td-challenge {
  max-width: 160px;
}

.challenge-pill {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.challenge-pill-custom {
  background: rgba(45, 212, 191, 0.1);
  color: #5eead4;
  border-color: rgba(45, 212, 191, 0.2);
}

a.challenge-pill-lab-link {
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}

a.challenge-pill-lab-link:hover {
  background: rgba(45, 212, 191, 0.16);
  border-color: rgba(45, 212, 191, 0.35);
  color: #99f6e4;
}

a.challenge-pill-lab-link:focus-visible {
  outline: 2px solid rgba(45, 212, 191, 0.55);
  outline-offset: 2px;
}

.game-type-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.game-type-pill-rated {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.game-type-pill-friendly {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

/* History Columns */
.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.color-dot.color-white {
  background: #e2e2e2;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.color-dot.color-black {
  background: #3a3a3a;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.result-win {
  color: var(--color-success);
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.result-draw {
  color: var(--color-draw);
  background: rgba(168, 162, 158, 0.1);
  border: 1px solid rgba(168, 162, 158, 0.2);
}

.result-loss {
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.result-abort {
  color: var(--text-muted);
  background: rgba(160, 160, 184, 0.1);
  border: 1px solid rgba(160, 160, 184, 0.2);
}

.opponent-link {
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.opponent-link:hover {
  color: var(--accent-mid);
}

.opponent-rating {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-left: 4px;
}

.td-elos {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.elo-before {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

.elo-arrow-sm {
  color: var(--text-muted);
  margin: 0 2px;
  font-size: var(--font-size-xs);
}

.elo-after {
  font-weight: 600;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.elo-delta-sm {
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
  padding: 1px 4px;
  border-radius: 4px;
}

.delta-up {
  color: var(--color-success);
  background: rgba(34, 197, 94, 0.1);
}

.delta-down {
  color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
}

.elo-no-change {
  color: var(--text-muted);
  margin-left: 8px;
}



.no-challenge {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.reason-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-style: italic;
}

.tc-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: 4px;
}

.td-date time {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

.td-actions {
  text-align: center;
  width: 36px;
}

.btn-view-game {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: color .15s, background .15s;
}

.btn-view-game:hover {
  color: var(--accent-mid);
  background: rgba(124, 58, 237, 0.12);
}

.history-empty {
  background: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4xl) var(--space-xl);
  text-align: center;
  padding-bottom: var(--space-xl);
}

.history-empty .empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.history-empty p {
  color: var(--text-secondary);
  font-size: var(--font-size-lg);
}

/* ── Animations ── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .profile-header {
    flex-direction: column;
    text-align: center;
    gap: var(--space-md);
  }

  .profile-name-row {
    flex-direction: column;
    justify-content: center;
  }

  .profile-joined {
    justify-content: center;
  }

  .profile-stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stat-elo {
    grid-column: 1 / -1;
  }

  .th-challenge,
  .td-challenge,
  .th-reason,
  .td-reason {
    display: none;
  }
}

@media (max-width: 480px) {
  .profile-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .history-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .th-tc,
  .td-tc {
    display: none;
  }
}

/* ── Load More ── */
.history-load-more {
  text-align: center;
  margin-top: var(--space-xl);
}

.history-load-more .btn {
  padding-left: var(--space-2xl);
  padding-right: var(--space-2xl);
}

/* ── Color Badge (merged into result) ── */

/* ── Profile Actions ── */
.profile-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

/* ── Follow Button ── */
.btn-follow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: transparent;
  color: var(--text-primary);
}

.btn-follow:hover {
  border-color: var(--accent-primary);
  background: rgba(124, 58, 237, 0.1);
}

.btn-follow .icon-following,
.btn-follow .following-text {
  display: none;
}

.btn-follow.following {
  border-color: var(--accent-primary);
  background: rgba(124, 58, 237, 0.15);
  color: var(--accent-primary);
}

.btn-follow.following .icon-follow,
.btn-follow.following .follow-text {
  display: none;
}

.btn-follow.following .icon-following,
.btn-follow.following .following-text {
  display: inline;
}

.btn-follow.following:hover {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.btn-follow.following:hover .following-text::after {
  content: ' ✕';
}

/* ── Challenge Button ── */
.btn-challenge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 700;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--gradient-accent);
  color: white;
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.35);
}

.btn-challenge:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(124, 58, 237, 0.45);
}

/* ── Modal Overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
  padding: var(--space-lg);
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(124, 58, 237, 0.2);
  transform: scale(.9);
  transition: transform var(--transition-base);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.visible .modal-card {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.modal-body {
  padding: var(--space-xl);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-lg) var(--space-xl);
  border-top: 1px solid var(--border-color);
}

.modal-actions .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ── Option buttons (reused from lobby) ── */
.panel-section {
  margin-bottom: var(--space-lg);
}

.panel-section:last-child {
  margin-bottom: 0;
}

.panel-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.option-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  font-family: var(--font-family);
  min-width: 90px;
}

.option-btn:hover {
  border-color: var(--border-color-hover);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
}

.option-btn.selected {
  border-color: var(--accent-start);
  background: rgba(124, 58, 237, 0.15);
  color: var(--text-primary);
  box-shadow: 0 0 12px rgba(124, 58, 237, 0.15);
}

.option-main {
  font-size: var(--font-size-base);
  font-weight: 700;
}

.option-sub {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.option-btn.selected .option-sub {
  color: var(--accent-mid);
}

/* ── Waiting Modal ── */
.modal-card-waiting {
  text-align: center;
  padding: var(--space-2xl) var(--space-xl);
}

.waiting-icon {
  margin-bottom: var(--space-lg);
}

.waiting-spinner-lg {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-mid);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}

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

.waiting-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  margin: 0 0 var(--space-sm);
}

.waiting-text {
  color: var(--text-secondary);
  font-size: var(--font-size-base);
  margin: 0 0 var(--space-xs);
}

.waiting-text strong {
  color: var(--accent-mid);
}

.waiting-subtext {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin: 0 0 var(--space-xl);
}

/* ── Match Overlay ── */
.match-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.match-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.match-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl) var(--space-3xl);
  text-align: center;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(124, 58, 237, 0.2);
  transform: scale(.9);
  transition: transform var(--transition-base);
}

.match-overlay.visible .match-card {
  transform: scale(1);
}

.match-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.match-title {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  margin-bottom: var(--space-sm);
  background: var(--gradient-accent-h);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.match-info {
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-lg);
}

.match-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.match-loader span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-mid);
  animation: matchBounce .6s ease-in-out infinite alternate;
}

.match-loader span:nth-child(2) { animation-delay: .2s; }
.match-loader span:nth-child(3) { animation-delay: .4s; }

@keyframes matchBounce {
  from { opacity: .3; transform: translateY(0); }
  to   { opacity: 1;  transform: translateY(-6px); }
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: calc(var(--z-modal) + 1);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn .3s ease;
  box-shadow: var(--shadow-md);
  max-width: 360px;
}

.toast-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

.toast-info {
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.4);
  color: #c4b5fd;
}

.toast.removing {
  animation: toastOut .25s ease forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(12px) scale(.95); }
}