/* 🎨 استایل امکانات جدید — هم‌خانواده با تم اصلی گیمیفای (بنفش تیره + طلایی) */
:root {
  --gm-bg: #17111f;
  --gm-card: #1d1527;
  --gm-card2: #241a33;
  --gm-gold: #f2ca7c;
  --gm-purple: #a98cf7;
  --gm-green: #7cd7b6;
  --gm-pink: #eda0b9;
  --gm-line: rgba(255, 255, 255, 0.12);
}

/* ---------- دکمه‌های شناور ---------- */
#gamify-tribes-fab, #gamify-mod-fab, #gamify-gift-fab {
  position: fixed;
  left: 14px;
  z-index: 99990;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease;
  font-family: "Vazirmatn", sans-serif;
}
#gamify-tribes-fab { bottom: 96px; background: linear-gradient(135deg, #2c2140, #1d1527); border: 2px solid var(--gm-purple); animation: gamifyPulse 2.6s ease-in-out infinite; }
#gamify-mod-fab { bottom: 204px; background: #241a33; border: 1px solid var(--gm-green); }
#gamify-gift-fab { bottom: 258px; background: #241a33; border: 1px solid var(--gm-gold); animation: gamifyFloat 3s ease-in-out infinite; }
#gamify-tribes-fab:hover, #gamify-mod-fab:hover, #gamify-gift-fab:hover { transform: scale(1.1); }
.gamify-fab-badge {
  position: absolute; top: -6px; right: -6px;
  background: #e5485c; color: #fff; font-size: 11px; font-weight: 800;
  border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center;
}

/* ---------- اورلی و مودال ---------- */
.gamify-overlay {
  position: fixed; inset: 0; z-index: 99991;
  background: rgba(10, 6, 16, 0.78);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 18px 12px;
  overflow-y: auto;
  font-family: "Vazirmatn", sans-serif;
  color: #fff;
}
.gamify-overlay.open { display: flex; animation: gamifyFadeIn 0.25s ease; }
.gamify-modal {
  width: min(640px, 96vw);
  background: var(--gm-card);
  border: 1px solid rgba(169, 140, 247, 0.4);
  border-radius: 22px;
  padding: 18px;
  margin: auto;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  animation: gamifyPop 0.3s ease;
}
.gamify-modal.wide { width: min(760px, 96vw); }
.gamify-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.gamify-modal-head b { font-size: 18px; }
.gamify-modal-head button { background: rgba(255,255,255,0.07); border: 1px solid var(--gm-line); color: #fff; border-radius: 10px; padding: 4px 12px; cursor: pointer; font-family: inherit; }
.gamify-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 4px; }
.gamify-tabs button {
  white-space: nowrap; background: rgba(255,255,255,0.05); border: 1px solid var(--gm-line);
  color: #ddd; border-radius: 999px; padding: 7px 14px; cursor: pointer; font-family: inherit; font-size: 13px;
}
.gamify-tabs button.active { background: var(--gm-purple); color: #17111f; font-weight: 800; border-color: var(--gm-purple); }
.gamify-body { display: grid; gap: 12px; }
.gamify-loading { text-align: center; padding: 10px; opacity: 0.8; font-size: 13px; }
.gamify-empty { text-align: center; padding: 30px 16px; opacity: 0.95; line-height: 2.2; }
.gamify-empty h3 { margin: 8px 0; }
.gamify-hint { font-size: 12px; opacity: 0.75; line-height: 2; }
.gamify-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- دکمه‌ها ---------- */
.gamify-btn {
  background: rgba(255,255,255,0.07); border: 1px solid var(--gm-line); color: #fff;
  border-radius: 12px; padding: 9px 16px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 700;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.gamify-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
.gamify-btn.primary { background: linear-gradient(135deg, var(--gm-gold), #e0a94f); color: #241a10; border: none; }
.gamify-btn.danger { border-color: rgba(229,72,92,0.6); color: #ff9aa8; }
.gamify-btn.sm { padding: 6px 12px; font-size: 12px; }
.gamify-btn.full { width: 100%; }
.gamify-btn.war { border-color: rgba(237,160,185,0.6); color: var(--gm-pink); }
.gamify-joined { font-size: 12px; color: var(--gm-green); font-weight: 800; }

/* ---------- کارت قبیله ---------- */
.gamify-tribe-card {
  display: flex; gap: 12px; align-items: center;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--gm-line);
  border-inline-start: 4px solid var(--tribe, var(--gm-purple));
  border-radius: 16px; padding: 12px;
}
.gamify-tribe-logo { font-size: 42px; line-height: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4)); }
.gamify-tribe-logo.sm { font-size: 34px; }
.gamify-tribe-info { flex: 1; display: grid; gap: 2px; min-width: 0; }
.gamify-tribe-info b { font-size: 15px; }
.gamify-tribe-info small { font-size: 12px; opacity: 0.75; }
.gamify-tribe-acts { display: grid; gap: 6px; }
.gamify-tribe-head { display: flex; gap: 14px; background: linear-gradient(135deg, color-mix(in srgb, var(--tribe) 18%, transparent), transparent); border: 1px solid var(--gm-line); border-radius: 18px; padding: 16px; }
.gamify-tribe-head h2 { margin: 0 0 4px; font-size: 20px; }
.gamify-tribe-head h2 small { opacity: 0.6; font-size: 13px; }
.gamify-desc { font-size: 13px; opacity: 0.85; line-height: 1.9; margin: 6px 0; }
.gamify-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; opacity: 0.9; }
.gamify-members { display: grid; gap: 8px; }
.gamify-member { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,0.04); border-radius: 12px; padding: 8px 12px; }
.gamify-member b { display: block; font-size: 14px; }
.gamify-member small { font-size: 11px; opacity: 0.7; }
.gamify-mavatar { font-size: 20px; }

