:root {
  color-scheme: dark;
  --bg: #000000;
  --card-bg: linear-gradient(175deg, rgba(42, 24, 56, .92), rgba(16, 9, 20, .96));
  --card-border: rgba(224, 130, 255, .28);
  --card-glow:
    0 0 0 1px rgba(255, 255, 255, .04) inset,
    0 18px 50px -14px rgba(190, 60, 220, .45),
    0 0 90px -30px rgba(110, 70, 255, .45);
  --grad-brand: linear-gradient(90deg, #ffc24b 0%, #ff6aa0 55%, #b455ff 100%);
  --grad-fill: linear-gradient(90deg, #ffb648, #ff5f96);
  --grad-success: linear-gradient(135deg, #3fe08a, #1fb85f);
  --ink: #f4eefc;
  --ink-dim: #a597b8;
  --ink-faint: #6d6280;
  --gold: #ffd23f;
  --silver: #e7e5ef;
  --bronze: #ff8a3d;
  --blue: #7c8bf0;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Vazirmatn", "Tahoma", sans-serif;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button { font-family: inherit; }

.hidden { display: none !important; }

/* ---------------------------------------------------------- icon system */

.nav-btn svg,
.tab svg,
.trophy-btn svg,
.modal-close svg,
.ic svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.icon-paw,
.icon-bone,
.icon-star,
.icon-trophy {
  fill: currentColor;
  stroke: none;
}

.icon-trophy .stroke-part {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.fill-part {
  fill: currentColor !important;
  stroke: none !important;
}

/* ---------------------------------------------------------- splash */

#splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  transition: opacity .45s ease, visibility .45s ease;
  background:
    radial-gradient(60% 40% at 50% 18%, rgba(150, 60, 220, .18), transparent 70%),
    var(--bg);
}

#splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  width: 100%;
  max-width: 340px;
  padding: 40px 28px 32px;
  border-radius: 28px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-glow);
  text-align: center;
}

.mascot { margin: 0 auto 20px; }
.mascot svg { display: block; }
.mascot-lg { width: 108px; height: 108px; filter: drop-shadow(0 8px 24px rgba(255, 120, 170, .35)); }
.mascot-lg svg { width: 108px; height: 108px; }

.brand-title {
  margin: 0 0 6px;
  font-size: 30px;
  font-weight: 800;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: .5px;
}

.brand-sub {
  margin: 0 0 26px;
  font-size: 14px;
  color: var(--ink-dim);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .07);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--grad-fill);
  box-shadow: 0 0 14px rgba(255, 110, 150, .6);
  transition: width .25s ease;
}

/* ---------------------------------------------------------- app shell */

#app {
  min-height: 100dvh;
  padding: calc(20px + var(--safe-t)) 18px calc(96px + var(--safe-b));
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(55% 32% at 50% 10%, rgba(150, 60, 220, .16), transparent 70%),
    var(--bg);
}

.profile-card {
  width: 100%;
  max-width: 380px;
  margin-top: 8px;
  padding: 30px 22px 26px;
  border-radius: 30px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-glow);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.avatar-wrap {
  position: relative;
  width: 116px;
  height: 116px;
  margin-bottom: 16px;
}

.avatar-wrap::before,
.avatar-wrap::after {
  content: "";
  position: absolute;
  top: -6px;
  width: 30px;
  height: 42px;
  background: linear-gradient(160deg, #8f6bff, #5aa6ff);
  border: 2px solid rgba(0, 0, 0, .5);
  border-radius: 60% 40% 55% 45% / 70% 60% 40% 30%;
  z-index: 0;
}

.avatar-wrap::before { left: -8px; transform: rotate(-24deg); }
.avatar-wrap::after { right: -8px; transform: rotate(24deg) scaleX(-1); }

.avatar {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #1c1224;
  border: 3px solid rgba(255, 255, 255, .12);
  box-shadow: 0 0 0 3px rgba(180, 90, 255, .35), 0 10px 26px -8px rgba(180, 90, 255, .5);
}

.display-name {
  margin: 2px 0 4px;
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
}

.username {
  margin: 0;
  font-size: 13px;
  color: var(--ink-dim);
  padding: 4px 14px;
  background: rgba(255, 255, 255, .05);
  border-radius: 999px;
  min-height: 14px;
}

.deco-line {
  width: 100%;
  max-width: 220px;
  height: 1px;
  margin: 18px 0;
  background: linear-gradient(90deg, transparent, rgba(255, 130, 200, .55), transparent);
  position: relative;
}

.deco-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--grad-fill);
  box-shadow: 0 0 12px rgba(255, 110, 150, .8);
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  padding: 12px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .04);
}

