/* ============================================
   RITHM - Profile Page Styles
   ============================================ */

/* ── Layout ──────────────────────────── */

.profile-layout {
  padding: var(--space-6);
}

/* ── Profile Header ───────────────────── */

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-color);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  object-fit: cover;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
}

.profile-avatar--default {
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
}

.profile-info {
  flex: 1;
}

.profile-username {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.3px;
  margin-bottom: var(--space-1);
}

.profile-settings-link {
  color: var(--text-muted);
  font-size: 0.7em;
  margin-left: var(--space-2);
  text-decoration: none;
  transition: color var(--transition-fast);
  vertical-align: middle;
}

.profile-settings-link:hover {
  color: var(--color-primary);
}

.profile-meta {
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  gap: var(--space-4);
  align-items: center;
  flex-wrap: wrap;
}

.profile-streak-badge,
.profile-achievement-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.profile-streak-badge {
  background: var(--surface-warning);
  color: var(--color-warning);
}

.profile-achievement-badge {
  background: var(--surface-primary);
  color: var(--color-primary);
}

.profile-pro-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(94, 106, 210, 0.15);
  border: 1px solid rgba(94, 106, 210, 0.4);
  border-radius: 12px;
  color: var(--color-primary-light);
  font-size: 0.75rem;
  font-weight: 600;
}

.profile-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-3);
}

/* ── Pending Requests ─────────────────── */

.pending-requests-section {
  background: var(--surface-alpha);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-6);
}

.pending-requests-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pending-request-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.pending-request-card:hover {
  border-color: var(--border-hover);
  background: var(--surface-alpha);
}

.pending-request-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  min-width: 0;
}

.pending-request-actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ── Tab Bar ──────────────────────────── */

.profile-tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-6);
}

.profile-tab {
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.profile-tab:hover {
  color: var(--text-primary);
}

.profile-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.profile-tab:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* ── Tab Content ──────────────────────── */

.profile-tab-content {}

/* ── Overview: Summary Stats Grid ─────── */

.profile-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.profile-stat-card {
  background: var(--surface-alpha);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
}

.profile-stat-card .profile-stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--color-primary);
}

.profile-stat-card .profile-stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ── Unified Section Pattern ──────────── */

.profile-section {
  background: var(--surface-alpha);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.profile-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.profile-section-header h2 {
  font-size: 1.15rem;
  margin: 0;
}

.profile-section-header h2 i {
  margin-right: var(--space-2);
  color: var(--text-muted);
}

.profile-section-meta {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.profile-section-link {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.profile-section-link:hover {
  color: var(--color-primary-light);
}

.profile-section-link i {
  margin-left: var(--space-1);
  font-size: 0.75rem;
}

/* ── Game Stats ───────────────────────── */

.game-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-3);
}

.game-stats-section {
  background: var(--surface-alpha);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.game-stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.profile-stats-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-4);
}

.profile-stats-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
}

.game-stats-section.note .profile-stats-icon       { background: var(--color-primary); }
.game-stats-section.interval .profile-stats-icon    { background: #ec4899; }
.game-stats-section.chord .profile-stats-icon       { background: var(--color-success); }
.game-stats-section.pitch .profile-stats-icon       { background: var(--color-warning); }
.game-stats-section.scale .profile-stats-icon       { background: #5ba3c9; }
.game-stats-section.chordread .profile-stats-icon   { background: #8b5cf6; }
.game-stats-section.duration .profile-stats-icon    { background: var(--color-danger); }
.game-stats-section.scale_reading .profile-stats-icon { background: #b89040; }
.game-stats-section.duration_read .profile-stats-icon { background: #8a6a4a; }

.profile-stats-card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* ── Difficulty Tabs ──────────────────── */

.difficulty-tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.difficulty-tab {
  padding: 8px 12px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all var(--transition-fast);
}

.difficulty-tab:hover {
  border-color: var(--color-primary);
  color: var(--text-primary);
}

.difficulty-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.difficulty-tab:focus-visible {
  box-shadow: var(--shadow-focus);
  outline: none;
  border-color: var(--color-primary);
}

.difficulty-tab i {
  margin-right: 3px;
  font-size: 0.7rem;
}

.profile-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.profile-stat-item {
  text-align: center;
  padding: var(--space-3);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}

.profile-stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-stat-value.highlight {
  color: var(--color-primary);
}

.profile-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-1);
}

/* ── Progress Dashboard ───────────────── */

.progress-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.progress-select {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.progress-select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

.progress-select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.chart-container {
  position: relative;
  width: 100%;
  min-height: 300px;
}

.chart-container canvas {
  width: 100%;
  height: 300px;
}

.chart-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  color: var(--text-secondary);
  text-align: center;
}

.chart-empty i {
  font-size: 2.5rem;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.chart-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

.analytics-pro-cta {
  margin: var(--space-4) 0 0;
  padding: 10px 14px;
  border-top: 1px dashed var(--border-color);
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-align: center;
}

.analytics-pro-cta .fa-lock {
  color: var(--text-muted);
  margin-right: 6px;
}

.analytics-pro-cta a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
  margin-left: 4px;
}

.analytics-pro-cta a:hover {
  text-decoration: underline;
}

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

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-separator {
  width: 1px;
  height: 16px;
  background: var(--border-color);
  margin: 0 var(--space-1);
}

.legend-item svg {
  vertical-align: middle;
}

/* ── Score History ────────────────────── */

.score-history-section .chart-container {
  min-height: 280px;
}

.score-history-legend {
  display: flex;
  justify-content: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.score-history-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-history-legend-line {
  width: 22px;
  height: 2px;
  border-radius: 1px;
}

.score-history-legend-line--dashed {
  background: repeating-linear-gradient(
    to right,
    currentColor 0,
    currentColor 5px,
    transparent 5px,
    transparent 9px
  );
}

/* ── Achievements ─────────────────────── */

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--surface-alpha);
  transition: border-color var(--transition-fast);
}

.achievement-card.earned {
  border-color: rgba(94, 106, 210, 0.3);
}

.achievement-card.locked {
  border-color: var(--border-color);
  filter: grayscale(60%);
}

.achievement-card.locked .achievement-name,
.achievement-card.locked .achievement-desc {
  color: var(--text-muted);
}

.achievement-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-primary);
  font-size: 0.95rem;
}

