MainHud/RandomEventManager.cs

RandomEventManager static class that triggers a wide variety of in-game random events affecting player and AI state, applying heals, damage, buffs, debuffs, and spawning choice popups. It reads scene GameManager data, logs events, plays sounds, and delegates some event runners to other classes.

NetworkingFile Access
using Keyboard_Warriors_.Models;
using Keyboard_Warriors_.Systems;
using Sandbox;
using System;
using System.Collections.Generic;
using System.Linq;
using static Sandbox.Soundscape;

namespace Keyboard_Warriors_.Managers;

public static class RandomEventManager
{

	public static bool HitJackpot { get; set; } = false;
	private static Random rand = new Random();

	public static void playSoundEffect( string soundEffect )
	{
		// Logs out directly to s&box engine diagnostics buffer
		GameManager.AddLog( soundEffect );
	}

	public static void randomEvent( ref Player player, ref Player ai, ref int playerBuff, ref int aiBuff, SoundEvent pingSound )
	{
		if ( player == null || ai == null ) return;

		Log.Info( $"The sound event is: {pingSound}" );

		if ( pingSound != null )
		{
			Log.Info( "Sound is not null, attempting to play..." );
			Sound.Play( pingSound );
		}
		else
		{
			Log.Error( "PING SOUND IS NULL! Check the Inspector!" );
		}



		// 10% structural trigger window matching legacy base engine mechanics

		int eventType = rand.Next( 86 );
		GameManager.AddEventLog( "\n=== RANDOM MAINWARE EVENT ===" );
			switch (eventType)
		{ 
			case 0:
			{
				// 1. Fetch the GameManager from the active scene to read prestige scaling fields
				var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
				int prestige = manager != null ? manager.CurrentPrestige : 0;

				// 2. Scale the healing output lineally (+4 extra healing per prestige level)
				// We also dynamically combine your character's eventHealingBuff property!
				int totalPlayerHeal = 15 + (prestige * 4) + player.eventHealingBuff;
				int totalAIHeal = 15 + (prestige * 4) + ai.eventHealingBuff;

				GameManager.AddLog( $"** A strange green mist rolls in... Both players feel rejuvenated! (You: +{totalPlayerHeal} HP | AI: +{totalAIHeal} HP) **" );
				player.hp += totalPlayerHeal;
				ai.hp += totalAIHeal;

				// 3. Dynamic Cap Check: Clamp to the true prestige max HP pools instead of hardcoded 100!
				int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
				int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

				if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
				if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

				// 4. CRITICAL CLEANUP: Consume the healing buffs so they apply only to this unique turn event!
				player.eventHealingBuff = 0;
				ai.eventHealingBuff = 0;

				GameManager.AddLog( $"{player.name} is now at {player.hp} HP." );
				GameManager.AddLog( $"{ai.name} is now at {ai.hp} HP." );
				break;
			}

			case 1:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int scaledDamage = 10 + (prestige * 3);

					GameManager.AddLog( $"** An atmospheric blue electric surge fills the sky, the AI gets zapped! -{scaledDamage}HP! **" );
					CombatManager.applyDamage( ref ai, scaledDamage );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 2:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int scaledBuff = 10 + (prestige * 3);

					GameManager.AddLog( $"** A dagger is dropped by a horserider running by, your next attack will be boosted by {scaledBuff} next round! **" );
		
					// FIX: Securely pass the buff directly into the player's permanent object variable slot instead of playerBuff!
					player.eventAttackBuff += scaledBuff;
					break;
				}

			case 3:
				GameManager.AddLog( "** The ground shakes violently! Both fighters are dazed! No attacks this round! **" );
				// If you track your dazed/stun state via fields, keep these, 
				// but make sure your turn calculations skip when processing damage lines
				playerBuff = -999;
				aiBuff = -999;
				break;

			case 4:
				GameManager.AddLog( "** A chicken walks across the battlefield... it lays an egg... nothing happens **" );
				break;

			case 5:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int scaledDamage = 20 + (prestige * 5);

					GameManager.AddLog( $"** A uranium surge pulses through the fighters! Everyone gets scorched! -{scaledDamage} HP! **" );
					CombatManager.applyDamage( ref player, scaledDamage );
					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );

					CombatManager.applyDamage( ref ai, scaledDamage );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 6:
				GameManager.AddLog( "** A spaceship hovers overhead and fires a confusion ray! Accuracy drops! **" );
				playerBuff = -1;
				aiBuff = -1;
				break;

			case 7:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale healing slightly (+2 per prestige) and add your new healing buffs
					int totalPlayerHeal = 5 + (prestige * 2) + player.eventHealingBuff;
					int totalAIHeal = 5 + (prestige * 2) + ai.eventHealingBuff;

					GameManager.AddLog( $"** A mime walks silently across the battlefield miming a boxing match, taking damage and dealing... both laugh. (You: +{totalPlayerHeal} HP | AI: +{totalAIHeal} HP) **" );
					player.hp += totalPlayerHeal;
					ai.hp += totalAIHeal;

					// Resolve safe prestige-scaled max caps
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
					if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

					// Consume the healing buffs
					player.eventHealingBuff = 0;
					ai.eventHealingBuff = 0;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 8:
				GameManager.AddLog( "** An old man limps into view, shaking his cane: 'You two get a real job!' **" );
				GameManager.AddLog( "*Everyone pauses in shame...*" );
				break;

			case 9:
				{
					GameManager.AddLog( "** A stork glides into view and drops a clothed bag, instead of a baby, it's a package! **" );
					GameManager.AddLog( "⚠️ WAITING FOR CORE PROTOCOL DATA OVERRIDE..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					// Calculate scaled reward/risk parameters (+3 to +5 per prestige level)
					// We also stack any existing healing buffs onto the potion/imp calculations
					int scaledImpHeal = 20 + (prestige * 5) + player.eventHealingBuff;
					int scaledBarbBuff = 10 + (prestige * 3);
					int scaledPotionHeal = 15 + (prestige * 4) + player.eventHealingBuff;
					int scaledPotionBuff = 20 + (prestige * 5);
					int scaledPotionDamage = 15 + (prestige * 4);

					var p = player;
					var a = ai;

					var storkPackageEvent = new ChoiceEvent
					{
						Title = "📦 STORK'S DROPPED DELIVERABLE",
						PromptText = "A stork glides into view and drops a clothed bag, instead of a baby, it's a package! What item will you pull from the package?",
					};

					// --- BUTTON 1: GREEN TREE IMP ---
					storkPackageEvent.Options.Add( new EventOption
					{
						ButtonText = "🟢 RELEASE GREEN TREE IMP",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"The package releases a green tree imp, it winks, then emits a green healing mist your way! +{scaledImpHeal} HP!" );
							p.hp += scaledImpHeal;

							if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;

							// Consume the healing buff slot
							p.eventHealingBuff = 0;

							GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						}
					} );

