/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
	currentLevel: 1,
	highestLevel: 1
});
/**** 
* Classes
****/ 
var AttackMenu = Container.expand(function (karen) {
	var self = Container.call(this);
	self.visible = false;
	self.buttons = [];
	// Back button
	self.backButton = new BattleButton("Back", 0, 120, 'defendButton');
	self.backButton.onSelect = function () {
		self.hide();
		battleUI.showMainMenu();
	};
	self.addChild(self.backButton);
	self.showAttacks = function () {
		// Clear old attack buttons
		for (var i = 0; i < self.buttons.length; i++) {
			self.removeChild(self.buttons[i]);
		}
		self.buttons = [];
		// Create new attack buttons
		for (var i = 0; i < karen.attacks.length; i++) {
			var attack = karen.attacks[i];
			var yPos = -150 + i * 80;
			var btn = new BattleButton(attack.name, 0, yPos, attack.special ? 'specialButton' : 'attackButton');
			btn.attackIndex = i;
			btn.onSelect = function () {
				self.hide();
				battleSystem.executePlayerTurn(karen.getAttack(this.attackIndex));
			};
			self.addChild(btn);
			self.buttons.push(btn);
		}
		self.visible = true;
	};
	self.hide = function () {
		self.visible = false;
	};
	return self;
});
var BattleButton = Container.expand(function (text, x, y, color) {
	var self = Container.call(this);
	self.button = self.attachAsset(color || 'attackButton', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.text = new Text2(text, {
		size: 40,
		fill: 0xFFFFFF,
		font: "Impact"
	});
	self.text.anchor.set(0.5, 0.5);
	self.addChild(self.text);
	self.x = x;
	self.y = y;
	self.setEnabled = function (enabled) {
		self.alpha = enabled ? 1.0 : 0.5;
		self.enabled = enabled;
	};
	// Store original scale values when button is created
	self.originalScaleX = self.scale.x;
	self.originalScaleY = self.scale.y;
	self.down = function (x, y, obj) {
		if (!self.enabled) {
			return;
		}
		// Use button graphic scale change instead of the entire container
		tween(self.button, {
			scaleX: 0.9,
			scaleY: 0.9
		}, {
			duration: 100
		});
	};
	self.up = function (x, y, obj) {
		if (!self.enabled) {
			return;
		}
		// Reset button graphic scale instead of the entire container
		tween(self.button, {
			scaleX: 1.0,
			scaleY: 1.0
		}, {
			duration: 100
		});
		if (self.onSelect) {
			self.onSelect();
		}
	};
	self.setEnabled(true);
	return self;
});
var BattleSystem = Container.expand(function () {
	var self = Container.call(this);
	// Remove existing background if it exists
	if (self.battleBackground) {
		self.removeChild(self.battleBackground);
	}
	// Set background based on current level
	if (self.currentLevel === 1 || storage.currentLevel === 1) {
		self.battleBackground = self.attachAsset('battleBackground', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			scaleX: 1.2,
			scaleY: 1.2
		});
	} else if (self.currentLevel === 2 || storage.currentLevel === 2) {
		self.battleBackground = self.attachAsset('battlebackground2', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			scaleX: 2.0,
			scaleY: 1.6
		});
	} else {
		self.battleBackground = self.attachAsset('battlebackground3', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			scaleX: 3.4,
			scaleY: 2.0
		});
	}
	self.currentEnemy = null;
	self.karen = null;
	self.currentLevel = storage.currentLevel || 1;
	self.playerTurn = true;
	self.gameOver = false;
	self.startBattle = function (level) {
		// Clean up previous battle if exists
		if (self.karen) {
			self.removeChild(self.karen);
		}
		if (self.currentEnemy) {
			self.removeChild(self.currentEnemy);
		}
		// Reset state
		self.playerTurn = true;
		self.gameOver = false;
		// Set current level
		self.currentLevel = level;
		// Update background for the new level
		if (self.battleBackground) {
			self.removeChild(self.battleBackground);
		}
		if (level === 1) {
			self.battleBackground = self.attachAsset('battleBackground', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 0,
				y: 0,
				scaleX: 1.2,
				scaleY: 1.2
			});
		} else if (level === 2) {
			self.battleBackground = self.attachAsset('battlebackground2', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 0,
				y: 0,
				scaleX: 2.0,
				scaleY: 1.6
			});
		} else {
			self.battleBackground = self.attachAsset('battlebackground3', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 0,
				y: 0,
				scaleX: 3.4,
				scaleY: 2.0
			});
		}
		self.addChild(self.battleBackground);
		// Create karen with level-specific attacks
		self.karen = new Karen();
		// Update Karen's attacks based on level
		if (level === 1) {
			self.karen.attacks = [{
				name: "Demand Manager",
				damage: 20,
				description: "Karen SLAMS the counter, 'Where’s your MANAGER?!'"
			}, {
				name: "I know the owner !!",
				damage: 25,
				description: "Karen smirks smugly: 'I *know* the owner, sweetie.'"
			}, {
				name: "Write a 1 star review !",
				damage: 30,
				description: "'Enjoy your career-ending Yelp review!'"
			}, {
				name: "Your salary",
				damage: 35,
				description: "'With that attitude? You won’t even make minimum wage!'"
			}];
		} else if (level === 2) {
			self.karen.attacks = [{
				name: "Call the police",
				damage: 20,
				description: "'Yes, hello? There's a child playing.'"
			}, {
				name: "Talk to parents",
				damage: 25,
				description: "Karen yells: 'I DEMAND to speak with your parents—NOW!'"
			}, {
				name: "Faking getting hurt",
				damage: 35,
				special: true,
				description: "Karen screams : 'AHH! Assault! That child hurt me!"
			}, {
				name: "Private property",
				damage: 30,
				description: "Karen screeches: 'This is MY lawn! You’re trespassing!'"
			}];
		} else if (level === 3) {
			self.karen.attacks = [{
				name: "Unacceptable !!",
				damage: 25,
				description: "Karen screams 'UNACCEPTABLE!' at top volume"
			}, {
				name: "I know my rights !!",
				damage: 30,
				description: "Karen slams the rulebook: 'I KNOW my rights and this is ILLEGAL!'"
			}, {
				name: "Justice Attack",
				damage: 30,
				special: true,
				description: "Karen channels courtroom energy: 'I DEMAND JUSTICE!'"
			}, {
				name: "Total Refund",
				damage: 30,
				description: "Karen flips a table: 'I want a full refund. For EVERYTHING. Including my gas.'"
			}];
		}
		self.karen.x = -500;
		self.karen.y = 0;
		self.addChild(self.karen);
		// Create enemy based on level
		var enemyType;
		if (level === 1) {
			enemyType = "employee";
		} else if (level === 2) {
			enemyType = "kid";
		} else {
			enemyType = "manager";
		}
		self.currentEnemy = new Enemy(enemyType);
		self.currentEnemy.x = 500;
		self.currentEnemy.y = 0;
		self.addChild(self.currentEnemy);
		// Update UI
		battleUI.setMessage("A wild " + self.currentEnemy.name + " appears!");
		// Update button texts based on Karen's current attacks
		battleUI.attackButton1.text.setText(self.karen.attacks[0].name);
		battleUI.attackButton1.attackData = self.karen.attacks[0];
		battleUI.attackButton2.text.setText(self.karen.attacks[1].name);
		battleUI.attackButton2.attackData = self.karen.attacks[1];
		battleUI.attackButton3.text.setText(self.karen.attacks[2].name);
		battleUI.attackButton3.attackData = self.karen.attacks[2];
		battleUI.attackButton4.text.setText(self.karen.attacks[3].name);
		battleUI.attackButton4.attackData = self.karen.attacks[3];
		// Wait a moment then show "What will Karen do?"
		LK.setTimeout(function () {
			battleUI.setMessage("What will Karen do?");
		}, 2000);
		battleUI.enableButtons(true);
		battleUI.showMainMenu();
		// Play appropriate sound based on level
		if (level === 1) {
			LK.getSound('excuseme').play();
		} else if (level === 2) {
			LK.getSound('whatareyoudoing').play();
		} else if (level === 3) {
			LK.getSound('knwowhoiam').play();
		}
		// Stop any current music before playing new music
		LK.stopMusic();
		// Play level-specific music
		if (level === 1) {
			LK.playMusic('jingleremix');
		} else if (level === 2) {
			LK.playMusic('gtasound');
		} else if (level === 3) {
			LK.playMusic('office');
		}
	};
	self.executePlayerTurn = function (attack) {
		if (!self.playerTurn || self.gameOver) {
			return;
		}
		// Disable buttons during animation
		battleUI.enableButtons(false);
		// Show only attack description, not the name
		battleUI.setMessage(attack.description ? attack.description : "");
		// Play attack sound
		LK.getSound('attack').play();
		if (attack.name === "Demand Manager") {
			LK.getSound('askmanager').play();
		} else if (attack.name === "I know the owner !!") {
			LK.getSound('knowtheowner').play();
		} else if (attack.name === "Write a 1 star review !") {
			LK.getSound('writingreview').play();
		} else if (attack.name === "Your salary") {
			LK.getSound('payyoursalary').play();
		} else if (attack.name === "Security Please") {
			LK.getSound('securityplease').play();
		} else if (attack.name === "Complaint Form") {
			LK.getSound('complainform').play();
		} else if (attack.name === "Is there a Carin") {
			LK.getSound('istherecarin').play();
		} else if (attack.name === "Miss Calm Down") {
			LK.getSound('misscalmdown').play();
		} else if (attack.name === "Faking getting hurt") {
			LK.getSound('gettinghurt').play();
		} else if (attack.name === "Call the police") {
			LK.getSound('police').play();
		} else if (attack.name === "Talk to parents") {
			LK.getSound('talktoparents').play();
		} else if (attack.name === "Private property") {
			LK.getSound('privateproperty').play();
		} else if (attack.name === "Unacceptable !!") {
			LK.getSound('unacceptable').play();
		} else if (attack.name === "I know my rights !!") {
			LK.getSound('knowmyrights').play();
		} else if (attack.name === "Justice Attack") {
			LK.getSound('justiceattack').play();
		} else if (attack.name === "Total Refund") {
			LK.getSound('totalrefund').play();
		} else if (attack.name === "Ignore") {
			LK.getSound('ignoring').play();
		} else if (attack.name === "Ok Boomer") {
			LK.getSound('okboomer').play();
		} else if (attack.name === "Film For TikTok") {
			LK.getSound('viralontiktok').play();
		} else if (attack.name === "Skateboard Trick") {
			LK.getSound('affraidofaballoon').play();
		} else {
			LK.getSound(attack.special ? 'special' : 'attack').play();
		}
		// Animate karen
		tween(self.karen, {
			x: -300
		}, {
			duration: 300,
			onFinish: function onFinish() {
				tween(self.karen, {
					x: -500
				}, {
					duration: 300
				});
			}
		});
		// Deal damage after animation delay
		LK.setTimeout(function () {
			var damage = attack.damage;
			if (attack.special) {
				damage = Math.floor(damage * 1.5);
			}
			var actualDamage = self.currentEnemy.takeDamage(damage);
			// Removed damage message display
			// Check if enemy is defeated
			if (self.currentEnemy.health <= 0) {
				self.enemyDefeated();
			} else {
				// Switch to enemy turn after delay
				LK.setTimeout(function () {
					self.playerTurn = false;
					// Set message with enemy name before starting enemy turn
					battleUI.setMessage("What will " + self.currentEnemy.name + " do?");
					self.enemyTurn();
				}, 3000);
			}
		}, 600);
	};
	self.playerDefend = function () {
		if (!self.playerTurn || self.gameOver) {
			return;
		}
		// Disable buttons during animation
		battleUI.enableButtons(false);
		// Show defend message
		battleUI.setMessage("");
		// Play defend sound
		LK.getSound('defend').play();
		// Set defend flag
		self.karen.defend();
		// Visual feedback
		tween(self.karen.visual, {
			alpha: 0.7
		}, {
			duration: 300,
			onFinish: function onFinish() {
				tween(self.karen.visual, {
					alpha: 1
				}, {
					duration: 300
				});
			}
		});
		// Switch to enemy turn after delay
		LK.setTimeout(function () {
			self.playerTurn = false;
			self.enemyTurn();
		}, 3000);
	};
	self.playerSpecial = function () {
		if (!self.playerTurn || self.gameOver) {
			return;
		}
		// This is a special version of playerTurn for the "Speak to Manager" button
		// It will use the first special attack found
		for (var i = 0; i < self.karen.attacks.length; i++) {
			if (self.karen.attacks[i].special) {
				self.playerTurn(self.karen.attacks[i]);
				break;
			}
		}
	};
	self.enemyTurn = function () {
		if (self.playerTurn || self.gameOver) {
			return;
		}
		// Get enemy action
		var action = self.currentEnemy.chooseAction();
		// Show action message
		battleUI.setMessage(action.text);
		// Animate enemy
		tween(self.currentEnemy, {
			x: 300
		}, {
			duration: 300,
			onFinish: function onFinish() {
				tween(self.currentEnemy, {
					x: 500
				}, {
					duration: 300
				});
			}
		});
		// Process action after animation delay
		LK.setTimeout(function () {
			if (action.type === "attack") {
				// Play attack sound
				LK.getSound('attack').play();
				if (action.attack.name === "Is there a Carin") {
					LK.getSound('istherecarin').play();
				} else if (action.attack.name === "Security Please") {
					LK.getSound('securityplease').play();
				} else if (action.attack.name === "Miss Calm Down") {
					LK.getSound('misscalmdown').play();
				} else if (action.attack.name === "Complaint Form") {
					LK.getSound('complainform').play();
				} else if (action.attack.name === "Ignore" || action.attack.name === "Skateboard Trick" || action.attack.name === "Ok Boomer") {
					// Kid sounds could be added here if available
				} else if (action.attack.name === "Corporate Policy" || action.attack.name === "Security Call" || action.attack.name === "Lifetime Ban" || action.attack.name === "Record Incident") {
					// Manager sounds could be added here if available
				}
				// Deal damage
				var damage = action.attack.damage;
				var actualDamage = self.karen.takeDamage(damage);
				// Removed damage message display
				// Check if player is defeated
				if (self.karen.health <= 0) {
					self.playerDefeated();
				} else {
					// Switch to player turn after delay
					LK.setTimeout(function () {
						self.playerTurn = true;
						battleUI.setMessage("What will Karen do?");
						battleUI.enableButtons(true);
						battleUI.showMainMenu();
					}, 3000);
				}
			} else if (action.type === "defend") {
				// Play defend sound
				LK.getSound('defend').play();
				// Visual feedback
				tween(self.currentEnemy.visual, {
					alpha: 0.7
				}, {
					duration: 300,
					onFinish: function onFinish() {
						tween(self.currentEnemy.visual, {
							alpha: 1
						}, {
							duration: 300
						});
					}
				});
				// Switch to player turn after delay
				LK.setTimeout(function () {
					self.playerTurn = true;
					battleUI.setMessage("What will Karen do?");
					battleUI.enableButtons(true);
					battleUI.showMainMenu();
				}, 3000);
			}
		}, 600);
	};
	self.enemyDefeated = function () {
		self.gameOver = true;
		// Show victory message first
		battleUI.setMessage(self.currentEnemy.name + " has been defeated!");
		// Delay victory sound to avoid overlap with attack sound
		LK.setTimeout(function () {
			// Play victory sound after delay
			LK.getSound('victory').play();
		}, 1000);
		// Score system removed
		LK.setTimeout(function () {
			battleUI.setMessage("You won!");
			// Progress to next level if not on final level
			if (self.currentLevel < 3) {
				self.currentLevel++;
				storage.currentLevel = self.currentLevel;
				if (self.currentLevel > storage.highestLevel) {
					storage.highestLevel = self.currentLevel;
				}
				// Start next battle after delay
				LK.setTimeout(function () {
					self.startBattle(self.currentLevel);
				}, 2000);
			} else {
				// Game completed
				LK.setTimeout(function () {
					battleUI.setMessage("Congratulations! You've defeated everyone!");
					LK.setTimeout(function () {
						// Reset to level 1 for next game
						self.currentLevel = 1;
						storage.currentLevel = 1;
						LK.showYouWin();
					}, 2000);
				}, 2000);
			}
		}, 2000);
	};
	self.playerDefeated = function () {
		self.gameOver = true;
		// Play defeat sound
		LK.getSound('defeat').play();
		// Show defeat message
		battleUI.setMessage("Karen has been defeated!");
		// Reset to level 1
		self.currentLevel = 1;
		storage.currentLevel = 1;
		// Show game over after delay
		LK.setTimeout(function () {
			LK.showGameOver();
		}, 2000);
	};
	return self;
});
var BattleUI = Container.expand(function () {
	var self = Container.call(this);
	// Battle message text
	self.messageText = new Text2("", {
		size: 40,
		fill: 0xFFFFFF,
		font: "Impact"
	});
	self.messageText.anchor.set(0.5, 0);
	self.messageText.x = 0;
	self.messageText.y = -200;
	self.addChild(self.messageText);
	// Karen's attack buttons
	var karenMoves = [{
		name: "Demand Manager",
		damage: 20,
		defense: 0,
		description: "Karen demanded to see the manager!"
	}, {
		name: "I know the owner !!",
		damage: 25,
		defense: 0,
		description: "Karen claims to know the owner!"
	}, {
		name: "Write a 1 star review !",
		damage: 30,
		defense: 0,
		description: "Karen threatened a bad review!"
	}, {
		name: "Your salary",
		damage: 35,
		defense: 0,
		description: "Karen threatened about employee's salary!"
	}];
	self.attackButton1 = new BattleButton(karenMoves[0].name, -600, -80);
	self.attackButton1.attackData = karenMoves[0];
	self.attackButton1.scale.set(1.5, 1.5); // Increase button size
	self.attackButton1.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton1);
	self.attackButton2 = new BattleButton(karenMoves[1].name, -600, 80);
	self.attackButton2.attackData = karenMoves[1];
	self.attackButton2.scale.set(1.5, 1.5); // Increase button size
	self.attackButton2.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton2);
	self.attackButton3 = new BattleButton(karenMoves[2].name, 600, -80, 'attackButton');
	self.attackButton3.attackData = karenMoves[2];
	self.attackButton3.scale.set(1.5, 1.5); // Increase button size
	self.attackButton3.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton3);
	self.attackButton4 = new BattleButton(karenMoves[3].name, 600, 80, 'attackButton');
	self.attackButton4.attackData = karenMoves[3];
	self.attackButton4.scale.set(1.5, 1.5); // Increase button size
	self.attackButton4.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton4);
	self.setMessage = function (message) {
		// Use only the message box for displaying messages
		if (messageBox) {
			messageBox.setMessage(message);
			messageBox.show();
		}
	};
	self.enableButtons = function (enabled) {
		self.attackButton1.setEnabled(enabled);
		self.attackButton2.setEnabled(enabled);
		self.attackButton3.setEnabled(enabled);
		self.attackButton4.setEnabled(enabled);
	};
	self.hideMainMenu = function () {
		self.attackButton1.visible = false;
		self.attackButton2.visible = false;
		self.attackButton3.visible = false;
		self.attackButton4.visible = false;
	};
	self.showMainMenu = function () {
		self.attackButton1.visible = true;
		self.attackButton2.visible = true;
		self.attackButton3.visible = true;
		self.attackButton4.visible = true;
	};
	return self;
});
var Character = Container.expand(function (name, maxHealth, attacks) {
	var self = Container.call(this);
	self.name = name;
	self.maxHealth = maxHealth;
	self.health = maxHealth;
	self.attacks = attacks || [];
	self.isDefending = false;
	// Create visual representation
	self.visual = null;
	self.takeDamage = function (amount) {
		if (self.isDefending) {
			amount = Math.floor(amount / 2);
			self.isDefending = false;
		}
		self.health = Math.max(0, self.health - amount);
		// Visual feedback
		var damageEffect = LK.getAsset('damageEffect', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			alpha: 0.7
		});
		self.addChild(damageEffect);
		tween(damageEffect, {
			alpha: 0
		}, {
			duration: 500,
			onFinish: function onFinish() {
				damageEffect.destroy();
			}
		});
		// Update health bar if exists
		if (self.healthBar) {
			self.updateHealthBar();
		}
		LK.getSound('hit').play();
		return amount;
	};
	self.defend = function () {
		self.isDefending = true;
		LK.getSound('defend').play();
		return "defending";
	};
	self.heal = function (amount) {
		self.health = Math.min(self.maxHealth, self.health + amount);
		// Update health bar if exists
		if (self.healthBar) {
			self.updateHealthBar();
		}
		return amount;
	};
	self.getAttack = function (index) {
		return self.attacks[index];
	};
	self.createHealthBar = function () {
		// Create health bar background
		self.healthBarBg = LK.getAsset('healthBarBackground', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 300
		});
		self.addChild(self.healthBarBg);
		// Create health bar
		self.healthBar = LK.getAsset('healthBar', {
			anchorX: 0,
			anchorY: 0.5,
			x: -200,
			y: 300
		});
		self.addChild(self.healthBar);
		// Create health text
		self.healthText = new Text2(self.health + "/" + self.maxHealth, {
			size: 30,
			fill: 0xFFFFFF,
			font: "Impact"
		});
		self.healthText.anchor.set(0.5, 0.5);
		self.healthText.x = 0;
		self.healthText.y = 300;
		self.addChild(self.healthText);
		// Create name text
		self.nameText = new Text2(self.name, {
			size: 40,
			fill: 0xFFFFFF,
			font: "Impact"
		});
		self.nameText.anchor.set(0.5, 0.5);
		self.nameText.x = 0;
		self.nameText.y = 380;
		self.addChild(self.nameText);
	};
	self.updateHealthBar = function () {
		var healthPercent = self.health / self.maxHealth;
		self.healthBar.width = 400 * healthPercent;
		self.healthText.setText(self.health + "/" + self.maxHealth);
	};
	return self;
});
var Karen = Character.expand(function () {
	var self = Character.call(this, "Karen", 100, [{
		name: "Demand Manager",
		damage: 20,
		description: "Karen demanded to see the manager!"
	}, {
		name: "I know the owner !!",
		damage: 25,
		description: "Karen claims to know the owner!"
	}, {
		name: "Write a 1 star review !",
		damage: 30,
		description: "Karen threatened a bad review!"
	}, {
		name: "Your salary",
		damage: 35,
		description: "Karen threatened about employee's salary!"
	}]);
	self.visual = self.attachAsset('karen', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.createHealthBar();
	return self;
});
var Enemy = Character.expand(function (type) {
	var self = Character.call(this);
	if (type === "employee") {
		self = Character.call(this, "Fast Food Employee", 100, [{
			name: "Is there a Carin",
			damage: 0,
			defense: 15,
			description: "Asked if there is another Karen named Carin!"
		}, {
			name: "Security Please",
			damage: 30,
			defense: 0,
			description: "Called security for assistance!"
		}, {
			name: "Miss Calm Down",
			damage: 15,
			defense: 5,
			description: "Asked Karen to please calm down..."
		}, {
			name: "Complaint Form",
			damage: 25,
			defense: 0,
			description: "Offered a formal complaint form to fill."
		}]);
		self.visual = self.attachAsset('employee', {
			anchorX: 0.5,
			anchorY: 0.5
		});
	} else if (type === "kid") {
		self = Character.call(this, "Neighborhood Kid", 100, [{
			name: "Ignore",
			damage: 15,
			description: "Kid ignores Karen completely"
		}, {
			name: "Afraid of a Balloon",
			damage: 25,
			description: "Kid kidding Karen about her inner child fears"
		}, {
			name: "Ok Boomer",
			damage: 35,
			special: true,
			description: "Kid says 'OK Boomer' and keeps playing"
		}, {
			name: "Viral on TikTok",
			damage: 30,
			description: "Starts filming Karen for a viral TikTok"
		}]);
		self.visual = self.attachAsset('kid', {
			anchorX: 0.5,
			anchorY: 0.5
		});
	} else if (type === "manager") {
		self = Character.call(this, "The Manager", 120, [{
			name: "Give An Answer",
			damage: 20,
			description: "Says it'll take 6 weeks... and means it"
		}, {
			name: "The Rules",
			damage: 30,
			description: "Slaps Karen with the rulebook—literally"
		}, {
			name: "Protocol",
			damage: 40,
			special: true,
			description: "Drops a mountain of forms and walks away"
		}, {
			name: "Not My Problem",
			damage: 25,
			description: "Shrugs so hard it hurts Karen’s feelings"
		}]);
		self.visual = self.attachAsset('manager', {
			anchorX: 0.5,
			anchorY: 0.5
		});
	}
	self.createHealthBar();
	self.chooseAction = function () {
		// Simple AI - only choose attacks, no defend option
		// Choose a random attack
		var attackIndex = Math.floor(Math.random() * self.attacks.length);
		var attack = self.attacks[attackIndex];
		// Play correct sound for kid's attacks
		if (type === "kid" && attack.name === "Ignore") {
			LK.getSound('ignoring').play();
		} else if (type === "kid" && attack.name === "Ok Boomer") {
			LK.getSound('okboomer').play();
		} else if (type === "kid" && attack.name === "Afraid of a Balloon") {
			LK.getSound('affraidofaballoon').play();
		} else if (type === "kid" && attack.name === "Viral on TikTok") {
			LK.getSound('viralontiktok').play();
		} else if (type === "manager" && attack.name === "Give An Answer") {
			LK.getSound('giveananswer').play();
		} else if (type === "manager" && attack.name === "The Rules") {
			LK.getSound('therules').play();
		} else if (type === "manager" && attack.name === "Protocol") {
			LK.getSound('protocol').play();
		} else if (type === "manager" && attack.name === "Not My Problem") {
			LK.getSound('notmyproblem').play();
		}
		return {
			type: "attack",
			attack: attack,
			text: attack.description ? attack.description : ""
		};
	};
	return self;
});
var MainMenu = Container.expand(function () {
	var self = Container.call(this);
	// Add menu background
	self.background = self.attachAsset('menubackground', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Remove title and subtitle text for cleaner look
	// Start Button - bigger and lower on screen
	self.startButton = new BattleButton("Start Game", 0, 500, 'attackButton');
	self.startButton.scale.set(2.0, 2.0); // Make button significantly bigger
	self.startButton.onSelect = function () {
		self.onStartGame();
	};
	self.addChild(self.startButton);
	// Level select if player has unlocked additional levels
	self.levelButtons = [];
	self.updateLevelButtons = function () {
		// Clear existing buttons
		for (var i = 0; i < self.levelButtons.length; i++) {
			self.removeChild(self.levelButtons[i]);
		}
		self.levelButtons = [];
		// Empty function now - no level selection
	};
	// Default handler, will be overridden
	self.onStartGame = function () {
		console.log("Start game handler not set");
	};
	return self;
});
var MessageBox = Container.expand(function () {
	var self = Container.call(this);
	// Create message box background
	self.background = new Container();
	self.addChild(self.background);
	// Create a semi-transparent black background
	var bg = LK.getAsset('healthBarBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: 0,
		y: 0,
		alpha: 0.8
	});
	bg.width = 1800;
	bg.height = 250;
	self.background.addChild(bg);
	// Create message text
	self.messageText = new Text2("", {
		size: 60,
		fill: 0xFFFFFF,
		font: "Impact"
	});
	self.messageText.anchor.set(0.5, 0.5);
	self.addChild(self.messageText);
	// Set message function
	self.setMessage = function (message) {
		self.messageText.setText(message);
	};
	// Show animation
	self.show = function () {
		self.visible = true;
		self.alpha = 0;
		tween(self, {
			alpha: 1
		}, {
			duration: 300
		});
	};
	// Hide animation
	self.hide = function () {
		tween(self, {
			alpha: 0
		}, {
			duration: 300,
			onFinish: function onFinish() {
				self.visible = false;
			}
		});
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x222222
});
/**** 
* Game Code
****/ 
// Setup game state variables
var gameState = "menu"; // Can be "menu" or "battle"
var battleSystem, battleUI, attackMenu, messageBox;
// Create main menu
var mainMenu = new MainMenu();
mainMenu.x = 2048 / 2;
mainMenu.y = 2732 / 2;
game.addChild(mainMenu);
// Initialize menu level buttons based on storage data
mainMenu.updateLevelButtons();
// Handle starting the game from menu
mainMenu.onStartGame = function () {
	// Hide menu
	mainMenu.visible = false;
	// Change state
	gameState = "battle";
	// Create battle elements if they don't exist
	if (!battleSystem) {
		// Create main battle system
		battleSystem = new BattleSystem();
		battleSystem.x = 2048 / 2;
		battleSystem.y = 2732 / 2;
		game.addChild(battleSystem);
		// Create UI
		battleUI = new BattleUI();
		battleUI.x = 2048 / 2;
		battleUI.y = 2732 - 300;
		game.addChild(battleUI);
		// Create attack menu initially with null karen parameter
		attackMenu = new AttackMenu(null);
		attackMenu.x = 2048 / 2;
		attackMenu.y = 2732 - 300;
		game.addChild(attackMenu);
		// Create message box
		messageBox = new MessageBox();
		messageBox.x = 2048 / 2;
		messageBox.y = 2732 / 2 - 650; // Position higher above characters
		game.addChild(messageBox);
		// Level text removed
		// Scoreboard removed
	} else {
		// Make battle elements visible again
		battleSystem.visible = true;
		battleUI.visible = true;
		attackMenu.visible = false;
		messageBox.visible = true;
	}
	// Karen now uses direct attack buttons
	// Start the game with appropriate level
	battleSystem.startBattle(battleSystem.currentLevel);
	// Music is now handled in battleSystem.startBattle to avoid duplication
};
// Game update function 
game.update = function () {
	// Score system removed
}; /**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
	currentLevel: 1,
	highestLevel: 1
});
/**** 
* Classes
****/ 
var AttackMenu = Container.expand(function (karen) {
	var self = Container.call(this);
	self.visible = false;
	self.buttons = [];
	// Back button
	self.backButton = new BattleButton("Back", 0, 120, 'defendButton');
	self.backButton.onSelect = function () {
		self.hide();
		battleUI.showMainMenu();
	};
	self.addChild(self.backButton);
	self.showAttacks = function () {
		// Clear old attack buttons
		for (var i = 0; i < self.buttons.length; i++) {
			self.removeChild(self.buttons[i]);
		}
		self.buttons = [];
		// Create new attack buttons
		for (var i = 0; i < karen.attacks.length; i++) {
			var attack = karen.attacks[i];
			var yPos = -150 + i * 80;
			var btn = new BattleButton(attack.name, 0, yPos, attack.special ? 'specialButton' : 'attackButton');
			btn.attackIndex = i;
			btn.onSelect = function () {
				self.hide();
				battleSystem.executePlayerTurn(karen.getAttack(this.attackIndex));
			};
			self.addChild(btn);
			self.buttons.push(btn);
		}
		self.visible = true;
	};
	self.hide = function () {
		self.visible = false;
	};
	return self;
});
var BattleButton = Container.expand(function (text, x, y, color) {
	var self = Container.call(this);
	self.button = self.attachAsset(color || 'attackButton', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.text = new Text2(text, {
		size: 40,
		fill: 0xFFFFFF,
		font: "Impact"
	});
	self.text.anchor.set(0.5, 0.5);
	self.addChild(self.text);
	self.x = x;
	self.y = y;
	self.setEnabled = function (enabled) {
		self.alpha = enabled ? 1.0 : 0.5;
		self.enabled = enabled;
	};
	// Store original scale values when button is created
	self.originalScaleX = self.scale.x;
	self.originalScaleY = self.scale.y;
	self.down = function (x, y, obj) {
		if (!self.enabled) {
			return;
		}
		// Use button graphic scale change instead of the entire container
		tween(self.button, {
			scaleX: 0.9,
			scaleY: 0.9
		}, {
			duration: 100
		});
	};
	self.up = function (x, y, obj) {
		if (!self.enabled) {
			return;
		}
		// Reset button graphic scale instead of the entire container
		tween(self.button, {
			scaleX: 1.0,
			scaleY: 1.0
		}, {
			duration: 100
		});
		if (self.onSelect) {
			self.onSelect();
		}
	};
	self.setEnabled(true);
	return self;
});
var BattleSystem = Container.expand(function () {
	var self = Container.call(this);
	// Remove existing background if it exists
	if (self.battleBackground) {
		self.removeChild(self.battleBackground);
	}
	// Set background based on current level
	if (self.currentLevel === 1 || storage.currentLevel === 1) {
		self.battleBackground = self.attachAsset('battleBackground', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			scaleX: 1.2,
			scaleY: 1.2
		});
	} else if (self.currentLevel === 2 || storage.currentLevel === 2) {
		self.battleBackground = self.attachAsset('battlebackground2', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			scaleX: 2.0,
			scaleY: 1.6
		});
	} else {
		self.battleBackground = self.attachAsset('battlebackground3', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			scaleX: 3.4,
			scaleY: 2.0
		});
	}
	self.currentEnemy = null;
	self.karen = null;
	self.currentLevel = storage.currentLevel || 1;
	self.playerTurn = true;
	self.gameOver = false;
	self.startBattle = function (level) {
		// Clean up previous battle if exists
		if (self.karen) {
			self.removeChild(self.karen);
		}
		if (self.currentEnemy) {
			self.removeChild(self.currentEnemy);
		}
		// Reset state
		self.playerTurn = true;
		self.gameOver = false;
		// Set current level
		self.currentLevel = level;
		// Update background for the new level
		if (self.battleBackground) {
			self.removeChild(self.battleBackground);
		}
		if (level === 1) {
			self.battleBackground = self.attachAsset('battleBackground', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 0,
				y: 0,
				scaleX: 1.2,
				scaleY: 1.2
			});
		} else if (level === 2) {
			self.battleBackground = self.attachAsset('battlebackground2', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 0,
				y: 0,
				scaleX: 2.0,
				scaleY: 1.6
			});
		} else {
			self.battleBackground = self.attachAsset('battlebackground3', {
				anchorX: 0.5,
				anchorY: 0.5,
				x: 0,
				y: 0,
				scaleX: 3.4,
				scaleY: 2.0
			});
		}
		self.addChild(self.battleBackground);
		// Create karen with level-specific attacks
		self.karen = new Karen();
		// Update Karen's attacks based on level
		if (level === 1) {
			self.karen.attacks = [{
				name: "Demand Manager",
				damage: 20,
				description: "Karen SLAMS the counter, 'Where’s your MANAGER?!'"
			}, {
				name: "I know the owner !!",
				damage: 25,
				description: "Karen smirks smugly: 'I *know* the owner, sweetie.'"
			}, {
				name: "Write a 1 star review !",
				damage: 30,
				description: "'Enjoy your career-ending Yelp review!'"
			}, {
				name: "Your salary",
				damage: 35,
				description: "'With that attitude? You won’t even make minimum wage!'"
			}];
		} else if (level === 2) {
			self.karen.attacks = [{
				name: "Call the police",
				damage: 20,
				description: "'Yes, hello? There's a child playing.'"
			}, {
				name: "Talk to parents",
				damage: 25,
				description: "Karen yells: 'I DEMAND to speak with your parents—NOW!'"
			}, {
				name: "Faking getting hurt",
				damage: 35,
				special: true,
				description: "Karen screams : 'AHH! Assault! That child hurt me!"
			}, {
				name: "Private property",
				damage: 30,
				description: "Karen screeches: 'This is MY lawn! You’re trespassing!'"
			}];
		} else if (level === 3) {
			self.karen.attacks = [{
				name: "Unacceptable !!",
				damage: 25,
				description: "Karen screams 'UNACCEPTABLE!' at top volume"
			}, {
				name: "I know my rights !!",
				damage: 30,
				description: "Karen slams the rulebook: 'I KNOW my rights and this is ILLEGAL!'"
			}, {
				name: "Justice Attack",
				damage: 30,
				special: true,
				description: "Karen channels courtroom energy: 'I DEMAND JUSTICE!'"
			}, {
				name: "Total Refund",
				damage: 30,
				description: "Karen flips a table: 'I want a full refund. For EVERYTHING. Including my gas.'"
			}];
		}
		self.karen.x = -500;
		self.karen.y = 0;
		self.addChild(self.karen);
		// Create enemy based on level
		var enemyType;
		if (level === 1) {
			enemyType = "employee";
		} else if (level === 2) {
			enemyType = "kid";
		} else {
			enemyType = "manager";
		}
		self.currentEnemy = new Enemy(enemyType);
		self.currentEnemy.x = 500;
		self.currentEnemy.y = 0;
		self.addChild(self.currentEnemy);
		// Update UI
		battleUI.setMessage("A wild " + self.currentEnemy.name + " appears!");
		// Update button texts based on Karen's current attacks
		battleUI.attackButton1.text.setText(self.karen.attacks[0].name);
		battleUI.attackButton1.attackData = self.karen.attacks[0];
		battleUI.attackButton2.text.setText(self.karen.attacks[1].name);
		battleUI.attackButton2.attackData = self.karen.attacks[1];
		battleUI.attackButton3.text.setText(self.karen.attacks[2].name);
		battleUI.attackButton3.attackData = self.karen.attacks[2];
		battleUI.attackButton4.text.setText(self.karen.attacks[3].name);
		battleUI.attackButton4.attackData = self.karen.attacks[3];
		// Wait a moment then show "What will Karen do?"
		LK.setTimeout(function () {
			battleUI.setMessage("What will Karen do?");
		}, 2000);
		battleUI.enableButtons(true);
		battleUI.showMainMenu();
		// Play appropriate sound based on level
		if (level === 1) {
			LK.getSound('excuseme').play();
		} else if (level === 2) {
			LK.getSound('whatareyoudoing').play();
		} else if (level === 3) {
			LK.getSound('knwowhoiam').play();
		}
		// Stop any current music before playing new music
		LK.stopMusic();
		// Play level-specific music
		if (level === 1) {
			LK.playMusic('jingleremix');
		} else if (level === 2) {
			LK.playMusic('gtasound');
		} else if (level === 3) {
			LK.playMusic('office');
		}
	};
	self.executePlayerTurn = function (attack) {
		if (!self.playerTurn || self.gameOver) {
			return;
		}
		// Disable buttons during animation
		battleUI.enableButtons(false);
		// Show only attack description, not the name
		battleUI.setMessage(attack.description ? attack.description : "");
		// Play attack sound
		LK.getSound('attack').play();
		if (attack.name === "Demand Manager") {
			LK.getSound('askmanager').play();
		} else if (attack.name === "I know the owner !!") {
			LK.getSound('knowtheowner').play();
		} else if (attack.name === "Write a 1 star review !") {
			LK.getSound('writingreview').play();
		} else if (attack.name === "Your salary") {
			LK.getSound('payyoursalary').play();
		} else if (attack.name === "Security Please") {
			LK.getSound('securityplease').play();
		} else if (attack.name === "Complaint Form") {
			LK.getSound('complainform').play();
		} else if (attack.name === "Is there a Carin") {
			LK.getSound('istherecarin').play();
		} else if (attack.name === "Miss Calm Down") {
			LK.getSound('misscalmdown').play();
		} else if (attack.name === "Faking getting hurt") {
			LK.getSound('gettinghurt').play();
		} else if (attack.name === "Call the police") {
			LK.getSound('police').play();
		} else if (attack.name === "Talk to parents") {
			LK.getSound('talktoparents').play();
		} else if (attack.name === "Private property") {
			LK.getSound('privateproperty').play();
		} else if (attack.name === "Unacceptable !!") {
			LK.getSound('unacceptable').play();
		} else if (attack.name === "I know my rights !!") {
			LK.getSound('knowmyrights').play();
		} else if (attack.name === "Justice Attack") {
			LK.getSound('justiceattack').play();
		} else if (attack.name === "Total Refund") {
			LK.getSound('totalrefund').play();
		} else if (attack.name === "Ignore") {
			LK.getSound('ignoring').play();
		} else if (attack.name === "Ok Boomer") {
			LK.getSound('okboomer').play();
		} else if (attack.name === "Film For TikTok") {
			LK.getSound('viralontiktok').play();
		} else if (attack.name === "Skateboard Trick") {
			LK.getSound('affraidofaballoon').play();
		} else {
			LK.getSound(attack.special ? 'special' : 'attack').play();
		}
		// Animate karen
		tween(self.karen, {
			x: -300
		}, {
			duration: 300,
			onFinish: function onFinish() {
				tween(self.karen, {
					x: -500
				}, {
					duration: 300
				});
			}
		});
		// Deal damage after animation delay
		LK.setTimeout(function () {
			var damage = attack.damage;
			if (attack.special) {
				damage = Math.floor(damage * 1.5);
			}
			var actualDamage = self.currentEnemy.takeDamage(damage);
			// Removed damage message display
			// Check if enemy is defeated
			if (self.currentEnemy.health <= 0) {
				self.enemyDefeated();
			} else {
				// Switch to enemy turn after delay
				LK.setTimeout(function () {
					self.playerTurn = false;
					// Set message with enemy name before starting enemy turn
					battleUI.setMessage("What will " + self.currentEnemy.name + " do?");
					self.enemyTurn();
				}, 3000);
			}
		}, 600);
	};
	self.playerDefend = function () {
		if (!self.playerTurn || self.gameOver) {
			return;
		}
		// Disable buttons during animation
		battleUI.enableButtons(false);
		// Show defend message
		battleUI.setMessage("");
		// Play defend sound
		LK.getSound('defend').play();
		// Set defend flag
		self.karen.defend();
		// Visual feedback
		tween(self.karen.visual, {
			alpha: 0.7
		}, {
			duration: 300,
			onFinish: function onFinish() {
				tween(self.karen.visual, {
					alpha: 1
				}, {
					duration: 300
				});
			}
		});
		// Switch to enemy turn after delay
		LK.setTimeout(function () {
			self.playerTurn = false;
			self.enemyTurn();
		}, 3000);
	};
	self.playerSpecial = function () {
		if (!self.playerTurn || self.gameOver) {
			return;
		}
		// This is a special version of playerTurn for the "Speak to Manager" button
		// It will use the first special attack found
		for (var i = 0; i < self.karen.attacks.length; i++) {
			if (self.karen.attacks[i].special) {
				self.playerTurn(self.karen.attacks[i]);
				break;
			}
		}
	};
	self.enemyTurn = function () {
		if (self.playerTurn || self.gameOver) {
			return;
		}
		// Get enemy action
		var action = self.currentEnemy.chooseAction();
		// Show action message
		battleUI.setMessage(action.text);
		// Animate enemy
		tween(self.currentEnemy, {
			x: 300
		}, {
			duration: 300,
			onFinish: function onFinish() {
				tween(self.currentEnemy, {
					x: 500
				}, {
					duration: 300
				});
			}
		});
		// Process action after animation delay
		LK.setTimeout(function () {
			if (action.type === "attack") {
				// Play attack sound
				LK.getSound('attack').play();
				if (action.attack.name === "Is there a Carin") {
					LK.getSound('istherecarin').play();
				} else if (action.attack.name === "Security Please") {
					LK.getSound('securityplease').play();
				} else if (action.attack.name === "Miss Calm Down") {
					LK.getSound('misscalmdown').play();
				} else if (action.attack.name === "Complaint Form") {
					LK.getSound('complainform').play();
				} else if (action.attack.name === "Ignore" || action.attack.name === "Skateboard Trick" || action.attack.name === "Ok Boomer") {
					// Kid sounds could be added here if available
				} else if (action.attack.name === "Corporate Policy" || action.attack.name === "Security Call" || action.attack.name === "Lifetime Ban" || action.attack.name === "Record Incident") {
					// Manager sounds could be added here if available
				}
				// Deal damage
				var damage = action.attack.damage;
				var actualDamage = self.karen.takeDamage(damage);
				// Removed damage message display
				// Check if player is defeated
				if (self.karen.health <= 0) {
					self.playerDefeated();
				} else {
					// Switch to player turn after delay
					LK.setTimeout(function () {
						self.playerTurn = true;
						battleUI.setMessage("What will Karen do?");
						battleUI.enableButtons(true);
						battleUI.showMainMenu();
					}, 3000);
				}
			} else if (action.type === "defend") {
				// Play defend sound
				LK.getSound('defend').play();
				// Visual feedback
				tween(self.currentEnemy.visual, {
					alpha: 0.7
				}, {
					duration: 300,
					onFinish: function onFinish() {
						tween(self.currentEnemy.visual, {
							alpha: 1
						}, {
							duration: 300
						});
					}
				});
				// Switch to player turn after delay
				LK.setTimeout(function () {
					self.playerTurn = true;
					battleUI.setMessage("What will Karen do?");
					battleUI.enableButtons(true);
					battleUI.showMainMenu();
				}, 3000);
			}
		}, 600);
	};
	self.enemyDefeated = function () {
		self.gameOver = true;
		// Show victory message first
		battleUI.setMessage(self.currentEnemy.name + " has been defeated!");
		// Delay victory sound to avoid overlap with attack sound
		LK.setTimeout(function () {
			// Play victory sound after delay
			LK.getSound('victory').play();
		}, 1000);
		// Score system removed
		LK.setTimeout(function () {
			battleUI.setMessage("You won!");
			// Progress to next level if not on final level
			if (self.currentLevel < 3) {
				self.currentLevel++;
				storage.currentLevel = self.currentLevel;
				if (self.currentLevel > storage.highestLevel) {
					storage.highestLevel = self.currentLevel;
				}
				// Start next battle after delay
				LK.setTimeout(function () {
					self.startBattle(self.currentLevel);
				}, 2000);
			} else {
				// Game completed
				LK.setTimeout(function () {
					battleUI.setMessage("Congratulations! You've defeated everyone!");
					LK.setTimeout(function () {
						// Reset to level 1 for next game
						self.currentLevel = 1;
						storage.currentLevel = 1;
						LK.showYouWin();
					}, 2000);
				}, 2000);
			}
		}, 2000);
	};
	self.playerDefeated = function () {
		self.gameOver = true;
		// Play defeat sound
		LK.getSound('defeat').play();
		// Show defeat message
		battleUI.setMessage("Karen has been defeated!");
		// Reset to level 1
		self.currentLevel = 1;
		storage.currentLevel = 1;
		// Show game over after delay
		LK.setTimeout(function () {
			LK.showGameOver();
		}, 2000);
	};
	return self;
});
var BattleUI = Container.expand(function () {
	var self = Container.call(this);
	// Battle message text
	self.messageText = new Text2("", {
		size: 40,
		fill: 0xFFFFFF,
		font: "Impact"
	});
	self.messageText.anchor.set(0.5, 0);
	self.messageText.x = 0;
	self.messageText.y = -200;
	self.addChild(self.messageText);
	// Karen's attack buttons
	var karenMoves = [{
		name: "Demand Manager",
		damage: 20,
		defense: 0,
		description: "Karen demanded to see the manager!"
	}, {
		name: "I know the owner !!",
		damage: 25,
		defense: 0,
		description: "Karen claims to know the owner!"
	}, {
		name: "Write a 1 star review !",
		damage: 30,
		defense: 0,
		description: "Karen threatened a bad review!"
	}, {
		name: "Your salary",
		damage: 35,
		defense: 0,
		description: "Karen threatened about employee's salary!"
	}];
	self.attackButton1 = new BattleButton(karenMoves[0].name, -600, -80);
	self.attackButton1.attackData = karenMoves[0];
	self.attackButton1.scale.set(1.5, 1.5); // Increase button size
	self.attackButton1.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton1);
	self.attackButton2 = new BattleButton(karenMoves[1].name, -600, 80);
	self.attackButton2.attackData = karenMoves[1];
	self.attackButton2.scale.set(1.5, 1.5); // Increase button size
	self.attackButton2.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton2);
	self.attackButton3 = new BattleButton(karenMoves[2].name, 600, -80, 'attackButton');
	self.attackButton3.attackData = karenMoves[2];
	self.attackButton3.scale.set(1.5, 1.5); // Increase button size
	self.attackButton3.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton3);
	self.attackButton4 = new BattleButton(karenMoves[3].name, 600, 80, 'attackButton');
	self.attackButton4.attackData = karenMoves[3];
	self.attackButton4.scale.set(1.5, 1.5); // Increase button size
	self.attackButton4.onSelect = function () {
		self.hideMainMenu();
		battleSystem.executePlayerTurn(this.attackData);
	};
	self.addChild(self.attackButton4);
	self.setMessage = function (message) {
		// Use only the message box for displaying messages
		if (messageBox) {
			messageBox.setMessage(message);
			messageBox.show();
		}
	};
	self.enableButtons = function (enabled) {
		self.attackButton1.setEnabled(enabled);
		self.attackButton2.setEnabled(enabled);
		self.attackButton3.setEnabled(enabled);
		self.attackButton4.setEnabled(enabled);
	};
	self.hideMainMenu = function () {
		self.attackButton1.visible = false;
		self.attackButton2.visible = false;
		self.attackButton3.visible = false;
		self.attackButton4.visible = false;
	};
	self.showMainMenu = function () {
		self.attackButton1.visible = true;
		self.attackButton2.visible = true;
		self.attackButton3.visible = true;
		self.attackButton4.visible = true;
	};
	return self;
});
var Character = Container.expand(function (name, maxHealth, attacks) {
	var self = Container.call(this);
	self.name = name;
	self.maxHealth = maxHealth;
	self.health = maxHealth;
	self.attacks = attacks || [];
	self.isDefending = false;
	// Create visual representation
	self.visual = null;
	self.takeDamage = function (amount) {
		if (self.isDefending) {
			amount = Math.floor(amount / 2);
			self.isDefending = false;
		}
		self.health = Math.max(0, self.health - amount);
		// Visual feedback
		var damageEffect = LK.getAsset('damageEffect', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 0,
			alpha: 0.7
		});
		self.addChild(damageEffect);
		tween(damageEffect, {
			alpha: 0
		}, {
			duration: 500,
			onFinish: function onFinish() {
				damageEffect.destroy();
			}
		});
		// Update health bar if exists
		if (self.healthBar) {
			self.updateHealthBar();
		}
		LK.getSound('hit').play();
		return amount;
	};
	self.defend = function () {
		self.isDefending = true;
		LK.getSound('defend').play();
		return "defending";
	};
	self.heal = function (amount) {
		self.health = Math.min(self.maxHealth, self.health + amount);
		// Update health bar if exists
		if (self.healthBar) {
			self.updateHealthBar();
		}
		return amount;
	};
	self.getAttack = function (index) {
		return self.attacks[index];
	};
	self.createHealthBar = function () {
		// Create health bar background
		self.healthBarBg = LK.getAsset('healthBarBackground', {
			anchorX: 0.5,
			anchorY: 0.5,
			x: 0,
			y: 300
		});
		self.addChild(self.healthBarBg);
		// Create health bar
		self.healthBar = LK.getAsset('healthBar', {
			anchorX: 0,
			anchorY: 0.5,
			x: -200,
			y: 300
		});
		self.addChild(self.healthBar);
		// Create health text
		self.healthText = new Text2(self.health + "/" + self.maxHealth, {
			size: 30,
			fill: 0xFFFFFF,
			font: "Impact"
		});
		self.healthText.anchor.set(0.5, 0.5);
		self.healthText.x = 0;
		self.healthText.y = 300;
		self.addChild(self.healthText);
		// Create name text
		self.nameText = new Text2(self.name, {
			size: 40,
			fill: 0xFFFFFF,
			font: "Impact"
		});
		self.nameText.anchor.set(0.5, 0.5);
		self.nameText.x = 0;
		self.nameText.y = 380;
		self.addChild(self.nameText);
	};
	self.updateHealthBar = function () {
		var healthPercent = self.health / self.maxHealth;
		self.healthBar.width = 400 * healthPercent;
		self.healthText.setText(self.health + "/" + self.maxHealth);
	};
	return self;
});
var Karen = Character.expand(function () {
	var self = Character.call(this, "Karen", 100, [{
		name: "Demand Manager",
		damage: 20,
		description: "Karen demanded to see the manager!"
	}, {
		name: "I know the owner !!",
		damage: 25,
		description: "Karen claims to know the owner!"
	}, {
		name: "Write a 1 star review !",
		damage: 30,
		description: "Karen threatened a bad review!"
	}, {
		name: "Your salary",
		damage: 35,
		description: "Karen threatened about employee's salary!"
	}]);
	self.visual = self.attachAsset('karen', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.createHealthBar();
	return self;
});
var Enemy = Character.expand(function (type) {
	var self = Character.call(this);
	if (type === "employee") {
		self = Character.call(this, "Fast Food Employee", 100, [{
			name: "Is there a Carin",
			damage: 0,
			defense: 15,
			description: "Asked if there is another Karen named Carin!"
		}, {
			name: "Security Please",
			damage: 30,
			defense: 0,
			description: "Called security for assistance!"
		}, {
			name: "Miss Calm Down",
			damage: 15,
			defense: 5,
			description: "Asked Karen to please calm down..."
		}, {
			name: "Complaint Form",
			damage: 25,
			defense: 0,
			description: "Offered a formal complaint form to fill."
		}]);
		self.visual = self.attachAsset('employee', {
			anchorX: 0.5,
			anchorY: 0.5
		});
	} else if (type === "kid") {
		self = Character.call(this, "Neighborhood Kid", 100, [{
			name: "Ignore",
			damage: 15,
			description: "Kid ignores Karen completely"
		}, {
			name: "Afraid of a Balloon",
			damage: 25,
			description: "Kid kidding Karen about her inner child fears"
		}, {
			name: "Ok Boomer",
			damage: 35,
			special: true,
			description: "Kid says 'OK Boomer' and keeps playing"
		}, {
			name: "Viral on TikTok",
			damage: 30,
			description: "Starts filming Karen for a viral TikTok"
		}]);
		self.visual = self.attachAsset('kid', {
			anchorX: 0.5,
			anchorY: 0.5
		});
	} else if (type === "manager") {
		self = Character.call(this, "The Manager", 120, [{
			name: "Give An Answer",
			damage: 20,
			description: "Says it'll take 6 weeks... and means it"
		}, {
			name: "The Rules",
			damage: 30,
			description: "Slaps Karen with the rulebook—literally"
		}, {
			name: "Protocol",
			damage: 40,
			special: true,
			description: "Drops a mountain of forms and walks away"
		}, {
			name: "Not My Problem",
			damage: 25,
			description: "Shrugs so hard it hurts Karen’s feelings"
		}]);
		self.visual = self.attachAsset('manager', {
			anchorX: 0.5,
			anchorY: 0.5
		});
	}
	self.createHealthBar();
	self.chooseAction = function () {
		// Simple AI - only choose attacks, no defend option
		// Choose a random attack
		var attackIndex = Math.floor(Math.random() * self.attacks.length);
		var attack = self.attacks[attackIndex];
		// Play correct sound for kid's attacks
		if (type === "kid" && attack.name === "Ignore") {
			LK.getSound('ignoring').play();
		} else if (type === "kid" && attack.name === "Ok Boomer") {
			LK.getSound('okboomer').play();
		} else if (type === "kid" && attack.name === "Afraid of a Balloon") {
			LK.getSound('affraidofaballoon').play();
		} else if (type === "kid" && attack.name === "Viral on TikTok") {
			LK.getSound('viralontiktok').play();
		} else if (type === "manager" && attack.name === "Give An Answer") {
			LK.getSound('giveananswer').play();
		} else if (type === "manager" && attack.name === "The Rules") {
			LK.getSound('therules').play();
		} else if (type === "manager" && attack.name === "Protocol") {
			LK.getSound('protocol').play();
		} else if (type === "manager" && attack.name === "Not My Problem") {
			LK.getSound('notmyproblem').play();
		}
		return {
			type: "attack",
			attack: attack,
			text: attack.description ? attack.description : ""
		};
	};
	return self;
});
var MainMenu = Container.expand(function () {
	var self = Container.call(this);
	// Add menu background
	self.background = self.attachAsset('menubackground', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	// Remove title and subtitle text for cleaner look
	// Start Button - bigger and lower on screen
	self.startButton = new BattleButton("Start Game", 0, 500, 'attackButton');
	self.startButton.scale.set(2.0, 2.0); // Make button significantly bigger
	self.startButton.onSelect = function () {
		self.onStartGame();
	};
	self.addChild(self.startButton);
	// Level select if player has unlocked additional levels
	self.levelButtons = [];
	self.updateLevelButtons = function () {
		// Clear existing buttons
		for (var i = 0; i < self.levelButtons.length; i++) {
			self.removeChild(self.levelButtons[i]);
		}
		self.levelButtons = [];
		// Empty function now - no level selection
	};
	// Default handler, will be overridden
	self.onStartGame = function () {
		console.log("Start game handler not set");
	};
	return self;
});
var MessageBox = Container.expand(function () {
	var self = Container.call(this);
	// Create message box background
	self.background = new Container();
	self.addChild(self.background);
	// Create a semi-transparent black background
	var bg = LK.getAsset('healthBarBackground', {
		anchorX: 0.5,
		anchorY: 0.5,
		x: 0,
		y: 0,
		alpha: 0.8
	});
	bg.width = 1800;
	bg.height = 250;
	self.background.addChild(bg);
	// Create message text
	self.messageText = new Text2("", {
		size: 60,
		fill: 0xFFFFFF,
		font: "Impact"
	});
	self.messageText.anchor.set(0.5, 0.5);
	self.addChild(self.messageText);
	// Set message function
	self.setMessage = function (message) {
		self.messageText.setText(message);
	};
	// Show animation
	self.show = function () {
		self.visible = true;
		self.alpha = 0;
		tween(self, {
			alpha: 1
		}, {
			duration: 300
		});
	};
	// Hide animation
	self.hide = function () {
		tween(self, {
			alpha: 0
		}, {
			duration: 300,
			onFinish: function onFinish() {
				self.visible = false;
			}
		});
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0x222222
});
/**** 
* Game Code
****/ 
// Setup game state variables
var gameState = "menu"; // Can be "menu" or "battle"
var battleSystem, battleUI, attackMenu, messageBox;
// Create main menu
var mainMenu = new MainMenu();
mainMenu.x = 2048 / 2;
mainMenu.y = 2732 / 2;
game.addChild(mainMenu);
// Initialize menu level buttons based on storage data
mainMenu.updateLevelButtons();
// Handle starting the game from menu
mainMenu.onStartGame = function () {
	// Hide menu
	mainMenu.visible = false;
	// Change state
	gameState = "battle";
	// Create battle elements if they don't exist
	if (!battleSystem) {
		// Create main battle system
		battleSystem = new BattleSystem();
		battleSystem.x = 2048 / 2;
		battleSystem.y = 2732 / 2;
		game.addChild(battleSystem);
		// Create UI
		battleUI = new BattleUI();
		battleUI.x = 2048 / 2;
		battleUI.y = 2732 - 300;
		game.addChild(battleUI);
		// Create attack menu initially with null karen parameter
		attackMenu = new AttackMenu(null);
		attackMenu.x = 2048 / 2;
		attackMenu.y = 2732 - 300;
		game.addChild(attackMenu);
		// Create message box
		messageBox = new MessageBox();
		messageBox.x = 2048 / 2;
		messageBox.y = 2732 / 2 - 650; // Position higher above characters
		game.addChild(messageBox);
		// Level text removed
		// Scoreboard removed
	} else {
		// Make battle elements visible again
		battleSystem.visible = true;
		battleUI.visible = true;
		attackMenu.visible = false;
		messageBox.visible = true;
	}
	// Karen now uses direct attack buttons
	// Start the game with appropriate level
	battleSystem.startBattle(battleSystem.currentLevel);
	// Music is now handled in battleSystem.startBattle to avoid duplication
};
// Game update function 
game.update = function () {
	// Score system removed
};
:quality(85)/https://cdn.frvr.ai/68092031a35fff5118d2367e.png%3F3) 
 karen a white blonde woman from the meme "karen" screaming and point her finger to the right. Single Game Texture. In-Game asset. 2d. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/680a07bef56782f2a7c1d258.png%3F3) 
 kid with a ball Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/6809d74bf43c19059935a298.png%3F3) 
 :quality(85)/https://cdn.frvr.ai/68092071a35fff5118d23699.png%3F3) 
 fast food employee. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/680a497c19270306bf2414aa.png%3F3) 
 insde manager office. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
:quality(85)/https://cdn.frvr.ai/680a612776ced24387a1c01a.png%3F3) 
 manager character upper body part. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
excuseme
Sound effect
writingreview
Sound effect
unacceptable
Sound effect
askmanager
Sound effect
payyoursalary
Sound effect
knowmyrights
Sound effect
knowtheowner
Sound effect
securityplease
Sound effect
istherecarin
Sound effect
misscalmdown
Sound effect
complainform
Sound effect
whatareyoudoing
Sound effect
police
Sound effect
talktoparents
Sound effect
privateproperty
Sound effect
gettinghurt
Sound effect
victory
Sound effect
ignoring
Sound effect
okboomer
Sound effect
viralontiktok
Sound effect
affraidofaballoon
Sound effect
protocol
Sound effect
giveananswer
Sound effect
therules
Sound effect
justiceattack
Sound effect
incompetent
Sound effect
totalrefund
Sound effect
notmyproblem
Sound effect
knwowhoiam
Sound effect
jingleremix
Music
gtasound
Music
office
Music