/* ══════════════════════════════════════════
   PROFILE.CSS — Profile, XP, Character Card, Level Up
   ══════════════════════════════════════════ */


/* ── PROFILE HERO V2 ── */
.profile-hero-v2 {
  display: flex; flex-direction: column; align-items: center;
  padding: 24px 16px 20px; margin-bottom: 16px;
  position: relative;
}

/* Username · Archetype title */
.profile-char-title {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; justify-content: center;
  margin-bottom: 20px;
}
.profile-username-display {
  font-size: 22px; font-weight: 900; letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--neon-cyan), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.profile-username-display {
  -webkit-text-fill-color: white !important;
  color: white;
}
.profile-title-dot {
  font-size: 18px; color: var(--text2); font-weight: 300;
  -webkit-text-fill-color: var(--text2);
}
.profile-archetype-display {
  font-size: 22px; font-weight: 900; letter-spacing: -0.5px;
  background: linear-gradient(90deg, var(--gold2), var(--gold), var(--neon-pink));
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: sweep 4s linear infinite;
}
@keyframes sweep { 0%{background-position:0%} 100%{background-position:200%} }

/* Portrait */
.profile-portrait-wrap {
  position: relative; margin-bottom: 14px;
}
.profile-portrait-glow {
  position: absolute; inset: -12px; border-radius: 30px;
  background: radial-gradient(ellipse, rgba(180,79,255,0.25) 0%, transparent 70%);
  z-index: 0;
  animation: portrait-pulse 3s ease-in-out infinite;
}
@keyframes portrait-pulse {
  0%,100% { opacity: 0.6; transform: scale(1); }
  50%      { opacity: 1;   transform: scale(1.03); }
}
.profile-portrait {
  width: 260px; height: 260px; border-radius: 22px;
  background: var(--surface); border: 2px solid var(--border);
  overflow: hidden; position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  transition: border-color 0.3s;
}
.profile-portrait.has-char {
  border-color: rgba(180,79,255,0.5);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 0 24px rgba(180,79,255,0.2);
}

/* Level badge */
.profile-level-badge {
  position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  color: #000; font-size: 12px; font-weight: 900;
  padding: 4px 14px; border-radius: 20px; z-index: 2;
  box-shadow: 0 0 14px rgba(255,215,0,0.4);
  white-space: nowrap;
}

/* Info row */
.profile-info-row {
  text-align: center; margin-top: 8px;
}
.profile-info-row .profile-email  { font-size: 12px; color: var(--text2); margin-bottom: 3px; }
.profile-info-row .profile-joined { font-size: 11px; color: var(--text2); }

/* ── PROFILE PAGE ── */
.profile-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 18px;
}

.profile-avatar {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent2), var(--neon-pink)) !important;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 800; color: white;
  flex-shrink: 0; border: 3px solid var(--border);
  box-shadow: 0 0 20px var(--accent-glow) !important;
  animation: avatar-glow 2s ease-in-out infinite !important;
}

.profile-info { flex: 1; min-width: 0; }
.profile-username {
  font-size: 20px; font-weight: 800; letter-spacing: -0.4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 3px;
}
.profile-email  { font-size: 13px; color: var(--text2); margin-bottom: 5px; }
.profile-joined { font-size: 12px; color: var(--text2); }

/* ── XP CARD ── */
.xp-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 18px 20px; margin-bottom: 12px;
}
.xp-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.xp-title { font-size: 14px; font-weight: 700; }
.xp-level {
  font-size: 12px; font-weight: 900 !important;
  background: linear-gradient(90deg, var(--gold2), var(--gold)) !important;
  color: #000 !important;
  padding: 2px 10px; border-radius: 20px;
  box-shadow: 0 0 14px var(--gold-glow) !important;
}
.xp-track {
  height: 12px !important; border-radius: 6px !important;
  background: var(--surface2) !important; border: 1px solid var(--border) !important;
  overflow: hidden;
}
.xp-fill {
  height: 100%; border-radius: 6px !important;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--neon-pink)) !important;
  background-size: 200% auto !important;
  animation: xp-shimmer 2s linear infinite !important;
  transition: width 0.8s cubic-bezier(0.34,1.56,0.64,1) !important;
}
@keyframes xp-shimmer { 0%{background-position:0%} 100%{background-position:200%} }
.xp-fill.gaining { box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(180,79,255,0.2) !important; }
.xp-sub { font-size: 12px; color: var(--text2); margin-top: 7px; }

