/* --- GLOBAL & UTILITY STYLES --- */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

body {
	background: linear-gradient(to bottom, #2563eb, #1d4ed8, #1e3a8a);
	min-height: 100vh;
	font-family: Arial, sans-serif;
	padding: 16px;
	overflow-x: hidden;
}

.container {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 16px;
}

/* --- MAIN LAYOUT --- */
/* CORRECTED: Use Flexbox to center the content block. This is the key fix. */
.equipment-interface {
	display: flex;
	justify-content: center;
	/* This will center the character-container horizontally */
	margin-bottom: 32px;
}

/* --- CHARACTER & EQUIPMENT GRID --- */
.character-container {
	display: grid;
	grid-template-columns: repeat(5, 1fr);
	grid-template-rows: repeat(4, 1fr);
	gap: 13px;
	width: 100%;
	/* Take up the full width of the parent flex item */
	max-width: 480px;
	/* Control the maximum size on mobile */
	aspect-ratio: 5 / 4;
	position: relative;
}

.character-image {
	grid-column: 2 / 5;
	grid-row: 1 / 5;
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 10%;
	position: relative;
}

.character-image::before {
	content: '';
	position: absolute;
	inset: 10%;
	background: linear-gradient(to bottom right, transparent, transparent, rgba(0, 0, 0, 0.2));
	border-radius: 12px;
}

/* --- EQUIPMENT SLOT PLACEMENT --- */
.equipment-slot {
	position: relative;
	width: 100%;
	height: 100%;
	cursor: pointer;
	transition: transform 0.2s;
}

.equipment-slot:hover {
	transform: scale(1.05);
	z-index: 10;
}

.mainhand {
	grid-area: 1 / 1 / 2 / 2;
}

.helmet {
	grid-area: 2 / 1 / 3 / 2;
}

.armor {
	grid-area: 3 / 1 / 4 / 2;
}

.boots {
	grid-area: 4 / 1 / 5 / 2;
}

.offhand {
	grid-area: 1 / 5 / 2 / 6;
}

.accessory1 {
	grid-area: 2 / 5 / 3 / 6;
}

.accessory2 {
	grid-area: 3 / 5 / 4 / 6;
}

.accessory3 {
	grid-area: 4 / 5 / 5 / 6;
}


/* --- SLOT & JEWEL VISUAL STYLES --- */
.slot-frame {
	width: 100%;
	height: 100%;
	background: linear-gradient(to bottom, #fbbf24, #f59e0b, #d97706);
	border-radius: 8px;
	padding: 4px;
}

.slot-inner {
	width: 100%;
	height: 100%;
	background: linear-gradient(to bottom, #6b7280, #374151);
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.slot-inner img {
	width: 90%;
	height: 90%;
	object-fit: contain;
}

.slot-equipped {
	background: linear-gradient(to bottom, #8b5cf6, #7c3aed) !important;
	border: 2px solid #a78bfa;
}

.slot-plus {
	position: absolute;
	width: 24px;
	height: 24px;
	top: -4px;
	right: -4px;
	background: #10b981;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid #34d399;
	font-weight: bold;
	color: white;
	font-size: 14px;
}

.jewel-slots-left,
.jewel-slots-right {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	flex-direction: column;
	gap: 4px;
	z-index: 5;
}

.jewel-slots-left {
	right: 100%;
	margin-right: 6px;
}

.jewel-slots-right {
	left: 100%;
	margin-left: 6px;
}

.jewel-slot {
	width: 20px;
	height: 20px;
	background: #6b7280;
	border: 2px solid #facc15;
	border-radius: 50%;
	box-shadow: inset 0 0 4px rgba(255, 255, 255, 0.3);
	cursor: pointer;
	transition: transform 0.2s;
}

.jewel-slot:hover {
	transform: scale(1.1);
}

/* --- ACTION BUTTONS & ATTRIBUTE DISPLAY --- */
.action-buttons {
	display: flex;
	gap: 16px;
	justify-content: center;
	margin-bottom: 32px;
	flex-wrap: wrap;
}

.action-button {
	padding: 12px 32px;
	font-size: 16px;
	font-weight: bold;
	border: none;
	border-radius: 12px;
	cursor: pointer;
	transition: all 0.2s;
	box-shadow: 0 8px 16px -4px rgba(0, 0, 0, 0.3);
}

.clear-button {
	background: linear-gradient(to bottom, #14b8a6, #0d9488);
	color: white;
	border: 4px solid #5eead4;
}

.action-button:hover {
	transform: translateY(-2px);
}

/* CORRECTED: Center the attribute display using margin: auto */
.attribute-display {
	width: 100%;
	max-width: 500px;
	margin: 0 auto;
	/* This ensures it's centered independently */
}

.attribute-frame {
	background: linear-gradient(to bottom, #fbbf24, #f59e0b, #d97706);
	border-radius: 16px;
	padding: 4px;
}

.attribute-inner {
	background: linear-gradient(to bottom, rgba(30, 58, 138, 0.9), rgba(30, 64, 175, 0.95));
	border-radius: 12px;
	padding: 24px;
}

.attribute-title {
	color: #fde68a;
	font-weight: bold;
	font-size: 1.25rem;
	text-align: center;
	margin-bottom: 16px;
	text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.stats-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
}

.stat-item {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: rgba(0, 0, 0, 0.2);
	border-radius: 8px;
	padding: 12px;
	border: 1px solid rgba(234, 179, 8, 0.3);
}

.stat-name {
	color: #fef3c7;
	font-weight: 500;
	font-size: 1rem;
}

.stat-value {
	color: #fde047;
	font-weight: bold;
	font-size: 1rem;
}

.no-equipment {
	color: #d1d5db;
	text-align: center;
	padding: 32px;
	font-size: 1rem;
	grid-column: 1 / -1;
}

/* --- POPUP STYLES (Unchanged) --- */
.popup-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, .5);
	-webkit-backdrop-filter: blur(4px);
	backdrop-filter: blur(4px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 50;
	display: none
}

.popup-overlay.active {
	display: flex
}

.popup-content {
	background: linear-gradient(to bottom right, #475569, #334155);
	border: 2px solid #fbbf24;
	border-radius: 16px;
	padding: 16px;
	max-width: 90%;
	width: 100%;
	max-height: 80vh;
	overflow-y: auto;
	margin: 16px
}

.popup-header {
	display: flex;
	align-items: center;
	justify-content: center;
	margin-bottom: 16px;
	flex-direction: column;
	flex-wrap: wrap;
	align-content: center
}

.close-button {
	width: 28px;
	height: 28px;
	background: #ef4444;
	border-radius: 50%;
	border: none;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: #fff;
	font-size: 14px;
	transition: background .2s
}

.close-button:hover {
	background: #dc2626
}

.equipment-list {
	display: flex;
	flex-direction: column;
	gap: 12px
}

.equipment-item {
	background: linear-gradient(to right, rgba(71, 85, 105, .5), rgba(51, 65, 85, .5));
	border: 1px solid #64748b;
	border-radius: 8px;
	padding: 12px;
	cursor: pointer;
	transition: all .2s;
	display: flex;
	align-items: center;
	gap: 12px
}

.equipment-item:hover {
	border-color: #fbbf24;
	box-shadow: 0 4px 12px rgba(0, 0, 0, .3)
}

.equipment-icon {
	width: 48px;
	height: 48px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	border: 2px solid
}

.common {
	background: linear-gradient(to bottom right, #6b7280, #4b5563);
	border-color: #9ca3af
}

.uncommon {
	background: linear-gradient(to bottom right, #34d399, #10b981);
	border-color: #057E24
}

.rare {
	background: linear-gradient(to bottom right, #3b82f6, #2563eb);
	border-color: #324E8F
}

.epic {
	background: linear-gradient(to bottom right, #8b5cf6, #7c3aed);
	border-color: #773184
}

.legendary {
	background: linear-gradient(to bottom right, #f59e0b, #d97706);
	border-color: #BD9319
}

.mythic {
	background: linear-gradient(to bottom right, #f97316, #ea580c);
	border-color: #D25B16
}

.tempered {
	background: linear-gradient(to bottom right, #22d3ee, #06b6d4);
	border-color: #65B7F1
}

.equipment-details {
	flex: 1
}

.equipment-name {
	color: #fde68a;
	font-weight: 700;
	font-size: 16px;
	margin-bottom: 4px
}

.equipment-level {
	color: #fbbf24;
	font-size: 12px;
	margin-bottom: 8px
}

.equipment-stats {
	display: flex;
	flex-direction: column;
	gap: 4px
}

.equipment-stat {
	display: flex;
	justify-content: space-between;
	font-size: 12px
}

.equipment-stat-name {
	color: #cbd5e1
}

.equipment-stat-value {
	color: #fde047;
	font-weight: 600
}

.equip-button {
	width: 28px;
	height: 28px;
	background: #d97706;
	border: 1px solid #fbbf24;
	border-radius: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: background .2s
}

.equip-button:hover {
	background: #f59e0b
}

.rarity-button {
	padding: 8px 16px;
	border: 2px solid;
	border-radius: 0;
	cursor: pointer;
	transition: all .3s ease;
	position: relative;
	clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center
}

.rarity-button.common {
	background-image: url(https://static.wikia.nocookie.net/lordsmobile/images/5/5f/Common.png)
}

.rarity-button.common,
.rarity-button.epic,
.rarity-button.legendary,
.rarity-button.mythic,
.rarity-button.rare,
.rarity-button.tempered,
.rarity-button.uncommon {
	background-size: cover;
	background-position: center
}

.rarity-button.uncommon {
	background-image: url(https://static.wikia.nocookie.net/lordsmobile/images/4/40/Uncommon.png)
}

.rarity-button.rare {
	background-image: url(https://static.wikia.nocookie.net/lordsmobile/images/9/9f/Rare.png)
}

.rarity-button.epic {
	background-image: url(https://static.wikia.nocookie.net/lordsmobile/images/2/26/Epic.png)
}

.rarity-button.legendary {
	background-image: url(https://static.wikia.nocookie.net/lordsmobile/images/e/e2/Legendary.png)
}

.rarity-button.mythic {
	background-image: url(https://static.wikia.nocookie.net/lordsmobile/images/e/ec/Mythic.png)
}

.rarity-button.tempered {
	background-image: url(https://static.wikia.nocookie.net/lordsmobile/images/4/47/Temper.png)
}

.rarity-button:active {
	box-shadow: 0 0 15px 5px rgba(255, 255, 255, .8), 0 0 20px 10px rgba(255, 255, 255, .6), inset 0 0 10px 5px rgba(255, 255, 255, .4);
	transform: scale(1.05)
}

.rarity-buttons {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
	justify-content: center
}

.jewel-list {
	display: flex;
	flex-direction: column;
	gap: 10px
}

.jewel-item {
	background: linear-gradient(to right, #4b5563, #374151);
	border: 1px solid #9ca3af;
	border-radius: 8px;
	padding: 10px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	cursor: pointer;
	transition: all .2s
}

.jewel-item:hover {
	border-color: #facc15;
	background: #1f2937;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .3)
}

#jewelPopup .popup-content {
	max-width: 90%;
	width: 100%;
	padding: 16px
}

#jewelList .jewel-item {
	padding: 8px;
	background-color: #1e293b;
	border-radius: 8px;
	margin-bottom: 8px;
	border: 1px solid #334155
}

/* --- RESPONSIVE BREAKPOINTS --- */
/* CORRECTED: Media queries now only adjust size and spacing, not layout. */

@media (min-width: 540px) {
	.stats-grid {
		grid-template-columns: 1fr 1fr;
	}
}

/* Tablet layout */
@media (min-width: 768px) {
	.character-container {
		max-width: 600px;
		gap: 16px;
		/* Increase gap for more breathing room */
	}

	.attribute-display {
		max-width: 600px;
	}
}

/* Desktop layout */
@media (min-width: 1024px) {
	.character-container {
		max-width: 700px;
		/* Allow the grid to grow larger on desktop */
		gap: 20px;
		/* Further increase the gap */
	}

	.attribute-display {
		max-width: 700px;
	}

	.jewel-slot {
		width: 24px;
		height: 24px;
	}
}