:root {
  --profile-bg: #03070f;
  --profile-card: rgba(8, 14, 27, .82);
  --profile-card-hover: rgba(12, 21, 39, .94);
  --profile-border: rgba(88, 151, 255, .22);
  --profile-text: #f4f7ff;
  --profile-muted: #94a3b8;
  --profile-blue: #28b9ff;
  --profile-purple: #a855f7;
  --profile-orange: #ff7a00;
  --profile-green: #55e878;
  --profile-yellow: #ffc83d;
}

.profile-body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 10%, rgba(40, 185, 255, .16), transparent 32rem),
    radial-gradient(circle at 86% 18%, rgba(168, 85, 247, .13), transparent 30rem),
    #02050c;
  color: var(--profile-text);
}

.profile-page-shell {
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 30px 16px 54px;
  box-sizing: border-box;
}

.profile-panel {
  min-width: 0;
  background: linear-gradient(145deg, rgba(13, 22, 40, .88), rgba(3, 8, 18, .94));
  border: 1px solid rgba(92, 145, 255, .18);
  border-radius: 18px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .025);
}

.profile-hero {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 20px;
  border-radius: 28px;
  overflow: hidden;
}

.profile-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.profile-hero > * {
  position: relative;
}

.profile-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(180px, .55fr) minmax(180px, .55fr);
  gap: 18px;
  align-items: stretch;
}

.profile-identity-card {
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 238px;
  padding: 26px;
}

.profile-avatar-ring {
  flex: 0 0 auto;
  width: 176px;
  height: 176px;
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(40, 185, 255, .38), 0 0 48px rgba(168, 85, 247, .2);
}

.profile-hero-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  border: 2px solid rgba(40, 185, 255, .65);
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.profile-name-row h1 {
  margin: 0;
  font-size: clamp(1.85rem, 4vw, 3rem);
  line-height: 1;
  font-weight: 900;
  font-family: "Figtree", sans-serif;
  text-transform: uppercase;
}

.profile-rank-pill.xp-rank-badge {
  min-height: 18px;
  padding: 3px 8px;
  font-size: 9px;
  letter-spacing: .05em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 4px 12px rgba(0,0,0,.18);
}

.profile-level-layout {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  margin-top: 24px;
}

.profile-level-badge {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0 50%);
  background: linear-gradient(145deg, rgba(40, 185, 255, .22), rgba(50, 88, 255, .14));
  border: 1px solid rgba(40, 185, 255, .55);
}

.profile-level-badge strong {
  font-size: 30px;
  line-height: 1;
}

.profile-level-badge span {
  text-transform: uppercase;
  font-size: 9px;
  color: #9ddcff;
  font-weight: 900;
}

.profile-xp-topline {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: #b9c6dd;
}

.profile-xp-topline strong {
  color: #fff;
}

.profile-xp-track {
  height: 18px;
  margin: 10px 0;
  border: 1px solid rgba(93, 148, 255, .4);
  border-radius: 999px;
  background: rgba(0, 0, 0, .36);
  overflow: hidden;
}

.profile-xp-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--profile-blue), #47e3ff);
  box-shadow: 0 0 18px rgba(40, 185, 255, .55);
}

.profile-xp-block p {
  margin: 0;
  color: #b9c6dd;
}

.profile-xp-block p strong {
  color: var(--profile-blue);
}

.profile-feature-card {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  min-height: 218px;
}

.profile-card-kicker,
.profile-badges-card h2 {
  margin: 0;
  color: #f091ff;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 13px;
  font-weight: 900;
}

.profile-card-kicker {
  margin: 0 0 12px;
}

.profile-feature-card.cyan .profile-card-kicker {
  color: #69f4ff;
}

.profile-feature-card img {
  width: min(132px, 68%);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 0 22px rgba(168, 85, 247, .3));
}

.profile-feature-card strong {
  font-size: 17px;
}

.profile-feature-card small,
.profile-stat-card small,
.profile-global-card small,
.profile-global-card em {
  color: var(--profile-muted);
  font-style: normal;
}

.profile-stats-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 182px;
  gap: 18px;
}

.profile-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  padding: 14px;
}

.profile-stat-card {
  display: grid;
  gap: 0px 14px;
  padding: 10px 14px;
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.profile-stat-card:last-child {
  border-right: 0;
}

.profile-stat-card > span {
  grid-row: 1 / 4;
  place-items: center;
  width: 58px;
  height: 58px;
  font-size: 46px;
}

.profile-stat-card strong {
  font-size: clamp(1.55rem, 2.4vw, 2.05rem);
  line-height: 1;
  padding: 10px 0 0;
}

.profile-stat-card strong small {
  font-size: 12px;
  text-transform: uppercase;
}

.profile-stat-card em {
  text-transform: uppercase;
  font-weight: 900;
  font-style: normal;
  font-size: 13px;
}

.profile-stat-card.blue em { color: var(--profile-blue); }
.profile-stat-card.yellow em { color: var(--profile-yellow); }
.profile-stat-card.green em { color: var(--profile-green); }
.profile-stat-card.orange em { color: var(--profile-orange); }

.profile-rate-card {
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
}

.profile-rate-ring {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--profile-purple) calc(var(--progress) * 1%), rgba(255, 255, 255, .08) 0);
  position: relative;
}

