/* game.css — صفحه‌ی بازی: بوم تمام‌صفحه، Joystick، دکمه‌های اکشن، HUD */

.game-screen {
  position: relative;
  padding: 0;
  overflow: hidden;
  background: #1a1410;
}

#game-canvas-container {
  position: absolute;
  inset: 0;
  touch-action: none; /* جلوگیری از اسکرول/زوم مرورگر روی بوم بازی */
}
#game-canvas-container canvas {
  display: block;
}

/* --- HUD بالای صفحه --- */
.game-hud {
  position: absolute;
  top: env(safe-area-inset-top);
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  z-index: 20;
  pointer-events: none;
}
.game-hud .hud-stats {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.hud-pill {
  background: rgba(26, 20, 16, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}
.hud-back-btn {
  pointer-events: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(26, 20, 16, 0.75);
  border: 1px solid var(--color-border);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- نوار XP نازک زیر HUD بالای صفحه‌ی بازی --- */
.hud-xp-track {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 46px);
  left: 14px;
  right: 14px;
  height: 5px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
  z-index: 20;
  pointer-events: none;
}
.hud-xp-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary));
  transition: width 0.4s ease;
}

/* --- جلوه‌ی نوری تمام‌صفحه هنگام Level Up --- */
.level-up-flash {
  position: absolute;
  inset: 0;
  z-index: 44;
  background: radial-gradient(circle, rgba(232, 176, 75, 0.55), rgba(232, 176, 75, 0) 70%);
  opacity: 0;
  pointer-events: none;
}
.level-up-flash.is-flashing {
  animation: level-up-flash 0.9s ease;
}
@keyframes level-up-flash {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .level-up-flash.is-flashing { animation: none; }
}

/* --- Joystick مجازی (پایین چپ) --- */
.joystick-zone {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 20px;
  z-index: 20;
}
.joystick-base {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: rgba(26, 20, 16, 0.45);
  border: 2px solid rgba(243, 233, 220, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.joystick-knob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(232, 176, 75, 0.85);
  border: 2px solid rgba(255,255,255,0.4);
  transition: transform 0.05s linear;
  pointer-events: none;
}

/* --- دکمه‌های اکشن (پایین راست) --- */
.action-buttons {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: 20px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.action-btn {
  width: 56px;
  height: 56px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: rgba(44, 33, 25, 0.85);
  border: 1px solid var(--color-border);
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
}
.action-btn:active {
  transform: scale(0.92);
}
.action-btn.is-highlighted {
  background: linear-gradient(180deg, var(--color-accent), var(--color-primary));
}

/* --- دکمه‌ی تعامل: حالت غیرفعال وقتی هیچ NPC نزدیک نیست --- */
.action-btn.is-disabled {
  opacity: 0.4;
  filter: grayscale(0.6);
}
.action-btn.is-pulsing {
  animation: pulse-glow 1.1s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 176, 75, 0.55); }
  50% { box-shadow: 0 0 0 10px rgba(232, 176, 75, 0); }
}

/* --- لایه‌ی Modal مشترک (Dialogue / Missions) --- */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 6, 0.55);
  display: none;
  align-items: flex-end;
  z-index: 40;
}
.modal-overlay.is-visible {
  display: flex;
}

/* --- جعبه‌ی دیالوگ --- */
.dialogue-box {
  width: 100%;
  background: var(--color-bg-elevated, #241a12);
  border-top: 2px solid var(--color-accent, #e8b04b);
  border-radius: 18px 18px 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: sheet-slide-up 0.22s ease;
}
.dialogue-name {
  font-weight: 800;
  color: var(--color-accent, #e8b04b);
  font-size: 15px;
}
.dialogue-text {
  font-size: 15px;
  line-height: 1.9;
  min-height: 48px;
}

/* --- پنل ماموریت‌ها (Bottom Sheet) --- */
.panel-sheet {
  width: 100%;
  max-height: 72vh;
  background: var(--color-bg-elevated, #241a12);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheet-slide-up 0.22s ease;
}
@keyframes sheet-slide-up {
  from { transform: translateY(16px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .dialogue-box, .panel-sheet { animation: none; }
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 800;
  font-size: 16px;
}
.panel-header button {
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
}
.panel-body {
  overflow-y: auto;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quest-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.quest-card .quest-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 4px;
}
.quest-card .quest-desc {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin-bottom: 8px;
  line-height: 1.6;
}
.quest-card .quest-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}
.quest-status-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-weight: 700;
}
.quest-status-badge.status-locked { background: rgba(255,255,255,0.08); color: #9a9a9a; }
.quest-status-badge.status-available { background: rgba(74,144,192,0.25); color: #7cc0e8; }
.quest-status-badge.status-active { background: rgba(232,176,75,0.25); color: var(--color-accent, #e8b04b); }
.quest-status-badge.status-completed { background: rgba(90,180,90,0.25); color: #8fd18f; }
.quest-reward {
  color: var(--color-accent, #e8b04b);
  font-weight: 700;
}
.quest-card.is-locked { opacity: 0.55; }

/* --- کارت آیتم فروشگاه --- */
.shop-item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.shop-item-icon {
  font-size: 26px;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.shop-item-info { flex: 1; min-width: 0; }
.shop-item-name { font-weight: 700; font-size: 14px; }
.shop-item-desc { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.shop-item-price { font-size: 12px; font-weight: 700; color: var(--color-accent, #e8b04b); margin-top: 4px; }
.shop-buy-btn {
  min-width: 64px;
  min-height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #241708;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.shop-buy-btn:disabled {
  opacity: 0.45;
  filter: grayscale(0.4);
}

/* --- گرید اینونتوری --- */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.inventory-slot {
  aspect-ratio: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 24px;
  position: relative;
}
.inventory-slot .qty-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.6);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  color: #fff;
}
.inventory-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 30px 10px;
  color: var(--color-text-muted);
  font-size: 13px;
}
.reward-banner {
  position: absolute;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-12px);
  background: linear-gradient(135deg, var(--color-accent, #e8b04b), var(--color-primary, #c17f3e));
  color: #241708;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  text-align: center;
  z-index: 45;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}
.reward-banner.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.reward-banner-title {
  font-weight: 800;
  font-size: 15px;
}
.reward-banner-items {
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}