/* ---------- فرم ---------- */
.gamify-form { display: grid; gap: 12px; }
.gamify-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 700; }
.gamify-form input, .gamify-form textarea, .gamify-form select {
  background: #17111f; border: 1px solid var(--gm-line); color: #fff;
  border-radius: 12px; padding: 10px 12px; font-family: inherit; font-size: 14px; width: 100%;
}
.gamify-form textarea { min-height: 70px; resize: vertical; }
.gamify-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gamify-search { display: flex; gap: 8px; }
.gamify-search input { flex: 1; background: #17111f; border: 1px solid var(--gm-line); color: #fff; border-radius: 12px; padding: 9px 12px; font-family: inherit; }

/* ---------- نبرد و رتبه ---------- */
.gamify-battle { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: rgba(237,160,185,0.07); border: 1px solid rgba(237,160,185,0.3); border-radius: 14px; padding: 12px; }
.gamify-battle b { display: block; }
.gamify-battle small { font-size: 12px; opacity: 0.8; }
.gamify-rank { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: rgba(255,255,255,0.04); border-radius: 12px; padding: 9px 12px; font-size: 13px; flex-wrap: wrap; }

/* ---------- کویییز ---------- */
.gamify-quiz { display: grid; gap: 12px; }
.gamify-quiz-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; opacity: 0.9; flex-wrap: wrap; }
.gamify-timer { height: 8px; background: rgba(255,255,255,0.1); border-radius: 999px; overflow: hidden; }
.gamify-timer span { display: block; height: 100%; background: linear-gradient(90deg, var(--gm-green), var(--gm-gold)); border-radius: 999px; transition: width 0.25s linear; }
.gamify-q { font-size: 17px; line-height: 2; margin: 4px 0; }
.gamify-opts { display: grid; gap: 8px; }
.gamify-opt {
  text-align: right; background: rgba(255,255,255,0.05); border: 1px solid var(--gm-line); color: #fff;
  border-radius: 14px; padding: 12px 14px; cursor: pointer; font-family: inherit; font-size: 14px; transition: all 0.2s ease;
}
.gamify-opt:hover:not(:disabled) { border-color: var(--gm-purple); background: rgba(169,140,247,0.12); transform: translateX(-3px); }
.gamify-opt.correct { background: rgba(124,215,182,0.2); border-color: var(--gm-green); animation: gamifyPop 0.4s ease; }
.gamify-opt.wrong { background: rgba(229,72,92,0.18); border-color: #e5485c; }
.gamify-opt:disabled { cursor: default; opacity: 0.95; }
.gamify-expl { background: rgba(242,202,124,0.1); border: 1px solid rgba(242,202,124,0.35); border-radius: 12px; padding: 10px 12px; font-size: 13px; line-height: 2; }
.gamify-quiz-done { text-align: center; padding: 16px; display: grid; gap: 8px; justify-items: center; }

/* ---------- پنل مدیر ---------- */
.gamify-mod-card { background: rgba(255,255,255,0.04); border: 1px solid var(--gm-line); border-radius: 16px; padding: 14px; display: grid; gap: 10px; }
.gamify-mod-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; opacity: 0.9; flex-wrap: wrap; }
.gamify-mod-body { font-size: 14px; line-height: 2.1; white-space: pre-wrap; }
.gamify-mod-opts { font-size: 13px; opacity: 0.9; display: grid; gap: 4px; margin: 0; padding-right: 18px; }
.gamify-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 8px; }
.gamify-stat-card { background: rgba(169,140,247,0.1); border: 1px solid rgba(169,140,247,0.3); border-radius: 14px; padding: 12px 8px; text-align: center; }
.gamify-stat-card b { display: block; font-size: 20px; color: var(--gm-gold); }
.gamify-stat-card small { font-size: 11px; opacity: 0.8; }

