/* ------------------------------------------------------------------ public profile (public/js/pages/profile.js) */
.profile-page { display: flex; flex-direction: column; gap: 16px; }
.profile-back { align-self: flex-start; border: 0; background: none; cursor: pointer; padding: 0; font: inherit; }

/* Hero card */
.profile-hero {
  --rank: #9aa7b8; position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 24px; align-items: center; padding: 26px 28px;
  background:
    radial-gradient(520px 260px at 0% 0%, color-mix(in srgb, var(--rank) 22%, transparent), transparent 70%),
    radial-gradient(420px 240px at 100% 100%, rgba(239, 59, 59, .1), transparent 70%),
    var(--panel);
  animation: profileIn .45s cubic-bezier(.2, .9, .3, 1.1);
}
.profile-hero::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--rank), var(--accent), transparent);
}
.profile-hero-glow {
  position: absolute; width: 260px; height: 260px; left: -60px; top: -90px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--rank) 30%, transparent), transparent 65%);
  filter: blur(10px); animation: profileGlow 6s ease-in-out infinite;
}
@keyframes profileGlow { 50% { transform: translate(20px, 14px) scale(1.08); opacity: .8; } }
@keyframes profileIn { from { opacity: 0; transform: translateY(10px); } }

.profile-avatar { position: relative; width: 96px; height: 96px; flex: none; }
.profile-avatar .profile-av {
  width: 96px; height: 96px; font-size: 40px; border: 3px solid color-mix(in srgb, var(--rank) 70%, #000);
  box-shadow: 0 0 0 4px rgba(0, 0, 0, .35), 0 0 34px color-mix(in srgb, var(--rank) 45%, transparent);
}
.profile-lvl { position: absolute; right: -8px; bottom: -6px; display: grid; place-items: center; border-radius: 50%; background: var(--panel); padding: 2px; box-shadow: 0 4px 12px rgba(0, 0, 0, .5); }
.profile-ring { position: relative; width: 46px; height: 46px; display: grid; place-items: center; }
.profile-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.profile-ring .bg { fill: rgba(0, 0, 0, .45); stroke: rgba(255, 255, 255, .1); stroke-width: 3; }
.profile-ring .fg { fill: none; stroke: var(--rank); stroke-width: 3; stroke-linecap: round; filter: drop-shadow(0 0 3px var(--rank)); }
.profile-ring b { position: relative; font: 400 15px/1 var(--display); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }

.profile-id { position: relative; min-width: 0; }
.profile-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-name-row h1 { font-size: 30px; line-height: 1.1; overflow-wrap: anywhere; }
.profile-rank { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 14px; }
.profile-rank-name {
  font-family: var(--display); letter-spacing: .08em; text-transform: uppercase; font-size: 13px;
  color: var(--rank); text-shadow: 0 0 14px color-mix(in srgb, var(--rank) 50%, transparent);
}
.profile-xp { margin-top: 12px; max-width: 460px; }
.profile-xp-bar { height: 10px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line2); overflow: hidden; }
.profile-xp-bar i {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--rank) 60%, var(--accent)), var(--rank));
  box-shadow: 0 0 12px color-mix(in srgb, var(--rank) 60%, transparent);
  transition: width 1.1s cubic-bezier(.2, .9, .3, 1);
}
.profile-xp-text { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.profile-joined { margin-top: 10px; font-size: 12.5px; color: var(--dim); }

.profile-worth {
  position: relative; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right;
  padding: 14px 18px; border-radius: 14px; background: rgba(0, 0, 0, .22); border: 1px solid var(--line);
}
.profile-worth small { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.profile-worth b { font-family: var(--display); font-weight: 400; font-size: 28px; color: var(--gold); text-shadow: 0 0 20px rgba(228, 174, 57, .3); }
.profile-worth b .price { gap: 8px; }
.profile-worth > span { font-size: 13px; color: var(--muted); }
.profile-worth .btn { margin-top: 6px; }

.profile-mod { position: relative; grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 14px; border-top: 1px dashed var(--line2); font-size: 13px; }

/* Stat tiles */
.profile-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.profile-stat {
  position: relative; padding: 14px 16px 15px; overflow: hidden; display: flex; flex-direction: column; gap: 2px;
  animation: profileIn .5s cubic-bezier(.2, .9, .3, 1.1) backwards; transition: border-color .2s, transform .2s;
}
.profile-stat:hover { border-color: var(--line2); transform: translateY(-2px); }
.profile-stat:nth-child(2) { animation-delay: .04s; }
.profile-stat:nth-child(3) { animation-delay: .08s; }
.profile-stat:nth-child(4) { animation-delay: .12s; }
.profile-stat:nth-child(5) { animation-delay: .16s; }
.profile-stat:nth-child(6) { animation-delay: .2s; }
.profile-stat-icon {
  position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  color: var(--accent-hi); background: rgba(239, 59, 59, .1);
}
.profile-stat.gold .profile-stat-icon { color: var(--gold); background: rgba(228, 174, 57, .12); }
.profile-stat small { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; padding-right: 40px; }
.profile-stat b { font-family: var(--display); font-weight: 400; font-size: 21px; margin-top: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-stat.gold b { color: var(--gold); }
.profile-stat-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.profile-stat-sub .price { color: var(--text); font-size: 12px; gap: 3px; }
.profile-stat-bar { height: 4px; border-radius: 99px; background: var(--bg2); margin-top: 8px; overflow: hidden; }
.profile-stat-bar i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: linear-gradient(90deg, var(--accent-lo), var(--accent-hi)); animation: profileBar 1.1s cubic-bezier(.2, .9, .3, 1) .2s backwards; }
@keyframes profileBar { from { width: 0; } }

/* Best drop + top items */
.profile-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: stretch; }
.profile-best, .profile-top, .profile-bets { padding: 18px; }
.profile-sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.profile-sec-head .muted { font-size: 13px; margin-left: auto; }
.profile-best-card { position: relative; }
.profile-best-card::before {
  content: ''; position: absolute; inset: -10px; border-radius: 20px; pointer-events: none;
  background: radial-gradient(circle at 50% 60%, color-mix(in srgb, var(--c) 35%, transparent), transparent 65%);
  animation: profileGlow 5s ease-in-out infinite;
}
.profile-best-card .item { position: relative; padding: 14px 14px 16px; }
.profile-best-card .item-img img { animation: profileFloat 4s ease-in-out infinite; }
@keyframes profileFloat { 50% { transform: translateY(-6px) rotate(-2deg); } }
.profile-items { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.profile-item { animation: profileIn .45s cubic-bezier(.2, .9, .3, 1.2) backwards; animation-delay: calc(var(--i) * 60ms + .1s); }
.profile-item .item { height: 100%; }
.profile-none { padding: 30px 10px; text-align: center; color: var(--muted); font-size: 14px; border: 1px dashed var(--line2); border-radius: 12px; }

/* Recent bets */
.profile-bets .table-wrap { margin: 0 -18px -18px; }
.profile-bets-table td, .profile-bets-table th { padding: 10px 18px; }
.profile-game { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 7px; background: var(--panel3); font-size: 12.5px; font-weight: 600; }
.profile-bets-table .profile-mult { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.profile-bets-table tr.win .profile-mult, .profile-bets-table tr.win .profile-payout { color: var(--green); }
.profile-bets-table tr.win td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.profile-bets-table tr.loss td:first-child { box-shadow: inset 3px 0 0 rgba(240, 82, 82, .5); }
.profile-when { text-align: right; white-space: nowrap; font-size: 13px; }

/* Responsive */
@media (max-width: 1240px) {
  .profile-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .profile-items { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}
@media (max-width: 900px) {
  .profile-hero { grid-template-columns: auto minmax(0, 1fr); }
  .profile-worth { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; text-align: left; }
  .profile-worth .btn { margin-top: 0; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-best-card { max-width: 260px; margin: 0 auto; }
}
@media (max-width: 640px) {
  .profile-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 22px 16px; gap: 16px; }
  .profile-name-row, .profile-rank { justify-content: center; }
  .profile-name-row h1 { font-size: 24px; }
  .profile-xp { margin-left: auto; margin-right: auto; width: 100%; }
  .profile-worth { width: 100%; justify-content: center; text-align: center; flex-direction: column; }
  .profile-mod { justify-content: center; }
  .profile-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .profile-stat { padding: 12px; }
  .profile-stat b { font-size: 17px; }
  .profile-stat-icon { width: 28px; height: 28px; right: 8px; top: 8px; }
  .profile-stat-icon svg { width: 16px; height: 16px; }
  .profile-stat small { font-size: 10.5px; padding-right: 30px; }
  .profile-items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .profile-best, .profile-top, .profile-bets { padding: 14px; }
  .profile-bets .table-wrap { margin: 0 -14px -14px; }
  .profile-bets-table td, .profile-bets-table th { padding: 9px 6px; font-size: 12.5px; }
  .profile-bets-table td:first-child, .profile-bets-table th:first-child { padding-left: 14px; }
  .profile-bets-table td:nth-last-child(2), .profile-bets-table th:nth-last-child(2) { padding-right: 14px; }
  .profile-bets-table .price { gap: 3px; }
  .profile-game { padding: 0 7px; font-size: 12px; }
  .profile-bets-table .profile-when { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .profile-hero, .profile-stat, .profile-item, .profile-hero-glow, .profile-best-card::before, .profile-best-card .item-img img, .profile-stat-bar i { animation: none; }
  .profile-xp-bar i { transition: none; }
}