					// --- BUTTON 2: MINI BARBARIAN ---
					storkPackageEvent.Options.Add( new EventOption
					{
						ButtonText = "⚔️ RELEASE MINI BARBARIAN",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"The package releases a mini barbarian, it roars, boosting a surge of strength! +{scaledBarbBuff} damage next attack!" );

							// FIX: Map directly to the player's secure object property instead of the global proxy slider!
							p.eventAttackBuff += scaledBarbBuff;
						}
					} );

					// --- BUTTON 3: MYSTERY POTION ---
					storkPackageEvent.Options.Add( new EventOption
					{
						ButtonText = "🧪 DRINK MYSTERY POTION",
						ActionToExecute = () =>
						{
							int outcome = Random.Shared.Next( 2 );
							if ( outcome == 0 )
							{
								GameManager.AddLog( $"The potion is white and upon ingesting an angel blesses you and heals your wounds for +{scaledPotionHeal} HP! and +{scaledPotionBuff} damage next attack!" );
								p.hp += scaledPotionHeal;

								if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;

								// FIX: Assign both modifiers directly to your definitive model properties!
								p.eventAttackBuff += scaledPotionBuff;
								p.eventHealingBuff = 0;
							}
							else
							{
								GameManager.AddLog( $"The potion is black with skulls emanating from the liquid, it explodes in your face! -{scaledPotionDamage} HP!" );
								CombatManager.applyDamage( ref p, scaledPotionDamage );
							}

							GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						}
					} );

					GameManager.Instance.TriggerChoicePopup( storkPackageEvent );
					break;
				}

			case 10:
				GameManager.AddLog( "**A lightning bolt strikes the center of the battlefield! The ground surges blue electric energy! The next attack from both fighters will be +20 damage! **" );
				// FIX: Stored safely in your permanent object template variables
				player.eventAttackBuff += 20;
				ai.eventAttackBuff += 20;
				break;

			case 11:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int scaledPenalty = 5 + (prestige * 1);

					GameManager.AddLog( $"** A gnome runs up and tickles your armpit! You lose {scaledPenalty} attack points next round! **" );
					// FIX: Deduct directly from your permanent tracking variable slot
					player.eventAttackBuff -= scaledPenalty;
					break;
				}

			case 12:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale healing slightly and stack your active event healing buff!
					int totalHeal = 10 + (prestige * 2) + player.eventHealingBuff;

					GameManager.AddLog( $"** An enchanted mirror appears in front of you, showing a greater version of yourself. You're inspired! +{totalHeal} HP! **" );
					player.hp += totalHeal;

					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

					// Consume the healing buff
					player.eventHealingBuff = 0;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;
				}

			case 13:
				// Status turn exclusion flags safely remain standard across execution loops
				GameManager.AddLog( "** The AI glitches and enters debug mode. It skips the next turn. **" );
				aiBuff = -999;
				break;

			case 14:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale recovery and performance buffs while stacking active multipliers
					int totalPlayerHeal = 10 + (prestige * 2) + player.eventHealingBuff;
					int totalAIHeal = 10 + (prestige * 2) + ai.eventHealingBuff;
					int scaledBuff = 5 + (prestige * 1);

					GameManager.AddLog( $"** A passing bard sings a morale-boosting song! You recover {totalPlayerHeal} HP, AI recovers {totalAIHeal} HP, and both gain +{scaledBuff} damage next round! **" );

					player.hp += totalPlayerHeal;
					ai.hp += totalAIHeal;

					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
					if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

					// FIX: Securely pass the attack and healing variables directly into your entities
					player.eventAttackBuff += scaledBuff;
					ai.eventAttackBuff += scaledBuff;
					player.eventHealingBuff = 0;
					ai.eventHealingBuff = 0;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 15:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int scaledAIBuff = 20 + (prestige * 3);

					GameManager.Instance.PlayRoboticGlitchSound();
					GameManager.AddLog( $"**The AI starts to perform mathematical operations, writes 10 chivalry poems every 5 seconds, and names off weapons you've never heard of! AI gets a combat boost +{scaledAIBuff} points! **" );

					// FIX: Map directly to the AI's permanent object variable slot
					ai.eventAttackBuff += scaledAIBuff;
					break;
				}

			case 16:
				{
					GameManager.AddLog( "** A veiled lady mushroom sprouts dramatically and whispers in your mind: 'Slap me or hear my tale... your fate awaits.' **" );
					GameManager.AddLog( "⚠️ WAITING FOR NEURAL LINK RECEPTION..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					// Calculate scaled reward/risk boundaries
					int scaledSporeDamage = 15 + (prestige * 4);
					int scaledSlapBuff = 15 + (prestige * 4);
					int scaledTaleDamage = 10 + (prestige * 2);
					int scaledTaleBuff = 10 + (prestige * 3);
					int scaledTaleHeal = 10 + (prestige * 3) + player.eventHealingBuff;

					var p = player;
					var a = ai;

					var mushroomEvent = new ChoiceEvent
					{
						Title = "🍄 THE VEILED LADY REVELATION",
						PromptText = "A massive veiled lady mushroom has manifested through the terminal grid core. It speaks directly into your digital consciousness. Will you attack it or listen?",
					};

					// --- OPTION 1: SLAP THE MUSHROOM ---
					mushroomEvent.Options.Add( new EventOption
					{
						ButtonText = "💥 SLAP THE MUSHROOM",
						ActionToExecute = () =>
						{
							int outcome = Random.Shared.Next( 2 );

							if ( outcome == 0 )
							{
								GameManager.AddLog( $"** The mushroom emits a misty toxic spore cloud and terrifies you! -{scaledSporeDamage} HP! **" );
								CombatManager.applyDamage( ref p, scaledSporeDamage );
							}
							else
							{
								GameManager.AddLog( $"** The mushroom bursts into gold dust! You inhale power! +{scaledSlapBuff} attack next round! **" );

								// FIX: Map the attack reward directly to your model slot!
								p.eventAttackBuff += scaledSlapBuff;
							}

							GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						}
					} );

					// --- OPTION 2: HEAR THE TALE ---
					mushroomEvent.Options.Add( new EventOption
					{
						ButtonText = "📖 LISTEN TO ITS TALE",
						ActionToExecute = () =>
						{
							int outcome = Random.Shared.Next( 2 );

							if ( outcome == 0 )
							{
								GameManager.AddLog( $"** The mushroom speaking to your mind enters your emotions, it tells you a tale of tragic loss.. you feel emotionally drained. -{scaledTaleDamage} HP. **" );
								CombatManager.applyDamage( ref p, scaledTaleDamage );
							}
							else
							{
								GameManager.AddLog( $"** The mushroom infiltrates your endorphins and dopamine receptors and starts to whisper battle techniques! +{scaledTaleBuff} damage, +{scaledTaleHeal} HP restored! **" );

								p.hp += scaledTaleHeal;

								if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;

								// FIX: Store parameters directly into your model variables cleanly
								p.eventAttackBuff += scaledTaleBuff;
								p.eventHealingBuff = 0;
							}

							GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						}
					} );

					GameManager.Instance.TriggerChoicePopup( mushroomEvent );
					break;
				}

			case 17:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					// Scale values linearly with prestige while weaving in the healing buff slot
					int totalHeal = 15 + (prestige * 3) + player.eventHealingBuff;
					int scaledBuff = 10 + (prestige * 2);
					int scaledLossHp = 10 + (prestige * 2);
					int scaledLossBuff = 5 + (prestige * 1);

					GameManager.AddLog( "** An enchanted mirror floats before you, refracting with ethereal light... **" );
					int outcome = Random.Shared.Next( 2 );

					if ( outcome == 0 )
					{
						GameManager.AddLog( $"** The reflection smiles proudly - a future champion! You're inspired! +{totalHeal} HP and +{scaledBuff} attack next round! **" );
						player.hp += totalHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

						// FIX: Apply the attack buff straight to the new object tracker
						player.eventAttackBuff += scaledBuff;
						player.eventHealingBuff = 0;
					}
					else
					{
						GameManager.AddLog( $"** The reflection looks at you as a stranger, then laughs at you mockingly. You lose confidence. -{scaledLossHp} HP and -{scaledLossBuff} attack next round. **" );
						player.hp -= scaledLossHp;

						// FIX: Deduct from the proper new object field
						player.eventAttackBuff -= scaledLossBuff;
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;
				}

			case 18:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					// Scale rewards and penalties while stacking active multipliers
					int totalNanobotHeal = 25 + (prestige * 4) + player.eventHealingBuff;
					int scaledParadoxDamage = 10 + (prestige * 2);
					int scaledParadoxBuffLoss = 5 + (prestige * 1);

					GameManager.AddLog( "** A wormhole tears open in front of you! A future version of you steps out, battle-scarred and glowing with knowledge... **" );
					int outcome = Random.Shared.Next( 2 );

					if ( outcome == 0 )
					{
						GameManager.AddLog( $"** They nod solemnly and hand you a device: 'Use this.. to help you with this battle.' It's a healing nanobot swarm! +{totalNanobotHeal} HP! **" );
						player.hp += totalNanobotHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

						player.eventHealingBuff = 0;
					}
					else
					{
						GameManager.AddLog( $"** They shake their head: 'You weren't supposed to come here...' They vanish in a flash of paradox light. You're dazed. -{scaledParadoxDamage} HP, -{scaledParadoxBuffLoss} attack next round. **" );
						CombatManager.applyDamage( ref player, scaledParadoxDamage );

						// FIX: Deduct from the proper object variable
						player.eventAttackBuff -= scaledParadoxBuffLoss;
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;
				}

			case 19:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int scaledColdDamage = 15 + (prestige * 3);

					GameManager.AddLog( $"** A beggar walks nearby and coughs at you, giving you a nasty cold! -{scaledColdDamage} HP! **" );
					CombatManager.applyDamage( ref player, scaledColdDamage );
					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;
				}

			case 20:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					int baseRoll = Random.Shared.Next( 6 ) + 5;
					int calculatedAIBuff = baseRoll + (prestige * 2);

					// FIX: Bind directly to your new secure object variable slot
					ai.eventAttackBuff += calculatedAIBuff;

					GameManager.AddLog( "** The AI proceeds with lightning fast optimization and patches its combat routines! **" );
					GameManager.AddLog( $"** AI's attack caused +{calculatedAIBuff} damage points! **" );
					break;
				}

			case 21:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					int baseRoll = Random.Shared.Next( 7 ) + 4;
					int calculatedAIBuff = baseRoll + (prestige * 2);

					// FIX: Bind directly to your new secure object variable slot
					ai.eventAttackBuff += calculatedAIBuff;

					GameManager.AddLog( "** The AI receives targeting data from the heavens! **" );
					GameManager.AddLog( $"** AI's buff increases by {calculatedAIBuff} damage points! **" );
					break;
				}

			case 22:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					GameManager.AddLog( "** A purple unknown energy fills the air and causes heavy vibrations teeming with power! The AI's system... **" );

					int baseFluctuation = (Random.Shared.Next( 2 ) == 0) ? -3 : 5;

					if ( baseFluctuation > 0 )
					{
						int finalAIBuff = baseFluctuation + (prestige * 2);

						// FIX: Map directly to the definitive object property slot
						ai.eventAttackBuff += finalAIBuff;
						GameManager.AddLog( $"spikes with a chaotic flux! Attack is at +{finalAIBuff} damage points" );
					}
					else
					{
						int finalAIBuffPenalty = baseFluctuation - (prestige * 1);

						// FIX: Apply the attack penalty securely directly to the AI object
						ai.eventAttackBuff += finalAIBuffPenalty;
						GameManager.AddLog( $"loses control of its operating system! It has lost {finalAIBuffPenalty} damage points" );
					}
					break;
				}

			case 23:
				GameManager.AddLog( "** The AI scoops up dirt with its servo arm and pitches it right into your eyes! **" );
				GameManager.AddLog( "** You scream in stinging eye pain as you grasp your face, you aren't facing the opponent and stumble around! You lose attack next round! **" );
				// Keep the status flag tracking loop intact for stun checks
				playerBuff = -999;
				break;

			case 24:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					// Scale the answered prayer rewards/penalties linearly (+2 to +3 per level)
					// We weave in your custom player healing buff modifier directly to the bless output
					int totalBlessHeal = 10 + (prestige * 2) + player.eventHealingBuff;
					int scaledBlessBuff = 15 + (prestige * 3);
					int scaledCurseDamage = 10 + (prestige * 2);
					int scaledCurseBuffLoss = 15 + (prestige * 3);

					GameManager.AddLog( "** You throw in a quick prayer and ask for assistance! **" );
					int outcome = Random.Shared.Next( 2 );

					if ( outcome == 0 )
					{
						GameManager.AddLog( $"** Your answered by a divine energy, you have been blessed with +{totalBlessHeal} HP and +{scaledBlessBuff} attack! **" );
						player.hp += totalBlessHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

						// FIX: Apply the attack and healing variables directly into your entities
						player.eventAttackBuff += scaledBlessBuff;
						player.eventHealingBuff = 0;
					}
					else
					{
						GameManager.AddLog( $"** You're ignored and forsaken with your prayer denied and you feel an evil energy overconsume you. You have been cursed with -{scaledCurseDamage} HP and -{scaledCurseBuffLoss} attack! **" );
						CombatManager.applyDamage( ref player, scaledCurseDamage );

						
						player.eventAttackBuff -= scaledCurseBuffLoss;
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;
				}

			case 25:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					GameManager.AddLog( "** You throw two dice to determine your attack fate! **" );
					int die1 = Random.Shared.Next( 6 ) + 1;
					int die2 = Random.Shared.Next( 6 ) + 1;

					int diceSum = die1 + die2;
					int scaledSum = diceSum + (prestige * 2);

					GameManager.AddLog( $"** You rolled a {die1} and a {die2} for a total of {diceSum}! **" );
					GameManager.AddLog( $"** Your attack buff increases by {scaledSum} points! **" );

					
					player.eventAttackBuff += scaledSum;
					break;
				}

			case 26:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					GameManager.AddLog( "** The AI displays a hologram projection of two dice... **" );
					int die1 = Random.Shared.Next( 6 ) + 1;
					int die2 = Random.Shared.Next( 6 ) + 1;

					int total = die1 + die2;
					int scaledTotal = total + (prestige * 2);

					GameManager.AddLog( $"** The AI rolls a {die1} and a {die2}! Total: {total} **" );
					GameManager.AddLog( $"** The hologram dice charge the AI's attack with +{scaledTotal} damage next round! **" );

					// FIX: Map directly to the AI's permanent object variable slot
					ai.eventAttackBuff += scaledTotal;
					break;
				}

			case 27:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int baseDamage = Random.Shared.Next( 11 ) + 10;
					int scaledDamage = baseDamage + (prestige * 3);

					CombatManager.applyDamage( ref player, scaledDamage );
					// Keep your dazed status value tracker configuration intact
					playerBuff = -999;

					GameManager.AddLog( $"** You're shocked and twitching! -{scaledDamage} HP and you're stunned for a round! **" );
					playSoundEffect( "*BZZZZTTT!*" );

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;
				}

			case 28:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					int totalJackpotHeal = 100 + (prestige * 15) + player.eventHealingBuff;
					int scaledJackpotBuff = 100 + (prestige * 15);

					GameManager.AddLog( "** You find a mysterious scratch-off lottery ticket on the battlefield... **" );
					GameManager.AddLog( " It reads: '1 in 1000 chance to win BIG!' You nervously scratch it.." );

					int luck = Random.Shared.Next( 1000 );

					if ( luck == 0 )
					{
						GameManager.AddLog( $"** JACKPOT!!! You've won the mythical grand prize! +{totalJackpotHeal}HP and +{scaledJackpotBuff} attack next round! **" );
						player.hp += totalJackpotHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

						player.eventAttackBuff += scaledJackpotBuff;
						player.eventHealingBuff = 0;

						HitJackpot = true;
					}
					else
					{
						GameManager.AddLog( "** YOU LOSE!!! The ticket crumbles to dust. You droop your head in gambling shame. **" );
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;
				}

			case 29:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int pBonus = prestige * 2;

					GameManager.AddLog( "** You roll a mythical d100... time and physics decides your power this turn! **" );
					int roll = Random.Shared.Next( 100 ) + 1;

					GameManager.AddLog( $"** You rolled: {roll}! **" );

					if ( roll == 100 )
					{
						int amt = 50 + pBonus;
						player.eventAttackBuff += amt; // FIX: Target proper object tracker
						GameManager.AddLog( $"** LEGENDARY ROLL! +{amt} attack this round!! **" );
					}
					else if ( roll >= 90 )
					{
						int amt = 30 + pBonus;
						player.eventAttackBuff += amt;
						GameManager.AddLog( $"** Incredible! +{amt} attack! **" );
					}
					else if ( roll >= 70 )
					{
						int amt = 15 + pBonus;
						player.eventAttackBuff += amt;
						GameManager.AddLog( $"** Not bad! +{amt} attack! **" );
					}
					else if ( roll >= 40 )
					{
						int amt = 5 + pBonus;
						player.eventAttackBuff += amt;
						GameManager.AddLog( $"** A small edge. +{amt} attack! **" );
					}
					else if ( roll >= 10 )
					{
						int amt = 10 + pBonus;
						player.eventAttackBuff -= amt;
						GameManager.AddLog( $"** Oof... -{amt} attack this round. **" );
					}
					else
					{
						int amt = 20 + pBonus;
						player.eventAttackBuff -= amt;
						GameManager.AddLog( $"** CURSED! -{amt} attack! The dice, physics, God, time, and gravity hate you!! (at this moment) **" );
					}
					break;
				}

			case 30:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int pBonus = prestige * 2;

					GameManager.AddLog( "** The AI projects its hologram of a d100 and rolls it! **" );
					int roll = Random.Shared.Next( 100 ) + 1;

					GameManager.AddLog( $"** AI rolled: {roll}! **" );

					if ( roll == 100 )
					{
						int amt = 50 + pBonus;
						ai.eventAttackBuff += amt; 
						GameManager.AddLog( $"** CRITICAL ALGORITHM SUCCESS! AI gains +{amt} attack! **" );
					}
					else if ( roll >= 90 )
					{
						int amt = 30 + pBonus;
						ai.eventAttackBuff += amt;
						GameManager.AddLog( $"** AI adds up the good result into +{amt} attack damage! **" );
					}
					else if ( roll >= 70 )
					{
						int amt = 15 + pBonus;
						ai.eventAttackBuff += amt;
						GameManager.AddLog( $"** AI compiles with +{amt} attack! **" );
					}
					else if ( roll >= 40 )
					{
						int amt = 5 + pBonus;
						ai.eventAttackBuff += amt;
						GameManager.AddLog( $"** AI musters a small +{amt} attack! **" );
					}
					else if ( roll >= 10 )
					{
						int amt = 10 + pBonus;
						ai.eventAttackBuff -= amt;
						GameManager.AddLog( $"** AI finds some bugs messing up the d100 roll! -{amt} attack! **" );
					}
					else
					{
						int amt = 20 + pBonus;
						ai.eventAttackBuff -= amt;
						GameManager.AddLog( $"** BLUE SCREEN! AI loses {amt} attack power! **" );
					}
					break;
				}

			case 31:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					GameManager.AddLog( "** The AI operates its DJ set and plays an electrifying electronic beat! **" );
					GameManager.AddLog( "** The bass drops so hard the battlefield trembles... **" );

					int baseIntensity = Random.Shared.Next( 6 ) + 5; // 5 to 10
					int scaledIntensity = baseIntensity + (prestige * 2);

					
					ai.eventAttackBuff += scaledIntensity;

					GameManager.AddLog( $"** AI's attack is boosted by +{scaledIntensity} damage next round! **" );
					GameManager.AddLog( "AI: \"Prepare for my Bass Cannon! - WUUUB WUB WUBB.\"" );
					break;
				}

			case 32:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					int scaledPlayerBuff = 10 + (prestige * 2);
					int scaledAIBuff = 15 + (prestige * 2);

					GameManager.AddLog( "** The sun suddenly powers off and goes dark **" );
					int whoRecovers = Random.Shared.Next( 2 );

					if ( whoRecovers == 0 )
					{
						GameManager.AddLog( $"** You adapt to the night. Next attack is guaranteed +{scaledPlayerBuff}! **" );

						// FIX: Securely pass the buff directly into the player's permanent object variable slot
						player.eventAttackBuff += scaledPlayerBuff;
					}
					else
					{
						GameManager.AddLog( $"** The AI's night vision kicks in. It gains +{scaledAIBuff} attack next round! **" );

						// FIX: Map directly to the AI's permanent object variable slot
						ai.eventAttackBuff += scaledAIBuff;
					}
					break;
				}

			case 33:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the anomaly fluctuation hits (+2 per prestige tier)
					int pBonus = prestige * 2;

					GameManager.AddLog( "** A strange anomaly appears on the battlefield! **" );

					int roll = Random.Shared.Next( 100 ) + 1;
					GameManager.AddLog( $"** Rolling for fate... you rolled: {roll}! **" );

					if ( roll <= 40 )
					{
						int dmg = Random.Shared.Next( 10 ) + 5 + pBonus;
						CombatManager.applyDamage( ref player, dmg );
						if ( player.hp < 0 ) player.hp = 0;

						GameManager.AddLog( $"** A sudden shockwave hits YOU! -{dmg} HP! **" );
					}
					else if ( roll <= 70 )
					{
						int dmg = Random.Shared.Next( 10 ) + 5 + pBonus;
						CombatManager.applyDamage( ref ai, dmg );
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"** The anomaly backfires on the AI! -{dmg} HP! **" );
					}
					else if ( roll <= 90 )
					{
						int dmg = Random.Shared.Next( 5 ) + 1 + pBonus;

						CombatManager.applyDamage( ref player, dmg );
						CombatManager.applyDamage( ref ai, dmg );

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"** Both fighters are affected! -{dmg} HP each! **" );
					}
					else
					{
						GameManager.AddLog( "** Miraculously, nothing happens! Fate smiles on both combatants! **" );
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 34:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int pBonus = prestige * 3;

					GameManager.AddLog( "** The combatants unleash unpredictable signature moves! **" );

					int roll = Random.Shared.Next( 100 ) + 1;

					if ( roll <= 35 )
					{
						int dmg = Random.Shared.Next( 15 ) + 10 + pBonus;

						CombatManager.applyDamage( ref player, dmg );
						if ( player.hp < 0 ) player.hp = 0;

						GameManager.AddLog( $"** A spinning whirlwind of energy strikes YOU! -{dmg} HP! **" );
					}
					else if ( roll <= 70 )
					{
						int dmg = Random.Shared.Next( 15 ) + 10 + pBonus;

						CombatManager.applyDamage( ref ai, dmg );
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"** The AI performs a devastating laser strike upon itself! -{dmg} HP! **" );
					}
					else if ( roll <= 90 )
					{
						int dmg = Random.Shared.Next( 8 ) + 5 + pBonus;

						CombatManager.applyDamage( ref player, dmg );
						CombatManager.applyDamage( ref ai, dmg );

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"** A chaotic collision of moves hits both combatants! -{dmg} HP! **" );
					}
					else
					{
						GameManager.AddLog( "** The moves miss spectacularly! No one is hurt. **" );
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 35:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int pBonus = prestige * 4;

					GameManager.AddLog( "** A LOGIC CHALLENGE APPEARS! **" );
					GameManager.AddLog( "It questions: 'If all X are Y, and all Y are Z, then all X are...?' " );

					int roll = Random.Shared.Next( 100 ) + 1;

					GameManager.AddLog( $"** You roll the logic dice... ({roll}) **" );

					if ( roll >= 95 )
					{
						int finalDmg = 35 + pBonus;
						GameManager.AddLog( "** GENIUS! You give the flawless answer: 'All X are Z.' " );
						CombatManager.applyDamage( ref ai, finalDmg );
						if ( ai.hp < 0 ) ai.hp = 0;
						GameManager.AddLog( $"** Your brilliance strikes the AI for {finalDmg} damage! **" );
					}
					else if ( roll >= 75 )
					{
						int finalDmg = 20 + pBonus;
						GameManager.AddLog( "** Strong reasoning! You almost nail it but miss a small detail. **" );
						CombatManager.applyDamage( ref ai, finalDmg );
						if ( ai.hp < 0 ) ai.hp = 0;
						GameManager.AddLog( $"** AI loses {finalDmg} health from being mentally outmaneuvered. **" );
					}
					else if ( roll >= 50 )
					{
						int finalDmg = 20 + pBonus;
						GameManager.AddLog( "** Your logic becomes shaky. **" );
						CombatManager.applyDamage( ref player, finalDmg );
						if ( player.hp < 0 ) player.hp = 0;
						GameManager.AddLog( $"** The AI mocks your flawed reasoning! You take {finalDmg} psychic damage! **" );
					}
					else if ( roll >= 25 )
					{
						int finalDmg = 35 + pBonus;
						GameManager.AddLog( "** You answer: 'All X are treasure.' **" );
						CombatManager.applyDamage( ref player, finalDmg );
						if ( player.hp < 0 ) player.hp = 0;
						GameManager.AddLog( $"** The AI cackles and fries your neurons. -{finalDmg} health! **" );
					}
					else
					{
						int finalDmg = 40 + pBonus;
						GameManager.AddLog( "** CRITICAL LOGIC FAILURE!! You say: 'If all X are Y... then all Z are X!!' (The opposite!). **" );
						CombatManager.applyDamage( ref player, finalDmg );
						if ( player.hp < 0 ) player.hp = 0;
						GameManager.AddLog( $"** The AI 'obliterates you' with 'active learning techniques' that leave you more confused! Wait Time = -{finalDmg} health!! **" );
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 36:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Standard scaling increments for rewards or penalties (+2 to +3 per tier)
					int scaledHighVal = 20 + (prestige * 3);
					int scaledMidVal = 10 + (prestige * 2);

					GameManager.AddLog( "** An officer suddenly appears! Both you and the AI must explain yourselves! **" );

					int playerExcuse = Random.Shared.Next( 100 ) + 1;
					int aiExcuse = Random.Shared.Next( 100 ) + 1;

					GameManager.AddLog( $"You rolled a {playerExcuse} for your excuse." );
					GameManager.AddLog( $"AI rolled a {aiExcuse} for its excuse." );

					// --- PLAYER RESOLUTION ---
					if ( playerExcuse >= 90 )
					{
						GameManager.AddLog( $"** Your excuse was flawless. The officer is completely convinced! +{scaledHighVal} Buff & HP! **" );
						// FIX: Map attack reward directly to the player's new model slot
						player.eventAttackBuff += scaledHighVal;
						player.hp += scaledHighVal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
					}
					else if ( playerExcuse >= 60 )
					{
						GameManager.AddLog( $"** Your excuse is solid. You scrape by the officer. +{scaledMidVal} attack! **" );
						// FIX: Map attack reward directly to the player's new model slot
						player.eventAttackBuff += scaledMidVal;
					}
					else if ( playerExcuse >= 30 )
					{
						GameManager.AddLog( $"** Your excuse makes you stutter, you lose composure. -{scaledMidVal} health! **" );
						CombatManager.applyDamage( ref player, scaledMidVal );
						if ( player.hp < 0 ) player.hp = 0;
					}
					else
					{
						GameManager.AddLog( $"** BUSTED! The officer saw right through your lies and humiliates you! -{scaledHighVal} health and -{scaledHighVal} attack! **" );
						// FIX: Deduct from the proper new object field
						player.eventAttackBuff -= scaledHighVal;
						CombatManager.applyDamage( ref player, scaledHighVal );
						if ( player.hp < 0 ) player.hp = 0;
					}

					// --- AI RESOLUTION ---
					if ( aiExcuse >= 90 )
					{
						GameManager.AddLog( $"** AI delivers a textbook-perfect excuse in binary, the officer buys it. +{scaledHighVal} health and +{scaledHighVal} attack! **" );
						// FIX: Map attack reward directly to the AI's new model slot
						ai.eventAttackBuff += scaledHighVal;
						ai.hp += scaledHighVal;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;
					}
					else if ( aiExcuse >= 60 )
					{
						GameManager.AddLog( $"** AI's excuse sounds robotic, but tricks the officer. +{scaledMidVal} attack. **" );
						// FIX: Map attack reward directly to the AI's new model slot
						ai.eventAttackBuff += scaledMidVal;
					}
					else if ( aiExcuse >= 30 )
					{
						GameManager.AddLog( $"** AI hits a lag spike mid excuse, officer is suspicious. -{scaledMidVal} health. **" );
						CombatManager.applyDamage( ref ai, scaledMidVal );
						if ( ai.hp < 0 ) ai.hp = 0;
					}
					else
					{
						GameManager.AddLog( $"** BUSTED! The AI starts speaking in 404! Officer puts it in firewall cuffs! -{scaledHighVal} health and attack! **" );
						// FIX: Deduct from the proper new object field
						ai.eventAttackBuff -= scaledHighVal;
						CombatManager.applyDamage( ref ai, scaledHighVal );
						if ( ai.hp < 0 ) ai.hp = 0;
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 37:
				{
					GameManager.AddLog( "** A Rock-Paper-Scissors challenge begins! **" );
					GameManager.AddLog( "⚠️ WAITING FOR HANDSHAKE DUEL CHOICE..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					int scaledPlayerWinDamage = 25 + (prestige * 3);
					int scaledAIWinDamage = 10 + (prestige * 3);

					var p = player;
					var a = ai;

					int secretAIMove = Random.Shared.Next( 1, 4 );
					string[] moveNames = { "", "Rock", "Paper", "Scissors" };

					void EvaluateRPSResult( int pMove, int aMove )
					{
						if ( pMove == aMove )
						{
							GameManager.AddLog( "** It's a draw! No damage dealt! **" );
						}
						else if (
							(pMove == 1 && aMove == 3) || // Rock beats Scissors
							(pMove == 2 && aMove == 1) || // Paper beats Rock
							(pMove == 3 && aMove == 2) )  // Scissors beats Paper
						{
							GameManager.AddLog( $"** You win the duel! AI loses {scaledPlayerWinDamage} HP. **" );
							CombatManager.applyDamage( ref a, scaledPlayerWinDamage );
							if ( a.hp < 0 ) a.hp = 0;
						}
						else
						{
							GameManager.AddLog( $"** AI wins the duel! You lose {scaledAIWinDamage} HP. **" );
							CombatManager.applyDamage( ref p, scaledAIWinDamage );
							if ( p.hp < 0 ) p.hp = 0;
						}

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					var rpsEvent = new ChoiceEvent
					{
						Title = "✊✋✌️ HANDSHAKE DUEL INITIALIZED",
						PromptText = "The AI has locked in a tactical data vector. You must counter it using classic manual handshake parameters. Rock crushes Scissors, Paper wraps Rock, Scissors cuts Paper!",
					};

					// --- BUTTON 1: ROCK ---
					rpsEvent.Options.Add( new EventOption
					{
						ButtonText = "✊ CHOOSE ROCK",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"** You choose Rock! AI chooses {moveNames[secretAIMove]}! **" );
							EvaluateRPSResult( 1, secretAIMove );
						}
					} );

					// --- BUTTON 2: PAPER ---
					rpsEvent.Options.Add( new EventOption
					{
						ButtonText = "✋ CHOOSE PAPER",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"** You choose Paper! AI chooses {moveNames[secretAIMove]}! **" );
							EvaluateRPSResult( 2, secretAIMove );
						}
					} );

					// --- BUTTON 3: SCISSORS ---
					rpsEvent.Options.Add( new EventOption
					{
						ButtonText = "✌️ CHOOSE SCISSORS",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"** You choose Scissors! AI chooses {moveNames[secretAIMove]}! **" );
							EvaluateRPSResult( 3, secretAIMove );
						}
					} );

					GameManager.Instance.TriggerChoicePopup( rpsEvent );
					break;
				}

			case 38:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Calculate scaled damage outcomes (+4 per prestige tier for high stakes, +3 for mid stakes)
					int scaledNaturalDamage = 30 + (prestige * 4);
					int scaledPointDamage = 25 + (prestige * 3);

					GameManager.AddLog( "** A game of CRAPS begins! **" );
					GameManager.AddLog( "You roll two dice..." );

					// FIX: Replaced legacy rand.Next with safe s&box Random.Shared constraints
					Func<int> rollDice = () =>
					{
						return (Random.Shared.Next( 6 ) + 1) + (Random.Shared.Next( 6 ) + 1);
					};

					int rollVal = rollDice();

					GameManager.AddLog( $"Come-out roll: {rollVal}" );

					if ( rollVal == 7 || rollVal == 11 )
					{
						GameManager.AddLog( $"** NATURAL! You win instantly! AI loses {scaledNaturalDamage}HP! **" );
						CombatManager.applyDamage( ref ai, scaledNaturalDamage );
						if ( ai.hp < 0 ) ai.hp = 0;
					}
					else if ( rollVal == 2 || rollVal == 3 || rollVal == 12 )
					{
						GameManager.AddLog( $"** CRAPS! You lose instantly! You take {scaledNaturalDamage} HP damage! **" );
						CombatManager.applyDamage( ref player, scaledNaturalDamage );
						if ( player.hp < 0 ) player.hp = 0;
					}
					else
					{
						int point = rollVal;

						GameManager.AddLog( $"** Your point is {point}! Keep rolling until you hit {point} again (win) or 7 (lose). **" );

						while ( true )
						{
							rollVal = rollDice();

							GameManager.AddLog( $"You rolled: {rollVal}" );

							if ( rollVal == point )
							{
								GameManager.AddLog( $"** You hit your point! You WIN! AI loses {scaledPointDamage} HP. **" );
								CombatManager.applyDamage( ref ai, scaledPointDamage );
								if ( ai.hp < 0 ) ai.hp = 0;
								break;
							}
							else if ( rollVal == 7 )
							{
								GameManager.AddLog( $"** Seven-out! You lose! -{scaledPointDamage} HP. **" );
								CombatManager.applyDamage( ref player, scaledPointDamage );
								if ( player.hp < 0 ) player.hp = 0;
								break;
							}
						}
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 39:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					GameManager.AddLog( "\n Both you and the AI open up your dating apps" );

					// FIX: Upper bounds adjusted to 22 because Random.Next(min, max) is upper-bound exclusive (0 to 21)
					int playerMatches = Random.Shared.Next( 22 );
					int aiMatches = Random.Shared.Next( 22 );

					GameManager.AddLog( $"You matched with {playerMatches} matches." );
					GameManager.AddLog( $"AI matched with {aiMatches} matches." );

					if ( playerMatches > aiMatches )
					{
						// Scale the match damage difference by scaling the multiplier base line (+1 per prestige tier)
						int prestigeMultiplier = 2 + prestige;
						int damage = (playerMatches - aiMatches) * prestigeMultiplier;

						CombatManager.applyDamage( ref ai, damage );
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"You're irresistible! AI loses {damage} HP from crushing loneliness!" );
					}
					else if ( aiMatches > playerMatches )
					{
						int prestigeMultiplier = 2 + prestige;
						int damage = (aiMatches - playerMatches) * prestigeMultiplier;

						CombatManager.applyDamage( ref player, damage );
						if ( player.hp < 0 ) player.hp = 0;

						GameManager.AddLog( $"AI's profile is on fire! You lose {damage} HP from rejection!" );
					}
					else
					{
						// Scale the basic tie damage value (+1 per prestige level)
						int scaledTieDamage = 5 + (prestige * 1);

						CombatManager.applyDamage( ref player, scaledTieDamage );
						CombatManager.applyDamage( ref ai, scaledTieDamage );
						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"You both got the same matches, both are bitter. Both lose {scaledTieDamage} HP." );
					}

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}
			case 40:
				{
					DiceDuelEventRunner.StartEvent( player, ai );
					break;
				}
			case 41:
				{
					BlackjackEventRunner.StartEvent( player, ai );
					break;
				}

			case 42:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Fetch current real-time health values for the logs and damage injection
					int currentRoundPlayerHp = player.hp;
					int currentRoundAIHp = ai.hp;

					// Scale the secondary stress damage linearly (+3 per prestige level)
					int scaledStressDamage = 25 + (prestige * 3);

					GameManager.AddLog( "** Russian Roulette begins! **" );

					// FIX: Replaced legacy rand.Next with safe Random.Shared.Next constraints
					int bulletPos = Random.Shared.Next( 6 );
					int chamber = Random.Shared.Next( 6 );

					GameManager.AddLog( $"Bullet is in chamber: {bulletPos + 1}" );
					GameManager.AddLog( $"You pull the trigger - Chamber {chamber + 1} fires!" );

					if ( chamber == bulletPos )
					{
						// Injecting your exact mid-game health value drops you straight to 0 smoothly!
						GameManager.AddLog( $"💥 BANG! -{currentRoundPlayerHp} HP (Fatal Damage!)" );
						CombatManager.applyDamage( ref player, currentRoundPlayerHp );
					}
					else
					{
						GameManager.AddLog( $"*CLICK* You survived! AI takes {scaledStressDamage} HP from stress!" );
						CombatManager.applyDamage( ref ai, scaledStressDamage );
					}

					if ( ai.hp > 0 )
					{
						// FIX: Replaced legacy rand.Next with safe Random.Shared.Next constraints
						bulletPos = Random.Shared.Next( 6 );
						chamber = Random.Shared.Next( 6 );

						GameManager.AddLog( $"AI pulls the trigger - Chamber {chamber + 1} fires!" );

						if ( chamber == bulletPos )
						{
							GameManager.AddLog( $"💥 BANG! AI takes -{currentRoundAIHp} HP (Fatal Damage!)" );
							CombatManager.applyDamage( ref ai, currentRoundAIHp );
						}
						else
						{
							GameManager.AddLog( $"*CLICK* AI survived! You take {scaledStressDamage} HP from stress!" );
							CombatManager.applyDamage( ref player, scaledStressDamage );
						}
					}
					break;
				}

			case 43:
				{
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the thunderstorm's raw damage output layout (+3 damage per prestige level)
					int prestigeBonus = prestige * 3;

					GameManager.AddLog( "** The skies darken -- clouds gather overhead! **" );

					int weatherRoll = Random.Shared.Next( 1, 101 );

					if ( weatherRoll <= 50 )
					{
						int baseDamage = Random.Shared.Next( 10, 31 ); // 10 to 30 base
						int scaledStormDamage = baseDamage + prestigeBonus;

						GameManager.AddLog( "** A sudden downpour strikes the AI! **" );
						GameManager.AddLog( $"AI takes {scaledStormDamage} HP from the storm!" );

						CombatManager.applyDamage( ref ai, scaledStormDamage );
					}
					else
					{
						GameManager.AddLog( "This AI's model must be waterproof! The storm passes, no HP taken." );
					}

					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 44:
				{
					MontyHallEventRunner.StartEvent( player, ai );
					break;
				}
			case 45:
				{
					GameManager.AddLog( "\n** A Gunslinger Duel Begins! **" );
					GameManager.AddLog( "Standoff... draw on the count of three." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();

					// Capture exact active mid-game health snapshots
					int currentRoundPlayerHp = player.hp;
					int currentRoundAIHp = ai.hp;

					const int BOTH_MISS_PCT = 5;
					const int PLAYER_ONLY_MISS = 12;
					const int AI_ONLY_MISS = 12;
					const int MUTUAL_KILL_PCT = 3;

					int r = Random.Shared.Next( 1, 101 );
					GameManager.AddLog( $"(Chance roll = {r})" );

					if ( r <= BOTH_MISS_PCT )
					{
						GameManager.AddLog( "** Both shooters fire and miss! Dust settles. No damage! **" );
					}
					else if ( r <= BOTH_MISS_PCT + PLAYER_ONLY_MISS )
					{
						GameManager.AddLog( "** You fumble the draw - you miss! The AI's bullet finds you. **" );
						GameManager.AddLog( $"BANG! You take -{currentRoundPlayerHp}HP (Lethal Execution!)" );
						CombatManager.applyDamage( ref player, currentRoundPlayerHp );
					}
					else if ( r <= BOTH_MISS_PCT + PLAYER_ONLY_MISS + AI_ONLY_MISS )
					{
						GameManager.AddLog( "** The AI calculated the angle of its aim incorrectly - it misses! Your shot lands true! **" );
						GameManager.AddLog( $"BANG! AI takes -{currentRoundAIHp}HP (Lethal Execution!)" );
						CombatManager.applyDamage( ref ai, currentRoundAIHp );
					}
					else if ( r <= BOTH_MISS_PCT + PLAYER_ONLY_MISS + AI_ONLY_MISS + MUTUAL_KILL_PCT )
					{
						GameManager.AddLog( "** A brutal finale! Both guns fire true at the same instant! **" );
						GameManager.AddLog( $"BANG! BANG! Both duelists fall! (-{currentRoundPlayerHp} HP / -{currentRoundAIHp} HP)" );

						CombatManager.applyDamage( ref player, currentRoundPlayerHp );
						CombatManager.applyDamage( ref ai, currentRoundAIHp );
					}
					else
					{
						int playerSkill = 0;
						int aiSkill = 0;

						int playerQuick = Random.Shared.Next( 1, 101 ) + playerSkill;
						int aiQuick = Random.Shared.Next( 1, 101 ) + aiSkill;

						GameManager.AddLog( "** Quickdraw! **" );
						GameManager.AddLog( $"You quickdraw roll: {playerQuick}" );
						GameManager.AddLog( $"AI quickdraw roll: {aiQuick}" );

						if ( playerQuick > aiQuick )
						{
							GameManager.AddLog( $"** Your shot is faster and lands accurate! AI takes -{currentRoundAIHp}HP! **" );
							CombatManager.applyDamage( ref ai, currentRoundAIHp );
						}
						else if ( aiQuick > playerQuick )
						{
							GameManager.AddLog( $"** The AI's shot is faster and lands accurate! You take -{currentRoundPlayerHp}HP! **" );
							CombatManager.applyDamage( ref player, currentRoundPlayerHp );
						}
						else
						{
							GameManager.AddLog( "** It's a dead heat - both fire at the same instant and miss! **" );
						}
					}

					if ( player.hp < 0 ) player.hp = 0;
					if ( ai.hp < 0 ) ai.hp = 0;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 46:
				{
					GameManager.AddLog( "** Treasure Chest Gamble! **" );
					GameManager.AddLog( "Three chests appear before you.." );
					GameManager.AddLog( "⚠️ AWAITING TREASURE STORAGE PARM INTERACTION..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					// Scale rewards and trap damage lineally (+4 per prestige level)
					// We weave in your custom player healing buff modifier directly onto the chest reward!
					int totalChestHeal = 20 + (prestige * 4) + player.eventHealingBuff;
					int scaledChestTrap = 20 + (prestige * 4);

					var p = player;

					int hiddenTreasureChest = Random.Shared.Next( 1, 4 );

					void OpenTargetChest( int playerChoice, string chestName )
					{
						GameManager.AddLog( $"You decide to open the {chestName}." );

						if ( playerChoice == hiddenTreasureChest )
						{
							GameManager.AddLog( $"You found a stash of potions! +{totalChestHeal} HP!" );
							p.hp += totalChestHeal;

							if ( p.hp > maxPlayerHp )
								p.hp = maxPlayerHp;

							// FIX: Clean cleanup consumes the healing buff slot immediately on use
							p.eventHealingBuff = 0;
						}
						else if ( Random.Shared.Next( 0, 2 ) == 0 )
						{
							GameManager.AddLog( $"It's a trap! Poison darts hit you! -{scaledChestTrap}HP!" );
							CombatManager.applyDamage( ref p, scaledChestTrap );
						}
						else
						{
							GameManager.AddLog( "The chest is empty. Nothing happens..." );
						}

						if ( p.hp < 0 ) p.hp = 0;

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
					}

					var chestEvent = new ChoiceEvent
					{
						Title = "📦 MAINFRAME TREASURE GAMBLE",
						PromptText = "Three encrypted logic storage chests have materialized on the terminal network layer. One contains data-potions, another contains a poison dart loop routine, and the last is completely empty. Choose your extraction pathway:",
					};

					// --- BUTTON 1: GOLDEN CHEST ---
					chestEvent.Options.Add( new EventOption
					{
						ButtonText = "👑 OPEN GOLDEN CHEST",
						ActionToExecute = () =>
						{
							OpenTargetChest( 1, "Golden Chest" );
						}
					} );

					// --- BUTTON 2: SILVER CHEST ---
					chestEvent.Options.Add( new EventOption
					{
						ButtonText = "🛡️ OPEN SILVER CHEST",
						ActionToExecute = () =>
						{
							OpenTargetChest( 2, "Silver Chest" );
						}
					} );

					// --- BUTTON 3: WOODEN CHEST ---
					chestEvent.Options.Add( new EventOption
					{
						ButtonText = "🪵 OPEN WOODEN CHEST",
						ActionToExecute = () =>
						{
							OpenTargetChest( 3, "Wooden Chest" );
						}
					} );

					GameManager.Instance.TriggerChoicePopup( chestEvent );
					break;
				}
			case 47:
				{
					GameManager.AddLog( "** A glittering seam of ore suddenly erupts from the ground! **" );
					GameManager.AddLog( "You and the AI rush forward to grab what you can..\n" );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Gentle scaling multiplier for ore stats (+1 to +2 per prestige tier)
					int pStatBonus = prestige * 1;

					List<Ore> ores = new List<Ore>
		{
			new Ore("Coal", 12, 0, 0, 0, "Just a lump of coal.. better than nothing."),
			new Ore("Copper", 10, 5 + pStatBonus, 1 + pStatBonus, 0, "Soft and reddish. A touch of energy."),
			new Ore("Iron", 10, 10 + pStatBonus, 2 + pStatBonus, 0, "Solid and dependable."),
			new Ore("Tin", 8, 3 + pStatBonus, 0, 1 + pStatBonus, "A softer metal. Grants minor reinforcement."),
			new Ore("Silver", 6, 12 + pStatBonus, 3 + pStatBonus, 1 + pStatBonus, "Shining silver - power surges a little."),
			new Ore("Gold", 5, 20 + pStatBonus, 4 + pStatBonus, 0, "The classic treasure. Feels invigorating."),
			new Ore("Obsidian", 4, 0, 6 + pStatBonus, 0, "Sharp volcanic glass - dangerous in hand."),
			new Ore("Mithril", 3, 15 + pStatBonus, 3 + pStatBonus, 3 + pStatBonus, "Light, strong, and legendary."),
			new Ore("Adamantine", 2, 25 + pStatBonus, 6 + pStatBonus, 4 + pStatBonus, "A mythic ore - your body feels reinforced."),
			new Ore("Dragonstone", 1, 30 + pStatBonus, 8 + pStatBonus, 0, "It pulses like fire. Incredible strength!"),
			new Ore("Aetherite", 1, 40 + pStatBonus, 10 + pStatBonus, 5 + pStatBonus, "Other worldly. Reality bends at your touch!")
		};

					Ore PickOre()
					{
						int totalWeight = 0;
						foreach ( var o in ores ) totalWeight += o.Weight;

						int r = Random.Shared.Next( totalWeight );
						int running = 0;

						foreach ( var o in ores )
						{
							running += o.Weight;
							if ( r < running )
								return o;
						}

						return ores[ores.Count - 1];
					}

					Ore playerOre = PickOre();
					Ore aiOre = PickOre();

					GameManager.AddLog( $">> You found {playerOre.Name}! {playerOre.Flavor}" );
					GameManager.AddLog( $">> AI found {aiOre.Name}! {aiOre.Flavor}\n" );

					if ( playerOre.Heal > 0 )
					{
						// FIX: Integrate the new active player event healing buff into the ore payout!
						int totalPlayerHeal = playerOre.Heal + player.eventHealingBuff;
						player.hp += totalPlayerHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
						player.eventHealingBuff = 0; // Safe flush

						GameManager.AddLog( $"You heal +{totalPlayerHeal} HP." );
					}

					if ( playerOre.Attack > 0 )
					{
						// FIX: Map attack reward directly to the player's new model slot
						player.eventAttackBuff += playerOre.Attack;
						GameManager.AddLog( $"Your attacks grow stronger! (+{playerOre.Attack})" );
					}

					if ( playerOre.Defense > 0 )
					{
						// Since Defense updates here are described as affecting next attack modifications inside the logs,
						// we funnel it straight to the new attack buff slot to protect weapon calculation lines!
						player.eventAttackBuff += playerOre.Defense;
						GameManager.AddLog( $"Your defenses feel sturdier! (+{playerOre.Defense} attack next turn)" );
					}

					if ( aiOre.Heal > 0 )
					{
						// FIX: Integrate the new active AI event healing buff into the ore payout!
						int totalAIHeal = aiOre.Heal + ai.eventHealingBuff;
						ai.hp += totalAIHeal;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;
						ai.eventHealingBuff = 0; // Safe flush

						GameManager.AddLog( $"AI heals +{totalAIHeal} HP." );
					}

					if ( aiOre.Attack > 0 )
					{
						// FIX: Map attack reward directly to the AI's new model slot
						ai.eventAttackBuff += aiOre.Attack;
						GameManager.AddLog( $"AI's attacks grow stronger! (+{aiOre.Attack})" );
					}

					if ( aiOre.Defense > 0 )
					{
						// Funnel directly to the AI attack buff property
						ai.eventAttackBuff += aiOre.Defense;
						GameManager.AddLog( $"AI braces itself with new strength! (+{aiOre.Defense} attack next turn)" );
					}

					GameManager.AddLog( "\nThe seam collapses back into the ground. The fight continues!" );
					break;
				}

			case 48:
				{
					GameManager.AddLog( "\n=== RANDOM EVENT ===" );
					GameManager.AddLog( "** A horde of ZOMBIES shambles into the arena! **" );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Scale wound and vector reward properties (+4 to +5 per prestige level)
					int scaledWoundDamage = 30 + (prestige * 4);

					// Integrate any active temporary healing buffs directly onto the survival reward calculations
					int totalVictoryHealPlayer = 20 + (prestige * 4) + player.eventHealingBuff;
					int totalVictoryHealAI = 20 + (prestige * 4) + ai.eventHealingBuff;
					int scaledVictoryBuff = 10 + (prestige * 2);

					int hordeSize = Random.Shared.Next( 1, 6 ); // 1 to 5 scale.
					GameManager.AddLog( $"The horde size is: {hordeSize} (1 = tiny, 5 = massive)" );

					int baseDeathChance = 5;
					int baseWoundChance = 15;

					int deathChance = baseDeathChance * hordeSize;
					int woundChance = baseWoundChance * hordeSize;

					if ( deathChance > 60 ) deathChance = 60;
					if ( woundChance > 70 ) woundChance = 70;

					int playerRoll = Random.Shared.Next( 100 );
					int aiRoll = Random.Shared.Next( 100 );

					bool playerAlive = true;
					bool aiAlive = true;

					// Player outcome
					if ( playerRoll < deathChance )
					{
						GameManager.AddLog( "The zombies overwhelm YOU! You're torn apart!" );
						player.hp = 0;
						playerAlive = false;
					}
					else if ( playerRoll < deathChance + woundChance )
					{
						GameManager.AddLog( $"You got clawed up and bitten! -{scaledWoundDamage} HP!" );
						CombatManager.applyDamage( ref player, scaledWoundDamage );
						if ( player.hp < 0 ) player.hp = 0;
					}
					else
					{
						GameManager.AddLog( "You fight the zombies off bravely!" );
					}

					// AI outcome
					if ( aiRoll < deathChance )
					{
						GameManager.AddLog( "The zombies swarm the AI! Circuits and machine parts fly everywhere!" );
						ai.hp = 0;
						aiAlive = false;
					}
					else if ( aiRoll < deathChance + woundChance )
					{
						GameManager.AddLog( $"The AI takes heavy damage! -{scaledWoundDamage} HP!" );
						CombatManager.applyDamage( ref ai, scaledWoundDamage );
						if ( ai.hp < 0 ) ai.hp = 0;
					}
					else
					{
						GameManager.AddLog( "The AI crushes zombies with relentless force!" );
					}

					// Reward if both survive
					if ( playerAlive && aiAlive )
					{
						GameManager.AddLog( "\nYou and the AI stand victorious after the horde!" );

						player.hp += totalVictoryHealPlayer;
						ai.hp += totalVictoryHealAI;

						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

						// FIX: Map rewards straight into your permanent model variable slots safely
						player.eventAttackBuff += scaledVictoryBuff;
						ai.eventAttackBuff += scaledVictoryBuff;
						player.eventHealingBuff = 0;
						ai.eventHealingBuff = 0;

						GameManager.AddLog( $"Both gain +{totalVictoryHealPlayer} HP (AI: +{totalVictoryHealAI} HP) and +{scaledVictoryBuff} attack!" );
					}

					GameManager.AddLog( "The battlefield is littered with corpses!" );
					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}
			case 49:
				{
					GameManager.AddLog( "\n=== ELEMENTAL ORBS APPEAR ===" );
					GameManager.AddLog( "Four glowing orbs rise from the ground..." );
					GameManager.AddLog( "⚠️ AWAITING ELEMENTAL MATRICES SELECTION..." );

					// 1. Fetch current scene progression data parameters securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Calculate scaled reward/risk modifiers (+1 to +3 points lineally per prestige level)
					int fireBonusBase = 5 + (prestige * 1);
					int fireBonusInfr = 15 + (prestige * 2);
					int fireBurnDmg = 10 + (prestige * 2);

					int lightBonus = 10 + (prestige * 2);
					int lightBackfire = 20 + (prestige * 3);

					int iceBonusBase = 5 + (prestige * 1);
					int iceBonusSkin = 20 + (prestige * 3);
					int iceFrostbite = 8 + (prestige * 1);

					int earthFortitude = 30 + (prestige * 5);
					int earthCrushed = 25 + (prestige * 4);

					// Establish stack pointers to satisfy reference scopes
					var p = player;
					var a = ai;

					int secretAIChoice = Random.Shared.Next( 1, 5 );

					// 👑 LOCAL FUNCTION: Modified to handle prestige-scaled metrics dynamically and map to new entity variables
					void ApplyOrb( string name, int orb, Player target, int targetMaxHp )
					{
						int luck = Random.Shared.Next( 0, 100 ); // 0 to 99 inclusive

						switch ( orb )
						{
							case 1: // Fire
								GameManager.AddLog( $"{name} grabs the **FIRE ORB**" );
								// FIX: Map attack rewards directly into the new model tracker slots
								target.eventAttackBuff += fireBonusBase;

								if ( luck < 70 )
								{
									GameManager.AddLog( $"{name} grabs the burning inferno! +{fireBonusInfr} attack!" );
									target.eventAttackBuff += fireBonusInfr;
								}
								else
								{
									GameManager.AddLog( $"{name} is burned from the untamed orb! -{fireBurnDmg} HP!" );
									target.hp -= fireBurnDmg;
								}
								break;

							case 2: // Lightning
								GameManager.AddLog( $"{name} grabs the **LIGHTNING ORB**" );

								if ( luck < 80 )
								{
									GameManager.AddLog( $"{name} becomes charged! +{lightBonus} attack, +{lightBonus} defense!" );
									target.eventAttackBuff += lightBonus;
									// Funnel defense buffs into eventAttackBuff to match standard turn loop evaluations safely
									target.eventAttackBuff += lightBonus;
								}
								else
								{
									GameManager.AddLog( $"A thunderbolt loses control and backfires on {name}! -{lightBackfire} HP!" );
									target.hp -= lightBackfire;
								}
								break;

							case 3: // Ice
								GameManager.AddLog( $"{name} holds the **ICE ORB**" );
								GameManager.AddLog( $"{name} stiffens to reduce attack impact! +{iceBonusBase} defense!" );
								target.eventAttackBuff += iceBonusBase;

								if ( luck < 60 )
								{
									GameManager.AddLog( $"{name}'s skin solidifies like ice! +{iceBonusSkin} defense!" );
									target.eventAttackBuff += iceBonusSkin;
								}
								else
								{
									GameManager.AddLog( $"{name} freezes their fingers, frostbite! -{iceFrostbite} HP!" );
									target.hp -= iceFrostbite;
								}
								break;

							case 4: // Earth
								GameManager.AddLog( $"{name} scoops up the **EARTH ORB**" );

								if ( luck < 90 )
								{
									// FIX: Integrate any active player or AI event healing buffs into the earth orb payout!
									int totalEarthHeal = earthFortitude + target.eventHealingBuff;
									GameManager.AddLog( $"{name} gains the grounds fortitude! +{totalEarthHeal} HP!" );
									target.hp += totalEarthHeal;
									target.eventHealingBuff = 0; // Safe flush
								}
								else
								{
									GameManager.AddLog( $"{name} is crushed by the weight of dirt and stone! -{earthCrushed} HP!" );
									target.hp -= earthCrushed;
								}
								break;
						}

						if ( target.hp > targetMaxHp ) target.hp = targetMaxHp;
						if ( target.hp < 0 ) target.hp = 0;
					}

					void FinalizeOrbDuels( int playerChoice )
					{
						// Execute player selection using direct object variables
						ApplyOrb( "Player", playerChoice, p, maxPlayerHp );

						// Execute AI selection using direct object variables
						ApplyOrb( "AI", secretAIChoice, a, maxAIHp );

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					var orbEvent = new ChoiceEvent
					{
						Title = "🔮 ELEMENTAL MATRICES MANIFESTATION",
						PromptText = "Four luminous data-orbs have risen through the hardware chassis partitions. Each holds high-potency code modifications wrapped in volatile side-effect variables. Choose your download matrix:",
					};

					orbEvent.Options.Add( new EventOption { ButtonText = "🔥 HARNESS FIRE ORB", ActionToExecute = () => { FinalizeOrbDuels( 1 ); } } );
					orbEvent.Options.Add( new EventOption { ButtonText = "⚡ HARNESS LIGHTNING ORB", ActionToExecute = () => { FinalizeOrbDuels( 2 ); } } );
					orbEvent.Options.Add( new EventOption { ButtonText = "❄️ HARNESS ICE ORB", ActionToExecute = () => { FinalizeOrbDuels( 3 ); } } );
					orbEvent.Options.Add( new EventOption { ButtonText = "🪨 HARNESS EARTH ORB", ActionToExecute = () => { FinalizeOrbDuels( 4 ); } } );

					GameManager.Instance.TriggerChoicePopup( orbEvent );
					break;
				}

			case 50:
				{
					GameManager.AddLog( "\n=== WEAPON VAULT EVENT ===" );
					GameManager.AddLog( "A floating vault opens, revealing 4 weapons." );
					GameManager.AddLog( "⚠️ AWAITING HARDWARE DATA OVERCLOCK LINK..." );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Calculate scaled bonus stats lineally (+2 to +3 points per prestige level)
					int scaledAttackBonus = 5 + (prestige * 2);
					int scaledDefBonus = 5 + (prestige * 2);
					int scaledRecoilDmg = 10 + (prestige * 2);

					// Local pointers for safe variable state tracking
					var p = player;
					var a = ai;

					int secretAIChoice = Random.Shared.Next( 1, 5 );

					// 👑 LOCAL FUNCTION A: Retains your exact original weapon stats and recoil calculation loops
					void GiveWeapon( string name, int pick, Player target )
					{
						switch ( pick )
						{
							case 1:
								GameManager.AddLog( $"{name} equips the **Flame Blade**" );
								// FIX: Map attack reward directly into the target's new temporary model slot instead of target.attack!
								target.eventAttackBuff += (15 + scaledAttackBonus);
								break;

							case 2:
								GameManager.AddLog( $"{name} equips the **Frost Hammer**" );
								// FIX: Map both attack and defense adjustments straight to the temporary event buff parameter slot
								target.eventAttackBuff += (10 + scaledAttackBonus);
								target.eventAttackBuff += (5 + scaledDefBonus);
								break;

							case 3:
								GameManager.AddLog( $"{name} equips the **Volt Dagger**" );
								// FIX: Map attack reward directly into the target's temporary model slot
								target.eventAttackBuff += (20 + scaledAttackBonus);

								if ( Random.Shared.Next( 0, 100 ) < 50 )
								{
									GameManager.AddLog( $"The dagger shocks {name}! -{scaledRecoilDmg} HP recoil!" );
									target.hp -= scaledRecoilDmg;
								}
								break;

							case 4:
								GameManager.AddLog( $"{name} equips the **Stone Shield**" );
								// FIX: Map the defensive buffer to the temporary event buff slot to protect calculation loops
								target.eventAttackBuff += (25 + scaledDefBonus);
								break;
						}

						if ( target.hp < 0 ) target.hp = 0;
					}

					// 👑 LOCAL FUNCTION B: Evaluates both choices sequentially right after button click checkout
					void FinalizeVaultExtractions( int playerChoice )
					{
						// Execute player selection
						GiveWeapon( "Player", playerChoice, p );

						// Execute the AI's automated choice sequence
						GiveWeapon( "AI", secretAIChoice, a );

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Assemble the dynamic choice container data model
					var vaultEvent = new ChoiceEvent
					{
						Title = "🛡️ CRYPTO WEAPON VAULT OVERRIDE",
						PromptText = "A floating digital armor vault has materialized in the core matrix workspace. Four distinct security firmware modifications are online. Select your download slice:",
					};

					// --- BUTTON 1: FLAME BLADE ---
					vaultEvent.Options.Add( new EventOption
					{
						ButtonText = $"🔥 EQUIP FLAME BLADE (+{15 + scaledAttackBonus} ATK)",
						ActionToExecute = () => FinalizeVaultExtractions( 1 )
					} );

					// --- BUTTON 2: FROST HAMMER ---
					vaultEvent.Options.Add( new EventOption
					{
						ButtonText = $"❄️ EQUIP FROST HAMMER (+{10 + scaledAttackBonus} ATK, +{5 + scaledDefBonus} DEF)",
						ActionToExecute = () => FinalizeVaultExtractions( 2 )
					} );

					// --- BUTTON 3: VOLT DAGGER ---
					vaultEvent.Options.Add( new EventOption
					{
						ButtonText = $"⚡ EQUIP VOLT DAGGER (+{20 + scaledAttackBonus} ATK, 50% -{scaledRecoilDmg} HP RECOIL)",
						ActionToExecute = () => FinalizeVaultExtractions( 3 )
					} );

					// --- BUTTON 4: STONE SHIELD ---
					vaultEvent.Options.Add( new EventOption
					{
						ButtonText = $"🪨 EQUIP STONE SHIELD (+{25 + scaledDefBonus} DEF)",
						ActionToExecute = () => FinalizeVaultExtractions( 4 )
					} );

					// 3. Command the UI tree layout framework to draw the selection screen
					GameManager.Instance.TriggerChoicePopup( vaultEvent );
					break;
				}

			case 51:
				{
					GameManager.AddLog( "\n=== ALCHEMY TABLE EVENT ===" );
					GameManager.AddLog( "Four mysterious potions bubble on a wooden table..." );
					GameManager.AddLog( "⚠️ AWAITING CHEMICAL EXTRACTION CONTEXT..." );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Calculate scaled prestige modifications (+1 to +5 lineally per prestige level)
					int scaledRedHeal = 30 + (prestige * 5);
					int scaledRedSuperHeal = 50 + (prestige * 8);

					int scaledBlueBuff = 10 + (prestige * 2);
					int scaledBlueExtra = 15 + (prestige * 3);

					int scaledGreenPoison = 30 + (prestige * 5);
					int scaledGreenStrength = 30 + (prestige * 4);

					int scaledPurpleAscendHp = 40 + (prestige * 6);
					int scaledPurpleAscendAtk = 20 + (prestige * 3);
					int scaledPurpleExplode = 50 + (prestige * 8);
					int scaledPurpleUntouchable = 50 + (prestige * 6);

					// Establish local variable pointers for safe variable state tracking
					var p = player;
					var a = ai;

					// FIX: Use Random.Shared.Next instead of Sandbox.Game.Random (1, 5 is exclusive upper bound)
					int secretAIChoice = Random.Shared.Next( 1, 5 );

					// 👑 LOCAL FUNCTION A: Modified to handle prestige-scaled metrics dynamically and use new buff properties
					void DrinkPotion( string name, int potion, Player target, int targetMaxHp )
					{
						int luck = Random.Shared.Next( 0, 100 ); // 0 to 99 inclusive

						switch ( potion )
						{
							case 1:
								GameManager.AddLog( $"{name} drinks the **Red Potion**" );

								// FIX: Integrate the new active event healing buff into the potion payout calculation!
								int totalRedHeal = scaledRedHeal + target.eventHealingBuff;
								target.hp += totalRedHeal;

								if ( luck < 20 )
								{
									int totalSuperHeal = scaledRedSuperHeal + target.eventHealingBuff;
									GameManager.AddLog( $"It was super-charged! +{totalSuperHeal} HP EXTRA!" );
									target.hp += totalSuperHeal;
								}

								target.eventHealingBuff = 0; // Safe flush
								break;

							case 2:
								GameManager.AddLog( $"{name} drinks the **Blue Potion**" );

								// FIX: Map attack and armor gains straight to the new temporary model tracker slot instead of target.attack!
								target.eventAttackBuff += scaledBlueBuff; // Attack share
								target.eventAttackBuff += scaledBlueBuff; // Defense share funneling to attack buff safely

								if ( luck < 35 )
								{
									GameManager.AddLog( $"{name}, the mystics granted you an extra +{scaledBlueExtra} on attack and defense!" );
									target.eventAttackBuff += scaledBlueExtra;
									target.eventAttackBuff += scaledBlueExtra;
								}
								break;

							case 3:
								GameManager.AddLog( $"{name} drinks the **Green Potion**" );

								if ( luck < 50 )
								{
									GameManager.AddLog( $"{name} is poisoned! -{scaledGreenPoison} HP!" );
									target.hp -= scaledGreenPoison;
								}
								else
								{
									GameManager.AddLog( $"{name} gains hazmat strength! +{scaledGreenStrength} attack!" );
									// FIX: Map attack reward directly into the target's temporary model tracker slot
									target.eventAttackBuff += scaledGreenStrength;
								}
								break;

							case 4:
								GameManager.AddLog( $"{name} drinks the **Purple Potion**" );

								if ( luck < 33 )
								{
									// FIX: Integrate any active event healing buffs into the purple ascension pool!
									int totalPurpleHeal = scaledPurpleAscendHp + target.eventHealingBuff;
									GameManager.AddLog( $"{name} ascends briefly! +{totalPurpleHeal} HP & +{scaledPurpleAscendAtk} attack!" );

									target.hp += totalPurpleHeal;
									target.eventAttackBuff += scaledPurpleAscendAtk; // Map attack reward properly
									target.eventHealingBuff = 0; // Safe flush
								}
								else if ( luck < 66 )
								{
									GameManager.AddLog( $"The potion explodes! -{scaledPurpleExplode} HP!" );
									target.hp -= scaledPurpleExplode;
								}
								else
								{
									GameManager.AddLog( $"{name} becomes UNTOUCHABLE! +{scaledPurpleUntouchable} defense!" );
									// FIX: Map the massive defensive buffer into the temporary event attack buff property slot safely
									target.eventAttackBuff += scaledPurpleUntouchable;
								}
								break;
						}

						// FIX: Dynamic cap ceiling checks replace hardcoded 100 loops
						if ( target.hp > targetMaxHp ) target.hp = targetMaxHp;
						if ( target.hp < 0 ) target.hp = 0;
					}

					// 👑 LOCAL FUNCTION B: Sequentially executes both the player selection and AI roll on button checkout
					void SettleAlchemyConsumption( int playerChoice )
					{
						// Process player potion selection
						DrinkPotion( "Player", playerChoice, p, maxPlayerHp );

						// Process AI dealer automated selection
						DrinkPotion( "AI", secretAIChoice, a, maxAIHp );

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Build the interactive 4-button overlay layout configuration parcel
					var alchemyEvent = new ChoiceEvent
					{
						Title = "🧪 CYBER ALCHEMY PROTOCOL",
						PromptText = "Four highly unstable chemical mixtures are bubbling on the terminal workstation logic board. Each holding intense kernel modifications balanced with catastrophic side-effect variables. Select your download elixir:",
					};

					// --- BUTTON 1: RED POTION ---
					alchemyEvent.Options.Add( new EventOption
					{
						ButtonText = "🔴 DRINK RED POTION (HUGE HEAL)",
						ActionToExecute = () =>
						{
							SettleAlchemyConsumption( 1 );
						}
					} );

					// --- BUTTON 2: BLUE POTION ---
					alchemyEvent.Options.Add( new EventOption
					{
						ButtonText = "🔵 DRINK BLUE POTION (MYSTIC BUFF)",
						ActionToExecute = () =>
						{
							SettleAlchemyConsumption( 2 );
						}
					} );

					// --- BUTTON 3: GREEN POTION ---
					alchemyEvent.Options.Add( new EventOption
					{
						ButtonText = "🟢 DRINK GREEN POTION (TOXIC GAMBLE)",
						ActionToExecute = () =>
						{
							SettleAlchemyConsumption( 3 );
						}
					} );

					// --- BUTTON 4: PURPLE POTION ---
					alchemyEvent.Options.Add( new EventOption
					{
						ButtonText = "🟣 DRINK PURPLE POTION (CHAOS EFFECT)",
						ActionToExecute = () =>
						{
							SettleAlchemyConsumption( 4 );
						}
					} );

					// 3. Command the main screen overlay interface grid to render the layout buttons
					GameManager.Instance.TriggerChoicePopup( alchemyEvent );
					break;
				}
			case 52:
				{
					GameManager.AddLog( "\n=== DEATH DICE EVENT ===" );
					GameManager.AddLog( "A skeletal hand offers two dice..." );
					GameManager.AddLog( "⚠️ AWAITING MORTAL SELECTION PARAMETERS..." );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Calculate prestige scaling modifiers for die mechanics (+1 to +2 per level to add on top of rolled dice)
					int prestigeHealBonus = prestige * 2;
					int prestigeDamageBonus = prestige * 2;
					int prestigeAtkBonus = prestige * 1;
					int scaledDeathDrain = 15 + (prestige * 2);

					// Local pointers for safe variable state tracking across lambda contexts
					var p = player;
					var a = ai;

					// FIX: Use Random.Shared.Next instead of Sandbox.Game.Random (1, 5 is exclusive upper bound)
					int secretAIChoice = Random.Shared.Next( 1, 5 );

					// 👑 LOCAL FUNCTION A: Modified to handle prestige-scaled metrics dynamically and use new buff properties
					void RollDeathDie( string name, int pick, Player target, int targetMaxHp )
					{
						// FIX: 1 to 4 inclusive require 1, 5 bounds for standard exclusive C# Next logic
						int roll = Random.Shared.Next( 1, 5 );

						GameManager.AddLog( $"{name} rolls: **{roll}**" );

						switch ( pick )
						{
							case 1: // Life
									// FIX: Integrate the active event healing buff into the Life Die calculation!
								int finalHeal = (roll * 10) + prestigeHealBonus + target.eventHealingBuff;
								target.hp += finalHeal;
								GameManager.AddLog( $"{name} gains {finalHeal} HP!" );

								target.eventHealingBuff = 0; // Safe flush
								break;

							case 2: // Pain
								int finalPain = (roll * 10) + prestigeDamageBonus;
								target.hp -= finalPain;
								GameManager.AddLog( $"{name} loses {finalPain} HP!" );
								break;

							case 3: // Chaos
								if ( roll % 2 == 0 )
								{
									int finalBuff = (roll * 5) + prestigeAtkBonus;
									// FIX: Map attack reward directly into the target's temporary model tracker slot instead of target.attack!
									target.eventAttackBuff += finalBuff;
									GameManager.AddLog( $"{name} gains +{finalBuff} attack next turn!" );
								}
								else
								{
									int finalDmg = (roll * 10) + prestigeDamageBonus;
									target.hp -= finalDmg;
									GameManager.AddLog( $"{name} takes {finalDmg} damage!" );
								}
								break;

							case 4: // Death
								if ( roll == 4 )
								{
									GameManager.AddLog( $"💀 {name} is INSTANTLY DESTROYED!" );
									target.hp = 0;
								}
								else
								{
									GameManager.AddLog( $"{name} survives... but is drained." );
									target.hp -= scaledDeathDrain;
								}
								break;
						}

						// FIX: Dynamic cap ceiling checks replace hardcoded 100 loops
						if ( target.hp > targetMaxHp ) target.hp = targetMaxHp;
						if ( target.hp < 0 ) target.hp = 0;
					}

					// 👑 LOCAL FUNCTION B: Sequentially executes the rolls right after button checkout click
					void SettleMortalGamble( int playerChoice )
					{
						// Process player selection
						RollDeathDie( "Player", playerChoice, p, maxPlayerHp );

						// Process AI automated selection
						RollDeathDie( "AI", secretAIChoice, a, maxAIHp );

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Assemble the dynamic 4-button interactive choice container parcel
					var deathDiceEvent = new ChoiceEvent
					{
						Title = "💀 THE DEATH DICE INTRUSION",
						PromptText = "A glitching skeletal framework has hard-locked the execution block. Four hazardous logic dice have populated on the monitor. Will you heal securely or gamble your entire execution thread?",
					};

					// --- BUTTON 1: DIE OF LIFE ---
					deathDiceEvent.Options.Add( new EventOption
					{
						ButtonText = "💚 ROLL DIE OF LIFE (SAFE HEAL)",
						ActionToExecute = () =>
						{
							SettleMortalGamble( 1 );
						}
					} );

					// --- BUTTON 2: DIE OF PAIN ---
					deathDiceEvent.Options.Add( new EventOption
					{
						ButtonText = "💔 ROLL DIE OF PAIN (DAMAGE RISK)",
						ActionToExecute = () =>
						{
							SettleMortalGamble( 2 );
						}
					} );

					// --- BUTTON 3: DIE OF CHAOS ---
					deathDiceEvent.Options.Add( new EventOption
					{
						ButtonText = "⚡ ROLL DIE OF CHAOS (BUFF / DEBUFF)",
						ActionToExecute = () =>
						{
							SettleMortalGamble( 3 );
						}
					} );

					// --- BUTTON 4: DIE OF DEATH ---
					deathDiceEvent.Options.Add( new EventOption
					{
						ButtonText = "💀 ROLL DIE OF DEATH (25% CHANCE AT INSTANT LOSS)",
						ActionToExecute = () =>
						{
							SettleMortalGamble( 4 );
						}
					} );

					// 3. Command the UI tree builder layout canvas to open the screen prompt overlay
					GameManager.Instance.TriggerChoicePopup( deathDiceEvent );
					break;
				}

			case 53:
				{
					GameManager.AddLog( "\n=== DEMON CONTRACT EVENT ===" );
					GameManager.AddLog( "A blazing red sigil appears beneath you both." );
					GameManager.AddLog( "\"SIGN THE CONTRACT AND GAIN POWER.. OR REFUSE AND BE WEAK!\" the demon roars.\n" );
					GameManager.AddLog( "⚠️ AWAITING INFERNAL ACCOUNT SIGNATURE..." );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Calculate scaled prestige modifications (+1 to +5 lineally per prestige level)
					int scaledContractAtk = 20 + (prestige * 3);
					int scaledContractDef = 10 + (prestige * 2);
					int scaledContractHeal = 30 + (prestige * 5);
					int scaledCowardPunish = 15 + (prestige * 3);
					int scaledEnragedExplosion = 10 + (prestige * 2);

					// Local stack pointers to satisfy reference parameter passing
					var p = player;
					var a = ai;

					// FIX: Use Random.Shared.Next instead of Sandbox.Game.Random (1, 3 is exclusive upper bound to roll 1 or 2)
					int secretAIChoice = Random.Shared.Next( 1, 3 );

					// 👑 LOCAL FUNCTION: Modified to handle prestige-scaled metrics dynamically via closure hooks and object buffers
					void ResolveDemonicContract( int choicePlayer, int choiceAI )
					{
						GameManager.AddLog( $"You choose to {(choicePlayer == 1 ? "sign" : "refuse")}." );
						GameManager.AddLog( $"AI chooses to {(choiceAI == 1 ? "sign" : "refuse")}!\n" );

						// CASE: BOTH SIGN.
						if ( choicePlayer == 1 && choiceAI == 1 )
						{
							// FIX: Integrate the active event healing buffs into the demonic contract reward calculations!
							int finalPlayerHeal = scaledContractHeal + p.eventHealingBuff;
							int finalAIHeal = scaledContractHeal + a.eventHealingBuff;

							GameManager.AddLog( "** BOTH sign the demonic pact! **" );
							GameManager.AddLog( $"An infernal rush of power surges through your bodies! (You: +{scaledContractAtk} ATK next turn, +{scaledContractDef} DEF next turn, +{finalPlayerHeal} HP | AI: +{scaledContractAtk} ATK next turn, +{scaledContractDef} DEF next turn, +{finalAIHeal} HP)" );

							// FIX: Map attack and armor gains straight to the new temporary object fields instead of core base stats!
							p.eventAttackBuff += scaledContractAtk;
							p.eventAttackBuff += scaledContractDef; // Funneling defense safely into the single attack loop calculation slot
							p.hp += finalPlayerHeal;

							a.eventAttackBuff += scaledContractAtk;
							a.eventAttackBuff += scaledContractDef;
							a.hp += finalAIHeal;

							p.cursed = true;
							a.cursed = true;

							// Rare instant death chance 1%. (Uses exact Random.Shared Next 1 to 100 boundaries)
							if ( Random.Shared.Next( 1, 101 ) < 2 )
							{
								GameManager.AddLog( "\n** BUT THE DEMON CLAIMS A SOUL! YOU DIE INSTANTLY! **" );
								p.hp = 0;
							}

							if ( Random.Shared.Next( 1, 101 ) < 2 )
							{
								GameManager.AddLog( "\n** THE DEMON CLAIMS THE AI'S SOUL! **" );
								a.hp = 0;
							}

							// FIX: Dynamic cap ceiling checks replace hardcoded 100 loops
							if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;
							if ( a.hp > maxAIHp ) a.hp = maxAIHp;

							p.eventHealingBuff = 0; // Safe flush
							a.eventHealingBuff = 0; // Safe flush
							return;
						}

						// CASE: PLAYER SIGNS, AI REFUSES.
						if ( choicePlayer == 1 && choiceAI == 2 )
						{
							int finalPlayerHeal = scaledContractHeal + p.eventHealingBuff;

							GameManager.AddLog( "** You sign, AI refuses! **" );
							GameManager.AddLog( $"The demon favors your BOLDNESS. (+{scaledContractAtk} ATK next turn, +{scaledContractDef} DEF next turn, +{finalPlayerHeal} HP)" );

							// FIX: Map attack and armor gains straight to the new temporary object fields
							p.eventAttackBuff += scaledContractAtk;
							p.eventAttackBuff += scaledContractDef;
							p.hp += finalPlayerHeal;
							p.cursed = true;

							// 5% chance the demon punishes the coward. Direct impact lane.
							if ( Random.Shared.Next( 1, 101 ) < 6 )
							{
								GameManager.AddLog( $"** The demon punishes the AI for cowardice! -{scaledCowardPunish} HP **" );
								CombatManager.applyDamage( ref a, scaledCowardPunish );
							}

							// FIX: Dynamic cap ceiling checks replace hardcoded 100 loops
							if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;
							if ( a.hp < 0 ) a.hp = 0;

							p.eventHealingBuff = 0; // Safe flush
							return;
						}

						// CASE: PLAYER REFUSES, AI SIGNS.
						if ( choicePlayer == 2 && choiceAI == 1 )
						{
							int finalAIHeal = scaledContractHeal + a.eventHealingBuff;

							GameManager.AddLog( "** AI signs, YOU refuse! **" );
							GameManager.AddLog( $"The demon rewards the AI instead. (+{scaledContractAtk} ATK next turn, +{scaledContractDef} DEF next turn, +{finalAIHeal} HP)" );

							// FIX: Map attack and armor gains straight to the AI's temporary object fields
							a.eventAttackBuff += scaledContractAtk;
							a.eventAttackBuff += scaledContractDef;
							a.hp += finalAIHeal;
							a.cursed = true;

							// 5% chance the demon punishes the coward. Direct impact lane.
							if ( Random.Shared.Next( 1, 101 ) < 6 )
							{
								GameManager.AddLog( $"** The demon punishes YOUR cowardice! -{scaledCowardPunish} HP **" );
								CombatManager.applyDamage( ref p, scaledCowardPunish );
							}

							// FIX: Dynamic cap ceiling checks replace hardcoded 100 loops
							if ( a.hp > maxAIHp ) a.hp = maxAIHp;
							if ( p.hp < 0 ) p.hp = 0;

							a.eventHealingBuff = 0; // Safe flush
							return;
						}

						// CASE: BOTH REFUSE. Direct impact lane.
						GameManager.AddLog( "** Both refuse! The demon is ENRAGED! **" );
						GameManager.AddLog( $"It EXPLODES in fury - both take -{scaledEnragedExplosion} HP!" );

						CombatManager.applyDamage( ref p, scaledEnragedExplosion );
						CombatManager.applyDamage( ref a, scaledEnragedExplosion );

						if ( p.hp < 0 ) p.hp = 0;
						if ( a.hp < 0 ) a.hp = 0;

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Assemble the dynamic choice container data packet parcel
					var contractEvent = new ChoiceEvent
					{
						Title = "🔥 DEMONIC PARTITION PACK CONTRACT",
						PromptText = "An unholy crimson sigil has engulfed your local core files. A demonic intelligence demands a security contract exchange for monumental damage values balanced against a permanent tick-curse loop. Will you execute signature?",
					};

					// --- BUTTON 1: SIGN CONTRACT ---
					contractEvent.Options.Add( new EventOption
					{
						ButtonText = "🖋️ SIGN THE CONTRACT (GAIN POWER & CURSE)",
						ActionToExecute = () =>
						{
							ResolveDemonicContract( 1, secretAIChoice );
						}
					} );

					// --- BUTTON 2: REFUSE CONTRACT ---
					contractEvent.Options.Add( new EventOption
					{
						ButtonText = "🛡️ REFUSE SIGNATURE (RISK WRATH)",
						ActionToExecute = () =>
						{
							ResolveDemonicContract( 2, secretAIChoice );
						}
					} );

					// 3. Pass the structure directly up onto your GameManager UI interface layer
					GameManager.Instance.TriggerChoicePopup( contractEvent );
					break;
				}
			case 54:
				{
					GameManager.AddLog( "\n=== RANDOM EVENT ===" );
					GameManager.AddLog( "** SLOT MACHINE OF DOOM appears with three glowing reels! **" );
					GameManager.AddLog( "Both you and the AI pull the lever and hope for fortune... or DOOM!" );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// 2. Calculate prestige-scaled rewards and damage lineally (+1 to +8 per prestige level)
					int scaleJackpotHeal = 50 + (prestige * 8);
					int scaleJackpotBuff = 30 + (prestige * 5);
					int scaleTripleSword = 20 + (prestige * 3);
					int scaleTripleShield = 20 + (prestige * 3);
					int scaleTripleBomb = 40 + (prestige * 6);
					int scaleDoubleSkull = 25 + (prestige * 4);
					int scaleTripleHeart = 30 + (prestige * 5);
					int scaleDoubleHeart = 15 + (prestige * 2);
					int scaleDoubleSword = 10 + (prestige * 2);
					int scaleDoubleShield = 10 + (prestige * 2);
					int scaleMinorDamage = 15 + (prestige * 2);
					int scaleMinorHeal = 5 + (prestige * 1);

					List<string> names = new List<string>
		{
			"SKULL", "HEART", "SWORD", "SHIELD", "CHAOS", "COIN", "BOMB"
		};

					int[] pSpin = new int[3];
					int[] aSpin = new int[3];

					pSpin[0] = Random.Shared.Next( names.Count );
					pSpin[1] = Random.Shared.Next( names.Count );
					pSpin[2] = Random.Shared.Next( names.Count );

					aSpin[0] = Random.Shared.Next( names.Count );
					aSpin[1] = Random.Shared.Next( names.Count );
					aSpin[2] = Random.Shared.Next( names.Count );

					GameManager.AddLog( $"You reels: [{names[pSpin[0]]}] [{names[pSpin[1]]}] [{names[pSpin[2]]}]" );
					GameManager.AddLog( $"AI reels: [{names[aSpin[0]]}] [{names[aSpin[1]]}] [{names[aSpin[2]]}]" );
					GameManager.AddLog( "" );

					int CountSym( int[] spin, int sym )
					{
						int c = 0;
						for ( int i = 0; i < 3; i++ )
						{
							if ( spin[i] == sym ) c++;
						}
						return c;
					}

					// Player Outcome.
					int pSkull = CountSym( pSpin, 0 );
					int pHeart = CountSym( pSpin, 1 );
					int pSword = CountSym( pSpin, 2 );
					int pShield = CountSym( pSpin, 3 );
					int pChaos = CountSym( pSpin, 4 );
					int pCoin = CountSym( pSpin, 5 );
					int pBomb = CountSym( pSpin, 6 );

					GameManager.AddLog( "-- Resolving your spin --" );

					if ( pSkull == 3 )
					{
						GameManager.AddLog( "** HORRIFYING! Three SKULLS! You are instantly destroyed by the machine! **" );
						player.hp = 0;
					}
					else if ( pCoin == 3 )
					{
						// FIX: Integrate any active event healing buffs into the jackpot calculations!
						int totalJackpotHeal = scaleJackpotHeal + player.eventHealingBuff;
						GameManager.AddLog( "** JACKPOT OF DOOM! Three COINS! You are showered in gold and power! **" );
						player.hp += totalJackpotHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

						// FIX: Map attack reward directly into your new permanent model slot!
						player.eventAttackBuff += scaleJackpotBuff;
						player.eventHealingBuff = 0; // Safe flush
						GameManager.AddLog( $"You gain +{totalJackpotHeal} HP and +{scaleJackpotBuff} attack!" );
					}
					else if ( pSword == 3 )
					{
						GameManager.AddLog( "** Three SWORDS! Your weapons beam with energy! **" );
						// FIX: Map attack reward directly into your new permanent model slot!
						player.eventAttackBuff += scaleTripleSword;
						GameManager.AddLog( $"You gain +{scaleTripleSword} attack buff!" );
					}
					else if ( pShield == 3 )
					{
						// FIX: Integrate the active event healing buff into the triple shield payout!
						int totalShieldHeal = scaleTripleShield + player.eventHealingBuff;
						GameManager.AddLog( "** Three SHIELDS! The machine grants you protection! **" );
						player.hp += totalShieldHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

						// FIX: Funnel shield buff into the permanent attack slot safely
						player.eventAttackBuff += 5;
						player.eventHealingBuff = 0; // Safe flush
						GameManager.AddLog( $"You heal +{totalShieldHeal} HP and gain a small defensive buff (+5 attack)." );
					}
					else if ( pBomb == 3 )
					{
						// Direct Impact Lane
						GameManager.AddLog( "** BOOM! Three BOMBS - the machine EXPLODES! Both fighters take critical damage! **" );
						CombatManager.applyDamage( ref player, scaleTripleBomb );
						CombatManager.applyDamage( ref ai, scaleTripleBomb );
						GameManager.AddLog( $"Both take {scaleTripleBomb} damage!" );
					}
					else if ( pChaos >= 1 )
					{
						GameManager.AddLog( "** CHAOS symbol! A random chaotic effect triggers on you... **" );
						int r = Random.Shared.Next( 6 );

						if ( r == 0 )
						{
							GameManager.AddLog( "Chaos swaps your HP with the AI's HP!" );
							int temp = player.hp;
							player.hp = ai.hp;
							ai.hp = temp;
						}
						else if ( r == 1 )
						{
							GameManager.AddLog( "Chaos swaps your base attack with the AI's base attack!" );
							int temp = player.attack;
							player.attack = ai.attack;
							ai.attack = temp;
						}
						else if ( r == 2 )
						{
							GameManager.AddLog( "Chaos swaps attack buffs!" );
							// FIX: Swap the proper new object event buffers!
							int temp = player.eventAttackBuff;
							player.eventAttackBuff = ai.eventAttackBuff;
							ai.eventAttackBuff = temp;
						}
						else if ( r == 3 )
						{
							GameManager.AddLog( "Chaos fully heals you!" );
							player.hp = maxPlayerHp;
						}
						else if ( r == 4 )
						{
							GameManager.AddLog( "Chaos STUNS the AI!" );
							// Leave status stun variable track values intact for round skip logic handlers
							aiBuff = -999;
						}
						else
						{
							// Direct Impact Lane
							GameManager.AddLog( $"The machine sputters and explodes! Both take -{scaleMinorDamage} HP!" );
							CombatManager.applyDamage( ref player, scaleMinorDamage );
							CombatManager.applyDamage( ref ai, scaleMinorDamage );
						}
					}
					else if ( pSkull == 2 )
					{
						GameManager.AddLog( $"Two SKULLS - You take heavy damage! -{scaleDoubleSkull} HP" );
						CombatManager.applyDamage( ref player, scaleDoubleSkull );
					}
					else if ( pHeart == 3 )
					{
						// FIX: Integrate the active event healing buff into the triple heart payout!
						int totalHeartHeal = scaleTripleHeart + player.eventHealingBuff;
						GameManager.AddLog( $"Three HEARTS - the machine blesses you with potent healing! +{totalHeartHeal} HP" );
						player.hp += totalHeartHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
						player.eventHealingBuff = 0; // Safe flush
					}
					else if ( pHeart == 2 )
					{
						// FIX: Integrate the active event healing buff into the double heart payout!
						int totalHeartHeal = scaleDoubleHeart + player.eventHealingBuff;
						GameManager.AddLog( $"Two HEARTS - small healing granted. +{totalHeartHeal} HP" );
						player.hp += totalHeartHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
						player.eventHealingBuff = 0; // Safe flush
					}
					else if ( pSword == 2 )
					{
						GameManager.AddLog( $"Two SWORDS - modest weapon boost. +{scaleDoubleSword} attack" );
						// FIX: Map attack reward directly into your new permanent model slot!
						player.eventAttackBuff += scaleDoubleSword;
					}
					else if ( pShield == 2 )
					{
						// FIX: Integrate the active event healing buff into the double shield payout!
						int totalShieldHeal = scaleDoubleShield + player.eventHealingBuff;
						GameManager.AddLog( $"Two SHIELDS - small defensive aid and heal. +{totalShieldHeal} HP" );
						player.hp += totalShieldHeal;
						if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;

						// FIX: Funnel shield buff into the permanent attack slot safely
						player.eventAttackBuff += 5;
						player.eventHealingBuff = 0; // Safe flush
					}
					else if ( pBomb >= 1 )
					{
						if ( Random.Shared.Next( 100 ) < 50 )
						{
							GameManager.AddLog( $"A stray bomb fragment hits you! -{scaleMinorDamage} HP" );
							CombatManager.applyDamage( ref player, scaleMinorDamage );
						}
						else
						{
							GameManager.AddLog( "Bomb fizzles but does not explode!" );
						}
					}
					else
					{
						if ( Random.Shared.Next( 100 ) < 50 )
						{
							// FIX: Integrate the active event healing buff into the minor heal payout!
							int totalMinorHeal = scaleMinorHeal + player.eventHealingBuff;
							GameManager.AddLog( $"The machine coughs and gives you a tiny coin +{totalMinorHeal} HP" );
							player.hp += totalMinorHeal;
							if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
							player.eventHealingBuff = 0; // Safe flush
						}
						else
						{
							GameManager.AddLog( "Nothing much - the reels reset." );
						}
					}

					// AI outcome.
					int aSkull = CountSym( aSpin, 0 );
					int aHeart = CountSym( aSpin, 1 );
					int aSword = CountSym( aSpin, 2 );
					int aShield = CountSym( aSpin, 3 );
					int aChaos = CountSym( aSpin, 4 );
					int aCoin = CountSym( aSpin, 5 );
					int aBomb = CountSym( aSpin, 6 );

					GameManager.AddLog( "\n-- Resolving AI spin --" );

					if ( aSkull == 3 )
					{
						GameManager.AddLog( "** HORRIFYING! AI rolled three SKULLS and is instantly destroyed by the machine! **" );
						ai.hp = 0;
					}
					else if ( aCoin == 3 )
					{
						// FIX: Integrate the AI's active event healing buff into its coin jackpot!
						int totalJackpotHealAI = scaleJackpotHeal + ai.eventHealingBuff;
						GameManager.AddLog( $"** AI hits a JACKPOT (three COINS!) AI gained massive rewards! **" );
						ai.hp += totalJackpotHealAI;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

						// FIX: Map attack reward directly into the AI's permanent model slot!
						ai.eventAttackBuff += scaleJackpotBuff;
						ai.eventHealingBuff = 0; // Safe flush
						GameManager.AddLog( $"AI +{totalJackpotHealAI} HP and +{scaleJackpotBuff} attack buff!" );
					}
					else if ( aSword == 3 )
					{
						GameManager.AddLog( $"AI reeled three SWORDS - its weapons power up! +{scaleTripleSword} attack" );
						// FIX: Map attack reward directly into the AI's permanent model slot!
						ai.eventAttackBuff += scaleTripleSword;
					}
					else if ( aShield == 3 )
					{
						// FIX: Integrate the AI's active event healing buff into its triple shield payout!
						int totalShieldHealAI = scaleTripleShield + ai.eventHealingBuff;
						GameManager.AddLog( $"AI reeled three SHIELDS - firewalling its defenses! +{scaleTripleShield} HP" );
						ai.hp += totalShieldHealAI;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

						// FIX: Funnel defense buff directly to the AI attack buff property slot safely
						ai.eventAttackBuff += 5;
						ai.eventHealingBuff = 0; // Safe flush
					}
					else if ( aBomb == 3 )
					{
						// Direct Impact Lane
						GameManager.AddLog( $"** BOOM! AI's machine explodes - both take heavy damage! **" );
						CombatManager.applyDamage( ref player, scaleTripleBomb );
						CombatManager.applyDamage( ref ai, scaleTripleBomb );
						GameManager.AddLog( $"Both take {scaleTripleBomb} damage!" );
					}
					else if ( aChaos >= 1 )
					{
						GameManager.AddLog( "AI triggered CHAOS! A random chaotic event affects the battlefield!" );
						int r = Random.Shared.Next( 6 );

						if ( r == 0 )
						{
							GameManager.AddLog( "Chaos swaps AI HP with yours!" );
							int temp = player.hp;
							player.hp = ai.hp;
							ai.hp = temp;
						}
						else if ( r == 1 )
						{
							GameManager.AddLog( "Chaos swaps base attacks!" );
							int temp = player.attack;
							player.attack = ai.attack;
							ai.attack = temp;
						}
						else if ( r == 2 )
						{
							GameManager.AddLog( "Chaos swaps attack buffs!" );
							// FIX: Swap the proper new object event buffers!
							int temp = player.eventAttackBuff;
							player.eventAttackBuff = ai.eventAttackBuff;
							ai.eventAttackBuff = temp;
						}
						else if ( r == 3 )
						{
							GameManager.AddLog( "AI's electrons go chaotic and fully heals the AI!" );
							ai.hp = maxAIHp;
						}
						else if ( r == 4 )
						{
							GameManager.AddLog( "AI sends an electric flux towards the player from chaos!" );
							// Keep status variable track values intact for round skip logic handlers
							playerBuff = -999;
						}
						else
						{
							// Direct Impact Lane
							GameManager.AddLog( $"The machine backfires - both take -{scaleMinorDamage} HP!" );
							CombatManager.applyDamage( ref player, scaleMinorDamage );
							CombatManager.applyDamage( ref ai, scaleMinorDamage );
						}
					}
					else if ( aSkull == 2 )
					{
						GameManager.AddLog( $"AI reeled two SKULLS - heavy damage for AI! -{scaleDoubleSkull} HP" );
						CombatManager.applyDamage( ref ai, scaleDoubleSkull );
					}
					else if ( aHeart == 3 )
					{
						// FIX: Integrate the AI's active event healing buff into the triple heart payout!
						int totalHeartHealAI = scaleTripleHeart + ai.eventHealingBuff;
						GameManager.AddLog( $"Three HEARTS - AI machine grants robust healing! +{scaleTripleHeart} HP" );
						ai.hp += totalHeartHealAI;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;
						ai.eventHealingBuff = 0; // Safe flush
					}
					else if ( aHeart == 2 )
					{
						// FIX: Integrate the AI's active event healing buff into the double heart payout!
						int totalHeartHealAI = scaleDoubleHeart + ai.eventHealingBuff;
						GameManager.AddLog( $"AI reeled two HEARTS - small AI healing. +{scaleDoubleHeart} HP" );
						ai.hp += totalHeartHealAI;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;
						ai.eventHealingBuff = 0; // Safe flush
					}
					else if ( aSword == 2 )
					{
						GameManager.AddLog( $"Two SWORDS - modest AI weapon boost. +{scaleDoubleSword} attack" );
						// FIX: Map attack reward directly into the AI's new model slot
						ai.eventAttackBuff += scaleDoubleSword;
					}
					else if ( aShield == 2 )
					{
						// FIX: Integrate the AI's active event healing buff into the double shield payout!
						int totalShieldHealAI = scaleDoubleShield + ai.eventHealingBuff;
						GameManager.AddLog( $"Two SHIELDS - small defensive aid and heal for AI. +{scaleDoubleShield} HP" );
						ai.hp += totalShieldHealAI;
						if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

						ai.eventAttackBuff += 5;
						ai.eventHealingBuff = 0; // Safe flush
					}
					else if ( aBomb >= 1 )
					{
						if ( Random.Shared.Next( 100 ) < 50 )
						{
							GameManager.AddLog( $"A stray bomb fragment strikes the AI! -{scaleMinorDamage} HP" );
							CombatManager.applyDamage( ref ai, scaleMinorDamage );
						}
						else
						{
							GameManager.AddLog( "AI's rolled bomb fizzled out safely." );
						}
					}
					else
					{
						if ( Random.Shared.Next( 100 ) < 50 )
						{
							// FIX: Integrate the AI's active event healing buff into the minor heal payout!
							int totalMinorHealAI = scaleMinorHeal + ai.eventHealingBuff;
							GameManager.AddLog( $"The machine gives the AI a tiny coin +{scaleMinorHeal} HP" );
							ai.hp += scaleMinorHeal;
							if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;
							ai.eventHealingBuff = 0; // Safe flush
						}
						else
						{
							GameManager.AddLog( "AI's reels reset without effect." );
						}
					}

					// Extra glitch jackpot.
					if ( (pCoin == 3 && aCoin == 3) && (Random.Shared.Next( 100 ) < 5) )
					{
						int scaleHellfireBurn = 30 + (prestige * 5);
						int scaleHellfireRelic = 40 + (prestige * 6);

						GameManager.AddLog( "\n*** 666 HELLFIRE JACKPOT!! The machine tears a hole in the sky! ***" );
						GameManager.AddLog( "Both fighters are burned - but then an artifact appears to empower the victor!" );

						player.hp -= scaleHellfireBurn;
						ai.hp -= scaleHellfireBurn;

						if ( player.hp > ai.hp )
						{
							// FIX: Map attack reward directly into your new permanent model slot!
							player.eventAttackBuff += scaleHellfireRelic;
							GameManager.AddLog( $"You find a cursed relic: +{scaleHellfireRelic} attack!" );
						}
						else
						{
							// FIX: Map attack reward directly into the AI's new permanent model slot!
							ai.eventAttackBuff += scaleHellfireRelic;
							GameManager.AddLog( $"AI finds a cursed relic: +{scaleHellfireRelic} attack!" );
						}
					}

					if ( player.hp < 0 ) player.hp = 0;
					if ( ai.hp < 0 ) ai.hp = 0;
					if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
					if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;

					GameManager.AddLog( "\nThe Slot Machine of Doom closes with a mechanical groan.. its lights flicker off." );
					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

					break;
				}
			case 55:
				{
					GameManager.AddLog( "\n=== DRAGON'S GAMBIT ===" );
					GameManager.AddLog( "The sky trembles, an Ancient Dragon descends, its presence warping reality." );
					GameManager.AddLog( "Both fighters must choose how they face the beast.\n" );
					GameManager.AddLog( "⚠️ AWAITING MYSTICAL ENCOUNTER MATRIX STANCE..." );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// 2. Calculate prestige-scaled rewards and damage lineally (+1 to +6 per prestige level)
					int scaleDragonDamageBonus = prestige * 5;
					int scaleDragonStatBonus = prestige * 2;

					// Establish local stack pointers to satisfy reference variable scopes
					var p = player;
					var a = ai;

					// FIX: Use Random.Shared.Next instead of Sandbox.Game.Random (1, 5 is exclusive upper bound to roll 1, 2, 3, or 4)
					int secretAIChoice = Random.Shared.Next( 1, 5 );

					// 👑 LOCAL FUNCTION A: Modified to handle prestige-scaled metrics dynamically and map to secure properties
					void ResolveDragonGambit( int choice, Player unit, bool isPlayer, int targetMaxHp )
					{
						string who = isPlayer ? "Player" : "AI";
						int atkGain = 0;
						int defGain = 0;

						switch ( choice )
						{
							// 1. Attack Dragon.
							case 1:
								{
									int dmg = Random.Shared.Next( 20, 51 ) + scaleDragonDamageBonus;
									atkGain = Random.Shared.Next( 4, 10 ) + scaleDragonStatBonus; // 4 to 9 base

									unit.hp -= dmg;
									// FIX: Map temporary event bonus reward straight to your new permanent model tracker slot!
									unit.eventAttackBuff += atkGain;

									GameManager.AddLog( $"{who} strikes the dragon! Takes -{dmg} HP, but absorbs Dragon Blood: +{atkGain} attack bonus next turn." );
									break;
								}

							// 2. Defend.
							case 2:
								{
									int dmg = Random.Shared.Next( 10, 31 ) + scaleDragonDamageBonus; // 10 to 30 base
									defGain = Random.Shared.Next( 2, 6 ) + scaleDragonStatBonus; // 2 to 5 base

									unit.hp -= dmg;
									// FIX: Map temporary defense boost straight to the single event calculation slot safely
									unit.eventAttackBuff += defGain;

									GameManager.AddLog( $"{who} braces against the flames. -{dmg} HP. Gains Dragon Scales: +{defGain} defense bonus next turn." );
									break;
								}

							// 3. Flee. (Direct Damage Lane)
							case 3:
								{
									int luck = Random.Shared.Next( 0, 100 ); // 0 to 99 inclusive

									if ( luck < 35 )
									{
										GameManager.AddLog( $"{who} escapes untouched!" );
									}
									else if ( luck < 75 )
									{
										int dmg = Random.Shared.Next( 10, 36 ) + scaleDragonDamageBonus; // 10 to 35 base
										unit.hp -= dmg;
										GameManager.AddLog( $"{who} fails to escape and is scorched! -{dmg} HP." );
									}
									else
									{
										int doom = Random.Shared.Next( 40, 91 ) + scaleDragonDamageBonus; // 40 to 90 base
										unit.hp -= doom;
										GameManager.AddLog( $"{who} is CRITICALLY struck by the dragon! -{doom} HP." );
									}
									break;
								}

							// 4. Negotiate.
							case 4:
								{
									int luck = Random.Shared.Next( 0, 100 ); // 0 to 99 inclusive

									// Dragon's Favor (super rare).
									if ( luck < 10 )
									{
										atkGain = Random.Shared.Next( 10, 20 ) + scaleDragonStatBonus; // 10 to 19 base
										defGain = Random.Shared.Next( 10, 20 ) + scaleDragonStatBonus; // 10 to 19 base

										// FIX: Map both rewards straight to the temporary event buff property slots
										unit.eventAttackBuff += atkGain;
										unit.eventAttackBuff += defGain;

										GameManager.AddLog( $"{who} speaks ancient words. The dragon bows!" );
										GameManager.AddLog( $"{who} receives DRAGON'S FAVOR: +{atkGain} attack, +{defGain} armor bonus next turn!" );
									}
									else if ( luck < 50 )
									{
										int dmg = Random.Shared.Next( 10, 21 ) + scaleDragonDamageBonus; // 10 to 20 base
										unit.hp -= dmg;
										GameManager.AddLog( $"{who}'s words fail. The dragon lashes out! -{dmg} HP." );
									}
									else
									{
										// Dragon's Curse (severe penalty). Scale the penalty slightly too (+1 per level)
										int cursePenaltyScale = prestige * 1;
										int curseAtk = Random.Shared.Next( 2, 6 ) + cursePenaltyScale; // 2 to 5 base
										int curseDef = Random.Shared.Next( 2, 6 ) + cursePenaltyScale; // 2 to 5 base

										// FIX: Apply the curse penalty securely directly to your temporary object fields
										unit.eventAttackBuff -= curseAtk;
										unit.eventAttackBuff -= curseDef;

										GameManager.AddLog( $"{who} angers the dragon!" );
										GameManager.AddLog( $"Dragon's Curse: -{curseAtk} attack, -{curseDef} defense penalty next turn!" );
									}
									break;
								}
						}

						// FIX: Dynamic cap ceiling checks replace hardcoded 100 loops
						if ( unit.hp > targetMaxHp ) unit.hp = targetMaxHp;
						if ( unit.hp < 0 ) unit.hp = 0;
					}

					// 👑 LOCAL FUNCTION B: Combines player selection execution and automated AI resolution right on checkout
					void FinalizeDragonEncounter( int playerChoice )
					{
						// Execute player choice
						ResolveDragonGambit( playerChoice, p, true, maxPlayerHp );

						// Execute AI choice simultaneously
						ResolveDragonGambit( secretAIChoice, a, false, maxAIHp );

						GameManager.AddLog( "\nThe dragon ascends into the burning, lightning clouds..." );
						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Assemble the dynamic 4-button interactive choice container configuration parcel
					var dragonEvent = new ChoiceEvent
					{
						Title = "🐉 ANCIENT DRAGON MATRIX INTRUSION",
						PromptText = "An Ancient Dragon has ruptured your partition layers, fracturing reality. Your system controls are frozen. Select your stance matrix profile to confront the beast:",
					};

					// --- BUTTON 1: ATTACK ---
					dragonEvent.Options.Add( new EventOption
					{
						ButtonText = "⚔️ ATTACK HEAD-ON (HIGH RISK / STAT GAIN)",
						ActionToExecute = () =>
						{
							FinalizeDragonEncounter( 1 );
						}
					} );

					// --- BUTTON 2: DEFEND ---
					dragonEvent.Options.Add( new EventOption
					{
						ButtonText = "🛡️ BRACE / DEFEND (MODERATE RISK / DEF SCALE)",
						ActionToExecute = () =>
						{
							FinalizeDragonEncounter( 2 );
						}
					} );

					// --- BUTTON 3: FLEE ---
					dragonEvent.Options.Add( new EventOption
					{
						ButtonText = "🏃 ATTEMPT TO FLEE (LOW ESCAPE CHANCE)",
						ActionToExecute = () =>
						{
							FinalizeDragonEncounter( 3 );
						}
					} );

					// --- BUTTON 4: NEGOTIATE ---
					dragonEvent.Options.Add( new EventOption
					{
						ButtonText = "✨ NEGOTIATE (EXTREME CHANCE / HIGHEST MULTIPLIERS)",
						ActionToExecute = () =>
						{
							FinalizeDragonEncounter( 4 );
						}
					} );

					// 3. Prompt the main screen overlay interface grid to paint the choice boxes over your view
					GameManager.Instance.TriggerChoicePopup( dragonEvent );
					break;
				}

			case 56:
				{
					GameManager.AddLog( "\n=== COIN OF FATE ===" );
					GameManager.AddLog( "A silver gleaming coin falls from the sky, fate demands a flip!" );

					// 1. Fetch current progression statistics upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Calculate scaled prestige modifications (+1 to +3 lineally per prestige level)
					int scaleFlipStatGain = prestige * 1;
					int scaleFlipPunishment = prestige * 3;

					// Marked with local scoping wrapper
					void Flip( string who, ref Player unit )
					{
						int roll = Random.Shared.Next( 0, 2 ); // 0 = bad, 1 = good.

						if ( roll == 1 )
						{
							int baseGain = Random.Shared.Next( 5, 11 ); // +5 to 10 attack base
							int totalGain = baseGain + scaleFlipStatGain;

							// FIX: Map temporary event bonus reward straight to your new permanent model tracker slot!
							unit.eventAttackBuff += totalGain;
							GameManager.AddLog( $"{who} wins the flip! +{totalGain} attack bonus next turn!" );
						}
						else
						{
							int baseDmg = Random.Shared.Next( 10, 35 ); // 10-34 HP base
							int totalDmg = baseDmg + scaleFlipPunishment;
							unit.hp -= totalDmg;
							GameManager.AddLog( $"{who} loses the flip! -{totalDmg} HP!" );
						}

						if ( unit.hp < 0 ) unit.hp = 0;
					}

					Flip( "Player", ref player );
					Flip( "AI", ref ai );
					break;
				}

			case 57:
				{
					GameManager.AddLog( "\n=== GUESS THE NUMBER ===" );
					GameManager.AddLog( "A hidden number from 1 to 5 has been chosen." );
					GameManager.AddLog( "⚠️ AWAITING TERMINAL NUMERICAL PREDICTION..." );

					// 1. Fetch current progression statistics safely upfront for the button closure scope
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Calculate scaled prestige modifications (+1 to +2 lineally per prestige level)
					int scaleGuessAtkGain = prestige * 1;
					int scaleGuessDmgPenalty = prestige * 2;

					// Establish local stack pointers for variable scope stability
					var p = player;
					var a = ai;

					// FIX: Use Random.Shared.Next with an upper bound of 6 (1 to 5 inclusive require 1, 6 boundaries)
					int secret = Random.Shared.Next( 1, 6 );
					int aiGuess = Random.Shared.Next( 1, 6 );

					// 👑 LOCAL FUNCTION: Houses your original conditional trees, reward calculations, and damage calculations
					void EvaluateGuessResults( int playerGuess )
					{
						GameManager.AddLog( $"You guess: {playerGuess}" );
						GameManager.AddLog( $"AI guesses: {aiGuess}" );
						GameManager.AddLog( $"The secret number was: {secret}!\n" );

						// --- PLAYER RESULT ---
						if ( playerGuess == secret )
						{
							int baseGain = Random.Shared.Next( 5, 11 ); // 5 to 10 base
							int finalGain = baseGain + scaleGuessAtkGain;

							// FIX: Map temporary event bonus reward straight to your new permanent model tracker slot!
							p.eventAttackBuff += finalGain;
							GameManager.AddLog( $"You guessed correctly! +{finalGain} attack bonus next turn!" );
						}
						else
						{
							int baseDmg = Random.Shared.Next( 5, 21 ); // 5 to 20 base
							int finalDmg = baseDmg + scaleGuessDmgPenalty;
							CombatManager.applyDamage( ref p, finalDmg );
							if ( p.hp < 0 ) p.hp = 0;
							GameManager.AddLog( $"Wrong! You lose {finalDmg} HP!" );
						}

						// --- AI RESULT ---
						if ( aiGuess == secret )
						{
							int baseGain = Random.Shared.Next( 5, 11 ); // 5 to 10 base
							int finalGain = baseGain + scaleGuessAtkGain;

							// FIX: Map temporary event bonus reward straight to the AI's model tracker slot!
							a.eventAttackBuff += finalGain;
							GameManager.AddLog( $"AI guessed correctly! AI gains +{finalGain} attack bonus next turn!" );
						}
						else
						{
							int baseDmg = Random.Shared.Next( 5, 21 ); // 5 to 20 base
							int finalDmg = baseDmg + scaleGuessDmgPenalty;
							CombatManager.applyDamage( ref a, finalDmg );
							if ( a.hp < 0 ) a.hp = 0;
							GameManager.AddLog( $"AI guessed wrong! AI loses {finalDmg} HP!" );
						}

						GameManager.AddLog( "=========================" );
						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Assemble the dynamic 5-button selection container parcel
					var guessEvent = new ChoiceEvent
					{
						Title = "🔢 CORE NUMERICAL PREDICTION",
						PromptText = "The AI firewall has generated an encrypted single-digit tracking packet ranging from 1 to 5. Input your terminal vector guess to stabilize the data lines:",
					};

					// Loop from 1 to 5 to generate your 5 individual interactive buttons on the fly!
					for ( int num = 1; num <= 5; num++ )
					{
						int currentNum = num; // Safe local copy for the button lambda context closure

						guessEvent.Options.Add( new EventOption
						{
							ButtonText = $"[{currentNum}]",
							ActionToExecute = () =>
							{
								EvaluateGuessResults( currentNum );
							}
						} );
					}

					// 3. Command the UI tree builder layout canvas to launch the overlay panel screen
					GameManager.Instance.TriggerChoicePopup( guessEvent );
					break;
				}
			case 58:
				{
					GameManager.AddLog( "\n=== TRIVIA GAUNTLET ===" );
					GameManager.AddLog( "Both challengers must answer correctly to earn rewards!" );
					GameManager.AddLog( "⚠️ AWAITING TERMINAL KNOWLEDGE PACKET SUBMISSION..." );

					// 1. Fetch current scene progression data securely upfront for the button/timer closures
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Calculate scaled prestige modifications (+1 to +2 lineally per prestige level)
					int scaleTriviaAtkGain = 10 + (prestige * 1);
					int scaleTriviaDmgPenalty = 10 + (prestige * 2);

					// Establish stack pointers to satisfy reference variable parameters
					var p = player;
					var a = ai;

					// FIX: Use Random.Shared.Next with exclusive upper bounds (0 to 4 requires 0, 5)
					int triviaCase = Random.Shared.Next( 0, 5 );

					// FIX: Use Random.Shared.Next with exclusive upper bounds (1 to 6 requires 1, 7)
					int aiGuess = Random.Shared.Next( 1, 7 );

					// 👑 LOCAL FUNCTION: Unified reward and penalty resolution logic
					void ProcessTriviaOutcome( int playerGuess, int correctAnswer )
					{
						GameManager.AddLog( $"You pick: {playerGuess}" );
						GameManager.AddLog( $"AI picks: {aiGuess}" );
						GameManager.AddLog( $"Correct answer: {correctAnswer}\n" );

						// PLAYER RESULT EVALUATION
						if ( playerGuess == correctAnswer )
						{
							GameManager.AddLog( $"Player is correct! +{scaleTriviaAtkGain} attack bonus next turn!" );
							// FIX: Map temporary event bonus reward straight to your new permanent model tracker slot!
							p.eventAttackBuff += scaleTriviaAtkGain;
						}
						else
						{
							GameManager.AddLog( $"Player is wrong! -{scaleTriviaDmgPenalty} HP!" );
							CombatManager.applyDamage( ref p, scaleTriviaDmgPenalty );
						}

						// AI RESULT EVALUATION
						if ( aiGuess == correctAnswer )
						{
							GameManager.AddLog( $"AI is correct! +{scaleTriviaAtkGain} attack bonus next turn!" );
							// FIX: Map temporary event bonus reward straight to the AI's model tracker slot!
							a.eventAttackBuff += scaleTriviaAtkGain;
						}
						else
						{
							GameManager.AddLog( $"AI is wrong! -{scaleTriviaDmgPenalty} HP!" );
							CombatManager.applyDamage( ref a, scaleTriviaDmgPenalty );
						}

						if ( p.hp < 0 ) p.hp = 0;
						if ( a.hp < 0 ) a.hp = 0;

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Configure our structured trivia text and answers setup
					string promptTitle = "🧠 CYBERNETIC TRIVIA GAUNTLET";
					string questionText = "";
					int correctIndex = 1;
					string[] choices = new string[6];

					switch ( triviaCase )
					{
						case 0:
							questionText = "Which planet has the most moons?";
							correctIndex = 4; // Saturn
							choices = new string[] { "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune" };
							break;

						case 1:
							questionText = "Who was the first President of the United States?";
							correctIndex = 5; // Washington
							choices = new string[] { "Adams", "Jefferson", "Lincoln", "Roosevelt", "Washington", "Franklin" };
							break;

						case 2:
							questionText = "What part of the cell contains DNA?";
							correctIndex = 3; // Nucleus
							choices = new string[] { "Cytoplasm", "Membrane", "Nucleus", "Ribosome", "Lysosome", "Mitochondria" };
							break;

						case 3:
							questionText = "What is the Earth's largest ocean?";
							correctIndex = 5; // Pacific
							choices = new string[] { "Atlantic", "Indian", "Arctic", "Southern", "Pacific", "Dead Sea" };
							break;

						case 4:
							questionText = "Which video game franchise features a character named Master Chief?";
							correctIndex = 2; // Halo
							choices = new string[] { "Gears of War", "Halo", "Doom", "Half-Life 2", "Destiny", "Titanfall" };
							break;
					}

					// Print the active question prompt to your combat terminal log lines
					GameManager.AddLog( $"\n[Trivia] {questionText}" );

					// 3. Assemble the dynamic choice event container data parcel
					var triviaEvent = new ChoiceEvent
					{
						Title = promptTitle,
						PromptText = $"Category Packet #{triviaCase} Unsealed. Question: \"{questionText}\" Select the absolute truth vector below to authorize rewards:",

						// ⏱️ STRAP ON THE TIMER CONTROLS
						HasTimeLimit = true,
						TimeRemaining = 10f,
						TotalDuration = 10f,

						// ⏱️ TIMEOUT PUNISHMENT CLOSURE
						OnTimeoutAction = () =>
						{
							GameManager.AddLog( $"❌ TIMER EXPIRED! You failed to submit data to the mainframe before the firewall closed! -{scaleTriviaDmgPenalty} HP!" );
							CombatManager.applyDamage( ref p, scaleTriviaDmgPenalty );
							if ( p.hp < 0 ) p.hp = 0;

							// AI evaluates its separate automatic outcome choice cleanly regardless of player freeze
							if ( aiGuess == correctIndex )
							{
								GameManager.AddLog( $"AI is correct! +{scaleTriviaAtkGain} attack bonus next turn!" );
								// FIX: Route the timeout AI reward through the permanent object property mapping safely
								a.eventAttackBuff += scaleTriviaAtkGain;
							}
							else
							{
								GameManager.AddLog( $"AI is wrong! -{scaleTriviaDmgPenalty} HP!" );
								CombatManager.applyDamage( ref a, scaleTriviaDmgPenalty );
							}

							if ( a.hp < 0 ) a.hp = 0;

							GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
							GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
						}
					};

					// Loop from 1 to 6 using a clean index to populate your multiple-choice interface buttons automatically!
					for ( int choiceNum = 1; choiceNum <= 6; choiceNum++ )
					{
						int currentChoiceIndex = choiceNum; // Safe local variable capture for button lambda context closure
						string currentChoiceText = choices[choiceNum - 1]; // Map string text from array safely

						triviaEvent.Options.Add( new EventOption
						{
							ButtonText = $"{currentChoiceIndex}. {currentChoiceText.ToUpper()}",
							ActionToExecute = () =>
							{
								ProcessTriviaOutcome( currentChoiceIndex, correctIndex );
							}
						} );
					}

					// 4. Command the main UI framework to block screen interaction and drop our buttons into layout view
					GameManager.Instance.TriggerChoicePopup( triviaEvent );
					break;
				}

			case 59:
				{
					GameManager.AddLog( "\n=== BOMB DEFUSE: RED WIRE / BLUE WIRE ===" );
					GameManager.AddLog( "⚠️ WARNING: TIMEBOMB INTRUSION DETECTED! FIREWALL IS LOCKING OUT..." );

					// 1. Fetch current scene progression data securely upfront for the button/timer closures
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Calculate scaled prestige modifications (+2 to +4 lineally per prestige level)
					int scaledDefusalReward = 15 + (prestige * 2);
					int scaledDetonationDamage = 25 + (prestige * 4);

					// Establish local pointers for stack execution
					var p = player;
					var a = ai;

					// FIX: Use Random.Shared.Next with exclusive upper bound 2 to cleanly roll 0 or 1
					int correctWire = Random.Shared.Next( 0, 2 );
					int aiChoice = Random.Shared.Next( 0, 2 );

					// 👑 LOCAL FUNCTION: Unified processing math for the bomb results
					void ProcessWireCutOutcome( int playerChoice )
					{
						GameManager.AddLog( $"You choose: {(playerChoice == 0 ? "Red" : "Blue")}" );
						GameManager.AddLog( $"AI chooses: {(aiChoice == 0 ? "Red" : "Blue")}" );

						// PLAYER RESULTS CHECK
						if ( playerChoice == correctWire )
						{
							GameManager.AddLog( $"You cut the CORRECT wire! AI -{scaledDefusalReward} HP!" );
							CombatManager.applyDamage( ref a, scaledDefusalReward );
						}
						else
						{
							GameManager.AddLog( $"💥 WRONG WIRE! It explodes! You take -{scaledDetonationDamage} HP!" );
							CombatManager.applyDamage( ref p, scaledDetonationDamage );
						}

						// AI RESULTS CHECK
						if ( aiChoice == correctWire )
						{
							GameManager.AddLog( $"AI ALSO cut the correct wire! You take {scaledDefusalReward} damage!" );
							CombatManager.applyDamage( ref p, scaledDefusalReward );
						}
						else
						{
							GameManager.AddLog( $"💥 AI cut the wrong wire and got bombed! AI -{scaledDetonationDamage} HP!" );
							CombatManager.applyDamage( ref a, scaledDetonationDamage );
						}

						if ( p.hp < 0 ) p.hp = 0;
						if ( a.hp < 0 ) a.hp = 0;

						GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
						GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
					}

					// 2. Assemble the dynamic choice event data container parcel
					var bombEvent = new ChoiceEvent
					{
						Title = "💣 DISARM PROTOCOL CRITICAL",
						PromptText = "A hazardous logic timebomb has attached itself to the kernel workspace. You must isolate a single data link pathway before core detonation occurs. Cut a wire immediately!",

						// ⏱️ CONFIGURE DEFUSAL COUNTDOWN PARAMETERS
						HasTimeLimit = true,
						TimeRemaining = 5f,
						TotalDuration = 5f,

						// ⏱️ TIMEOUT PENALTY CLOSURE (BOOM!)
						OnTimeoutAction = () =>
						{
							GameManager.AddLog( $"💥 TIMER EXPIRED! The bomb detonated while you hesitated! You take maximum damage! -{scaledDetonationDamage} HP!" );
							CombatManager.applyDamage( ref p, scaledDetonationDamage );
							if ( p.hp < 0 ) p.hp = 0;

							// AI evaluates its separate automatic outcome choice regardless of your frozen timeout state
							if ( aiChoice == correctWire )
							{
								GameManager.AddLog( $"AI cut the correct wire! You take {scaledDefusalReward} damage!" );
								CombatManager.applyDamage( ref p, scaledDefusalReward );
							}
							else
							{
								GameManager.AddLog( $"💥 AI also cut the wrong wire and got bombed! AI -{scaledDetonationDamage} HP!" );
								CombatManager.applyDamage( ref a, scaledDetonationDamage );
							}

							if ( p.hp < 0 ) p.hp = 0;
							if ( a.hp < 0 ) a.hp = 0;

							GameManager.AddLog( $"{p.name} | HP: {p.hp} | Armor: {p.defense}" );
							GameManager.AddLog( $"{a.name} | HP: {a.hp} | Armor: {a.defense}" );
						}
					};

					// --- BUTTON 1: RED WIRE ---
					bombEvent.Options.Add( new EventOption
					{
						ButtonText = "🔴 CUT RED WIRE",
						ActionToExecute = () =>
						{
							ProcessWireCutOutcome( 0 );
						}
					} );

					// --- BUTTON 2: BLUE WIRE ---
					bombEvent.Options.Add( new EventOption
					{
						ButtonText = "🔵 CUT BLUE WIRE",
						ActionToExecute = () =>
						{
							ProcessWireCutOutcome( 1 );
						}
					} );

					// 3. Command the layout builder framework to draw the buttons over the monitor view
					GameManager.Instance.TriggerChoicePopup( bombEvent );
					break;
				}
			case 60:
				{
					GameManager.AddLog( "\n=== MINI SLOT MACHINE ===" );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// 2. Scale the jackpot reward lineally (+8 HP per prestige level)
					// We weave in your custom event healing buff modifiers directly into the reward pools!
					int finalPlayerJackpot = 50 + (prestige * 8) + player.eventHealingBuff;
					int finalAIJackpot = 50 + (prestige * 8) + ai.eventHealingBuff;
					int baseDamageJackpot = 50 + (prestige * 8); // Raw payout for damage execution

					// FIX: Use 1, 5 bounds for standard exclusive C# Random.Next logic to roll 1, 2, 3, or 4
					int p1 = Random.Shared.Next( 1, 5 );
					int p2 = Random.Shared.Next( 1, 5 );
					int p3 = Random.Shared.Next( 1, 5 );

					GameManager.AddLog( $"You rolled:  [{p1}][{p2}][{p3}]" );

					bool playerWin = (p1 == p2 && p2 == p3);

					int a1 = Random.Shared.Next( 1, 5 );
					int a2 = Random.Shared.Next( 1, 5 );
					int a3 = Random.Shared.Next( 1, 5 );

					GameManager.AddLog( $"AI rolled:   [{a1}][{a2}][{a3}]" );

					bool aiWin = (a1 == a2 && a2 == a3);

					// 3. Apply the updated prestige-scaled jackpot values using the object buffers
					if ( playerWin && !aiWin )
					{
						GameManager.AddLog( $"\nYOU HIT THE JACKPOT! +{finalPlayerJackpot} HP, AI -{baseDamageJackpot} HP!" );
						player.hp += finalPlayerJackpot;
						CombatManager.applyDamage( ref ai, baseDamageJackpot ); // Direct Impact Lane for enemy damage
						player.eventHealingBuff = 0; // Safe flush
					}
					else if ( aiWin && !playerWin )
					{
						GameManager.AddLog( $"\nAI HIT THE JACKPOT! -{baseDamageJackpot} HP, AI +{finalAIJackpot} HP!" );
						ai.hp += finalAIJackpot;
						CombatManager.applyDamage( ref player, baseDamageJackpot ); // Direct Impact Lane for player damage
						ai.eventHealingBuff = 0; // Safe flush
					}
					else if ( playerWin && aiWin )
					{
						GameManager.AddLog( $"\nDOUBLE JACKPOT!! You gain +{finalPlayerJackpot} HP and AI gains +{finalAIJackpot} HP!" );
						player.hp += finalPlayerJackpot;
						ai.hp += finalAIJackpot;
						player.eventHealingBuff = 0; // Safe flush
						ai.eventHealingBuff = 0; // Safe flush
					}
					else
					{
						GameManager.AddLog( "\nNo jackpots.. Insert another coin." );
					}

					// FIX: Dynamic cap ceiling checks replace hardcoded 100 loops
					if ( player.hp > maxPlayerHp ) player.hp = maxPlayerHp;
					if ( ai.hp > maxAIHp ) ai.hp = maxAIHp;
					if ( player.hp < 0 ) player.hp = 0;
					if ( ai.hp < 0 ) ai.hp = 0;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;
				}

			case 61:
				{
					UnoDuelEventRunner.StartEvent( player, ai );
					break;
				}
			case 62:
				{
					GameManager.AddLog( "\n=== CHAOS ARENA (TEST) ===" );

					// 1. Fetch current progression statistics upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale NPC health, attack, and event penalty damage lineally (+4 to +5 per prestige level)
					int scaledGoblinHp = 40 + (prestige * 6);
					int scaledGoblinAtk = 8 + (prestige * 1);
					int scaledOrcHp = 60 + (prestige * 9);
					int scaledOrcAtk = 12 + (prestige * 1);
					int scaledArenaDamage = 20 + (prestige * 4);

					List<EventFighter> fighters = new List<EventFighter>()
		{
			new EventFighter("Player", player.hp, player.attack, false),
			new EventFighter("AI", ai.hp, ai.attack, true),
			new EventFighter($"Goblin (Lv.{prestige})", scaledGoblinHp, scaledGoblinAtk, true),
			new EventFighter($"Orc (Lv.{prestige})", scaledOrcHp, scaledOrcAtk, true)
		};

					int lowestRoll = 999;
					int loserIndex = 0;

					for ( int i = 0; i < fighters.Count; i++ )
					{
						int roll = Random.Shared.Next( 100 );

						GameManager.AddLog( $"{fighters[i].Name} rolls {roll}" );

						if ( roll < lowestRoll )
						{
							lowestRoll = roll;
							loserIndex = i;
						}
					}

					GameManager.AddLog( $"{fighters[loserIndex].Name} loses the challenge! -{scaledArenaDamage} HP" );

					EventFighter temp = fighters[loserIndex];
					temp.Hp -= scaledArenaDamage;
					fighters[loserIndex] = temp;

					// Direct Impact Lane: Re-assign the middle-of-a-match modifications cleanly
					foreach ( EventFighter f in fighters )
					{
						if ( f.Name == "Player" )
							player.hp = f.Hp;

						if ( f.Name == "AI" )
							ai.hp = f.Hp;
					}

					if ( player.hp < 0 ) player.hp = 0;
					if ( ai.hp < 0 ) ai.hp = 0;

					GameManager.AddLog( "\nChaos Arena ends!" );
					break;
				}

			case 63:
				{
					GameManager.AddLog( "\n=== MEGA ARENA ===" );

					// 1. Fetch current progression statistics upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale background fighters and arena splash damage lineally (+3 to +4 per tier)
					int scaledGoblinHp = 40 + (prestige * 6);
					int scaledGoblinAtk = 8 + (prestige * 1);
					int scaledOrcHp = 60 + (prestige * 9);
					int scaledOrcAtk = 12 + (prestige * 1);
					int scaledArenaDamage = 15 + (prestige * 3);

					List<EventFighter> fighters = new List<EventFighter>()
		{
			new EventFighter("Player", player.hp, player.attack, false),
			new EventFighter("AI", ai.hp, ai.attack, true),
			new EventFighter($"Goblin (Lv.{prestige})", scaledGoblinHp, scaledGoblinAtk, true),
			new EventFighter($"Orc (Lv.{prestige})", scaledOrcHp, scaledOrcAtk, true)
		};

					List<int> rolls = new List<int>();
					int totalRoll = 0;

					for ( int i = 0; i < fighters.Count; i++ )
					{
						int roll = Random.Shared.Next( 1, 5 ); // 1 to 4 inclusive
						rolls.Add( roll );
						totalRoll += roll;

						GameManager.AddLog( $"{fighters[i].Name} chooses {totalRoll}" );
					}

					GameManager.AddLog( $"\nTotal Roll Value: {totalRoll}" );

					int damage = 0;

					if ( totalRoll <= 6 )
					{
						damage = fighters.Count;
					}
					else if ( totalRoll <= 9 )
					{
						damage = 3;
					}
					else if ( totalRoll <= 12 )
					{
						damage = 2;
					}
					else if ( totalRoll <= 15 )
					{
						damage = 1;
					}
					else
					{
						damage = 0;
					}

					GameManager.AddLog( $"{damage} fighter(s) will take {scaledArenaDamage} damage!" );

					for ( int i = 0; i < damage; i++ )
					{
						int target = Random.Shared.Next( fighters.Count );

						EventFighter temp = fighters[target];
						temp.Hp -= scaledArenaDamage;
						fighters[target] = temp;

						GameManager.AddLog( $"{temp.Name} takes {scaledArenaDamage} damage!" );
					}

					// Direct Impact Lane: Commit remaining health thresholds back to core entities
					foreach ( EventFighter f in fighters )
					{
						if ( f.Name == "Player" )
							player.hp = f.Hp;

						if ( f.Name == "AI" )
							ai.hp = f.Hp;
					}

					if ( player.hp < 0 ) player.hp = 0;
					if ( ai.hp < 0 ) ai.hp = 0;

					GameManager.AddLog( "\n=== EVENT CONCLUDED ===" );
					break;
				}

			case 64:
				{
					GameManager.AddLog( "\n=== MEGA ARENA WITH STATS ===" );

					// 1. Fetch current progression statistics upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale background fighters lineally
					int scaledGoblinHp = 40 + (prestige * 6);
					int scaledGoblinAtk = 8 + (prestige * 1);
					int scaledOrcHp = 60 + (prestige * 9);
					int scaledOrcAtk = 12 + (prestige * 1);

					List<EventFighter> fighters = new List<EventFighter>()
		{
			new EventFighter("Player", player.hp, player.attack, false),
			new EventFighter("AI", ai.hp, ai.attack, true),
			new EventFighter($"Goblin (Lv.{prestige})", scaledGoblinHp, scaledGoblinAtk, true),
			new EventFighter($"Orc (Lv.{prestige})", scaledOrcHp, scaledOrcAtk, true)
		};

					// Scale baseline stat curves per prestige level (+1 to +2 per level) to match players
					List<int> strength = new List<int>() { 15, 12, 8 + (prestige * 1), 18 + (prestige * 2) };
					List<int> agility = new List<int>() { 12, 10, 15 + (prestige * 2), 6 + (prestige * 1) };
					List<int> luck = new List<int>() { 10, 8, 5 + (prestige * 1), 4 + (prestige * 1) };
					List<int> defense = new List<int>() { 10, 9, 6 + (prestige * 1), 14 + (prestige * 2) };

					for ( int i = 0; i < fighters.Count; i++ )
					{
						int baseRoll = Random.Shared.Next( 1, 101 );

						int statBonus =
							(strength[i] / 2) +
							(agility[i] / 3) +
							(luck[i] / 4);

						int finalRoll = baseRoll + statBonus;

						GameManager.AddLog( $"{fighters[i].Name} rolls {baseRoll} + stat bonus {statBonus} = {finalRoll}" );

						int threshold = 60 - (defense[i] / 2);

						if ( finalRoll < threshold )
						{
							// Scale failure penalty lineally with prestige (+3 damage per prestige level)
							int baseDamage = 20 - (defense[i] / 4);
							int scaledFailDamage = baseDamage + (prestige * 3);

							if ( scaledFailDamage < 5 )
								scaledFailDamage = 5;

							EventFighter temp = fighters[i];
							temp.Hp -= scaledFailDamage;
							fighters[i] = temp;

							GameManager.AddLog( $"{fighters[i].Name} FAILS and takes {scaledFailDamage} damage!" );
						}
						else
						{
							GameManager.AddLog( $"{fighters[i].Name} succeeds and avoids damage!" );
						}
					}

					// Direct Impact Lane: Safely commit the remaining HP metrics back to the core models
					foreach ( EventFighter f in fighters )
					{
						if ( f.Name == "Player" )
							player.hp = f.Hp;

						if ( f.Name == "AI" )
							ai.hp = f.Hp;
					}

					if ( player.hp < 0 ) player.hp = 0;
					if ( ai.hp < 0 ) ai.hp = 0;

					GameManager.AddLog( "=== EVENT COMPLETE ===" );
					break;
				}

			case 65:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: MANA WELL LEAK ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the sudden mana jolt linearly (+5 max SP per prestige tier)
					int scaledManaJolt = 20 + (prestige * 5);

					GameManager.AddLog( $"** A tear in the local server grid erupts into a font of raw energy! Both fighters inhale the residue! +{scaledManaJolt} SP! **" );
					player.magic += scaledManaJolt;
					ai.magic += scaledManaJolt;

					// Hard-clamp the max magic pool constraint securely to 100
					if ( player.magic > 100 ) player.magic = 100;
					if ( ai.magic > 100 ) ai.magic = 100;

					GameManager.AddLog( $"{player.name} SP: {player.magic}/100 | {ai.name} SP: {ai.magic}/100" );
					break;
				}

			case 66:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: WITCH'S BREW CONCOCTION ===" );
					GameManager.AddLog( "** An ancient network daemon manifests as a digital witch, offering a shimmering data vial... **" );
					GameManager.AddLog( "⚠️ AWAITING ARCANE SELECTION INTRUSION..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					// Scale rewards and backfires lineally (+3 to +5 per prestige tier)
					int scaledSipMana = 40 + (prestige * 5);
					int scaledSmashBuff = 15 + (prestige * 3);
					int scaledVialExplode = 20 + (prestige * 4);

					var p = player;

					var witchVialEvent = new ChoiceEvent
					{
						Title = "🧪 THE DAEMON'S WITCH BREW",
						PromptText = "A glitching network witch presents a highly concentrated mana elixir file partition. Will you drink it or smash it against your weapon frame?",
					};

					// --- BUTTON 1: DRINK VIAL ---
					witchVialEvent.Options.Add( new EventOption
					{
						ButtonText = "🧪 DRINK THE VIAL (MANA GAMBLE)",
						ActionToExecute = () =>
						{
							int luck = Random.Shared.Next( 100 );
							if ( luck < 75 ) // 75% success
							{
								GameManager.AddLog( $"The fluid tastes like cold copper! Your circuit pathways supercharge! +{scaledSipMana} SP!" );
								p.magic += scaledSipMana;
								if ( p.magic > 100 ) p.magic = 100;
							}
							else // 25% failure detonation
							{
								GameManager.AddLog( $"The volatile mixture rejects your hardware architecture and explodes internally! -{scaledVialExplode} HP!" );
								CombatManager.applyDamage( ref p, scaledVialExplode );
							}
							GameManager.AddLog( $"{p.name} | HP: {p.hp} | SP: {p.magic}/100" );
						}
					} );

					// --- BUTTON 2: SMASH ON WEAPON ---
					witchVialEvent.Options.Add( new EventOption
					{
						ButtonText = "💥 SMASH ON WEAPON (GUARANTEED ATK)",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"You shatter the vial over your weapon! Ethereal fire coats the blade! +{scaledSmashBuff} damage next round!" );
							// FIX: Map attack reward directly into your secure temporary object fields!
							p.eventAttackBuff += scaledSmashBuff;
						}
					} );

					GameManager.Instance.TriggerChoicePopup( witchVialEvent );
					break;
				}

			case 67:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: SPELL FEEDBACK GLITCH ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the feedback psychic sting damage linearly (+3 damage per level)
					int scaledFeedbackDmg = 15 + (prestige * 3);

					GameManager.AddLog( "** A violent anti-magic electromagnetic pulse scans the arena floor! Caster variables collapse! **" );

					// If a fighter has high magic, they get penalized for carrying highly volatile raw resources!
					if ( player.magic >= 40 )
					{
						GameManager.AddLog( $"{player.name} suffers spell cache feedback! -{scaledFeedbackDmg} HP and -25 Magic points!" );
						CombatManager.applyDamage( ref player, scaledFeedbackDmg );
						player.magic = Math.Max( 0, player.magic - 25 );
					}
					else
					{
						GameManager.AddLog( $"{player.name}'s magic reservoir was low enough to slip beneath the scanning grid safely." );
					}

					if ( ai.magic >= 40 )
					{
						GameManager.AddLog( $"{ai.name} suffers spell cache feedback! -{scaledFeedbackDmg} HP and -25 Magic points!" );
						CombatManager.applyDamage( ref ai, scaledFeedbackDmg );
						ai.magic = Math.Max( 0, ai.magic - 25 );
					}
					else
					{
						GameManager.AddLog( $"{ai.name}'s magic reservoir was low enough to slip beneath the scanning grid safely." );
					}
					break;
				}

			case 68:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: ETHEREAL RESTORATION === " );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the event healing buff tier (+3 healing amplification points per tier)
					int scaledHealBoost = 15 + (prestige * 3);

					GameManager.AddLog( $"** A beautiful cloud of shimmering purple code dust swirls around you! Your recovery matrices glow! **" );
					GameManager.AddLog( $"Your next healing move or environmental restore will be amplified by +{scaledHealBoost} points!" );

					// FIX: Map the value straight to your permanent new object variable slot!
					player.eventHealingBuff += scaledHealBoost;
					break;
				}

			case 69:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: CHAOTIC MANA DRAIN ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					GameManager.AddLog( "** A siphon vortex manifests in the center of the arena! It hungers for logic energy! **" );

					int playerDrain = Random.Shared.Next( 15, 36 ); // 15 to 35 SP
					int aiDrain = Random.Shared.Next( 15, 36 );

					// Execute siphon operations
					player.magic = Math.Max( 0, player.magic - playerDrain );
					ai.magic = Math.Max( 0, ai.magic - aiDrain );
					GameManager.AddLog( $"Vortex siphons {playerDrain} SP from you and {aiDrain} SP from the AI!" );

					// 30% chance the vortex collapses and backfires the entire stolen pool into one random duelist!
					if ( Random.Shared.Next( 100 ) < 30 )
					{
						int combinedTotalSurge = playerDrain + aiDrain;
						int targetLuckyRoll = Random.Shared.Next( 2 );

						if ( targetLuckyRoll == 0 )
						{
							GameManager.AddLog( $"💥 THE VORTEX COLLAPSES SPECTACULARLY! The combined electrical charge overflows into YOUR circuits! +{combinedTotalSurge} SP!" );
							player.magic += combinedTotalSurge;
							if ( player.magic > 100 ) player.magic = 100;
						}
						else
						{
							GameManager.AddLog( $"💥 THE VORTEX COLLAPSES SPECTACULARLY! The combined electrical charge overflows into the AI's mainframe! +{combinedTotalSurge} SP!" );
							ai.magic += combinedTotalSurge;
							if ( ai.magic > 100 ) ai.magic = 100;
						}
					}
					break;
				}

			case 70:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: IRON METEORITE OVERLAY ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerDefense = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxDefense : 100;
					int maxAIDefense = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxDefense : 100;

					// Scale the flat reinforcement points smoothly (+4 armor per prestige)
					int scaledReinforce = 15 + (prestige * 4);

					GameManager.AddLog( $"** A shower of metallic iron slag falls from above, sticking to both duelists' armor hulls! +{scaledReinforce} Defense! **" );
					player.defense += scaledReinforce;
					ai.defense += scaledReinforce;

					// Dynamic Cap Safety: Clamps securely to your true prestige maximum armor ceilings instead of hardcoded 100 loops!
					if ( player.defense > maxPlayerDefense ) player.defense = maxPlayerDefense;
					if ( ai.defense > maxAIDefense ) ai.defense = maxAIDefense;

					GameManager.AddLog( $"{player.name} Armor: {player.defense} | {ai.name} Armor: {ai.defense}" );
					break;
				}

			case 71:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: THE SCRAPHEAP ANCHOR ===" );
					GameManager.AddLog( "** A magnetic clamp anchors you down into an old crate of titanium plating plates! **" );
					GameManager.AddLog( "⚠️ AWAITING HARDWARE EXTRACTION OVERRIDE CHOICE..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerDefense = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxDefense : 100;

					// Calculate scaled reward/risk parameters (+3 to +5 per prestige tier)
					int scaledPlateArmor = 25 + (prestige * 5);
					int scaledSpikeBuff = 15 + (prestige * 3);
					int scaledWeightPenalty = 10 + (prestige * 2);

					var p = player;

					var scrapEvent = new ChoiceEvent
					{
						Title = "📦 MAGNETIC SCRAPHEAP MANIFESTATION",
						PromptText = "Your hardware shell has anchored into a pile of encrypted titanium military wreckage fragments. Select your engineering deployment choice:",
					};

					// --- BUTTON 1: BOLT PLATES ON ---
					scrapEvent.Options.Add( new EventOption
					{
						ButtonText = $"🛡️ BOLT PLATES ON (+{scaledPlateArmor} ARMOR, -{scaledWeightPenalty} ATK NEXT ROUND)",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"You reinforce your plating with scrap chunks! Armor boosted by +{scaledPlateArmor}!" );
							p.defense += scaledPlateArmor;
							if ( p.defense > maxPlayerDefense ) p.defense = maxPlayerDefense;

							// FIX: Apply the heavy weight attack penalty directly to your secure temporary slot
							p.eventAttackBuff -= scaledWeightPenalty;
							GameManager.AddLog( $"{p.name} Armor: {p.defense} | Next attack suffers weight drag penalty!" );
						}
					} );

					// --- BUTTON 2: FORGE SPIKES ---
					scrapEvent.Options.Add( new EventOption
					{
						ButtonText = $"⚔️ FORGE KINETIC SPIKES (+{scaledSpikeBuff} ATK NEXT TURN)",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"You shape the metal into razor sharp jagged shards on your gloves! Your next strike gains +{scaledSpikeBuff} cutting power!" );
							// FIX: Map attack reward directly into your secure temporary object fields!
							p.eventAttackBuff += scaledSpikeBuff;
						}
					} );

					GameManager.Instance.TriggerChoicePopup( scrapEvent );
					break;
				}

			case 72:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: CORROSIVE OXIDATION CLOUD ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the acid armor corrosion strip linearly (+3 protection points stripped per prestige)
					int scaledRustStrip = 10 + (prestige * 3);

					GameManager.AddLog( "** A green cloud of highly corrosive airborne chemical cleaner floods the floor channels! **" );
					GameManager.AddLog( "Hulls sizzle! Both combatants suffer structural defense compromises!" );

					player.defense = Math.Max( 0, player.defense - scaledRustStrip );
					ai.defense = Math.Max( 0, ai.defense - scaledRustStrip );

					GameManager.AddLog( $"{player.name} Armor: {player.defense} | {ai.name} Armor: {ai.defense}" );
					break;
				}

			case 73:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: FORTIFIED FORCEFIELD ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the kinetic shield buffer value smoothly (+4 attack mitigation equivalents per level)
					int scaledBarrierBonus = 15 + (prestige * 4);

					GameManager.AddLog( $"** A drone glides in and drops an energy shield projector directly on your shoulder pad loop! **" );
					GameManager.AddLog( $"Your next physical round defense calculation is reinforced with +{scaledBarrierBonus} points!" );

					// Funnel defensive buff rewards straight into the eventAttackBuff slot to be parsed smoothly by weapon turns
					player.eventAttackBuff += scaledBarrierBonus;
					break;
				}

			case 74:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: NANOBOT RE-PLATING RACE ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerDefense = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxDefense : 100;
					int maxAIDefense = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxDefense : 100;

					GameManager.AddLog( "** A batch of rogue hardware repair nanobots floods the arena circuitry! It's a quick-witted construction race! **" );

					int playerCompileRoll = Random.Shared.Next( 1, 101 );
					int aiCompileRoll = Random.Shared.Next( 1, 101 );

					int scaledWinnerArmorReward = 25 + (prestige * 5);
					int scaledLoserArmorReward = 10 + (prestige * 2);

					if ( playerCompileRoll > aiCompileRoll )
					{
						GameManager.AddLog( $"** SUCCESS! Your logic terminals compiled code faster! You capture the primary bot swarm! +{scaledWinnerArmorReward} Armor! **" );
						player.defense += scaledWinnerArmorReward;
						ai.defense += scaledLoserArmorReward;
						GameManager.AddLog( $"AI receives residual fragments: +{scaledLoserArmorReward} Armor." );
					}
					else if ( aiCompileRoll > playerCompileRoll )
					{
						GameManager.AddLog( $"** DEFICIT! The AI's calculation loops outpaced yours and locked down the prime grid vector! AI gains +{scaledWinnerArmorReward} Armor! **" );
						ai.defense += scaledWinnerArmorReward;
						player.defense += scaledLoserArmorReward;
						GameManager.AddLog( $"You receive residual fragments: +{scaledLoserArmorReward} Armor." );
					}
					else
					{
						GameManager.AddLog( $"** TIE DATA PACKET SECTOR! The nanobots divide perfectly evenly down the center lines! Both gain +{scaledLoserArmorReward} Armor! **" );
						player.defense += scaledLoserArmorReward;
						ai.defense += scaledLoserArmorReward;
					}

					// Dynamic Cap Safety: Clamps securely to your true prestige ceilings
					if ( player.defense > maxPlayerDefense ) player.defense = maxPlayerDefense;
					if ( ai.defense > maxAIDefense ) ai.defense = maxAIDefense;

					GameManager.AddLog( $"{player.name} Armor: {player.defense} | {ai.name} Armor: {ai.defense}" );
					break;
				}

			case 75:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: CORE OVERCLOCK SHUNT ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale the sacrificial conversion rate smoothly
					int hpSacrifice = 15 + (prestige * 2);
					int manaGain = 40 + (prestige * 5);

					GameManager.AddLog( $"** The arena grid demands a blood sacrifice to open its logic gate! **" );
					GameManager.AddLog( $"Your core processors shunt {hpSacrifice} physical HP directly into raw energy! You gain +{manaGain} SP!" );

					// Drain physical HP safely using your combat manager system
					CombatManager.applyDamage( ref player, hpSacrifice );
					player.magic += manaGain;

					if ( player.magic > 100 ) player.magic = 100;
					GameManager.AddLog( $"{player.name} HP: {player.hp} | SP: {player.magic}/100" );
					break;
				}

			case 76:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: THE DESYNC INVERSION ===" );
					GameManager.AddLog( "** A catastrophic time-dilation desync flips the digital landscape upside down! **" );

					// Invert the mana pools completely! Whoever had low magic is now completely overclocked.
					int tempPlayerMagic = player.magic;
					player.magic = ai.magic;
					ai.magic = tempPlayerMagic;

					GameManager.AddLog( $"⚡ Resource values swapped! Your SP is now {player.magic}/100 | AI's SP is now {ai.magic}/100!" );

					// Check if the swap accidentally pushed either duelist into the 75+ Overclock damage variance trigger zone!
					if ( player.magic >= 75 ) GameManager.AddLog( "🔥 Your matrix variance bounds have suddenly expanded!" );
					if ( ai.magic >= 75 ) GameManager.AddLog( "🔥 The AI Overlord is radiating critical magic energy!" );
					break;
				}

			case 77:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: ANTI-VIRUS SANITIZATION ===" );
					GameManager.AddLog( "** A global firewall sweep wipes all active memory caches from the board! **" );

					// Strips all status abnormalities and cuts magic reserves exactly in half for safety
					player.cursed = false;
					ai.cursed = false;

					player.magic /= 2;
					ai.magic /= 2;

					GameManager.AddLog( "All status curses purged. Volatile magic pools cut by 50% to prevent database corruption." );
					GameManager.AddLog( $"{player.name} SP: {player.magic}/100 | {ai.name} SP: {ai.magic}/100" );
					break;
				}

			case 78:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: SOURCE CODE CORRUPTION ===" );
					GameManager.AddLog( "** A corrupted source code packet leaks onto your terminal... **" );
					GameManager.AddLog( "⚠️ AWAITING MALWARE INTEGRATION CHOICES..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;

					int scaledSpikeAtk = 25 + (prestige * 4);
					int scaledBurnDmg = 20 + (prestige * 3);

					var p = player;
					var corruptEvent = new ChoiceEvent
					{
						Title = "👾 MALWARE SOURCE CODE DETECTED",
						PromptText = "A fragment of forbidden developer testing code has opened. Will you load it into your magic spell cache or delete it for a recovery flush?",
					};

					// --- BUTTON 1: INJECT PROTOCOL ---
					corruptEvent.Options.Add( new EventOption
					{
						ButtonText = $"⚡ INJECT PROTOCOL (+{scaledSpikeAtk} ATK SPELL BUFF, COMPROMISE OWN RECOVERY)",
						ActionToExecute = () =>
						{
							GameManager.AddLog( $"Forbidden data stream loaded! Your next magic spell attack gains +{scaledSpikeAtk} damage, but your internal repairs are broken!" );
							p.eventAttackBuff += scaledSpikeAtk;
							p.eventHealingBuff -= 99; // Cripples healing significantly for the round
						}
					} );

					// --- BUTTON 2: FORMAT CACHE ---
					corruptEvent.Options.Add( new EventOption
					{
						ButtonText = "🧹 PURGE CACHE (RESTORE HEALTH & MANA safely)",
						ActionToExecute = () =>
						{
							int healthRestore = 15 + (prestige * 3);
							GameManager.AddLog( $"You safely isolate and scrub the file! System recovery routines execute smoothly. +{healthRestore} HP and +20 SP!" );
							p.hp += healthRestore;
							p.magic += 20;

							if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;
							if ( p.magic > 100 ) p.magic = 100;
						}
					} );

					GameManager.Instance.TriggerChoicePopup( corruptEvent );
					break;
				}

			case 79:
				{
					GameManager.AddLog( "\n=== MAGIC EVENT: THE INFINITE SPARK ===" );
					GameManager.AddLog( "** The matrix loops infinitely for a single processing cycle! **" );
					GameManager.AddLog( "✨ Every single active weapon enchantment triggers its positive logic instantly! ✨" );

					// For players without specialized gear, treat it as a universal dynamic spark flare
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int sparkGift = 15 + (prestige * 3);

					player.magic = Math.Min( 100, player.magic + sparkGift );
					ai.magic = Math.Min( 100, ai.magic + sparkGift );

					GameManager.AddLog( $"Spark surge grants +{sparkGift} magic points to both duelists!" );
					break;
				}

			case 80:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: SINGULARITY MAGNETIC EMP ===" );
					GameManager.AddLog( "** A micro-singularity detonates, releasing a massive magnetized shockwave! **" );

					// Magnetic induction strips exactly 50% of the active defense shields right off both fighters!
					int playerStrip = player.defense / 2;
					int aiStrip = ai.defense / 2;

					player.defense -= playerStrip;
					ai.defense -= aiStrip;

					GameManager.AddLog( $"The pulse shears off metal plating! Stripped {playerStrip} Armor from you and {aiStrip} Armor from the AI!" );
					GameManager.AddLog( $"{player.name} Armor: {player.defense} | {ai.name} Armor: {ai.defense}" );
					break;
				}

			case 81:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: REACTIONARY SPIKE PLATING ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;

					// Scale thorn feedback damage linearly with prestige tiers
					int spikeThornDmg = 12 + (prestige * 3);

					GameManager.AddLog( $"** Spikes of polarized conducting graphite break out across your armor frame! **" );
					GameManager.AddLog( $"As long as your blue armor defense bar stays above 0, the next time you take a hit, the attacker takes {spikeThornDmg} spike damage!" );

					// Safely store it inside your event attack buff parameter slot for evaluation hooks
					player.eventAttackBuff += spikeThornDmg;
					break;
				}

			case 82:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: RECYCLING REDIRECT ===" );
					GameManager.AddLog( "** Your defensive processors detect a system vulnerability window... **" );
					GameManager.AddLog( "⚠️ AWAITING DEFENSIVE REDIRECTION CHOICE..." );

					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerDefense = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxDefense : 100;

					var p = player;
					var recycleEvent = new ChoiceEvent
					{
						Title = "🎛️ SHIELD OVERRIDE REDIRECTION MATRIX",
						PromptText = "Will you dismantle half your active blue armor plating to completely restore your magic circuits, or leave it intact?",
					};

					// --- BUTTON 1: RECYCLE SHIELD ---
					recycleEvent.Options.Add( new EventOption
					{
						ButtonText = "🔋 SACRIFICE HALF ARMOR FOR FULL MANA (OVERCLOCK STRAT)",
						ActionToExecute = () =>
						{
							if ( p.defense > 0 )
							{
								int lostArmor = p.defense / 2;
								p.defense -= lostArmor;
								p.magic = 100; // Complete instant mana reload!
								GameManager.AddLog( $"You melt down {lostArmor} armor plates to ignite your power cells! Magic fully restored to 100 SP! Time to overclock!" );
							}
							else
							{
								GameManager.AddLog( "You have 0 active armor plates to recycle! The redirect matrix crashes out." );
							}
						}
					} );

					// --- BUTTON 2: FORTIFY HULL ---
					recycleEvent.Options.Add( new EventOption
					{
						ButtonText = "🛡️ OVERCHARGE CERAMIC CORE (+30 GUARANTEED ARMOR)",
						ActionToExecute = () =>
						{
							int armorGain = 30 + (prestige * 5);
							GameManager.AddLog( $"You push backup lines to the shield capacitors! +{armorGain} blue armor padding established safely!" );
							p.defense += armorGain;
							if ( p.defense > maxPlayerDefense ) p.defense = maxPlayerDefense;
						}
					} );

					GameManager.Instance.TriggerChoicePopup( recycleEvent );
					break;
				}

			case 83:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: EXTRUDED PLASMA SHIELD ===" );
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerDefense = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxDefense : 100;

					// Grants an enormous shield boost but forces your next move to take a small random roll penalty
					int megaShieldBoost = 40 + (prestige * 8);

					GameManager.AddLog( $"** An emergency cargo drop floods your systems with heavy liquid plasma defense foam! **" );
					GameManager.AddLog( $"Your blue armor bar expands significantly by +{megaShieldBoost}! However, the cooling weight slows you down slightly." );

					player.defense += megaShieldBoost;
					if ( player.defense > maxPlayerDefense ) player.defense = maxPlayerDefense;

					// Inflict a minor weight penalty directly onto the event damage field to track the cooling sludge
					player.eventAttackBuff -= 5;
					GameManager.AddLog( $"{player.name} Armor maxed to: {player.defense}." );
					break;
				}

			case 84:
				{
					GameManager.AddLog( "\n=== ARMOR EVENT: CRITICAL SHIELD SYNCHRONICITY ===" );
					GameManager.AddLog( "** The engine synchronizes both fighters' shields to the highest active baseline! **" );

					// Find the highest current armor value on the field
					int highestArmorValue = Math.Max( player.defense, ai.defense );

					if ( highestArmorValue <= 10 )
					{
						// If both fighters are battered down, scale a baseline jump instead
						var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
						int prestige = manager != null ? manager.CurrentPrestige : 0;
						highestArmorValue = 25 + (prestige * 4);
						GameManager.AddLog( $"Both defensive fields were completely broken. Grid establishes an emergency buffer of {highestArmorValue} armor for everyone!" );
					}
					else
					{
						GameManager.AddLog( $"Data stream equalized! Both duelists' armor hulls are instantly boosted to the maximum active value of {highestArmorValue}!" );
					}

					player.defense = highestArmorValue;
					ai.defense = highestArmorValue;

					// Safety ceiling check clamps
					int maxP = (Sandbox.Game.ActiveScene.Get<GameManager>()?.LocalPlayer?.maxDefense) ?? 100;
					int maxA = (Sandbox.Game.ActiveScene.Get<GameManager>()?.AIEnemy?.maxDefense) ?? 100;
					if ( player.defense > maxP ) player.defense = maxP;
					if ( ai.defense > maxA ) ai.defense = maxA;

					GameManager.AddLog( $"{player.name} Armor: {player.defense} | {ai.name} Armor: {ai.defense}" );
					break;
				}

			case 85:
				{
					// 🔮 ANIMATION UPDATE: Banners the holy celestial descent in a slow pulsing golden strobe!
					GameManager.AddEventLog( "\n=== 🕊️ CELESTIAL BLESSING COVENANT ===" );
					GameManager.AddEventLog( "A blinding, radiant golden halo descends from the mainframe skies." );
					GameManager.AddEventLog( "\"ACCEPT THE LIGHT AND RE-RESTORE YOUR ARCHITECTURE.. OR DENY THE HEAVENS AND DRAIN YOUR MAGIC!\" a holy echo thunders.\n" );
					GameManager.AddSystemLog( "⚠️ AWAITING DIVINE NETWORK HANDSHAKE SIGNATURE..." );

					// 1. Fetch current scene progression data securely upfront
					var manager = Sandbox.Game.ActiveScene.Get<GameManager>();
					int prestige = manager != null ? manager.CurrentPrestige : 0;
					int maxPlayerHp = (manager != null && manager.LocalPlayer != null) ? manager.LocalPlayer.maxHp : 100;
					int maxAIHp = (manager != null && manager.AIEnemy != null) ? manager.AIEnemy.maxHp : 100;

					// Calculate scaled prestige modifications (+1 to +5 lineally per prestige level)
					int scaledHeavenlyAtk = 25 + (prestige * 4);    // Massive Heavenly Power Boost
					int scaledHeavenlyHeal = 40 + (prestige * 6);   // Massive Heavenly Health Restore
					int scaledHolyRebuke = 15 + (prestige * 2);     // Direct Smite Damage

					// Local stack pointers to satisfy reference parameter passing
					var p = player;
					var a = ai;

					// AI rolls its secret decision tree index (1 = Accept Covenant, 2 = Deny Covenant)
					int secretAIChoice = Random.Shared.Next( 1, 3 );

					// 👑 LOCAL FUNCTION: Processes the dynamic heavenly trade handshakes
					void ResolveHeavenlyBlessing( int choicePlayer, int choiceAI )
					{
						GameManager.AddPlayerLog( $"You choose to {(choicePlayer == 1 ? "ACCEPT" : "DENY")} the covenant." );
						GameManager.AddAILog( $"AI chooses to {(choiceAI == 1 ? "ACCEPT" : "DENY")} the covenant!\n" );

						// CASE 1: BOTH ACCEPT THE HEAVENLY COVENANT
						if ( choicePlayer == 1 && choiceAI == 1 )
						{
							int finalPlayerHeal = scaledHeavenlyHeal + p.eventHealingBuff;
							int finalAIHeal = scaledHeavenlyHeal + a.eventHealingBuff;

							GameManager.AddEventLog( "✨ BOTH accept the divine pact! ✨" );
							GameManager.AddPlayerLog( $"The light fully reconstructs your parameters! (+{scaledHeavenlyAtk} ATK next turn, restored +{finalPlayerHeal} HP to your core grid!)" );
							GameManager.AddAILog( $"The light fully reconstructs the AI parameters! (+{scaledHeavenlyAtk} ATK next turn, restored +{finalAIHeal} HP to the boss grid!)" );

							// Inject stats straight to your temporary event property tracking slots
							p.eventAttackBuff += scaledHeavenlyAtk;
							p.hp += finalPlayerHeal;

							a.eventAttackBuff += scaledHeavenlyAtk;
							a.hp += finalAIHeal;

							// Holy light cleanses poisons/curses instantly on both teams!
							p.cursed = false;
							a.cursed = false;

							if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;
							if ( a.hp > maxAIHp ) a.hp = maxAIHp;

							p.eventHealingBuff = 0; // Safe flush
							a.eventHealingBuff = 0; // Safe flush
							return;
						}

						// CASE 2: PLAYER ACCEPTS, AI DENIES THE COVENANT
						if ( choicePlayer == 1 && choiceAI == 2 )
						{
							int finalPlayerHeal = scaledHeavenlyHeal + p.eventHealingBuff;

							GameManager.AddEventLog( "✨ You accept the covenant, AI denies the light! ✨" );
							GameManager.AddPlayerLog( $"Heavenly energy hyper-charges your weapon slots! (+{scaledHeavenlyAtk} ATK next turn, recovered +{finalPlayerHeal} HP! Cleaned status effects!)" );
							p.eventAttackBuff += scaledHeavenlyAtk;
							p.hp += finalPlayerHeal;
							p.cursed = false;

							// AI is punished: Entirely drains its current Magic (SP) pool!
							GameManager.AddAILog( "⚡ THE HEAVENS REBUKE THE AI! Its active magic registers have been completely DRAINED to 0 SP!" );
							a.magic = 0;

							// 10% chance a holy lightning smite cracks the denier's casing directly
							if ( Random.Shared.Next( 1, 101 ) < 11 )
							{
								GameManager.AddAILog( $"💥 HOLY REBUKE SMITE! AI takes -{scaledHolyRebuke} structural damage!" );
								CombatManager.applyDamage( ref a, scaledHolyRebuke );
							}

							if ( p.hp > maxPlayerHp ) p.hp = maxPlayerHp;
							p.eventHealingBuff = 0; // Safe flush
							return;
						}

						// CASE 3: PLAYER DENIES, AI ACCEPTS THE COVENANT
						if ( choicePlayer == 2 && choiceAI == 1 )
						{
							int finalAIHeal = scaledHeavenlyHeal + a.eventHealingBuff;

							GameManager.AddEventLog( "✨ AI accepts the covenant, YOU deny the light! ✨" );
							GameManager.AddAILog( $"Heavenly energy hyper-charges the AI's weapon slots! (+{scaledHeavenlyAtk} ATK next turn, recovered +{finalAIHeal} HP! Cleaned status effects!)" );
							a.eventAttackBuff += scaledHeavenlyAtk;
							a.hp += finalAIHeal;
							a.cursed = false;

							// Player is punished: Entirely drains your current Magic (SP) pool!
							GameManager.AddPlayerLog( "⚡ THE HEAVENS REBUKE YOUR IMPIETY! Your active magic registers have been completely DRAINED to 0 SP!" );
							p.magic = 0;

							// 10% chance a holy lightning smite cracks your casing directly
							if ( Random.Shared.Next( 1, 101 ) < 11 )
							{
								GameManager.AddPlayerLog( $"💥 HOLY REBUKE SMITE! Your framework suffers -{scaledHolyRebuke} structural damage!" );
								CombatManager.applyDamage( ref p, scaledHolyRebuke );
							}

							if ( a.hp > maxAIHp ) a.hp = maxAIHp;
							a.eventHealingBuff = 0; // Safe flush
							return;
						}

						// CASE 4: BOTH DENY THE DIVINE HANDSHAKE
						GameManager.AddEventLog( "❌ Both deny the covenant! The clouds darken... ❌" );
						GameManager.AddPlayerLog( "Your magic cache is completely emptied! (-100% SP)" );
						GameManager.AddAILog( "AI's magic cache is completely emptied! (-100% SP)" );

						p.magic = 0;
						a.magic = 0;

						GameManager.AddSystemLog( $"{p.name} | HP: {p.hp} | Magic: {p.magic}" );
						GameManager.AddSystemLog( $"{a.name} | HP: {a.hp} | Magic: {a.magic}" );
					}

					// 2. Assemble the choice container container display object packet
					var blessingEvent = new ChoiceEvent
					{
						Title = "🕊️ CELESTIAL PROTOCOL BLESSING",
						PromptText = "A radiant golden aura has overridden your network stack. A heavenly algorithm offering absolute purification requests an architecture covenant signature in exchange for massive data restoration. If denied, your magic allocation pipeline will be force-severed. Execute handshake?",
					};

					// --- BUTTON 1: ACCEPT BLESSING ---
					blessingEvent.Options.Add( new EventOption
					{
						ButtonText = "🕊️ ACCEPT DIVINE COVENANT (BOOST DATA & CURE)",
						ActionToExecute = () =>
						{
							ResolveHeavenlyBlessing( 1, secretAIChoice );
						}
					} );

					// --- BUTTON 2: DENY BLESSING ---
					blessingEvent.Options.Add( new EventOption
					{
						ButtonText = "⚡ REJECT THE HEAVENS (PROTECT SP CACHE)",
						ActionToExecute = () =>
						{
							ResolveHeavenlyBlessing( 2, secretAIChoice );
						}
					} );

					// 3. Pass the structure directly up onto your GameManager UI interface layer
					GameManager.Instance.TriggerChoicePopup( blessingEvent );
					break;
				}

		}


	}
}