.achievement-card.earned .achievement-icon {
  background: var(--color-primary);
  color: #fff;
}

.achievement-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: block;
}

.achievement-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
  line-height: 1.3;
}

/* ── Friends ──────────────────────────── */

.friends-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-3);
}

.friend-card {
  background: var(--surface-alpha);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.friend-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface);
}

.friend-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

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

.friend-online-badge {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-success);
  border: 2px solid var(--bg-surface);
}

.friend-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.friend-username {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.friend-status.online {
  color: var(--color-success);
}

.friends-online-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--color-success);
  font-weight: 500;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  display: inline-block;
}

.friends-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  color: var(--text-secondary);
  text-align: center;
}

.friends-empty i {
  font-size: 2rem;
  margin-bottom: var(--space-3);
  opacity: 0.4;
}

.friends-empty p {
  margin: 0;
  font-size: 0.9rem;
}

/* ── Lesson Progress (overview tab) ───── */

.lesson-overview {
  background: var(--surface-alpha);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.lesson-plan-overall {
  margin-bottom: var(--space-4);
}

.lesson-plan-overall-bar-wrap {
  height: 8px;
  background: var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.lesson-plan-overall-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  transition: width 0.4s ease;
}

.lesson-plan-overall-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.lesson-plan-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lesson-phase-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--space-3) 0 var(--space-1);
  margin: 0;
}

.lesson-phase-label:first-child {
  padding-top: 0;
}

.lesson-plan-week {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  text-decoration: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.lesson-plan-week:hover {
  border-color: var(--border-hover);
  background: var(--surface-alpha);
}

.lesson-plan-week.complete {
  border-color: rgba(34, 197, 94, 0.3);
}

.lesson-plan-week.current {
  border-left: 3px solid var(--color-primary);
  background: var(--surface-primary);
}

.lesson-plan-week-num {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-primary);
  flex-shrink: 0;
}

.lesson-plan-week.complete .lesson-plan-week-num {
  background: var(--color-success);
  color: #fff;
}

.lesson-plan-week-info {
  flex-grow: 1;
  min-width: 0;
}

