:root {
  --profile-bg: #05020f;
  --profile-panel: rgba(12, 4, 36, .88);
  --profile-panel-strong: rgba(16, 5, 46, .94);
  --profile-cyan: #41efff;
  --profile-pink: #f044d9;
  --profile-gold: #ffd660;
  --profile-text: #f8fbff;
  --profile-muted: rgba(231, 242, 255, .72);
  --profile-shape: polygon(24% 0, 76% 0, 100% 24%, 100% 76%, 76% 100%, 24% 100%, 0 76%, 0 24%);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }

a, button, .profile-icon-link, .profile-secondary-action {
  -webkit-user-select: none;
  user-select: none;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 15% 12%, rgba(65, 239, 255, .16), transparent 28%),
    radial-gradient(circle at 82% 16%, rgba(240, 68, 217, .14), transparent 30%),
    radial-gradient(circle at 50% 100%, rgba(129, 92, 255, .16), transparent 42%),
    var(--profile-bg);
  color: var(--profile-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body { overflow-x: hidden; }

.profile-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 0 0 34px;
}

/* ── Sticky header bar ───────────────────────────────────────────────── */
.profile-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 0 10px;
  pointer-events: none;
}

/* Full-viewport-width frosted backdrop behind the sticky bar —
   opacity is driven by --topbar-opacity (0 at top → 1 after scrolling ~120 px) */
.profile-topbar::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  background: rgba(5, 2, 15, .92);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  border-bottom: 1px solid rgba(65, 239, 255, .14);
  z-index: -1;
  opacity: var(--topbar-opacity, 0);
}

.profile-topbar-title {
  flex: 1;
  text-align: center;
  font-size: clamp(.86rem, 3.5vw, 1.05rem);
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--profile-text);
  text-shadow: 0 0 10px rgba(65, 239, 255, .22);
}