/* ---------- انیمیشن‌ها ---------- */
@keyframes gamifyFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes gamifyPop { 0% { transform: scale(0.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes gamifyFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes gamifyPulse { 0%, 100% { box-shadow: 0 8px 24px rgba(169,140,247,0.25); } 50% { box-shadow: 0 8px 32px rgba(169,140,247,0.55); } }
@keyframes gamifyToastIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* موبایل */
@media (max-width: 560px) {
  .gamify-tribe-card { flex-wrap: wrap; }
  .gamify-tribe-acts { flex-direction: row; display: flex; width: 100%; }
  .gamify-tribe-acts .gamify-btn { flex: 1; }

  .gamify-grid2 { grid-template-columns: 1fr; }
}

/* ===== فیکس ریشه‌ای پرش چت: پنل گفت‌وگوی بازیکنان ارتفاع ثابت می‌گیرد تا فقط کادر پیام‌ها اسکرول شود ===== */
.gm-panel.grid[class*="md:grid-cols-[280px_1fr]"] {
  height: min(78vh, 720px);
  height: min(78dvh, 720px);
  min-height: 420px !important;
  grid-template-rows: minmax(0, 1fr);
}
.gm-panel.grid[class*="md:grid-cols-[280px_1fr]"] > * { min-height: 0; }
@media (max-width: 767px) {
  .gm-panel.grid[class*="md:grid-cols-[280px_1fr]"] { height: min(74dvh, 640px); }
}

/* ===== مرکز پاداش: چرخ شانس + ماموریت‌ها + تالار افتخار ===== */
#gamify-arena-fab {
  position: fixed; left: 14px; bottom: 312px; z-index: 99990; width: 48px; height: 48px; border-radius: 50%;
  font-size: 22px; cursor: pointer; font-family: "Vazirmatn", sans-serif;
  background: radial-gradient(circle at 30% 25%, #ffe9a8, #f2ca7c 55%, #d99a38); color: #241a10;
  border: 2px solid #fff3c9; box-shadow: 0 8px 26px rgba(242,202,124,.5);
  animation: gamifyGlow 2.4s ease-in-out infinite; transition: transform .2s ease;
}
#gamify-arena-fab:hover { transform: scale(1.12) rotate(-8deg); }
#gamify-arena-fab .gamify-fab-badge { top: -6px; right: -6px; animation: gamifyPop .4s ease; }
@keyframes gamifyGlow { 0%,100% { box-shadow: 0 8px 22px rgba(242,202,124,.35); } 50% { box-shadow: 0 8px 36px rgba(242,202,124,.85), 0 0 0 6px rgba(242,202,124,.12); } }
@keyframes gamifyShine { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
@keyframes gamifyBolt { 0%,100% { transform: scale(1); filter: drop-shadow(0 0 4px #f8c56c); } 50% { transform: scale(1.18); filter: drop-shadow(0 0 14px #ffd76a); } }
@keyframes gamifyRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.gamify-hero { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 18px; background: linear-gradient(135deg, rgba(242,202,124,.16), rgba(169,140,247,.14)); border: 1px solid rgba(242,202,124,.35); }
.gamify-hero .bolt { font-size: 40px; animation: gamifyBolt 2s ease-in-out infinite; }
.gamify-hero .lv { font-weight: 800; font-size: 16px; }
.gamify-xpbar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; margin-top: 6px; }
.gamify-xpbar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #f2ca7c, #ffe9a8, #f2ca7c); background-size: 200% 100%; animation: gamifyShine 2.6s linear infinite; transition: width .8s ease; }

.gamify-wheel-wrap { position: relative; width: min(280px, 78vw); aspect-ratio: 1; margin: 6px auto 4px; }
.gamify-wheel { width: 100%; height: 100%; border-radius: 50%; border: 6px solid #f2ca7c; box-shadow: 0 0 0 4px #241a33, 0 14px 40px rgba(0,0,0,.55), inset 0 0 30px rgba(0,0,0,.4); transition: transform 5s cubic-bezier(.12,.72,.08,1); position: relative; overflow: hidden; }
.gamify-wheel .seg { position: absolute; inset: 0; display: flex; justify-content: center; align-items: flex-start; padding-top: 9%; font-size: 24px; transform-origin: 50% 50%; }
.gamify-wheel-pin { position: absolute; top: -12px; left: 50%; transform: translateX(-50%); font-size: 30px; z-index: 2; filter: drop-shadow(0 3px 4px rgba(0,0,0,.6)); }
.gamify-wheel-hub { position: absolute; inset: 38%; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #ffe9a8, #d99a38); border: 3px solid #fff3c9; z-index: 1; display: grid; place-items: center; font-size: 26px; box-shadow: 0 4px 14px rgba(0,0,0,.5); }

.gamify-quest { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid var(--gm-line); animation: gamifyRise .4s ease both; }
.gamify-quest.done { border-color: rgba(124,215,182,.5); background: rgba(124,215,182,.07); }
.gamify-quest .ic { font-size: 28px; }
.gamify-quest .tt { font-weight: 700; font-size: 13px; }
.gamify-quest .rw { font-size: 11px; opacity: .8; margin-top: 2px; }
.gamify-quest .bar { height: 6px; border-radius: 999px; background: rgba(255,255,255,.1); margin-top: 6px; overflow: hidden; }
.gamify-quest .bar i { display: block; height: 100%; background: linear-gradient(90deg, #7cd7b6, #b9f1dc); border-radius: 999px; transition: width .6s ease; }
.gamify-hall { display: grid; gap: 6px; }
.gamify-hall .row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.04); font-size: 13px; animation: gamifyRise .4s ease both; }
.gamify-hall .row:nth-child(1) { background: linear-gradient(90deg, rgba(242,202,124,.22), transparent); }
.gamify-hall .row b { flex: 1; }
.gamify-prize-pop { text-align: center; padding: 10px; animation: gamifyPop .45s ease; }
.gamify-prize-pop .big { font-size: 56px; animation: gamifyBolt 1.2s ease-in-out infinite; }

/* انیمیشن ظریف برای کارت‌ها و دکمه‌های بازی اصلی */
.gm-panel, .gm-card { transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
.gm-panel:hover { box-shadow: 0 10px 34px rgba(0,0,0,.35); }
@media (prefers-reduced-motion: reduce) { #gamify-arena-fab, .gamify-xpbar > i, .gamify-hero .bolt { animation: none !important; } }