/* ── STATS GRID ── */
.stats-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin-bottom: 12px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 10px; text-align: center;
}
.stat-num { font-size: 26px; font-weight: 800; color: var(--gold) !important; letter-spacing: -0.5px; filter: drop-shadow(0 0 8px var(--gold-glow)); }
.stat-lbl { font-size: 11px; color: var(--text2); margin-top: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }

.profile-section-label {
  font-size: 11px; font-weight: 700; color: var(--text2);
  letter-spacing: 0.8px; text-transform: uppercase;
  margin: 18px 0 8px 4px;
}

.profile-action {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 15px 18px; margin-bottom: 8px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: all 0.18s;
  width: 100%; text-align: left;
  color: var(--text); font-family: inherit; font-size: 15px;
}
.profile-action:hover { background: var(--surface2); }
.profile-action .pa-icon { font-size: 18px; }
.profile-action .pa-label { font-size: 15px; font-weight: 600; flex: 1; }
.profile-action .pa-arrow { color: var(--text2); font-size: 16px; }
.profile-action.danger { color: var(--red); }
.profile-action.danger .pa-arrow { color: rgba(239,68,68,0.5); }

/* ── CHANGE PW INLINE ── */
.change-pw-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px;
  margin-bottom: 8px; display: none;
  animation: fadeIn 0.2s ease;
}
.change-pw-box.open { display: block; }
.change-pw-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--text2); }

/* ── CHARACTER CARD ── */
.char-card {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 12px;
  border: 3px solid var(--gold);
  box-shadow: 0 0 30px var(--gold-glow), 0 0 60px rgba(255,215,0,0.1);
  animation: char-glow 2s ease-in-out infinite;
  background: var(--surface2);
}
@keyframes char-glow {
  0%,100% { box-shadow: 0 0 30px var(--gold-glow); }
  50%      { box-shadow: 0 0 50px var(--gold-glow), 0 0 80px rgba(255,215,0,0.2); }
}
#char-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.char-img-placeholder {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 48px; color: var(--text2);
  gap: 8px;
}
.char-img-placeholder span {
  font-size: 12px; color: var(--text2); font-weight: 600;
}

.hf-key-box {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-bottom: 12px;
}
.hf-key-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--text2); }
.hf-key-row { display: flex; gap: 8px; }
.hf-key-row input { flex: 1; }
.hf-key-row button {
  padding: 10px 14px; border-radius: 10px;
  background: var(--accent); color: white; border: none;
  font-size: 13px; font-weight: 700; cursor: pointer;
  font-family: inherit; white-space: nowrap;
}

/* ── XP POPUP TOAST ── */
.xp-toast {
  position: fixed; pointer-events: none; z-index: 8000;
  left: 50% !important;
  transform: translateX(-50%);
  font-size: clamp(48px, 12vw, 80px);
  font-weight: 900; letter-spacing: 2px;
  background: linear-gradient(135deg, var(--gold), var(--neon-pink), var(--neon-cyan), var(--gold));
  background-size: 300% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 20px var(--gold-glow)) drop-shadow(0 0 40px rgba(255,45,120,0.4));
  animation: xp-jackpot 2s cubic-bezier(0.34,1.56,0.64,1) forwards, neon-sweep 0.8s linear infinite;
  white-space: nowrap;
  text-align: center;
  width: 100vw;
}
@keyframes xp-jackpot {
  0%   { transform: translateX(-50%) translateY(40px) scale(0.2) rotate(-8deg); opacity: 0; }
  15%  { transform: translateX(-50%) translateY(-10px) scale(1.15) rotate(2deg); opacity: 1; }
  40%  { transform: translateX(-50%) translateY(-20px) scale(1.05) rotate(-1deg); opacity: 1; }
  75%  { transform: translateX(-50%) translateY(-30px) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-80px) scale(0.8) rotate(3deg); opacity: 0; }
}