.profile-rate-ring::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: #090d19;
}

.profile-rate-ring > * {
  position: relative;
}

.profile-rate-ring strong {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  font-size: 30px;
  line-height: 1;
}

.profile-rate-ring small {
  font-size: 16px;
}

.profile-rate-ring span {
  display: block;
  margin-top: 6px;
  color: #c8d0e2;
}

.profile-showcase-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 238px;
  gap: 18px;
}

.profile-badges-card {
  padding: 20px 24px;
}

.profile-featured-badges {
  display: flex;
  gap: 18px;
  flex-wrap: nowrap;
  margin-top: 14px;
  padding-bottom: 4px;
}

.profile-featured-badges figure {
  flex: 0 0 112px;
  margin: 0;
  text-align: center;
  border-radius: 14px;
  padding: 8px;
  transition: transform .18s ease, background .18s ease;
}

.profile-featured-badges figure:hover,
.profile-featured-badges figure:focus-visible {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, .05);
  outline: 1px solid rgba(40, 185, 255, .38);
}

.profile-featured-badges img {
  width: 92px;
  max-width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(255, 122, 0, .24));
}

.profile-featured-badges figcaption {
  font-size: 12px;
  color: #d9e4ff;
}

.profile-global-card {
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 26px;
}

.profile-global-card > span {
  font-size: 36px;
}

.profile-global-card strong {
  font-size: 36px;
}

.achievements-table,
.scores-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background: linear-gradient(145deg, rgba(13, 22, 40, .88), rgba(3, 8, 18, .94));
  border-radius: 16px;
}

.achievements-table th,
.achievements-table td,
.scores-table th,
.scores-table td {
  padding: 13px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  text-align: left;
}

.achievements-table th,
.scores-table th {
  background: rgba(255, 255, 255, .04);
  color: #b8c3d9;
}

.achievement-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.achievement-badge {
  position: relative;
  display: inline-block;
}

.achievement-icon {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.achievement-icon.locked,
.achievement-popin img.locked {
  filter: grayscale(100%);
  opacity: .45;
}

.achievement-popin {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(.98);
  width: 200px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(10, 10, 10, .96);
  border: 1px solid #2a2a2a;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}

.achievement-badge:hover .achievement-popin,
.achievement-badge:focus-within .achievement-popin {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}

.achievement-popin img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  margin: 0 auto;
}

.achievement-popin h4,
.achievement-popin p {
  text-align: center;
}

.scores-table td:nth-child(2),
.scores-table td:nth-child(3) {
  font-variant-numeric: tabular-nums;
}

.edit-profile-btn {
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 10px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  display: inline-flex;
  background: rgba(255, 255, 255, .05);
}

@media (max-width: 980px) {
  .profile-hero-grid,
  .profile-stats-layout,
  .profile-showcase-row {
    grid-template-columns: 1fr;
  }

  .profile-hero-grid {
    grid-template-columns: 1fr 1fr;
  }

  .profile-identity-card {
    grid-column: 1 / -1;
  }

  .profile-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-stat-card:nth-child(2) {
    border-right: 0;
  }
}

@media (max-width: 640px) {
  .profile-page-shell {
    padding: 16px 10px 42px;
  }

  .profile-hero {
    padding: 10px;
    border-radius: 20px;
  }

  .profile-hero-grid {
    grid-template-columns: 1fr;
  }

  .profile-identity-card {
    flex-direction: column;
    text-align: center;
    padding: 20px 12px;
    gap: 18px;
  }

  .profile-avatar-ring {
    width: 132px;
    height: 132px;
  }

  .profile-name-row {
    justify-content: center;
  }

  .profile-level-layout {
    grid-template-columns: 1fr;
    margin-top: 18px;
  }

  .profile-level-badge {
    width: 82px;
    margin: 0 auto;
  }

  .profile-xp-topline {
    flex-direction: column;
    align-items: center;
    gap: 4px;
  }

  .profile-stat-grid {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .profile-stat-card {
    grid-template-columns: 48px minmax(0, 1fr);
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
  }

  .profile-stat-card > span {
    width: 48px;
    height: 48px;
    font-size: 23px;
  }

  .profile-rate-ring {
    width: 108px;
    height: 108px;
  }

  .profile-featured-badges {
    scroll-snap-type: x proximity;
  }

  .profile-featured-badges figure {
    min-width: 104px;
    scroll-snap-align: start;
  }

  .achievements-table,
  .scores-table {
    display: block;
    overflow-x: auto;
    font-size: 14px;
  }

  .achievement-popin {
    left: 0;
    transform: scale(.98);
  }

  .achievement-badge:hover .achievement-popin,
  .achievement-badge:focus-within .achievement-popin {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
