/* =====================================================
   MODALS · Inventario, Negozio, Reward, Toast
   ===================================================== */

/* ===== BASE MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s ease;
}

.modal-overlay.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 500px;
  max-height: 88vh;
  background: linear-gradient(180deg, #1a1a2e 0%, #0f0f1e 100%);
  border-radius: 24px 24px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-subtitle { font-size: 12px; color: rgba(255, 255, 255, 0.6); margin-top: 2px; }
.modal-body { padding: 14px; overflow-y: auto; -webkit-overflow-scrolling: touch; max-height: 90vh; }

.close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== INVENTARIO ===== */
.rarity-section { margin-bottom: 20px; }
.rarity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.rarity-common    { color: #4ade80; }
.rarity-rare      { color: #60a5fa; }
.rarity-epic      { color: #c084fc; }
.rarity-legendary { color: #fbbf24; }

.char-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.char-card {
  aspect-ratio: 1;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s;
}

.char-card.locked { filter: grayscale(1) brightness(0.3); opacity: 0.5; }
.char-card.unlocked { background: rgba(255, 255, 255, 0.1); }
.char-card.rarity-common.unlocked    { border-color: #4ade80; box-shadow: 0 0 15px rgba(74, 222, 128, 0.4); }
.char-card.rarity-rare.unlocked      { border-color: #60a5fa; box-shadow: 0 0 15px rgba(96, 165, 250, 0.5); }
.char-card.rarity-epic.unlocked      { border-color: #c084fc; box-shadow: 0 0 15px rgba(192, 132, 252, 0.6); }
.char-card.rarity-legendary.unlocked { border-color: #fbbf24; box-shadow: 0 0 20px rgba(251, 191, 36, 0.7); animation: legendaryGlow 2s ease-in-out infinite; }

@keyframes legendaryGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(251, 191, 36, 0.7); }
  50%      { box-shadow: 0 0 30px rgba(251, 191, 36, 1); }
}

.char-card .count { position: absolute; bottom: 4px; right: 6px; font-size: 10px; font-weight: 700; background: rgba(0,0,0,0.7); padding: 1px 6px; border-radius: 8px; color: #fbbf24; }
.char-card.locked .count { display: none; }

/* ===== NEGOZIO ===== */
.shop-item { display: flex; align-items: center; gap: 14px; padding: 14px; background: rgba(255,255,255,0.05); border-radius: 16px; margin-bottom: 12px; border: 2px solid rgba(255,255,255,0.08); }
.shop-item.chest-normal    { border-color: rgba(74, 222, 128, 0.3); }
.shop-item.chest-coins     { border-color: rgba(96, 165, 250, 0.4); }
.shop-item.chest-legendary { border-color: rgba(251, 191, 36, 0.5); box-shadow: 0 0 25px rgba(251, 191, 36, 0.2); }

.shop-icon { font-size: 42px; line-height: 1; flex-shrink: 0; }
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.shop-desc { font-size: 11px; color: rgba(255, 255, 255, 0.55); line-height: 1.4; }
.shop-stock { font-size: 11px; color: rgba(255, 255, 255, 0.8); margin-top: 3px; font-weight: 600; }
.shop-stock.full { color: #f59e0b; }

.btn-buy { background: linear-gradient(90deg, #fbbf24, #f59e0b); border: none; color: #1a1a2e; padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: transform 0.15s; flex-shrink: 0; }
.btn-buy:active { transform: scale(0.94); }
.btn-buy:disabled { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.4); cursor: not-allowed; }
.btn-buy.legendary { background: linear-gradient(90deg, #a78bfa, #7c3aed); color: #fff; }

/* ===== OTTIENI CASSA ===== */
.obtain-options { display: flex; flex-direction: column; gap: 12px; }
.obtain-option { display: flex; align-items: center; gap: 14px; padding: 16px; background: rgba(255, 255, 255, 0.06); border: 2px solid rgba(255, 255, 255, 0.1); border-radius: 16px; cursor: pointer; transition: all 0.2s; color: #fff; text-align: left; font-family: inherit; width: 100%; }
.obtain-option:not(.disabled):hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(251, 191, 36, 0.4); }
.obtain-option:not(.disabled):active { transform: scale(0.98); }
.obtain-option.disabled { opacity: 0.55; cursor: default; }

.obtain-icon { font-size: 34px; line-height: 1; flex-shrink: 0; }
.obtain-info { flex: 1; min-width: 0; }
.obtain-title { font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.obtain-desc { font-size: 12px; color: rgba(255, 255, 255, 0.6); font-weight: 500; }
.obtain-arrow { font-size: 24px; color: rgba(255, 255, 255, 0.4); flex-shrink: 0; }

/* ===== REWARD POPUP ===== */
.reward-popup { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.9); backdrop-filter: blur(8px); padding: 20px; }
.reward-popup.active { display: flex; animation: fadeIn 0.3s ease; }

.reward-card { background: linear-gradient(135deg, #1a1a2e, #0f0f1e); border-radius: 24px; padding: 25px 20px; text-align: center; max-width: 300px; width: 100%; border: 2px solid rgba(255,255,255,0.15); animation: rewardPop 0.5s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes rewardPop { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.reward-card.rarity-common    { border-color: #4ade80; box-shadow: 0 0 40px rgba(74, 222, 128, 0.4); }
.reward-card.rarity-rare      { border-color: #60a5fa; box-shadow: 0 0 40px rgba(96, 165, 250, 0.5); }
.reward-card.rarity-epic      { border-color: #c084fc; box-shadow: 0 0 50px rgba(192, 132, 252, 0.6); }
.reward-card.rarity-legendary { border-color: #fbbf24; box-shadow: 0 0 60px rgba(251, 191, 36, 0.7); }

.reward-emoji { font-size: 75px; line-height: 1; margin-bottom: 15px; animation: bounceIn 0.7s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes bounceIn { 0% { transform: scale(0) rotate(-180deg); } 60% { transform: scale(1.2) rotate(10deg); } 100% { transform: scale(1) rotate(0deg); } }

.reward-rarity { font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; margin-bottom: 6px; }
.reward-name { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.reward-status { font-size: 13px; color: rgba(255, 255, 255, 0.7); margin-bottom: 20px; }
.reward-status.duplicate { color: #fbbf24; font-weight: 600; }

/* ===== BOTTONI PRIMARI ===== */
.btn-primary {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  border: none;
  color: #1a1a2e;
  padding: 14px 30px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform 0.15s;
}

.btn-primary:active { transform: scale(0.96); }
.btn-primary:disabled { background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.4); cursor: not-allowed; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  z-index: 300;
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  max-width: 85%;
  text-align: center;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== SETTINGS ===== */
.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(0.9); }

.settings-section { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.settings-section:last-child { border-bottom: none; margin-bottom: 0; }
.settings-label { font-size: 13px; font-weight: 700; color: rgba(255, 255, 255, 0.5); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; font-size: 14px; font-weight: 500; }

.toggle-switch { background: #ef4444; border: none; color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 700; cursor: pointer; transition: all 0.2s; min-width: 55px; }
.toggle-switch.on { background: #4ade80; color: #0f0f1e; }

.settings-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 14px; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; margin-top: 8px; transition: background 0.2s; }
.settings-btn:active { background: rgba(255, 255, 255, 0.1); }
.settings-btn.danger { color: #ef4444; border-color: rgba(239, 68, 68, 0.3); }
.settings-info { padding: 12px 16px; background: rgba(255, 255, 255, 0.03); border-radius: 14px; font-size: 13px; color: rgba(255, 255, 255, 0.7); }

/* ===== INFO ===== */
.info-icon { font-family: serif !important; font-style: italic; font-weight: 900; color: #60a5fa !important; border-color: rgba(96, 165, 250, 0.4) !important; background: rgba(96, 165, 250, 0.1) !important; }
.info-section { margin-bottom: 24px; background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 16px; padding: 16px; }
.info-title { font-size: 15px; font-weight: 800; color: #fbbf24; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.info-text { font-size: 13px; line-height: 1.5; color: rgba(255, 255, 255, 0.8); }
.info-chest-row { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed rgba(255, 255, 255, 0.1); }
.info-chest-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.info-chest-name { font-size: 13px; font-weight: 700; margin-bottom: 6px; color: #fff; }
.info-probs { display: flex; gap: 8px; flex-wrap: wrap; }
.info-probs span { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); }
.info-probs .p-common    { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
.info-probs .p-rare      { color: #60a5fa; background: rgba(96, 165, 250, 0.1); }
.info-probs .p-epic      { color: #c084fc; background: rgba(192, 132, 252, 0.1); }
.info-probs .p-legendary { color: #fbbf24; background: rgba(251, 191, 36, 0.1); }
.info-wheel-list { display: flex; flex-direction: column; gap: 6px; }
.info-wheel-list div { display: flex; justify-content: space-between; font-size: 12px; padding: 6px 10px; background: rgba(255, 255, 255, 0.04); border-radius: 8px; color: rgba(255, 255, 255, 0.85); }