/* ── LEVEL UP POPUP ── */
.levelup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  z-index: 9000; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(16px);
}
.levelup-overlay.show { display: flex; animation: overlay-in 0.3s ease; }
@keyframes overlay-in { from{opacity:0} to{opacity:1} }
.levelup-overlay.show .levelup-box { animation: reel-stop 0.6s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes reel-stop {
  0%   { transform: translateY(-60px) scale(0.7) rotateX(45deg); opacity: 0; }
  60%  { transform: translateY(8px) scale(1.04) rotateX(-3deg); opacity: 1; }
  100% { transform: translateY(0) scale(1) rotateX(0); opacity: 1; }
}
.levelup-box {
  background: var(--surface); border-radius: 28px; padding: 32px 24px;
  max-width: 360px; width: 90%; text-align: center;
  position: relative; overflow: hidden;
}
.levelup-box::before {
  content: ''; position: absolute; inset: -3px; border-radius: 31px; z-index: -1;
  background: linear-gradient(135deg, var(--gold), var(--neon-pink), var(--accent), var(--neon-cyan), var(--gold2), var(--gold));
  background-size: 400% 400%;
  animation: flame-border 1.5s ease infinite;
  filter: blur(2px);
}
.levelup-box::after {
  content: ''; position: absolute; inset: -3px; border-radius: 31px; z-index: -1;
  background: linear-gradient(135deg, var(--gold), var(--neon-pink), var(--accent), var(--neon-cyan), var(--gold));
  background-size: 400% 400%;
  animation: flame-border 1.5s ease infinite;
}
.levelup-glow {
  position: absolute; inset: 0; pointer-events: none; border-radius: 28px;
  background: radial-gradient(circle at 50% 30%, rgba(255,215,0,0.15), transparent 60%);
  animation: glow-pulse 1.5s ease-in-out infinite;
}
@keyframes glow-pulse { 0%,100%{opacity:0.6} 50%{opacity:1} }
.levelup-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(90deg, var(--gold2), var(--gold));
  color: #000; padding: 7px 20px; border-radius: 20px;
  font-size: 15px; font-weight: 900; margin-bottom: 16px;
  box-shadow: 0 0 30px var(--gold-glow); letter-spacing: 1px;
  animation: badge-slam 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.2s both,
             badge-pulse 1.2s ease-in-out 0.7s infinite;
}
@keyframes badge-slam { from{transform:scale(0) rotate(-15deg)} to{transform:scale(1) rotate(0)} }
@keyframes badge-pulse {
  0%,100% { box-shadow: 0 0 30px var(--gold-glow); }
  50%      { box-shadow: 0 0 60px var(--gold-glow), 0 0 90px rgba(255,215,0,0.2); }
}
.levelup-img-wrap {
  width: 190px; height: 190px; border-radius: 20px; overflow: hidden;
  margin: 0 auto 16px;
  border: 3px solid var(--gold) !important;
  box-shadow: 0 0 40px var(--gold-glow), 0 0 80px rgba(255,215,0,0.15);
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  animation: img-spin-in 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.1s both;
}
@keyframes img-spin-in { from{transform:scale(0) rotate(180deg);opacity:0} to{transform:scale(1) rotate(0);opacity:1} }
.levelup-img-wrap img { width:100%; height:100%; object-fit:cover; }
.levelup-char-name {
  font-size: 24px; font-weight: 900; letter-spacing: -0.4px; margin-bottom: 8px;
  background: linear-gradient(90deg, var(--gold), var(--neon-pink));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  filter: drop-shadow(0 0 10px var(--gold-glow));
  animation: badge-slam 0.4s cubic-bezier(0.34,1.56,0.64,1) 0.3s both;
}
.levelup-msg {
  font-size: 14px; color: var(--text2); line-height: 1.6;
  margin-bottom: 22px; font-style: italic;
  animation: badge-slam 0.4s cubic-bezier(0.34,1.56,0.64,1) 0.4s both;
}
.levelup-close {
  width: 100%; padding: 16px;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--neon-pink));
  background-size: 200% auto; color: white;
  border: none; border-radius: 14px; font-size: 18px; font-weight: 900;
  cursor: pointer; font-family: inherit; letter-spacing: 0.5px;
  animation: flame-border 2s ease infinite, btn-slam 0.4s cubic-bezier(0.34,1.56,0.64,1) 0.5s both;
  box-shadow: 0 4px 30px var(--accent-glow);
  transition: transform 0.15s;
}
@keyframes btn-slam { from{transform:translateY(20px);opacity:0} to{transform:translateY(0);opacity:1} }
.levelup-close:active { transform: scale(0.95); }

@media (max-width: 480px) {
  .profile-hero { flex-direction: column; text-align: center; }
}

