:root {
  --bg: #0b0e14;
  --surface: #161b22;
  --card: #1c222b;
  --gold: #ffd700;
  --gold-2: #c5a000;
  --text: #ececec;
  --muted: #9e9e9e;
  --danger: #f44336;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-bottom: 104px;
}
.profile-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px 16px 0;
}
.profile-topbar {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  margin: 18px 0 22px;
}
.profile-topbar h1 {
  margin: 0;
  text-align: center;
  color: var(--gold);
  font-size: 1.28rem;
  font-weight: 900;
  letter-spacing: .02em;
}
.top-icon {
  border: 0;
  background: transparent;
  color: var(--gold);
  font-size: 1.8rem;
  cursor: pointer;
}
.profile-content { display: grid; gap: 24px; }
.profile-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 20px;
  align-items: center;
  background: var(--card);
  border-radius: 18px;
  padding: 28px 30px;
}
.avatar {
  width: 88px;
  height: 88px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #05070a;
  font-size: 3rem;
  font-weight: 950;
}
.profile-name { margin: 0; font-size: 1.9rem; color: var(--muted); line-height: 1.05; }
.profile-rank { margin: 6px 0 0; color: var(--gold); font-size: 1.2rem; }
.profile-email { margin: 2px 0 0; color: var(--muted); font-size: 1rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat-box {
  min-height: 112px;
  border-radius: 16px;
  padding: 16px 10px;
  background: var(--card);
  display: grid;
  place-items: center;
  text-align: center;
}
.stat-box strong { color: var(--gold); font-size: 1.65rem; line-height: 1; }
.stat-box span:first-child, .stat-box small { color: var(--muted); font-weight: 800; }
.stat-box small { font-size: .96rem; }
.section-title { margin: 6px 0 14px; font-size: 1.45rem; }
.achievements-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.achievements-heading .section-title { margin: 6px 0 0; }
.achievements-heading .section-title span { color: var(--gold); font-size: 1rem; }
.view-all-achievements {
  flex: none;
  color: var(--gold);
  font-size: .9rem;
  font-weight: 900;
  text-decoration: none;
}
.achievements {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 20px;
  text-align: center;
}
.profile-trophy {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.profile-trophy-badge {
  width: 84px;
  height: 84px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.15), rgba(28, 34, 43, 1));
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}
.profile-trophy-badge img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.profile-trophy-name {
  display: block;
  font-weight: 900;
  font-size: 0.92rem;
  line-height: 1.15;
  color: var(--text);
}
.achievements-loading,
.achievements:has(.achievements-empty) { grid-template-columns: 1fr; }
.achievements-loading p,
.achievements-empty { margin: 0; color: var(--muted); text-align: left; }
.menu-list { display: grid; gap: 8px; }
.menu-item {
  width: 100%;
  min-height: 62px;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font: inherit;
  font-size: 1.35rem;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.menu-item .menu-icon { color: var(--muted); }
.menu-item.admin { color: var(--gold); }
.menu-item.danger { color: var(--danger); }
.not-logged { text-align: center; padding: 10px 8px; }
.not-logged .avatar { margin: 0 auto 18px; background: var(--surface); color: var(--muted); }
.locked-list { margin-top: 26px; display: grid; gap: 16px; text-align: left; }
.locked-item {
  display: grid;
  grid-template-columns: 42px 1fr 24px;
  gap: 12px;
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.locked-badge {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--surface);
  display: grid;
  place-items: center;
  color: var(--gold);
}
.locked-item small { color: var(--muted); }
.login-bottom {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 104px;
  max-width: 728px;
  margin: 0 auto;
}
.gold-btn, .ghost-btn {
  min-height: 50px;
  border-radius: 9px;
  padding: 0 18px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}
.gold-btn { border: 0; background: var(--gold); color: #05070a; }
.ghost-btn { border: 1px solid rgba(255,255,255,.16); background: transparent; color: var(--text); }
.full-width { width: 100%; }
.app-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 86px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  background: rgba(22, 27, 34, .98);
  box-shadow: 0 -10px 35px rgba(0,0,0,.22);
}
.nav-item {
  color: var(--muted);
  text-decoration: none;
  display: grid;
  place-items: center;
  gap: 3px;
  border-radius: 24px;
  font-weight: 850;
}
.nav-item span { font-size: 1.7rem; line-height: 1; }
.nav-item small { font-size: .76rem; text-align: center; line-height: 1.05; }
.nav-item.active { color: var(--gold); background: rgba(255,255,255,.04); }
.profile-dialog {
  width: min(440px, calc(100vw - 32px));
  border: 0;
  border-radius: 18px;
  background: var(--card);
  color: var(--text);
  padding: 22px;
}
.profile-dialog::backdrop { background: rgba(0,0,0,.62); }
.profile-dialog form { display: grid; gap: 14px; }
.profile-dialog h2 { margin: 0 0 4px; }
.profile-dialog label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; }
.profile-dialog input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.dialog-error { color: var(--danger); min-height: 1em; margin: 0; }
.dialog-note { margin: 0; color: var(--muted); line-height: 1.35; }
.admin-dialog form.loading {
  opacity: 0.7;
  pointer-events: none;
}
.admin-toggle {
  min-height: 48px;
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text) !important;
}
.admin-toggle input {
  width: 46px;
  min-height: 26px;
  accent-color: var(--gold);
}
.profile-toast {
  position: fixed;
  left: 50%;
  bottom: 106px;
  transform: translateX(-50%) translateY(18px);
  background: #05070a;
  color: white;
  padding: 12px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: .2s ease;
  pointer-events: none;
}
.profile-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 560px) {
  .profile-card { grid-template-columns: 82px 1fr; padding: 28px 30px; gap: 18px; }
  .avatar { width: 78px; height: 78px; font-size: 2.55rem; }
  .profile-name { font-size: 1.68rem; }
  .stats-grid { gap: 10px; }
  .stat-box { min-height: 112px; padding: 14px 8px; }
  .stat-box strong { font-size: 1.55rem; }
  .achievements { grid-template-columns: repeat(3, 1fr); gap: 14px 10px; }
  .profile-trophy-badge { width: 70px; height: 70px; }
  .profile-trophy-name { font-size: .8rem; }
  .menu-item { font-size: 1.28rem; }
}
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .profile-card { padding: 22px 18px; }
}