/* ── Nav icon buttons ────────────────────────────────────────────────── */
.profile-icon-link {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  clip-path: var(--profile-shape);
  background: linear-gradient(135deg, var(--profile-cyan), #815cff 52%, var(--profile-pink));
  box-shadow: 0 0 14px rgba(65, 239, 255, .16), 0 0 14px rgba(240, 68, 217, .12);
  pointer-events: auto;
}

.profile-icon-link::before {
  content: '';
  position: absolute;
  inset: 2px;
  clip-path: var(--profile-shape);
  background:
    radial-gradient(circle at 28% 18%, rgba(97, 246, 255, .35), transparent 42%),
    radial-gradient(circle at 80% 86%, rgba(255, 71, 222, .32), transparent 46%),
    linear-gradient(145deg, rgba(22, 9, 68, .98), rgba(8, 2, 30, .99));
}

.profile-icon-link { position: relative; }
.profile-icon-link img { position: relative; z-index: 1; width: 20px; height: 20px; }

.profile-hero {
  text-align: center;
  margin: clamp(12px, 5vh, 42px) auto 22px;
}

.profile-kicker,
.profile-copy,
.profile-since,
.profile-panel p,
.profileMeta {
  color: var(--profile-muted);
}

.profile-kicker {
  margin: 0 0 10px;
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.profile-hero h1 {
  margin: 0;
  font-size: clamp(3.2rem, 11vw, 6rem);
  line-height: .86;
  letter-spacing: -.05em;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255,255,255,.26), 0 0 24px rgba(65,239,255,.18);
}

.profile-copy {
  margin: 14px auto 0;
  max-width: 660px;
  line-height: 1.5;
}

.profile-panel {
  position: relative;
  /* Neon gradient ring — matches the Challenges paywall & leaderboard board */
  border: 1.5px solid transparent;
  border-radius: 28px;
  padding: clamp(18px, 3vw, 30px);
  background:
    linear-gradient(180deg, rgba(28,10,58,.94), rgba(8,2,28,.96)) padding-box,
    linear-gradient(135deg, #41efff 0%, #815cff 36%, #f044d9 68%, #4afcff 100%) border-box;
  box-shadow:
    0 0 28px rgba(42, 246, 255, .30),
    0 0 22px rgba(255, 71, 222, .20),
    inset 0 0 22px rgba(129,92,255,.11),
    0 24px 72px rgba(0,0,0,.54);
}

.profile-signin-panel,
.profile-loading-panel { text-align: center; max-width: 760px; margin: 0 auto; }
.profile-signin-panel h2,
.profile-loading-panel h2 { margin: 0 0 8px; font-size: clamp(2rem, 6vw, 3.8rem); }

.profile-loader-mark {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  color: var(--profile-cyan);
  filter: drop-shadow(0 0 18px rgba(65,239,255,.58));
  animation: profileLoaderPulse 1.2s ease-in-out infinite;
}

.profile-loader-mark img { width: 100%; height: 100%; }

@keyframes profileLoaderPulse {
  0%, 100% { transform: scale(.94); opacity: .72; }
  50% { transform: scale(1.04); opacity: 1; }
}

.profile-name-row button,
.profile-secondary-action {
  min-height: 48px;
  border: 1px solid rgba(65,239,255,.48);
  border-radius: 999px;
  color: var(--profile-text);
  background: linear-gradient(135deg, rgba(65,239,255,.18), rgba(240,68,217,.16));
  font-weight: 900;
  cursor: pointer;
}

.profile-identity-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: radial-gradient(circle, rgba(65,239,255,.34), rgba(240,68,217,.22) 58%, rgba(8,2,28,.95));
  border: 1px solid rgba(65,239,255,.5);
  font-weight: 950;
  letter-spacing: .04em;
}

.profile-identity-card h2 { margin: 0 0 6px; font-size: clamp(1.7rem, 5vw, 3rem); }
.profile-identity-card p { margin: 0; }

.profile-name-panel {
  margin-top: 20px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 20px;
  background: rgba(255,255,255,.045);
}

.profile-name-panel label {
  display: block;
  margin-bottom: 10px;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.profile-name-row { display: flex; gap: 10px; }
.profile-name-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(65,239,255,.38);
  border-radius: 999px;
  background: rgba(0,0,0,.28);
  color: var(--profile-text);
  font: inherit;
}

.profile-kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.profile-kpi-grid article {
  min-height: 108px;
  padding: 16px;
  border: 1px solid rgba(65,239,255,.24);
  border-radius: 20px;
  background: rgba(255,255,255,.045);
}

.profile-kpi-grid span {
  display: block;
  color: var(--profile-muted);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.profile-kpi-grid strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.55rem, 4vw, 2.4rem);
  line-height: .95;
}

.profile-since { margin: 14px 0 0; font-size: .95rem; }

.profile-wallet-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: center;
  margin-top: 22px;
  padding: 20px 22px;
  border: 1px solid rgba(255, 214, 96, .42);
  border-radius: 22px;
  background:
    radial-gradient(120% 150% at 0 0, rgba(255, 214, 96, .16), transparent 60%),
    rgba(255, 255, 255, .045);
}

.profile-wallet-balance {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.profile-wallet-coin {
  flex: none;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c4, var(--profile-gold) 46%, #c8922b);
  border: 1px solid rgba(255, 233, 160, .85);
  box-shadow: 0 0 18px rgba(255, 214, 96, .35), inset 0 -4px 8px rgba(140, 90, 10, .45);
}

.profile-wallet-label {
  display: block;
  color: var(--profile-muted);
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.profile-wallet-balance strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.9rem, 5vw, 2.7rem);
  line-height: .95;
  color: var(--profile-gold);
}

.profile-wallet-lifetime { text-align: right; }

.profile-wallet-lifetime strong {
  display: block;
  margin-top: 6px;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  line-height: .95;
}

.profile-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.profile-breakdown-card,
.profile-mode-stats-card {
  padding: 18px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 22px;
  background: rgba(255,255,255,.04);
}

