:root {
  --gryffindor-red: #740001;
  --slytherin-green: #1a472a;
  --ravenclaw-blue: #0e1a40;
  --hufflepuff-yellow: #ecb939;
  --gold: #d4af37;
  --bg: #0d0d0d;
  --card: #171717;
  --text: #f5f1e8;
  --muted: #c7bfb2;
  --font-magic: 'Henny Penny', sans-serif;
  --font-sans: 'Vazirmatn', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(circle at top, #1a1a1a, #070707);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.magic-title {
  font-family: var(--font-magic);
  color: var(--gold);
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

/* صفحه ورود جادویی */
.welcome-screen {
  position: fixed;
  inset: 0;
  background: #0a0a0a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  overflow: hidden;
}

/* لایه تاریکی ملایم روی کل صفحه ورود برای خوانایی متن‌ها */
.welcome-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(1px);
  z-index: 2;
  pointer-events: none; /* مانع کلیک روی دکمه نشود */
}

/* لنگه‌های دروازه متحرک (نقشه غارتگر) که عکس روی آن‌ها قرار می‌گیرد */
.scroll-curtain {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  /* عکس به صورت متغیر از جاوااسکریپت تزریق می‌شود */
  background-image: var(--welcome-bg, url('pic/DJI_0141.JPG'));
  background-size: 200% 100%; /* عرض دو برابر چون هر لنگه نصف عکس را پوشش می‌دهد */
  background-repeat: no-repeat;
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 50px rgba(0,0,0,0.9);
  transition: transform 1.3s cubic-bezier(0.77, 0, 0.175, 1);
  z-index: 1;
}

/* لنگه سمت چپ: نیمه سمت چپ عکس را نشان می‌دهد */
.curtain-left { 
  left: 0; 
  background-position: left center;
  transform-origin: left; 
  border-left: none;
}

/* لنگه سمت راست: نیمه سمت راست عکس را نشان می‌دهد */
.curtain-right { 
  right: 0; 
  background-position: right center;
  transform-origin: right; 
  border-right: none;
}

/* انیمیشن باز شدن دو لنگه دروازه به طرفین */
.welcome-screen.split .curtain-left { transform: scaleX(0); }
.welcome-screen.split .curtain-right { transform: scaleX(0); }

.welcome-content {
  position: relative;
  z-index: 3;
  text-align: center;
  max-width: 400px;
  transition: opacity 0.5s ease;
}
.welcome-screen.split .welcome-content { opacity: 0; pointer-events: none; }

.crest { font-size: 3rem; margin-bottom: 10px; animation: pulse 2s infinite; }

.btn-primary {
  background: linear-gradient(135deg, var(--gryffindor-red), #4a0001);
  color: var(--text);
  border: 1px solid var(--gold);
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  margin-top: 25px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  width: 100%;
}

/* هدر و جغد متحرک */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: rgba(23, 23, 23, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  position: sticky;
  top: 0;
  z-index: 90;
}

.hedwig-owl {
  font-size: 2rem;
  animation: owlFly 3s ease-in-out infinite;
}

@keyframes owlFly {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(5deg); }
}

/* بخش معجون شانس */
.felix-section { padding: 15px; }
.felix-box {
  background: linear-gradient(135deg, #1b112c, #0d0718);
  border: 1px solid var(--hufflepuff-yellow);
  border-radius: 16px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: 0 0 15px rgba(236, 185, 57, 0.15);
  position: relative;
  overflow: hidden;
}

.felix-box.shake-magic {
  animation: shake 0.5s linear infinite;
}

.felix-icon { font-size: 2.2rem; }
.felix-text h4 { color: var(--hufflepuff-yellow); margin-bottom: 4px; font-size: 0.95rem; }
.felix-text p { color: var(--muted); font-size: 0.8rem; }
.btn-felix {
  background: var(--hufflepuff-yellow);
  color: #111;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  margin-right: auto;
}

/* دسته‌بندی‌ها و کارت‌ها */
.category-nav {
  display: flex;
  gap: 10px;
  padding: 10px 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  background: var(--card);
  border: 1px solid rgba(212, 175, 55, 0.2);
  padding: 8px 16px;
  border-radius: 20px;
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.85rem;
}
.nav-btn.active {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--gold);
  color: var(--gold);
}

.categories-container { padding: 20px; }
.category-block { margin-bottom: 35px; }
.category-title { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 8px; }
.category-title h3 { font-size: 1.2rem; color: var(--text); }

.items-grid { display: grid; grid-template-columns: 1fr; gap: 15px; }

/* کارت‌های متناسب با عکس‌های عمودی */
.item-card {
  background: var(--card);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  align-items: center;
}

.item-card img { 
  width: 85px; 
  aspect-ratio: 3 / 4; 
  object-fit: cover;
  border-radius: 8px;
  margin: 10px;
}

.item-body { padding: 12px 6px 12px 12px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.item-body h3 { font-size: 0.95rem; color: var(--gold); margin-bottom: 4px; }
.item-body p { color: var(--muted); font-size: 0.75rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.price { color: var(--text); font-weight: bold; font-size: 0.85rem; margin-top: 6px; text-align: left; }

/* بج‌های سطح سختی */
.level-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  align-self: flex-start;
  margin-top: 5px;
  font-weight: bold;
  display: inline-block;
}
.level-muggle { background: rgba(14, 26, 64, 0.3); color: #8ba2ff; border: 1px solid var(--ravenclaw-blue); }
.level-hogwarts { background: rgba(236, 185, 57, 0.2); color: var(--hufflepuff-yellow); border: 1px solid var(--hufflepuff-yellow); }
.level-sorcerer { background: rgba(116, 0, 1, 0.2); color: #ff8b8d; border: 1px solid var(--gryffindor-red); }

/* مودال با بک‌لایت تنفسی */
.item-modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); }
.modal-content {
  position: relative;
  background: #121212 url('https://www.transparenttextures.com/patterns/parchment.png');
  border: 1px solid var(--gold);
  border-radius: 24px;
  width: 100%;
  max-width: 340px;
  overflow: hidden;
  z-index: 2;
  box-shadow: 0 0 35px var(--backlight-color, rgba(212, 175, 55, 0.35));
  animation: modalOpen 0.3s ease-out, glowPulse 3s ease-in-out infinite alternate;
}

@keyframes modalOpen {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes glowPulse {
  from { box-shadow: 0 0 20px var(--backlight-color, rgba(212, 175, 55, 0.3)); }
  to { box-shadow: 0 0 45px var(--backlight-color, rgba(212, 175, 55, 0.65)); transform: scale(1.01); }
}

.modal-close { position: absolute; top: 22px; right: 22px; background: rgba(0,0,0,0.6); border: 1px solid var(--gold); color: var(--text); width: 32px; height: 32px; border-radius: 50%; font-size: 0.9rem; z-index: 5; cursor: pointer; }
.modal-image-wrapper { position: relative; width: 100%; padding: 15px 15px 0 15px; }
.modal-image-wrapper img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
.modal-info { padding: 20px; }
.modal-info h2 { color: var(--gold); font-size: 1.2rem; margin-bottom: 8px; }
.modal-info p { color: var(--muted); font-size: 0.85rem; line-height: 1.6; margin-top: 10px; }
.modal-price { margin-top: 15px; font-size: 1.05rem; font-weight: bold; color: var(--gold); text-align: left; }
.game-level-badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: bold; margin-bottom: 8px; }

/* انیمیشن‌ها */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px) rotate(-1deg); }
  40%, 80% { transform: translateX(4px) rotate(1deg); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; text-shadow: 0 0 15px var(--gold); }
}