.lesson-plan-week-title {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.lesson-plan-week-bar-wrap {
  height: 3px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.lesson-plan-week-bar {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.lesson-plan-week.complete .lesson-plan-week-bar {
  background: var(--color-success);
}

.lesson-plan-week-pct {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  white-space: nowrap;
}

/* ── Challenges ───────────────────────── */

.challenges-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.challenge-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--surface-alpha);
  flex-wrap: wrap;
}

.challenge-players {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.95rem;
}

.challenge-vs {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.85rem;
}

.challenge-details {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.challenge-scores {
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.challenge-status-label {
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.challenge-pending .challenge-status-label { background: var(--surface-warning); color: var(--color-warning); }
.challenge-completed .challenge-status-label { background: var(--surface-success); color: var(--color-success); }
.challenge-accepted .challenge-status-label { background: var(--surface-info); color: var(--color-info); }
.challenge-declined .challenge-status-label { background: var(--surface-danger); color: var(--color-danger); }

.challenge-expires {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.challenge-actions {
  display: flex;
  gap: var(--space-2);
}

.result-win { color: var(--color-success); font-weight: 600; }
.result-loss { color: var(--color-danger); font-weight: 600; }
.result-tie { color: var(--color-warning); font-weight: 600; }

/* ── Challenge Modal ──────────────────── */

.challenge-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.challenge-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 520px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.challenge-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-5);
}

.challenge-modal-header h3 { margin: 0; font-size: 1.1rem; color: var(--text-primary); }
.challenge-modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.5rem; cursor: pointer; padding: 0 var(--space-1); line-height: 1; transition: color var(--transition-fast); }
.challenge-modal-close:hover { color: var(--text-primary); }
.challenge-modal-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-2); }

.challenge-game-grid,
.challenge-difficulty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.challenge-option {
  padding: var(--space-3) var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.challenge-option i { display: block; font-size: 1.1rem; margin-bottom: var(--space-1); }
.challenge-option:hover { border-color: var(--color-primary-light); color: var(--text-primary); }
.challenge-option.selected { border-color: var(--color-primary); background: var(--surface-primary); color: var(--text-primary); }

.challenge-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ── Utility ──────────────────────────── */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── Responsive ───────────────────────── */

@media (max-width: 768px) {
  .profile-layout {
    padding: var(--space-4);
  }

  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

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

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

  .pending-request-card {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .pending-request-actions {
    justify-content: flex-end;
  }

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

  .profile-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .profile-tabs::-webkit-scrollbar {
    display: none;
  }
  .profile-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .achievements-grid {
    grid-template-columns: 1fr;
  }

  .game-stats-grid {
    grid-template-columns: 1fr;
  }

  .friends-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .challenge-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .challenge-game-grid,
  .challenge-difficulty-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .challenge-modal {
    width: 95%;
    padding: var(--space-4);
  }
}

@media (max-width: 480px) {
  .profile-layout {
    padding: var(--space-3);
  }

  .profile-stats-grid {
    grid-template-columns: 1fr;
  }

  .progress-controls {
    width: 100%;
  }

  .progress-select {
    flex: 1 1 100%;
    font-size: 1rem;
  }
}

/* ── Featured Badges (profile header) ──────────────────────── */

.profile-featured-badges {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}

.profile-featured-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: default;
}

/* ── Achievement card enhancements ──────────────────────────── */

.achievement-earned-date {
  font-size: 0.72rem;
  color: var(--color-primary);
  display: block;
  margin-top: 3px;
  font-weight: 500;
}

.achievement-progress-bar-wrap {
  height: 4px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  margin-top: var(--space-2);
  overflow: hidden;
}

.achievement-progress-bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.achievement-progress-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 3px;
}

.achievement-card[data-achievement-id] {
  cursor: pointer;
}

.achievement-card[data-achievement-id]:hover {
  border-color: rgba(94, 106, 210, 0.5);
}

.achievement-card.featured-selected {
  border-color: var(--color-primary);
  background: rgba(94, 106, 210, 0.08);
}

.achievement-card.featured-selected .achievement-icon {
  background: var(--color-primary);
  color: #fff;
}

/* ── Featured Badge Picker ───────────────────────────────────── */

.featured-badge-picker {
  background: var(--surface-alpha);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}

.featured-badge-picker-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.featured-badge-picker-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.featured-badge-picker-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.featured-badge-slots {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.featured-badge-slot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 120px;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-surface);
}

.featured-badge-slot i {
  color: var(--color-primary);
  width: 16px;
  text-align: center;
}

.featured-badge-slot span {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.featured-badge-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
  line-height: 1;
  margin-left: auto;
}

.featured-badge-remove:hover {
  color: var(--text-primary);
}

.featured-badge-picker-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Friend badge count ─────────────────────────────────────── */

.friend-badge-count {
  font-size: 0.72rem;
  color: var(--color-primary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 3px;
}

.friend-badge-count i {
  font-size: 0.65rem;
}

/* ── Public profile (/u/<username>/) ──────────────────────────────────────── */

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

.public-profile-top-games {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

.public-profile-top-game {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  background: var(--surface-alpha);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.public-profile-top-game:hover {
  border-color: var(--color-primary);
  transform: translateY(-1px);
}

.public-profile-top-game-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.public-profile-top-game-name {
  font-weight: 600;
  color: var(--text-primary);
}

.public-profile-top-game-stats {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.public-profile-cta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
}