.profile-breakdown-card h3,
.profile-mode-stats-card h3 { margin: 0 0 14px; }
.profile-bars { display: grid; gap: 12px; }
.profile-bar-label { display: flex; justify-content: space-between; gap: 10px; font-size: .86rem; color: var(--profile-muted); }
.profile-bar-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.profile-bar-fill { height: 100%; width: var(--pct); border-radius: inherit; background: linear-gradient(90deg, var(--profile-cyan), var(--profile-pink)); }

.profile-mode-stats-card { margin-top: 20px; }
.profile-mode-stats { display: grid; gap: 14px; }

.profile-mode-block {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 18px;
  overflow: hidden;
}

.profile-mode-block-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255,255,255,.07);
  font-weight: 900;
  font-size: .86rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--profile-text);
  border-bottom: 1px solid rgba(255,255,255,.09);
}

.profile-mode-h-legend {
  font-size: .72rem;
  font-weight: 900;
  color: var(--profile-cyan);
  letter-spacing: .12em;
  text-shadow: 0 0 8px rgba(65,239,255,.5);
}

.profile-mode-v-legend {
  font-size: .72rem;
  font-weight: 900;
  color: var(--profile-pink);
  letter-spacing: .12em;
  text-shadow: 0 0 8px rgba(240,68,217,.5);
}

.profile-mode-vs-stats {
  padding: 12px 16px;
  display: grid;
  gap: 14px;
}

.profile-vs-stat-row {
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: center;
  gap: 10px;
}

.profile-vs-h-val {
  font-size: .95rem;
  font-weight: 900;
  color: var(--profile-cyan);
  text-align: left;
  text-shadow: 0 0 10px rgba(65,239,255,.35);
}

.profile-vs-v-val {
  font-size: .95rem;
  font-weight: 900;
  color: var(--profile-pink);
  text-align: right;
  text-shadow: 0 0 10px rgba(240,68,217,.35);
}

.profile-vs-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}

.profile-vs-bar-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--profile-muted);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.profile-vs-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: rgba(255,255,255,.05);
}

.profile-vs-bar-h {
  height: 100%;
  flex-shrink: 0;
  background: linear-gradient(90deg, rgba(65,239,255,.95), rgba(65,239,255,.55));
}

.profile-vs-bar-v {
  height: 100%;
  flex: 1;
  background: linear-gradient(90deg, rgba(240,68,217,.55), rgba(240,68,217,.95));
}

.profile-message { min-height: 1.3em; color: var(--profile-gold); }

/* ── Store panel (Remove Ads) ───────────────────────────────────────────── */

.profile-store-panel {
  max-width: 560px;
  margin: 22px auto 0;
  text-align: center;
}

.profile-store-heading {
  margin: 0 0 8px;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
}

.profile-store-copy {
  margin: 0 0 22px;
}

.profile-store-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.profile-store-primary-btn {
  min-height: 54px;
  min-width: 220px;
  padding: 0 36px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--profile-cyan), #815cff 52%, var(--profile-pink));
  color: #fff;
  font: 900 1rem/1 inherit;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(65, 239, 255, .22), 0 0 24px rgba(240, 68, 217, .16);
  transition: opacity .18s, transform .12s;
}

.profile-store-primary-btn:hover  { opacity: .88; transform: translateY(-1px); }
.profile-store-primary-btn:active { opacity: 1; transform: translateY(0); }
.profile-store-primary-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.profile-store-primary-btn.purchased {
  background: linear-gradient(135deg, rgba(65,239,255,.18), rgba(129,92,255,.18));
  border: 1px solid rgba(65,239,255,.48);
  box-shadow: none;
}

.profile-store-restore-btn {
  min-width: 180px;
  padding: 0 24px;
  font-size: .88rem;
}

@media (max-width: 1100px) {
  .profile-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .profile-provider-grid,
  .profile-breakdown-grid { grid-template-columns: 1fr; }
  .profile-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .profile-shell { width: min(100% - 20px, 1180px); }
  .profile-identity-card { grid-template-columns: auto 1fr; }
  .profile-secondary-action { grid-column: 1 / -1; }
  .profile-name-row { flex-direction: column; }
  .profile-wallet-card { grid-template-columns: 1fr; }
  .profile-wallet-lifetime { text-align: left; }
}