/* ── CHARACTER COLLECTION ── */
.char-collection-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px; cursor: pointer;
  transition: all 0.15s; overflow: hidden;
}
.char-collection-card:active { transform: scale(0.97); }
.ccc-img-wrap {
  width: 100%; aspect-ratio: 1/1; border-radius: 10px;
  overflow: hidden; background: var(--surface); margin-bottom: 6px;
  position: relative;
}
.ccc-completion {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(0,0,0,0.7); border-radius: 8px;
  padding: 2px 6px; font-size: 9px; font-weight: 800; color: var(--neon-green);
}
.ccc-name {
  font-size: 10px; font-weight: 800; text-align: center;
  margin-bottom: 5px; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ccc-progress-bar {
  height: 3px; background: var(--border); border-radius: 2px; overflow: hidden;
}
.ccc-progress-fill {
  height: 100%; background: var(--neon-green); border-radius: 2px;
  transition: width 0.5s;
}

/* ── CHARACTER STORY MODAL MISSIONS ── */
.cs-mission-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.cs-mission-row:last-child { border-bottom: none; }
.cs-mission-row.done { opacity: 0.6; }
.cs-mission-check { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.cs-mission-info  { flex: 1; }
.cs-mission-title { font-size: 13px; font-weight: 800; margin-bottom: 3px; }
.cs-mission-desc  { font-size: 11px; color: var(--text2); line-height: 1.4; }
.cs-complete-btn {
  padding: 6px 12px; border-radius: 10px; border: none;
  background: var(--accent); color: white; font-family: inherit;
  font-size: 11px; font-weight: 800; cursor: pointer; flex-shrink: 0;
}

/* ── SMALL TOGGLE (settings) ── */
.toggle-switch-sm { position:relative; display:inline-block; width:44px; height:24px; flex-shrink:0; }
.toggle-switch-sm input { opacity:0; width:0; height:0; }
.toggle-slider-sm { position:absolute; cursor:pointer; inset:0; background:var(--border); border-radius:24px; transition:0.3s; }
.toggle-slider-sm::before { content:''; position:absolute; width:16px; height:16px; left:4px; bottom:4px; background:white; border-radius:50%; transition:0.3s; }
input:checked + .toggle-slider-sm { background:var(--green); }
input:checked + .toggle-slider-sm::before { transform:translateX(20px); }

/* ── LEADERBOARD BUTTON ── */
.profile-leaderboard-btn {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 16px; margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(255,215,0,0.08), rgba(180,79,255,0.08));
  border: 1px solid rgba(255,215,0,0.2); border-radius: 18px;
  color: white; font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
.profile-leaderboard-btn:active { transform: scale(0.98); }

/* ── LEADERBOARD POPUP ── */
.lb-tab {
  padding: 11px 16px; border: none; background: none;
  color: var(--text2); font-family: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; transition: all 0.2s; flex-shrink: 0;
}
.lb-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.lb-time-btn {
  padding: 6px 14px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--surface2);
  color: var(--text2); font-family: inherit;
  font-size: 11px; font-weight: 800; cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.lb-time-btn.active {
  background: rgba(255,215,0,0.12);
  border-color: rgba(255,215,0,0.3);
  color: var(--gold);
}

.lb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.lb-row:last-child { border-bottom: none; }
.lb-rank {
  font-size: 18px; font-weight: 900; width: 32px; text-align: center;
  flex-shrink: 0; font-family: 'Syne', sans-serif;
}
.lb-rank.gold   { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }
.lb-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: white;
}
.lb-info { flex: 1; min-width: 0; }
.lb-username { font-size: 14px; font-weight: 800; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-subtitle { font-size: 10px; color: var(--text2); }
.lb-stat { font-size: 16px; font-weight: 900; color: var(--gold); flex-shrink: 0; font-family: 'Syne', sans-serif; }
.lb-you { background: rgba(255,215,0,0.06); border-radius: 10px; padding: 0 8px; margin: 0 -8px; }

/* Bar leaderboard */
.bar-lb-range {
  padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border);
  background: none; color: var(--text2); font-family: inherit;
  font-size: 10px; font-weight: 800; cursor: pointer; transition: all 0.15s;
}
.bar-lb-range.active { background: rgba(255,215,0,0.1); border-color: rgba(255,215,0,0.3); color: var(--gold); }
