:root {
  --bg: #000000;
  --card: #1c1c1e;
  --card2: #2c2c2e;
  --text: #ffffff;
  --muted: #8e8e93;
  --accent: #3e82f7;
  --accent2: #0a84ff;
  --green: #34c759;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro", "Segoe UI", "Tahoma", sans-serif;
  padding: 0 0 40px;
  min-height: 100vh;
}

#app { max-width: 520px; margin: 0 auto; padding: 16px; }

/* ===== الصورة الكبيرة ===== */
.hero { text-align: center; padding: 16px 0 8px; }
.big-avatar {
  width: 128px; height: 128px; border-radius: 50%;
  margin: 0 auto 12px; overflow: hidden;
  background: #2a2a3e;
  display: flex; align-items: center; justify-content: center;
}
.big-avatar img { width: 100%; height: 100%; object-fit: cover; }
.hero h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.level { color: var(--muted); font-size: 14px; }

/* ===== بطاقة الاسم ===== */
.card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin: 16px 0;
}
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; text-align: right; }
.name-row { display: flex; gap: 10px; align-items: center; }
#nameInput {
  flex: 1;
  background: var(--card2);
  border: none; border-radius: 12px;
  color: var(--text);
  padding: 14px 16px;
  font-size: 16px;
  text-align: right;
  outline: none;
}
#nameInput::placeholder { color: var(--muted); }
.save-btn {
  background: var(--accent);
  color: #fff; border: none;
  border-radius: 12px;
  padding: 14px 22px;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
}
.save-btn:active { opacity: .7; }
.hint { color: var(--muted); font-size: 12px; margin-top: 10px; text-align: right; }

/* ===== المفتاح ===== */
.toggle-row {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; margin-top: 14px; font-size: 15px;
}
.switch { position: relative; display: inline-block; width: 50px; height: 30px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; cursor: pointer;
  background: #555; border-radius: 30px; transition: .3s;
}
.slider::before {
  content: ""; position: absolute;
  height: 24px; width: 24px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .3s;
}
input:checked + .slider { background: var(--green); }
input:checked + .slider::before { transform: translateX(20px); }

/* ===== الفئات (chips) ===== */
.chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 4px 0; margin-bottom: 8px;
  flex-direction: row-reverse;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  background: var(--card2);
  color: var(--text);
  border: none; border-radius: 20px;
  padding: 10px 18px;
  font-size: 15px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); }
.free-note { color: var(--muted); font-size: 13px; text-align: right; margin-bottom: 14px; }

/* ===== شبكة الأفاتار ===== */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.avatar-item {
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color .15s, transform .1s;
}
.avatar-item { position: relative; background: #2a2a3e; }
.avatar-item img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-item.selected { border-color: var(--accent); transform: scale(1.05); }
.avatar-item:active { transform: scale(.95); }

/* المقفلة: تعتيم + قفل وشارة */
.avatar-item.locked img { filter: grayscale(0.7) brightness(0.55); }
.lock-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: flex-end; justify-content: center;
  gap: 4px; padding-bottom: 6px; pointer-events: none;
}
.lock-overlay .badge { font-size: 14px; }
.lock-overlay .lock { font-size: 14px; }

/* شارة الزاوية للمفتوحة المميزة */
.corner-badge {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  font-size: 13px; pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