.stat-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 84px;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-faint);
}

.stat-value {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
  direction: ltr;
}

.stat-value .ic { display: inline-flex; color: var(--gold); }
.stat-value .ic svg { width: 17px; height: 17px; }
.stat-block:last-child .ic { color: #ffb6d9; }

.stat-sep {
  width: 1px;
  height: 30px;
  background: rgba(255, 255, 255, .1);
}

.trophy-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: linear-gradient(160deg, rgba(255, 210, 90, .18), rgba(180, 90, 255, .14));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .04) inset, 0 8px 22px -8px rgba(255, 190, 90, .45);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .15s ease;
}

.trophy-btn svg { width: 27px; height: 27px; filter: drop-shadow(0 2px 6px rgba(255, 190, 90, .5)); }

.trophy-btn:active { transform: scale(.92); }

/* ---------------------------------------------------------- bottom nav */

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(24, 14, 30, .88);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-glow);
  backdrop-filter: blur(14px);
  z-index: 40;
}

.nav-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-dim);
  cursor: pointer;
  transition: background .15s ease, transform .15s ease, color .15s ease;
}

.nav-btn svg { width: 21px; height: 21px; }

.nav-btn:active { transform: scale(.9); }

.nav-active {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 130, 200, .5);
  box-shadow: 0 0 16px rgba(255, 110, 150, .35);
  color: #ff8fc4;
}

/* ---------------------------------------------------------- leaderboard modal */

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(6px);
  transition: opacity .3s ease, visibility .3s ease;
}

.modal.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 84vh;
  padding: 26px 18px calc(20px + var(--safe-b));
  border-radius: 28px 28px 0 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-bottom: none;
  box-shadow: var(--card-glow);
  display: flex;
  flex-direction: column;
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .08);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close svg { width: 13px; height: 13px; stroke-width: 2.2; }

.lb-title {
  margin: 0 0 4px;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.lb-sub {
  margin: 0 0 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 13px 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .04);
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s ease, box-shadow .2s ease, transform .15s ease, color .2s ease;
}

.tab svg { width: 20px; height: 20px; }

.tab:active { transform: scale(.96); }

.tab-active {
  background: var(--grad-success);
  border-color: transparent;
  color: #06210f;
  box-shadow: 0 0 20px rgba(60, 220, 130, .45);
}

.lb-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 4px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .035);
  border-inline-start: 3px solid var(--blue);
}

.lb-row.rank-1 { border-inline-start-color: var(--gold); }
.lb-row.rank-2 { border-inline-start-color: var(--silver); }
.lb-row.rank-3 { border-inline-start-color: var(--bronze); }

.lb-rank {
  min-width: 30px;
  height: 30px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink-dim);
  direction: ltr;
}

.rank-1 .lb-rank,
.rank-2 .lb-rank,
.rank-3 .lb-rank {
  color: #1a1024;
  font-size: 13px;
}

.rank-1 .lb-rank { background: linear-gradient(150deg, #ffe37a, var(--gold)); box-shadow: 0 0 14px rgba(255, 210, 63, .55); }
.rank-2 .lb-rank { background: linear-gradient(150deg, #ffffff, var(--silver)); box-shadow: 0 0 12px rgba(231, 229, 239, .4); }
.rank-3 .lb-rank { background: linear-gradient(150deg, #ffb066, var(--bronze)); box-shadow: 0 0 12px rgba(255, 138, 61, .45); }

.lb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #241730;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, .1);
}

.lb-name {
  flex: 1;
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: start;
}

.lb-value {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 4px;
  direction: ltr;
}

.lb-value svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  fill: currentColor;
  stroke: none;
}

.lb-empty {
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
  padding: 30px 0;
}

/* ---------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translate(-50%, 10px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(28, 16, 36, .95);
  border: 1px solid var(--card-border);
  color: var(--ink);
  font-size: 13px;
  z-index: 90;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 480px) {
  #app { align-items: center; }
}
